",$this->Fields[$this->SplitPageField]);
$i = 1; foreach($this->SplitFields as $k=>$v) { $tmpv = cn_substr($v,50); $pos = strpos($tmpv,'#e#'); if($pos>0) { $st = trim(cn_substr($tmpv,$pos)); if($st==""||$st=="副标题"||$st=="分页标题") { $this->SplitFields[$k] = preg_replace("/^(.*)#e#/is","",$v); continue; } else { $this->SplitFields[$k] = preg_replace("/^(.*)#e#/is","",$v); $this->SplitTitles[$k] = $st; } } else { continue; } $i++; } $this->TotalPage = count($this->SplitFields); $this->Fields['totalpage'] = $this->TotalPage; }
//处理默认缩略图等 if($this->Fields['litpic'] == '-' || $this->Fields['litpic'] == '') { $this->Fields['litpic'] = $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif'; } if(!eregi("^http://",$this->Fields['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { $this->Fields['litpic'] = $GLOBALS['cfg_mainsite'].$this->Fields['litpic']; } $this->Fields['picname'] = $this->Fields['litpic'];
//模板里直接使用{dede:field name='image'/}获取缩略图 $this->Fields['image'] = (!eregi('jpg|gif|png', $this->Fields['picname']) ? '' : "<img src='{$this->Fields['picname']}' />");
//digg if($this->Fields['goodpost'] + $this->Fields['badpost'] == 0) { $this->Fields['goodper'] = $this->Fields['badper'] = 0; } else { $this->Fields['goodper'] = number_format($this->Fields['goodpost']/($this->Fields['goodpost']+$this->Fields['badpost']), 3)*100; $this->Fields['badper'] = 100 - $this->Fields['goodper']; }
}
//获得当前字段参数 function GetCurTag($fieldname) { if(!isset($this->dtp->CTags)) { return ''; } foreach($this->dtp->CTags as $ctag) { if($ctag->GetTagName()=='field' && $ctag->GetAtt('name')==$fieldname) { return $ctag; } else { continue; } } return ''; }
//生成静态HTML function MakeHtml($isremote=0) { global $cfg_remote_site,$fileFirst; if($this->IsError) { return ''; } $this->Fields["displaytype"] = "st"; //预编译$th $this->LoadTemplet(); $this->ParAddTable(); $this->ParseTempletsFirst();
//分析要创建的文件名称 $filename = GetFileNewName( $this->ArcID,$this->Fields['typeid'],$this->Fields['senddate'], $this->Fields['title'],$this->Fields['ismake'],$this->Fields['arcrank'], $this->TypeLink->TypeInfos['namerule'],$this->TypeLink->TypeInfos['typedir'],$this->Fields['money'],$this->Fields['filename'] );
$filenames = explode(".", $filename); $this->ShortName = $filenames[count($filenames)-1]; if($this->ShortName=='') $this->ShortName = 'html'; $fileFirst = eregi_replace("\.".$this->ShortName."$", "", $filename); $this->Fields['namehand'] = basename($fileFirst); $filenames = explode("/",$filename); $this->NameFirst = eregi_replace("\.".$this->ShortName."$","",$filenames[count($filenames)-1]); if($this->NameFirst=='') { $this->NameFirst = $this->arcID; }
//获得当前文档的全名 $filenameFull = GetFileUrl( $this->ArcID,$this->Fields['typeid'],$this->Fields["senddate"], $this->Fields["title"],$this->Fields["ismake"], $this->Fields["arcrank"],$this->TypeLink->TypeInfos['namerule'],$this->TypeLink->TypeInfos['typedir'],$this->Fields["money"],$this->Fields['filename'], $this->TypeLink->TypeInfos['moresite'],$this->TypeLink->TypeInfos['siteurl'],$this->TypeLink->TypeInfos['sitepath'] ); $this->Fields['arcurl'] = $this->Fields['fullname'] = $filenameFull;
//对于已设置不生成HTML的文章直接返回网址 if($this->Fields['ismake']==-1 || $this->Fields['arcrank']!=0 || $this->Fields['money']>0 || ($this->Fields['typeid']==0 && $this->Fields['channel'] != -1) ) { return $this->GetTrueUrl($filename); } //循环生成HTML文件 else { for($i=1;$i<=$this->TotalPage;$i++) { if($this->TotalPage > 1) { $this->Fields['tmptitle'] = (empty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle']); if($i>1) $this->Fields['title'] = $this->Fields['tmptitle']."($i)"; } if($i>1) { $truefilename = $this->GetTruePath().$fileFirst."_".$i.".".$this->ShortName; } else { $truefilename = $this->GetTruePath().$filename; } $this->ParseDMFields($i,1); $this->dtp->SaveTo($truefilename); //如果启用远程发布则需要进行判断 if($cfg_remote_site=='Y' && $isremote == 1) {
//分析远程文件路径 $remotefile = str_replace(DEDEROOT, '', $truefilename); $localfile = '..'.$remotefile; //创建远程文件夹 $remotedir = preg_replace('/[^\/]*\.html/', '', $remotefile); $this->ftp->rmkdir($remotedir); $this->ftp->upload($localfile, $remotefile, 'ascii'); } } } $this->dsql->ExecuteNoneQuery("Update `zuimoban_archives` set ismake=1 where id='".$this->ArcID."'"); return $this->GetTrueUrl($filename); }
//获得真实连接路径 function GetTrueUrl($nurl) { return GetFileUrl ( $this->Fields['id'], $this->Fields['typeid'], $this->Fields['senddate'], $this->Fields['title'], $this->Fields['ismake'], $this->Fields['arcrank'], $this->TypeLink->TypeInfos['namerule'], $this->TypeLink->TypeInfos['typedir'], $this->Fields['money'], $this->Fields['filename'], $this->TypeLink->TypeInfos['moresite'], $this->TypeLink->TypeInfos['siteurl'], $this->TypeLink->TypeInfos['sitepath'] ); }
//获得站点的真实根路径 function GetTruePath() { $truepath = $GLOBALS["cfg_basedir"]; return $truepath; }
//获得指定键值的字段 function GetField($fname, $ctag) { //所有Field数组 OR 普通Field if($fname=='array') { return $this->Fields; } //指定了ID的节点 else if($ctag->GetAtt('noteid') != '') { if( isset($this->Fields[$fname.'_'.$ctag->GetAtt('noteid')]) ) { return $this->Fields[$fname.'_'.$ctag->GetAtt('noteid')]; } } else if( isset($this->Fields[$fname]) ) { return $this->Fields[$fname]; } return ''; }
//获得模板文件位置 function GetTempletFile() { global $cfg_basedir,$cfg_templets_dir,$cfg_df_style; $cid = $this->ChannelUnit->ChannelInfos['nid']; if(!empty($this->Fields['templet'])) { $filetag = MfTemplet($this->Fields['templet']); if( !ereg('/', $filetag) ) $filetag = $GLOBALS['cfg_df_style'].'/'.$filetag; } else { $filetag = MfTemplet($this->TypeLink->TypeInfos["temparticle"]); } $tid = $this->Fields['typeid']; $filetag = str_replace('{cid}', $cid,$filetag); $filetag = str_replace('{tid}', $tid,$filetag); $tmpfile = $cfg_basedir.$cfg_templets_dir.'/'.$filetag; if($cid=='spec') { if( !empty($this->Fields['templet']) ) { $tmpfile = $cfg_basedir.$cfg_templets_dir.'/'.$filetag; } else { $tmpfile = $cfg_basedir.$cfg_templets_dir."/{$cfg_df_style}/article_spec.htm"; } } if(!file_exists($tmpfile)) { $tmpfile = $cfg_basedir.$cfg_templets_dir."/{$cfg_df_style}/".($cid=='spec' ? 'article_spec.htm' : 'article_default.htm'); } return $tmpfile; }
//动态输出结果 function display() { global $htmltype; if($this->IsError) { return ''; } $this->Fields["displaytype"] = "dm"; if($this->NowPage > 1) $this->Fields["title"] = $this->Fields["title"]."({$this->NowPage})"; //预编译 $this->LoadTemplet(); $this->ParAddTable();
$this->ParseTempletsFirst();
//跳转网址 $this->Fields['flag']=empty($this->Fields['flag'])? "" : $this->Fields['flag']; if(ereg('j', $this->Fields['flag']) && $this->Fields['redirecturl'] != '') { if($GLOBALS['cfg_jump_once']=='N') { $pageHtml = "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$GLOBALS['cfg_soft_lang']."\">\r\n<title>".$this->Fields['title']."</title>\r\n"; $pageHtml .= "<meta http-equiv=\"refresh\" content=\"3;URL=".$this->Fields['redirecturl']."\">\r\n</head>\r\n<body>\r\n"; $pageHtml .= "现在正在转向:".$this->Fields['title'].",请稍候...<br/><br/>\r\n转向内容简介:".$this->Fields['description']."\r\n</body>\r\n</html>\r\n"; echo $pageHtml; } else { header("location:{$this->Fields['redirecturl']}"); } exit(); } $pageCount = $this->NowPage; $this->ParseDMFields($pageCount,0); $this->dtp->display(); }
//载入模板 function LoadTemplet() { if($this->TempSource=='') { $tempfile = $this->GetTempletFile(); if(!file_exists($tempfile) || !is_file($tempfile)) { echo "文档ID:{$this->Fields['id']} - {$this->TypeLink->TypeInfos['typename']} - {$this->Fields['title']}<br />"; echo "模板文件不存在,无法解析文档!"; exit(); } $this->dtp->LoadTemplate($tempfile); $this->TempSource = $this->dtp->SourceString; } else { $this->dtp->LoadSource($this->TempSource); } }
//解析模板,对固定的标记进行初始给值 function ParseTempletsFirst() { if(empty($this->Fields['keywords'])) { $this->Fields['keywords'] = ''; }
if(empty($this->Fields['reid'])) { $this->Fields['reid'] = 0; }
$GLOBALS['envs']['tags'] = $this->Fields['tags'];
if(isset($this->TypeLink->TypeInfos['reid'])) { $GLOBALS['envs']['reid'] = $this->TypeLink->TypeInfos['reid']; }
$GLOBALS['envs']['keyword'] = $this->Fields['keywords'];
$GLOBALS['envs']['typeid'] = $this->Fields['typeid'];
$GLOBALS['envs']['topid'] = GetTopid($this->Fields['typeid']);
$GLOBALS['envs']['aid'] = $GLOBALS['envs']['id'] = $this->Fields['id'];
$GLOBALS['envs']['adminid'] = $GLOBALS['envs']['mid'] = $this->Fields['mid'];
$GLOBALS['envs']['channelid'] = $this->TypeLink->TypeInfos['channeltype'];
if($this->Fields['reid']>0) { $GLOBALS['envs']['typeid'] = $this->Fields['reid']; }
MakeOneTag($this->dtp, $this, 'N'); }
//解析模板,对内容里的变动进行赋值 function ParseDMFields($pageNo,$ismake=1) { $this->NowPage = $pageNo; $this->Fields['nowpage'] = $this->NowPage; if($this->SplitPageField!='' && isset($this->Fields[$this->SplitPageField])) { $this->Fields[$this->SplitPageField] = $this->SplitFields[$pageNo - 1]; if($pageNo>1) $this->Fields['description'] = trim(ereg_replace("[\r\n\t]", ' ', cn_substr(html2text($this->Fields[$this->SplitPageField]), 200))); }
//解析模板 if(is_array($this->dtp->CTags)) { foreach($this->dtp->CTags as $i=>$ctag) { if($ctag->GetName()=='field') { $this->dtp->Assign($i, $this->GetField($ctag->GetAtt('name'), $ctag) ); } else if($ctag->GetName()=='pagebreak') { if($ismake==0) { $this->dtp->Assign($i,$this->GetPagebreakDM($this->TotalPage,$this->NowPage,$this->ArcID)); } else { $this->dtp->Assign($i,$this->GetPagebreak($this->TotalPage,$this->NowPage,$this->ArcID)); } } else if($ctag->GetName()=='pagetitle') { if($ismake==0) { $this->dtp->Assign($i,$this->GetPageTitlesDM($ctag->GetAtt("style"),$pageNo)); } else { $this->dtp->Assign($i,$this->GetPageTitlesST($ctag->GetAtt("style"),$pageNo)); } } else if($ctag->GetName()=='prenext') { $this->dtp->Assign($i,$this->GetPreNext($ctag->GetAtt('get'))); } else if($ctag->GetName()=='fieldlist') { $innertext = trim($ctag->GetInnerText()); if($innertext=='') $innertext = GetSysTemplets('tag_fieldlist.htm'); $dtp2 = new DedeTagParse(); $dtp2->SetNameSpace('field','[',']'); $dtp2->LoadSource($innertext); $oldSource = $dtp2->SourceString; $oldCtags = $dtp2->CTags; $res = ''; if(is_array($this->ChannelUnit->ChannelFields) && is_array($dtp2->CTags)) { foreach($this->ChannelUnit->ChannelFields as $k=>$v) { if(isset($v['autofield']) && empty($v['autofield'])) { continue; } $dtp2->SourceString = $oldSource; $dtp2->CTags = $oldCtags; $fname = $v['itemname']; foreach($dtp2->CTags as $tid=>$ctag2) { if($ctag2->GetName()=='name') { $dtp2->Assign($tid,$fname); } else if($ctag2->GetName()=='tagname') { $dtp2->Assign($tid,$k); } else if($ctag2->GetName()=='value') { $this->Fields[$k] = $this->ChannelUnit->MakeField($k,$this->Fields[$k],$ctag2); @$dtp2->Assign($tid,$this->Fields[$k]); } } $res .= $dtp2->GetResult(); } } $this->dtp->Assign($i,$res); }//end case
}//结束模板循环
} }
//关闭所占用的资源 function Close() { $this->FixedValues = ''; $this->Fields = ''; }
//获取上一篇,下一篇链接 function GetPreNext($gtype='') { $rs = ''; if(count($this->PreNext)<2) { $aid = $this->ArcID; $preR = $this->dsql->GetOne("Select id From `zuimoban_arctiny` where id<$aid And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id desc"); $nextR = $this->dsql->GetOne("Select id From `zuimoban_arctiny` where id>$aid And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id asc"); $next = (is_array($nextR) ? " where arc.id={$nextR['id']} " : ' where 1>2 '); $pre = (is_array($preR) ? " where arc.id={$preR['id']} " : ' where 1>2 '); $query = "Select arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic, t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath from `zuimoban_archives` arc left join zuimoban_arctype t on arc.typeid=t.id "; $nextRow = $this->dsql->GetOne($query.$next); $preRow = $this->dsql->GetOne($query.$pre); if(is_array($preRow)) { $mlink = GetFileUrl($preRow['id'],$preRow['typeid'],$preRow['senddate'],$preRow['title'],$preRow['ismake'],$preRow['arcrank'], $preRow['namerule'],$preRow['typedir'],$preRow['money'],$preRow['filename'],$preRow['moresite'],$preRow['siteurl'],$preRow['sitepath']); $this->PreNext['pre'] = "上一篇:<a href='$mlink'>{$preRow['title']}</a> "; $this->PreNext['preimg'] = "<a href='$mlink'><img src=\"{$preRow['litpic']}\" alt=\"{$preRow['title']}\"/></a> "; } else { $this->PreNext['pre'] = "上一篇:没有了 "; $this->PreNext['preimg'] ="<img src=\"/templets/default/images/nophoto.jpg\" alt=\"对不起,没有上一图集了!\"/>"; } if(is_array($nextRow)) { $mlink = GetFileUrl($nextRow['id'],$nextRow['typeid'],$nextRow['senddate'],$nextRow['title'],$nextRow['ismake'],$nextRow['arcrank'], $nextRow['namerule'],$nextRow['typedir'],$nextRow['money'],$nextRow['filename'],$nextRow['moresite'],$nextRow['siteurl'],$nextRow['sitepath']); $this->PreNext['next'] = "下一篇:<a href='$mlink'>{$nextRow['title']}</a> "; $this->PreNext['nextimg'] = "<a href='$mlink'><img src=\"{$nextRow['litpic']}\" alt=\"{$nextRow['title']}\"/></a> "; } else { $this->PreNext['next'] = "下一篇:没有了 "; $this->PreNext['nextimg'] ="<a href='javascript:void(0)' alt=\"\"><img src=\"/templets/default/images/nophoto.jpg\" alt=\"对不起,没有下一图集了!\"/></a>"; } } if($gtype=='pre') { $rs = $this->PreNext['pre']; } else if($gtype=='preimg'){
$rs = $this->PreNext['preimg']; } else if($gtype=='next') { $rs = $this->PreNext['next']; } else if($gtype=='nextimg'){
$rs = $this->PreNext['nextimg']; } else { $rs = $this->PreNext['pre']." ".$this->PreNext['next']; } return $rs; }
//获得动态页面分页列表 function GetPagebreakDM($totalPage,$nowPage,$aid) { global $cfg_rewrite; if($totalPage==1) { return ""; } $PageList = "<a>共".$totalPage."页: </a>"; $nPage = $nowPage-1; $lPage = $nowPage+1; if($nowPage==1) { $PageList.="<a href='#'>上一页</a>"; } else { if($nPage==1) { $PageList.="<a href='view.php?aid=$aid'>上一页</a>"; if($cfg_rewrite == 'Y') { $PageList = preg_replace("/.php\?aid=(\d+)/i",'-\\1-1.html',$PageList); } } else { $PageList.="<a href='view.php?aid=$aid&pageno=$nPage'>上一页</a>"; if($cfg_rewrite == 'Y') { $PageList = str_replace(".php?aid=","-",$PageList); $PageList = preg_replace("/&pageno=(\d+)/i",'-\\1.html',$PageList); } } } for($i=1;$i<=$totalPage;$i++) { if($i==1) { if($nowPage!=1) { $PageList.="<a href='view.php?aid=$aid'>1</a>"; if($cfg_rewrite == 'Y') { $PageList = preg_replace("/.php\?aid=(\d+)/i",'-\\1-1.html',$PageList); } } else { $PageList.="<a>1</a>"; } } else { $n = $i; if($nowPage!=$i) { $PageList.="<a href='view.php?aid=$aid&pageno=$i'>".$n."</a>"; if($cfg_rewrite == 'Y') { $PageList = str_replace(".php?aid=","-",$PageList); $PageList = preg_replace("/&pageno=(\d+)/i",'-\\1.html',$PageList); } } else { $PageList.="<a href='#'>{$n}</a>"; } } } if($lPage <= $totalPage) { $PageList.="<a href='view.php?aid=$aid&pageno=$lPage'>下一页</a>"; if($cfg_rewrite == 'Y') { $PageList = str_replace(".php?aid=","-",$PageList); $PageList = preg_replace("/&pageno=(\d+)/i",'-\\1.html',$PageList); } } else { $PageList.= "<a href='#'>下一页</a>"; } return $PageList; }
//获得静态页面分页列表 function GetPagebreak($totalPage,$nowPage,$aid) { if($totalPage==1) { return ""; } $PageList = "<a>共".$totalPage."页: </a>"; $nPage = $nowPage-1; $lPage = $nowPage+1; if($nowPage==1) { $PageList.="<a href='#'>上一页</a>"; } else { if($nPage==1) { $PageList.="<a href='".$this->NameFirst.".".$this->ShortName."'>上一页</a>"; } else { $PageList.="<a href='".$this->NameFirst."_".$nPage.".".$this->ShortName."'>上一页</a>"; } } for($i=1;$i<=$totalPage;$i++) { if($i==1) { if($nowPage!=1) { $PageList.="<a href='".$this->NameFirst.".".$this->ShortName."'>1</a>"; } else { $PageList.="<a href='#'>1</a>"; } } else { $n = $i; if($nowPage!=$i) { $PageList.="<a href='".$this->NameFirst."_".$i.".".$this->ShortName."'>".$n."</a>"; } else { $PageList.="<a href='#'>{$n}</a>"; } } } if($lPage <= $totalPage) { $PageList.="<a href='".$this->NameFirst."_".$lPage.".".$this->ShortName."'>下一页</a>"; } else { $PageList.= "<a href='#'>下一页</a>"; } return $PageList; }
//获得动态页面小标题 function GetPageTitlesDM($styleName,$pageNo) { if($this->TotalPage==1) { return ""; } if(count($this->SplitTitles)==0) { return ""; } $i=1; $aid = $this->ArcID; if($styleName=='link') { $revalue = ""; foreach($this->SplitTitles as $k=>$v) { if($i==1) { $revalue .= "<a href='view.php?aid=$aid&pageno=$i'>$v</a> \r\n"; } else { if($pageNo==$i) { $revalue .= " $v \r\n"; } else { $revalue .= "<a href='view.php?aid=$aid&pageno=$i'>$v</a> \r\n"; } } $i++; } } else { $revalue = "<select id='dedepagetitles' onchange='location.href=this.options[this.selectedIndex].value;'>\r\n"; foreach($this->SplitTitles as $k=>$v) { if($i==1) { $revalue .= "<option value='".$this->Fields['phpurl']."/view.php?aid=$aid&pageno=$i'>{$i}、{$v}</option>\r\n"; } else { if($pageNo==$i) { $revalue .= "<option value='".$this->Fields['phpurl']."/view.php?aid=$aid&pageno=$i' selected>{$i}、{$v}</option>\r\n"; } else { $revalue .= "<option value='".$this->Fields['phpurl']."/view.php?aid=$aid&pageno=$i'>{$i}、{$v}</option>\r\n"; } } $i++; } $revalue .= "</select>\r\n"; } return $revalue; }
//获得静态页面小标题 function GetPageTitlesST($styleName,$pageNo) { if($this->TotalPage==1) { return ""; } if(count($this->SplitTitles)==0) { return ""; } $i=1; if($styleName=='link') { $revalue = ""; foreach($this->SplitTitles as $k=>$v) { if($i==1) { $revalue .= "<a href='".$this->NameFirst.".".$this->ShortName."'>$v</a> \r\n"; } else { if($pageNo==$i) { $revalue .= " $v \r\n"; } else { $revalue .= "<a href='".$this->NameFirst."_".$i.".".$this->ShortName."'>$v</a> \r\n"; } } $i++; } } else { $revalue = "<select id='dedepagetitles' onchange='location.href=this.options[this.selectedIndex].value;'>\r\n"; foreach($this->SplitTitles as $k=>$v) { if($i==1) { $revalue .= "<option value='".$this->NameFirst.".".$this->ShortName."'>{$i}、{$v}</option>\r\n"; } else { if($pageNo==$i) { $revalue .= "<option value='".$this->NameFirst."_".$i.".".$this->ShortName."' selected>{$i}、{$v}</option>\r\n"; } else { $revalue .= "<option value='".$this->NameFirst."_".$i.".".$this->ShortName."'>{$i}、{$v}</option>\r\n"; } } $i++; } $revalue .= "</select>\r\n"; } return $revalue; }
/** * 高亮问题修正, 排除alt title <a></a>直接的字符替换 * * @param string $kw * @param string $body * @return string */ function ReplaceKeyword($kw,&$body) { global $cfg_cmspath; $maxkey = 5; $kws = explode(",",trim($kw)); //以分好为间隔符 $i=0; $karr = $kaarr = $GLOBALS['replaced'] = array();
//暂时屏蔽超链接 $body = preg_replace("/(<a(.*))(>)(.*)(<)(\/a>)/isU", '\\1-]-\\4-[-\\6', $body);
foreach($kws as $k) { $k = trim($k); if($k!="") { if($i > $maxkey) { break; } $myrow = $this->dsql->GetOne("select * from zuimoban_keywords where keyword='$k' And rpurl<>'' "); if(is_array($myrow)) { $karr[] = $k; $GLOBALS['replaced'][$k] = 0; $kaarr[] = "<a href='{$myrow['rpurl']}'><u>$k</u></a>"; } $i++; } } $body = preg_replace("/(^|>)([^<]+)(?=<|$)/sUe", "_highlight('\\2', \$karr, \$kaarr, '\\1')", $body);
//恢复超链接 $body = preg_replace("/(<a(.*))-\]-(.*)-\[-(\/a>)/isU", '\\1>\\3<\\4', $body); return $body; }
}//End Archives
//高亮专用, 替换多次是可能不能达到最多次 function _highlight($string, $words, $result, $pre) { global $cfg_replace_num; $string = str_replace('\"', '"', $string); if($cfg_replace_num > 0) { foreach ($words as $key => $word) { if($GLOBALS['replaced'][$word] == 1) { continue; } $string = preg_replace("/".preg_quote($word)."/", $result[$key], $string, $cfg_replace_num); if(strpos($string, $word) !== false) { $GLOBALS['replaced'][$word] = 1; } } } else { $string = str_replace($words, $result, $string); } return $pre.$string; }
(责任编辑:最模板) |