Location: PHPKode > projects > SiteX > forums.php
<?PHP
ob_start();
session_start();

include("includes/globals.php.inc");
include("includes/functions.php");
include("lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("lang/".$sxSetup['Language'].".php");
include("themes/$THEME_FOLDER/config.php.inc");

protectComponentPage(6);

if($search_text_forum)
{
	header("Location: search.php?type=forum&search=".urlencode($search_text_forum));
	die();
}
if($markall)
{
	$query = "DELETE FROM $DB_Forums_Unread WHERE userid='$THIS_USER'";
	$result = mysql_query($query, $Link) or queryError("71", mysql_error());
}
if(($Add)AND(strlen($name2) > 0))
{
	$query = "SELECT * FROM $DB_Forums_Groups ORDER BY position DESC LIMIT 0,1";
	$result = mysql_query($query, $Link) or queryError("22", mysql_error());
	$ROW = mysql_fetch_object($result);
	$position = $ROW->position + 1;
	
	$query = "INSERT INTO $DB_Forums_Groups (name, position) VALUES ('$name2', '$position')";
	$result = mysql_query($query, $Link) or queryError("23", mysql_error());
	$message = $sxLang['MessageForumGroupAdded'];
	header("Location: ./admin/forums_manager.php");
}

$sxTitleAddendum = getComponentName("6");
include("themes/$THEME_FOLDER/header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function confirmMark(theID)
{
	if(confirm("<?PHP echo $sxLang['ForumJSConfirmMarkAll']; ?>"))
	{
		window.location='<?PHP print $PHP_SELF."?markall=true"; ?>';
	}
}
//-->
</script>
<div class="bodyWrapper">
<h1><?PHP echo getComponentName("6"); ?></h1>
<?PHP if($loginError) echoMessage($sxLang['MessageForumMustLogin']); else echoMessage($message); ?>
<div style="padding-left:0px;padding-right:0px;padding-top:1px;padding-bottom:10px;"> &nbsp;
<table border="0" cellspacing="1" cellpadding="6" width="<?PHP echo $sxSetup['ForumWidth']; ?>" align="center">
<tr>
  <td class="tableColumn"><?PHP echo $sxLang['ForumItemForum']; ?></td>
  <td class="tableColumn"><?PHP echo $sxLang['ForumItemTopics']; ?></td>
  <td class="tableColumn"><?PHP echo $sxLang['ForumItemPostsShort']; ?></td>
  <td class="tableColumn"><?PHP echo $sxLang['ForumItemLastPost']; ?></td>
</tr>
<?PHP if((userForumManager())OR(userAdmin())) {  ?>
<tr>
<td colspan="4" class="tableColumn">
	<form name="sxFormAddGroup" method="post" action="<?PHP echo "./admin/forums_manager.php"; ?>">
	  <input name="name2" type="text" id="name2" size="25" maxlength="255" />
	  <input name="Add" type="submit" id="Add" value="<?PHP echo $sxLang['ForumButtonAddGroup']; ?>" class="sxButton" /> | <a href="./admin/forums_manager.php"><?PHP echo $sxLang['AdminLinkForumManage'] ?></a> | <a href="./admin/forums_add.php"><?PHP echo $sxLang['ForumButtonAdd'] ?></a>
	</form>
</td>
</tr>
<?PHP } ?>
<?PHP if(userEditor()) {  ?>
<tr>
<td colspan="4" class="tableColumn">
	<form name="sxFormAddGroup" method="post" action="<?PHP echo "./admin/forums_manager.php"; ?>">
	  <?PHP if($sxSetup['EditorRightsForumsManage']) { ?><input name="name2" type="text" id="name2" size="25" maxlength="255" />
	  <input name="Add" type="submit" id="Add" value="<?PHP echo $sxLang['ForumButtonAddGroup']; ?>" class="sxButton" /> | <?PHP }?><?PHP if($sxSetup['EditorRightsForumsManage']) { ?><a href="./admin/forums_manager.php"><?PHP echo $sxLang['AdminLinkForumManage'] ?></a> |<?PHP }?><?PHP if($sxSetup['EditorRightsForumsAdd']) { ?> <a href="./admin/forums_add.php"><?PHP echo $sxLang['ForumButtonAdd'] ?></a><?PHP } ?>
	</form>
</td>
</tr>
<?PHP }?>
<?PHP
$query = "SELECT * FROM $DB_Forums_Groups ORDER BY position ASC";
$result = mysql_query($query, $Link) or queryError("21", mysql_error());
while($ROW = mysql_fetch_object($result)){
	
	$showGroup = false;
	
	$query2 = "SELECT * FROM $DB_Forums WHERE groupid='$ROW->id' ORDER BY position ASC";
	$result2 = mysql_query($query2, $Link) or queryError("71", mysql_error());
	while($ROW2 = mysql_fetch_object($result2)){
		if((forumAccess($ROW2->id))OR(!$sxSetup['ForumHidePrivate'])) $showGroup = true;
	}
	
	if($showGroup) echo '  <tr><td class="tableColumn" colspan="4">' . $ROW->name . '</td></tr>';
	
	$query2 = "SELECT * FROM $DB_Forums WHERE groupid='$ROW->id' ORDER BY position ASC";
	$result2 = mysql_query($query2, $Link) or queryError("71", mysql_error());			
	while($ROW2 = mysql_fetch_object($result2)){
	
		if((forumAccess($ROW2->id))OR(!$sxSetup['ForumHidePrivate'])){
		
			echo '<tr>';
			echo '<td class="sxTdTableRow"><table border="0" cellpadding="0" cellspacing="0"><tr><td>';
			echo '<table border="0" style="width:5px;height:20px;" bgcolor="';
			
			$uid = $HTTP_SESSION_VARS['userid'];
			
			$query3 = "SELECT * FROM $DB_Forums_Unread, $DB_Forums_Posts
					 WHERE $DB_Forums_Posts.id=$DB_Forums_Unread.postid AND
							$DB_Forums_Posts.forumid='$ROW2->id' AND
							 $DB_Forums_Unread.userid='$uid'";
			$result3 = mysql_query($query3, $Link) or queryError("71", mysql_error());
			if(mysql_num_rows($result3)) echo $sxTheme['ColorTextTable'];
			else echo  $sxTheme['ColorTable'];
			
			echo '">';
			echo '<tr><td></td></tr></table></td><td width="8">&nbsp;</td><td>';
			echo '<strong><a href="forums_view.php?forumid=' . $ROW2->id . '">' . $ROW2->name . '</a> ';
			
			$query3 = "SELECT * FROM $DB_Forums_Private WHERE forumid='$ROW2->id'";
			$result3 = mysql_query($query3, $Link) or queryError("71", mysql_error());
			if(mysql_num_rows($result3))
				echo '<img src="images/noentry.gif" alt="' . $sxLang['ForumPrivate'] . '" />';
			
			echo '</strong><br />';
			echo '<span class="sxSmallText">' . $ROW2->description . '</span></td></tr></table></td>';
			
			echo '<td class="sxTdTableRow">';
			$query3 = "SELECT * FROM $DB_Forums_Posts WHERE forumid='$ROW2->id' AND replyto='0'";
			$result3 = mysql_query($query3, $Link) or queryError("71", mysql_error());
			echo number_format(mysql_num_rows($result3));
			echo '</td>';
			
			echo '<td class="sxTdTableRow">';
			$query3 = "SELECT * FROM $DB_Forums_Posts WHERE forumid='$ROW2->id'";
			$result3 = mysql_query($query3, $Link) or queryError("71", mysql_error());
			echo number_format(mysql_num_rows($result3));
			echo '</td>';
			
			echo '<td class="sxTdTableRow" width="125">';
			$query3 = "SELECT * FROM $DB_Forums_Posts WHERE forumid='$ROW2->id' ORDER BY timestamp DESC LIMIT 0,1";
			$result3 = mysql_query($query3, $Link) or queryError("71", mysql_error());
			if(mysql_num_rows($result3)){
				
				$ROW3 = mysql_fetch_object($result3);
				echo '<span class="sxSmallText">' . fetchDate($ROW3->timestamp, 1, 1) . '<br />' . $sxLang['ForumBy'] . ' ';
				
				if($ROW3->userid != 0){
					$query4 = "SELECT * FROM $DB_Users WHERE id='$ROW3->userid'";
					$result4 = mysql_query($query4, $Link) or queryError("71", mysql_error());
					$ROW4 = mysql_fetch_object($result4);
					echo '<a href="admin/profile_view.php?user=' . $ROW4->username . '">' . $ROW4->username . '</a></span>';
				}else echo $sxLang['Anonymous'].'</span>';
				
			}else echo '<span class="sxSmallText">' . $sxLang['NoPosts'] . '</span>';
			
			echo '</td>';
			echo '</tr>';
		}
	}
}
if(mysql_num_rows($result) == 0) echo '<tr class="sxTdTableRow"><td colspan="3"><em>' . $sxLang['NoForums'] . '</em></td></tr>';
?>
<tr><td class="sxTdTableRow" colspan="4">
<a href="#" onclick="confirmMark()"><span class="sxSmallText"><?PHP echo $sxLang['ForumMarkAll']; ?></span></a><br /><br />
<span class="sxSmallText"><?PHP echo $sxLang['ForumTotalTopics']; ?>: <?PHP
	$sxQueryTotalTopics = "SELECT * FROM $DB_Forums_Posts WHERE replyto='0'";
	$sxResultTotalTopics = mysql_query($sxQueryTotalTopics, $Link) or queryError("2001", mysql_error());
	echo number_format(mysql_num_rows($sxResultTotalTopics));
?></span><br />
<span class="sxSmallText"><?PHP echo $sxLang['ForumTotalPosts']; ?>: <?PHP
	$sxQueryTotalPosts = "SELECT * FROM $DB_Forums_Posts";
	$sxResultTotalPosts = mysql_query($sxQueryTotalPosts, $Link) or queryError("2002", mysql_error());
	echo number_format(mysql_num_rows($sxResultTotalPosts));
?></span><br /><br />
<span class="sxSmallText"><?PHP echo $sxLang['ForumTotalVisitorsOnline']; ?>: <?PHP
	$sxQueryVisitorsOnline = "SELECT * FROM $DB_Visitors WHERE lastvisit>'" . ($NOW-$sxThemeConfig['OnlineTimeInSeconds']) . "'";
	$sxResultVisitorsOnline = mysql_query($sxQueryVisitorsOnline, $Link) or queryError("2006", mysql_error());
	echo number_format(mysql_num_rows($sxResultVisitorsOnline));
?> (<?PHP echo $sxLang['ForumTotalVisitorsOnlineTotal']; ?>), <?PHP
	$sxQueryMembersOnline = "SELECT DISTINCT userid FROM $DB_Visitors WHERE lastvisit>'" . ($NOW-$sxThemeConfig['OnlineTimeInSeconds']) . "' AND userid!='0'";
	$sxResultMembersOnline = mysql_query($sxQueryMembersOnline, $Link) or queryError("2003", mysql_error());
	echo number_format(mysql_num_rows($sxResultMembersOnline));
?> (<?PHP echo $sxLang['ForumTotalVisitorsOnlineMembers']; ?>), <?PHP
	$sxQueryGuestsOnline = "SELECT * FROM $DB_Visitors WHERE lastvisit>'" . ($NOW-$sxThemeConfig['OnlineTimeInSeconds']) . "' AND userid='0'";
	$sxResultGuestsOnline = mysql_query($sxQueryGuestsOnline, $Link) or queryError("2004", mysql_error());
	echo number_format(mysql_num_rows($sxResultGuestsOnline));
?> (<?PHP echo $sxLang['ForumTotalVisitorsOnlineGuests']; ?>)</span><br />
<span class="sxSmallText"><?PHP echo $sxLang['ForumMembersOnline']; ?>: <?PHP
	$sxQueryMembersOnline = "SELECT DISTINCT userid FROM $DB_Visitors WHERE lastvisit>'" . ($NOW-$sxThemeConfig['OnlineTimeInSeconds']) . "' AND userid!='0'";
	$sxResultMembersOnline = mysql_query($sxQueryMembersOnline, $Link) or queryError("2003", mysql_error());
	if(mysql_num_rows($sxResultMembersOnline) > 0){
		$sxFirst = true;
		while($sxROWMembersOnline = mysql_fetch_object($sxResultMembersOnline)){
			if($sxFirst) $sxFirst = false;
			else echo ', ';
			echo '<a href="admin/profile_view.php?user=' . getUsername($sxROWMembersOnline->userid) . '">' . getUsername($sxROWMembersOnline->userid) . '</a>';
		}
	}
?></span>
</td></tr>
<tr>
  <td colspan="4" align="right">
	  <form action="<?PHP echo $PHP_SELF; ?>" name="sxFormSearchForum" method="post">
	  <?PHP echo $sxLang['MessageForumSearch']; ?>: 
	  <input type="text" name="search_text_forum" style="width:150px;" /> 
	  <input type="submit" name="StartSearch" value="<?PHP echo $sxLang['ButtonFind']; ?>" style="width:50px;" class="sxButton" />
	  </form></td>
</tr>
</table>
</div>
</div>
<?PHP
include("themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX