我的论坛源代码(二)


Posted in PHP onOctober 09, 2006

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

<HTML>
<HEAD>
<TITLE>狐网论坛</TITLE>
<STYLE type=text/css>
P {FONT-FAMILY: normal; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt}
DIV {FONT-FAMILY: normal; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt}
</STYLE>
<LINK href="js/lfox.css" rel=stylesheet /LINK>
<?php
include "linkfox.inc.php";
include "info.inc.php";

?>
</HEAD>
<body bgcolor="#FFFFFF">
<?
$tem=$HTTP_COOKIE_VARS[FlyFoxNet];        //这里取COOKIE里的信息
$temp=explode("|",$tem);                  //因为用户名和密码是用"|"分隔并记录在COOKIE里的
$cookiem=$temp[0];                        //取用户名
$useinfo=cuser($cookiem,$action);         //CUSER这个函数是用来判别是否从COOKIE中取出了信息
$query="select usename from useinfo where usename='".$useinfo[0]."'"; //检查是否注册用户
$req=mysql_query($query);
if ($req)
{
  $usename=mysql_fetch_array($req);                            
    if($usename[0]==$useinfo[0]) $useinfo[0]=$usename[0];     
    else {
        $usename=1;
        $useinfo[0]="游客";
         }
}
else $usename=1;$useinfo[0]="游客";
?>
<table width="100%" cellpadding="4" cellspacing="0" border="0">
  <tr>
    <td height="40" rowspan="2" width="60%">
      <div align="right"></div>
      <div align="right"></div>
    </td>
    <td height="20" width="10%"> </td>
    <td height="20" width="10%"> </td>
    <td height="20" width="10%"> </td>
    <td height="20" width="10%"> </td>
  </tr>
  <tr>
    <td height="20" width="10%">
      <div align="center"><a href="reguse.php?action=xy"><img src="images/top_register.gif" width="74" height="21" border="0"></a></div>
    </td>
    <td height="20" width="10%">
      <div align="center"><a href="useinfo.php?action=find"><img src="images/top_members.gif" width="74" height="21" border="0"></a></div>
    </td>
    <td height="20" width="10%"><a href="useinfo.php?action=edit"><img src="images/top_profile.gif" width="74" height="21" border="0"></a></td>
    <td height="20" width="10%"><a href="okey.php?d=q"><img src="images/top_logout.gif" width="74" height="21" border="0"></a></td>
  </tr>
  <tr>
    <td height="20" width=60%>
      <div align="left">当前位置:<font color="#0000FF">狐网─>狐网论坛─>主题列表</font>

<? echo "<font color='00dd00'>".$useinfo[2]."</font><font color='ff0000'>"; echo "欢迎你来到论坛!</font>"; ?></div>
    </td>
    <td height="20" width="10%">
      <div align="center"><? echo "<a href='post.php'><img src='images/newthread.gif' width='70' height='20' border='0' alt='发布新帖'></a>";  ?></div>
    </td>
    <td height="20" width="10%">
      <div align="center"><? if ($action==find) echo "<a href='foxbbs.php'><img src='images/dispall.gif' width='70' height='20' border='0' alt='显示所有贴子列表'></a>"; else echo "<a href='superuse.php'  target='_blank'><img src='images/super.gif' border='0' alt='管理专区,非请莫进'></a>";?></div>
    </td>
    <td height="20" width="10%">
      <div align="center"><a href="reguse.php?action=dl"><img src="images/dl.gif" border="0" alt="登录用户"></a></div>
    </td>
    <td height="20" width="10%">
      <div align="center"><a href="http://lfox.oso.com.cn/index.php" target="_blank"><img src="images/fox.gif" border="0" alt="返回狐网首页"></a></div>
    </td>
  </tr>
</table>
<? echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
echo "<tr bgcolor='#000000'><td><table width='100%' border='0' cellspacing='1' cellpadding='1'>";
?>       <tr bgcolor="#229999">
          <td width="5%">
            <div align="center"><font color="#FFFFFF">状态</font></div>
          </td>
          <td width="5%">
            <div align="center"><font color="#FFFFFF">表情</font></div>
          </td>
          <td width="30%">
            <div align="center"><font color="#FFFFFF">主

题</font></div>
          </td>
          <td width="25%">
            <div align="center"><font color="#FFFFFF">作

者</font></div>
          </td>
          <td width="5%">
            <div align="center"><font color="#FFFFFF">回复</font></div>
          </td>
          <td width="5%">
            <div align="center"><font color="#FFFFFF">人气</font></div>
          </td>
          <td width="25%">
            <div align="center"><font color="#FFFFFF">最后回复时间</font></div>
          </td>
        </tr>
        <?php
$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<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>$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<$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日)&&$bbs[6]<$imgnum&&$bbs[12]!=1)                           // 如果是当天的帖子
              $img="images/newfolder.gif";

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

              else if(substr($bbs[4],0,-8)!=date(Y年n月j日)&&$bbs[6]>=$imgnum&&$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]."&use=".$bbs[1]."'>".$bbs[3]."</a></div></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 width='100%' border='0' cellspacing='0' cellpadding='0'>";
