"; switch ($action) { Case "uploadPictureForm": if (isset($_SESSION['loggedinadmin'])) { showUploadPictureForm(); } else { echo "You don't have access to this feature!"; } break; Case "addPictureForm": if (isset($_SESSION['loggedinadmin'])) { if(isset($_GET['pictureFilename'])) { $pictureFilename = $_GET['pictureFilename']; } else { $pictureFilename=""; } showAddPictureForm($pictureFilename); } else { echo "You don't have access to this feature!"; } break; Case "uploadPicture": if (isset($_SESSION['loggedinadmin'])) { uploadPicture(); } else { echo "You don't have access to this feature!"; } break; Case "editPictureForm": if (isset($_SESSION['loggedinadmin'])) { $pictureID = $_GET['pictureID']; showEditPictureForm($pictureID); } else { echo "You don't have access to this feature!"; } break; Case "addPicture": if (isset($_SESSION['loggedinadmin'])) { IF ($_POST['pictureName'] != '') { addNewPicture(); } else { echo "Missing information. Please go back and complete the form."; } } else { echo "You don't have access to this feature!"; } break; Case "updatePicture": if (isset($_SESSION['loggedinadmin'])) { $pictureID = $_POST['pictureID']; IF (($_POST['pictureName'] != '') OR ($pictureID != 0 )) { updatePicture($pictureID); } else { echo "Missing information. Please go back and complete the form."; } } else { echo "You don't have access to this feature!"; } break; Case "viewPicture": $pictureID = $_GET['pictureID']; showPicture($pictureID); break; Case "viewPictures": showPictures(); break; Case "viewAllDocuments": showAllDocuments(); break; Case Null: Default: echo "

More pictures and videos on our facebook page:
"; echo "LOPL - London Ontario Pinball League

"; showPublicPictures(); break; } mysql_close(); echo ""; include 'footer.php'; Function showAddPictureForm($pictureFilename) { echo "

Add New Picture

"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Name
Location
Date
Is Public"; echo "YES"; echo "NO"; echo "
filename
Notes
"; echo ""; echo ""; echo "
"; } Function showEditPictureForm($pictureID) { $sql = "SELECT * FROM P_pictures WHERE pictureID = ".$pictureID; $response = mysql_query($sql); echo "

Edit Pictures

"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Name
Location
Date
Is Public"; echo "YES"; echo "NO"; echo "
Filename
Notes
"; echo ""; echo ""; echo ""; echo "
"; } Function showUploadPictureForm() { echo "
"; echo ""; echo "
"; echo ""; echo "
"; } Function uploadPicture() { $allowedExts = array("jpg", "jpeg", "gif", "png"); $path_parts = pathinfo($_FILES["file"]["name"]); $extension = strtolower(end(explode(".", $_FILES["file"]["name"]))); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 1500000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "
"; } else { echo "Upload: " . $_FILES["file"]["name"] . "
"; echo "Type: " . $_FILES["file"]["type"] . "
"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB
"; echo "Uploaded to: " . $_FILES["file"]["tmp_name"]; echo "
"; $filename = $_FILES["file"]["name"]; if (file_exists("pictures/" . $_FILES["file"]["name"])) { //already have one of those, add a timestamp to the name $filename = $path_parts['filename']."_".microtime(true).".".$extension; } move_uploaded_file($_FILES["file"]["tmp_name"], "pictures/" .$filename); echo "Moved to: " . "pictures/" . $filename; echo "

"; $sql = "INSERT INTO P_pictures (" ."date, filename, name) " ."VALUES (" ."CURRENT_TIMESTAMP, " ."'$filename', '$filename') "; $retval = mysql_query( $sql); if(! $retval ) { die('Could not enter data: ' . mysql_error()); } echo "Entered data successfully\n"; $pictureID = mysql_insert_id(); //define arguments for the make_thumb function $source = "pictures/" . $filename; $destination = "pictures/thumbnails/thumb_". $pictureID .".jpg"; //specify your desired width for your thumbnails $width = "200"; //Finally call the make_thumb function $srctype = $_FILES["file"]["type"]; make_thumb($source,$srctype,$destination,$width); } } else { echo "Invalid file"; If ($_FILES["file"]["size"] > 1500000) { echo "File size limit of 1.5Mb. Please rescale and try again.
"; } } } //Function to generate image thumbnails function make_thumb($src, $srctype, $dest, $desired_width) { /* read the source image */ switch($srctype) { case "image/jpeg": case "image/jpg": case "image/pjpeg": $source_image = imagecreatefromjpeg($src); break; case "image/gif": case "image/png": $source_image = imagecreatefrompng($src); } $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */ $desired_height = floor($height * ($desired_width / $width)); if($desired_height > 240) { $desired_height = 240; $desired_width = floor($width * ($desired_height / $height)); } /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($desired_width, $desired_height); /* copy source image at a resized size */ imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height); /* create the physical thumbnail image to its destination with 100% quality*/ imagejpeg($virtual_image, $dest,100); } Function AddNewPicture() { foreach ($_POST as $key => $value) { echo $key; echo " - "; echo $value; echo "
"; } $sql = "INSERT INTO P_pictures (" ."name, location, date, notes, isPublic, filename) " ."VALUES (" ."'$_POST[pictureName]', '$_POST[pictureLocation]', " ."'$_POST[pictureDate]', '$_POST[pictureNotes]', " ."'$_POST[pictureIsPublic]', " ."'$_POST[pictureFilename]') "; $retval = mysql_query( $sql); if(! $retval ) { die('Could not enter data: ' . mysql_error()); } echo "Entered data successfully\n"; $pictureID = mysql_insert_id(); return $pictureID; } Function updatePicture($pictureID) { foreach ($_POST as $key => $value) { echo $key; echo " - "; echo $value; echo "
"; } $sql = "UPDATE P_pictures SET " ."name = '$_POST[pictureName]', " ."location = '$_POST[pictureLocation]'," ."date = '$_POST[pictureDate]'," ."isPublic = '$_POST[pictureIsPublic]'," ."filename = '$_POST[pictureFilename]'," ."notes = '$_POST[pictureNotes]'" ." WHERE pictureID = ".$pictureID; $retval = mysql_query( $sql); if(! $retval ) { echo $sql; die('Could not update data: ' . mysql_error()); } echo "Updated data successfully."; } function showPictures() { echo "

All Pictures

"; $sql = "SELECT * FROM P_pictures ORDER BY date DESC"; $response = mysql_query($sql); $i=0; $Max=mysql_numrows($response); if ($Max == 0 ) { echo "No pictures at this time."; } else { While ($i < $Max) { $filename = mysql_result($response, $i, "filename"); $pictureID = mysql_result($response, $i, "pictureID"); echo "
"; echo "
"; echo ""; echo "\"Thumbnail
"; echo "
".mysql_result($response, $i, "name")."
".date('Y-m-d', strtotime( mysql_result($response, $i, 'date') )); if (isset($_SESSION['loggedinadmin'])) { echo ""; } echo "
"; echo "
\n"; $i = $i + 1; } } } Function showPicture($pictureID) { $sql = "SELECT * FROM P_pictures WHERE pictureID = ".$pictureID; $response = mysql_query($sql); echo "

Picture Viewer

"; $filename = mysql_result($response, 0, "filename"); echo "
\"[$filename]\"
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Picture ID".mysql_result($response, 0, "pictureID")."
Name".mysql_result($response, 0, "name")."
Date".mysql_result($response, 0, "date")."
Location".mysql_result($response, 0, "location")."
Note".mysql_result($response, 0, "notes")."
"; if(isset($_SESSION['loggedinadmin'])) { echo "


"; } } Function showPublicPictures() { if (isset($_SESSION['loggedin'])) { echo "

Latest Public Pictures

"; } else { echo "

Latest 3 Pictures - Login to see more

"; } $sql = "SELECT * FROM P_pictures WHERE isPublic = 1 ORDER BY date DESC LIMIT 0, 3"; $response = mysql_query($sql); $i=0; $Max=mysql_numrows($response); if ($Max == 0 ) { echo "No pictures at this time."; } else { While ($i < $Max) { $filename = mysql_result($response, $i, "filename"); $pictureID = mysql_result($response, $i, "pictureID"); echo "
"; echo "
"; echo ""; echo "\"Thumbnail
"; echo "
".mysql_result($response, $i, "name")."
".date('Y-m-d', strtotime( mysql_result($response, $i, 'date') )); if (isset($_SESSION['loggedinadmin'])) { echo ""; } echo "
"; echo "
\n"; $i = $i + 1; } } } Function showAllDocuments() { if (isset($_SESSION['loggedinadmin'])) { echo "

Documents

"; echo ""; echo ""; foreach(glob('docs/*.*') as $filename) { echo ""; } echo "
FileSizeD/L Link
$filename" . filesize($filename) . "$filename
"; } else { echo "

Documents

"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
*.doc
Score Sheet (2 rows, 4 machines)LOPL_Score_2
Score Sheet (3 rows, 4 machines)LOPL_Score_3
*.pdf
Score Sheet (1 row, 8 machines)LOPL_Score_1
Score Sheet (2 rows, 4 machines)LOPL_Score_2
Score Sheet (3 rows, 4 machines)LOPL_Score_3
"; } } ?>