Johannes Zellner před 11 roky
revize
cc75e3efae
24 změnil soubory, kde provedl 1117 přidání a 0 odebrání
  1. 235 0
      admin.php
  2. 0 0
      blacklist.txt
  3. binární
      icons/101907-hardwood_lights-1680x1050.jpg
  4. binární
      icons/1280x1024.jpg
  5. binární
      icons/47861-wood.jpg
  6. binární
      icons/80934-darkwood16001200.jpg
  7. binární
      icons/87741-madera2.png
  8. binární
      icons/_MG_1103.jpg
  9. binární
      icons/add.png
  10. binární
      icons/ajax-loader.gif
  11. binární
      icons/album.png
  12. binární
      icons/darkwood.jpg
  13. binární
      icons/directory.png
  14. binární
      icons/image.png
  15. binární
      icons/lightroom.png
  16. binární
      icons/remove.png
  17. binární
      icons/shadow.png
  18. binární
      icons/stripes.png
  19. binární
      icons/zip.png
  20. 338 0
      index.php
  21. 196 0
      lightroom.php
  22. 110 0
      lightroom_api.php
  23. 120 0
      resize.php
  24. 118 0
      style.css

+ 235 - 0
admin.php

@@ -0,0 +1,235 @@
+<?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 (count($files) < $maxCount && $count >= $offset && !in_array($dir.$file, $blacklist))
+					$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&#038;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 sortOut(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=sortOut');
+		request.onreadystatechange = function() {
+			if (request.readyState == 4) {
+				if (request.status != 200) {
+					alert("Request finished with error: " + request.status);
+				} else {
+					if (request.responseText == "success")
+						location.replace("admin.php?getDir=<?php echo $dir; ?>&offset=<?php echo $offset; ?>");
+					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">
+<img class="backgroundImage" src="icons/darkwood.jpg"/>
+
+<center><div class="caption">Hochzeit - Admin</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&uuml;ck</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\">";
+	$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 id=\"lightRoomButton".$i."\" class=\"sortOutButton\"><a href=\"JavaScript: sortOut('".$dir.$files[$i]."');\"><img id=\"lightRoomButtonIcon".$i."\" name=\"remove\" src=\"icons/remove.png\" 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."\">&lt;</a>";
+}
+
+if (($count > $offset + $maxCount) || ($offset >  0))
+	echo "<font class=\"gridLabel\">&nbsp; - &nbsp;</font>";
+
+if ($count > $offset + $maxCount)
+	echo "<a class=\"gridLabel\" href=\"".$_SERVER['PHP_SELF']."?getDir=".$dir."/&offset=".($offset + $maxCount)."\">&gt;</a>";
+?>
+</center>
+
+</body>
+</html>

+ 0 - 0
blacklist.txt


binární
icons/101907-hardwood_lights-1680x1050.jpg


binární
icons/1280x1024.jpg


binární
icons/47861-wood.jpg


binární
icons/80934-darkwood16001200.jpg


binární
icons/87741-madera2.png


binární
icons/_MG_1103.jpg


binární
icons/add.png


binární
icons/ajax-loader.gif


binární
icons/album.png


binární
icons/darkwood.jpg


binární
icons/directory.png


binární
icons/image.png


binární
icons/lightroom.png


binární
icons/remove.png


binární
icons/shadow.png


binární
icons/stripes.png


binární
icons/zip.png


+ 338 - 0
index.php

@@ -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&#038;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&uuml;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."\">&lt;</a>";
+}
+
+if (($count > $offset + $maxCount) || ($offset >  0))
+	echo "<font class=\"gridLabel\">&nbsp; - &nbsp;</font>";
+
+if ($count > $offset + $maxCount)
+	echo "<a class=\"gridLabel\" href=\"".$_SERVER['PHP_SELF']."?getDir=".$dir."/&offset=".($offset + $maxCount)."\">&gt;</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();">&nbsp;</td>
+<td class="slideShowCloseButton" onClick="javascript: stopSlideShow();">&nbsp;</td>
+<td class="slideShowNextButton" onClick="javascript: next();">&nbsp;</td>
+</tr>
+</table>
+
+</div>
+
+</body>
+</html>

+ 196 - 0
lightroom.php

@@ -0,0 +1,196 @@
+<?php
+
+session_start();
+
+$maxCount = 30;
+$offset = 0;
+$count = 0;
+
+if (isset($_SESSION["lightroomFiles"])) {
+	if (isset($_GET["offset"]))
+		$offset = $_GET["offset"];
+
+	$files = array();
+
+	for ($i = 0; $i < count($_SESSION["lightroomFiles"]); ++$i) {
+		if (count($files) < $maxCount && $count >= $offset) {
+			$files[] = $_SESSION["lightroomFiles"][$i];
+		}
+		++$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&#038;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 lightroomRemoveItem(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=remove');
+		request.onreadystatechange = function() {
+			if (request.readyState == 4) {
+				if (request.status != 200) {
+					alert("Request finished with error: " + request.status);
+				} else {
+					if (request.responseText == "success")
+						location.replace("lightroom.php?offset=<?php echo $offset; ?>");
+					else
+						alert(request.responseText);
+				}
+			}
+		};
+	}
+}
+
+function lightroomZip() {
+	if (window.XMLHttpRequest) 
+		request = new XMLHttpRequest();
+	
+	if (!request) {
+		alert("Could not create XMLHttpRequest.");
+		return false;
+	} else {
+		document.getElementById("loadingIndicator").style.visibility = "visible";
+		
+		request.open('post', "lightroom_api.php", true);
+		request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+		request.send('action=zip');
+		request.onreadystatechange = function() {
+			if (request.readyState == 4) {
+				if (request.status != 200) {
+					alert("Request finished with error: " + request.status);
+				} else {
+					if (request.responseText.search("success") == 0) {
+						var zipfile = request.responseText.split(":")[1];
+						if (zipfile != "")
+							window.location.href = zipfile;
+					} else {
+						alert(request.responseText);
+					}
+					document.getElementById("loadingIndicator").style.visibility = "hidden";
+				}
+			}
+		};
+	}
+}
+
+</script>
+
+</head>
+
+<body bgcolor="#000000">
+<img class="backgroundImage" src="icons/darkwood.jpg"/>
+
+<center><div class="caption">Lightroom</div></center>
+
+<div style="position: fixed; top: 20px; left: 20px;"><a class="gridLabel" href="index.php">Zur&uuml;ck</a></div>
+<div style="position: fixed; top: 20px; right: 20px;"><a href="JavaScript: lightroomZip();"><img src="icons/zip.png"></a></div>
+<div id="loadingIndicator" style="position: fixed; top: 20px; right: 27px; visibility: hidden;"><img src="icons/ajax-loader.gif"></div>
+
+<table class="grid">
+
+<?php
+
+if (isset($files)) {
+	// 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';\">";
+		$thumbnail = "thumbnails/".md5($files[$i])."jpg";
+		if (!file_exists($thumbnail))
+			createthumb($files[$i], $thumbnail, 250, 250);
+		echo "<div class=\"gridIconShadow\">";
+		echo "<img src=\"".$thumbnail."\" class=\"gridIcon\">";
+		echo "</div>";
+		echo "<div id=\"lightRoomButton".$i."\" class=\"lightroomAddButton\"><a href=\"JavaScript: lightroomRemoveItem('".$files[$i]."');\"><img src=\"icons/remove.png\" 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']."?offset=".$tmp."\">&lt;</a>";
+}
+
+if (($count > $offset + $maxCount) || ($offset >  0))
+	echo "<font class=\"gridLabel\">&nbsp; - &nbsp;</font>";
+
+if ($count > $offset + $maxCount)
+	echo "<a class=\"gridLabel\" href=\"".$_SERVER['PHP_SELF']."?offset=".($offset + $maxCount)."\">&gt;</a>";
+?>
+</center>
+
+</body>
+</html>

+ 110 - 0
lightroom_api.php

@@ -0,0 +1,110 @@
+<?php
+
+session_start();
+
+header('Content-Type: text/html; charset=utf-8');
+
+$zipFolder = "zip/";
+$toplevelDir = "pictures/";
+$saveFolder = "pictures_save/";
+
+if (!isset($_POST["action"]))
+	exit("error: no action defined.");
+	
+$action = $_POST["action"];
+
+if ($action == "add") {
+	if (!isset($_POST["file"]))
+		exit("error: no file specified.");
+	$file = $_POST["file"];
+	
+	if (!file_exists($file))
+		exit("error: file does not exist.".$file);
+	
+	$files = array();
+	if (isset($_SESSION["lightroomFiles"]))
+		$files = $_SESSION["lightroomFiles"];
+		
+	$files[] = $file;
+	
+	$_SESSION["lightroomFiles"] = $files;
+	
+	exit("success");
+} elseif ($action == "remove") {
+	if (!isset($_POST["file"]))
+		exit("error: no file specified.");
+	$file = $_POST["file"];
+	
+	$files = array();
+	if (isset($_SESSION["lightroomFiles"]))
+		$files = $_SESSION["lightroomFiles"];
+	
+	for($i = 0; $i < count($files); ++$i) {
+		if ($files[$i] == $file) {
+			array_splice($files, $i, 1);
+			break;
+		}
+	}
+	
+	$_SESSION["lightroomFiles"] = $files;
+	
+	exit("success");
+} elseif ($action == "zip") {
+	$zip = new ZipArchive();
+	$zipFilename = $zipFolder.session_id().".zip";
+	
+	if (file_exists($zipFilename))
+		unlink($zipFilename);
+	
+	if ($zip->open($zipFilename, ZIPARCHIVE::CREATE) !== TRUE)
+		exit("error: cannot create zip archive");
+		
+	$files = array();
+	if (isset($_SESSION["lightroomFiles"]))
+		$files = $_SESSION["lightroomFiles"];
+
+	for($i = 0; $i < count($files); ++$i)
+		$zip->addFile($files[$i]);
+		
+	$zip->close();
+	
+	exit("success:".$zipFilename);
+} elseif ($action == "zipClean") {
+	// Open a known directory, and proceed to read its contents
+	if (is_dir($zipFolder)) {
+		if ($dh = scandir($zipFolder)) {
+			for ($i = 0; $i < count($dh); ++$i) {
+				if ($dh[$i] == "." || $dh[$i] == "..")
+					continue;
+					
+				$filePath = $zipFolder.$dh[$i];
+				$stat = stat($filePath);
+				if (time() - $stat['ctime'] > (30*60))
+					unlink($filePath);
+			}
+			exit("success");
+		}
+	}
+	exit("error: could not open zip folder ".$zipFolder);
+} elseif ($action == "sortOut") {
+	if (!isset($_POST["file"]))
+		exit("error: no file specified.");
+	$file = $_POST["file"];
+	
+	// load blacklist
+	$blacklistFilename = "blacklist.txt";
+	$blacklistHandle = fopen($blacklistFilename, "a");
+	if (!$blacklistHandle)
+		exit("error: could not open blacklist file.");
+		
+	if (!fwrite($blacklistHandle, $file."\n"))
+		exit("error: could not write blacklist file.");
+		
+	fclose($blacklistHandle);
+		
+	exit("success");
+}
+
+exit("error: unsupported action.");
+
+?>

+ 120 - 0
resize.php

@@ -0,0 +1,120 @@
+<?php
+
+$maxCount = 4;
+$count = 0;
+$resizeCount = 0;
+$folderIndex = 0;
+	
+if (isset($_GET["folder"]))
+	$folderIndex = $_GET["folder"];
+
+$srcFolder = "pictures/";
+$destFolder = "pictures_new/";
+
+$folders = array("Standesamt/",
+		"Shooting/",
+		"Gruppen/",
+		"Fotobooth/",
+		"Feier/");
+
+$folder = $srcFolder . $folders[$folderIndex];
+
+if (!is_dir($destFolder . $folders[$folderIndex])) {
+	mkdir($destFolder . $folders[$folderIndex]);
+}
+
+if (is_dir($folder)) {
+	if ($dh = scandir($folder)) {
+		for ($i = 0; $i < count($dh); ++$i) {
+			$file = $dh[$i];
+			if ($file == "." || $file == "..")
+				continue;
+				
+			if (is_dir($folder . $file))
+				continue;
+				
+			if (file_exists($destFolder . $folders[$folderIndex] . $file))
+				continue;
+				
+			if ($resizeCount < $maxCount) {
+				resize($folder . $file, $destFolder . $folders[$folderIndex] . $file, 1920, 1080);
+				++$resizeCount;
+			}
+		}
+	}
+}
+
+function resize($name, $filename, $w, $h) 
+{
+	echo "resize: " . $name . " -> " . $filename;
+	echo "<br>";
+	
+	$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);
+	
+	$new_w = $w;
+	$new_h = $h;
+	
+	if ($old_w > $old_h)
+		$new_h = $old_h * ($new_w/$old_w);
+	
+	if ($old_w < $old_h)
+		$new_w = $old_w * ($new_h/$old_h);
+	
+	echo "<br>";
+	echo $old_w ."x" . $old_h;
+	echo " -> ";
+	echo $new_w ."x" . $new_h;
+	echo "<br><br>";
+
+	$dst_img=ImageCreateTrueColor($new_w, $new_h);
+	imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $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);
+}
+
+
+$refreshUri  = $PHP_SELF;
+
+if ($resizeCount == 0)
+	$folderIndex++;
+	
+$refreshUri .= "?folder=".$folderIndex;
+
+if ($folderIndex > count($folders))
+	$refreshUri = "index.php";
+
+?>
+
+<html>
+<head>
+
+<title> Resizer </title>
+
+<META HTTP-EQUIV="refresh" CONTENT="1;URL=<? echo $refreshUri; ?>">
+
+</head>
+
+<body>
+
+</body>
+</html>

