Beispiel #1
0
    }
    if ($_POST['summary'] == '') {
        $_POST['summary'] = check::csubstr(trim(str_replace(" ", " ", str_replace("\r\n", "", strip_tags($_POST['intro'])))), 0, $arrGWeb['db_summary_len']);
    }
    if (is_array($_POST['photo'])) {
        $_POST['thumbnail'] = $_POST['photo'][0]['photo'];
    } else {
        $_POST['thumbnail'] = $_POST['photo'];
    }
    $objWebInit->saveInfo($_POST, 0);
    if ($arrGWeb['file_static']) {
        //生成静态页面
        $intID = $objWebInit->getMaxID() - 1;
        $strDir = ceil($intID / $arrGCache['cache_filenum']);
        $objCache = new cache($arrGCache['cache_root'] . '-' . $strDir . '/' . $intID . $arrGWeb['file_suffix'], $arrGCache['cache_time']);
        $objCache->cache_start();
        $strContents = @file_get_contents('http://' . $_SERVER["HTTP_HOST"] . '/' . $arrGWeb['module_id'] . '/detail.php?id=' . $intID);
        if ($strContents) {
            echo $strContents;
        }
        $objCache->cache_end(false);
    }
    check::WindowLocation('index.php', 'page=' . $_GET['page']);
}
if (!is_array($arrMType) || empty($arrMType)) {
    $arrMType = $objWebInit->getTypeList();
    $arrMType = $objWebInit->formatTypeList(0, $arrMType);
}
$_SESSION['submitpasskey'] = md5(md5(time()));
//print_r($arrMType);
// 输出到模板
Beispiel #2
0
 /**
  * 更新页面缓存(纯静态和smarty缓存)
  * @author	肖飞
  * @param	int		$id					记录ID数或者单页数组的KEY
  * @param	int		$type_id			栏目类型ID 便于清除列表页的缓存
  * @param	array		$arrMOutput	输出到smartyd的数组
  * @return	void
  */
 public function updateCache($id, $type_id = 1, $arrMOutput = array())
 {
     global $arrGWeb, $arrGCache;
     if ($arrGWeb['file_static']) {
         //生成静态页面
         $intID = intval($id);
         $strDir = ceil($intID / $arrGCache['cache_filenum']);
         if (empty($intID)) {
             //单页栏目
             $intID = $id;
             $strCacheFile = $arrGCache['cache_root'] . '/' . $id . $arrGWeb['file_suffix'];
             @unlink($arrGCache['cache_root'] . '/' . $id . 'tw' . $arrGWeb['file_suffix']);
         } else {
             //其他栏目
             $strCacheFile = $arrGCache['cache_root'] . '-' . $strDir . '/' . $intID . $arrGWeb['file_suffix'];
             @unlink($arrGCache['cache_root'] . '-' . $strDir . '/' . $intID . 'tw' . $arrGWeb['file_suffix']);
         }
         $objCache = new cache($strCacheFile, $arrGCache['cache_time']);
         $objCache->cache_start();
         $strContents = @file_get_contents('http://' . $_SERVER["HTTP_HOST"] . $arrGWeb['WEB_ROOT_pre'] . '/' . $arrGWeb['module_id'] . '/detail.php?id=' . $intID);
         if ($strContents) {
             echo $strContents;
         }
         $objCache->cache_end(false);
     }
     if ($arrGWeb['URL_static']) {
         //更新smarty缓存
         $objSmarty = new SmartyTpl();
         if (empty($arrMOutput['template_dir'])) {
             $objSmarty->setTemplateDir($this->arrGSmarty['template_dir']);
         } else {
             $objSmarty->setTemplateDir($arrMOutput['template_dir']);
         }
         $objSmarty->setCompileDir($this->arrGSmarty['compile_dir']);
         $objSmarty->setCacheDir($this->arrGSmarty['cache_dir']);
         $objSmarty->plugins_dir = $this->arrGSmarty['plugins_dir'];
         $arrMOutput['smarty_debug'] = '';
         $arrMOutput['smarty_debug'] ? $objSmarty->compile_check = true : '';
         $arrMOutput['smarty_debug'] ? $objSmarty->debugging = true : '';
         $objSmarty->caching = $this->arrGSmarty['caching'];
         if ($objSmarty->caching) {
             $objSmarty->cache_lifetime = isset($this->arrGSmarty['cache_lifetime']) ? $this->arrGSmarty['cache_lifetime'] : 3600;
             $objSmarty->cache_modified_check = isset($this->arrGSmarty['cache_modified_check']) ? $this->arrGSmarty['cache_modified_check'] : false;
         }
         if (!empty($arrMOutput['smarty_assign'])) {
             while (list($key, $value) = each($arrMOutput['smarty_assign'])) {
                 $objSmarty->assign($key, $value);
             }
         }
         if ($_SESSION['langset'] == 'zh_tw') {
             $objSmarty->autoload_filters = array('output' => array('langset'));
         }
         $objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/');
         $objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/index.php');
         $objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/');
         $objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/index.php');
         $objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/list/');
         $objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/list.php');
         $objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/list/type_id-' . $type_id . $arrGWeb['file_suffix']);
         $objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/list.php/type_id-' . $type_id . $arrGWeb['file_suffix']);
         $objSmarty->clearCache($arrMOutput['template_file'], $_SESSION['langset'] . '/' . $arrGWeb['module_id'] . '/list.php?type_id=' . $type_id);
     }
     if ($arrGWeb['PDO_CACHE']) {
         if (!empty($this->arrGPdoDB['PDO_CACHE_ROOT'])) {
             check::delTreeDirs($this->arrGPdoDB['PDO_CACHE_ROOT']);
         }
     }
 }
Beispiel #3
0
                 $intID = $v['id'];
                 if (empty($intID)) {
                     continue;
                 }
                 include_once '../../' . $_GET['id'] . '/config/var.inc.php';
                 $intNum = ceil($intID / $arrGCache['cache_filenum']);
                 if ($_SESSION['langset'] == 'zh_tw') {
                     $arrGWeb['file_suffix'] = 'tw' . $arrGWeb['file_suffix'];
                 }
                 if ($_GET['id'] == 'archives') {
                     $strDir = $arrGCache['cache_root'] . '/' . $_GET['id'] . '/' . $v['type_title_english'] . $arrGWeb['file_suffix'];
                 } else {
                     $strDir = $arrGCache['cache_root'] . '/' . $_GET['id'] . '-' . $intNum . '/' . $intID . $arrGWeb['file_suffix'];
                 }
                 $objCache = new cache($strDir);
                 $objCache->cache_start(true);
                 if ($_GET['id'] == 'archives') {
                     $strContents = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . '/' . $_GET['id'] . '/detail.php?name=' . $v['type_title_english']);
                 } else {
                     $strContents = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . '/' . $_GET['id'] . '/detail.php?id=' . $intID);
                 }
                 if ($strContents) {
                     header("HTTP/1.1 200 OK");
                     echo $strContents;
                 }
                 $objCache->cache_end(false);
             }
             check::AlertExit("网站静态页面已重新生成 !", -1);
         }
     }
 }