| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <?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&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ü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."\"><</a>";
- }
- if (($count > $offset + $maxCount) || ($offset > 0))
- echo "<font class=\"gridLabel\"> - </font>";
- if ($count > $offset + $maxCount)
- echo "<a class=\"gridLabel\" href=\"".$_SERVER['PHP_SELF']."?offset=".($offset + $maxCount)."\">></a>";
- ?>
- </center>
- </body>
- </html>
|