+ 118 - 0
style.css

@@ -0,0 +1,118 @@
+
+.backgroundImage {
+	width: 100%;
+	height: 100%;
+	position: fixed;
+	top: 0px;
+	left: 0px;
+	z-index: -100;
+}
+
+.caption {
+	font-family: Norican;
+	font-size: 32px;
+	color: white;
+	text-shadow: black 0px -2px 0px;
+}
+
+a:link { text-decoration:none; }
+a:visited { text-decoration:none; }
+a:hover { text-decoration:none; color: lightsteelblue}
+a:active { text-decoration:none; }
+
+.backLabel {
+	position: fixed;
+	top: 20px;
+	left: 20px;
+}
+
+.gridLabel { 
+	font-family: Ubuntu, sans-serif;
+	font-style: bold;
+	font-size: 18px; 
+	color: white; 
+	text-align: center;
+	text-shadow: black 0px -1px 0px;
+}
+
+.gridIcon {
+	margin-left: auto;
+	margin-right: auto;
+	display: block;
+}
+
+.gridIconShadow {
+	background: url("icons/shadow.png") no-repeat bottom right;
+	float:right;
+}
+
+.gridIconShadow img {
+	display: block; /* IE won't do well without this */
+	position: relative; /* Make the shadow's position relative to its image */
+	padding: 3px; /* This creates a border around the image */
+	background-color: #fff; /* Background color of the border created by the padding */
+	border: 1px solid #cecece; /* A 1 pixel greyish border is applied to the white border created by the padding */
+	margin: -6px 6px 6px -6px; /* Offset the image by certain pixels to reveal the shadow, as the shadows are 6 pixels wide, offset it by that amount to get a perfect shadow */
+}
+
+.gridCell {
+	width: 256px;
+	padding: 20px;
+	border-width: 0px;
+	border-style: solid;
+}
+
+.grid {
+	width: 920px;
+	border-width: 0px;
+	border-style: solid;
+	margin-left: auto;
+	margin-right: auto;
+	display: block;
+}
+
+.slideShow {
+	position: fixed;
+	top: 0px;
+	left: 0px;
+	background-color: black;
+	width: 100%;
+	height: 100%;
+	visibility: hidden;
+}
+
+.slideShowItem {
+	margin-left: auto;
+	margin-right: auto;
+	display: block;
+}
+
+.slideShowCloseButton {
+	width: 60%;
+	height: 100%;
+	cursor: pointer;
+}
+
+.slideShowPreviousButton {
+	width: 20%;
+	height: 100%;
+	cursor: w-resize
+}
+
+.slideShowNextButton {
+	width: 20%;
+	height: 100%;
+	cursor: e-resize
+}
+
+.lightroomAddButton {
+	position: absolute;
+	background-color: transparent;
+	visibility: hidden;
+}
+
+.sortOutButton {
+	position: absolute;
+	background-color: transparent;
+	visibility: visible;
+}