<?
include_once("inc/config.php");
include_once("inc/publicfun.php");
include_once("inc/ftbbsdbclass.php");
include_once("conn.php");
/*
'ft_na贴子调用函数
'调用方法<script src="callfun.php?n=10&a=0&b=0&c=0&d=0&e=8"></script>
'n为记录数
'a类别显示标识值为0时不显示论坛类别1显示论坛类别
'b日期显示标识值为0时不显示1显示
'c作者显示标识值为0时不显示1显示
'd为贴子标识0为最新贴1为精华贴2为推荐贴
'e为取出标题的长度
*/
$n=$_GET["n"];
$a=$_GET["a"];
$b=$_GET["b"];
$c=$_GET["c"];
$d=$_GET["d"];
$e=$_GET["e"];
ft_na($n,$a,$b,$c,$d,$e);
Function ft_na($n,$a,$b,$c,$d,$e){
if ($d==1){
$sql="SELECT * from {$tablepre}bbs_cate,{$tablepre}bbstitle where {$tablepre}bbs_cate.BBS_Cate_ID = {$tablepre}bbstitle.BoardID_2 and {$tablepre}bbstitle.deleted=0 and {$tablepre}bbstitle.huati=1 order by {$tablepre}bbstitle.redate desc limit 0,".$n."";
}
elseif ($d==2){
$sql="SELECT * from {$tablepre}bbs_cate,{$tablepre}bbstitle where {$tablepre}bbs_cate.BBS_Cate_ID = {$tablepre}bbstitle.BoardID_2 and {$tablepre}bbstitle.deleted=0 and {$tablepre}bbstitle.sign=1 order by {$tablepre}bbstitle.redate desc limit 0,".$n."";
}
else{
$sql="SELECT * from {$tablepre}bbs_cate,{$tablepre}bbstitle where {$tablepre}bbs_cate.BBS_Cate_ID = {$tablepre}bbstitle.BoardID_2 and {$tablepre}bbstitle.deleted=0 and {$tablepre}bbs_cate.BBS_Cate_Qs=0 order by {$tablepre}bbstitle.redate desc limit 0,".$n."";
}

$rs=mysql_query($sql);
$myrow = mysql_fetch_array($rs);
$numrows = mysql_num_rows($rs);
if ($numrows!=0){
  $nl="";
  do {
  $id=$myrow[0];
  $title=substr($myrow["title"],0,$e);
  $boardid_1=$myrow["BoardID_1"];
  $boardid_2=$myrow["BoardID_2"];
  $BBS_Cate_Name=$myrow["BBS_Cate_Name"];
  $tk1="default..php?a=".$boardid_1."&b=".$boardid_2."";
  if ($a==1){
  $astring="[<a href=".$tk1.">".$myrow["BBS_Cate_Name"]."</a>]";
  }
  if ($b==1){
  $bstring=dateFormat($myrow["redate"],'y-m-d');
  }
  if ($c==1){
  $cstring="<a href=ftbbsmyinfo.php?ftbbsuser=".$myrow["user_id"].">".$myrow["user_id"]."</a>";
  }
  $nl=$nl.$astring."<a href=ftbbs.php?id=".$id." target=\"_blank\">".$title."</a>&nbsp;".$cstring. " ".$bstring."<br>";
 }
  while ($myrow = mysql_fetch_array($rs)); 
}
else{
  $nl="记录为空";
}
echo "document.write('".$nl."');";
}
?>