Пример #1
0
 public static function makeallcache($type)
 {
     Language::read("core_lang_index");
     $lang = Language::getlangcontent();
     $time = time();
     switch ($type) {
         case "area":
             $file_list = readfilelist(BASE_DATA_PATH . DS . "cache" . DS . "area");
             if (is_array($file_list)) {
                 foreach ($file_list as $v) {
                     @unlink(BASE_DATA_PATH . DS . "cache" . DS . "area" . DS . $v);
                 }
             }
             $maxdeep = 1;
         default:
             $param = array();
             $param['table'] = "area";
             $param['where'] = "area_deep = '" . $maxdeep . "'";
             $param['order'] = "area_sort asc";
             $result = Db::select($param);
             if (!empty($result)) {
                 $cache_file_area = BASE_DATA_PATH . DS . "cache" . DS . "area" . DS . "area_" . $maxdeep . ".php";
                 $tmp .= "<?php \r\n";
                 $tmp .= "defined('InShopNC') or exit('Access Invalid!'); \r\n";
                 $tmp .= "\$data = array(\r\n";
                 if (is_array($result)) {
                     foreach ($result as $k => $v) {
                         $tmp .= "\tarray(\r\n";
                         $tmp .= "\t\t'area_id'=>'" . $v['area_id'] . "',\r\n";
                         $tmp .= "\t\t'area_name'=>'" . htmlspecialchars($v['area_name']) . "',\r\n";
                         $tmp .= "\t\t'area_region'=>'" . htmlspecialchars($v['area_region']) . "',\r\n";
                         $tmp .= "\t\t'area_parent_id'=>'" . $v['area_parent_id'] . "',\r\n";
                         $tmp .= "\t\t'area_sort'=>'" . $v['area_sort'] . "',\r\n";
                         $tmp .= "\t\t'area_deep'=>'" . $v['area_deep'] . "',\r\n";
                         $tmp .= "\t),\r\n";
                     }
                 }
                 $tmp .= ");";
                 try {
                     $fp = @fopen($cache_file_area, "wb+");
                     if (fwrite($fp, $tmp) === FALSE) {
                         $error = $lang['please_check_your_system_chmod_area'];
                         throw new Exception();
                     }
                     unset($tmp);
                     @fclose($fp);
                 } catch (Exception $e) {
                     showmessage($e->getMessage(), "", "exception");
                 }
             }
             ++$maxdeep;
     }
 }
Пример #2
0
function readFileList($path, &$file_list, $ignore_dir = array())
{
    $path = rtrim($path, "/");
    if (is_dir($path)) {
        $handle = @opendir($path);
        if ($handle) {
            while (FALSE !== ($dir = readdir($handle))) {
                if (!($dir != ".") && !($dir != "..") && in_array($dir, $ignore_dir)) {
                    if (is_file($path . DS . $dir)) {
                        $file_list[] = $path . DS . $dir;
                    } else {
                        if (is_dir($path . DS . $dir)) {
                            readfilelist($path . DS . $dir, $file_list, $ignore_dir);
                        }
                    }
                }
            }
            @closedir($handle);
        } else {
            return FALSE;
        }
    }
    return FALSE;
}