以下代码为鱼鱼原创,版权归鱼鱼和一千零一夜所有.
看到有好多朋友问,就征求了臭鱼的同意把这个放出来了,注释都写的很清楚.
演示:http://bbs.1001year.net/
社区热点,就是调用的帖子.需要调用更多版块的就多加.其他修改可以参考首页调用的修改.
如果你的论坛不是生成伪静态,下面的帖子地址就改为- http://www.***.com/viewthread.php?tid={$result[tid]}
复制代码
老规矩,喜欢的看,不喜欢的闪.
- <?
- //论坛数据库信息
- $dbuser='dbuser'; //数据库用户名
- $dbpass='dbpass'; //数据库密码
- $dbname='dbname'; //数据库名
- $shownum='10'; //显示数量
- $titlelen=35; //第一个版块的标题长度
- $titlelen2=35; //第二个版块的标题长度
- $titlelen3=35; //第三个版块的标题长度
- $lasttime=time()-51840000; //显示两个月内的热门贴
- mysql_connect('',$dbuser,$dbpass); //连接数据库
- mysql_query("SET NAMES GBK");
- mysql_select_db($dbname);
- //-------------------美女写真-------------------
- $select = mysql_query("SELECT tid,fid,author,lastpost,dateline,lastposter,views,subject,replies FROM cdb_threads where fid=27 and lastpost>$lasttime and closed=0 ORDER BY replies DESC LIMIT 0, $shownum"); //查询表
- $result=mysql_fetch_array($select); //以下show是输出
- $show.= "<table width='100%' border='0' cellspacing='0' cellpadding='0'>\r\n";
- while ($result)
- {
- $longname=$result['subject'];
- //截取帖子标题长度
- if(strlen($result['subject']) > $titlelen)
- {
- $result['subject']=substr($result['subject'],"0",$titlelen-4).chr(0);
- $result['subject']=$result['subject']."...";
- }
- $lastpost=date('Y-m-d',$result[lastpost]);
- $dateline=date('Y-m-d',$result[dateline]);
- $show.="<tr><td>";
- $show.="<a href=http://bbs.1001year.net/thread-{$result[tid]}-1-1.html target=_blank title='标题:{$longname}
- 作者:{$result['author']}
- 发表日期:{$dateline}
- 最后回复:{$lastpost}({$result['lastposter']})
- 阅读次数:{$result['views']}
- 回复次数:{$result['replies']}'>".$result['subject']."</a>";
- $show.="</td></tr>";
- $result=mysql_fetch_array($select);
- }
- $show.="</table>";
- $filename='bbs_mv.html';
- $handle=fopen ($filename,"w");
- fwrite($handle,$show);
- fclose($handle);
- unset ($show);
- //-------------------精彩贴图-------------------
- $select = mysql_query("SELECT tid,fid,author,lastpost,dateline,lastposter,views,subject,replies FROM cdb_threads where fid=20 and lastpost>$lasttime and closed=0 ORDER BY replies DESC LIMIT 0, $shownum");
- $result=mysql_fetch_array($select);
- $show.= "<table width='100%' border='0' cellspacing='0' cellpadding='0'>\r\n";
- while ($result)
- {
- $longname=$result['subject'];
- //截取帖子标题长度
- if(strlen($result['subject']) > $titlelen2)
- {
- $result['subject']=substr($result['subject'],"0",$titlelen2-4).chr(0);
- $result['subject']=$result['subject']."...";
- }
- $lastpost=date('Y-m-d',$result[lastpost]);
- $dateline=date('Y-m-d',$result[dateline]);
- $show.="<tr><td>";
- $show.="<a href=http://bbs.1001year.net/thread-{$result[tid]}-1-1.html target=_blank title='标题:{$longname}
- 作者:{$result['author']}
- 发表日期:{$dateline}
- 最后回复:{$lastpost}({$result['lastposter']})
- 阅读次数:{$result['views']}
- 回复次数:{$result['replies']}'>".$result['subject']."</a>";
- $show.="</td></tr>";
- $result=mysql_fetch_array($select);
- }
- $show.="</table>";
- $filename='bbs_tt.html';
- $handle=fopen ($filename,"w");
- fwrite($handle,$show);
- fclose($handle);
- unset ($show);
- //-------------------占星奇缘-------------------
- $select = mysql_query("SELECT tid,fid,author,lastpost,dateline,lastposter,views,subject,replies FROM cdb_threads where fid=78 and lastpost>$lasttime and closed=0 ORDER BY replies DESC LIMIT 0, $shownum");
- $result=mysql_fetch_array($select);
- $show.= "<table width='100%' border='0' cellspacing='0' cellpadding='0'>\r\n";
- while ($result)
- {
- $longname=$result['subject'];
- //截取帖子标题长度
- if(strlen($result['subject']) > $titlelen2)
- {
- $result['subject']=substr($result['subject'],"0",$titlelen3-4).chr(0);
- $result['subject']=$result['subject']."...";
- }
- $lastpost=date('Y-m-d',$result[lastpost]);
- $dateline=date('Y-m-d',$result[dateline]);
- $show.="<tr><td>";
- $show.="<a href=http://bbs.1001year.net/thread-{$result[tid]}-1-1.html target=_blank title='标题:{$longname}
- 作者:{$result['author']}
- 发表日期:{$dateline}
- 最后回复:{$lastpost}({$result['lastposter']})
- 阅读次数:{$result['views']}
- 回复次数:{$result['replies']}'>".$result['subject']."</a>";
- $show.="</td></tr>";
- $result=mysql_fetch_array($select);
- }
- $show.="</table>";
- $filename='bbs.html';
- $handle=fopen ($filename,"w");
- fwrite($handle,$show);
- fclose($handle);
- unset ($show);
- ?>
复制代码
[ 本帖最后由 TaRot! 于 2007-7-19 19:24 编辑 ] |