我的论坛源代码(二)

主界面,也就是显示主题列表的这页。
//foxbbs.php 功能:显示论坛的主题

1<html>
2<head>
3<title>狐网论坛</title>
4<style type="text/css">   
5P {FONT-FAMILY: normal; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt}   
6DIV {FONT-FAMILY: normal; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt}   
7</style>
8<link href="js/lfox.css" link="" rel="stylesheet"/>   

include "linkfox.inc.php";
include "info.inc.php";

 1</head>
 2<body bgcolor="#FFFFFF">
 3<?   
 4$tem=$HTTP_COOKIE_VARS[FlyFoxNet]; //这里取COOKIE里的信息   
 5$temp=explode("|",$tem); //因为用户名和密码是用"|"分隔并记录在COOKIE里的   
 6$cookiem=$temp[0]; //取用户名   
 7$useinfo=cuser($cookiem,$action); //CUSER这个函数是用来判别是否从COOKIE中取出了信息   
 8$query="select usename from useinfo where usename='".$useinfo[0]."'"; //检查是否注册用户   
 9$req=mysql_query($query);   
10if ($req)   
11{   
12$usename=mysql_fetch_array($req);   
13if($usename[0]==$useinfo[0]) $useinfo[0]=$usename[0];   
14else {   
15$usename=1;   
16$useinfo[0]="游客";   
17}   
18}   
19else $usename=1;$useinfo[0]="游客";   
20?>
21<table border="0" cellpadding="4" cellspacing="0" width="100%">
22<tr>
23<td height="40" rowspan="2" width="60%">
24<div align="right"></div>
25<div align="right"></div>
26</td>
27<td height="20" width="10%"> </td>
28<td height="20" width="10%"> </td>
29<td height="20" width="10%"> </td>
30<td height="20" width="10%"> </td>
31</tr>
32<tr>
33<td height="20" width="10%">
34<div align="center"><a href="reguse.php?action=xy"><img border="0" height="21" src="images/top_register.gif" width="74"/></a></div>
35</td>
36<td height="20" width="10%">
37<div align="center"><a href="useinfo.php?action=find"><img border="0" height="21" src="images/top_members.gif" width="74"/></a></div>
38</td>
39<td height="20" width="10%"><a href="useinfo.php?action=edit"><img border="0" height="21" src="images/top_profile.gif" width="74"/></a></td>
40<td height="20" width="10%"><a href="okey.php?d=q"><img border="0" height="21" src="images/top_logout.gif" width="74"/></a></td>
41</tr>
42<tr>
43<td height="20" width="60%">
44<div align="left">当前位置:<font color="#0000FF">狐网─&gt;狐网论坛─&gt;主题列表</font> <? echo "<font color='00dd00'>".$useinfo[2]."<font color="ff0000">"; echo "欢迎你来到论坛!</font>"; ?&gt;</div>
45</td>
46<td height="20" width="10%">
47<div align="center"><? echo "<a href='post.php'><img alt="发布新帖" border="0" height="20" src="images/newthread.gif" width="70"/>"; ?&gt;</div>
48</td>
49<td height="20" width="10%">
50<div align="center"><? if ($action==find) echo "<a href='foxbbs.php'><img alt="显示所有贴子列表" border="0" height="20" src="images/dispall.gif" width="70"/>"; else echo "<a href="superuse.php" target="_blank"><img alt="管理专区,非请莫进" border="0" src="images/super.gif"/></a>";?&gt;</div>
51</td>
52<td height="20" width="10%">
53<div align="center"><a href="reguse.php?action=dl"><img alt="登录用户" border="0" src="images/dl.gif"/></a></div>
54</td>
55<td height="20" width="10%">
56<div align="center"><a href="http://lfox.oso.com.cn/index.php" target="_blank"><img alt="返回狐网首页" border="0" src="images/fox.gif"/></a></div>
57</td>
58</tr>
59</table>
60<? echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";   
61echo "<tr bgcolor="#000000"><td><table border="0" cellpadding="1" cellspacing="1" width="100%">";   
62?&gt; <tr bgcolor="#229999">
63<td width="5%">
64<div align="center"><font color="#FFFFFF">状态</font></div>
65</td>
66<td width="5%">
67<div align="center"><font color="#FFFFFF">表情</font></div>
68</td>
69<td width="30%">
70<div align="center"><font color="#FFFFFF">主 题</font></div>
71</td>
72<td width="25%">
73<div align="center"><font color="#FFFFFF">作 者</font></div>
74</td>
75<td width="5%">
76<div align="center"><font color="#FFFFFF">回复</font></div>
77</td>
78<td width="5%">
79<div align="center"><font color="#FFFFFF">人气</font></div>
80</td>
81<td width="25%">
82<div align="center"><font color="#FFFFFF">最后回复时间</font></div>
83</td>
84</tr>   

