Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy
Agenda Assignment recap Assignment recap File upload File upload Directory functions Directory functions MyFallColors project MyFallColors project
Rest of Semester Nov 7 – File and Directory functions Nov 7 – File and Directory functions Nov 14 – Error/Security [PRESENTATIONS] Nov 14 – Error/Security [PRESENTATIONS] Nov 21 – PHP Applications?? Nov 21 – PHP Applications?? Nov 28 – OOP [QUIZ] Nov 28 – OOP [QUIZ] Dec 5 – Web Services/SOAP Dec 5 – Web Services/SOAP Dec 12 – Open Lab Dec 12 – Open Lab Dec 14 – Projects Due!! Dec 14 – Projects Due!!
File Upload (html) </form>
File Information (php) // File upload error $_FILES["file"]["error"] // Actual file name $_FILES["file"]["name"]; // File type $_FILES["file"]["type"]; // File size in bytes $_FILES["file"]["size"]; // File tmp location and name $_FILES["file"]["tmp_name"];
File Upload (php) // Folder need to have permission 777 $local = “files/”; if (file_exists($local. $_FILES["file"]["name"])) { echo $_FILES["file"]["name"]. " already exists. "; }else{ move_uploaded_file($_FILES["file"]["tmp_name"], "files/". $_FILES["file"]["name"]); }
File Upload (security) 1.Assign 775 permission to upload folder 2.Disable directory indexes and script exection using.htaccess 3.Place the upload folder outside WWW root 4.Check for type of file upload and deny uploading other files 5.Restrict its size 6.Verify image using getimagesize() function with PHP 7.Create random files names using md5() 8.Use DB to store file information 9.chown the writable folder to apache or nobody and assign 770 permission
File Read (php) $dir = “files/";if (is_dir($dir)) {if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { while (($file = readdir($dh)) !== false) { echo "filename: $file; } closedir($dh); }}
Questions?
Presentation Two Pick a current article from 2012 around any Internet, programming or Web topic Pick a current article from 2012 around any Internet, programming or Web topic Prepare a 2-3 minute talk which you will do from your chair – if you need the project you can present from the front of the classroom Prepare a 2-3 minute talk which you will do from your chair – if you need the project you can present from the front of the classroom You will be presenting on November 14. You will be presenting on November 14.
Assignment 4 Update the “colors” project to add the following fields to the gallery: Update the “colors” project to add the following fields to the gallery: State of photo (AZ, AL, AR, AK …) State of photo (AZ, AL, AR, AK …) Date of photo (12/01/2012) Date of photo (12/01/2012) Description of photo Description of photo You will to make updates to the DB table, the gallery display page and the submit photo page. You will to make updates to the DB table, the gallery display page and the submit photo page. URL to by Nov 14 at 6:00pm URL to by Nov 14 at
Final Project Create a PHP website using pieces of code and modules we learned in class Create a PHP website using pieces of code and modules we learned in class Make the site look like a finished product that you can share as a indication of your skills Make the site look like a finished product that you can share as a indication of your skills You will be graded on looks, details and demonstration of php knowledge You will be graded on looks, details and demonstration of php knowledge Send to with URL to input form file before 6pm on Dec 14. Send to with URL to input form file before 6pm on Dec