<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* 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.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or Header("Location: ../../index.php");

$module_name = "Feedback";
get_lang($module_name);
$pagetitle = " - "._FEEDBACKTITLE."";
/**********************************/
/* Configuration                  */
/*                                */
/* You can change this:           */
/* $index = 0; (right side off)   */
/**********************************/
$index = 1;
$subject = "$sitename "._FEEDBACK."";
/**********************************/

incoh();
global $opi, $message, $send, $cookie;
$cookie[0] = $GLOBALS['db']->XMFnum($cookie[0]);
if ($cookie[1] != "") {
	$sql = "SELECT `name`, `username`, `user_email` FROM `".TABLE_USERS."` WHERE `user_id`='$cookie[0]'";
	if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain users modules', '', __LINE__, __FILE__, $sql);}
	$row = $GLOBALS['db']->sql_fetchrow($result);
	$rname = stripslashes($row['name']);
	if ($rname != "") {
		$sender_name = stripslashes($row['name']);
	} else {
		$sender_name = stripslashes($row['username']);
	}
	$sender_email = stripslashes($row['user_email']);
}

$form_block = "
    <center><font class='title'><b>$sitename: "._FEEDBACKTITLE."</b></font>
    <br /><br /><font class=\"content\">"._FEEDBACKNOTE."</font>
    <form method=\"post\" action=\"modules.php?name=$module_name\">
    <p><strong>"._YOURNAME.":</strong><br />
    <input type=\"text\" name=\"sender_name\" value=\"$sender_name\" size='30' /></p>
    <p><strong>"._YOUREMAIL.":</strong><br />
    <input type=\"text\" name=\"sender_email\" value=\"$sender_email\" size='30' /></p>
    <p><strong>"._MESSAGE.":</strong><br />
    <textarea name=\"message\" cols='70' rows='15'>$message</textarea></p>
    <input type=\"hidden\" name=\"opi\" value=\"ds\" />
    <p><input type=\"submit\" name=\"submit\" onclick=\"this.form.submit();this.disabled=true;this.value='"._WAITING."'\" value=\""._SEND."\" /></p>
    </form></center>
";

Max_OpenTable();
if ($opi != "ds") {
	echo "$form_block";
} elseif ($opi == "ds") {
	if ($sender_name == "") {
		$name_err = "<center><font class=\"option\"><b><i>"._FBENTERNAME."</i></b></font></center><br />";
		$send = "no";
	}
	if ($sender_email == "") {
		$email_err = "<center><font class=\"option\"><b><i>"._FBENTEREMAIL."</i></b></font></center><br />";
		$send = "no";
	}
	if ($message == "") {
		$message_err = "<center><font class=\"option\"><b><i>"._FBENTERMESSAGE."</i></b></font></center><br />";
		$send = "no";
	}
	if ($send != "no") {
		$sender_name = removecrlf($sender_name);
		$sender_email = removecrlf($sender_email);
		$msg = "$sitename\n\n";
		$msg .= ""._SENDERNAME.": $sender_name\n";
		$msg .= ""._SENDEREMAIL.": $sender_email\n";
		$msg .= ""._MESSAGE.": $message\n\n";
		$to = $adminmail;
		$mailheaders = "From: $sender_name <$sender_email>\n";
		$mailheaders .= "Reply-To: $sender_email\n\n";
		mail($to, $subject, $msg, $mailheaders);
		echo "<p><center>"._FBMAILSENT."</center></p>"
		    ."<p><center>"._FBTHANKSFORCONTACT."</center></p>";
	} elseif ($send == "no") {
		OpenTable2();
		echo "$name_err"
		    ."$email_err"
		    ."$message_err";
		CloseTable2();
		br('2');
		echo "$form_block";
	}
}

Max_CloseTable();
incof();