$imgnum=20; //点击次数,准备改状态图
if (!$user) $user="all";
$query="select count() from foxbbs"; //首先计算总的论题数
$req=mysql_query($query);
if ($req)
{
$row=mysql_fetch_array($req);
$num=$row[0];
if (!$rows) $rows=10; //控制每页显示条数
if (!$l) $l=1; //设定排序方式
if ($num/$rows&lt;1) $page=1; //计算总页数
else if($num/$rows==floor($num/$rows)) $page=$num/$rows;
else $page=floor($num/$rows)+1;
if (!$dpage) $dpage=1; //当前显示的页数
if ($dpage&gt;$page) $dpage=$page; //不能超过最大页数
if ($dpage==1) $tem=0; //控制当前页应该显示的信息
else $tem=($dpage-1)
$rows;
if ($l==2) $s="hfnum";
else if ($l==3) $s="djnum";
else $s="id";
for ($i=0;$i&lt;$rows;$i++) //根据设定的每页行数来取记录
{
$tem1=$tem+1;
if($action==find) $query="select * from foxbbs where usename='".$user."' order by $s desc limit $tem,$tem1";
else $query="select * from foxbbs order by $s desc limit $tem,$tem1";
$req=mysql_query($query);
if ($req)
{
$bbs=mysql_fetch_array($req); //看有没有回复时间,如果没有就取发帖时间代替回复时间
if ($bbs[3])
{
if (!$bbs[8]) $bbs[8]=$bbs[4]." ".$bbs[1];
else $bbs[8]=$bbs[8]." ".$bbs[10];

if (substr($bbs[4],0,-8)==date(Y年n月j日)&amp;&amp;$bbs[6]&lt;$imgnum&amp;&amp;$bbs[12]!=1) // 如果是当天的帖子
$img="images/newfolder.gif";

else if(substr($bbs[4],0,-8)==date(Y年n月j日)&amp;&amp;$bbs["djnum"]&gt;=$imgnum&amp;&amp;$bbs[12]!=1) //如果是当天,并且点击数上10
$img="images/newhotfolder.gif";

else if(substr($bbs[4],0,-8)!=date(Y年n月j日)&amp;&amp;$bbs[6]&gt;=$imgnum&amp;&amp;$bbs[12]!=1) //如果不是当天,但点击上20
$img="images/hotfolder.gif";

else if($bbs[12]==1) $img="images/lock.gif"; //已锁
else $img="images/folder.gif";
echo "<tr bgcolor="#eeeeee">";
echo "<td width="5%"><div align="center"><img src='".$img."'/></div></td>";
echo "<td width="5%"><div align="center"><img src='images/".$bbs[2].".gif'/></div></td>";
echo "<td width="30%"><div align="left">";
if ($bbs[12]==1) echo $bbs[3]."</div></td>";
else echo "<a href='dispbbs.php?id=".$bbs[0]."&amp;use=".$bbs[1]."'>".$bbs[3]."</a></tr></table></td>";
echo "<td width="25%"><div align="center">".$bbs[1]."</div></td>";
echo "<td width="5%"><div align="center">".$bbs[7]."</div></td>";
echo "<td width="5%"><div align="center">".$bbs[6]."</div></td>";
echo "<td width="25%"><div align="left">".$bbs[8]."</div></td></tr>";
}
}
$tem++;
}
}
echo "<tr><td colspan="7">";
echo "<table border="0" cellpadding="0" cellspacing="0" width="100%">";
echo "<tr>";
echo "<td bgcolor="#229999" colspan="3" height="15" width="100%"><div align="left"><font color="ffffff">|===&gt; ";
if($page==1)
{
echo "[上一页] [下一页]";
}

