<?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(3);
if( ($Submit) AND ($_SERVER['HTTP_REFERER'] == $sxSetup['Url'].'/guestbook_sign.php') )
{
$process_form = false;
// If form is secured
if($sxSetup['FormSecurity'] == 1)
{
// Validate the code
if(validateSecurityCode(htmlspecialchars($security_code), intval($codeid,10)) == true)
$process_form = true;
else
$message = $sxLang['MessageSecurityCodeRejected'];
}
else
$process_form = true;
if($process_form == true)
{
$name = htmlspecialchars($name);
$email = htmlspecialchars($email);
$website = htmlspecialchars($website);
$gbmessage = htmlspecialchars($gbmessage);
$query = "INSERT INTO $DB_Guestbook (name, email, website, message, timestamp, approved) VALUES ('$name', '$email', '$website', '$gbmessage', '$NOW', '0')";
$result = mysql_query($query, $Link) or queryError("11", mysql_error());
if($sxSetup['GuestbookApproval'])
{
mail($sxSetup['AdminEmail'], $sxLangMail['SubjectGuestbookApproval'], $sxLangMail['GuestbookApproval'], "From: ".$sxSetup['AdminEmail']);
header("Location: guestbook.php?message=".urlencode($sxLang['MessageGuestbookApproval']));
die();
}
else
{
header("Location: guestbook.php");
die();
}
}
}
// Referal check
elseif( !( (!$Submit) AND ( ($_SERVER['HTTP_REFERER'] == $sxSetup['Url'].'/guestbook.php') OR ($_SERVER['HTTP_REFERER'] == $sxSetup['Url'].'/sitemap.php')) ) )
die();
// Secure imaging
if($sxSetup['FormSecurity'] == 1)
$sxSecureImage = sxCreateSecurityImage();
$sxTitleAddendum = getComponentName("3").' - Sign '.getComponentName("3");
include("themes/$THEME_FOLDER/header.php");
?>
<script language="javascript" type="text/javascript">
<!--
function submitIt(myForm){
if(myForm.name.value == ""){
alert("<?PHP echo $sxLang['GuestbookJSNameEmpty']; ?>");
myForm.name.select();
return false;
}
if(myForm.gbmessage.value == ""){
alert("<?PHP echo $sxLang['GuestbookJSMessageEmpty']; ?>");
myForm.gbmessage.select();
return false;
}
}
//-->
</script>
<div class="bodyWrapper">
<h1><?php echo $sxLang['GuestbookSign']; ?></h1>
<?PHP echoMessage($message); ?>
<form name="sxGuestbookSign" method="post" action="<?PHP echo $PHP_SELF; ?>" onsubmit="return submitIt(this)">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemName']; ?></td>
<td><input name="name" type="text" id="name" maxlength="80"<?PHP if($Submit) echo ' value="' . $name . '"'; elseif(loggedIn()) echo ' value="' . $HTTP_SESSION_VARS['firstname'] . ' ' . $HTTP_SESSION_VARS['lastname'] . '"'; ?> /></td>
</tr>
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemEmail']; ?></td>
<td><input name="email" type="text" id="email" maxlength="80"<?PHP if($Submit) echo ' value="' . $email . '"'; elseif(loggedIn()) echo ' value="' . $HTTP_SESSION_VARS['email'] . '"'; ?> /></td>
</tr>
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemWebsite']; ?></td>
<td><input name="website" type="text" id="website" maxlength="255"<?PHP if($Submit) echo ' value="' . $website . '"'; elseif(loggedIn()) echo ' value="' . $HTTP_SESSION_VARS['website'] . '"'; ?> />
<span class="sxSmallText">(<?PHP echo $sxLang['GuestbookWebsitePleaseEnter']; ?>)</span></td>
</tr>
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemMessage']; ?></td>
<td><textarea name="gbmessage" id="gbmessage" style="width:300px;height:200px;"><?PHP if($Submit) echo $gbmessage; ?></textarea></td>
</tr>
<?PHP if($sxSetup['FormSecurity'] == 1){ ?>
<tr>
<td class="sxTdItem"> </td>
<td><img src="<?PHP echo $sxSecureImage['url']; ?>" /><br/><?PHP echo $sxLang['GeneralItemSecureCase']; ?></td>
</tr>
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemSecureCode']; ?></td>
<td><input name="security_code" type="text" id="security_code" maxlength="255" /></td>
</tr>
<?PHP } ?>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="<?PHP echo $sxLang['GuestbookSign']; ?>" class="sxButton" />
<input type="hidden" name="codeid" value="<?PHP echo $sxSecureImage['codeid']; ?>" /></td>
</tr>
<?PHP if($sxSetup['GuestbookApproval'] == 1){ ?>
<tr>
<td valign="top"> </td>
<td><?PHP echo $sxLang['GuestbookApprovalRequired']; ?></td>
</tr>
<?PHP } ?>
</table>
</form>
</div>
<?PHP
include("themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>