"; print_r($_FILES['attachment']['error'] == 0 && isset($_FILES['attachment']['name'])); */ if(isset($_FILES['attachment']['name']) && $_FILES['attachment']['error'] == 0) { $kb = 1024; $mb = $kb * $kb; $maxfilesize = 10 * $mb; //max 10 MB file // Where the file is going to be placed $filename = $_FILES['attachment']['name']; // Get the name of the file (including file extension). /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $newfilename = $tsup . str_replace(" ","_",basename($filename)); $upload_path .= $newfilename; $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); //print "size of " . $_FILES['attachment']['tmp_name'] . " is " . filesize($_FILES['attachment']['tmp_name']) . ". Moving to $upload_path.

"; if((filesize($_FILES['attachment']['tmp_name']) <= $maxfilesize) && move_uploaded_file($_FILES['attachment']['tmp_name'], $upload_path)) { $_POST['attachment'] = $newfilename; process_inputs($newfilename); }//end if filesize is ok and moved else { $messages .= "Your request was NOT submitted. The file you selected for upload failed. Be sure that it is less than 10MB. Click the Back button of your browser and try again.
"; }//end else filesize is not ok or not moved }//end if file to upload else { process_inputs(); }//end else no file, so just process form }//end if submit button clicked && valid captcha //invalid captcha else if(isset($_POST['submitbutton'])) $messages .= "You entered the incorrect characters in the CAPTCHA text box. Please click the browser's back button and if the letters haven't changed you may need to refresh the page and ensure that everything is still filled out properly. Please be sure to use all capital letters and numbers for the CAPTCHA.
"; //this function will process the inputs submitted by the user function process_inputs($newfilename = "") { global $messages, $request_path, $requestname, $adminemails, $adminurl, $fromaddr, $upload_path, $eldlab, $eldcoordemails; $fp = fopen ("$request_path$requestname", "w"); if(!$fp) $messages .= "Your request was NOT submitted. There was a problem completing your request. Click the Back button of your browser and try again.
"; else { fwrite($fp, " $value) { if($key == "confirm" || $key == "submitbutton" || preg_match("/date/i",$key) > 0 || preg_match("/period/i",$key) > 0 || ($key == "attachment" && $value == "")){} //ignore confirm checkbox, submit, start/end date, and periods //selections and apps else if(is_array($value)) { fwrite($fp, "\$data['$key'] = array();\n"); for($i = 0; $i < count($value); $i++) { fwrite($fp, "\$data['$key']['" . $value[$i] . "'] = \"" . addslashes($value[$i]) . "\";\n"); }//end for each element in array fwrite($fp, "\n"); }//end else if array input else { $value = addslashes($value); fwrite($fp, "\$data['$key'] = \"$value\";\n"); }//end else a normal scalar }//end for each item in $_POST $messages .= "Your lab request has been submitted for approval and processing.
"; fwrite($fp, "?>"); fclose($fp); $premsg = "Thank you for your lab submission. You will receive an email when your request has been processed.\n\n***********************************************************\n\n"; $msg = ""; $_POST['attachment'] = isset($_FILES['attachment']['name']) ? $_FILES['attachment']['name'] : ""; foreach($_POST as $key => $value) { if($key == "confirm" || $key == "submitbutton" || preg_match("/date/i",$key) > 0 || preg_match("/period/i",$key) > 0 || ($key == "attachment" && $value == "")){} //ignore confirm checkbox, submit, start/end date, and periods //selections and apps else if(is_array($value)) { $msg .= "$key:\n"; for($i = 0; $i < count($value); $i++) { $msg .= $value[$i] . "\n"; }//end for each element in array $msg .= "\n"; }//end else if array input else { $msg .= "$key: $value\n"; }//end else a normal scalar }//end for each item in $_POST $msg = stripslashes($msg); $premsg .= $msg; $file_size = filesize($upload_path); $handle = fopen($upload_path, "r"); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: $fromaddr\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-type:text/plain; charset=iso-8859-1\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= $premsg."\r\n\r\n"; $header .= "--".$uid."--"; //attachment if(isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != "") { $header .= "\r\nContent-Type: " . $_FILES['attachment']['type'] . "; name=\"".$_FILES['attachment']['name']."\"\r\n"; // use different content types here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=\"".$_FILES['attachment']['name']."\"\r\n\r\n"; $header .= $content."\r\n\r\n"; $header .= "--".$uid."--"; }//end if attachment $success = mail($_POST['email'], "Lab Request Confirmation" , "" , $header); /* print "LOGGING TO $uid"."request.log
"; $fp = fopen("$uid"."request.log","w"); fwrite($fp, $header); fclose($fp); */ //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" if($success) $messages .= "You should receive a confirmation email shortly.
"; else $messages .= "The confirmation was unable to send. Please contact $adminemails and notify them.
"; //now we send out the admin emails $msg = preg_replace("/attachment: ".$_FILES['attachment']['name'] . "/is","attachment: $newfilename",$msg); $premsg = "A new lab request has been submitted.\n\nVisit $adminurl?file=$requestname to process this request.\nVisit $adminurl to view all requests.\n\n***********************************************************\n\n"; $premsg .= $msg; $header = "From: $fromaddr\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-type:text/plain; charset=iso-8859-1\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= $premsg."\r\n\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-Type: " . $_FILES['attachment']['type'] . "; name=\"$newfilename\"\r\n"; // use different content types here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=\"$newfilename\"\r\n\r\n"; $header .= $content."\r\n\r\n"; $header .= "--".$uid."--"; if($_POST['platform'] == $eldlab) $adminemails .= ",$eldcoordemails"; $success = mail($adminemails, "New Lab Request Submitted" , "" , $header); /* print "LOGGING TO $uid"."request.log
"; $fp = fopen("$uid"."AdminRequest.log","w"); fwrite($fp, $header); fclose($fp); */ //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" if($success) $messages .= "A notification email has been sent to the admins for processing.
"; else $messages .= "Unable to send admin notification email. Please contact $adminemails directly to notify them of your request.
"; }//end else opened request file for write }//end function process_inputs ?> Lab Request

Computer Lab/Cart Request Form



Allow at least 48 hours for processing & booking!
Watch this tutorial for help filling out this form & know what to expect.
Computer Lab Request Form Tutorial
Warning: Refreshing the page will cause some populated fields to be cleared

*Teacher's Name:             *Teacher's Email:
Usage/Project Outcome
If any of the below are included sufficiently in your attached file, please write "See attached" in each of those fields.
*Project Outcome/Objective:
*Standards:
*Project Description:

Attach a File:

To avoid scheduling conflicts, visit the master lab calendar first.

Start: select    to   End: select
Periods: $value) { print " $key"; }//end foreach period }//end if only an All Day option else //multiple periods { $first = true; foreach($periodTimes as $key => $value) { if($first) $first = false; else print ", "; print " $key"; }//end foreach period }//end else multiple periods ?>


*
Lab Specifications
*Platform Preference: $text) { print " $text "; }//end foreach platform preference ?>
*Applications to be used: $text) { print " $text "; }//end foreach platform preference ?>
Other:
*TA Duties/Expectations (enter N/A if requesting a cart):
Other Instructions/Requests:
Agreement
* I have read and signed the Computer Labs Protocol. I understand my duties and the expectation of lab usage. Seating charts are ready to be filed upon arrival.
Please type the characters shown into the box below using all CAPITAL letters.






Copyright Jason Karuza 2010