else if ($dpage==1) //如果当前在第一页
{
$u=$dpage+1;
echo "[上一页] <a href='foxbbs.php?dpage=".$u."&amp;rows=".$rows."&amp;l=".$l."&amp;user=".$user."'>[下一页]</a>";
}
else if($dpage&gt;1&amp;&amp;$dpage&lt;$page) //如果当前在中间页
{
$u=$dpage+1;
$d=$dpage-1;
echo "<a href='foxbbs.php?dpage=".$d."&amp;rows=".$rows."&amp;l=".$l."&amp;user=".$user."'>[上一页]</a> <a href='foxbbs.php?dpage=".$u."&amp;rows=".$rows."&amp;l=".$l."&amp;user=".$user."'>[下一页]</a>";
}
else if($dpage==$page) //如果当前在最后一页
{
$d=$dpage-1;
echo "<a href='foxbbs.php?dpage=".$d."&amp;rows=".$rows."&amp;l=".$l."&amp;user=".$user."'>[上一页]</a> [下一页]";
}
echo "</font></div></td>";
echo "</tr></table></td></tr>";
echo "<div align="center">论题数:".$num." 当前第".$dpage."页/共有".$page."页<select name="dpage" onchange="javascript:location.href=this.options[this.selectedIndex].value" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px dashed; BORDER-LEFT: #000000 1px dashed; BORDER-RIGHT: #000000 1px dashed; BORDER-TOP: #000000 1px dashed;">";
for ($i=1;$i&lt;=$page;$i++)
{
if ($i==$dpage) echo "<option selected="" value='foxbbs.php?dpage=".$i."&amp;rows=".$row."&amp;l=".$l."&amp;user=".$user."'>第".$i."页</option>";
else echo "<option value='foxbbs.php?dpage=".$i."&amp;rows=".$rows."&amp;l=".$l."'>第".$i."页</option>";
}
echo "</select>";
echo "<select name="dpage" onchange="javascript:location.href=this.options[this.selectedIndex].value" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px dashed; BORDER-LEFT: #000000 1px dashed; BORDER-RIGHT: #000000 1px dashed; BORDER-TOP: #000000 1px dashed;">";
echo "<option selected="" value="">选择排序方式</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=".$rows."&amp;user=".$user."&amp;l=1'>安发贴时间排序</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=".$rows."&amp;user=".$user."&amp;l=3'>安点击数排序</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=".$rows."&amp;user=".$user."&amp;l=2'>安回复数排序</option>";
echo "</select>";
echo "<select name="dpage" onchange="javascript:location.href=this.options[this.selectedIndex].value" style="BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px dashed; BORDER-LEFT: #000000 1px dashed; BORDER-RIGHT: #000000 1px dashed; BORDER-TOP: #000000 1px dashed;">";
echo "<option selected="" value="">选择每页显示行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=5&amp;l=".$l."&amp;user=".$user."'>每页五行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=10&amp;l=".$l."&amp;user=".$user."'>每页十行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=15&amp;l=".$l."&amp;user=".$user."'>每页十五行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=20&amp;l=".$l."&amp;user=".$user."'>每页二十行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=25&amp;l=".$l."&amp;user=".$user."'>每页二十五行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=30&amp;l=".$l."&amp;user=".$user."'>每页三十行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=35&amp;l=".$l."&amp;user=".$user."'>每页三十五行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=40&amp;l=".$l."&amp;user=".$user."'>每页四十行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=45&amp;l=".$l."&amp;user=".$user."'>每页四十五行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&amp;rows=50&amp;l=".$l."&amp;user=".$user."'>每页五十行</option>";
echo "</select>";
$query="select count(*) from useinfo"; //统计注册用户数
$req=mysql_query($query);
$usenum=mysql_fetch_array($req);
$query="select usename from useinfo order by useid desc limit 0,1"; //查找最新注册的用户,因为ID是自增的,所以可以根据ID来判断,最大的也就是最新的。
$req=mysql_query($query);
$newuse=mysql_fetch_array($req);
echo " 目前共有成员[<font color="ff0000">".$usenum[0]."</font>]名/最新加盟[<font color="ff0000">".$newuse[0]."</font>]";

 1<table border="0" cellpadding="0" cellspacing="0" width="100%">
 2<tr>
 3<td height="30"> </td>
 4</tr>
 5<tr>
 6<td height="30">
 7<table border="0" cellpadding="0" cellspacing="0" width="100%">
 8<tr>
 9<td height="20" width="20%">
