objDB = $GLOBALS["PEAK"]["SO"]->createObject("DataBase"); $this->strTableTS = $GLOBALS["PEAK"]["SO"]->getTableName("TemplateSet"); $this->strTableTemplate = $GLOBALS["PEAK"]["SO"]->getTableName("Templates"); } /** * 对象自检. * * Detail description * @param none * @global none * @since 1.0 * @access public * @return void * @update 2004-8-17 21:16 */ function checkMe(){ if ($this->objDB->checkMe()) { return TRUE; }else{ return FALSE; } } // end checkMe /** * 清除已解析的模板内容 * * Detail description * @param string $__strReturnVar : (Optional)名称 * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function clearParse ( $_strReturnVar = "") { $this->clear($_strReturnVar); } // end clearParse /** * 清除内容 * * Detail description * @param object $__objReturnVar : (Optional)名称 * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function clear($_objReturnVar = "") { // Clears out hash created by call to parse() if(!empty($_objReturnVar)) { if( (gettype($_objReturnVar)) != "array") { unset($this->$_objReturnVar); return; }else{ while ( list ($__strKey,$__objVal) = each ($_objReturnVar) ) { unset($this->$__objVal); } return; } } // Empty - clear all of them while ( list ( $__strKey,$__objVal) = each ($this->arrHandle) ) { $__strKEY = $__strKey; unset($this->$__strKEY); } return; } // end clear() /** * 清除所有内容 * * Detail description * @param none * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function clearAll (){ $this->clear(); $this->clearAssign(); $this->clearDefine(); $this->clearTemplate(); //$this->clearDynamic(); return; } // end clearAll /** * 清除模板 * * Detail description * @param object $_objTemplate : (Optional)模板文件名称 * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function clearTemplate ($_objTemplate = "") { if(empty($this->arrLoaded)) { // Nothing loaded, nothing to clear return true; } if(empty($_objTemplate)) { // Clear ALL templates while ( list ($key, $val) = each ($this->arrLoaded) ) { unset($this->$key); } unset($this->arrLoaded); return true; } else { if( (gettype($_objTemplate)) != "array") { if( (isset($this->$_objTemplate)) || (!empty($this->$_objTemplate)) ) { unset($this->arrLoaded[$_objTemplate]); unset($this->$_objTemplate); return true; } } else { while ( list ($__strKey, $__tmpVal) = each ($_objTemplate) ) { unset($this->arrLoaded[$__strKey]); unset($this->$__strKey); } return true; } } return false; } // end clearTemplate /** * 清除文件名定义 * * Detail description * @param object $_objTag : (Optional)文件名列表 * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function clearDefine($_objTag = "") { if(empty($_objTag)) { unset($this->arrFileList); return; } // Peak Jing :: 原代码有误 if( (gettype($_objTag)) != "array") { unset($this->arrFileList[$_objTag]); return; } else { while ( list ( $__strTag, $__tmpVal) = each ($_objTag) ) { unset($this->arrFileList[$__strTag]); } return; } } // end clearDefine /** * 清除所有模板标记 * * Detail description * @param none * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function clearAssign () { if(!(empty($this->arrParseVars))) { while(list($__strRef,$__tmpVal) = each ($this->arrParseVars) ) { unset($this->arrParseVars["$__strRef"]); } } } /** * 清除指定模板标记 * * Detail description * @param object $_objHref : 要清除的内容 * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function clearHref ($_objHref){ if(!empty($_objHref)) { if( (gettype($_objHref)) != "array") { unset($this->arrParseVars[$_objHref]); return; } else { while (list ($__strRef,$__tmpVal) = each ($_objHref) ) { unset($this->arrParseVars[$__strRef]); } return; } } else { // Empty - clear them all $this->clearAssign(); } return; } /** * 取得被分配的标记 * * Detail description * @param string $_strFT * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function getAssigned($_strFT = ""){ if(empty($_strFT)) { return false; } if(isset($this->arrParseVars["$_strFT"])) { return ($this->arrParseVars["$_strFT"]); } else { return false; } } /** * 保存并显示错误 * * Detail description * @param string $_strErrorMsg * @param int $_isDie * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function error ($_strErrorMsg, $_isDie = 0){ $this->strError = $_strErrorMsg; echo "ERROR: $this->strError
\n"; if ($_isDie == 1) { exit; } return; } // end error() /** * 显示调试信息 * * Detail description * @param array $_arrArray * @param string $_strCaption * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function printArray($_arrArray , $_strCaption){ if (count($_arrArray) != 0){ print "_debug_console.document.write('$_strCaption ');\n"; print "_debug_console.document.write(\"\");"; print "_debug_console.document.write('');\n "; $__booleanFlag = true; while ( list ($__strKey , $__strVal) = each ($_arrArray) ){ $__booleanFlag = !$__booleanFlag; $__strVal = htmlspecialchars(mysql_escape_string ($__strVal)); if (!$__booleanFlag) { $__strColor ="#EEFFEE"; }else{ $__strColor ="#EFEFEF"; } print "_debug_console.document.write('');\n "; } print "_debug_console.document.write(\"
keyvalue
$__strKey
$__strVal
\");"; } } /** * 设置模板集 * * Detail description * @param integer $_intTSID : 模板集ID * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function setTSID($_intTSID) { if (array_key_exists($_intTSID,$this->arrTSID)) { return true; }else{ $this->objDB->query("select TSID,TSName,Description,Type,Owner,Status from ".$this->strTableTS." where Type='".$this->charTemplateType."' and TSID='".$_intTSID."' and Status=1"); if ($this->objDB->nextRecord()) { $this->arrTSID[$_intTSID] = true; $this->intTemplateSet = $_intTSID; $this->arrTSData[$_intTSID]["Name"] = $this->objDB->f("TSName"); $this->arrTSData[$_intTSID]["Description"] = $this->objDB->f("Description"); $this->arrTSData[$_intTSID]["Type"] = $this->objDB->f("Type"); $this->arrTSData[$_intTSID]["Owner"] = $this->objDB->f("Owner"); $this->arrTSData[$_intTSID]["Status"] = $this->objDB->f("Status"); if ($this->getTemplateCachePath($_intTSID)) { return true; }else{ return false; } }else{ return false; } } } // End setTSID() /** * 返回模板集 * * Detail description * @param integer $_intTSID : 模板集ID * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function getTSData($_intTSID, $_strKey = "") { if ($this->setTSID($_intTSID)) { if (empty($_strKey)) { return $this->arrTSData[$_intTSID]; }else{ return $this->arrTSData[$_intTSID][$_strKey]; } }else{ return false; } } // End getTemplateSet() /** * 返回模板集 * * Detail description * @param integer $_intTSID : 模板集ID * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function getTemplateSet() { return $this->intTemplateSet; } // End getTemplateSet() /** * 返回模板集 * * Detail description * @param integer $_intTSID : 模板集ID * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function getTemplateCachePath() { if (empty($this->arrTSData[$this->intTemplateSet]["Type"])) { return false; } if ($this->checkTemplateCachePath($this->intTemplateSet)) { return $this->arrTSData[$this->intTemplateSet]["Path"]; }else{ return false; } } // End getTemplateSet() /** * 检查模板集的CACHE径路 * * Detail description * @param integer $_intTSID : 模板集ID * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function checkTemplateCachePath () { $__strTemplateCachePath = $this->getCachePath($this->intTemplateSet); if ($this->checkFile($__strTemplateCachePath)) { $this->arrTSData[$this->intTemplateSet]["Path"] = $__strTemplateCachePath; return true; } if (!array_key_exists($this->intTemplateSet,$this->arrTSData)) { return false; } $__strTSID = (string)$this->intTemplateSet; $__tmpPath = $GLOBALS["PEAK"]["SO"]->getConst("SYSTemplate"); $__tmpPath .= $this->arrTSData[$this->intTemplateSet]["Type"].$GLOBALS["PEAK"]["SO"]->getFSSeparator(); $GLOBALS["PEAK"]["ER"]->debug("strTSID:".$__strTSID, __LINE__,__FILE__,__FUNCTION__,__CLASS__); for ($__i=0;$__i<3 ;$__i++) { $__tmpPath .= $__strTSID[$__i].$GLOBALS["PEAK"]["SO"]->getFSSeparator(); if (!$this->checkFile($__tmpPath)) { if (!mkdir($__tmpPath,0777,1)){ $GLOBALS["PEAK"]["ER"]->warn("Make dir for $__tmpPath failed",__LINE__,__FILE__,__FUNCTION__,__CLASS__); return false; } } } if ($this->checkFile($__tmpPath)) { if (!@mkdir($__tmpPath.$this->intTemplateSet,0777)){ $GLOBALS["PEAK"]["ER"]->warn("Make dir for $__tmpPath failed",__LINE__,__FILE__,__FUNCTION__,__CLASS__); print $PHP_ERROR; return false; } } $this->arrTSData[$this->intTemplateSet]["Path"] = $__strTemplateCachePath; return true; } // End checkTemplateCachePath() /** * 设置模板类型 * * Detail description * @param integer $_intTSID : 模板集ID * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function setTemplateType ($_strTemplateType) { $this->charTemplateType = $_strTemplateType; } /** * 设置模板类型 * * Detail description * @param integer $_intTSID : 模板集ID * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function setTemplate ($_strTemplateType) { $this->charTemplateType = $_strTemplateType; } /** * 检查并加载Cache文件 * * Detail description * @param none * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function checkCachedFiles ($_strTemplateName) { $__tmpCacheFileName = $this->getCacheFileName($_strTemplateName, $this->intTemplateSet); if ($this->checkFile($__tmpCacheFileName)) { $this->arrTSData[$this->intTemplateSet]["Template"][$_strTemplateName] = $__tmpCacheFileName; $this->loadCacheFile($_strTemplateName, $this->intTemplateSet); return true; }else{ // print $_strTemplateName."&&&&&&&&&&&&
"; return $this->makeCacheFile($_strTemplateName); } } /** * 生成Cache文件 * * Detail description * @param string $_strContent : (Optional) 指定内容 * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function makeCacheFile ($_strTemplateName){ if ($this->getCachePath($this->intTemplateSet) != $this->arrTSData[$this->intTemplateSet]["Path"]) { return false; } $__strTempateContent = $this->getTempateContentFromDB($_strTemplateName, $this->intTemplateSet); if (empty($__strTempateContent)) { return false; } // print $_strTemplateName."^^^^^^^^^^^^
"; $__tmpCacheFileName = $this->getCacheFileName($_strTemplateName); if ($this->checkFile($__tmpCacheFileName)) { unlink($__tmpCacheFileName); } if (!$__resFP = fopen($__tmpCacheFileName, 'w')) { //$this->error("Error while opening cache file ($__strFileName)",0); return false; }else{ $__tmpTemplateVarName = $this->getTemplateVarName($_strTemplateName); $__strTempateContent = str_replace("\$","\\\$",$__strTempateContent); $__strTempateContent = "error("Error while writing cache file ($__strFileName)",0); return false; }else { fclose($__resFP); $this->loadCacheFile($_strTemplateName); return true; } fclose($__resFP); } } // end makeCacheFile() /** * 检查文件是否存在 * * Detail description * @param none * @global none * @since 1.0 * @access public * @return boolean * @update 2004-7-15 15:47 */ function checkFile ($_strFilename) { if(!file_exists($_strFilename)) { //$this->error("[$_strFilename] does not exist",0); return false; }else{ return true; } } /** * 从文件名中取得路径 * * Detail description * @param string $_strFileName : 文件名 * @global none * @since 1.0 * @access public * @return string * @update 2004-7-15 15:47 */ function getCachePath ( $_intTSID = 0 ){ if ($_intTSID == 0) { $_intTSID = $this->intTemplateSet; } $__strTSID = strval($_intTSID); $__strTemplateCachePath = $GLOBALS["PEAK"]["SO"]->getConst("SYSTemplate"); $__strTemplateCachePath .= $this->arrTSData[$_intTSID]["Type"].$GLOBALS["PEAK"]["SO"]->getFSSeparator(); $__strTemplateCachePath .= $__strTSID[0].$GLOBALS["PEAK"]["SO"]->getFSSeparator(); $__strTemplateCachePath .= $__strTSID[1].$GLOBALS["PEAK"]["SO"]->getFSSeparator(); $__strTemplateCachePath .= $__strTSID[2].$GLOBALS["PEAK"]["SO"]->getFSSeparator(); $__strTemplateCachePath .= $_intTSID.$GLOBALS["PEAK"]["SO"]->getFSSeparator(); //print $__strTemplateCachePath."+++++++++++++
"; return $__strTemplateCachePath; } /** * 从文件名中取得路径 * * Detail description * @param string $_strFileName : 文件名 * @global none * @since 1.0 * @access public * @return string * @update 2004-7-15 15:47 */ function getTemplateVarName ($_strTemplateName){ $_strTemplateName = str_replace(".","_",$_strTemplateName); return "___TEMPLATE_".$this->intTemplateSet."_".$_strTemplateName; } /** * 从文件名中取得路径 * * Detail description * @param string $_strFileName : 文件名 * @global none * @since 1.0 * @access public * @return string * @update 2004-7-15 15:47 */ function getCacheFileName ($_strTemplateName){ //print $_strTemplateName."--------------
"; return $this->getCachePath($this->intTemplateSet).$_strTemplateName; } /** * 从文件名中取得路径 * * Detail description * @param string $_strFileName : 文件名 * @global none * @since 1.0 * @access public * @return string * @update 2004-7-15 15:47 */ function getTempateContentFromDB ($_strTemplateName, $_intTSID = 0 ){ if ($_intTSID == 0) { $_intTSID = $this->intTemplateSet; } $this->objDB->query("select TemplateBody from ".$this->strTableTemplate." where TSID='".$_intTSID."' and TemplateName='".$_strTemplateName."'"); if ($this->objDB->nextRecord()) { //print $_strTemplateName."|".htmlspecialchars($this->objDB->f("TemplateBody")); return $this->objDB->f("TemplateBody"); }else{ return ""; } } /** * 定义文件名对应 * * Detail description * @param array $_arrFileList : 文件列表数组 * @global none * @since 1.0 * @access public * @return boolean * @update 2004-7-15 15:47 */ function define ($_arrTemplateList){ while ( list ($__strTemplateTag,$__strTemplateName) = each ($_arrTemplateList) ) { // print $__strTemplateName."************
"; if ($this->checkCachedFiles($__strTemplateName , $this->intTemplateSet)) { $this->arrTemplates[$this->intTemplateSet]["$__strTemplateTag"] = $__strTemplateName; }else{ return false; } } return true; } /** * 定义文件名对应 * * Detail description * @param array $_arrFileList : 文件列表数组 * @global none * @since 1.0 * @access public * @return boolean * @update 2004-7-15 15:47 */ function tag2Name ($_strTag){ if (array_key_exists($_strTag,$this->arrTemplates[$this->intTemplateSet])) { return $this->arrTemplates[$this->intTemplateSet][$_strTag]; }else{ return false; } } /** * 定义文件名对应 * * Detail description * @param array $_arrFileList : 文件列表数组 * @global none * @since 1.0 * @access public * @return boolean * @update 2004-7-15 15:47 */ function loadCacheFile ($_strTemplateName){ $__tmpCacheFileName = $this->getCacheFileName($_strTemplateName); if ($this->checkFile($__tmpCacheFileName)) { include($__tmpCacheFileName); $__strVarName = $this->getTemplateVarName($_strTemplateName,$this->intTemplateSet); //if ($__strVarName == "___TEMPLATE_50001_Index_LogContent") { // print $___TEMPLATE_50001_Index_LogContent."
"; //} if (array_key_exists($this->intTemplateSet,$this->arrTemplateContent)) { if (array_key_exists("$_strTemplateName",$this->arrTemplateContent[$this->intTemplateSet])) { return true; } } $this->arrTemplateContent[$this->intTemplateSet][$_strTemplateName]["VarName"] = $__strVarName; $this->arrTemplateContent[$this->intTemplateSet][$_strTemplateName]["Body"] = $$__strVarName; unset($$__strVarName); if (empty($this->arrTemplateContent[$this->intTemplateSet][$_strTemplateName]["Body"])) { return false; }else{ return true; } } } /** * 分配模板标记 * * Detail description * @param array $_arrFT : 列表 * @param string $_strTrailer * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function assign ($_arrFT, $_strTrailer = ""){ if(gettype($_arrFT) == "array") { while ( list ($__strKey,$__tmpVal) = each ($_arrFT) ) { if (!(empty($__strKey))) { $this->arrParseVars["$__strKey"] = ereg_replace('&#', '&#', $__tmpVal); } } } else { if (!empty($_arrFT)) { $this->arrParseVars["$_arrFT"] = ereg_replace('&#', '&#', $_strTrailer); } } } /** * 解析模板 * * Detail description * @param string $_strReturnVar : 设置的模板HANDLE * @param string $_strTemplateTag : 对应的模板文件标记 * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function parse ( $_strReturnVar, $_strTemplateTag ){ //print "ReturnVar::".$_strReturnVar.":
"; $__booleanAppend = false; $this->strLast = $_strReturnVar; $this->arrHandle[$_strReturnVar] = 1; if (gettype($_strTemplateTag) == "array"){ unset($this->$_strReturnVar); while ( list ( $__strKey , $__strVal ) = each ( $_strTemplateTag ) ) { if ( (!isset($this->$__strVal)) || (empty($this->$__strVal)) ) { $this->arrLoaded["$__strVal"] = 1; $__strTemplateName = $this->tag2Name($__strVal); $this->$__strVal = $this->getTemplate($__strTemplateName); } $this->$_strReturnVar = $this->parseTemplate($this->$__strVal,$this->arrParseVars); $this->assign( array( $_strReturnVar => $this->$_strReturnVar ) ); } }else{ $__strVal = $_strTemplateTag; if( (substr($__strVal,0,1)) == '.' ){ $__booleanAppend = true; $__strVal = substr($__strVal,1); } if ( (!isset($this->$__strVal)) || (empty($this->$__strVal)) ){ $this->arrLoaded["$__strVal"] = 1; $__strTemplateName = $this->tag2Name($__strVal); $this->$__strVal = $this->getTemplate($__strTemplateName); } if($__booleanAppend){ if (isset($this->$_strReturnVar)){ $this->$_strReturnVar .= $this->parseTemplate($this->$__strVal,$this->arrParseVars); }else{ $this->$_strReturnVar = $this->parseTemplate($this->$__strVal,$this->arrParseVars); } }else{ $this->$_strReturnVar = $this->parseTemplate($this->$__strVal,$this->arrParseVars); } $this->assign(array( $_strReturnVar => $this->$_strReturnVar) ); } return; } // End parse() /** * 获取模板 * * Detail description * @param string $_strTemplate : 模板名称 * @global none * @since 1.0 * @access public * @return string * @update 2004-7-15 15:47 */ function getTemplate ($_strTemplateName){ $__strContents = $this->arrTemplateContent[$this->intTemplateSet][$_strTemplateName]["Body"]; if( (!$__strContents) or (empty($__strContents)) ){ $this->error("getTemplate() failure: [$_strTemplateName] ".$GLOBALS["php_errormsg"],0); } return $__strContents; } // end getTemplate /** * 打印模板内容 * * Detail description * @param string $_strTemplate : (Optional)指定模板 * @param boolean $_booleanReturnString : (Optional)是否返回字符串 * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function FastPrint ( $_strTemplate = "", $_booleanReturnString = FALSE ) { if(empty($_strTemplate)) { $_strTemplate = $this->strLast; } if( (!(isset($this->$_strTemplate))) || (empty($this->$_strTemplate)) ) { $this->error("Nothing parsed, nothing printed",0); return; }else{ if (!get_magic_quotes_gpc()) { $this->$_strTemplate = stripslashes($this->$_strTemplate); } if (!$_booleanReturnString) { print $this->$_strTemplate; }else{ return $this->$_strTemplate; } return; } } // end FastPrint() /** * 解析单个模板 * * Detail description * @param string $_strTemplate : 模板内容字符串 * @param string $_arrVariables : 标记数组 * @global none * @since 1.0 * @access public * @return string * @update 2004-7-15 15:47 */ function parseTemplate ($_strTemplate, $_arrVariables) { while ( list ($__strKey, $__tmpVal) = each ($_arrVariables) ) { if (!(empty($__strKey))) { if(gettype($__tmpVal) != "string") { settype($__tmpVal, "string"); } $__strKey = ''; $_strTemplate = ereg_replace("$__strKey","$__tmpVal","$_strTemplate"); } } $_strTemplate = str_replace("","",$_strTemplate); return $_strTemplate; } // end parseTemplate(); /** * 打印模板内容 * * Detail description * @param string $_strTemplate : (Optional)指定模板 * @param boolean $_booleanReturnString : (Optional)是否返回字符串 * @global none * @since 1.0 * @access public * @return void * @update 2004-7-15 15:47 */ function getBlogListOptions () { if (array_key_exists("BBCS_Blogs", $GLOBALS["_SESSION"])) { $__arrBlogs = $GLOBALS["_SESSION"]["BBCS_Blogs"]; $__strString = ""; foreach ($__arrBlogs as $__strBlogID => $__strBlogName) { $__intBlogID = substr($__strBlogID, 3); $__strString .= "\n"; } return $__strString; }else{ return ""; } } // end getBlogListOptions() } // end FastTemplate // Set internal character encoding to UTF-8 // header("Content-Type: text/html; charset=UTF-8"); // End ?>
Fatal error: Class 'FastTemplate' not found in /srv/_sys-v5/site/noaccess/include/libs/SystemOperator.class.php(380) : eval()'d code on line 1