| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- <?php
- // +----------------------------------------------------------------------
- // | Fanwe 方维直播系统
- // +----------------------------------------------------------------------
- // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Author: 云淡风轻(1956838968@qq.com)
- // +----------------------------------------------------------------------
- class CacheAction extends CommonAction{
- public function clear_admin()
- {
- set_time_limit(0);
- es_session::close();
- $this->clear_admin_file();
- header("Content-Type:text/html; charset=utf-8");
- exit("<div style='line-height:50px; text-align:center; color:#f30;'>".L('CLEAR_SUCCESS')."</div><div style='text-align:center;'><input type='button' onclick='$.weeboxs.close();' class='button' value='关闭' /></div>");
- }
- private function clear_admin_file(){
- clear_dir_file(get_real_path()."public/runtime/admin/Cache/");
- clear_dir_file(get_real_path()."public/runtime/admin/Data/_fields/");
- clear_dir_file(get_real_path()."public/runtime/admin/Temp/");
- clear_dir_file(get_real_path()."public/runtime/admin/Logs/");
- clear_file(get_real_path()."public/runtime/admin/~app.php");
- clear_file(get_real_path()."public/runtime/admin/~runtime.php");
- clear_file(get_real_path()."public/runtime/admin/lang.js");
- clear_file(get_real_path()."public/runtime/app/config_cache.php");
- }
-
- public function clear_parse_file()
- {
- set_time_limit(0);
- es_session::close();
-
- $this->clear_parse_file_fun();
-
- header("Content-Type:text/html; charset=utf-8");
- if($GLOBALS['distribution_cfg']['CACHE_TYPE']!="File"&&$GLOBALS['distribution_cfg']['CACHE_TYPE']!="Db")
- {
- exit("<div style='line-height:25px; text-align:center; color:#f30;'>".L('CLEAR_SUCCESS').",如未生效,请进入缓存管理平台重置缓存</div><div style='text-align:center;'><input type='button' onclick='$.weeboxs.close();' class='button' value='关闭' /></div>");
- }
- else
- exit("<div style='line-height:50px; text-align:center; color:#f30;'>".L('CLEAR_SUCCESS')."</div><div style='text-align:center;'><input type='button' onclick='$.weeboxs.close();' class='button' value='关闭' /></div>");
- }
- private function clear_parse_file_fun(){
- clear_dir_file(get_real_path()."public/runtime/statics/");
-
- clear_dir_file(get_real_path()."public/runtime/app/tpl_caches/");
- clear_dir_file(get_real_path()."public/runtime/app/tpl_compiled/");
-
- clear_dir_file(get_real_path()."public/runtime/wap/tpl_caches/");
- clear_dir_file(get_real_path()."public/runtime/wap/tpl_compiled/");
-
- clear_dir_file(get_real_path()."public/runtime/wap_app/tpl_caches/");
- clear_dir_file(get_real_path()."public/runtime/wap_app/tpl_compiled/");
- }
-
- public function clear_data()
- {
- set_time_limit(0);
- es_session::close();
- $this->clear_data_file();
-
- header("Content-Type:text/html; charset=utf-8");
- if($GLOBALS['distribution_cfg']['CACHE_TYPE']!="File"&&$GLOBALS['distribution_cfg']['CACHE_TYPE']!="Db")
- {
- exit("<div style='line-height:25px; text-align:center; color:#f30;'>".L('CLEAR_SUCCESS').",如未生效,请进入缓存管理平台重置缓存</div><div style='text-align:center;'><input type='button' onclick='$.weeboxs.close();' class='button' value='关闭' /></div>");
- }
- else
- exit("<div style='line-height:50px; text-align:center; color:#f30;'>".L('CLEAR_SUCCESS')."</div><div style='text-align:center;'><input type='button' onclick='$.weeboxs.close();' class='button' value='关闭' /></div>");
- }
-
- private function clear_data_file(){
- clear_file(get_real_path()."public/runtime/app/deal_cate_conf.js");
- clear_dir_file(get_real_path()."public/runtime/app/deal_region_conf/");
- if(intval($_REQUEST['is_all'])==0)
- {
- //数据缓存
- clear_dir_file(get_real_path()."public/runtime/app/data_caches/");
- clear_dir_file(get_real_path()."public/runtime/app/db_caches/");
-
- clear_dir_file(get_real_path()."public/runtime/mapi/data_caches/");
-
- $GLOBALS['cache']->clear();
- clear_dir_file(get_real_path()."public/runtime/app/tpl_caches/");
- clear_dir_file(get_real_path()."public/runtime/app/tpl_compiled/");
-
- clear_dir_file(get_real_path()."public/runtime/wap/tpl_caches/");
- clear_dir_file(get_real_path()."public/runtime/wap/tpl_compiled/");
-
- clear_dir_file(get_real_path()."public/runtime/wap_app/tpl_caches/");
- clear_dir_file(get_real_path()."public/runtime/wap_app/tpl_compiled/");
- clear_file(get_real_path()."public/runtime/app/lang.js");
-
- //删除相关未自动清空的数据缓存
- clear_auto_cache("page_image");
- }
- else
- {
- clear_dir_file(get_real_path()."public/runtime/data/");
- clear_dir_file(get_real_path()."public/runtime/app/data_caches/");
- clear_dir_file(get_real_path()."public/runtime/app/db_caches/");
- clear_dir_file(get_real_path()."public/runtime/mapi/data_caches/");
- $GLOBALS['cache']->clear();
- clear_dir_file(get_real_path()."public/runtime/app/tpl_caches/");
- clear_dir_file(get_real_path()."public/runtime/app/tpl_compiled/");
-
- clear_dir_file(get_real_path()."public/runtime/wap/tpl_caches/");
- clear_dir_file(get_real_path()."public/runtime/wap/tpl_compiled/");
-
- clear_dir_file(get_real_path()."public/runtime/wap_app/tpl_caches/");
- clear_dir_file(get_real_path()."public/runtime/wap_app/tpl_compiled/");
- clear_file(get_real_path()."public/runtime/app/lang.js");
-
- //后台
- clear_dir_file(get_real_path()."public/runtime/admin/Cache/");
- clear_dir_file(get_real_path()."public/runtime/admin/Data/_fields/");
- clear_dir_file(get_real_path()."public/runtime/admin/Temp/");
- clear_dir_file(get_real_path()."public/runtime/admin/Logs/");
- clear_file(get_real_path()."public/runtime/admin/~app.php");
- clear_file(get_real_path()."public/runtime/admin/~runtime.php");
- clear_file(get_real_path()."public/runtime/admin/lang.js");
- clear_file(get_real_path()."public/runtime/app/config_cache.php");
-
- $GLOBALS['db']->query("update ".DB_PREFIX."deal_log set comment_data_cache = '',deal_info_cache=''");
- $GLOBALS['db']->query("update ".DB_PREFIX."deal set deal_extra_cache = ''");
- $GLOBALS['db']->query("update ".DB_PREFIX."deal_comment set deal_info_cache=''");
- }
- }
-
- public function clear_image()
- {
- set_time_limit(0);
- es_session::close();
-
- $this->clear_image_file_fun();
-
- header("Content-Type:text/html; charset=utf-8");
-
- if($GLOBALS['distribution_cfg']['CACHE_TYPE']!="File"&&$GLOBALS['distribution_cfg']['CACHE_TYPE']!="Db")
- {
- exit("<div style='line-height:25px; text-align:center; color:#f30;'>".L('CLEAR_SUCCESS').",如未生效,请进入缓存管理平台重置缓存</div><div style='text-align:center;'><input type='button' onclick='$.weeboxs.close();' class='button' value='关闭' /></div>");
- }
- else
- exit("<div style='line-height:50px; text-align:center; color:#f30;'>".L('CLEAR_SUCCESS')."</div><div style='text-align:center;'><input type='button' onclick='$.weeboxs.close();' class='button' value='关闭' /></div>");
- }
- private function clear_image_file_fun(){
- $path = APP_ROOT_PATH."public/attachment/";
- $this->clear_image_file($path);
- $path = APP_ROOT_PATH."public/images/";
- $this->clear_image_file($path);
-
- $qrcode_path = APP_ROOT_PATH."public/images/qrcode/";
- $this->clear_qrcode($qrcode_path);
-
- clear_dir_file(get_real_path()."public/runtime/app/tpl_caches/");
- clear_dir_file(get_real_path()."public/runtime/app/tpl_compiled/");
- }
-
- public function clear_all(){
- set_time_limit(0);
- es_session::close();
- $GLOBALS['cache']->clear();
- // $GLOBALS['cache']->celar_con();
- $this->updateRegionJS();
- $this->clear_admin_file();
- $this->clear_parse_file_fun();
-
- $this->clear_data_file();
-
- $this->clear_image_file_fun();
- header("Content-Type:text/html; charset=utf-8");
- exit("<div style='line-height:50px; text-align:center; color:#f30;'>".L('CLEAR_SUCCESS')."</div><div style='text-align:center;'><input type='button' onclick='$.weeboxs.close();' class='button' value='关闭' /></div>");
- }
- private function updateRegionJS()
- {
- $jsStr = "var regionConf = ".$this->getRegionJS();
- $path = get_real_path()."public/region.js";
- @file_put_contents($path,$jsStr);
- }
-
- private function getRegionJS()
- {
- $jsStr = "";
- $childRegionList = M("RegionConf")->where("region_level = 2")->order("id asc")->findAll();
-
- foreach($childRegionList as $childRegion)
- {
- if(empty($jsStr))
- $jsStr .= "{";
- else
- $jsStr .= ",";
-
- $childStr = $this->getRegionChildJS($childRegion['id']);
- $jsStr .= "\"r$childRegion[id]\":{\"i\":$childRegion[id],\"n\":\"$childRegion[name]\",\"c\":$childStr}";
- }
-
- if(!empty($jsStr))
- $jsStr .= "}";
- else
- $jsStr .= "\"\"";
-
- return $jsStr;
- }
- private function getRegionChildJS($pid)
- {
- $jsStr = "";
- $childRegionList = M("RegionConf")->where("pid=".$pid)->order("id asc")->findAll();
-
- foreach($childRegionList as $childRegion)
- {
- if(empty($jsStr))
- $jsStr .= "{";
- else
- $jsStr .= ",";
-
- $childStr = $this->getRegionChildJS($childRegion['id']);
- $jsStr .= "\"r$childRegion[id]\":{\"i\":$childRegion[id],\"n\":\"$childRegion[name]\",\"c\":$childStr}";
- }
-
- if(!empty($jsStr))
- $jsStr .= "}";
- else
- $jsStr .= "\"\"";
-
- return $jsStr;
- }
-
- private function clear_qrcode($path)
- {
-
- if ( $dir = opendir( $path ) )
- {
- while ( $file = readdir( $dir ) )
- {
- $check = is_dir( $path. $file );
- if ( !$check )
- {
- @unlink ( $path . $file);
- }
- else
- {
- if($file!='.'&&$file!='..')
- {
- $this->clear_qrcode($path.$file."/");
- }
- }
- }
- closedir( $dir );
- return true;
- }
- }
-
- private function clear_image_file($path)
- {
- if ( $dir = opendir( $path ) )
- {
- while ( $file = readdir( $dir ) )
- {
- $check = is_dir( $path. $file );
- if ( !$check )
- {
- if(preg_match("/_(\d+)x(\d+)/i",$file,$matches))
- @unlink ( $path . $file);
- }
- else
- {
- if($file!='.'&&$file!='..')
- {
- $this->clear_image_file($path.$file."/");
- }
- }
- }
- closedir( $dir );
- return true;
- }
- }
- }
- ?>
|