echo "<tr>";
echo "<td height='15' width='100%' colspan='3' bgcolor='#229999'><div align='left'><font color='ffffff'>|===> ";
if($page==1)
  {
     echo "[上一页]

[下一页]";
}

else if ($dpage==1)   //如果当前在第一页
  {
     $u=$dpage+1;
     echo "[上一页]

<a href='foxbbs.php?dpage=".$u."&rows=".$rows."&l=".$l."&user=".$user."'>[下一页]</a>";
   }
else if($dpage>1&&$dpage<$page)   //如果当前在中间页
  {
     $u=$dpage+1;
     $d=$dpage-1;
     echo "<a href='foxbbs.php?dpage=".$d."&rows=".$rows."&l=".$l."&user=".$user."'>[上一页]</a>

<a href='foxbbs.php?dpage=".$u."&rows=".$rows."&l=".$l."&user=".$user."'>[下一页]</a>";
  }
else if($dpage==$page)  //如果当前在最后一页
  {
     $d=$dpage-1;
     echo "<a href='foxbbs.php?dpage=".$d."&rows=".$rows."&l=".$l."&user=".$user."'>[上一页]</a>

[下一页]";
  }
echo "</font></div></td>";
echo "</tr></table></td></tr></table></td></tr></table>";
echo "<div align='center'>论题数:".$num." 当前第".$dpage."页/共有".$page."页<select style='BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px dashed; BORDER-LEFT: #000000 1px dashed; BORDER-RIGHT: #000000 1px dashed; BORDER-TOP: #000000 1px dashed;' name='dpage' onChange='javascript:location.href=this.options[this.selectedIndex].value'>";
for ($i=1;$i<=$page;$i++)
{
  if ($i==$dpage) echo "<option value='foxbbs.php?dpage=".$i."&rows=".$row."&l=".$l."&user=".$user."' selected>第".$i."页</option>";
  else echo "<option value='foxbbs.php?dpage=".$i."&rows=".$rows."&l=".$l."'>第".$i."页</option>";
}
echo "</select>";
echo "<select style='BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px dashed; BORDER-LEFT: #000000 1px dashed; BORDER-RIGHT: #000000 1px dashed; BORDER-TOP: #000000 1px dashed;' name='dpage' onChange='javascript:location.href=this.options[this.selectedIndex].value'>";
echo "<option value='' selected>选择排序方式</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=".$rows."&user=".$user."&l=1'>安发贴时间排序</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=".$rows."&user=".$user."&l=3'>安点击数排序</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=".$rows."&user=".$user."&l=2'>安回复数排序</option>";
echo "</select>";
echo "<select style='BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #000000 1px dashed; BORDER-LEFT: #000000 1px dashed; BORDER-RIGHT: #000000 1px dashed; BORDER-TOP: #000000 1px dashed;' name='dpage' onChange='javascript:location.href=this.options[this.selectedIndex].value'>";
echo "<option value='' selected>选择每页显示行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=5&l=".$l."&user=".$user."'>每页五行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=10&l=".$l."&user=".$user."'>每页十行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=15&l=".$l."&user=".$user."'>每页十五行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=20&l=".$l."&user=".$user."'>每页二十行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=25&l=".$l."&user=".$user."'>每页二十五行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=30&l=".$l."&user=".$user."'>每页三十行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=35&l=".$l."&user=".$user."'>每页三十五行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=40&l=".$l."&user=".$user."'>每页四十行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=45&l=".$l."&user=".$user."'>每页四十五行</option>";
echo "<option value='foxbbs.php?dpage=".$dpage."&rows=50&l=".$l."&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>]";

?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="30"> </td>
  </tr>
  <tr>
    <td height="30">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="20" width="20%">
            <div align="left">状态说明:</div>
          </td>
          <td height="20" width="20%">
            <div align="left"></div>
          </td>
          <td height="20"> </td>
          <td height="20"> </td>
        </tr>
        <tr>
          <td height="20" width="25%">
            <div align="left"><img src="images/newfolder.gif" width="14" height="11">
              当天产生新论题</div>
          </td>
          <td height="20" width="25%">
            <div align="left"><img src="images/newhotfolder.gif" width="14" height="17">
              当天回复最高的论题</div>
          </td>
          <td height="20" width="25%">
            <div align="left"><img src="images/folder.gif" width="14" height="11">
              一天以前的论题</div>
          </td>
          <td height="20" width="25%">
            <div align="left"><img src="images/hotfolder.gif" width="14" height="17">
              总计回复超过50个的论题</div>
          </td>
        </tr>
        <tr>
          <td height="20" width="25%">
            <div align="left"><img src="images/lock.gif" width="12" height="15">
              已被关闭的主题 </div>
          </td>
          <td height="20" width="25%">
            <div align="left"></div>
          </td>
          <td height="20" width="25%">
            <div align="left"></div>
          </td>
          <td height="20" width="25%">
          <tr><td colspan="4" height="100"><div align="center"><font color="ff0000">★论坛说明★</font></div><br><div align="left">
          

