demandSecure(); if($_POST["action"] == ""){ showContactPage(); } else { saveContactPageForm($_POST); } function showContactPage($data = Array(), $errs = Array()){ global $ang, $vars, $usePage; $usePage = 'contact'; $ang->title = "Contact Us"; $vars['title'] = $ang->title; $vars['contacts'] = $ang->contacts; $vars['data'] = $data; $vars['errors'] = $errs; // $this->setSmarty(Array("contacts","extraContacts","alumniContactPage","data", "errors"),Array($ang->contacts,$ang->extraContacts,$this->alumniContactPage, $data, $errs)); $ang->displayPage('contact',$vars); } function saveContactPageForm($postData){ global $ang, $vars, $usePage; foreach($postData as $key => $value){ if($key == "from"){ //must be email address //if(!ereg ("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $value)){ if(!preg_match("/^[^@ ]+@[^@ ]+\.[^@ \.]+$/", $value)){ //this isn't a valid email address $errors[] = "The email address you entered isn't a valid email address format. Please go back and enter a real email address.
We can't contact you without this address!"; } } if($key == "username"){ if($value == ""){ //is now an optional field... so commented out //$errors[] = "Username was blank. Please enter your full ".$this->serviceName." username (ie your full ".$this->serviceName." email address) in the field provided."; } else { //if(!ereg ("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $value)){ if(!preg_match("/^[^@ ]+@[^@ ]+\.[^@ \.]+$/", $value)){ //this isn't a valid email address $errors[] = "Username was invalid. It must be your full email address that you have here!"; } } } if($key == "to"){ //must match one of the available addresses $ok = false; $i = 1; foreach($this->ncontacts AS $thisEmail){ if($value == $i){ $ok = true; $sendingTo = $thisEmail; } $i++; } if(!$ok){ //didn't match the address, bail $errors[] = "The department you requested to send your message to was not recognised. Please go back and ensure you select an option from the list"; } } if($key == "subject" && $value == ""){ //must not be blank $errors[] = "Subject was blank. Please enter a subject to ensure your request is dealt with quickly and efficiently."; } if($key == "body" && $value == ""){ //must not be blank $errors[] = "The message field was blank. Please enter your message in the area provided."; } ${$key} = $value; } if(count($errors) > 0){ //something went wrong showContactPage($postData, $errors); exit; } if($sendingTo == ''){ //nothing? not possible! $sendingTo = 'help@aluminati.net'; } /* send an email */ $content = stripslashes("Contact Form Submission
External Email : $from
Username : $username
Sent To : $sendingTo
Date Sent : ".date('d-m-Y h:i:s')."

$body"); $email = New Email(); //$email->add_recipient('help@aluminati.net'); //debug force copy not usually needed $email->add_recipient($sendingTo); $email->set_subject(stripslashes($subject)); $email->set_from($from); $email->set_content($content); $email->send('-f '.$from); $ang->title = "Thank You!"; $vars['title'] = $ang->title; // $this->setSmarty(Array("content"),Array("A message has been sent to '$sendingTo'. Thank you for contacting us!")); $ang->displayPage('contact',$vars); } ?>