📄 template.php
字号:
<?php
!function_exists('readover') && exit('Forbidden');
require_once(R_P.'require/bbscode.php');
include_once(R_P."data/style/$db_defaultstyle.php");
if(!file_exists(R_P."template/$tplpath/readtpl.htm")){
$tplpath='wind';
}
$db_union && $db_union=explode("\t",stripslashes($db_union));
include_once(R_P."data/bbscache/forumcache.php");
if($tid){
ob_end_clean();
$path='../../..';
$yeyestyle=='no' ? $i_table="bgcolor=$tablecolor" : $i_table='class=i_table';
$S_sql=',tm.*,p.voteopts,p.pollid,m.uid,m.username,m.oicq,m.groupid,m.memberid,m.icon AS micon,m.hack,m.honor,m.signature,m.regdate,m.signchange,md.onlinetime,md.postnum,md.digests,md.rvrc,md.money,md.credit,md.thisvisit';
$J_sql='LEFT JOIN pw_tmsgs tm ON t.tid=tm.tid LEFT JOIN pw_members m ON m.uid=t.authorid LEFT JOIN pw_memberdata md ON md.uid=t.authorid LEFT JOIN pw_polls p ON p.pollid=t.pollid';
$read = $db->get_one("SELECT t.* $S_sql FROM pw_threads t $J_sql WHERE t.tid='$tid'");
$usehtm=1;
if($foruminfo['allowvisit']){
$usehtm=0;
}elseif($foruminfo['password']){
$usehtm=0;
}elseif($foruminfo['allowsell'] && strpos($read['content'],"[sell") !== false && strpos($read['content'],"[/sell]") !== false){
$usehtm=0;
} elseif($foruminfo['allowhide'] && strpos($read['content'],"[post]") !== false && strpos($read['content'],"[/post]") !== false){
$usehtm=0;
} elseif($foruminfo['allowencode'] && strpos($read['content'],"[hide") !== false && strpos($read['content'],"[/hide]") !== false){
$usehtm=0;
} elseif(!$ifcheck){
$usehtm=0;
}
$date=date('ym',$read['postdate']);
if(!$usehtm && file_exists(R_P."htm_data/$fid/$date/$tid.html"))unlink(R_P."htm_data/$fid/$date/$tid.html");
$page=floor($article/$db_readperpage)+1;//修改的帖子所在的页数
$count= $read['replies']+1;
if($usehtm && ($page==1 || $read['replies']<=$db_readperpage || $read['replies']%$db_readperpage==0 || !file_exists(R_P."htm_data/$fid/$date/$tid.html"))){
if($foruminfo['cms']){
include_once(R_P.'data/bbscache/c_cache.php');
include_once(R_P.'data/bbscache/c_config.php');
if(strpos($REQUEST_URI,'c_post')!==false){
$db_http=='N' && $imgpath=$H_url.'/'.$imgpath;
} else{
$db_http=='N' && $imgpath=$B_url.'/'.$imgpath;
}
include_once(R_P.'data/bbscache/forum_cache.php');
$_cmscate=array();
foreach($forum as $key=>$value){
if($value['cms'] && $value['type']=='forum' && !$value['ifhide']){
$htmurl="htm_data/$value[fid]/";
if(file_exists(R_P.$htmurl.'index.html') && @filesize(R_P.$htmurl.'index.html')>0 && @in_array($value['fid'],$htm_fid)){
$value['url']="$B_url/$htmurl";
} else{
$value['url']="$H_url/c_thread.php?fid=$value[fid]";
}
$_cmscate[$key]=$value;
}
}
$htm=1;
$f_url="$H_url/c_read.php?tid=$tid&";
$readtpl='c_readtpl';
} else{
$db_http=='N' && $imgpath=$path.'/'.$imgpath;
$f_url="$path/read.php?tid=$tid&";
$readtpl='readtpl';
}
$pollid=$read['pollid'];
if($read['voteopts']){
$tpc_date=get_date($read['postdate']);
htmvote($read['voteopts']);
}
$read['pid']='tpc';
$readdb=array();
$readdb[]=htmread($read,0);
$subject=$read['subject'];
$tpctitle='- '.$subject;
$favortitle=str_replace("'","‘",$subject);
if($read['replies']>0){
$start_limit = 0;
$readnum=$db_readperpage-1;
$query = $db->query("SELECT p.*,m.uid,m.username,m.oicq,m.groupid,m.memberid,m.icon AS micon,m.hack,m.honor,m.signature,m.regdate,m.signchange,md.onlinetime,md.postnum,md.digests,md.rvrc,md.money,md.credit,md.thisvisit FROM pw_posts p LEFT JOIN pw_members m ON m.uid=p.authorid LEFT JOIN pw_memberdata md ON md.uid=p.authorid WHERE p.tid='$tid' ORDER BY postdate LIMIT $start_limit, $readnum");
$start_limit++;
while($read=$db->fetch_array($query)){
if($foruminfo['allowsell'] && strpos($read['content'],"[sell") !== false && strpos($read['content'],"[/sell]") !== false){
$usehtm=0;
break;
} elseif($foruminfo['allowhide'] && strpos($read['content'],"[post]") !== false && strpos($read['content'],"[/post]") !== false){
$usehtm=0;break;
} elseif($foruminfo['allowencode'] && strpos($read['content'],"[hide") !== false && strpos($read['content'],"[/hide]") !== false){
$usehtm=0;break;
}
//$foruminfo['cms'] && $read['ifconvert']=1;
$readdb[]=htmread($read,$start_limit);
$start_limit++;
}
$db->free_result($query);unset($sign);
}
if($usehtm){
///cms
if($foruminfo['cms']){
include_once(R_P.'require/c_search.php');
list($tids,$kname)=search_tid($tid);
$related=array();
if($tids){
$query=$db->query("SELECT tid,fid,postdate,subject FROM pw_threads WHERE tid IN($tids) LIMIT 7");
while($rt=$db->fetch_array($query)){
$tpcurl="c_read.php?tid=$rt[tid]";
$rt['subject']=substrs($rt['subject'],50);
foreach($kname as $value){
$rt['subject']=str_replace($value,"<font color='#FF0000'>".$value."</font>",$rt['subject']);
}
$_related[]=array($tpcurl,$rt['subject'],$rt['fid'],$rt['postdate']);
}
}
}
///cms
if ($count%$db_readperpage==0){ //$count $db_readperpage read.php?fid=$fid&tid=$tid&
$numofpage=$count/$db_readperpage;
} else{
$numofpage=floor($count/$db_readperpage)+1;
}
if ($page=='lastpost' || $page>$numofpage){
$page=$numofpage;
}
$fengye=numofpage($count,$page,$numofpage,$f_url);//文章数,页码,共几页,路径
$f_url="htm_data/$fid/";
if($foruminfo['allowhtm'] && @filesize(R_P.$f_url.'index.html')>0){
$f_url="$B_url/$f_url";
} else{
$f_url="$H_url/c_thread.php?fid=$fid";
}
$db_obstart==1 ? ob_start('ob_gzhandler') : ob_start();
$db_bbsname_a=addslashes($db_bbsname);//模版内用到
require_once(PrintEot($readtpl));
$content=ob_get_contents();
ob_end_clean();
if(!is_dir(R_P.'htm_data/'.$fid)){
@mkdir(R_P.'htm_data/'.$fid,0777);
writeover(R_P."htm_data/$fid/index.html",'');
}
if(!is_dir(R_P.'htm_data/'.$fid.'/'.$date)){
@mkdir(R_P.'htm_data/'.$fid.'/'.$date,0777);
writeover(R_P."htm_data/$fid/$date/index.html",'');
}
writeover(R_P."htm_data/$fid/$date/$tid.html",$content,"rb+",0);
} elseif(file_exists(R_P."htm_data/$fid/$date/$tid.html")){
@unlink(R_P."htm_data/$fid/$date/$tid.html");
}
$j_p=R_P."htm_data/$fid/$date/$tid.html";
}
}
function htmread($read,$start_limit){
global $tpc_author,$path,$count,$timestamp,$db_onlinetime,$attachpath,$gp_allowloadrvrc,$tablecolor,$readcolorone,$readcolortwo,$lpic,$ltitle,$imgpath,$db_ipfrom,$db_showonline,$stylepath,$db_windpost,$db_windpic,$fid,$tid;
include_once(R_P.'data/bbscache/level.php');
$read['lou']=$start_limit;
$start_limit==$count-1 && $read['jupend']='<a name=lastatc></a>';
if ($start_limit%2==0){
$read['colour']=$readcolorone;
} else{
$read['colour']=$readcolortwo;
}
$read['ifsign']<2 && $read['content']=str_replace("\n","<br>",$read['content']);
//$read['content']=str_replace("\n","<font color=$read[colour]>$GLOBALS[db_bbsurl]</font><br>",$read['content']);
$read['groupid']=='-1' && $read['groupid']=$read['memberid'];
if($read['groupid']!=''){
!$lpic[$read['groupid']] && $read['groupid']=8;
$read['lpic']=$lpic[$read['groupid']];
$read['level']=$ltitle[$read['groupid']];
$read['regdate']=get_date($read['regdate'],"Y-m-d");
$read['aurvrc']=floor($read['rvrc']/10);
$read['author']=$read['username'];
$read['ontime']=(int)($read['onlinetime']/3600);
$tpc_author=$read['author'];
/*
if($read['hack']==1){
$read['face']=getwindxiu($read['author'],$i,140,226);//虚拟形象插件接口
} else{*/
$read['face']=showfacedesign($read['micon']);
//}
if($db_ipfrom==1) $read['ipfrom']=' From:'.$read['ipfrom'];
/**
* 屏蔽禁言组帖子
*/
/*if(($read['groupid']=='6') || empty($read['content'])){
return '';
}*/
global $sign;
if(!$sign[$read['author']]){
if ($read['ifsign']==1){
if($read['signchange']==2) $read['signature']=convert($read['signature'],$db_windpic,2);//动态判断签名转换
$read['signature']=str_replace("\n","<br>",$read['signature']);
}else{
$read['signature']='';
}
}else{
$read['signature']=$sign[$read['author']];
}
$sign[$read['author']]=$read['signature'];
}else{
$read['face']="<br>";$read['lpic']='8';
$read['digests']=$read['credit']=$read['level']=$read['postnum']=$read['money']=$read['regdate']=$read['lastlogin']=$read['aurvrc']='*';
}
$read['postdate']=get_date($read['postdate']);
if($read['ifmark']){
$markdb=explode("\t",$read['ifmark']);
$markinfo="<tr>";
foreach($markdb as $key=>$value){
$markinfo.='<td>'.$value.'</td>';
$key++;
if($key%3==0)$markinfo.='</tr><tr>';
}
$markinfo.='</tr>';
$read['mark']=$markinfo;
} else{
$read['mark']='';
}
if($read['icon']){
$read['icon']="<img src='$imgpath/post/emotion/$read[icon].gif' align=left border=0>";
} else{
$read['icon']='';
}
/**
* 动态判断发贴是否需要转换
*/
if($read['ifconvert']==2){
$read['content']=preg_replace("/\[sell=(.+?)\]/eis","",$read['content']);
$read['content']=preg_replace("/\[hide=(.+?)\]/eis","",$read['content']);
$read['content']=str_replace("[/hide]","",$read['content']);
$read['content']=str_replace("[/sell]","",$read['content']);
$read['content']=str_replace("[post]","",$read['content']);
$read['content']=str_replace("[/post]","",$read['content']);
$read['content']=convert($read['content'],$db_windpost);
}
/**
* 附件信息
*/
$downattach=$downpic='';
if($read['aid']!=''){
$attachs= unserialize(stripslashes($read['aid']));
if(is_array($attachs)){
foreach($attachs as $attach){
@extract($attach);
if(file_exists("$attachpath/$attachurl")){
if($type=='img' && $needrvrc==0){
$dfurl='<br>'.cvpic($path.'/'.$attachpath.'/'.$attachurl,1);
$read['pic'][]=array($aid,$dfurl);
} else{
$read['downattach'][]=array($aid,$name,$size,$hits,$needrvrc,$type);
}
}
}
}
}
$read['content']=$downpic.'<br>'.$read['content'].'<br>'.$downattach;
$read['alterinfo'] && $read['content'].="<br><br><br><font color=gray>[ $read[alterinfo] ]</font>";
return $read;
}
function htmvote($voteopts)
{
global $path,$multi,$votetype,$pollid,$votedb,$votesum,$viewvoter,$fid,$tid,$windid,$admin_check;
$votearray = unserialize(stripslashes($voteopts));
if(!is_array($votearray)) return;
if(!is_array($votearray['options'])) return;
$votetype = $votearray['multiple'][0] ? 'checkbox' : 'radio';
$votesum=0;
$vt_name=$vt_num=$voteid=$voter=$allvoter=$votedb=array();
foreach($votearray['options'] as $option){
foreach($option[2] as $key =>$value){
$allvoter[]=$value;
}
$vt_name[]=$option[0];
$vt_num[]=$option[1];
$votesum+=$option[1];
}
foreach($vt_name as $key=>$value){
$vote['width']=floor(500*$vt_num[$key]/($votesum+1));
$vote['name']=$value;
$vote['num']=$vt_num[$key];
$votedb[]=$vote;
}
$votesum=count(array_unique($allvoter));
$multi=$votearray['multiple'][0] ? $votearray['multiple'][1] : 0;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -