📄 article.php
字号:
<?php
if(!defined('IN_PHPCMS')) {
exit('Access Denied');
}
$rownum=8;
$topcommentsnum=10;
$query="select * from $table_article where recycle=0 and articleid='$articleid'";
$result=$db->query($query);
if($db->num_rows($result)==1){
$article=$db->fetch_array($result);
$article[adddate]=date("Y-m-d",$article[addtime]);
$article[addtime]=date("Y/md",$article[addtime]);
$article[content]=keylink($article[content]);
$cat = $_CAT[$article[catid]];
$inc = $inc ? "<?php\n \$readgrade=$article[readgrade];\n \$readpoint=$article[readpoint];\n?>".$inc : "";
$head[title]=$article[title];
$head[refresh]=$article[linkurl] ? '<meta http-equiv="refresh" content="0;URL='.$article[linkurl].'">' : '';
$head[keywords]=$article[keywords];
$head[description]=$article[titleintact] ? $article[titleintact] : $article[title];
$GLOBALS[template]=$template=$cat[cattemplate] ? $cat[cattemplate] : $dtemplate;
$GLOBALS[style]=$style=$cat[catstyle] ? $cat[catstyle] : $dstyle;
$query="select articleid,title,includepic,titlefontcolor,titlefonttype,showcommentlink,addtime from $table_article where passed>0 and recycle=0 and articleid<$articleid order by articleid desc limit 0,1";
$result=$db->query($query);
if($db->num_rows($result)>0){
$pre=$db->fetch_array($result);
$pre[adddate]=date("Y-m-d",$pre[addtime]);
$pre[addtime]=date("Y/md",$pre[addtime]);
$pre[fonttype][0]=$fonttype[$pre[titlefonttype]][0];
$pre[fonttype][1]=$fonttype[$pre[titlefonttype]][1];
$pre[includepic]=$includepic[$pre[includepic]];
}else{
$pre=0;
}
$query="select articleid,title,includepic,titlefontcolor,titlefonttype,showcommentlink,addtime from $table_article where passed>0 and recycle=0 and articleid>$articleid limit 0,1";
$result=$db->query($query);
if($db->num_rows($result)>0){
$next=$db->fetch_array($result);
$next[adddate]=date("Y-m-d",$next[addtime]);
$next[addtime]=date("Y/md",$next[addtime]);
$next[fonttype][0]=$fonttype[$next[titlefonttype]][0];
$next[fonttype][1]=$fonttype[$next[titlefonttype]][1];
$next[includepic]=$includepic[$next[includepic]];
}else{
$next=0;
}
if($article[keywords]){
$keywords=explode(",",addslashes($article[keywords]));
foreach($keywords as $k=>$keyword){
if($k>2)break;
$or = $k>0 ? " or " : " ";
$condition .=$or;
$condition .=" title like '%$keywords[$k]%' ";
}
$result=$db->query("select articleid,title,includepic,titlefontcolor,titlefonttype,showcommentlink,addtime from $table_article where passed>0 and recycle=0 and articleid!=$articleid and $condition order by articleid desc limit 0,$rownum");
while($related=$db->fetch_array($result)){
$related[adddate]=date('m-d',$related[addtime]);
$related[addtime]=date('Y/md',$related[addtime]);
$related[fonttype][0]=$fonttype[$related[titlefonttype]][0];
$related[fonttype][1]=$fonttype[$related[titlefonttype]][1];
$related[includepic]=$includepic[$related[includepic]];
$related[stitle]=wordscut($related[title],30,1);//related
$relateds[]=$related;
}
}
$result=$db->query("select * from $table_comment where articleid=$articleid order by commentid desc limit 0,$topcommentsnum");
while($comment=$db->fetch_array($result)){
$comment[adddate]=date('Y-m-d',$comment[addtime]);
$comment[gender]=$comment[gender] ? $language[man] : $language[woman];
$comments[]=$comment;
}
if(is_array($comments)){
arsort($comments);
}
if($article[paginationtype]==1){
$charnumber=strlen($article[content]);
$pagenumber=ceil($charnumber/$article[maxcharperpage]);
}elseif($article[paginationtype]==2){
$contents=explode('[next]',$article[content]);
$pagenumber=count($contents);
}
if($pagenumber>1){
for($i=0;$i<$pagenumber;$i++){
$page=$i+1;
if($article[paginationtype]==1){
$startpos=$i*$article[maxcharperpage];
$endpos=$page*$article[maxcharperpage];
$endpos=$endpos>$charnumber ? $charnumber : $endpos;
$content=substr($article[content],$startpos,$endpos);
}elseif($article[paginationtype]==2){
$content=$contents[$i];
}
$pages=articlepage($pagenumber,$page,$rootpath.'/data/'.$article[addtime].'/article_'.$articleid);
ob_start();
include template('article');
copyright($version);
$data = $inc.ob_get_contents();
ob_clean();
$filedir=$phpcms_root.'/data/'.$article[addtime];
createdir($filedir);
$filename= $i ? $filedir.'/article_'.$articleid.'_'.$i.$fileext : $filedir.'/article_'.$articleid.$fileext;
file_write($filename,$data);
}
}else{
$content=$article[content];
ob_start();
include template('article');
copyright($version);
$data = $inc.ob_get_contents();
ob_clean();
$filedir=$phpcms_root.'/data/'.$article[addtime];
createdir($filedir);
$filename=$filedir.'/article_'.$articleid.$fileext;
file_write($filename,$data);
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -