<?php
@package@version
require_once dirname(__FILE__) . "/CRUD-functions.php";
require_once dirname(__FILE__) . "/order-a-website-functions.php";
$datestamp = date("Ymd-His");
function order_a_website($arg)
{
global $datestamp;
echo $arg;
$page_id = $_REQUEST['page_id'];
if ($page_id == 6)
{
$result h1$result h1ok order_a_website_function();
------------------------------------------------------------- $fname = $_REQUEST['fname'];
$lname = $_REQUEST['lname'];
$email = $_REQUEST['email'];
$landline_number = $_REQUEST['landline_number'];
$mobile_number = $_REQUEST['mobile_number'];
$dob = $_REQUEST['dob'];
$title = $_REQUEST['title'];
$slogan = $_REQUEST['slogan'];
$message1 = $_REQUEST['message1'];
$title2 = $_REQUEST['title2'];
$message2 = $_REQUEST['message2'];
$title3 = $_REQUEST['title3'];
$message3 = $_REQUEST['message3'];
$title4 = $_REQUEST['title4'];
$message4 = $_REQUEST['message4'];
$title5 = $_REQUEST['title5'];
$message5 = $_REQUEST['message5'];
------------------------------------------------------------- if (($fname != "") AND ($lname != "") AND ($email != "") AND ($title != "") AND ($message1 != ""))
{
$mailBody = ""
. "order_date=$datestamp\n"
. "fname=$fname\n"
. "lname=$lname\n"
. "email=$email\n"
. "landline_number=$landline_number\n"
. "mobile_number=$mobile_number\n"
. "dob=$dob\n"
. "title=$title\n"
. "slogan=$slogan\n"
. "message1=\n$message1\n"
. "title2=$title2\n"
. "message2=\n$message2\n"
. "title3=$title3\n"
. "message3=\n$message3\n"
. "title4=$title4\n"
. "message4=\n$message4\n"
. "title5=$title5\n"
. "message5=\n$message5\n";
$mailSent = mail("sales" . "@" . "davinpearson.com", "Order for a website for $email", $mailBody);
if ($mailSent)
{
echo "<h2>Mail sent. Thank you for your feedback.</h2>";
echo "<h2>Please allow 5 working days for the website to be put online.</h2>";
}
else
{
echo "<h2>Error sending email message. Please try again.</h2>\n";
}
echo "<h2>For your convenience, here is the message body:</h2>\n";
echo "<pre>";
echo $mailBody;
echo "</pre>";
echo "<br>";
test_file("inputfile1");
test_file("inputfile2");
test_file("inputfile3");
test_file("inputfile4");
test_file("inputfile5");
test_file("inputfile6");
test_file("inputfile7");
test_file("inputfile8");
test_file("inputfile9");
test_file("inputfile10");
test_file("inputfile11");
test_file("inputfile12");
test_file("inputfile13");
test_file("inputfile14");
test_file("inputfile15");
test_file("inputfile16");
test_file("inputfile17");
echo '<div class="heading">Here is the same form back again</div>';
}
echo "<h2>NOTE: Required fields are marked with a <font color=red>*</font></h2>";
echo '<form name="myForm" onsubmit="return validateForm();" method="post" enctype="multipart/form-data">
<input type="hidden" name="page_id" value="';
echo $page_id;
echo '"><br>
First Name:<font color=red>*</font><br><input type="text" name="fname" size="76"><br>
Last Name:<font color=red>*</font><br><input type="text" name="lname" size="76"><br>
Email Address:<font color=red>*</font><br><input type="text" name="email" size="76"><br>
Landline Phone Number: <br><input type="text" name="landline_number" size="40"><br>
Mobile Phone Number: <br><input type="text" name="mobile_number" size="40"><br>
<h2>NOTE: your email address, date of birth and phone numbers will not be published on the web. </h2>
Date of Birth: (YYYY/MM/DD)<br><input type="text" name="dob" size="40"><br>
<br>
<div class="heading">Page 1 of your website</div>
Enter the title of your website here:<font color=red>*</font><br><input type="text" name="title" size="76"><br>
Enter the slogan of your website here:<br><input type="text" name="slogan" size="76"><br>
Enter the first page of your website here:<font color=red>*</font>:<br>
<textarea name="message1" rows="12" cols="80" wrap="virtual"></textarea>
Select up to five image files for the first page of your website to upload:<br>
<h2>NOTE: The size of each file cannot exceed 1MB</h2>
<input type="file" name="inputfile1" size="40"><br>
<input type="file" name="inputfile2" size="40"><br>
<input type="file" name="inputfile3" size="40"><br>
<input type="file" name="inputfile4" size="40"><br>
<input type="file" name="inputfile5" size="40"><br>
<br>
<div class="heading">Page 2 of your website</div>
Enter the title of the second page of your website here:<br><input type="text" name="title2" size="76"><br>
Enter the second page of your website here:<br>
<textarea name="message2" rows="12" cols="80" wrap="virtual"></textarea>
Select up to three image files for the second page of your website to upload:<br>
<input type="file" name="inputfile6" size="40"><br>
<input type="file" name="inputfile7" size="40"><br>
<input type="file" name="inputfile8" size="40"><br>
<br>
<div class="heading">Page 3 of your website</div>
Enter the title of the third page of your website here:<br><input type="text" name="title3" size="76"><br>
Enter the third page of your website here:<br>
<textarea name="message3" rows="12" cols="80" wrap="virtual"></textarea>
Select up to three image files for the third page of your website to upload:<br>
<input type="file" name="inputfile9" size="40"><br>
<input type="file" name="inputfile10" size="40"><br>
<input type="file" name="inputfile11" size="40"><br>
<br>
<div class="heading">Page 4 of your website</div>
Enter the title of the fourth page of your website here:<br><input type="text" name="title4" size="76"><br>
Enter the fourth page of your website here:<br>
<textarea name="message4" rows="12" cols="80" wrap="virtual"></textarea>
Select up to three image files for the fourth page of your website to upload:<br>
<input type="file" name="inputfile12" size="40"><br>
<input type="file" name="inputfile13" size="40"><br>
<input type="file" name="inputfile14" size="40"><br>
<br>
<div class="heading">Page 5 of your website</div>
Enter the title of the fifth page of your website here:<br><input type="text" name="title5" size="76"><br>
Enter the fifth page of your website here:<br>
<textarea name="message5" rows="12" cols="80" wrap="virtual"></textarea>
Select up to three image files for the fifth page of your website to upload:<br>
<input type="file" name="inputfile15" size="40"><br>
<input type="file" name="inputfile16" size="40"><br>
<input type="file" name="inputfile17" size="40"><br>
<br>
<div class="heading">All done!</div>
<div class="left">
<input type="submit" value="Order a Website Now!">
</div>
<div class="right">
<input type="reset" value="Reset form"><br>
</div>
<br>
Please allow 5 working days for the website to be put online.
</form>
';
}
}
function test_file($file_id)
{
global $datestamp;
if (isset($_FILES[$file_id]['name']))
{
if ($_FILES[$file_id]['name'] != "")
{
$name = $_FILES[$file_id]['name'];
$type = $_FILES[$file_id]['type'];
assert$type if (($type != "") && ($type != "image/gif") && ($type != "image/jpeg") && ($type != "image/jpg") && ($type != "image/pjpeg") && ($type != "image/x-png") && ($type != "image/png"))
{
echo h1error("Error #1: File type of \"$name\" must be one of GIF, JPEG, JPG or PNG");
echo h1("type=$type");
}
$size = $_FILES[$file_id]['size'];
if ($size > 1024 * 1024)
{
echo h1error("Error #2: File size of \"$name\" cannot exceed 1 MB");
}
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".",$name);
$extension = end($temp);
if (!in_array($extension, $allowedExts))
{
echo h1error("Error #3: File extension of \"$name\"must be one of *.gif, *.jpeg, *.jpg or *.png");
}
if ($_FILES[$file_id]['error'] > 0)
{
echo h1error("Error #4: An error has occurred for file \"$name\"");
echo h1("Return Code: " . $_FILES[$file_id]['error']);
}
else
{
$_FILES$file_id $_FILES$file_id $_FILES$file_id $_FILES$file_id if (!file_exists("upload"))
{
mkdir("upload");
echo h1ok("Created folder upload");
}
$newdir = "upload/" . $datestamp;
if (!file_exists($newdir))
{
h1$newdir mkdir($newdir);
echo h1("Created new folder $newdir");
}
$newfile = $newdir . "/" . $name;
if (file_exists($newfile))
{
echo h1error("Error #5: File \"$newfile\" already exists");
h1 }
else
{
move_uploaded_file($_FILES[$file_id]["tmp_name"] , $newfile);
echo h1ok("File upload of \"$newfile\" was successful");
}
}
}
}
}
add_action('the_content','order_a_website');
?>