Skip to content
Browse files

Initial checkin

  • Loading branch information...
0 parents commit 22c1104459604d1da31defd7399cb2978d3160b8 sofar committed
Showing with 838 additions and 0 deletions.
  1. +19 −0 Makefile
  2. +45 −0 album.css
  3. +146 −0 album.js
  4. +119 −0 album.php
  5. +22 −0 auth.php
  6. +25 −0 db.php
  7. BIN go-next.png
  8. BIN go-previous.png
  9. +129 −0 image.php
  10. +59 −0 index.php
  11. +43 −0 login.php
  12. +8 −0 logout.php
  13. +33 −0 members.php
  14. BIN movie.jpg
  15. +18 −0 private.php
  16. +94 −0 thumbs.sh
  17. +78 −0 upload.php
19 Makefile
@@ -0,0 +1,19 @@
+
+CLIENT = album.css album.js
+IMAGES = go-next.png go-previous.png movie.jpg
+SERVER = album.php auth.php db.php image.php index.php login.php logout.php \
+ members.php private.php upload.php
+TOOLS = thumbs.sh Makefile
+
+all: install
+
+dist:
+ tar czf album-`date -u +%Y%m%d`.tar.gz $(CLIENT) $(IMAGES) $(SERVER) $(TOOLS)
+
+install:
+ @echo Creating cache path:
+ mkdir -p .c
+ chmod 0777 .c
+ @echo Installation complete. Make sure you have PHP installed with
+ @echo EXIF support enabled. To pre-seed the cache, run `thumbs.sh`.
+ @echo Add albums by uploading image folders to the root path.
45 album.css
@@ -0,0 +1,45 @@
+html {
+ height: 100%;
+}
+
+body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+ background-color: #181818;
+ color: #ffffff;
+}
+A:link, A:visited, A:active {
+ color: #ffffff;
+ text-decoration: none;
+}
+A:hover {
+ color: #ffffff;
+ text-decoration: underline;
+}
+img.arrow {
+ border: 0px;
+ vertical-align: text-top;
+}
+img {
+ border-color: #ffffff;
+}
+img.selected {
+ border-width: 8px;
+}
+#preload {
+ display: none;
+}
+#thumbs {
+ padding: 0 0 4px 0;
+ text-align: center;
+}
+#content {
+ text-align: center;
+}
+#menu_l {
+ float: left;
+}
+#menu_r {
+ float: right;
+}
146 album.js
@@ -0,0 +1,146 @@
+
+function get_thumb_of(name) {
+ if (name.match(".avi"))
+ return name.replace(".avi", ".thm");
+ if (name.match(".AVI"))
+ return name.replace(".AVI", ".THM");
+ return name;
+}
+
+var hash = null;
+
+function anchor() {
+ var anchor;
+
+ if (hash != document.location.hash) {
+ // store complete hash including #
+ hash = document.location.hash;
+ // but strip # for anchor part to pass to select()
+ anchor = hash.substring(1);
+ // when opening from the index, assume no anchor
+ if (hash == "")
+ anchor = "all"; //entries[0];
+ } else {
+ anchor = "all"; //entries[0];
+ }
+
+ return anchor;
+}
+
+function select(entry) {
+ var selected = 0;
+
+ for (count = 0; count < entries.length; count++)
+ if (entry == entries[count])
+ selected = count;
+
+ // are we looking at an album index?
+ if (entry == "all") {
+ var thumbs = "<div style=\"display: inline-block; text-align: center; line-height: 120px;\">\n";
+ // paint all the thumbnails
+ for (count = 0; count < entries.length; count++) {
+ var thumbnailimage = get_thumb_of(entries[count]);
+ if ((count % 5) == 0)
+ thumbs += "<div style=\"clear: both;\"></div>\n";
+ thumbs += "<div style=\"float: left; height: 120px; width: 120px;\"><a href=\"javascript: select('" + entries[count] + "')\">";
+// doesn't work because backrefs are broken atm
+// thumbs += "<div style=\"float: left; height: 120px; width: 120px;\"><a href=\"/" + album + "/#" + entries[count] + "\">";
+ thumbs += "<img style=\"vertical-align: middle;\" src=\"/image.php?r=1&amp;x=100&amp;y=100&amp;i=" + album + "/" + thumbnailimage + "\" /></a>&nbsp;\n</div>\n";
+ }
+ thumbs += "</div>\n";
+
+ // Finished constructing the thumbs div
+ document.getElementById('thumbs').innerHTML = thumbs;
+ return;
+ }
+
+ // determine the range over 9 images to show
+ var start = Math.max(selected - 4, 0);
+ start = Math.min(start, Math.max(0, entries.length - 9));
+ var stop = Math.min(start + 9, entries.length);
+
+ // links to previous 9 images in the thumbs index
+ var thumbs = "";
+ if (start > 0) {
+ var center = Math.max(selected - 9, 0);
+ thumbs += "<a href=\"javascript: select('" + entries[center] + "');\"><img class=\"arrow\" src=\"/go-previous.png\" /></a>\n";
+ }
+
+ // show images start -> stop and put "entry" in display box
+ for (count = start; count < stop; count++) {
+ // thumbnail this
+ var thumbnailimage = get_thumb_of(entries[count]);
+ thumbs += "<a href=\"javascript: select('" + entries[count] + "')\"><img style=\"vertical-align: text-top;\" ";
+ if (selected == count) {
+ thumbs += "class=\"selected\" ";
+ }
+ if (Math.abs(selected - count) <= 1) {
+ thumbs += "src=\"/image.php?r=1&amp;x=100&amp;y=100&amp;i=" + album + "/" + thumbnailimage + "\" /></a>&nbsp;\n";
+ } else {
+ thumbs += "src=\"/image.php?r=1&amp;x=50&amp;y=50&amp;i=" + album + "/" + thumbnailimage + "\" /></a>&nbsp;\n";
+ }
+ }
+
+ // fill preload div
+ var preload = "";
+ if (stop < entries.length) {
+ var thumbnailimage = get_thumb_of(entries[stop]);
+ preload += "<img src=\"/image.php?r=1&amp;x=50&amp;y=50&amp;i=" + album + "/" + thumbnailimage + "\" />\n";
+ }
+
+ if (selected + 2 < entries.length) {
+ var thumbnailimage = get_thumb_of(entries[selected + 2]);
+ preload += "<img src=\"/image.php?r=1&amp;x=100&amp;y=100&amp;i=" + album + "/" + thumbnailimage + "\" />\n";
+ }
+
+ if ((selected + 1) < entries.length) {
+ if (!(entry.match(".avi") || entry.match(".AVI"))) {
+ preload += "<img src=\"/image.php?r=1&amp;x=800&amp;y=800&amp;i=" + album + "/" + entries[selected + 1] + "\" />\n";
+ }
+ }
+ document.getElementById('preload').innerHTML = preload;
+
+ // links to next 9 images in the thumbs index
+ if (stop < entries.length) {
+ var center = Math.min(stop + 5, entries.length)
+ thumbs += "<a href=\"javascript: select('" + entries[center - 1] + "');\"><img class=\"arrow\" src=\"/go-next.png\" /></a>\n";
+ }
+
+ // Finished constructing the thumbs div
+ document.getElementById('thumbs').innerHTML = thumbs;
+
+ var content = "\n";
+
+ // construct the map
+ content += "<map name=\"map-" + entry + "\">\n";
+ if (selected > 0) {
+ content += "<area shape=\"rect\" coords=\"0,0,250,800\" href=\"javascript: select('" + entries[selected - 1] + "')\" />\n";
+ }
+ if (selected < (entries.length - 1)) {
+ content += "<area shape=\"rect\" coords=\"400,0,800,800\" href=\"javascript: select('" + entries[selected + 1] + "')\" />\n";
+ }
+ content += "</map>\n";
+
+ if (selected > 0) {
+ content += "<a href=\"javascript: select('" + entries[selected - 1]+ "');\"><img class=\"arrow\" src=\"/go-previous.png\" /></a>\n";
+ }
+
+ // display selected image
+ if (entry.match(".avi") || entry.match(".AVI")) {
+ // Video display
+ content += "<embed autoplay=\"true\" autostart=\"true\" uimode=\"true\" type=\"application/x-mplayer2\" id=\"MediaPlayer\" src=\"/" + album + "/" + entry + "\" style=\"visibility: visible;\" height=\"480\" width=\"640\" pluginspage=\"http://www.microsoft.com/windows/windowsmedia/download/\">\n";
+ } else {
+ // image display
+ content += "<img class=\"selected\" usemap=\"#map-" + entry + "\" title=\'" + titles[selected] + "\' src=\"/image.php?r=1&amp;x=800&amp;y=800&amp;i=" + album + "/" + entry + "\" />\n";
+ }
+
+ if (selected + 1 < entries.length)
+ content += "<a href=\"javascript: select('" + entries[selected + 1] + "');\"><img class=\"arrow\" src=\"/go-next.png\" /></a>\n";
+
+ content += "<br />\n" + album + " / " + "<a href=\"/" + album + "/" + entry + "\">" + entry + "</a>\n";
+
+ // and display
+ document.getElementById('content').innerHTML = content;
+ document.location.hash = entry;
+}
+
119 album.php
@@ -0,0 +1,119 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- saved from url=(0014)about:internet -->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>album.foo-projects.org</title>
+<link rel="StyleSheet" href="/album.css" title="default" type="text/css" />
+<script type="text/javascript">
+<!--
+<?
+ # store list of items in this album
+ $album = $_GET['a'];
+ $dh = opendir($album);
+ while ($entry = readdir($dh)) {
+ if (!is_file($album . "/" . $entry))
+ continue;
+ if (preg_match('/thm/', $entry))
+ continue;
+ if (preg_match('/THM/', $entry))
+ continue;
+ if ($entry == ".p")
+ continue;
+ $items[] = $entry;
+ }
+ closedir($dh);
+ sort($items);
+
+ echo "var album = \"$album\";\n";
+ echo "var entries = new Array(\n";
+ foreach ($items as $entry) {
+ echo " '$entry'";
+ if ($entry == $items[count($items) - 1]) {
+ echo "\n";
+ } else {
+ echo ",\n";
+ }
+ }
+ echo ");\n";
+
+ echo "var titles = new Array(\n";
+ foreach ($items as $entry) {
+ if (preg_match('/.[jJ][pP][gG]$/', $album . "/" . $entry) == 0) {
+ echo " ''";
+ if ($entry != $items[count($items) - 1])
+ echo ",";
+ echo "\n";
+ continue;
+ }
+ $exif = exif_read_data($album . "/" . $entry, 0, true);
+ $title = "EXIF data from &quot;" . $album . "/" . $entry . "&quot;:&nbsp;";
+ $title .= "Filename: &quot;" . $exif['FILE']['FileName'] . "&quot;, &nbsp;";
+ $title .= "DateTime: &quot;" . $exif['IFD0']['DateTime'] . "&quot;, &nbsp;";
+ $title .= "ExifImageWidth: &quot;" . $exif['EXIF']['ExifImageWidth'] . "&quot;, &nbsp;";
+ $title .= "ExifImageLength: &quot;" . $exif['EXIF']['ExifImageLength'] . "&quot;, &nbsp;";
+ $title .= "Camera Make: &quot;" . $exif['IFD0']['Make'] . "&quot;, &nbsp;";
+ $title .= "Camera Model: &quot;" . $exif['IFD0']['Model'] . "&quot;, &nbsp;";
+ $title .= "ExposureTime: &quot;" . $exif['EXIF']['ExposureTime'] . "&quot;, &nbsp;";
+ $title .= "FNumber: &quot;" . $exif['EXIF']['FNumber'] . "&quot;, &nbsp;";
+ $title .= "ISOSpeedRatings: &quot;" . $exif['EXIF']['ISOSpeedRatings'] . "&quot;, &nbsp;";
+ $title .= "Comment: &quot;" . preg_replace('/[^[:print:]]/', '', $exif['EXIF']['UserComment']) . "&quot;";
+ echo " '" . $title . "'";
+
+ if ($entry != $items[count($items) - 1])
+ echo ",";
+ echo "\n";
+ }
+ echo ");\n";
+
+?>
+-->
+</script>
+<script type="text/javascript" src="/album.js"></script>
+</head>
+
+<?
+ $anchor = $_GET['s'];
+ if ($anchor != "") {
+ $select = $anchor;
+ } else {
+ $select = $items[0];
+ }
+
+ #echo "<body onload=\"javascript:select('$select')\">\n";
+ echo "<body onload=\"javascript:select(anchor())\">\n";
+ if (($album != "") && ($album != ".") && ($album != "..")
+ && (is_file($album))) {
+ # show naviagtion and frame
+ echo "<div style=\"text-align: center;\">\n";
+ echo "<a href=\"/\">Back to albums</a><br />\n";
+ echo "</div>\n";
+ echo "<hr />\n";
+ } else {
+ if (isset($_SERVER['PHP_AUTH_USER'])) {
+ echo "<div id=\"menu_r\">Logged in as <i>" . $_SERVER['PHP_AUTH_USER'] . "</i> (<a href=\"logout.php\">logout</a>)</div>\n";
+ echo "<div id=\"menu_l\">This album is ";
+ if (file_exists($album . "/.p")) {
+ echo "<a href=\"private.php?p=0&a=" . $album . "\">private</a>\n";
+ } else {
+ echo "<a href=\"private.php?p=1&a=" . $album . "\">public</a>\n";
+ }
+ echo "</div>\n";
+ }
+ echo "<div style=\"text-align: center;\">\n";
+ echo "<a href=\"/\">[album index]</a>&nbsp;&nbsp;\n";
+ echo "<a href=\"/$album/\">[view all images]</a>\n";
+ echo "</div>\n";
+ echo "<hr />\n";
+
+ # wrap both parts of the page into a div
+ echo "<div id=\"thumbs\"></div>\n";
+ echo "<div id=\"content\"></div>\n";
+
+ # preload div
+ echo "<div id=\"preload\"></div>\n";
+ }
+?>
+
+</body>
+</html>
22 auth.php
@@ -0,0 +1,22 @@
+<?
+
+function auth($user, $password)
+{
+ $lines = file(".u");
+ foreach ($lines as $line) {
+ list($key, $val) = explode(':', $line);
+
+ if (substr("$val", strlen("$val") - 1, 1) == "\n")
+ # chomp();
+ $val = substr("$val", 0, -1);
+
+ if (($key == $user) &&
+ (crypt($password, $val) == $val)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+?>
25 db.php
@@ -0,0 +1,25 @@
+
+global $db_file = "album.sqlite";
+global $db;
+
+function db_open() {
+ if (!file_exists($db_fil)) {
+ db_create();
+ }
+ $db = sqlite_open($db_file);
+}
+
+function db_create() {
+ $db = new SQLiteDatabase($db_file);
+ $db->query("BEGIN;
+ CREATE TABLE users(
+ id INTEGER PRIMARY KEY,
+ name CHAR(255),
+ password CHAR(255),
+ role INTEGER);
+ INSERT INTO users (name, role) VALUES('admin', '1');
+ COMMIT;");
+
+function db_close() {
+ sqlite_close($db_file);
+}
BIN go-next.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN go-previous.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 image.php
@@ -0,0 +1,129 @@
+<?
+
+$max_x = 800;
+$max_y = 800;
+$width = $_GET['x'];
+$height = $_GET['y'];
+
+$resample = $_GET['r'];
+
+$image = $_GET['i'];
+
+$album = dirname($image);
+
+$cache_path = ".c/" . $album;
+$cache_file = $cache_path . "/" . $witdh . "x" . $height . "-" . basename($image);
+
+if (!is_dir($cache_path))
+ mkdir($cache_path);
+
+header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($image)).' GMT', true, 200);
+header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (80640 * 180)) . ' GMT', true, 200);
+
+preg_match("'^(.*)\.(gif|jpe?g|png|thm)$'i", $image, $ext);
+
+# fetch the (already rotated) cached file if present
+if (file_exists($cache_file)) {
+ switch (strtolower($ext[2])) {
+ case 'jpg':
+ case 'jpeg':
+ case 'thm':
+ header("Content-type: image/jpeg");
+ break;
+ case 'gif':
+ header("Content-type: image/gif");
+ break;
+ case 'png':
+ header("Content-type: image/png");
+ break;
+ default:
+ exit;
+ break;
+ }
+ $fp = fopen($cache_file, "r");
+ fpassthru($fp);
+ fclose($fp);
+ exit;
+}
+
+
+# $o= shell_exec("identify -format \"%[EXIF:Orientation]\" ". escapeshellcmd($image));
+#$o= shell_exec("jhead -exifmap " . escapeshellcmd($image) . " | grep ^Orientation | cut -d: -f2");
+#$o = shell_exec("/usr/bin/exif-orientation.sh " . escapeshellcmd($image));
+$exif = exif_read_data($image, 0, true);
+$o = $exif['IFD0']['Orientation'];
+
+switch (strtolower($ext[2])) {
+case 'jpg':
+case 'jpeg':
+case 'thm':
+ $im = imagecreatefromjpeg($image);
+ header("Content-type: image/jpeg");
+ break;
+case 'gif':
+ $im = imagecreatefromgif($image);
+ header("Content-type: image/gif");
+ break;
+case 'png' :
+ $im = imagecreatefrompng($image);
+ header("Content-type: image/png");
+ break;
+default:
+ exit;
+ break;
+}
+
+list($width_orig, $height_orig) = getimagesize($image);
+
+$ratio_orig = $width_orig / $height_orig;
+
+if ($width/$height > $ratio_orig) {
+ $width = $height * $ratio_orig;
+} else {
+ $height = $width / $ratio_orig;
+}
+
+$save = imagecreatetruecolor($width, $height);
+
+if ( $resample == 1 ) {
+ imagecopyresampled($save, $im, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
+} else {
+ imagecopyresized($save, $im, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
+}
+
+
+switch ($o) {
+case 3:
+ $save = imagerotate($save, 180, 0);
+ break;
+case 6:
+ $save = imagerotate($save, 270, 0);
+ break;
+case 8:
+ $save = imagerotate($save, 90, 0);
+ break;
+}
+
+switch (strtolower($ext[2])) {
+case 'thm' :
+ imagejpeg ($save);
+ break;
+case 'jpg' :
+case 'jpeg':
+ imagejpeg ($save, $cache_file);
+ imagejpeg ($save);
+ break;
+case 'gif' :
+ imagegif ($save, $cache_file);
+ imagegif ($save);
+ break;
+case 'png' :
+ imagepng ($save, $cache_file);
+ imagepng ($save);
+ break;
+}
+
+imagedestroy($im);
+imagedestroy($save);
+
+?>
59 index.php
@@ -0,0 +1,59 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- saved from url=(0014)about:internet -->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>album.foo-projects.org</title>
+<link rel="StyleSheet" href="album.css" title="default" type="text/css">
+</head>
+<body>
+
+<?
+ if (isset($_SERVER['PHP_AUTH_USER'])) {
+ echo "<div id=\"menu_r\">Logged in as <i>" . $_SERVER['PHP_AUTH_USER'] . "</i> (<a href=\"logout.php\">logout</a></div>\n";
+ } else {
+ echo "<div id=\"menu_r\"><a href=\"login.php\">login</a></div>\n";
+ }
+ echo "<div style=\"text-align: center; width: 100%; padding: 5px;\">\n";
+ echo "<a href=\"/\">index</a>\n";
+ echo "</div>\n";
+ echo "<hr />\n";
+ # show list of albums
+ echo "<div style=\"overflow: auto; height: 100%; text-align: center; padding: 5px;\">\n";
+ $dh = opendir(getcwd());
+ while ($entry = readdir($dh)) {
+ if (is_dir($entry) && ($entry != ".") && ($entry != "..") && ($entry != ".c")) {
+ if ((!isset($_SERVER['PHP_AUTH_USER'])) &&
+ file_exists($entry . "/.p"))
+ continue;
+ $albums[] = $entry;
+ }
+ }
+ closedir($dh);
+ rsort($albums);
+
+ echo "<div style=\"display: inline-block;\">\n";
+ foreach ($albums as $entry) {
+ echo "<div style=\"float: left; height: 120px; width: 300px; display: table-cell; line-height: 120px; vertical-align: middle;\"><a href=\"$entry/\">$entry</a></div>\n";
+ # show a few thumbnails of this album, if they exist
+ $n = 0;
+ $top = getcwd();
+ chdir(".c/" . $entry);
+ foreach (glob("x100-*") as $thumb) {
+ $thumb = preg_replace('|x100-|', '', $thumb);
+ echo " <div style=\"display: inline-block; float: left; height: 120px; width: 120px; line-height: 120px;\">";
+ echo " <a href=\"$entry/#$thumb\">";
+ echo "<img style=\"vertical-align: middle;\" src=\"image.php?r=1&amp;x=100&amp;y=100&amp;i=$entry/$thumb\" /></a></div>\n";
+ $n++;
+ if ($n >= 4)
+ break;
+ }
+ chdir($top);
+ echo "<div style=\"clear: both;\"></div>\n";
+
+ }
+ echo "</div>\n";
+?>
+
+</body>
+</html>
43 login.php
@@ -0,0 +1,43 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- saved from url=(0014)about:internet -->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>album.foo-projects.org</title>
+<link rel="StyleSheet" href="album.css" title="default" type="text/css">
+<script type="text/javascript">
+<!--
+function login()
+{
+ var user = document.getElementById('user').value;
+ var password = document.getElementById('password').value;
+ var action = "http://album.foo-projects.org/members.php";
+ var http = new XMLHttpRequest();
+ http.open("GET", action, false, user, password);
+ http.send('');
+ if (http.status == 200) {
+ window.location = "http://album.foo-projects.org/";
+ return true;
+ } else {
+ alert('[' + http.status + ']: Incorrect username or password specified. Please try again.');
+ }
+}
+-->
+</script>
+</head>
+<body>
+ <div style="text-align: center; padding: 5px;">
+ <a href="http://album.foo-projects.org/">album.foo-projects.org</a><br />
+ </div>
+ <hr />
+ <div style="overflow: auto; height: 100%; text-align: center; padding: 5px;">
+ <form>
+ Username: <input id="user" type="text" /><br />
+ Password: <input id="password" type="password" /><br />
+ &nbsp;<br />
+ <input type="button" value="login" onclick="login();" />
+ </form>
+ </div>
+ <div id="message"></div>
+</body>
+</html>
8 logout.php
@@ -0,0 +1,8 @@
+<?
+ header('WWW-Authenticate: Basic realm="album.foo-projects.org"');
+ header('HTTP/1.0 401 Unauthorized');
+ header('HTTP-Status: 401 Unauthorized');
+ echo "<head><meta http-equiv=\"refresh\" content=\"0; URL=http://album.foo-projects.org/\"></head>\n";
+ echo "You have logged out.\n";
+ exit;
+?>
33 members.php
@@ -0,0 +1,33 @@
+<?
+ if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ header('HTTP/1.0 401 Unauthorized');
+ echo "<p>Incorrect login information provided</p>\n";
+ exit;
+ }
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- saved from url=(0014)about:internet -->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>album.foo-projects.org</title>
+<link rel="StyleSheet" href="album.css" title="default" type="text/css">
+</head>
+<body style="width: 1120px;">
+ <div style="text-align: center; padding: 5px;">
+<?
+ if (isset($_SERVER['PHP_AUTH_USER'])) {
+ echo "<div style=\"float: right; ;\">Logged in as <i>" . $_SERVER['PHP_AUTH_USER'] . "</i></div>\n";
+ }
+?>
+ <a href="http://album.foo-projects.org/">album.foo-projects.org</a><br />
+ </div>
+ <hr />
+ <div style="overflow: auto; height: 100%; text-align: center; padding: 5px;">
+<?
+ echo "<h3>Logged in as <i>" . $_SERVER['PHP_AUTH_USER'] . "</i></h3>\n";
+
+?>
+ </div>
+</body>
+</html>
BIN movie.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 private.php
@@ -0,0 +1,18 @@
+<?
+ if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ header('HTTP/1.0 401 Unauthorized');
+ echo "<p>Access denied.</p>\n";
+ exit;
+ }
+
+ $p = $_GET['p'];
+ $a = $_GET['a'];
+
+ if ($p == 0) {
+ if (file_exists($a . "/.p"))
+ unlink($a . "/.p");
+ } else if ($p == 1) {
+ if (!file_exists($a . "/.p"))
+ touch($a . "/.p");
+ }
+ header('Location: album.php?a=' . $a);
94 thumbs.sh
@@ -0,0 +1,94 @@
+#!/bin/bash
+
+renice +20 -p $$
+
+do_folder()
+{
+ if [ ! -d $1 ]; then
+ continue
+ fi
+
+ cd $1
+ mkdir -p ../.c/$1
+ chmod go+rwx ../.c/$1
+ for f in *.jpg *.JPG *.jpeg *.JPEG; do
+ if [ ! -f $f ] ; then
+ continue
+ fi
+
+ # don't need to run jhead if thumbs exist
+ if [ -f ../.c/$1/x50-$f ] &&
+ [ -f ../.c/$1/x100-$f ] &&
+ [ -f ../.c/$1/x800-$f ] ; then
+ continue
+ fi
+
+ # rotate if needed
+ unset R
+ O=$(jhead -exifmap "$f" | grep ^Orientation | cut -d: -f2)
+ case "$O" in
+ *90) R="-rotate 90" ;;
+ *180) R="-rotate 180" ;;
+ *270) R="-rotate 270" ;;
+ esac
+
+ PRINT=
+ if [ ! -f ../.c/$1/x50-$f ]; then
+ PRINT=$f
+ convert $f -resize 50x50 $R ../.c/$1/x50-$f &
+ fi
+ if [ ! -f .c/x100-$f ]; then
+ PRINT=$f
+ convert $f -resize 100x100 $R ../.c/$1/x100-$f &
+ fi
+ if [ ! -f .c/x800-$f ]; then
+ PRINT=$f
+ convert $f -resize 800x800 $R ../.c/$1/x800-$f &
+ fi
+ if [ -n "$PRINT" ]; then
+ echo -n "$1 - $PRINT"
+ fi
+
+ wait
+ if [ -n "$PRINT" ]; then
+ echo
+ fi
+ done
+
+ for f in *.avi *.AVI *.mpg *.MPG; do
+ if [ ! -f $f ]; then
+ continue
+ fi
+ t=${f//.avi/.thm}
+ t=${t//.AVI/.THM}
+ t=${t//.mpg/.thm}
+ t=${t//.MPG/.THM}
+
+ if [ -f $t ]; then
+ continue
+ else
+ cp ../movie.jpg $t
+ echo "$1 - $t"
+ fi
+ done
+
+ cd ..
+}
+
+if [ -n "$1" ] ; then
+ FOLDERS="$@"
+else
+ # might not work for other setups
+ FOLDERS=200*
+fi
+
+if ! jhead -V > /dev/null; then
+ echo "This script requires 'jhead' to be installed"
+ exit
+fi
+
+for n in $FOLDERS ; do
+ echo $n
+ do_folder $n
+done
+
78 upload.php
@@ -0,0 +1,78 @@
+<?
+ if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ header('HTTP/1.0 401 Unauthorized');
+ echo "<p>Incorrect login information provided</p>\n";
+ exit;
+ }
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!-- saved from url=(0014)about:internet -->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>album.foo-projects.org</title>
+<link rel="StyleSheet" href="album.css" title="default" type="text/css">
+</head>
+<body>
+ <div style="text-align: center; padding: 5px;">
+<?
+ echo "<div style=\"float: right; ;\">Logged in as <i>" . $_SERVER['PHP_AUTH_USER'] . "</i></div>\n";
+?>
+ <a href="http://album.foo-projects.org/">album.foo-projects.org</a><br />
+ </div>
+ <hr />
+ </div>
+ <div style="text-align: center;">
+<?
+ if (!isset($_GET['a'])) {
+ echo "<h3>I need an album to upload files into...</h3>";
+ exit;
+ }
+
+ $album = $_GET['a'];
+ if (!is_dir($album)) {
+ echo "<h3>Not a valid album</h3>";
+ exit;
+ }
+
+ if (empty($_FILES['images'])) {
+ # nothing uploaded - display upload forms
+ echo "<form enctype=\"multipart/form-data\" action=\"/upload.php?a=" . $album . "\" method=\"POST\">\n";
+ echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"8000000\" />\n";
+ echo "Upload files: <br />\n";
+ echo "<div id=\"upload\">\n";
+ echo "<input size=\"50\" name=\"images[]\" type=\"file\" /><br />\n";
+ echo "<input size=\"50\" name=\"images[]\" type=\"file\" /><br />\n";
+ echo "<input size=\"50\" name=\"images[]\" type=\"file\" /><br />\n";
+ echo "<input size=\"50\" name=\"images[]\" type=\"file\" /><br />\n";
+ echo "<input size=\"50\" name=\"images[]\" type=\"file\" /><br />\n";
+ echo "</div>\n";
+ echo "<br /><input type=\"submit\" value=\"Upload Files\" />\n";
+ echo "</form>\n\n";
+ } else {
+ # handle uploaded files
+ foreach ($_FILES["images"]["error"] as $key => $error) {
+ if ($error == UPLOAD_ERR_OK) {
+ $tmp_name = $_FILES["images"]["tmp_name"][$key];
+ $name = $_FILES["images"]["name"][$key];
+ # don't overwrite
+ if (file_exists("$album/$name")) {
+ echo "<p>Upload of \"$name\" failed! That image already exists in this the album \"$album\"!</p>\n";
+
+ } else {
+ move_uploaded_file($tmp_name, "$album/$name");
+
+ # display this image as a preview thumb
+ echo "<p>Uploaded \"$name\" OK! <img src=\"image.php?r=1&amp;x=100&amp;y=100&amp;i=$album/$name\" /></p>\n";
+ }
+ }
+ }
+ # and link back to uploading more stuff
+ echo "<p><a href=\"upload.php?a=" . $album . "\">upload more images to this album...</a></p>\n";
+ }
+ echo "<p><a href=\"album.php?a=" . $album . "\">go back to the album view...</a></p>\n";
+?>
+ </div>
+
+</body>
+</html>

0 comments on commit 22c1104

Please sign in to comment.
Something went wrong with that request. Please try again.