<?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)
############################################################################
# forumemaildetails.php: last changed 20/08/2006  version 2.4.10
#                        by Fred Stuurman (fc.stuurman@hccnet.nl)
#$Id: forumemaildetails.php,v 1.2 2006/10/15 19:08:53 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 ($_GET[forumid]))
{
	$forumid = intval($_GET[forumid]);
}
if (IsSet ($_POST[firstname]))
{
	$firstname = sql_addslashes($_POST[firstname]);
}
if (IsSet ($_POST[lastname]))
{
	$lastname = sql_addslashes($_POST[lastname]);
}
if (IsSet ($_POST[email]))
{
	$email = sql_addslashes($_POST[email]);
}
$error = true;

if ($firstname == "")
{
	$msg = "You didn't supply your first name.";
}
elseif ($lastname == "")
{
	$msg = "You didn't supply your last name.";
}
elseif ($email == "")
{
	$msg = "You didn't supply your email address.";
}
else
{

	$result2 = mysql_query("SELECT name FROM $forumcat_table WHERE cat_index = '$forumid'");
	if (mysql_num_rows($result2) > 0) //get the forum title 
	{
		$forum_title = mysql_result($result2, 0);
	}
	$result = mysql_query("SELECT * FROM $forumuser_table WHERE firstname = '" . $firstname . "' AND surname = '" . $lastname . "' AND email = '" . $email . "'");

	if (mysql_num_rows($result) == 0)
	{
		$msg = $sas_lang[forum_email_wrong_info];
	}
	else
	{
		$row = mysql_fetch_array($result);
		$message_to_sent = "<html><body>" . $sas_lang[forum_message] . " " . $forum_title . "\n\nUser ID = " . $row["username"];
		$message_to_sent .= "\nPassword = " . $row["password"] . "</body></html>";
		$message_to_sent = nl2br($message_to_sent);
		if ($row[email] != '') // send mail to requestor
		{
			require ("$cmsdir/core/class.phpmailer.php"); //use the phpmailer class
			$mail = new PHPMailer();
			$mail->From = $sas_config['email']; //site email address
			$mail->FromName = $sitename;
			$mail->Subject = "$sas_lang[forum_subject] - $sitename";
			$mail->Body = $message_to_sent;
			$mail->IsHTML(true);
			$mail->AddAddress($row[email]); //add email address ads owner.
			$mail->Send();
			$msg = $sas_lang[forum_email_msg] . "<b>" . $row[email] . "</b>";
			$error = false;
		}
		else
		{
			$msg = $sas_lang[forum_email_failed];
		}
	}
}
print "<table border='0' cellpadding='2' cellspacing='0' width='100%'>
          <tr>";
if ($error)
{
	print "<td width='100%' bgcolor='" . $TitleBackgroundColor . "'>
	              <font face='Arial' size='4'>$sas_lang[forum_error]</font></td>
	              </tr>
	              </table>
	              <p><font face='Arial' size='2'>" . $msg . "</font>";
}
else
{
	print "<td>&nbsp</td>
	              </tr>
	              </table>
	              <p><font face='Arial' size='2'>" . $msg . "</font>
	              <p><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>
	              <td width=\"10\">&nbsp;</td>
	              <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?option=login&section=$section&page=$page&forumid=$forumid'><b>$sas_lang[forum_login]</b></a></td>
	              <td background=\"$cmsdir/modules/sn_forum/right.gif\" width=\"10\">&nbsp;</td>
	              </tr></table>";
}
?>