10<div align="left">状态说明:</div>
11</td>
12<td height="20" width="20%">
13<div align="left"></div>
14</td>
15<td height="20"> </td>
16<td height="20"> </td>
17</tr>
18<tr>
19<td height="20" width="25%">
20<div align="left"><img height="11" src="images/newfolder.gif" width="14"/>   
21当天产生新论题</div>
22</td>
23<td height="20" width="25%">
24<div align="left"><img height="17" src="images/newhotfolder.gif" width="14"/>   
25当天回复最高的论题</div>
26</td>
27<td height="20" width="25%">
28<div align="left"><img height="11" src="images/folder.gif" width="14"/>   
29一天以前的论题</div>
30</td>
31<td height="20" width="25%">
32<div align="left"><img height="17" src="images/hotfolder.gif" width="14"/>   
33总计回复超过50个的论题</div>
34</td>
35</tr>
36<tr>
37<td height="20" width="25%">
38<div align="left"><img height="15" src="images/lock.gif" width="12"/>   
39已被关闭的主题 </div>
40</td>
41<td height="20" width="25%">
42<div align="left"></div>
43</td>
44<td height="20" width="25%">
45<div align="left"></div>
46</td>
47<td height="20" width="25%">
48<tr><td colspan="4" height="100"><div align="center"><font color="ff0000">★论坛说明★</font></div><br/><div align="left">   
491、此论坛只有注册用户才能发贴,如果您没注册,可以游客身份,查看、回复贴子,但是不能发帖。<br/>   
502、发帖用户将对论坛内所发的言论负全部责任,回本论坛主要是以情感方面为话题,(在技术论坛出来以前,可以适当地讨论技术方面的问题),如果站长一旦发现有用户使用本论坛讨论其它无关话题,将会立即加锁。(本站将相继推出其它论坛)<br/>   
513、我还没想到。呵呵……   
52</div></td></tr>
53<div align="left"></div>
54<tr><td height="70"></td></tr>
55<tr>
56<td colspan="4" height="20">
57<div align="center">&lt; <a href="mailto:[email protected]">与我联系</a> |─| <a href="mailto:[email protected]">FlyFox@Net</a> &gt;</div>
58</td>
59</tr>
60<tr><td height="20"></td></tr>
61<tr>
62<td colspan="4" height="20">
63<div align="center"><font color="#6666FF">飞狐工作室制作开发</font></div>
64</td>
65</tr>
66</td></tr></table>
67</td>
68</tr>
69</table></div></body>
70</html>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus