<!-- Start define code -->
<?php

//define a maxim size for the uploaded images in Kb
define ("MAX_SIZE","10000"); 

//This function reads the extension of the file. It is used to determine if the file  is an image by checking the extension.

function getExtension($str) {

$i = strrpos($str,".");

if (!$i) { return ""; }

$l = strlen($str) - $i;

$ext = substr($str,$i+1,$l);

return $ext;
}

//This variable is used as a flag. The value is initialized with 0 (meaning no  error  found) and it will be changed to 1 if an errro occures. If the error occures the file will not be uploaded.

$errors=0;

//Reads the name of the file the user submitted for uploading

$image=$_FILES['image']['name'];

//If it is not empty

if ($image) 

{

//get the original name of the file from the clients machine

$filename = stripslashes($_FILES['image']['name']);

//get the extension of the file in a lower case format

$extension = getExtension($filename);

$extension = strtolower($extension);

//if it is not a known extension, we will suppose it is an error and 

// will not  upload the file,  

//otherwise we will do more tests

if (($extension != "jpg") && ($extension != "jpeg") && ($extension !=

"png") && ($extension != "gif")) 

{

//print error message

	echo '<h1>Unknown extension!</h1>';

	$errors=1;

}

else

{

//get the size of the image in bytes

//$_FILES['image']['tmp_name'] is the temporary filename of the file in which the uploaded file was stored on the server

$size=filesize($_FILES['image']['tmp_name']);

//compare the size with the maxim size we defined and print error if bigger

if ($size > MAX_SIZE*4096)

{

echo '<h1>You have exceeded the size limit!</h1>';

$errors=1;

}

//we will give an unique name, for example the time in unix time format

$image_name=time().'.'.$extension;

//the stor name will be containing the full path where will be stored (images folder)

$storname="uploads/".$image_name;

//the new name will be containing the name of the image only (for display purposes on form)

$newname=$image_name;

//we verify if the image has been uploaded, and print error instead

$copied = copy($_FILES['image']['tmp_name'], $storname);

if (!$copied) 

{

echo '<h1>Copy unsuccessfull!</h1>';

$errors=1;

}}}

//If no errors registred, print the success message

if(isset($_POST['Submit']) && !$errors) 

{

echo "<h1>File Uploaded Successfully! Try again!</h1>";

}

?>
<!-- End define code -->
<!-- No idea what this is -->
<?php
   $racelocation = $_POST['racelocation'];

   $logo = $_POST['logo'];

   $background = $_POST['background'];

   $imageopt = $_POST['imageopt'];

   $line1 = $_POST['line1'];

   $line2 = $_POST['line2'];

?>
<!-- No idea what this is -->
<!-- Start header -->
<?php include 'header.php'; ?>
<!-- End header -->

<div id="main">
  <div id="example">
    <div id="rightcol">
      <div id="orderpreview">
        <h3>Custom Memory Preview</h3>
      </div>
      
      <!-- start stripe preview -->
      <div id="stripepreview"> 
        <!-- affiliate logo -->
        <div id="imagedest2">
          <?php
        if($logo == "race_dallas"){
        
            echo "<img src=\"images/web/race_dallas.png\">";
        
        } elseif($logo == "race_denver"){
        
            echo "<img src=\"images/web/race_denver.png\">";
        
        }else {
        
            echo "looks like you forgot to choose a logo";
        
        }
        ?>
        </div>
        <!-- affiliate logo --> 
        <!-- custom image section -->
        <div id="imagedest1">
          <?php
        
        if($imageopt == "custom"){
        
            echo "<img src=\"$storname\" height='357'>";	
        
        } elseif($imageopt == "race"){
        
            echo "<img src=\"images/web/Race.png\">";		
        
        }else {
        
            echo "<img src=\"images/web/Race.png\">";
        
        }
        ?>
        </div>
        <!-- custom image section --> 
        <!-- background -->
        <div id="imagedest">
          <?php
        
        if($background == "pink"){
        
            echo "<img src=\"images/web/pink.png\">";
        
        } elseif($background == "white"){
        
            echo "<img src=\"images/web/white.png\">";
        
        } elseif($background == "blank"){
        
            echo "<img src=\"images/web/blank.png\">";	
        
        }else {
        
            echo "looks like you forgot to choose a background";
        
        }
        ?>
        </div>
        <!-- background --> 
        <!-- custom lines -->
        <div id="customtxt"> <span id="line1"><?php echo $line1; ?></span><br />
          <span id="line2"><?php echo $line2; ?></span><br />
        </div>
        <!-- custom lines --> 
      </div>
      <!-- end stripe preview --> 
      
      <!--
<div id="editstripe">
<p><a href="javascript:" onclick="history.go(-1); return false">Edit Your Stripe</a></p>
</div>
--> 
    </div>
  </div>
  <form name="contactform" method="post" action="form_email.php">
    <div id="options">
      <div id="orderorderform"> <br />
        <h3>Order Form</h3>
        <h4>Billing Information</h4>
        <p><strong><em>Note: The stripes will be shipped directly to your Race Headquarters and installed by the Race Committee.</em></strong></p>
      </div>
      <div id="leftcolopt">
        <ul>
          <li>
            <label for="first_name">First Name *</label>
            <input  type="text" name="first_name" maxlength="50" size="25">
          </li>
          <li>
            <label for="last_name">Last Name *</label>
            <input  type="text" name="last_name" maxlength="50" size="25">
          </li>
          <li>
            <label for="email">Email Address *</label>
            <input  type="text" name="email" maxlength="50" size="25">
          </li>
          <li>
            <label for="telephone">Telephone Number</label>
            <input  type="text" name="telephone" maxlength="50" size="25">
          </li>
        </ul>
      </div>
      <div id="middlcolopt">
        <ul>
          <li>
            <label for="address">Street Address</label>
            <input  type="text" name="address" maxlength="50" size="25">
          </li>
          <li>
            <label for="city">City</label>
            <input  type="text" name="city" maxlength="50" size="25">
          </li>
          <li>
            <label for="state">State</label>
            <input  type="text" name="state" maxlength="50" size="25">
          </li>
          <li>
            <label for="zip">Zip Code</label>
            <input  type="text" name="zip" maxlength="50" size="25">
          </li>
        </ul>
      </div>
      <div id="rightcolopt">
        <ul>
          <li>
            <label for="race_location">Race Location</label>
            <input  type="text" name="race_location" maxlength="50" size="25">
          </li>
          <li>
            <label for="background">Stripe Background Color</label>
            <input name="background"  type="text" id="background" value="<?php echo $background; ?>" maxlength="50" size="25" readonly="readonly">
          </li>
          <li>
            <label for="line1">Line 1 Text</label>
            <input name="line1"  type="text" id="line1" value="<?php echo strip_tags($line1) ?>" maxlength="50" size="5" readonly="readonly">
          </li>
          <li>
            <label for="line2">Line 2 Text</label>
            <input name="line2"  type="text" id="line2" value="<?php echo strip_tags($line2) ?>" maxlength="50" size="5" readonly="readonly">
          </li>
          <li>
            <label for="imageopt">Custom Image</label>
            <input name="imageopt"  type="text" id="customimg" value="<?php echo $newname; ?>" maxlength="50" size="25" readonly="readonly">
          </li>
        </ul>
      </div>
      <div id="leftcolopt">
        <input type="image" src="images/buynow.png "style="width:200px" value="Submit">
      </div>
    </div>
  </form>
</div>
<!-- Start footer -->
<?php include 'footer.php'; ?>
<!-- End footer -->
