X-Git-Url: http://git.pjr.cc/?p=quickshow.git;a=blobdiff_plain;f=show.php;h=5d70a62ba215778ac8bd31599e203eb676c4db47;hp=3fc88bcf404f7fcdb2fa1e704d2f73ca7e33a1b1;hb=HEAD;hpb=33649e192eaf542244733759751a076aac7deb38 diff --git a/show.php b/show.php index 3fc88bc..5d70a62 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,81 @@ if(isset($_REQUEST["showpic"])) { } else { header("Status: 404 Not Found"); } +} else if(isset($_REQUEST["fullpic"])) { + $file = $_REQUEST["fullpic"]; + if(preg_match("/.*\/+.*/", $_REQUEST["fullpic"])) { + error_log("throwing 403"); + header("Status: 403 i dont think so"); + return; + } + $afile = "$show_dir/".$_REQUEST["fullpic"]; + if(file_exists($afile)) { + echo "

Fullsize picture $file

"; + } else { + header("Status: 403 i dont think so"); + return; + } + return; +} 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; + } + 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 +120,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 +135,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 +156,7 @@ if(isset($_REQUEST["showpic"])) { // echo "
";
 	// print_r($_SERVER);
-	//echo "
"; + // echo ""; $i = 0; $dh = opendir($show_dir); @@ -86,7 +166,7 @@ if(isset($_REQUEST["showpic"])) { echo ""; } - echo "
"; + echo ""; if($i == ($n_per_line-1)) { echo "";