程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> PHP綜合 >> 我的論壇源代碼(二)

我的論壇源代碼(二)

編輯:PHP綜合
主界面,也就是顯示主題列表的這頁。
//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:[email protected]">與我聯系</a> |─| <a href="mailto:[email protected]">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> 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved