3 /* This is a very simple app
4 * - you give it a directory where it'll look for jpg's and it'll give a quick index
5 * of them along with clickable links to see the full thing
8 #$show_dir = "/export/data/Pictures/showdir";
9 $show_dir = "/home/paulr/lithium/data/Pictures/show";
11 $this_url = "http://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
14 if(isset($_REQUEST["showpic"])) {
15 // show the pic requested...
16 if(preg_match("/.*\\+.*/", $_REQUEST["showpic"])) {
17 header("Status: 403 i dont think so");
18 error_log("throwing 403");
22 $afile = "$show_dir/".$_REQUEST["showpic"];
23 if(file_exists($afile)) {
24 header('Content-Type: image/jpeg');
25 echo file_get_contents($afile);
27 header("Status: 404 Not Found");
29 } else if(isset($_REQUEST["showtmp"])) {
31 if(preg_match("/.*\\+.*/", $_REQUEST["showtmp"])) {
32 error_log("throwing 403");
33 header("Status: 403 i dont think so");
36 $afile = "$show_dir/".$_REQUEST["showtmp"];
37 if(file_exists($afile)) {
38 header('Content-Type: image/jpeg');
39 $src = imagecreatefromjpeg($afile);
40 list($width, $height) = getimagesize($afile);
42 if($width > $height) {
44 $nh = (int)($height/($width/200));
47 $nw = (int)($width/($height/200));
55 * $mul = $height/$width/200
58 error_log("neww = $nw, $nh");
59 $thumb = imagecreatetruecolor($nw, $nh);
61 imagecopyresized($thumb, $src, 0, 0, 0, 0, $nw, $nh, $width, $height);
64 header("Status: 404 Not Found");
69 // show a grid of images
82 $dh = opendir($show_dir);
83 while (($file = readdir($dh)) !== false) {
84 if(preg_match("/.*\.[jJ][pP][gG]$/", $file)) {
89 echo "<td><a href=\"$this_url?showpic=$file\"><img src=\"$this_url?showtmp=$file\"></a></td>";
91 if($i == ($n_per_line-1)) {