include("/home/redresort/public_html.beta/inc/main.inc.php");
include("/home/redresort/public_html.beta/inc/header.inc.php");
//$dept = "kelly@redresort.com";
$dept = "ryan@redresort.com"; // test
$continue = "/";
$errors = array();
// Remove $_COOKIE elements from $_REQUEST.
if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
// Check all fields for an email header.
function recursive_array_check_header($element_value)
{
global $set;
if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i",$element_value)){$set = 1;}}
else
{
foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);}
}
}
recursive_array_check_header($_REQUEST);
if($set){$errors[] = "You cannot send an email header";}
unset($set);
// Validate charity name field.
if(isset($_REQUEST['cName']) && !empty($_REQUEST['cName']))
{
if(preg_match("/[^a-z' -]/i",stripslashes($_REQUEST['name']))){$errors[] = "You have entered an invalid character in the charity name field";}
}
if(!IsSet($_REQUEST['cName']) || !IsSet($_REQUEST['cPurpose']) || !IsSet($_REQUEST['cAddr']) || !IsSet($_REQUEST['cContact']) || !IsSet($_REQUEST['cPhone']) || !IsSet($_REQUEST['cEmail']) || !IsSet($_REQUEST['dReq']) || !IsSet($_REQUEST['dUse']) || !IsSet($_REQUEST['dPromo'])) {
$errors[] = "You are missing required fields. Please fill in the fields marked red.";
$reqFields = 1;
}
// Validate email field.
if(isset($_REQUEST['cEmail']) && !empty($_REQUEST['cEmail']))
{
if(preg_match("/(%0A|%0D|\n+|\r+|:)/i",$_REQUEST['cEmail'])){$errors[] = "Email address may not contain a new line or a colon";}
$_REQUEST['cEmail'] = trim($_REQUEST['cEmail']);
if(substr_count($_REQUEST['cEmail'],"@") != 1 || stristr($_REQUEST['cEmail']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['cEmail']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0 || substr_count($exploded_email[1],".") > 3){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $key => $value){if($key == 0){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}elseif(strlen($value) > 6 || !preg_match('/^[a-z0-9]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}}
}
// Remove leading whitespace from all values.
function recursive_array_check(&$element_value)
{
if(!is_array($element_value)){$element_value = ltrim($element_value);}
else
{
foreach($element_value as $key => $value){$element_value[$key] = recursive_array_check($value);}
}
return $element_value;
}
recursive_array_check($_REQUEST);
// Check referrer is from same site.
if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}
// Check for a blank form.
function recursive_array_check_blank($element_value)
{
global $set;
if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
else
{
foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}
}
}
recursive_array_check_blank($_REQUEST);
if(!$set){$errors[] = "You cannot send a blank form";}
unset($set);
// Display any errors and do not send mail if errors exist.
if(count($errors)){
$page["title"] = "Donation and Sponsorship Requests";
$page["section"] = "about";
$page["header"] = "headerSub";
$page["content_filename"] = "donations";
$menu[$page["section"]] = "on";
include($path ."content/layout/". $page["header"] .".inc.php");
include($path ."content/". $page["section"] . "_" . $page["content_filename"] .".inc.php");
include($path ."content/layout/footer.inc.php");
exit;
}
if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}
// Build message.
$cName = $_REQUEST['cName'];
$cPurpose = $_REQUEST['cPurpose'];
$cAddr = $_REQUEST['cAddr'];
$cContact = $_REQUEST['cContact'];
$cPhone = $_REQUEST['cPhone'];
$cFax = $_REQUEST['cFax'];
$cEmail = $_REQUEST['cEmail'];
$fType = $_REQUEST['fType'];
$fDate = $_REQUEST['fDate'];
$fLoc = $_REQUEST['fLoc'];
$fPeople = $_REQUEST['fPeople'];
$fDemo = $_REQUEST['fDemo'];
$fAds = $_REQUEST['fAds'];
$dReq = $_REQUEST['dReq'];
$dUse = $_REQUEST['dUse'];
$dPromo = $_REQUEST['dPromo'];
$message = "
Donation Request from:
------------------------------------------
Charity Name: " . $cName . "
Description:
" . $cPurpose . "
Contact Name: " . $cContact . "
Address: " . $cAddr . "
Email: " . $cEmail . "
Phone: " . $cPhone . "
Fax: " . $cFax . "
Function Details:
------------------------------------------
Type of Function: " . $fType . "
Function Date: " . $fDate . "
Function Location: " . $fLoc . "
Number of People Attending: " . $fPeople . "
Function Demographics:
" . $fDemo . "
Advertising:
" . $fAds . "
Donation Request:
------------------------------------------
Donation Request:
" . $dReq . "
How will the donation be used?:
" . $dUse . "
Promotion of Red:
" . $dPromo . "";
$message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."Red Mountain Resort";
$message = stripslashes($message);
$subject = "Donation Form Submission";
$from = $_REQUEST['cEmail'];
$errors = NULL;
mail2($dept,$subject,$message,$from);
/***************************************
********* EDIT THIS SECTION **********
***************************************/
$page["title"] = "Donation and Sponsorship Requests";
$page["section"] = "about";
$page["header"] = "headerSub";
$page["content_filename"] = "donations_sent";
$menu[$page["section"]] = "on";
/***************************************
********* DO NOT EDIT BELOW ***********
***************************************/
include($path ."content/layout/". $page["header"] .".inc.php");
include($path ."content/". $page["section"] . "_" . $page["content_filename"] .".inc.php");
include($path ."content/layout/footer.inc.php");
?>