|
@@ -0,0 +1,338 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+session_start();
|
|
|
|
|
+
|
|
|
|
|
+$toplevelDir = "pictures/";
|
|
|
|
|
+$dir = $toplevelDir;
|
|
|
|
|
+
|
|
|
|
|
+$maxCount = 30;
|
|
|
|
|
+$offset = 0;
|
|
|
|
|
+$count = 0;
|
|
|
|
|
+
|
|
|
|
|
+// load blacklist
|
|
|
|
|
+$blacklist = array();
|
|
|
|
|
+$blacklistFilename = "blacklist.txt";
|
|
|
|
|
+$blacklistHandle = fopen($blacklistFilename, "r");
|
|
|
|
|
+if ($blacklistHandle) {
|
|
|
|
|
+ $blacklistContent = fread($blacklistHandle, filesize($blacklistFilename));
|
|
|
|
|
+ fclose($blacklistHandle);
|
|
|
|
|
+ $blacklist = explode("\n", $blacklistContent);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+if (isset($_GET["offset"]))
|
|
|
|
|
+ $offset = $_GET["offset"];
|
|
|
|
|
+
|
|
|
|
|
+if (isset($_GET["getDir"]))
|
|
|
|
|
+ $dir = $_GET["getDir"];
|
|
|
|
|
+elseif (isset($_SESSION["indexDir"]))
|
|
|
|
|
+ $dir = $_SESSION["indexDir"];
|
|
|
|
|
+
|
|
|
|
|
+$_SESSION["indexDir"] = $dir;
|
|
|
|
|
+
|
|
|
|
|
+if (strpos($dir, $toplevelDir) !== 0)
|
|
|
|
|
+ $dir = $toplevelDir;
|
|
|
|
|
+else {
|
|
|
|
|
+ $dir = str_replace("..", "", $dir);
|
|
|
|
|
+ $dir = str_replace("//", "/", $dir);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+$folders = array();
|
|
|
|
|
+$files = array();
|
|
|
|
|
+
|
|
|
|
|
+// Open a known directory, and proceed to read its contents
|
|
|
|
|
+if (is_dir($dir)) {
|
|
|
|
|
+ if ($dh = scandir($dir)) {
|
|
|
|
|
+ for ($i = 0; $i < count($dh); ++$i) {
|
|
|
|
|
+ $file = $dh[$i];
|
|
|
|
|
+ if ($file == "." || $file == "..")
|
|
|
|
|
+ continue;
|
|
|
|
|
+
|
|
|
|
|
+ if (is_dir($dir . $file))
|
|
|
|
|
+ $folders[] = $file;
|
|
|
|
|
+ else {
|
|
|
|
|
+ if (!in_array($dir.$file, $blacklist)) {
|
|
|
|
|
+ if (count($files) < $maxCount && $count >= $offset)
|
|
|
|
|
+ $files[] = $file;
|
|
|
|
|
+ ++$count;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function createthumb($name, $filename, $new_w, $new_h)
|
|
|
|
|
+{
|
|
|
|
|
+ $system = explode('.', $name);
|
|
|
|
|
+ if (preg_match('/jpg|jpeg/', $system[1])) {
|
|
|
|
|
+ $src_img = imagecreatefromjpeg($name);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (preg_match('/png/', $system[1])) {
|
|
|
|
|
+ $src_img = imagecreatefrompng($name);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!$src_img) {
|
|
|
|
|
+ link("icons/image.png", $filename);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $old_w = imageSX($src_img);
|
|
|
|
|
+ $old_h = imageSY($src_img);
|
|
|
|
|
+
|
|
|
|
|
+ $old_x = 0;
|
|
|
|
|
+ $old_y = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if ($old_w > $old_h) {
|
|
|
|
|
+ $old_x = ($old_w - $old_h) / 2.0;
|
|
|
|
|
+ $old_w = $old_h;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($old_w < $old_h) {
|
|
|
|
|
+ $old_y = ($old_h - $old_w) / 2.0;
|
|
|
|
|
+ $old_h = $old_w;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $dst_img=ImageCreateTrueColor($new_w, $new_h);
|
|
|
|
|
+ imagecopyresampled($dst_img, $src_img, 0, 0, $old_x, $old_y, $new_w, $new_h, $old_w, $old_h);
|
|
|
|
|
+
|
|
|
|
|
+ if (preg_match("/png/",$system[1])) {
|
|
|
|
|
+ imagepng($dst_img, $filename, 90);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ imagejpeg($dst_img, $filename, 90);
|
|
|
|
|
+ }
|
|
|
|
|
+ imagedestroy($dst_img);
|
|
|
|
|
+ imagedestroy($src_img);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+?>
|
|
|
|
|
+
|
|
|
|
|
+<html>
|
|
|
|
|
+<head>
|
|
|
|
|
+<title>Gallery</title>
|
|
|
|
|
+
|
|
|
|
|
+<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,bold&subset=Latin">
|
|
|
|
|
+<link rel='stylesheet' id='googlefonts-css' href='http://fonts.googleapis.com/css?family=Norican%7CAlegreya%3A400italic%2C700italic%2C400%2C700%7CStint+Ultra+Condensed&ver=3.3.2' type='text/css' media='all' />
|
|
|
|
|
+<link rel="stylesheet" type="text/css" href="style.css">
|
|
|
|
|
+
|
|
|
|
|
+<script language="JavaScript">
|
|
|
|
|
+
|
|
|
|
|
+var request = false;
|
|
|
|
|
+
|
|
|
|
|
+function lightroomToggle(id, filename) {
|
|
|
|
|
+ if (document.getElementById(id).name == "add")
|
|
|
|
|
+ lightroomAction("add", id, filename);
|
|
|
|
|
+ else
|
|
|
|
|
+ lightroomAction("remove", id, filename);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function lightroomAction(action, id, filename) {
|
|
|
|
|
+ if (window.XMLHttpRequest)
|
|
|
|
|
+ request = new XMLHttpRequest();
|
|
|
|
|
+
|
|
|
|
|
+ if (!request) {
|
|
|
|
|
+ alert("Could not create XMLHttpRequest.");
|
|
|
|
|
+ return false;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ request.open('post', "lightroom_api.php", true);
|
|
|
|
|
+ request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
|
|
|
+ request.send('file=' + encodeURIComponent(filename) + '&action='+action);
|
|
|
|
|
+ request.onreadystatechange = function() {
|
|
|
|
|
+ if (request.readyState == 4) {
|
|
|
|
|
+ if (request.status != 200) {
|
|
|
|
|
+ alert("Request finished with error: " + request.status);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (request.responseText == "success") {
|
|
|
|
|
+ if (action == "add") {
|
|
|
|
|
+ document.getElementById(id).name = "remove";
|
|
|
|
|
+ document.getElementById(id).src = "icons/remove.png";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ document.getElementById(id).name = "add";
|
|
|
|
|
+ document.getElementById(id).src = "icons/add.png";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ alert(request.responseText);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function lightroomZipClean() {
|
|
|
|
|
+ if (window.XMLHttpRequest)
|
|
|
|
|
+ request = new XMLHttpRequest();
|
|
|
|
|
+
|
|
|
|
|
+ if (!request) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ request.open('post', "lightroom_api.php", true);
|
|
|
|
|
+ request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
|
|
|
+ request.send('action=zipClean');
|
|
|
|
|
+ request.onreadystatechange = function() { };
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+</head>
|
|
|
|
|
+
|
|
|
|
|
+<body bgcolor="#000000" onload="lightroomZipClean();">
|
|
|
|
|
+<img class="backgroundImage" src="icons/darkwood.jpg"/>
|
|
|
|
|
+
|
|
|
|
|
+<center><div class="caption">Hochzeit</div></center>
|
|
|
|
|
+
|
|
|
|
|
+<?php
|
|
|
|
|
+if ($dir != $toplevelDir) {
|
|
|
|
|
+ $dirUp = trim($dir, "/");
|
|
|
|
|
+ $dirUp = substr($dirUp, 0, strrpos($dirUp, "/"));
|
|
|
|
|
+ echo "<div class=\"backLabel\"><a class=\"gridLabel\" href=\"".$_SERVER['PHP_SELF']."?getDir=".$dirUp."/\">Zurück</a></div>";
|
|
|
|
|
+}
|
|
|
|
|
+?>
|
|
|
|
|
+
|
|
|
|
|
+<div style="position: fixed; top: 20px; right: 20px;"><a href="lightroom.php"><img src="icons/lightroom.png"></a></div>
|
|
|
|
|
+
|
|
|
|
|
+<table class="grid">
|
|
|
|
|
+
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+// Folder
|
|
|
|
|
+echo "<tr>";
|
|
|
|
|
+for($i = 0; $i < count($folders); $i++) {
|
|
|
|
|
+ if ($i%3 == 0)
|
|
|
|
|
+ echo "</tr><tr>";
|
|
|
|
|
+ echo "<td class=\"gridCell\">";
|
|
|
|
|
+ echo "<a href=\"".$_SERVER['PHP_SELF']."?getDir=".$dir.$folders[$i]."/\">";
|
|
|
|
|
+ echo "<img src=\"icons/album.png\" class=\"gridIcon\"><div class=\"gridLabel\">".$folders[$i]."</div>";
|
|
|
|
|
+ echo "</a>";
|
|
|
|
|
+ echo "</td>";
|
|
|
|
|
+}
|
|
|
|
|
+echo "</tr>";
|
|
|
|
|
+
|
|
|
|
|
+$sessionLightroomFiles = array();
|
|
|
|
|
+if (isset($_SESSION["lightroomFiles"]))
|
|
|
|
|
+ $sessionLightroomFiles = $_SESSION["lightroomFiles"];
|
|
|
|
|
+
|
|
|
|
|
+// Files
|
|
|
|
|
+echo "<tr>";
|
|
|
|
|
+for($i = 0; $i < count($files); $i++) {
|
|
|
|
|
+ if ($i%3 == 0)
|
|
|
|
|
+ echo "</tr><tr>";
|
|
|
|
|
+ echo "<td class=\"gridCell\" onMouseover=\"document.getElementById('lightRoomButton".$i."').style.visibility = 'visible';\" onMouseout=\"document.getElementById('lightRoomButton".$i."').style.visibility = 'hidden';\">";
|
|
|
|
|
+ echo "<a href=\"JavaScript: startSlideShow(".$i.");\">";
|
|
|
|
|
+ $thumbnail = "thumbnails/".md5($dir.$files[$i])."jpg";
|
|
|
|
|
+ if (!file_exists($thumbnail))
|
|
|
|
|
+ createthumb($dir . $files[$i], $thumbnail, 250, 250);
|
|
|
|
|
+ echo "<div class=\"gridIconShadow\">";
|
|
|
|
|
+ echo "<img src=\"".$thumbnail."\" class=\"gridIcon\">";
|
|
|
|
|
+ echo "</div>";
|
|
|
|
|
+ //echo "<div class=\"gridLabel\">".$files[$i]."</div>";
|
|
|
|
|
+ echo "</a>";
|
|
|
|
|
+
|
|
|
|
|
+ echo "<div id=\"lightRoomButton".$i."\" class=\"lightroomAddButton\"><a href=\"JavaScript: lightroomToggle('lightRoomButtonIcon".$i."', '".$dir.$files[$i]."');\"><img id=\"lightRoomButtonIcon".$i."\" ";
|
|
|
|
|
+ if (in_array($dir.$files[$i], $sessionLightroomFiles))
|
|
|
|
|
+ echo "name=\"remove\" src=\"icons/remove.png\"";
|
|
|
|
|
+ else
|
|
|
|
|
+ echo "name=\"add\" src=\"icons/add.png\"";
|
|
|
|
|
+ echo " width=\"32\" height=\"32\"/></a></div>";
|
|
|
|
|
+ echo "</td>";
|
|
|
|
|
+}
|
|
|
|
|
+echo "</tr>";
|
|
|
|
|
+
|
|
|
|
|
+?>
|
|
|
|
|
+
|
|
|
|
|
+</table>
|
|
|
|
|
+
|
|
|
|
|
+<center>
|
|
|
|
|
+<?php
|
|
|
|
|
+if ($offset > 0) {
|
|
|
|
|
+ $tmp = $offset - $maxCount;
|
|
|
|
|
+ if ($tmp < 0)
|
|
|
|
|
+ $tmp = 0;
|
|
|
|
|
+ echo "<a class=\"gridLabel\" href=\"".$_SERVER['PHP_SELF']."?getDir=".$dir."/&offset=".$tmp."\"><</a>";
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+if (($count > $offset + $maxCount) || ($offset > 0))
|
|
|
|
|
+ echo "<font class=\"gridLabel\"> - </font>";
|
|
|
|
|
+
|
|
|
|
|
+if ($count > $offset + $maxCount)
|
|
|
|
|
+ echo "<a class=\"gridLabel\" href=\"".$_SERVER['PHP_SELF']."?getDir=".$dir."/&offset=".($offset + $maxCount)."\">></a>";
|
|
|
|
|
+?>
|
|
|
|
|
+</center>
|
|
|
|
|
+
|
|
|
|
|
+<div id="slideShow" class="slideShow">
|
|
|
|
|
+<script language="JavaScript">
|
|
|
|
|
+
|
|
|
|
|
+var files = new Array();
|
|
|
|
|
+<?php
|
|
|
|
|
+for($i = 0; $i < count($files); $i++) {
|
|
|
|
|
+ echo "files.push(\"".$dir.$files[$i]."\")\n";
|
|
|
|
|
+}
|
|
|
|
|
+?>
|
|
|
|
|
+
|
|
|
|
|
+var slideShowIndex = 0;
|
|
|
|
|
+
|
|
|
|
|
+function startSlideShow(index) {
|
|
|
|
|
+ var elem = document.getElementById('slideShowItem');
|
|
|
|
|
+ elem.src = "";
|
|
|
|
|
+ slideShowIndex = index;
|
|
|
|
|
+ elem.src = files[slideShowIndex];
|
|
|
|
|
+ resizeToMax();
|
|
|
|
|
+ document.getElementById('slideShow').style.visibility = "visible";
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function stopSlideShow() {
|
|
|
|
|
+ var elem = document.getElementById('slideShowItem');
|
|
|
|
|
+ document.getElementById('slideShow').style.visibility = "hidden";
|
|
|
|
|
+ elem.src = "";
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+function next() {
|
|
|
|
|
+ var elem = document.getElementById('slideShowItem');
|
|
|
|
|
+
|
|
|
|
|
+ if (slideShowIndex >= files.length-1)
|
|
|
|
|
+ slideShowIndex = 0;
|
|
|
|
|
+ else
|
|
|
|
|
+ slideShowIndex += 1;
|
|
|
|
|
+
|
|
|
|
|
+ elem.src = files[slideShowIndex];
|
|
|
|
|
+ resizeToMax();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function previous() {
|
|
|
|
|
+ var elem = document.getElementById('slideShowItem');
|
|
|
|
|
+
|
|
|
|
|
+ if (slideShowIndex <= 0)
|
|
|
|
|
+ slideShowIndex = files.length-1;
|
|
|
|
|
+ else
|
|
|
|
|
+ slideShowIndex -= 1;
|
|
|
|
|
+
|
|
|
|
|
+ elem.src = files[slideShowIndex];
|
|
|
|
|
+ resizeToMax();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function resizeToMax(){
|
|
|
|
|
+ myImage = new Image()
|
|
|
|
|
+ var img = document.getElementById('slideShowItem');
|
|
|
|
|
+ myImage.src = img.src;
|
|
|
|
|
+ if(myImage.width / document.body.clientWidth > myImage.height / document.body.clientHeight) {
|
|
|
|
|
+ img.style.width = "95%";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ img.style.height = "95%";
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+</script>
|
|
|
|
|
+<div id="slideShowItemContainer"><img id="slideShowItem" class="slideShowItem" src=""/></div>
|
|
|
|
|
+<table style="position: absolute; left: 0px; top: 0px;" width="100%" height="100%">
|
|
|
|
|
+<tr>
|
|
|
|
|
+<td class="slideShowPreviousButton" onClick="javascript: previous();"> </td>
|
|
|
|
|
+<td class="slideShowCloseButton" onClick="javascript: stopSlideShow();"> </td>
|
|
|
|
|
+<td class="slideShowNextButton" onClick="javascript: next();"> </td>
|
|
|
|
|
+</tr>
|
|
|
|
|
+</table>
|
|
|
|
|
+
|
|
|
|
|
+</div>
|
|
|
|
|
+
|
|
|
|
|
+</body>
|
|
|
|
|
+</html>
|