/*
showcolumn.php
循环显示论坛标题页的文件
参数说明
fdColumnId 表示栏目的名称
isCool==1 表示是酷帖,否则是普通帖子
flag==1 表示用户选择了排序方式,否则为系统自动的选择排序方式
sortdesc1==desc 表示降序 否则为升序
sortarticle 表示是选择的那个字段为主进行排序
*/
$whereid=3;
require ("./share.php");
statuscount($fdColumnId); //站内统计
hitcount($fdColumnId);
sitepostcount("look");
require "./config/class.fasttemplate.php";
$tpl = new FastTemplate("./templates");
//定义使用到的模板
$tpl->define(
array(
columnMain => "main.tpl", //显示栏目信息主模板
threadCircleInfo => "userarticle_row.tpl", //循环主题
bottom => "bottom.tpl",
erroInfo => "erro.tpl" //错误提示
)
);
$coolcond=($coolflag)?"and ($bbstable.fdCool=1 or $bbstable.fdWebCool=1)":"";
$intLineNum=10;
if($intGotoPage <= 0) $intGotoPage=1;
$start = ($intGotoPage-1)*$intLineNum; //起始记录数
/*
function check_GroupId($login)
{
global $loginstr,$member,$DB_web;
$return=0;
$sql="select fdGroupId from $member where fdLogin='$login'";
$memberinfo1 = $DB_web->query_first($sql);
if($memberinfo[fdGroupId]==1){ //管理员
$return=1;
}
if($loginstr==$login) //自己
$return=1;
return $return;
}
//文章总数
if (check_GroupId($user)){
$sql="SELECT count(id) as id from $bbstable where fdLogin='$user'";
}
else{
*/
$sql="SELECT count($bbstable.id) as id from $bbstable,$bbscolumn where $bbstable.fdLogin='$user' and $bbstable.fdColumnId=$bbscolumn.id and $bbscolumn.fdIsPublic=1 $coolcond";
//}
$totals = $DB_web->query_first($sql);
$totalnum = $totals[id];
if(!$intLineNum) $intLineNum=1;
$totalpages = intval($totalnum/$intLineNum);
if( ($totalnum%$intLineNum)<>0 ) $totalpages = $totalpages+1;
if($totalpages<=0) $totalpages=1;
/*
if (check_GroupId($user)){
$mainsql = "SELECT * from $bbstable where fdLogin='$user' order by id desc limit $start,$intLineNum";
}
else{
*/
$mainsql = "SELECT $bbstable.* from $bbstable,$bbscolumn where $bbstable.fdLogin='$user' and $bbstable.fdColumnId=$bbscolumn.id and $bbscolumn.fdIsPublic=1 $coolcond order by $bbstable.id desc limit $start,$intLineNum";
//}
$result = $DB_web->query($mainsql);
$rowsNum = $DB_web->num_rows($result);
$i = $rowsNum;
$tpl->define_dynamic("row", "threadCircleInfo");
while($i>0)
{
$i--;
if ($bbstable==$bbsarticle){
$article_result = $DB_web->fetch_array($result);
}
else{
$r_rows=$DB_web->fetch_array($result);
$s_sql="select * from $bbsarticle where id=$r_rows[fdArticleId] order by id";
$r_result = $DB_web->query($s_sql);
$article_result =$DB_web->fetch_array($r_result);
}
$attribute=$article_result[fdAttack]?" [有附件]":"";
$infoimage1=(substr($article_result[fdReplyDate],0,10)==date('Y-m-d'))?"
":"";
$infoimage2=(substr($article_result[fdCreateDate],0,10)==date('Y-m-d'))?"
":"";
$infoimage=$infoimage1;
$infoimage=(strlen($infoimage2)>5)?$infoimage2:$infoimage;
//定义循环模板中的变量
$cool=($article_result[fdCool])?"
":""; $fdReplyAuthor=($article_result[fdReplyAuthor])?($article_result[fdReplyAuthor]):($article_result[fdLogin]);
$tpl->assign(
array(
startinfo => "",
endinfo => "",
infoimage => $infoimage,
topimage => ($article_result[fdIsTop]) ? "
" : "",
faceimage => $article_result[fdGraph],
title_href => "showthread.php?bbstable=$bbstable&threadid=".intval($article_result[id]),
articletitle=> $cool.mark($article_result[fdTitle]).$attribute,
bity => strlen($article_result[fdContent]),
author => "
":"
",
)
);
}
if ($i<=0){
$tpl->assign(
array(
startinfo => "",
endinfo => "",
infoimage => "",
topimage => "",
faceimage => "",
title_href => "",
articletitle=> "",
loginform => $logininfo,
JSCODE => $javascriptcode,
bgmusic => "",
bity => "",
author => "",
reply => "",
hits => "",
score =>"",
morepages => $morepages,
lastpostdate => ""
)
);
}
$tpl->parse(main, ".threadCircleInfo"); //解析循环的模板
$tpl->parse(bottominfo, "bottom"); //解析底部模板模板
$tpl->parse(main, "columnMain"); //解析主模板模板
$tpl->FastPrint();
//分页函数
function intShowPages($intLineNum,$intGotoPage,$totalpages){
global $fdColumnId,$flag,$sortdesc,$isCool,$user,$bbstable,$coolflag;
$intWhileNum=10;
$intSelfLine=$intGotoPage; #本页
$intStartPage=(($intSelfLine-1)-(($intSelfLine-1)%$intWhileNum));
$intEndPage=$intStartPage+$intWhileNum-1;
if($totalpages<$intEndPage){
$intEndPage=$totalpages-1;
$intWhileNum=$intEndPage-$intStartPage+1;
}
$sortdesc1=($sortdesc=="asc")?"desc":"asc";
$return="| "; for($i=1;$i<$intWhileNum+1;$i++){ $intOffsetNum=($intStartPage+($i-1))*$intLineNum; $intShowPage=($intStartPage+$i); if($intSelfLine==$intStartPage+$i){ #当前页不做联接 $return.=" ".$intShowPage." "; }else{ if($intShowPage<=$totalpages){ $return.=" ".$intShowPage.""; } } } $return.=" | "; $next_page=$intSelfLine+1; #下一页的页数 $return.="