It is now $timenow.

"); */ $daytoday = strftime("%a",$time); $daytoday = tr($daytoday,"A-Z","a-z"); if(exists($referring_url)) { /*echo("HERE $referring_url");*/ } $sock = msqlConnect(); if ($sock < 0) { fatal("Error : $ERRMSG\n"); } if (msqlSelectDB($sock,"take-away") < 0) { fatal("Error : $ERRMSG\n"); } if ($captcha_value == "") { echo("

You have not entered the characters shown in the image - this is a security measure. Please use your browser's back button to go back and enter these characters."); } else { $query = "select image_name, letters from captcha where image_name = '$file_name'"; if (msqlQuery($sock, $query) < 0) { fatal("Error : $ERRMSG\n"); } $res = msqlStoreResult(); $num_rows = msqlNumRows($res); if ($num_rows < 1) { echo("

The characters you typed are incorrect. |$row[0]|$row[1]|$file_name| Please use your browser's back button to go back and correct."); msqlFreeResult($res); } else { $row = msqlFetchRow($res); msqlFreeResult($res); $captcha_value= tr($captcha_value,"a-z","A-Z"); if ($captcha_value != $row[1]) { echo("

The characters you typed $captcha_value are incorrect. |$row[0]|$row[1]|$file_name| Please use your browser's back button to go back and correct."); } else { $query = "select distinct postcode from postcodes_lat_lon where postcode='$postcode'"; if (msqlQuery($sock, $query) < 0) { fatal("Error : $ERRMSG\n"); } $res = msqlStoreResult(); $num_rows = msqlNumRows($res); msqlFreeResult($res); if ($num_rows < 1) { echo("

This postcode is not on file.
$postcode
If you have made a mistake use your browser's back button to go back and correct. If you are in a new suburb
click here."); } else { $query = "select distinct city_suburb from postcodes_lat_lon where city_suburb clike '$city_suburb'"; if (msqlQuery($sock, $query) < 0) { fatal("Error : $ERRMSG\n"); } $res = msqlStoreResult(); $num_rows = msqlNumRows($res); msqlFreeResult($res); if ($num_rows < 1) { echo("

This city/suburb is not on file.
$city_suburb
If you have made a mistake use your browser's back button to go back and correct. If you are in a new suburb
click here."); } else { $query = "select distinct postcode, city_suburb, state from postcodes_lat_lon where postcode='$postcode' and city_suburb clike '$city_suburb' and state='$state'"; if (msqlQuery($sock, $query) < 0) { fatal("Error : $ERRMSG\n"); } $res = msqlStoreResult(); $num_rows = msqlNumRows($res); msqlFreeResult($res); if ($num_rows < 1) { echo("

This city/suburb
$city_suburb
does not relate to the postcode $postcode.
OR
You have not chosen the correct state -
$state
Use your browser's back button to go back and correct."); } else { $emailaddress_array = split($emailaddress,"@"); $domain = $emailaddress_array[1]; $result = system("dig MX $domain | grep 'ANSWER SECTION' > /dev/null"); if($result != 0) { echo("

This is not a valid email address.
$emailaddress
If you have made a mistake use your browser's back button to go back and correct."); } else { $query ="select last_name, emailaddress from take_away_customers where last_name clike '$last_name' and emailaddress clike '$emailaddress'"; if (msqlQuery($sock, $query) < 0) { fatal("Error checking for duplicates: $ERRMSG\n"); } $res = msqlStoreResult(); $num_rows = msqlNumRows($res); msqlFreeResult($res); if ($num_rows < 1) { echo("

Thank You - Please wait a moment

