Пример #1
0
 static function writeConfig($ConfigFile)
 {
     $m = D('Admin/Config');
     if ($ConfigFile == 'core') {
         //core缓存到配置目录
         $savefile = CONF_PATH . 'core.php';
         $data = $m->getConfig($ConfigFile);
         $b = cache_array($data, $savefile);
         return $data;
     }
     if ($ConfigFile == 'home/config') {
         //core缓存到配置目录
         $savefile = CONF_PATH . 'Home/config.php';
         $data = $m->getConfig($ConfigFile);
         if (empty($data['DEFAULT_THEME'])) {
             $data['DEFAULT_THEME'] = 'Default';
         }
         $b = cache_array($data, $savefile);
         return $data;
     }
     if ($ConfigFile == 'wap/config') {
         //core缓存到配置目录
         $savefile = CONF_PATH . 'Wap/config.php';
         $data = $m->getConfig($ConfigFile);
         if (empty($data['DEFAULT_THEME'])) {
             $data['DEFAULT_THEME'] = 'Default';
         }
         $b = cache_array($data, $savefile);
         return $data;
     }
     //缓存域名配置到缓存
     if ($ConfigFile == 'domain') {
         $savefile = CONF_PATH . 'domain.php';
         $data = $m->getConfig($ConfigFile);
         $domain = array('APP_SUB_DOMAIN_RULES' => array());
         if (empty($data)) {
             cache_array($domain, $savefile);
             //写入空
             return false;
         }
         $dList = explode(',', trim($data['WAP_URL']));
         foreach ((array) $dList as $d) {
             if (!empty($d)) {
                 $d = str_ireplace('http://', '', $d);
                 //去掉http://
                 $temp[$d] = array('wap/');
             }
         }
         $domain['APP_SUB_DOMAIN_RULES'] = $temp;
         $b = cache_array($domain, $savefile);
         return $data;
     }
     //html缓存
     if ($ConfigFile == 'html') {
         $savefile = CONF_PATH . 'html.php';
         $data = $m->getConfig($ConfigFile);
         $htmlEnable = $data['HTML_ENABLE'] == 1 ? true : false;
         //Html首页缓存时间
         $IndexCacheTime = $data['INDEX_CACHE_TIME'];
         //$IndexCacheTime = is_numeric($IndexCacheTime) ? "'$IndexCacheTime'" : "'0'";
         //Html频道缓存时间
         $ChannelCacheTime = $data['CHANNEL_CACHE_TIME'];
         //$ChannelCacheTime = is_numeric($ChannelCacheTime) ? "'$ChannelCacheTime'" : "'0'";
         //Html信息缓存时间
         $InfoCacheTime = $data['INFO_CACHE_TIME'];
         //$InfoCacheTime = is_numeric($InfoCacheTime) ? "'$InfoCacheTime'" : "'0'";
         $html = array('HTML_CACHE_ON' => $htmlEnable, 'HTML_CACHE_RULES' => array('index:index' => array('{:group}/index_{0|get_language_mark}', $IndexCacheTime), 'channel:index' => array('{:group}/channel/{id}{jobid}{infoid}_{0|get_language_mark}_{0|get_para}', $ChannelCacheTime), 'info:read' => array('{:group}/info/{id}_{0|get_para}', $InfoCacheTime)));
         $b = cache_array($html, $savefile);
         return $data;
     }
     //设置无需区分语言缓存项
     $file = $ConfigFile;
     if (in_array($ConfigFile, YdCache::$list)) {
         $data = $m->getConfig($ConfigFile);
         F($file, $data);
         //快速缓存
     } else {
         //需要缓存所有语言
         $lang = YdCache::readLanguage();
         foreach ($lang as $k => $v) {
             $file = $ConfigFile . '_' . $v['LanguageMark'];
             $where = '(LanguageID=' . $v['LanguageID'] . ' or LanguageID=0)';
             $where .= " and IsEnable = 1 and ConfigFile='{$ConfigFile}'";
             $data = $m->where($where)->getField('ConfigName,ConfigValue');
             F($file, $data);
             //快速缓存
         }
     }
     return $data;
 }