Ejemplo n.º 1
0
 /**
  * 写入所有缓存
  */
 static function writeAll()
 {
     YdCache::deleteAll();
     //仅更新Core,home/config即可,其它缓存会自动生成
     YdCache::writeCore();
     YdCache::writeHomeConfig();
     //重写Home分组主题名称
     YdCache::writeWapConfig();
     //重写Wap分组主题名称
     YdCache::writeDomain();
     //重写多域名配置缓存
     YdCache::writeHtml();
     //重写Html静态规则配置
     YdCache::writeWater();
     YdCache::writeUpload();
     YdCache::writeBaiduShare();
     YdCache::writeBasic();
     YdCache::writeComment();
     YdCache::writeContact();
     YdCache::writeGuestbook();
     YdCache::writeTag();
     YdCache::writeThumb();
     YdCache::writeSeo();
     YdCache::writeReg();
     YdCache::writeOrder();
     YdCache::writeStat();
     YdCache::writeWap();
     YdCache::writeOther();
     YdCache::writeChannel();
     //频道缓存
 }
Ejemplo n.º 2
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function init()
 {
     // 设置系统时区
     date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     // 加载动态项目公共文件和配置
     load_ext_file();
     // URL调度
     Dispatcher::dispatch();
     if (defined('GROUP_NAME')) {
         // 加载分组配置文件
         if (is_file(CONF_PATH . GROUP_NAME . '/config.php')) {
             C(include CONF_PATH . GROUP_NAME . '/config.php');
         }
         // 加载分组函数文件
         if (is_file(COMMON_PATH . GROUP_NAME . '/function.php')) {
             include COMMON_PATH . GROUP_NAME . '/function.php';
         }
     }
     /* 获取模板主题名称 */
     /*
     $templateSet =  C('DEFAULT_THEME');
     if(C('TMPL_DETECT_THEME')) {// 自动侦测模板主题
         $t = C('VAR_TEMPLATE');
         if (isset($_GET[$t])){
             $templateSet = $_GET[$t];
         }elseif(cookie('think_template')){
             $templateSet = cookie('think_template');
         }
         // 主题不存在时仍改回使用默认主题
         if(!is_dir(TMPL_PATH.$templateSet))
             $templateSet = C('DEFAULT_THEME');
         cookie('think_template',$templateSet);
     }
     */
     //修改By wang 2013-04-02============================================
     $templateSet = C('DEFAULT_THEME');
     //仅让home分组支持自动切换模板
     $gn = strtolower(GROUP_NAME);
     if (in_array($gn, array('home', 'wap')) && C('TMPL_DETECT_THEME')) {
         // 自动侦测模板主题
         $t = C('VAR_TEMPLATE');
         $ct = $gn . '_think_template';
         if (isset($_GET[$t])) {
             $templateSet = $_GET[$t];
             //更换主题,必须清空静态缓存
             if (C('HTML_CACHE_ON') == true && is_dir(TMPL_PATH . GROUP_NAME . '/' . $templateSet)) {
                 YdCache::deleteHtml('all');
                 //清楚全部Html缓存
             }
         } elseif (cookie($ct)) {
             $templateSet = cookie($ct);
         }
         // 主题不存在时仍改回使用默认主题
         if (!is_dir(TMPL_PATH . GROUP_NAME . '/' . $templateSet)) {
             $templateSet = C('DEFAULT_THEME');
             //切换到默认模板,也需要清空静态缓存
             if (C('HTML_CACHE_ON') == true && is_dir(TMPL_PATH . GROUP_NAME . '/' . $templateSet)) {
                 YdCache::deleteHtml('all');
                 //清楚全部Html缓存
             }
         }
         cookie($ct, $templateSet);
     }
     //==============================================================
     /* 模板相关目录常量 */
     define('THEME_NAME', $templateSet);
     // 当前模板主题名称
     $group = defined('GROUP_NAME') ? GROUP_NAME . '/' : '';
     define('THEME_PATH', TMPL_PATH . $group . (THEME_NAME ? THEME_NAME . '/' : ''));
     define('APP_TMPL_PATH', __ROOT__ . '/' . APP_NAME . (APP_NAME ? '/' : '') . basename(TMPL_PATH) . '/' . $group . (THEME_NAME ? THEME_NAME . '/' : ''));
     C('TEMPLATE_NAME', THEME_PATH . MODULE_NAME . (defined('GROUP_NAME') ? C('TMPL_FILE_DEPR') : '/') . ACTION_NAME . C('TMPL_TEMPLATE_SUFFIX'));
     C('CACHE_PATH', CACHE_PATH . $group);
     return;
 }
