diff --git a/application/controllers/cache.php b/application/controllers/cache.php index beed0749..447202f8 100644 --- a/application/controllers/cache.php +++ b/application/controllers/cache.php @@ -142,43 +142,25 @@ class Cache extends CI_Controller { * */ private function tree($dir, &$file, &$path, &$file_time) { - // 处理目录名中的特殊字符 - $dir = mb_convert_encoding($dir, 'UTF-8', mb_detect_encoding($dir, ['ASCII', 'GBK', 'ISO-8859-1', 'UTF-8'])); - $mydir = @dir($dir); - if (! $mydir) { - return; - } + $mydir = dir($dir); while ($f = $mydir->read()) { - // 跳过.和.. - if ($f == '.' || $f == '..') { - continue; - } - // 处理文件名中的特殊字符 - $f = mb_convert_encoding($f, 'UTF-8', mb_detect_encoding($f, ['ASCII', 'GBK', 'ISO-8859-1', 'UTF-8'])); - $fullPath = $dir . '/' . $f; - if (is_dir($fullPath) && (strpos($dir, '/cn/') === false) && (strpos($dir, '/amp/') === false) && (strpos($dir, '/js/') === false) && (strpos($dir, 'stfolder') === false)) { - $path[] = $fullPath; - $this->tree($fullPath, $file, $path, $file_time); + if (is_dir("$dir/$f") && $f != "." && $f != ".." && (strpos($dir, '/cn/') === false) && (strpos($dir, '/amp/') === false) && (strpos($dir, '/js/') === false) && (strpos($dir, 'stfolder') === false)) { + $path[] = "$dir/$f"; + $this->tree("$dir/$f", $file, $path, $file_time); } else { - if ( - (strpos($f, 'stfolder') === false) && - (strpos($f, '/cn/') === false) && - (strpos($f, '/amp/') === false) && - (strpos($f, '.pdf') === false) && - (strpos($f, '.mobile.htm') === false) && - (strpos($f, '.txt') === false) && - (strpos($f, '/js/') === false) && - (strpos($f, '.amp') === false) && - (strpos($f, 'stignore') === false) - ) { + if ($f != '.' && $f != '..' && (strpos($f, 'stfolder') === false) && (strpos($f, '/cn/') === false) && (strpos($f, '/amp/') === false) && (strpos($f, '.pdf') === false) && (strpos($f, '.mobile.htm') === false) && (strpos($f, '.txt') === false) && (strpos($f, '/js/') === false) && (strpos($f, '.amp') === false) && (strpos($f, 'stignore') === 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 = str_replace('/index.htm', '/', $url_temp); - $file_time[$url_temp] = date("F d Y H:i:s", filemtime($fullPath)); - $_url_temp = $url_temp; - $file[] = $_url_temp; + $file_time[$url_temp] = date("F d Y H:i:s", filemtime("$dir/$f")); + + // $encode = mb_detect_encoding($url_temp, ['ASCII', 'GBK', 'ISO-8859-1', 'UTF-8']); + // $_url_temp = mb_convert_encoding($url_temp, 'UTF8', $encode); + $_url_temp = $url_temp; + + $file[] = $_url_temp; } } }