【php开源代码栏目提醒】:本文主要为网学会员提供view_forums.php,希望对需要view_forums.php网友有所帮助,学习一下!
<?
/******************************************************************************\
* Copyright (C) 2002 B Squared (b^2) by Josh Sherman <josh@cleancode.org> *
* *
* This script displays the contents for the 'View Forums' page. Don't *
* forget the 12 space indent for all content pages. *
* *
* Last modified : September 21st, 2002 (JJS) *
\******************************************************************************/
/* Deter hackers */
$file_name = "view_forums.php";
/* Get the negative length of $file_name */
$file_name_length = -(strlen($file_name));
/* Check if the values match, if so, redirect */
if (substr($_SERVER['SCRIPT_NAME'], $file_name_length) == $file_name)
header("Location: ../index.php");
/* Pull the total number of users */
$SQL = "SELECT COUNT(*) as total_users FROM " . TABLE_PREFIX . "users;";
$results = ExeSQL($SQL);
/* Start off the table to divide everything */
echo " <TABLE border=\"0\" width=\"100%\">\n"
. " <TR class=\"small_text\">\n"
. " <TD>\n";
/* Grab the data, and display it */
while ($row = mysql_fetch_array($results))
echo " 总共注册用户: <B>" . $row["total_users"] . "</B><BR>\n";
/* Start the number of posts at zero */
$total_posts = 0;
/* Pull the total number of threads */
$SQL = "SELECT COUNT(*) AS total_posts FROM " . TABLE_PREFIX . "threads;";
$results = ExeSQL($SQL);
/* Grab the data and load it in a variable */
while ($row = mysql_fetch_array($results))
$total_posts = $row["total_posts"];
/* Pull the total number of replies */
$SQL = "SELECT COUNT(*) AS total_posts FROM " . TABLE_PREFIX . "replies;";
$results = ExeSQL($SQL);
/* Grab the data, and load it in a variable */
while ($row = mysql_fetch_array($results))
$total_posts = $total_posts + $row["total_posts"];
/* Display the total number of posts */
echo " 总贴数: <B>$total_posts</B><BR>\n";
/* Pull the most recent user added to the database */
$SQL = "SELECT * FROM " . TABLE_PREFIX . "users ORDER BY user_id DESC LIMIT 1;";
$results = ExeSQL($SQL);
/* Grab the data, and throw it on the screen */
while ($row = mysql_fetch_array($results))
echo " 欢迎最新
注册会员, <B><A href=\"?pid=view_profile&user=" . $row["user_name"] . "\">" . $row["user_name"] . "</A></B>.<P>\n";
/* Show the current date / time, then close out the table */
echo " </TD>\n"
. " <TD align=\"right\" valign=\"bottom\">\n"
. " " . date("l, F jS, Y\<\B\R\>g:i:s A T") . "\n"
. " </TD>\n"
. " </TR>\n"
. " </TABLE>\n";
/* Pull the forum list */
$SQL = "SELECT DISTINCT(forum_id) FROM " . TABLE_PREFIX . "forums;";
$results = ExeSQL($SQL);
/* Grab the data, and load it in an array */
while ($row = mysql_fetch_array($results))
$forum_list[] = $row["forum_id"];
/* Loop through the forum list and count the number of threads and replies, loading both into their respective arrays */
for ( $i = 0; $i < count($forum_list); $i++ )
{
/* Set the current forum in the loop */
$current_forum = $forum_list[$i];
/* Pull the total number of threads for the forum */
$SQL = "SELECT COUNT(*) AS total_threads FROM " . TABLE_PREFIX . "threads WHERE forum_id='$current_forum';";
$results = ExeSQL($SQL);
/* Grab the data, and load it in an array */
while ($row = mysql_fetch_array($results))
$total_threads[] = $row["total_threads"];
/* Pull the total number of replies for the forum */
$SQL = "SELECT COUNT(*) AS total_replies FROM " . TABLE_PREFIX . "replies WHERE forum_id='$current_forum';";
$results = ExeSQL($SQL);
/* Grab the data, and load it in an array */
while ($row =
mysql_fetch_array($results))
$total_replies[] = $row["total_replies"];
}
/* Build the
HTML table (column headings) */
echo " <TABLE cellspacing=\"0\" cellpadding=\"5\" width=\"100%\" border class=\"table_border\">\n"
. " <TR >\n"
. " <TD>论坛</TD>\n"
. " <TD align=\"center\" width=\"\">原始帖</TD>\n"
. " <TD align=\"center\" width=\"\">回复帖</TD>\n"
. " <TD align=\"center\" width=\"\" nowrap>最新发帖时间</TD>\n"
. " <TD align=\"center\" width=\"\">版主</TD>\n"
. " </TR>\n";
/* Pull each forum name in alpabetical order */
$SQL = "SELECT * FROM " . TABLE_PREFIX . "forums ORDER BY forum_order, forum_name;";
$results = ExeSQL($SQL);
/* Grab the data, do crap to it and and display it in the table */
while ($row = my
sql_fetch_array($results))
{
/* Determine how many posts there are for that forum */
$forum_key = array_search($row["forum_id"], $forum_list);
$all_threads = $total_threads[$forum_key];
$all_replies = $total_replies[$forum_key];
/* If there are no posts, then just set the value to "--" instead of "0" which I find unpleasant