"); $query = "select _seq from take_away_customers"; if (msqlQuery($sock, $query) < 0) { fatal("Error : $ERRMSG\n"); } $res = msqlStoreResult(); $row = msqlFetchRow($res); $record_no = (int)$row[0]; msqlFreeResult($res); $query = "select _sysdate from take_away_customers"; if (msqlQuery($sock, $query) < 0) { fatal("Error : $ERRMSG\n"); } $res = msqlStoreResult(); $row = msqlFetchRow($res); $creation_date = $row[0]; $update_date = $row[0]; $account_flag ="N"; $cred_card = ""; $card_name = ""; $card_exp_date = ""; $card_verification_code =""; $loyalty_flag = "N"; msqlFreeResult($res); $unique_flag = "N"; while($unique_flag == "N") { srandom($time); $cust_id = random(); $query = "select cust_id from take_away_customers where cust_id = '$cust_id'"; if (msqlQuery($sock, $query) < 0) { fatal("Error selecting cust_id: $ERRMSG\n"); } $res = msqlStoreResult(); $num_rows = msqlNumRows($res); msqlFreeResult($res); if ($num_rows > 1) { system("echo Duplicate cust_id $cust_id | mail -s'Duplicate cust_id' brad@austbiz.com.au"); } if ($num_rows < 1) { $unique_flag = "Y"; } } $first_name = tr($first_name,"a-z","A-Z"); $last_name = tr($last_name,"a-z","A-Z"); $stno_name = tr($stno_name,"a-z","A-Z"); $city_suburb = tr($city_suburb,"a-z","A-Z"); $emailaddress = tr($emailaddress,"A-Z","a-z"); if(msqlQuery($sock,"insert into take_away_customers values ($record_no,'$cust_id','$creation_date','$update_date','$first_name','$last_name','$stno_name','$city_suburb','$state','$postcode','$phone_no','$mobile_no','$emailaddress','$account_flag','$cred_card','$card_name','$card_exp_date','$card_verification_code','loyalty_flag')") < 0) { fatal("Error : $ERRMSG\n"); } $tmpfile = "/usr/local/apache2.2/htdocs/take-away/tmp/$cust_id.txt"; $fd = open("$tmpfile", ">"); if($fd < 0) { system("echo 'Cannot create temp file $tmpfile' | mail -s'create_customer.html error' brad@austbiz.com.au"); } else { fprintf($fd,"From: register@take-away.com.au\n"); fprintf($fd,"To: $emailaddress\n"); fprintf($fd,"Bcc: bradhill@bigpond.net.au\n"); fprintf($fd,"Subject: take-away.com.au online ordering registration\n"); fprintf($fd,"Content-Type:text/html; iso-8859-1\n"); fprintf($fd,"Content-Transfer-Encoding: 8bit\n"); fprintf($fd,"\n"); fprintf($fd,"take-away.com.au\n"); fprintf($fd,"You may need to click Load Images in your browser to see the images.
"); fprintf($fd,"
"); fprintf($fd,"

Hi $first_name. Thank you for registering with take-away.com.au

"); fprintf($fd,"Your customer i.d. is $cust_id

"); fprintf($fd,"Please write down your customer i.d. or print this page and keep in a secure place for future reference.

"); fprintf($fd,"You can cut and paste this i.d. number into the ordering page of any participating take-away
"); fprintf($fd,"restaurant in your region.

"); fprintf($fd,"Please check that the details you entered on the registration form are correct:

"); fprintf($fd,"First Name:$first_name
"); fprintf($fd,"Last Name:$last_name
"); fprintf($fd,"Street number and name:$stno_name
"); fprintf($fd,"City/Suburb:$city_suburb
"); fprintf($fd,"State:$state
"); fprintf($fd,"Postcode:$postcode
"); fprintf($fd,"Home phone number:$phone_no
"); fprintf($fd,"Mobile phone number:$mobile_no

"); fprintf($fd,"If any of the above are incorrect please reply to this email with the correct information.

"); fprintf($fd,"From time to time participating take-away shops that are in your local area would like to email you with
"); fprintf($fd,"specials, deals or menu changes. You may also be eligible for any loyalty programs that they have.

"); fprintf($fd,"If you don't want to receive any email notification of deals, specials, menu changes or loyalty programs
"); fprintf($fd,"please reply to this email with the words 'NO EMAIL THANKS' in the subject line.

"); fprintf($fd,"Thanks again for registering with take-away.com.au

"); fprintf($fd,"To see participating restaurants in your region $postcode Click here.

"); fprintf($fd,""); close($fd); system("cat $tmpfile | sendmail -t&"); if($referring_url <> "") { echo("You are now being returned to $referring_url - Please wait"); sleep(2); echo(""); } else { echo("Thank you for registering with take-away.com.au
An email is being sent to you now with your customer i.d.
You can cut and paste or type this customer i.d into
the website of any participating take-away restaurant in your region.

"); } } } else { echo("

This customer $first_name $last_name exists.
If you think that there is a problem
please send an email to advising of the problem.

"); } } } } } } } } /*echo("HERE $first_name $last_name $stno_name $city_suburb $state $postcode $mobile_no $phone_no $emailaddress $_sysdate");*/ >