From 9d51c7b1a4ac5fcdd7eb5bb50c69155e9c8e7be9 Mon Sep 17 00:00:00 2001 From: Marc MAURICE Date: Thu, 7 Oct 2010 21:27:44 +0200 Subject: [PATCH] Initial commit --- index.php | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ view.php | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 246 insertions(+) create mode 100644 index.php create mode 100644 view.php diff --git a/index.php b/index.php new file mode 100644 index 0000000..e6ab0c1 --- /dev/null +++ b/index.php @@ -0,0 +1,129 @@ + + + + + + + + $h) { + $newW = $maxSize; + $newH = $h/($w/$maxSize); + } else { + $newW = $w/($h/$maxSize); + $newH = $maxSize; + } + + $newImg = imagecreatetruecolor($newW, $newH); + + imagecopyresampled($newImg, $img, 0, 0, 0, 0, $newW, $newH, $w, $h); + + imagejpeg($newImg, $newImgFile); + + imagedestroy($img); + imagedestroy($newImg); + } + + return dirname($_SERVER["SCRIPT_NAME"])."/".$newImgFile; +} + +function getAlbumPreview($dir) +{ + foreach (scandir($dir) as $file) if ($file != '.' and $file != '..') { + if (mime_content_type("$dir/$file") == "image/jpeg") + return getPreview("$dir/$file", 100); + } + + return ''; +} + +$shortPath = isset($_SERVER["PATH_INFO"]) ? $_SERVER["PATH_INFO"] : ""; +if ($shortPath == '/') $shortPath = ''; +$scriptUrlPath = substr($_SERVER["SCRIPT_NAME"], 0, -4); // trim .php + +$imageFiles = array(); +$otherFiles = array(); + +$realDir = "images$shortPath"; + +foreach (scandir($realDir) as $file) if ($file != '.') +{ + if ($file == '..') + { + echo "
..
\n"; + } + elseif (is_dir("$realDir/$file")) + { + echo "
"; + $preview = getAlbumPreview("$realDir/$file"); + if ($preview !== '') { + echo " "; + } + + echo "$file"; + echo "
\n"; + } + else + { + $mime = mime_content_type("$realDir/$file"); + + if ($mime == "image/jpeg") + $imageFiles[] = $file; + else + $otherFiles[] = $file; + } +} + +foreach ($imageFiles as $file) { + echo "
\n"; +} + +foreach ($otherFiles as $file) { + echo "
$file
\n"; +} + +?> + + + diff --git a/view.php b/view.php new file mode 100644 index 0000000..d6d45bd --- /dev/null +++ b/view.php @@ -0,0 +1,117 @@ +=0 ; $prev--) { + $mime = mime_content_type("$realDir/$files[$prev]"); + if ($mime == "image/jpeg") + $prevImage = $files[$prev]; +} + +$imageUrl = dirname($scriptPath)."/images$quickPath"; + +if ($nextImage === '') { + $nextImageUrl = ''; + $nextPageUrl = ''; +} else { + $nextImageUrl = dirname($scriptPath)."/images".dirname($quickPath)."/$nextImage"; + $nextPageUrl = dirname($_SERVER["REQUEST_URI"])."/$nextImage"; +} +if ($prevImage === '') $prevPageUrl = ''; +else $prevPageUrl = dirname($_SERVER["REQUEST_URI"])."/$prevImage"; + +$directoryUrl = dirname($_SERVER["SCRIPT_NAME"])."/index".dirname($quickPath); + +header('Content-Type: text/html; charset=utf-8'); +header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + 3600)); +?> + + + + + + + + + + + + + + +
+^ +
+ + + + + + + + + + + -- 1.7.10.4