echo $tpl->finish($tpl->get("out"));
解决方案 »
- 求助php超链接的一个问题
- 关于小数点后取数问题,急急急急急急急急急,,在线等立即给分
- 请问怎么提取一段字符串中的汉字内容(包括标点最好能包括换行符什么的)
- 如何利用php把缓存页面下来
- 一道基础php面试题,想不通
- 新手求助:Permission denied in c:\inetpub\wwwroot\index.php
- 在使用mssql提交字段内容经常出现数据益出,如何搞好???
- 来帮帮啊,怎样在WINDOWS2000SERVER下架设PHP啊???
- 关于mssql_fetch_array的问题
- 为啥下载的文件会是损坏的额?? 这是什么问题??????? 求大神什么的
- 这段代码在我本机的apache下运行即可用,可我传到服务器上后就不好用了为什么呢?
- 关于INI_SET函数
一、修改template.inc
加入以下的几个函数:
/******************************************************************************
函数:savetofile ($dir,$varname)
功能:将分析结果保存到文件中去
参数:$dir,$varname 文件路径,分析结果
*/
function savetofile ($dir,$varname){
$data=$this->finish($this->get_var($varname));
$fp = fopen($dir,"w+");
fwrite($fp,$data);
}
/******************************************************************************
函数:renew ()
功能:清除已赋值数组,以免批生成文件的时候变量之间相互影响
参数:无
*/
function renew(){
$this->varkeys = array();
$this->varvals = array();
//$this->file = array();
}二、生成静态文件过程(仅供参考)
function staticInfo($aid){
global $db,$tbl,$template,$fpath,$file;
$sql="SELECT title,content,hits,title_name,come_from,writer,datetime FROM $tbl where news_id=$aid";
$db->query($sql);
$db->next_record();
//取出数据
$template->set_var(array("content" => $db->f("content"),"title" => $db->f("title"),"datetime" => $db->f("datetime"),"writer" => $db->f("writer"),"come_from" => $db->f("come_from")));
$template->parse("mains",$file);
//把分析结果mains存入静态文件
$filename = ARTICLE_PATH.$fpath."/".srandnum().time().".htm";
$template->savetofile("../".$filename,"mains");
echo $filename."<br>";
//置空
$template->renew();
//把旧文件删除,新文件路径保存到数据库
$sql = "select filepath from $tbl where news_id=$aid and checked=1";
if($db->query($sql)){
$db->next_record();
@unlink("../".$db->f("filepath"));
}
//标识为已审核新闻
$sql = "update $tbl set filepath='$filename',checked=1 where news_id=$aid";
$db->query($sql);
}
$newslist = $_POST['fldTblList'];
$id = explode(",",$newslist);for($i=0;$i<count($id);$i++){
staticInfo($id[$i]);
}
里面不是有一个get_var()函数吗?
用这个可以取得解析后的模版。