rendered paste body<?PHP
######################################################
# #
# Forms To Go 3.1.0 #
# http://www.bebosoft.com/ #
# #
######################################################
DEFINE('kOptional', True);
DEFINE('kMandatory', False);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('track_errors', true);
function DoStripSlashes($FieldValue)
{
if ( get_magic_quotes_gpc() ) {
if (is_array($FieldValue) ) {
return array_map('DoStripSlashes', $FieldValue);
} else {
return stripslashes($FieldValue);
}
} else {
return $FieldValue;
}
}
#----------
# FilterCChars:
function FilterCChars($TheString)
{
return preg_replace('/[\x00-\x1F]/', '', $TheString);
}
#----------
# Validate: Email
function check_email($email, $optional)
{
if ( (strlen($email) == 0) && ($optional === true) ) {
return true;
} elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
return true;
} else {
return false;
}
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ClientIP = $_SERVER['REMOTE_ADDR'];
}
$FTGname = DoStripSlashes( $_REQUEST['name'] );
$FTGsurname = DoStripSlashes( $_REQUEST['surname'] );
$FTGemail = DoStripSlashes( $_REQUEST['email'] );
$FTGaddress = DoStripSlashes( $_REQUEST['address'] );
$FTGhomephonenumber = DoStripSlashes( $_REQUEST['homephonenumber'] );
$FTGcellphonenumber = DoStripSlashes( $_REQUEST['cellphonenumber'] );
$FTGoccupation = DoStripSlashes( $_REQUEST['occupation'] );
$FTGage = DoStripSlashes( $_REQUEST['age'] );
$FTGheight = DoStripSlashes( $_REQUEST['height'] );
$FTGhaircolour = DoStripSlashes( $_REQUEST['haircolour'] );
$FTGEyecolour = DoStripSlashes( $_REQUEST['Eyecolour'] );
$FTGProvince = DoStripSlashes( $_REQUEST['Province'] );
$FTGpicture = $_FILES['picture']['name'];
$FTGReset = DoStripSlashes( $_REQUEST['Reset'] );
$FTGSubmit = DoStripSlashes( $_REQUEST['Submit'] );
# Fields Validations
$ValidationFailed = false;
if (!check_email($FTGemail, kMandatory)) {
$ValidationFailed = true;
$FTGemail_errmsg = "E-Mail Adress Invalid";
$ErrorList .= $FTGemail_errmsg . '<br/>';
}
# Include message in error page and dump it to the browser
if ($ValidationFailed === true) {
$ErrorPage = '<html><head><title>Error</title></head><body>';
$ErrorPage .= 'Errors found: <!--VALIDATIONERROR-->';
$ErrorPage .= '</body></html>';
$ErrorPage = str_replace('<!--VALIDATIONERROR-->', $ErrorList, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:name-->', $FTGname, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:surname-->', $FTGsurname, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:email-->', $FTGemail, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:address-->', $FTGaddress, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:homephonenumber-->', $FTGhomephonenumber, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:cellphonenumber-->', $FTGcellphonenumber, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:occupation-->', $FTGoccupation, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:age-->', $FTGage, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:height-->', $FTGheight, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:haircolour-->', $FTGhaircolour, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:Eyecolour-->', $FTGEyecolour, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:Province-->', $FTGProvince, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:picture-->', $FTGpicture, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:Reset-->', $FTGReset, $ErrorPage);
$ErrorPage = str_replace('<!--FIELDVALUE:Submit-->', $FTGSubmit, $ErrorPage);
$ErrorPage = str_replace('<!--ERRORMSG:email-->', $FTGemail_errmsg, $ErrorPage);
echo $ErrorPage;
exit;
}
# Email to Form Owner
$emailSubject = FilterCChars("Promotion Application Form");
$emailBody = "--FTG_BOUNDRY\n"
. "Content-Type: multipart/alternative; boundary=\"FTG_INNERBOUNDRY\"\n"
. "\n"
. "--FTG_INNERBOUNDRY\n"
. "Content-Type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-Transfer-Encoding: 8bit\n"
. "\n"
. "name : $FTGname\n"
. "surname : $FTGsurname\n"
. "email : $FTGemail\n"
. "address : $FTGaddress\n"
. "homephonenumber : $FTGhomephonenumber\n"
. "cellphonenumber : $FTGcellphonenumber\n"
. "occupation : $FTGoccupation\n"
. "age : $FTGage\n"
. "height : $FTGheight\n"
. "haircolour : $FTGhaircolour\n"
. "Eyecolour : $FTGEyecolour\n"
. "Province : $FTGProvince\n"
. "picture : $FTGpicture\n"
. "Reset : $FTGReset\n"
. "Submit : $FTGSubmit\n"
. ""
. "\n"
. "--FTG_INNERBOUNDRY\n"
. "Content-Type: text/html; charset=\"ISO-8859-1\"\n"
. "Content-Transfer-Encoding: base64\n"
. "\n"
. chunk_split(base64_encode("<html>\n"
. "<head>\n"
. "<title></title>\n"
. "</head>\n"
. "<body>\n"
. "name : $FTGname<br/>\n"
. "surname : $FTGsurname<br/>\n"
. "email : $FTGemail<br/>\n"
. "address : $FTGaddress<br/>\n"
. "homephonenumber : $FTGhomephonenumber<br/>\n"
. "cellphonenumber : $FTGcellphonenumber<br/>\n"
. "occupation : $FTGoccupation<br/>\n"
. "age : $FTGage<br/>\n"
. "height : $FTGheight<br/>\n"
. "haircolour : $FTGhaircolour<br/>\n"
. "Eyecolour : $FTGEyecolour<br/>\n"
. "Province : $FTGProvince<br/>\n"
. "picture : $FTGpicture<br/>\n"
. "Reset : $FTGReset<br/>\n"
. "Submit : $FTGSubmit<br/>\n"
. "</body>\n"
. "</html>\n"
. ""))
. "\n"
. "--FTG_INNERBOUNDRY--\n";
if ( is_uploaded_file($_FILES['picture']['tmp_name']) ) {
$fileName = $_FILES['picture']['tmp_name'];
$fileHandle = fopen($fileName, 'r');
$fileAttach = fread($fileHandle, filesize ($fileName));
fclose($fileHandle);
$fileAttach = chunk_split(base64_encode($fileAttach));
$emailBody .= "--FTG_BOUNDRY\n"
. "Content-Type: " . $_FILES['picture']['type'] . "; name=\"" . $_FILES['picture']['name'] . "\"\n"
. "Content-disposition: attachment\n"
. "Content-transfer-encoding: base64\n"
. "\n"
. "$fileAttach\n"
. "\n";
}
$emailBody .= "--FTG_BOUNDRY--\n";
$emailTo = "Zach <zach@webmail.co.za>";
$emailFrom = FilterCChars("$FTGemail");
$emailHeader = "From: $emailFrom\n"
. "MIME-Version: 1.0\n"
. "Content-Type: multipart/mixed; type=\"multipart/alternative\"; boundary=\"FTG_BOUNDRY\"\n"
. "\n";
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
# Redirect user to success page
header("Location: thankyou.html");
exit;
?>