1、此论坛只有注册用户才能发贴,如果您没注册,可以游客身份,查看、回复贴子,但是不能发帖。<br>
          

2、发帖用户将对论坛内所发的言论负全部责任,回本论坛主要是以情感方面为话题,(在技术论坛出来以前,可以适当地讨论技术方面的问题),如果站长一旦发现有用户使用本论坛讨论其它无关话题,将会立即加锁。(本站将相继推出其它论坛)<br>
          

3、我还没想到。呵呵……
          </div></td></tr>
            <div align="left"></div>

        <tr><td height="70"></td></tr>
        <tr>
          <td height="20" colspan="4">
            <div align="center">< <a href="mailto:hllinyu@netease.com">与我联系</a> |─| <a href="mailto:hllinyu@netease.com">FlyFox@Net</a> ></div>
          </td>
        </tr>
        <tr><td height="20"></td></tr>
        <tr>
          <td height="20" colspan="4">

            <div align="center"><font color="#6666FF">飞狐工作室制作开发</font></div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</body>
</html> 

PHP 相关文章推荐
模拟flock实现文件锁定
Feb 14 PHP
自动把纯文本转换成Web页面的php代码
Aug 27 PHP
在PHP中养成7个面向对象的好习惯
Jul 17 PHP
PHP版网站缓存加快打开速度的方法分享
Jun 03 PHP
php操作xml
Oct 27 PHP
PHP实现克鲁斯卡尔算法实例解析
Aug 22 PHP
php调用shell的方法
Nov 05 PHP
php使用pdo连接mssql server数据库实例
Dec 25 PHP
redirect_uri参数错误的解决方法(必看)
Feb 16 PHP
PHP面向对象之领域模型+数据映射器实例(分析)
Jun 21 PHP
多个Laravel项目如何共用migrations详解
Sep 25 PHP
PHP实现爬虫爬取图片代码实例
Mar 03 PHP
我的论坛源代码(三)
Oct 09 #PHP
我的论坛源代码(四)
Oct 09 #PHP
PHP的FTP学习(三)
Oct 09 #PHP
我的论坛源代码(六)
Oct 09 #PHP
我的论坛源代码(五)
Oct 09 #PHP
杏林同学录(五)
Oct 09 #PHP
PHP的FTP学习(二)
Oct 09 #PHP
You might like
PHP unlink与rmdir删除目录及目录下所有文件实例代码
2018/02/07 PHP
PHP实现数组转JSon和JSon转数组的方法示例
2018/06/14 PHP
PHP chop()函数讲解
2019/02/11 PHP
什么是JavaScript
2009/08/13 Javascript
javascript中的startWith和endWith的几种实现方法
2013/05/07 Javascript
js使用心得分享
2015/01/13 Javascript
微信JSSDK上传图片
2015/08/23 Javascript
基于javascript实现图片懒加载
2016/01/05 Javascript
nodejs加密Crypto的实例代码
2016/07/07 NodeJs
Vue实现自带的过滤器实例
2017/03/09 Javascript
seajs中模块依赖的加载处理实例分析
2017/10/10 Javascript
浅谈Node异步编程的机制
2017/10/18 Javascript
vue项目设置scrollTop不起作用(总结)
2018/12/21 Javascript
NodeJs实现简易WEB上传下载服务器
2019/08/10 NodeJs
vue-router的钩子函数用法实例分析
2019/10/26 Javascript
浅析js实现网页截图的两种方式
2019/11/01 Javascript
element-ui table行点击获取行索引(index)并利用索引更换行顺序
2020/02/27 Javascript
JS实现页面鼠标点击出现图片特效
2020/08/19 Javascript
Python科学计算环境推荐——Anaconda
2014/06/30 Python
python中使用xlrd读excel使用xlwt写excel的实例代码
2018/01/31 Python
利用Python如何批量修改数据库执行Sql文件
2018/07/29 Python
Python的几种主动结束程序方式
2019/11/22 Python
python3.7.3版本和django2.2.3版本是否可以兼容
2020/09/01 Python
Python和Bash结合在一起的方法
2020/11/13 Python
html5 datalist标签使用示例(自动完成组件)
2014/05/04 HTML / CSS
金宝贝童装官网:Gymboree
2016/08/31 全球购物
Willer台湾:日本高速巴士/夜行巴士预约
2017/07/09 全球购物
英国No.1体育用品零售商:SportsDirect.com
2019/10/16 全球购物
爱国演讲稿500字
2014/05/04 职场文书
品质标语大全
2014/06/21 职场文书
我们的节日春节活动方案
2014/08/22 职场文书
政府个人对照检查材料
2014/08/28 职场文书
道德与公民自我评价
2015/03/09 职场文书
丧事答谢词大全
2015/09/30 职场文书
python实现三阶魔方还原的示例代码
2021/04/28 Python
漫画「日和酱的要求是绝对的」第3卷封面公开
2022/03/21 日漫