Ejemplo n.º 3
0
 static function writeAll()
 {
     YdCache::deleteAll();
     YdCache::writeCore();
     YdCache::writeHomeConfig();
     YdCache::writeWapConfig();
     YdCache::writeDomain();
     YdCache::writeHtml();
     YdCache::writeWater();
     YdCache::writeUpload();
     YdCache::writeBaiduShare();
     YdCache::writeBasic();
     YdCache::writeComment();
     YdCache::writeContact();
     YdCache::writeGuestbook();
     YdCache::writeTag();
     YdCache::writeThumb();
     YdCache::writeSeo();
     YdCache::writeReg();
     YdCache::writeOrder();
     YdCache::writeStat();
     YdCache::writeWap();
     YdCache::writeOther();
     YdCache::writeChannel();
 }
Ejemplo n.º 4
0
 public function clearCache()
 {
     header("Content-Type:text/html; charset=utf-8");
     $action = strtolower($_REQUEST['Action']);
     cookie("MenuTopID", NULL);
     switch ($action) {
         case "systemcache":
             YdCache::writeall();
             $this->ajaxReturn(NULL, "清除系统缓存成功!", 1);
             break;
         case "modelcache":
             YdCache::deletetemp();
             $this->ajaxReturn(NULL, "清除频道模型缓存成功!", 1);
             break;
         case "homecache":
             YdCache::deletehome();
             $this->ajaxReturn(NULL, "清除模板缓存成功!", 1);
             break;
         case "wapcache":
             YdCache::deletewap();
             $this->ajaxReturn(NULL, "清除模板缓存成功!", 1);
             break;
         case "indexhtmlcache":
             YdCache::deletehtml("index");
             $this->ajaxReturn(NULL, "清除首页Html缓存成功!", 1);
             break;
         case "channelhtmlcache":
             YdCache::deletehtml("channel");
             $this->ajaxReturn(NULL, "清除频道首页Html缓存成功!", 1);
             break;
         case "infohtmlcache":
             YdCache::deletehtml("info");
             $this->ajaxReturn(NULL, "清除内容页面Html缓存成功!", 1);
             break;
         case "allhtmlcache":
             YdCache::deletehtml("all");
             $this->ajaxReturn(NULL, "清除全部Html缓存成功!", 1);
             break;
         case "saveconfig":
             if (isset($_POST)) {
                 break;
             }
             if (is_numeric($_POST['INDEX_CACHE_TIME'])) {
                 if (is_numeric($_POST['CHANNEL_CACHE_TIME'])) {
                 }
             }
             if (!is_numeric($_POST['INFO_CACHE_TIME'])) {
                 $this->ajaxReturn(NULL, "缓存时间必须为数字!", 0);
             }
             unset($_POST['__hash__']);
             $m = d("Admin/Config");
             if ($m->saveConfig($_POST, "html")) {
                 $this->ajaxReturn(NULL, "保存配置成功!", 1);
             } else {
                 $this->ajaxReturn(NULL, "保存配置失败!", 0);
             }
     }
     $m = d("Admin/Config");
     $data = $m->getConfig("html");
     $this->assign("HtmlEnable", $data['HTML_ENABLE']);
     $this->assign("IndexCacheTime", $data['INDEX_CACHE_TIME']);
     $this->assign("ChannelCacheTime", $data['CHANNEL_CACHE_TIME']);
     $this->assign("InfoCacheTime", $data['INFO_CACHE_TIME']);
     $this->assign("Action", __URL__ . "/clearCache");
     $this->display();
 }