GNU   davin.50webs.com/research
Bringing to you notes for the ages

       Main Menu          Research Projects         Photo Album            Curriculum Vitae      The Greatest Artists
    Email Address       Computer Games          Web Design          Java Training Wheels      The Fly (A Story)   
  Political Activism   Scruff the Cat       My Life Story          Smoking Cessation          Other Links      
Debugging Macros     String Class I     Linked List System I Java for C Programmers Naming Convention
    String Class II         How I use m4              Strings III                 Symmetrical I/O             Linked Lists II     
Run-Time Type Info   Virtual Methods      An Array System        Science & Religion            Submodes       
  Nested Packages      Memory Leaks    Garbage Collection      Internet & Poverty      What is Knowledge?
Limits of Evolution   Emacs Additions      Function Plotter           Romantic Love        The Next Big Thing
    Science Fiction     Faster Compilation Theory of Morality         Elisp Scoping               Elisp Advice      
  S.O.G.M. Pattern       Safe Properties         School Bullying          Charisma Control          Life and Death    
     Splitting Java          Multiple Ctors       Religious Beliefs         Conversation 1           Conversation 2    
   J.T.W. Language    Emacs Additions II      Build Counter             Relation Plotter          Lisp++ Language  
  Memory Leaks II   Super Constructors CRUD Implementation Order a Website Form There Is An Afterlife
More Occam's Razor C to Java Translator Theory of Morality II


order-a-website.php

    
<?php
/*
   @package Order A Website
   @version 1.0

Plugin URL: http://davin.50webs.com/research/2014/aoawf.html
   Author: Davin Pearson
   Author URL: <http://davin.50webs.com>

LIMITATION OF WARRANTY:

This file is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published
   by the Free Software Foundation; either version 2, or (at your
   option) any later version.

This file is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

You should have received a copy of the GNU General Public License
   along with this software, see the file COPYING.  If not, see:

<http://www.gnu.org/licenses/gpl-3.0.txt>.

*/

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 = eval("ls -l");
      //echo h1("eval(\"ls\")=$result");
      //echo h1ok("Entered Schmu");
      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");
            //exit();
         }
         $size = $_FILES[$file_id]['size'];
         if ($size > 1024 * 1024)
         {
            echo h1error("Error #2: File size of \"$name\" cannot exceed 1 MB");
            //exit();
         }
         $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");
            //exit();
         }
         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']);
            //exit();
         }
         else
         {
            //echo "Upload: "    . $_FILES[$file_id]['name'] . "<br\n>";
            //echo "Type: "      . $_FILES[$file_id]["type"] . "<br\n>";
            //echo "Size: "      . ($_FILES[$file_id]["size"] / 1024) . " kB<br>";
            //echo "Temp file: " . $_FILES[$file_id]["tmp_name"] . "<br\n>";
            if (!file_exists("upload"))
            {
               mkdir("upload");
               echo h1ok("Created folder upload");
            }
            $newdir = "upload/" . $datestamp;
            if (!file_exists($newdir))
            {
               //echo h1("Creating new folder $newdir");
               mkdir($newdir);
               echo h1("Created new folder $newdir");
            }
            $newfile = $newdir . "/" . $name;
            if (file_exists($newfile))
            {
               echo h1error("Error #5: File \"$newfile\" already exists");
               //echo h1("This error should never happen");
               //exit();
            }
            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');

?>
Back
| Main Menu | Research Projects | Photo Album | Curriculum Vitae | The Greatest Artists |
| Email Address | Computer Games | Web Design | Java Training Wheels | The Fly (A Story) |
| Political Activism | Scruff the Cat | My Life Story | Smoking Cessation | Other Links |
| Debugging Macros | String Class I | Linked List System I | Java for C Programmers | Naming Convention |
| String Class II | How I use m4 | Strings III | Symmetrical I/O | Linked Lists II |
| Run-Time Type Info | Virtual Methods | An Array System | Science & Religion | Submodes |
| Nested Packages | Memory Leaks | Garbage Collection | Internet & Poverty | What is Knowledge? |
| Limits of Evolution | Emacs Additions | Function Plotter | Romantic Love | The Next Big Thing |
| Science Fiction | Faster Compilation | Theory of Morality | Elisp Scoping | Elisp Advice |
| S.O.G.M. Pattern | Safe Properties | School Bullying | Charisma Control | Life and Death |
| Splitting Java | Multiple Ctors | Religious Beliefs | Conversation 1 | Conversation 2 |
| J.T.W. Language | Emacs Additions II | Build Counter | Relation Plotter | Lisp++ Language |
| Memory Leaks II | Super Constructors | CRUD Implementation | Order a Website Form | There Is An Afterlife |
| More Occam's Razor | C to Java Translator | Theory of Morality II
Last modified: Sun Sep 25 16:11:12 NZDT 2016
Best viewed at 800x600 or above resolution.
© Copyright 1999-2016 Davin Pearson.
Please report any broken links to