is_valid) { $error_recaptcha = "The reCAPTCHA wasn't entered correctly."; $error = 1; } // VALIDATE EMAIL * * * * * * * * * * * * * * * * * * * * * // $est_email = addslashes($_POST['email']); if (!preg_match("/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/", $est_email)) { $error_email = 1; $error = 1; } if (strlen($est_email) < 4){$error_username_length = 1; $error = 1;} $query = "SELECT * FROM a1_member WHERE email = '$est_email'"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); if ($num_rows != 0){ $error_email_used = 1; $error = 1; } $est_email2 = addslashes($_POST['email2']); if ($est_email != $est_email2){ $error_email_repeat = 1; $error = 1; } // VALIDATE USERNAME * * * * * * * * * * * * * * * * * * * * * // $username = $_POST['username']; if (strlen($username) < 4){$error_username_length = 1; $error = 1;} $query = "SELECT * FROM a1_member WHERE username = '$username'"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); if ($num_rows != 0){ $error_username_used = 1; $error = 1; } // VALIDATE AND ENCRYPT PASSWORD * * * * * * * * * * * * * * * * * * * * * // $password = $_POST['password']; if (strlen($password) < 4){$error_password_length = 1; $error = 1;} // $hash = sha1(strtolower($username) . $password); $salt = substr ($password, 0, 2); $hash = crypt($password, $salt); if ($error == 0){ // echo "test1"; $code_entities_match = array(' ','--','"','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',"'",',','.','/','*','+','~','`','='); $code_entities_replace = array('-','-','','','','','','','','','','','','','','','','','','','','','','','',''); $advert = strtolower($establishment); $advert = str_replace($code_entities_match, $code_entities_replace, $advert); $query = "SELECT * FROM a1_member WHERE advert = '$advert'"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); if ($num_rows != 0){ $town_suffix = strtolower($town); $town_suffix = str_replace($code_entities_match, $code_entities_replace, $town_suffix); $advert = $advert . "-" . $town_suffix; $query = "SELECT * FROM a1_member WHERE advert = '$advert'"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); if ($num_rows != 0){ $advert = $advert . "-" . rand(1, 100); } } $redirect = strtolower($town); $redirect = str_replace($code_entities_match, $code_entities_replace, $redirect); $redirect = $redirect . ".php"; // GET LATITUDE AND LONGITUDE FROM POSTCODE * * * * * * * * * * * * * * * * * * * * * *// if (substr($postcode, -4, 1) != " "){ $postcode = substr($postcode, 0, -3) . " " . substr($postcode, -3, 3); } $query = "SELECT * FROM a1_postcodes2 WHERE postcode = '$postcode'"; // $query_post = $query; $result = mysql_query($query); $row = mysql_fetch_array($result); $latitude = $row['latitude']; $longitude = $row['longitude']; // $pieces = explode(" ", $postcode); // $outcode = $pieces[0]; // $query = "SELECT * FROM a1_postcode WHERE outcode = '$outcode'"; // $result = mysql_query($query); // $row = mysql_fetch_array($result); // $latitude = $row['lat']; // $longitude = $row['lon']; // GET NEAREST PHPPAGE * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // http://en.wikipedia.org/wiki/Haversine_formula // http://www.scribd.com/doc/2569355/Geo-Distance-Search-with-MySQL $radius_earth = 6371; $within_distance = 10; // find all towns within this distance (ordered by distance and limited to 1 result) $query = "SELECT *, $radius_earth * 2 * ASIN(SQRT( POWER(SIN(($latitude - abs(dest.lat)) * pi()/180 / 2),2) + COS($latitude * pi()/180 ) * COS(abs(dest.lat) * pi()/180) * POWER(SIN(($longitude - dest.lon) * pi()/180 / 2), 2) )) as distance FROM a1_towns dest having distance < $within_distance ORDER BY distance limit 1;"; // echo $query; $result = mysql_query($query); $row = mysql_fetch_array($result); $redirect = $row['phppage']; $townID = $row['ID']; // RECORD THE DATE AND TIME THE ACCOUNT WAS CREATED * * * * * * * * * * * * * * * * * * * * * // $dateCreated = date('Y-m-d H:i:s'); // STATUS * * * * * * * * * * * * * * * * * * * * * // $status_user = "y"; $status_master = "u"; $formsComplete = "n"; // CREDITS * * * * * * * * * * * * * * * * * * * * * // $credit_balance = "10"; $credit_system = "y"; // VERSION * * * * * * * * * * * * * * * * * * * * * // $version = "2"; $query = "INSERT INTO a1_member (username, password, establishment, lastname, firstname, email, phone, homepage, advert, address1, address2, town, county, postcode, latitude, longitude, townID, redirect, contactDetailsComplete, version, status_user, status_master, formsComplete, bba_link_verified, credit_efficiency, credit_system, credit_balance, credit_report, bookinglevel, thor_active, thor_code_verified, category, dateCreated) VALUES ('$username', '$hash', '$establishment', '$surname', '$firstname', '$est_email', '$phone', '$homepage', '$advert', '$address1', '$address2', '$town', '$county', '$postcode', '$latitude', '$longitude', '$townID', '$redirect', 'y', '2', 'y', 'u', 'n', 'n', '0.50', '$credit_system', '$credit_balance', 'new2', 'a', 'n', 'n', '$category', '$dateCreated')"; $result = mysql_query($query); $accountID = mysql_insert_id (); $mytable = strtolower($establishment); $mytable = str_replace($code_entities_match, $code_entities_replace, $mytable); $mytable = str_replace("-", "_", $mytable); $mytable = substr($mytable, 0, 20); $mytable = "bb_".$accountID."_".$mytable; $invoiceNumber = $accountID . "-001"; $taxPoint = date('Y-m-d H:i:s'); $query = "UPDATE a1_member SET mytable = '$mytable' WHERE username = '$username'"; $result = mysql_query($query); $tbl_record = $mytable."_record"; $query = "CREATE TABLE $tbl_record (ID mediumint(9) NOT NULL AUTO_INCREMENT PRIMARY KEY, clicktime datetime NOT NULL, type varchar(1) NOT NULL, who varchar(64) NOT NULL, user_agent VARCHAR(100) NOT NULL, referer VARCHAR(500) NOT NULL, refID varchar(10) NOT NULL, credits DECIMAL( 7, 2 ) NOT NULL);"; $result = mysql_query($query); $query = "INSERT INTO a5_bba_invoices (invoiceNumber, accountID, taxPoint, credits, amount, method) VALUES ('$invoiceNumber', '$accountID', '$taxPoint', '$credit_balance', '0', 'Complimentary')"; $result = mysql_query($query); // SEND WELCOME EMAIL * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // $query = "SELECT * FROM a4_email_templates WHERE templateKey = 'welcome_auto'"; $result = mysql_query($query); $row = mysql_fetch_array($result, MYSQL_ASSOC); $templateID = $row['ID']; $subject = $row['subject']; // $msg_text = $row['msg_text']; $msgbody = $row['msgBody']; $Bcc1 = $row['Bcc1']; $Bcc2 = $row['Bcc2']; $msgbody = str_replace("[TITLE]", $title, $msgbody); $msgbody = str_replace("[FIRSTNAME]", $firstname, $msgbody); $msgbody = str_replace("[SURNAME]", $surname, $msgbody); $msgbody = str_replace("[FIRSTNAME2]", $firstname2, $msgbody); $msgbody = str_replace("[SURNAME2]", $surname2, $msgbody); $msgbody = str_replace("[EMAIL]", $est_email, $msgbody); $msgbody = str_replace("[TOWN]", $town, $msgbody); $msgbody = str_replace("[PHPPAGE]", $redirect, $msgbody); $msgbody = str_replace("[ADVERT]", $advert, $msgbody); $msgbody = str_replace("[USERNAME]", $username, $msgbody); $msgbody = str_replace("[WEBSITE]", $website, $msgbody); $msgbody = str_replace("[MYTABLE]", $mytable, $msgbody); $msgbody = str_replace("[CREDIT_BALANCE]", $credit_balance, $msgbody); include "admin/email-htmltotext.php"; $plaintext = convert_html_to_text($msgbody); $boundary = uniqid('np'); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"" . $boundary . "\"\r\n"; $headers .= "From: THOR availability system " . "\r\n"; if ($Bcc1 != NULL){ $headers .= "Bcc: <$Bcc1>" . "\r\n"; } if ($Bcc2 != NULL){ $headers .= "Bcc: <$Bcc2>" . "\r\n"; } // SEND THE EMAIL * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // $emailUsername = "admin@bedbreakfastavailability.co.uk"; $emailPassword = "b3dbr34kf45t4v41l4b1l1ty"; $emailAddress = "admin@bedbreakfastavailability.co.uk"; $emailName = "Bed breakfast availability"; $emailAccess = "y"; if ($emailAccess == "y"){ set_include_path( '/home/companio/public_html/' . PATH_SEPARATOR . get_include_path() ); require_once ("Zend/Mail/Transport/Smtp.php"); require_once ("Zend/Mail.php"); $smtpServer = 'smtp.gmail.com'; // $username = 'internet.results.ltd@gmail.com'; // $password = 'int3rn3t'; $config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login', 'username' => $emailUsername, 'password' => $emailPassword); $transport = new Zend_Mail_Transport_Smtp($smtpServer, $config); $mail = new Zend_Mail(); // $mail->setFrom('admin@bedbreakfastavailability.co.uk', 'Bed Breakfast Availability'); // $mail->addTo($sendto, 'Some Recipient'); $mail->addTo($est_email); $mail->setSubject($subject); $mail->setBodyText($plaintext); $mail->setBodyHtml($msgbody); if ($Cc1 != NULL){ $mail->addBcc($Cc1); } if ($Cc2 != NULL){ $mail->addBcc($Cc2); } if ($Bcc1 != NULL){ $mail->addBcc($Bcc1); } if ($Bcc2 != NULL){ $mail->addBcc($Bcc2); } $mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only try { $mail->send($transport); } catch (Zend_Exception $e) { //echo "Caught exception: " . get_class($e) . "\n"; //echo "Message: " . $e->getMessage() . "\n"; $errorSending = "1"; // echo "errorSending: " . $errorSending; } // echo "errorSending" . $errorSending; } if ($emailAccess == "n" OR $errorSending == "1") { $boundary = uniqid('np'); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"" . $boundary . "\"\r\n"; $headers .= "From: Bed Breakfast Availability " . "\r\n"; if ($Cc1 != NULL){ $headers .= "Cc: <$Cc1>" . "\r\n"; } if ($Cc2 != NULL){ $headers .= "Cc: <$Cc2>" . "\r\n"; } if ($Bcc1 != NULL){ $headers .= "Bcc: <$Bcc1>" . "\r\n"; } if ($Bcc2 != NULL){ $headers .= "Bcc: <$Bcc2>" . "\r\n"; } mail($est_email, $subject, "\r\n\r\n--" . $boundary . "\r\n" . "Content-Type: text/plain; charset=\"utf-8\"\r\n\r\n" . $plaintext . "\r\n\r\n--" . $boundary . "\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n\r\n" . "\n\n" . "\n\n" . $msgbody . "" . "\r\n\r\n--" . $boundary . "--", $headers); } // LOG SENT EMAIL * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // $logTime = date('Y-m-d H:i:s'); $query = "INSERT INTO a4_email_log (accountID, logTime, templateID) VALUES ('$accountID', '$logTime', '$templateID')"; $result = mysql_query($query); // SEND US NOTIFICATION OF NEW SIGN UP * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // $notification_msg = "The following account needs to be approved or rejected: \n\nEstablishment: $establishment \rFirst name: $firstname \rLast name: $surname \rEmail: $est_email \n\n Do this in \"customer settings\" - master control panel - then send the standard \"welcome\" email"; // mail('ben@internet-results.ltd.uk', 'BedBreakfastAvailability sign up', $notification_msg, 'Cc: jaminbase@gmail.com'); mail('ben@internet-results.ltd.uk', 'Bed Breakfast Availability sign up', $notification_msg); // LOG THEM IN * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // $secret_word = 'hou5e mu5ic'; setcookie('login',$username.','.md5($username.$secret_word),time( ) + (60 * 60 * 24 * 7), '/account/'); // echo "all good"; header("Location: http://www.bedbreakfastavailability.co.uk/account/"); } } // include "library/read_cookie.php"; ?> Advertise your B&B, hotel or self-catering accommodation
Bed & Breakfast Availability
20 $town bed and breakfasts"; // echo "

15 $town hotels

"; // echo "

5 $town guest houses

"; // echo "

3 $town self-catering accommodation

"; ?>

Bed and breakfast availability
b&b, guesthouse and hotel accommodation

Advertise your accommodation

Advertise on BedBreakfastAvailability.co.uk

'; ?>