⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cache.php

📁 SSCMS网站管理系统 飞狐源码站 SSCMS可以将网站内容全部生成静态HTML文件,这样可以极大地节约主机资源
💻 PHP
字号:
<?php
class CPage extends Page {
    function CPage(&$app)
    {
        $this->Page($app);
    } 

	function onrefresh(){
		$this->dbprefix();
		$this->CacheCates();
		$this->CacheModel();
		$this->CachePsn();
		$this->page_debug($this->app->getSysMsg('refresh_cache_ok'),"index.php?module=index&act=main",'');
	}

	function onclear_cache(){
		if(is_array($this->in['target'])){
			if($this->in[target][compile_tpl]=='1')$this->tpl->clearCaches('../templates_c');
			if($this->in[target][sys_cache]=='1')$this->tpl->clearCaches(DIR_CACHE);
			@mkdir(DIR_CACHE,0777);
			@chmod(DIR_CACHE,0777);
		}
		$this->tpl->assign('topic',$this->app->getSysMsg('clear_cache'));
		$this->tpl->display('admin/admin_clear_cache.html');
	}

	 function dbprefix()
    {
        $sql = "select * from " . DBPREFIX . "db_set order by `db_id`";
        $this->db->query($sql);
        $db_array = array();
        while ($row = $this->db->fetch_array()) {
            $db_array[] = $row;
        } 
        $this->dbSet = $db_array;
        $dbcache = var_export($db_array, true) . ';' . PHP_NEXTLINE . PHP_NEXTLINE;
        if (@$fp = fopen(DIR_CACHE . 'cache_dbset.inc.php', 'w')) {
            @fwrite($fp, "<?php" . PHP_NEXTLINE . "//SSMS cache file, DO NOT modify me!" .
                PHP_NEXTLINE . "//Created on " . date("M j, Y,G:i") . PHP_NEXTLINE . PHP_NEXTLINE . "\$dbSet=" . $dbcache . PHP_CLOSE_TAG);
            @fclose($fp);
        } else {
            exit('Can not write to cache file, please check cache directory.');
        } 
    } 
    // 刷新后台频道缓存
    function CacheCates()
    {
        $sql = "SELECT * FROM " . $this->category . " ORDER BY ParentID ASC";
        $this->db->query($sql);
        $cachecates = array();
        $cachecate = array();
        while ($row = $this->db->fetch_array()) {
           $cachecates[$row[ParentID]][$row[CateID]][CateID] = $row[CateID];
		   $cachecates[$row[ParentID]][$row[CateID]][Title] = $row[Title];
           $cachecate[$row[CateID]] = $row;
        } 
        $caches = var_export($cachecates, true) . ';' . PHP_NEXTLINE . PHP_NEXTLINE;
        $cache = var_export($cachecate, true) . ';' . PHP_NEXTLINE . PHP_NEXTLINE;
        if (@$fp = fopen(DIR_CACHE . 'cache_Category.inc.php', 'w')) {
            @fwrite($fp, "<?php" . PHP_NEXTLINE . "//SSMS cache file, DO NOT modify me!" . PHP_NEXTLINE . "//Created on " . date("M j, Y,G:i") . PHP_NEXTLINE . PHP_NEXTLINE . "\$cachecates=" . $caches . PHP_CLOSE_TAG);
            @fclose($fp);
        } else {
            exit('Can not write to cache file, please check cache directory.');
        } 
        if (@$fp = fopen(DIR_CACHE . 'cache_Cate.inc.php', 'w')) {
            @fwrite($fp, "<?php" . PHP_NEXTLINE . "//SSMS cache file, DO NOT modify me!" . PHP_NEXTLINE . "//Created on " . date("M j, Y,G:i") . PHP_NEXTLINE . PHP_NEXTLINE . "\$Cate=" . $cache . PHP_CLOSE_TAG);
            @fclose($fp);
        } else {
            exit('Can not write to cache file, please check cache directory.');
        } 
    } 
	
	function CacheModel() 
	{
		$sql ="SELECT * FROM ".$this->content_model;
		$this->db->query($sql);
		$caches=array();		
		while ($row = $this->db->fetch_array())
		{
			$tmp_caches[$row[ContentModelID]] = $row;
		}
		foreach($tmp_caches as $tmp_cache){
			unset($field);
			unset($TitleField);
			unset($MainField);
			$sql1="SELECT * FROM ".$this->content_field." where TableID=".$tmp_cache[ContentModelID]."  ORDER BY FieldOrder,TableID ASC";
			$this->db->query($sql1);
			while($rows=$this->db->fetch_array())
			{
				$field[]=$rows;
				$TableID=$rows[TableID];
				if($rows[IsTitleField])$TitleField=$rows[FieldName];
				if($rows[IsMainField])$MainField=$rows[FieldName];
			}
			$caches[$tmp_cache[ContentModelID]]=$tmp_cache;
			$caches[$tmp_cache[ContentModelID]][TitleField]=$TitleField;
			$caches[$tmp_cache[ContentModelID]][MainField]=$MainField;
			$caches[$tmp_cache[ContentModelID]][TableID]=$TableID;
			$caches[$tmp_cache[ContentModelID]][Model]=$field;
		}
		$cache = var_export($caches,TRUE).';'.PHP_NEXTLINE.PHP_NEXTLINE;
		if(@$fp = fopen(DIR_CACHE.'cache_contentmodel.inc.php', 'w'))
		{
			@fwrite($fp, "<?php".PHP_NEXTLINE."//SSMS cache file, DO NOT modify me!".PHP_NEXTLINE."//Created on ".date("M j, Y,G:i").PHP_NEXTLINE.PHP_NEXTLINE."\$content_model_info=".$cache.PHP_CLOSE_TAG);
			@fclose($fp);
		}else{
			exit('Can not write to cache file, please check cache directory.');
		}
	}

	function CachePsn()
	{
		$sql = "select * from ".$this->psn." order by PSNID";
		$this->db->query($sql);
		$psnarray = array();
		while ($row = $this->db->fetch_array())
		{
			$psnarray[$row[PSNID]] = $row;
		}
		$cache = var_export($psnarray,TRUE).';'.PHP_NEXTLINE.PHP_NEXTLINE;
		if(@$fp = fopen(DIR_CACHE.'cache_PSN.inc.php', 'w'))
		{
			@fwrite($fp, "<?php".PHP_NEXTLINE."//SSMS cache file, DO NOT modify me!".
				PHP_NEXTLINE."//Created on ".date("M j, Y,G:i").PHP_NEXTLINE.PHP_NEXTLINE."\$PSN_cache=".$cache.PHP_CLOSE_TAG);
				@fclose($fp);
		}else{
			exit('Can not write to cache file, please check cache directory.');
		}		
	}
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -