From 22c496f2f1d3d9466e138d44c49d9572a23e0bd0 Mon Sep 17 00:00:00 2001 From: paulr Date: Thu, 1 Dec 2011 12:04:02 +1100 Subject: [PATCH] master, master where's the dreams that i've been after? --- show.php | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 74 insertions(+), 10 deletions(-) diff --git a/show.php b/show.php index 3fc88bc..2489d45 100644 --- a/show.php +++ b/show.php @@ -5,10 +5,15 @@ * of them along with clickable links to see the full thing */ -#$show_dir = "/export/data/Pictures/showdir"; +// set these variables +$n_per_line = 6; // number of pics in each line of the table +$thumb_size = 300; // size of thumbnails +$med_size = 1024; // size of "medium" image + + $show_dir = "/net/iron/export/quickshow/"; -$n_per_line = 6; -$this_url = "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; +$this_url = "http://".$_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"]; + if(isset($_REQUEST["showpic"])) { @@ -26,6 +31,65 @@ if(isset($_REQUEST["showpic"])) { } else { header("Status: 404 Not Found"); } +} else if(isset($_REQUEST["medpic"])) { + $file = $_REQUEST["medpic"]; + if(preg_match("/.*\/+.*/", $_REQUEST["medpic"])) { + error_log("throwing 403"); + header("Status: 403 i dont think so"); + return; + } + $afile = "$show_dir/".$_REQUEST["medpic"]; + if(file_exists($afile)) { + echo "

Picture $file

"; + } else { + header("Status: 403 i dont think so"); + return; + } +} else if(isset($_REQUEST["showmedpic"])) { + if(preg_match("/.*\/+.*/", $_REQUEST["showmedpic"])) { + error_log("throwing 403"); + header("Status: 403 i dont think so"); + return; + } + $afile = "$show_dir/".$_REQUEST["showmedpic"]; + if(file_exists($afile)) { + header('Content-Type: image/jpeg'); + $src = imagecreatefromjpeg($afile); + list($width, $height) = getimagesize($afile); + + if($width <= $med_size && $height <= $med_size) { + // just pump out the pic + error_log("pic pump"); + header('Content-Type: image/jpeg'); + echo file_get_contents($afile); + return; + } + + // else, resize it + if($width > $height) { + $nw = $med_size; + $nh = (int)($height/($width/$med_size)); + } else { + $nh = $med_size; + $nw = (int)($width/($height/$med_size)); + + } + + /* + * 2000 + * 1800 + * $nw = 200 + * $mul = $height/$width/200 + */ + + // error_log("neww = $nw, $nh"); + $thumb = imagecreatetruecolor($nw, $nh); + + imagecopyresized($thumb, $src, 0, 0, 0, 0, $nw, $nh, $width, $height); + imagejpeg($thumb); + } else { + header("Status: 404 Not Found"); + } } else if(isset($_REQUEST["showtmp"])) { // nothing yet if(preg_match("/.*\/+.*/", $_REQUEST["showtmp"])) { @@ -40,11 +104,11 @@ if(isset($_REQUEST["showpic"])) { list($width, $height) = getimagesize($afile); if($width > $height) { - $nw = 200; - $nh = (int)($height/($width/200)); + $nw = $thumb_size; + $nh = (int)($height/($width/$thumb_size)); } else { - $nh = 200; - $nw = (int)($width/($height/200)); + $nh = $thumb_size; + $nw = (int)($width/($height/$thumb_size)); } @@ -55,7 +119,7 @@ if(isset($_REQUEST["showpic"])) { * $mul = $height/$width/200 */ - error_log("neww = $nw, $nh"); + // error_log("neww = $nw, $nh"); $thumb = imagecreatetruecolor($nw, $nh); imagecopyresized($thumb, $src, 0, 0, 0, 0, $nw, $nh, $width, $height); @@ -76,7 +140,7 @@ if(isset($_REQUEST["showpic"])) { // echo "
";
 	// print_r($_SERVER);
-	//echo "
"; + // echo ""; $i = 0; $dh = opendir($show_dir); @@ -86,7 +150,7 @@ if(isset($_REQUEST["showpic"])) { echo ""; } - echo "
"; + echo ""; if($i == ($n_per_line-1)) { echo ""; -- 1.7.0.4