Menu
Hi
I bought a booking script from this company – [url]http://www.freecontactform.com/booking_forms.php
[url]http://www.ruks.co.uk/booking_forms/booking/bookingform.htm
when i click on submit I dont get a confirmation email
I have attached all the files used
I need to get it up and runnying so peoplae can book but not sure what has gone wrong
thanks
ruksana
[canned-message]attachments-removed-during-migration
[CODE]<?php
/* Form software from www.FreeContactForm.com */
if(class_exists('required')) {
$reqobj = new required;
$reqobj->add('Full_Name','NOT_EMPTY');
$reqobj->add('Phone_Number','NOT_EMPTY');
$reqobj->add('Email','EMAIL');
$reqobj->add('Number_of_children','SELECT');
$reqobj->add('Full_Name1','NOT_EMPTY');
$reqobj->add('Age','NOT_EMPTY');
$reqobj->add('Time','SELECT');
$reqobj->add('Payment','SELECT');
}
$form_page_name = "bookingform.htm";
$email_it_to = "[email protected]";
$email_it_to_cc = "";
$email_it_to_bcc = "";
$email_it_from = "Little leap of faith";
$email_subject = "Booking Form";
$email_suspected_spam = "*SUSPECT Booking Form";
$accept_suspected_hack = "yes"; // change to "no" to NOT accept
$success_page = "thankyou.htm";
$failure_page = "_formerror.php";
$failure_accept_message = "yes";
if(phpversion() > "5.0") { date_default_timezone_set('UTC'); }
?>[/CODE]
[CODE]<?php
/*
// YOU DO NOT NEED TO CHANGE ANYTHING IN HERE //
include "_validation.php";
include "_configuration.php";
$email_timestamp = date($dateformat,mktime(date("H")+($hour_offset),date("i"),date("s"),date("m"),date("d"),date("y")));
// set-up redirect page
$redirect_to = $success_page;
// make sure we dont have any extra fields
/*foreach($_POST as $field_name => $field_value) {
if(!in_array($field_name,$fieldlist)) {
error_found("unexpected field found: $field_name",$failure_accept_message,$failure_page);
die();
}
}*/
if(!eregi("@",$email_it_from) && !is_array($email_it_from)) {
$email_it_from = $_POST[$email_it_from];
}
// check for any hacking attempts
class clean {
function comments($message) {
$this->naughty = false;
$this->message = $message;
$bad = array("content-type","bcc:","to:","cc:");
$for = array("%0a", "%0d");
// use the line below to be more strict
// $for = array( "r", "n", "%0a", "%0d");
foreach($bad as $b) {
if(eregi($b, $this->message)) {
$this->naughty = true;
}
}
$this->message = str_replace($bad,"#removed#", $this->message);
$this->message = stripslashes(str_replace($for, ' ', $this->message));
// check for HTML/Scripts
$length_was = strlen($this->message);
$this->message = strip_tags($this->message);
if(strlen($this->message) < $length_was) {
$this->naughty = true;
}
}
} // class
// function to handle errors
function error_found($mes,$failure_accept_message,$failure_page) {
if($failure_accept_message == "yes") {
$qstring = "?prob=".urlencode(base64_encode($mes));
} else {
$qstring = "";
}
$error_page_url = $failure_page."".$qstring;
header("Location: $error_page_url");
die();
}
$email_message = "";
// loop through all form fields submitted
foreach($_POST as $field_name => $field_value) {
if(in_array($field_name,array("recaptcha_challenge_field","recaptcha_response_field"))) {
continue;
}
// run all submitted content through string checker
// removing any dangerous code
if(is_array($field_value)) {
$this_val = '';
$fvac = count($field_value);
$fvaci=0;
foreach($field_value as $fva) {
$fvaci++;
$this_val .= $fva;
if($fvaci < $fvac) {
$this_val .= ", ";
}
}
} else {
$ms = new clean;
$ms->comments($field_value);
$is_naughty = $ms->naughty;
$this_val = $ms->message;
}
$email_message .= str_replace("n","rn",$field_name).": ".$this_val."rnrn";
}
$email_message .= "Senders IP Address: ".$_SERVER['REMOTE_ADDR']."rn";
$email_message .= "Form submitted at: ".$email_timestamp."rn";
$email_message .= "Referring Page: ".$_SERVER['HTTP_REFERER']."rnrn";
if($is_naughty) {
if($accept_suspected_hack == "yes") {
// continue
} else {
// pretend the email was sent
header("Location: $redirect_to");
die();
}
$email_subject = $email_suspected_spam;
}
class createTheMail {
public $iso = 'iso-8859-1';
public $linebreak = "rn";
public $from = '';
public $from_name = '';
public $reply_to = '';
public $to = '';
public $subject = '';
public $message = '';
public $bcc = '';
public $cc = '';
private $uid = '';
private $attachment_data = '';
public function __construct() {
$this->uid = md5(uniqid(time()));
}
public function setBcc($name,$email) {
if(strlen(trim($this->bcc)) == 0) {
$this->bcc = $name." <$email>";
} else {
$this->bcc += ','.$name." <$email>";
}
}
public function setCc($name,$email) {
if(strlen(trim($this->cc)) == 0) {
$this->cc = $name." <$email>";
} else {
$this->cc += ','.$name." <$email>";
}
}
public function addAttachment($file, $filename, $type) {
if($type == "") { $type = "application/octet-stream"; }
$filename_actual = basename($file);
$filename_new = empty($filename) ? basename($file) : $filename;
$path = dirname($file);
$file = $path.'/'.$filename_actual;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$content = chunk_split(base64_encode($content));
$this->attachment_data .= "--".$this->uid."rn";
$this->attachment_data .= "Content-Type: $type; name="".$filename_new.""".$this->linebreak;
$this->attachment_data .= "Content-Transfer-Encoding: base64".$this->linebreak;
$this->attachment_data .= "Content-Disposition: attachment; filename="".$filename_new.""".$this->linebreak.$this->linebreak;
$this->attachment_data .= $content.$this->linebreak.$this->linebreak;
}
public function mail() {
if (strlen(trim($this->attachment_data)) > 0) {
$header = "From: ".$this->from_name." <".$this->from.">".$this->linebreak;
$header .= "Reply-To: ".$this->reply_to.$this->linebreak;
if(strlen(trim($this->cc)) > 5) {
$header .= "Cc: ".$this->cc.$this->linebreak;
}
if(strlen(trim($this->bcc)) > 5) {
$header .= "Bcc: ".$this->bcc.$this->linebreak;
}
$header .= "X-Mailer: createTheMail".$this->linebreak;
$header .= "MIME-Version: 1.0".$this->linebreak;
$header .= "Content-Type: multipart/mixed; boundary="".$this->uid.""".$this->linebreak.$this->linebreak;
$header .= "This is a multi-part message in MIME format.".$this->linebreak;
$header .= "--".$this->uid.$this->linebreak;
$header .= "Content-type:text/plain; charset=".$this->iso.$this->linebreak;
$header .= "Content-Transfer-Encoding: 7bit".$this->linebreak.$this->linebreak;
$header .= $this->message.$this->linebreak.$this->linebreak;
$header .= $this->attachment_data;
$header .= "--".$this->uid."--";
if (@mail($this->to, $this->subject, "", $header)) {
return true;
} else {
return false;
}
} else {
$header = "From: ".($this->from_name)." <".($this->from).">".$this->linebreak;
$header .= "Reply-To: ".($this->reply_to).$this->linebreak;
if(strlen(trim($this->cc)) > 5) {
$header .= "CC: ".$this->cc.$this->linebreak;
}
if(strlen(trim($this->bcc)) > 5) {
$header .= "BCC: ".$this->bcc.$this->linebreak;
}
$header .= "X-Mailer: createTheMail".$this->linebreak;
if (@mail($this->to, $this->subject, $this->message, $header)) {
return true;
} else {
return false;
}
}
}
}
unset($_SERVER['PHP_SELF']);
unset($_SERVER['REMOTE_ADDR']);
if(is_array($email_it_to)) {
foreach($email_it_to as $email_it_to_element) {
$myemail = new createTheMail();
$myemail->iso = "iso-8859-1";
$myemail->to = "$email_it_to_element";
$myemail->from = "$email_it_from";
$myemail->from_name = "$email_it_from";
$myemail->reply_to = "$email_it_from";
if(strlen(trim($email_it_to_cc)) > 7) {
$myemail->setCc($email_it_to_cc,$email_it_to_cc);
}
if(strlen(trim($email_it_to_bcc)) > 7) {
$myemail->setBcc($email_it_to_bcc,$email_it_to_bcc);
}
$myemail->subject = $email_subject;
$myemail->message = $email_message;
if(count($_FILES) > 0 ) {
for($i=0; $i < count($_FILES['upload']['name']); $i++) {
if(trim($_FILES['upload']['name'][$i]) == "") {
// nothing selected
} else {
$file_extension = explode(".",$_FILES['upload']['name'][$i]);
$original_filename = $_FILES['upload']['name'][$i];
$file_extension = ".".strtolower($file_extension[(count($file_extension)-1)]);
$source_name = $_FILES['upload']['tmp_name'][$i];
$source_type = $_FILES['upload']['type'][$i];
$source_size = $_FILES['upload']['size'][$i];
if($source_size == 0) {
die('The size of the file '.$original_filename.' is to big, please go back and try again with a smaller file.');
} else {
$myemail->addAttachment($source_name,$original_filename,$source_type);
}
}
}
}
$myemail->mail();
}
} else {
$myemail = new createTheMail();
$myemail->iso = "iso-8859-1";
$myemail->to = "$email_it_to";
$myemail->from = "$email_it_from";
$myemail->from_name = "$email_it_from";
$myemail->reply_to = "$email_it_from";
if(strlen(trim($email_it_to_cc)) > 7) {
$myemail->setCc($email_it_to_cc,$email_it_to_cc);
}
if(strlen(trim($email_it_to_bcc)) > 7) {
$myemail->setBcc($email_it_to_bcc,$email_it_to_bcc);
}
$myemail->subject = $email_subject;
$myemail->message = $email_message;
if(count($_FILES) > 0 ) {
for($i=0; $i < count($_FILES['upload']['name']); $i++) {
if(trim($_FILES['upload']['name'][$i]) == "") {
// nothing selected
} else {
$file_extension = explode(".",$_FILES['upload']['name'][$i]);
$original_filename = $_FILES['upload']['name'][$i];
$file_extension = ".".strtolower($file_extension[(count($file_extension)-1)]);
$source_name = $_FILES['upload']['tmp_name'][$i];
$source_type = $_FILES['upload']['type'][$i];
$source_size = $_FILES['upload']['size'][$i];
if($source_size == 0) {
die('The size of the file '.$original_filename.' is to big, please go back and try again with a smaller file.');
} else {
$myemail->addAttachment($source_name,$original_filename,$source_type);
}
}
}
}
$myemail->mail();
}
// redirect
header("Location: $redirect_to");
die("<script>location.replace('$redirect_to')</script>");
?>[/CODE]
[CODE]<?php
class required {
var $fields; // public
function required() { // __construct()
$this->fields = array();
}
function add($name,$type) { //public
$this->fields[$name] = $type;
}
function out() { // public
return $this->fields;
}
}
class validate {
var $error = false; // public
var $error_string; // publc
var $error_tmp = "data not valid";
function validate($ar, $post) { // __construct()
if(!is_array($ar)) {
/* no validation required */
} else {
foreach($ar as $a_name => $a_type) {
/* if no validation specified, make not_empty */
if(trim($a_type) == "") { $a_type = "NOT_EMPTY"; }
/* make sure $name is in $post */
$found = false;
if($a_type == "COMPARE") {
$found = true;
} else {
foreach($post as $p_name => $p_value) {
if($p_name == $a_name) {
$found = true;
break;
}
}
}
if(!$found) {
$this->errors($a_name." : no data submitted.<br />");
} else {
if(is_array($a_type)) {
foreach($a_type as $tp) {
if(!$this->checkit($p_value,$tp)) {
echo "<i>$p_value,$tp</i><br />";
$this->errors($a_name." : ".$this->error_tmp."<br />");
}
}
} else {
if(!$this->checkit($p_value,$a_type)) {
$this->errors($a_name." : ".$this->error_tmp."<br />");
}
if($a_type == "COMPARE") {
$tmp_z = explode(":",$a_name);
$tmp_a = $tmp_z[0];
$tmp_b = $tmp_z[1];
if($post[$tmp_a] == $post[$tmp_b]) {
// matched
} else {
$this->errors("".htmlentities($tmp_a)."
DOES NOT MATCH ".htmlentities($tmp_a)."
<br />");
}
}
}
}
}
}
}
/* ERRORS */
function errors($str) { // private
$this->error = true;
$this->error_string .= $str;
}
/* VALIDATE FIELD AGAINST TYPE */
function checkit($value,$type) { // private
$length = "";
switch($type) {
case "COMPARE":
return true;
break;
case "CHECKBOX_GROUP":
case "SELECT_MULTIPLE":
if(!is_array($value) || count($value) == 0) {
$this->error_tmp = "nothing selected";
return false;
} else { return true; }
break;
case "CHECKBOX_SINGLE":
case "RADIO_SINGLE":
case "RADIO_GROUP":
case "SELECT":
case "NOT_EMPTY":
$this->error_tmp = "string cannot be empty";
return $this->not_empty($value);
break;
case "ALPHA":
$exp = "^[a-z]+$";
if($this->not_empty($value) && eregi($exp, $value)) { return true; } else { $this->error_tmp = "string not alpha"; return false; }
break;
case "ALPHASPACE":
$exp = "^[a-z ]+$";
if($this->not_empty($value) && eregi($exp, $value)) { return true; } else { $this->error_tmp = "string not alphaspace"; return false; }
break;
case "ALPHANUM":
$exp = "^[a-z0-9]+$";
if($this->not_empty($value) && eregi($exp, $value)) { return true; } else { $this->error_tmp = "string not alphanum"; return false; }
break;
case "ALPHANUMSPACE":
$exp = "^[a-z0-9 ]+$";
if($this->not_empty($value) && eregi($exp, $value)) { return true; } else { $this->error_tmp = "string not alphanumspace"; return false; }
break;
case "NUMERIC":
$exp = "^[0-9]+$";
if($this->not_empty($value) && eregi($exp, $value)) { return true; } else { $this->error_tmp = "string not numeric"; return false; }
break;
case "NUMERICPLUS":
$exp = "^[0-9+-. ]+$";
if($this->not_empty($value) && eregi($exp, $value)) { return true; } else { $this->error_tmp = "string not numericplus"; return false; }
break;
case "EMAIL":
$exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}$";
if($this->not_empty($value) && eregi($exp, $value)) { return true; } else { $this->error_tmp = "not a valid email"; return false; }
break;
case "YYYYMMDD":
$exp = "^(19|20)[0-9][0-9][- /.](0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])$";
if($this->not_empty($value) && eregi($exp, $value)) { return true; } else { $this->error_tmp = "string not YYYYMMDD"; return false; }
break;
case "DDMMYYYY":
$exp = "^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[-/.](19|20)[0-9][0-9]$";
if($this->not_empty($value) && eregi($exp, $value)) { return true; } else { $this->error_tmp = "string not DDMMYYYY"; return false; }
break;
case "MMDDYYYY":
$exp = "^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[-/.](19|20)[0-9][0-9]$";
if($this->not_empty($value) && eregi($exp, $value)) { return true; } else { $this->error_tmp = "string not MMDDYYYY"; return false; }
break;
default:
if($this->not_empty($value) && $this->regex($type,$value)) { return true; } else { $this->error_tmp = "string not valid"; return false; }
}
}
/* NOT_EMPTY */
function not_empty($value) { // private
if(trim($value) == "") { return false; } else { return true; }
}
/* REGULAR EXPRESSION */
function regex($regex, $value) { // private
$the_regex = 'ereg("'.$regex.'", "'.$value.'")';
$the_code = '<?php if('.$the_regex.') { return true; } else { return false; } ?>';
if(!eval('?>'.$the_code.'<?php ')) { return false; } else { return true; }
}
}
?>[/CODE]
0.1.9 — BETA 5.29