![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
[php]if(!defined("__CLASS_TEMPLATE__")) 看上去发生了轻微的错误.\n";
{
define("__CLASS_TEMPLATE__",1);
function EvalTemplate($templatefile, $vars, $is_admin=1)
{
global $BASE_ADMIN_TEMPLATE_PATH,$BASE_THEME_PATH,$BASE_PATH;
if($is_admin == 1)
{
$read_templatefile = $BASE_ADMIN_TEMPLATE_PATH.$templatefile;
}
elseif($is_admin == 0)
{
if(file_exists($BASE_THEME_PATH.$templatefile))
{
$read_templatefile = $BASE_THEME_PATH.$templatefile;
}
elseif(file_exists($BASE_PATH."themes/default/".$templatefile))
{
$read_templatefile = $BASE_PATH."themes/default/".$templatefile;
}
else
{
$msg = "没有找到模板文件:".$BASE_THEME_PATH.$templatefile;
email_error($msg);
}
}
$read = file($read_templatefile);
$i = 0;
while($i
$read[$i] = chop($read[$i])."\n";
$i++;
}
$line=implode($read, "");
eval("global $vars;");
$vars = str_replace(",","",$vars);
$var_list = explode("\$",$vars);
$i=0;
while($i <= sizeof($var_list))
{
$line = str_replace("<%$var_list[$i]%>",$$var_list[$i],$line);
$i++;
}
global $cat;
$line = str_replace("<%cat%>",$cat,$line);
return $line;
}
function DisplayTemplate($templatefile, $vars, $is_admin=1)
{
global $BASE_ADMIN_TEMPLATE_PATH,$BASE_THEME_PATH,$BASE_PATH,$theme_path;
if($is_admin == 1)
{
$read_templatefile = $BASE_ADMIN_TEMPLATE_PATH.$templatefile;
}
elseif($is_admin == 0)
{
if(file_exists($BASE_THEME_PATH.$templatefile))
{
$read_templatefile = $BASE_THEME_PATH.$templatefile;
}
else
{
$read_templatefile = $BASE_PATH."themes/default/".$templatefile;
}
}
$read = file($read_templatefile);
$i = 0;
while($i
$read[$i] = chop($read[$i])."\n";
$i++;
}
$line=implode($read, "");
eval("global $vars;");
$vars = str_replace(",","",$vars);
$var_list = explode("\$",$vars);
$i = 0;
while($i<=sizeof($var_list))
{
$line = str_replace("<%$var_list[$i]%>",$$var_list[$i],$line);
$i++;
}
global $cat;
$line = str_replace("<%cat%>",$cat,$line);
//$line = str_replace("\n","\r",$line);
$preg = "/
//$preg = "/
preg_match_all($preg,$line,$out,PREG_SET_ORDER);
$lines = preg_split($preg,$line);
if(sizeof($lines)>1)
{
$loop_line=0;
while(!empty($out[$loop_line][1]))
{
print $lines[$loop_line];
eval($out[$loop_line][1]);
$loop_line++;
if(empty($out[$loop_line][1]))
{
print $lines[$loop_line];
}
}
}
else
{
print $lines[0];
}
}
function revers_htmlspecialchars($msg)
{
$msg = str_replace("/>/i", ">", $msg);
$msg = str_replace("/</i", "<", $msg);
$msg = str_replace("/"/i", "\"", $msg);
$msg = str_replace("/&/i", "&", $msg);
return $msg;
}
function email_error($msg)
{
global $technical_email;
$message = "有一个模板错误: $msg\n";
$message .= "日期: ".date("Y-m-d H:i:s")."\n";
$message .= "脚本: ".getenv("REQUEST_URI")."\n";
$message .= "来自: ".getenv("HTTP_REFERER")."\n";
$message.="所在行: ".getenv("__LINE__")."\n";
//echo $message;
@mail ($technical_email,"有一个模板错误!",$message);
echo "\n\n";
echo "\n
echo "请再刷新尝试一下.
echo "一封电邮已经发送给我们的technical_email\">技术人员, 如果问题依然, 您也可以联系他.
echo "
如有不便, 敬请原谅.
";die("");
}
}
[/php]

