📄 read.php
字号:
<?php
require "./global.php";
include_once R_P.'header.php';
include_once R_P.'mydb.php';
include_once R_P.'code.php';
$lid = $read['lid'];
$blid = $lanmuindex[$lid]['kind'];
$downdate = date('ymd',$read['date']);
//附件
if($read['up']){
$downdb = explode("|",$read['up']);
foreach($downdb as $down){
if($down != ""){
$downquery = $db->getone("SELECT * FROM xydw_up WHERE savename='$down'");
$downnum ++;
$downall .= $downnum."<a href='./down.php?downid={$downquery['id']}' target=_blank>".$downquery['tempname']."</a> ";
}
}
}
$read['down'] = $downall;
//自动分页
if($rootindex['artlen']){
$contlen = strlen($read['content']);
//$rootindex['artlen'] % 2 && $rootindex['artlen'] += 1;
if($contlen < $rootindex['artlen']){
$pamount = 1;
} else {
$pamount = (int)($contlen/$rootindex['artlen']);
$contlen%$rootindex['artlen'] ? $pamount+=1 : "";
}
$page = (int)$page;
if(!$page || $page > $pamount) $page = 1;
$page < $pamount ? $nextpage = $page + 1 : $nextpage = 1;
$page < 2 ? $lastpage = 1 : $lastpage = $page - 1;
for($i=1;$i<=$pamount;$i++){
$i == $page ? $listpage .= " <a href='read.php?wid=$wid&page=$i'><b>$i</b></a> " : $listpage .= " <a href='read.php?wid=$wid&page=$i'>$i</a> ";
}
$listpage = "<a href='read.php?wid=$wid&page=$lastpage' title='上一页'><<</a>".$listpage."<a href='read.php?wid=$wid&page=$nextpage' title='下一页'>>></a>";
$offsetstart = ($page-1)*$rootindex['artlen'];
$offsetend = $page*$rootindex['artlen'];
if($page != 1){
$num = 0;
for($i=0;$i<$offsetstart;$i++){
if(ord($read['content'][$i])>127){
$num ++;
}
}
if($num%2){
$offsetstart ++;
}
}
if($offsetend < $contlen){
$num = 0;
for($i=$offsetstart;$i<$offsetend;$i++){
if(ord($read['content'][$i])>127){
$num ++;
}
}
if($num%2){
$offsetend ++;
}
} else $offsetend = $contlen;
$read['content'] = substr($read['content'],$offsetstart,($offsetend-$offsetstart));
} else {
//标签分页
$read['content'] = explode("[next]",$read['content']);
$pamount = count($read['content']);
$page = (int)$page;
if(!$page || $page > $pamount) $page = 1;
$page < $pamount ? $nextpage = $page + 1 : $nextpage = 1;
$page < 2 ? $lastpage = 1 : $lastpage = $page - 1;
for($i=1;$i<=$pamount;$i++){
$i == $page ? $listpage .= " <a href='read.php?wid=$wid&page=$i'><b>$i</b></a> " : $listpage .= " <a href='read.php?wid=$wid&page=$i'>$i</a> ";
}
$listpage = "<a href='read.php?wid=$wid&page=$lastpage' title='上一页'><<</a>".$listpage."<a href='read.php?wid=$wid&page=$nextpage' title='下一页'>>></a>";
$pageoffset = $page-1;
$read['content'] = $read['content'][$pageoffset];
}
$pamount == 1 && $listpage = '';
ReplaceWord($read['content']);
$rootindex['usehtml'] or $read['html'] = 0;
$rootindex['useubb'] or $read['ubb'] = 0;
$read['cont'] = readxydw($read['content'],$read['html'],$read['ubb']);
$date = date('Y-m-d',$read['date']);
$html_date = date(ym,$read['date']);
if($read['newsurl'] && $rootindex['newimg']) $read['img'] = "<a href='$read[newsurl]' target=_blank><img src='$read[newsurl]' border=0 onload='javascript:if(this.width>400)this.width=400' alt='点击图片放大' style='float:left'></a>";
$read['cont'] = $read['img'].$read['cont']."<br><br><div align=center>".$listpage."</div>";
//专题
if($read['zhuanti']){
include_once R_P."data/cache/zhuanti.php";
$read['ztname'] = $ztindex[$read['zhuanti']];
$read['zt'] = "<a href='./zhuanti.php?zid=".$read['zhuanti']."'><b>".$read['ztname']."</b></a>";
$ztquery = $db->query("SELECT wid,name,date FROM xydw_art WHERE zhuanti='$read[zhuanti]' AND wid!='$wid' AND xianshi='1' ORDER BY date DESC LIMIT $rootindex[zhuanti]");
while($ztrow = $db->fetch_array($ztquery)){
$read['zt'] .= "<br><img src='./images/$imgpath/i5.gif'> <a href='./read.php?wid=$ztrow[wid]' title='发表于:".date('Y-m-d',$ztrow[date])."'>$ztrow[name]</a>";
}
} else $read['zt'] = "暂无相关专题";
$pageup = $db->getone("SELECT wid,name,date FROM xydw_art WHERE lid='$lid' AND wid<'$wid' AND xianshi='1' ORDER BY date DESC LIMIT 1");
$pagedown = $db->getone("SELECT wid,name,date FROM xydw_art WHERE lid='$lid' AND wid>'$wid' AND xianshi='1' ORDER BY date ASC LIMIT 1");
$pageup ? $pageup = "上一篇:<a href='./read.php?wid={$pageup[wid]}' title='发表于:".date('Y-m-d',$pageup[date])."'>{$pageup[name]}</a>" : $pageup = "上一篇:无相关文章";
$pagedown ? $pagedown = "下一篇:<a href='./read.php?wid={$pagedown[wid]}' title='发表于:".date('Y-m-d',$pagedown[date])."'>{$pagedown[name]}</a>" : $pagedown = "下一篇:无相关文章";
$read['pageup'] = $pageup;
$read['pagedown'] = $pagedown;
//评论
$query = $db->query("SELECT author,comment,fen FROM xydw_comment WHERE wid='$wid' AND xianshi='1' ORDER BY dateline DESC LIMIT $rootindex[commentlist]");
while($row = $db->fetch_array($query)){
$cnum ++;
$cnum%2 ? $tclass = "bg_one" : $tclass = "bg_two";
ReplaceWord($row[comment]);
$row[author] = xsubstr($row[author],"20");
$row[comment] = readxydw($row[comment],0,$rootindex['commentubb']);
$comment .= "\t<tr><td class=$tclass valign=top width='130'><strong>$row[author]</strong><br>评分:$row[fen]</td><td class=$tclass>$row[comment]</td></tr>\n";
}
$comment && $read['comments'] = "<br><table width='95%' align=left' cellspacing='1px' bgcolor='#EFEFEF'>\n".$comment."</table>";
$read['comment'] or $read['comment'] = 0;
$read['fen']<0 && $read['fen'] = 0;
//其它
$read['author'] && $read['author'] = "作者:".$read['author'];
if($read['laiyuan']){
$laiyuan = explode("|",$read['laiyuan']);
$laiyuan[1] && $read['laiyuan'] = "<a href='".$laiyuan[1]."' target=_blank>".$laiyuan[0]."</a>";
} else $read['laiyuan'] = "<a href='".$rootindex[siteurl]."' target=_blank>".$rootindex['sitename']."</a>";
$read['visit'] < 1 && $read['visit'] = 1;
$read['ln'] = $lanmuindex[$read[lid]][name];
$read['blid'] = $lanmuindex[$read[lid]][kind];
$read['bln'] = $lanmuindex[$read[blid]][name];
$rootindex['ishtml'] && $read['hdate'] = date('ym',$read['date']); //静态页
$read['date'] = date('Y-m-d H:i',$read['date']);
$newest = OutPut(GetSql("$lid",$rootindex[listn],0,0),0,0); //最近更新
$good = OutPut(GetSql("$lid",$rootindex[listg],2,0),0,0); //最新推荐
$hot = OutPut(GetSql("$lid",$rootindex[listh],3,0),0,0); //热门文章
$db->query("UPDATE xydw_art SET visit=visit+1,last='$timestamp' WHERE wid='$wid'"); //点击计算
if($rootindex['ishtml'] && !file_exists(R_P."html_data/".$read['lid']."/".$read['hdate'].$wid.".htm")) include_once R_P."include/dohtml.php";
include_once R_P."include/left.php";
include_once temp('read');
include_once R_P.'footer.php';
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -