195 lines
6.6 KiB
PHP
195 lines
6.6 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
// if ($school_num == 3) startLog("support.form.php");
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = "";
|
|
$noTitle = true;
|
|
$headerArgs = "";
|
|
|
|
|
|
|
|
if (strlen($school_record['support_email']) == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-MISSING-SUPPORT-EMAIL-ADDRESS');
|
|
header("Location: /?error_message=".urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$emailTo = $school_record['support_email'];
|
|
|
|
|
|
$uidPrompt = getLanguageText('SUPPORT-NAME');
|
|
$session_active = 0;
|
|
if (SessionActive() == 1 && UserLoggedIn()) {
|
|
if (!isset($userid)) $userid = $_SESSION['UserInfo']['userid'];
|
|
if (!isset($user_email)) $user_email = $_SESSION['UserInfo']['email'];
|
|
$uidPrompt = getLanguageText('SUPPORT-ID');
|
|
$session_active = 1;
|
|
}
|
|
|
|
|
|
// Send email if all data is provided
|
|
if (isset($action) && ($action == 'support-submit' || $action == 'support-submit-active')) {
|
|
extract($_POST);
|
|
$error_message = "";
|
|
|
|
$post = print_r($_POST,true);
|
|
|
|
// Check for missing data in form
|
|
if (!isset($question) || strlen($question) == 0 || !isset($userid) || strlen($userid) == 0 || !isset($user_email) || strlen($user_email) == 0) {
|
|
$error_message = getLanguageText('MSG-MISSING-DATA');
|
|
}
|
|
|
|
// Validate the email address
|
|
if (strlen($error_message) == 0) {
|
|
if (!strpos($user_email,"@")) {
|
|
$error_message = getLanguageText('MSG-INVALID-EMAIL');
|
|
}
|
|
}
|
|
|
|
// Check the authentication word
|
|
if ($action == 'support-submit' && strlen($error_message) == 0) {
|
|
if ($session_active || (array_key_exists('hash_func', $_SESSION) && function_exists($_SESSION['hash_func']) &&
|
|
$_SESSION['hash_func'](strtolower($_POST['AuthenticationWord'])) == $_SESSION['freecap_word_hash'])) {
|
|
// reset freeCap session vars
|
|
// cannot stress enough how important it is to do this
|
|
// defeats re-use of known image with spoofed session id
|
|
$_SESSION['freecap_attempts'] = 0;
|
|
$_SESSION['freecap_word_hash'] = false;
|
|
}
|
|
else {
|
|
$error_message = getLanguageText('MSG-INVALID-AUTHENTICATION');
|
|
}
|
|
}
|
|
|
|
|
|
// Send the email
|
|
if (strlen($error_message) == 0) {
|
|
|
|
// Format the email
|
|
include "include/queuemail.php";
|
|
|
|
$school_name = $school_record['school_name'];
|
|
|
|
$emailRecipient = "Hot Lunch Support";
|
|
$emailReply = $userid;
|
|
$emailFrom = $user_email;
|
|
$emailSubject = getLanguageText('SUPPORT-SUBJECT');
|
|
$emailMessage = getLanguageText('EMAIL-FROM') . ": $userid\n" .
|
|
getLanguageText('TEXT-EMAIL') . ": $user_email\n\n" .
|
|
"$question\n\n" .
|
|
"-------------------------------------------\n" .
|
|
date("Y-m-d H:i:s",time()) . "\n" .
|
|
"$school_name\n\n";
|
|
|
|
//
|
|
// Log the request
|
|
//
|
|
$logTo = db_escape_string($emailTo);
|
|
$logReply = db_escape_string($emailReply);
|
|
$logFrom = db_escape_string($emailFrom);
|
|
$logMessage = db_escape_string($emailMessage);
|
|
$query = "insert into support_requests (school_num,emailto,emailreply,emailfrom,emailmessage,submitted,status) " .
|
|
"values ($school_num,'$logTo','$logReply','$logFrom','$logMessage',now(),'Open')";
|
|
db_query($query);
|
|
|
|
|
|
// Process send request
|
|
$emailTo = $EmailReplyAddress;
|
|
$emailFrom = $emailTo;
|
|
QueueEmail($emailTo, $emailFrom, $emailSubject, $emailMessage, $emailReply, $emailRecipient);
|
|
|
|
|
|
$form_message = getLanguageText('THANK-YOU');
|
|
$success = 1;
|
|
}
|
|
|
|
}
|
|
|
|
// Set the action for the form
|
|
$action = "support-submit";
|
|
if ($session_active == 1) $action = "support-submit-active";
|
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
function new_freecap() {
|
|
if(document.getElementById) {
|
|
thesrc = document.getElementById("freecap").src;
|
|
thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
|
|
document.getElementById("freecap").src = thesrc+"?"+Math.round(Math.random()*100000);
|
|
} else {
|
|
alert("Sorry, cannot autoreload freeCap image\nSubmit the form and a new freeCap will be loaded");
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<br>
|
|
<form method='post' action='/'>
|
|
<?php
|
|
$message_width = $default_form_width;
|
|
include "form.messages.php";
|
|
|
|
if (!isset($userid)) $userid = '';
|
|
if (!isset($user_email)) $user_email = '';
|
|
if (!isset($question)) $question = '';
|
|
?>
|
|
<table width='<?php echo($default_form_width) ?>' class='content-table'>
|
|
<?php if (isset($success)) { ?>
|
|
<tr>
|
|
<td colspan='4' align='center'><br><b><?php echo(getLanguageText('SUPPORT-SUCCESS')) ?></b><br><br></td>
|
|
</tr>
|
|
<?php } else { ?>
|
|
<tr>
|
|
<td align='left' colspan='4'><h2><?php echo(getLanguageText('SUPPORT-TITLE')) ?></h2></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left' width='40'></td>
|
|
<td align='right'><?php echo($uidPrompt) ?>: </td>
|
|
<td colspan='2' align='left'><input type='text' name='userid' value='<?php echo(str_replace("'","'",$userid)) ?>' size='30'></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left'></td>
|
|
<td align='right'><?php echo(getLanguageText('SUPPORT-EMAIL')) ?>: </td>
|
|
<td colspan='2' align='left'><input type='text' name='user_email' value='<?php echo($user_email) ?>' size='30'></td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td colspan='2' align='left'><br>
|
|
<?php echo(getLanguageText('SUPPORT-QUESTION')) ?>:<br>
|
|
<textarea name='question' rows='7' cols='80'><?php echo($question) ?></textarea></td>
|
|
</tr>
|
|
<?php if (SessionActive() != 1 || ! UserLoggedIn()) { ?>
|
|
<tr>
|
|
<td></td>
|
|
<td align='right' valign='top'><?php echo(getLanguageText('SUPPORT-AUTHENTICATION')) ?>: </td>
|
|
<td align='left' valign='top'><input type='text' name='AuthenticationWord' size='10'></td>
|
|
<td align='left' width='320'><img src="freecap.php" name="freecap" id="freecap" style="border: 1px solid black;"></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left' colspan='3'></td>
|
|
<td align='left' colspan='1'><span style="font-size: 85%;"><i><?php echo(getLanguageText('CAPTCHA-MSG')) ?> <a href="#" onClick="this.blur();new_freecap();return false;"><?php echo(getLanguageText('CLICK-HERE')) ?></a></td>
|
|
</tr>
|
|
<?php } ?>
|
|
<tr>
|
|
<td colspan='4' align='center'>
|
|
<br>
|
|
<input type='submit' class='btn btn--primary' value='<?php echo(getLanguageText('BUTTON-SUPPORT')) ?>'>
|
|
<br>
|
|
<br>
|
|
</td>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
</table>
|
|
<input type='hidden' name='action' value='<?php echo($action) ?>'>
|
|
</form>
|
|
<br>
|
|
<?php
|
|
echo($EmailReplyAddress);
|
|
endTemplate();
|
|
?>
|