X-Git-Url: http://git.pjr.cc/?p=quickshow.git;a=blobdiff_plain;f=show.php;h=2489d451ad452f85b0ddb67f85920cbcd6a4837b;hp=b74356c4ff3883ea465ea7bf412dcd4ea3630527;hb=22c496f2f1d3d9466e138d44c49d9572a23e0bd0;hpb=b7d895d39d91d4faafc496275b8687a210c6d452
diff --git a/show.php b/show.php
index b74356c..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";
-$show_dir = "/home/paulr/lithium/data/Pictures/show";
-$n_per_line = 4;
-$this_url = "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
+// 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/";
+$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 "
";