忽略德语mobile.htm

ct-mobile-first
LMR 5 years ago
parent 621ccd6535
commit 06d7555434

@ -18,7 +18,7 @@ class Cache extends CI_Controller
private $current_domain = '';
//文件更新日期
private $file_time = array();
function __construct()
{
parent::__construct();
@ -28,7 +28,7 @@ class Cache extends CI_Controller
$this->load->model('Information_model');
$this->site_code = $this->config->item('site_code');
}
/**
*
* 公有函数:扫描已有缓存文件并更新。
@ -36,14 +36,14 @@ class Cache extends CI_Controller
* 必要参数:
* @param String $site_code
*
*/
*/
public function update()
{
//设置缓存文件文件夹
$cache_config = $this->config->item('cache');
$current_cache_config = $cache_config[$this->site_code];
$this->dir = $current_cache_config['cache_path'];
//设置当前站点
$this->current_domain = $this->config->item('site_url');
//echo $this->config->item('site_url');
@ -58,18 +58,18 @@ class Cache extends CI_Controller
//die();
//按目录筛选结果
$this->filter($this->file, $this->path);
//整理需要传递到视图的数据
$data['file'] = $this->file;
$data['path'] = $this->path;
$data['file_time'] = $this->file_time;
$data['cache_api'] = $this->cache_api;
$data['post_para'] = $this->post_para;
//视图
$this->load->view('cache/update', $data);
}
/**
*
* 公有函数:扫描已有缓存文件并更新。
@ -77,7 +77,7 @@ class Cache extends CI_Controller
* 必要参数:
* @param String $site_code
*
*/
*/
public function sitemap()
{
header("Content-type:text/xml");
@ -85,7 +85,7 @@ class Cache extends CI_Controller
$cache_config = $this->config->item('cache');
$current_cache_config = $cache_config[$this->site_code];
$this->dir = $current_cache_config['cache_path'];
//设置当前站点
$this->current_domain = $this->config->item('site_url');
//设置缓存更新接口及POST参数
@ -95,7 +95,7 @@ class Cache extends CI_Controller
$this->tree($this->dir, $this->file, $this->path, $this->file_time);
//按目录筛选结果
$this->filter($this->file, $this->path);
//整理需要传递到视图的数据
$data['file'] = $this->file;
$data['path'] = $this->path;
@ -104,25 +104,23 @@ class Cache extends CI_Controller
$data['post_para'] = $this->post_para;
//排序file数组
sort ($data['file']);
sort($data['file']);
//生成sitemap
$dom = new DomDocument('1.0', 'utf-8');
$urlset = $dom->createElement('urlset');
$urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
$dom->appendchild($urlset);
foreach ($data['file'] as $f)
{
foreach ($data['file'] as $f) {
$url = $dom->createElement('url');
$loc = $dom->createElement('loc');
$text = $dom->createTextNode($f);
$loc->appendchild($text);
$url->appendchild($loc);
$urlset->appendchild($url);
}
}
echo($dom->saveXML());
echo ($dom->saveXML());
}
@ -136,25 +134,20 @@ class Cache extends CI_Controller
* @param Array $path - 存放路径结果的数组引用
* @param Array $file_time - 存放文件更新日期的数组引用
*
*/
*/
private function tree($dir, &$file, &$path, &$file_time)
{
$mydir = dir($dir);
while($f = $mydir->read())
{
if(is_dir("$dir/$f") && $f!="." && $f!=".." && (strpos($dir, '/cn/')===false) && (strpos($dir, '/amp/')===false))
{
while ($f = $mydir->read()) {
if (is_dir("$dir/$f") && $f != "." && $f != ".." && (strpos($dir, '/cn/') === false) && (strpos($dir, '/amp/') === false)) {
$path[] = "$dir/$f";
$this->tree("$dir/$f", $file, $path, $file_time);
}
else
{
if ($f!='.' && $f!='..' && (strpos($dir, '/cn/')===false) && (strpos($dir, '/amp/')===false) && (strpos($f, '.pdf')===false))
{
$file_temp = str_replace('/index.htm###', '', $f.'###');
} else {
if ($f != '.' && $f != '..' && (strpos($dir, '/cn/') === false) && (strpos($dir, '/amp/') === false) && (strpos($f, '.pdf') === false) && (strpos($f, '.mobile.htm') === false)) {
$file_temp = str_replace('/index.htm###', '', $f . '###');
$file_temp = str_replace('###', '', $file_temp);
$path_temp = str_replace($this->dir, '', $dir);
$url_temp = $this->current_domain.$path_temp.'/'.$file_temp;
$url_temp = $this->current_domain . $path_temp . '/' . $file_temp;
$url_temp = str_replace('index.htm', '', $url_temp);
$file_time[$url_temp] = date("F d Y H:i:s", filemtime("$dir/$f"));
$file[] = $url_temp;
@ -163,8 +156,8 @@ class Cache extends CI_Controller
}
$mydir->close();
}
/**
*
* 私有函数:筛选目录和文件。
@ -178,22 +171,18 @@ class Cache extends CI_Controller
*/
private function filter(&$file, &$path)
{
if (isset($_POST['p']) && !empty($_POST['p']))
{
if (isset($_POST['p']) && !empty($_POST['p'])) {
//删选文件
foreach ($file as &$f)
{
(stripos($f, $_POST['p'])!==false) or $f = false;
foreach ($file as &$f) {
(stripos($f, $_POST['p']) !== false) or $f = false;
}
$file = array_filter($file);
//删选目录
foreach ($path as &$p)
{
(stripos($p, $_POST['p'])!==false) or $p = false;
foreach ($path as &$p) {
(stripos($p, $_POST['p']) !== false) or $p = false;
}
$path = array_filter($path);
}
}
}
//end of Cache

Loading…
Cancel
Save