<?php

#############################################################################
#                              WIZZ FORUM
#  Wizz Forum is a KISS Forum: Keep It Small and Simple.
#
# About the Wizz Forum:
# Original Idea & PHP coding: Mike Kroger (mikek@icon.co.za),
# who granted permission to put Wizz forum uder the GNU GPL.  
# Code adaptations and modularization for Site@School:
# Fred Stuurman (fc.stuurman@hccnet.nl)
############################################################################
# forumviewstats.php: last changed 20/08/2006  version 2.4.03
#                     by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: forumviewstats.php,v 1.1 2006/10/03 09:15:18 fstuurman Exp $
############################################################################
#                        LICENSE INFORMATION
# Copyright (C) 2002, Rosa Boekdrukker Primary School, Holland.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
##############################################################################
if (!defined('IN_SAS'))
{
	die("Hacking attempt");
}

if (IsSet ($_SESSION[forum_username]))
{
	$forum_username = "$_SESSION[forum_username]";
}
if (IsSet ($_SESSION[forum_userindex]))
{
	$forum_userindex = "$_SESSION[forum_userindex]";
}
if (IsSet ($_GET[forumid]))
{
	$forumid = $_GET[forumid];
}

$result = mysql_query("Select * from $forumuser_table where username = '$forum_username'");
if ($row = mysql_fetch_array($result))
{
	print "<table cellspacing=\"0\" cellpadding=\"0\"><tr height=\"25\">
	           <td background=\"$cmsdir/modules/sn_forum/left.gif\" width=\"10\">&nbsp;</td>
	           <td background=\"$cmsdir/modules/sn_forum/middle.gif\" align=\"center\">
	           <a href='index.php?section=$section&page=$page&option=forum&forumid=$forumid'><b>$sas_lang[forum_main_page]</b></a></td>
	           <td background=\"$cmsdir/modules/sn_forum/right.gif\" width=\"10\">&nbsp;</td>
	           </tr></table>
	           <table border='0' cellpadding='2' cellspacing='0' width='100%'>
	           <tr>
	           <td width='100%' bgcolor='$TitleBackgroundColor' align='center'>
	           <font face='Arial' size='4'>$sas_lang[forum_your_stats]</font></td>
	           </tr>
	           </table>
	           <center>
	           <table border='1' cellpadding='0' cellspacing='0' width='80%' bordercolor='" . $sas_lang[forum_bordercolor] . "'>
	           <tr>
	           <td width='100%'>
	           <table border='0' cellpadding='3' cellspacing='0' width='100%'>
	           <tr>
	           <td width='50%' align='right' bgcolor='$OddBackgroundColor'>
	           <font face='Arial' size='2'>$sas_lang[forum_userid]</font></td>
	           <td width='50%' bgcolor='$OddBackgroundColor'>
	           <font face='Arial' size='2'><b>$forum_username</b></font></td>
	           </tr>
	           <tr>
	           <td width='50%' align='right' bgcolor='$EvenBackgroundColor'>
	           <font face='Arial' size='2'>$sas_lang[forum_firstname]</font></td>
	           <td width='50%' bgcolor='" . $EvenBackgroundColor . "'>
	           <font face='Arial' size='2'><b>$row[firstname]</b></font></td>
	           </tr>
	           <tr>
	           <td width='50%' align='right' bgcolor='" . $OddBackgroundColor . "'>
	           <font face='Arial' size='2'>$sas_lang[forum_name]</font></td>
	           <td width='50%' bgcolor='" . $OddBackgroundColor . "'>
	           <font face='Arial' size='2'><b>$row[surname]</b></font></td>
	           </tr>
	           <tr>
	           <td width='50%' align='right' bgcolor='$EvenBackgroundColor'>
	           <font face='Arial' size='2'>$sas_lang[forum_email]</font></td>
	           <td width='50%' bgcolor='$EvenBackgroundColor'>
	           <font face='Arial' size='2'><b>$row[email]</b></font></td>
	           </tr>
	           <tr>
	           <td width='50%' align='right' bgcolor='" . $OddBackgroundColor . "'>
	           <font face='Arial' size='2'>$sas_lang[forum_email_visible]</font></td>";
	if ($row[showemail] == 1)
	{
		$tmptext = $sas_lang[forum_yes];
	}
	else
	{
		$tmptext = $sas_lang[forum_no];
	}
	print "<td width='50%' bgcolor='$OddBackgroundColor'>
	                  <font face='Arial' size='2'><b>$tmptext</b></font></td>
	                  </tr>
	                  <tr>
	                  <td width='50%' align='right' bgcolor='$EvenBackgroundColor'>
	                  <font face='Arial' size='2'>$sas_lang[forum_website]</font></td>
	                  <td width='50%' bgcolor='$EvenBackgroundColor'>
	                  <font face='Arial' size='2'><b>$row[weburl]</b></font></td>
	                  </tr>
	                  <tr>
	                  <td width='50%' align='right' bgcolor='$OddBackgroundColor'>
	                  <font face='Arial' size='2'>$sas_lang[forum_joined_date]</font></td>";
	$ts = mktime(substr($row[joindate], 11, 2), substr($row[joindate], 14, 2), substr($row[joindate], 17, 2), substr($row[joindate], 5, 2), substr($row[joindate], 8, 2), substr($row[joindate], 0, 4));
	print "<td width='50%' bgcolor='" . $OddBackgroundColor . "'><font face='Arial' size='2'><b>" . strftime("%A %d %B %Y, %H:%M:%S", $ts) . "</b></font></td>
	                   </tr>
	                   <tr>
	                   <td width='50%' align='right' bgcolor='" . $EvenBackgroundColor . "'>
	                   <font face='Arial' size='2'>$sas_lang[forum_login_date]</font></td>";
	$ts = mktime(substr($row[lastlogin], 11, 2), substr($row[lastlogin], 14, 2), substr($row[lastlogin], 17, 2), substr($row[lastlogin], 5, 2), substr($row[lastlogin], 8, 2), substr($row[lastlogin], 0, 4));
	print "<td width='50%' bgcolor='" . $EvenBackgroundColor . "'><font face='Arial' size='2'><b>" . strftime("%A %d %B %Y, %H:%M:%S", $ts) . "</b></font></td>
	                   </tr>
	                   <tr>
	                   <td width='50%' align='right' bgcolor='" . $OddBackgroundColor . "'><font face='Arial' size='2'>$sas_lang[forum_contribution_date]</font></td>";
	if ($row[lastcontribution] == NULL)
	{
		print "<td width='50%' bgcolor='" . $OddBackgroundColor . "'><font face='Arial' size='2'>&nbsp;</font></td>";
	}
	else
	{
		$ts = mktime(substr($row[lastcontribution], 11, 2), substr($row[lastcontribution], 14, 2), substr($row[lastcontribution], 17, 2), substr($row[lastcontribution], 5, 2), substr($row[lastcontribution], 8, 2), substr($row[lastcontribution], 0, 4));
		print "<td width='50%' bgcolor='" . $OddBackgroundColor . "'><font face='Arial' size='2'><b>" . strftime("%A %d %B %Y, %H:%M:%S", $ts) . "</b></font></td>";
	}
	print "</tr>
	                   <tr>
	                   <td width='50%' align='right' bgcolor='" . $EvenBackgroundColor . "'>
	                   <font face='Arial' size='2'>$sas_lang[forum_topic_posted]</font></td>
	                   <td width='50%' bgcolor='" . $EvenBackgroundColor . "'>
	                   <font face='Arial' size='2'><b>$row[topics]</b></font></td>
	                   </tr>
	                   <tr>
	                   <td width='50%' align='right' bgcolor='" . $OddBackgroundColor . "'>
	                   <font face='Arial' size='2'>$sas_lang[forum_topic_replies]</font></td>
	                   <td width='50%' bgcolor='" . $OddBackgroundColor . "'>
	                   <font face='Arial' size='2'><b>$row[replies]</b></font></td>
	                   </tr>
	                   </table>
	                   </td></tr>
	                   </table></p>
	                   </center>";
	$result = mysql_query("Select * from $forumtopics_table where userid='" . $forum_username . "'");
	if (mysql_num_rows($result) != 0)
	{
		print "<center><table border='0' cellpadding='2' cellspacing='0' width='100%'>
		                       <tr>
		                       <td width='100%' align='center'>
		                       <font face='Arial' size='4'>$sas_lang[forum_posted_by_you] $forum_username</font></td>
		                       </tr>
		                       </table>
		                       <table border='1' cellpadding='2' cellspacing='0' width='80%' bordercolor='" . $sas_lang[forum_bordercolor] . "'>
		                       <tr>
		                       <td width='80%' bgcolor='$SubtitleBackgroundColor'>
		                       <font face='Arial' size='3' color='$forum_header_font_colour'><b>$sas_lang[forum_topic]</b></font></td>
		                       <td width='10%' bgcolor='$SubtitleBackgroundColor'>
		                       <font face='Arial' size='3' color='$forum_header_font_colour'><b>$sas_lang[forum_reply]</b></font></td>
		                       <td width='10%' bgcolor='$SubtitleBackgroundColor'>
		                       <font face='Arial' size='3' color='$forum_header_font_colour'><b>$sas_lang[forum_read]</b></font></td>
		                       </tr>";
		$bgColor = $OddBackgroundColor;
		while ($row = mysql_fetch_array($result))
		{
			print "<tr>
			                           <td width='80%' bgcolor='" . $bgColor . "'>
			                           <font face='Arial' size='2'><a href='index.php?page=" . $page . "&section=" . $section . "&option=topicdetails&TopicID=" . $row[topic_index] . "'>" . $row[topictitle] . "</a></font></td>
			                           <td width='10%' bgcolor='" . $bgColor . "'>
			                           <font face='Arial' size='2'>" . $row[replies] . "</font></td>
			                           <td width='10%' bgcolor='" . $bgColor . "'>
			                           <font face='Arial' size='2'>" . $row[topic_reads] . "</font></td>
			                           </tr>";
			if ($bgColor == $OddBackgroundColor)
			{
				$bgColor = $EvenBackgroundColor;
			}
			else
			{
				$bgColor = $OddBackgroundColor;
			}
		}
		print "</table></center></p>";
	}
	print "<table cellspacing=\"0\" cellpadding=\"0\"><tr height=\"25\">
	           <td background=\"$cmsdir/modules/sn_forum/left.gif\" width=\"10\">&nbsp;</td>
	           <td background=\"$cmsdir/modules/sn_forum/middle.gif\" align=\"center\">
	           <a href='index.php?section=$section&page=$page&option=forum&forumid=$forumid'><b>$sas_lang[forum_main_page]</b></a></td>
	           <td background=\"$cmsdir/modules/sn_forum/right.gif\" width=\"10\">&nbsp;</td>
	           </tr></table>";
}
else
{
	print "<table border='0' cellpadding='2' cellspacing='0' width='100%'>
	                   <tr>
	                   <td width='100%' bgcolor='$TitleBackgroundColor'><font face='Arial' size='4'>$sas_lang[forum_error]</font></td>
	                   </tr>
	                   </table>
	                   <p><font face='Arial' size='2'>A database error occured while trying to read your forum stats.</font>
	                   <font face='Arial' size='2'><p><A HREF=JavaScript:history.back()>$sas_lang[forum_back]</a></font></p>";
}
?>
