commit 4fcec884a502971c89588631f09f1419401a6242
Author: Eric Seigne <eric.seigne@ryxeo.com>
Date:   Sat Jun 9 15:46:53 2012 +0200

    nettoyage / commentaires / indentation

diff --git a/www/inc/config.inc.php b/www/inc/config.inc.php
index a4324a1..2e4a1ca 100644
--- a/www/inc/config.inc.php
+++ b/www/inc/config.inc.php
@@ -1,83 +1,82 @@
 <?php
-#base dirname
-  $root = dirname(dirname(__FILE__) . "../");
-# ===========================================================================
-# dir index
-	 $sortinmonth = 0;// 1 - alphabetically
-	 								  // 0 - by date (reverse)
+//base dirname
+$root = dirname(dirname(__FILE__) . "../");
+// ===========================================================================
+// dir index
+$sortinmonth = 0;// 1 - alphabetically
+// 0 - by date (reverse)
 
-# ===========================================================================
-# default languages
-# use UA's accept language
+// ===========================================================================
+// default languages
+// use UA's accept language
 require_once("$root/inc/l10nget.inc.php"); //get from UA
 if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
-	$sclang = get_lang_from_agent($_SERVER["HTTP_ACCEPT_LANGUAGE"]);
-} else {
-	$sclang = "en";
+  $sclang = get_lang_from_agent($_SERVER["HTTP_ACCEPT_LANGUAGE"]);
+ } else {
+  $sclang = "fr";
 }
 l10n::set("$root/l10n/".$GLOBALS['sclang']."/exif.lang");
 
-# ===========================================================================
-#Name to dsplay on the gallery
-$scnamegallery = "Photo Gallery Index";
+// ===========================================================================
+//Name to dsplay on the gallery
+$scnamegallery = "Album photo";
 
+// ===========================================================================
+// albums to show
+$yearsince = 2009;
+//images FIXME - this is stylesheet's job
+$img["left"] = "left.png";
+$img["right"] = "right.png";
+$img["top"] = "top.png";
+// ===========================================================================
+//thumbnail behaviour
+//keep this unset for dynamic thumbnail size
+//$thumbsize = "fixed";
+//How the previous and Next thumbnails should be scaled
+// 1 is 1:1, >1 is smaller, <1 is bigger
+$PNthumbScale = 1.5;
+// Photos Copyright
+//	CHANGE THIS! I am not trying to take over the world ;)
+$copy = "Software : GNU/GPL <a href=\"http://jimmac.musichall.cz/original.php\">Original</a> Copyright &copy; 1999-2005 Jakub Steiner - End user interface <a href=\"http://www.ryxeo.com/WebPhotoAlbum.html\">RyXeo WebPhotoAlbum</a> &copy; 2012 Eric Seigne";
+//app info
+$app["name"] = "RyXeo WebPhotoAlbum"; // opensource remote image gallery,
+// initialy not as lovely 
+$app["url"] = "http://www.ryxeo.com/WebPhotoAlbum.html";
+$app["version"] = "1.0";
+$exif_show = array("DateTime"=>__("Time Taken"), 
+		   "Make"=>__("Camera Manufacturer"), 
+		   "Model"=>__("Camera Model"), 
+		   "FocalLength"=>__("Real Focal Length"), 
+		   "FocalLengthIn35mmFilm"=>__("Focal Length Relative to 35mm Film"),
+		   "FNumber"=>__("F Stop"), 
+		   "Copyright"=>__("Copyright"), 
+		   "Artist"=>__("Artist"), 
+		   "ExposureTime"=>__("Time of Exposure"), 
+		   "ISOSpeedRatings"=>__("Film/Chip Sensitivity"),
+		   "Flash"=>__("Flash"));
+// ===========================================================================
+// Gallery Directory
+// This is a path relative to the directory where original is installed
+// eg. it can be "../galleries" to use a galleries dir above the original dir.
+$gallery_dir="galleries";
 
-# ===========================================================================
-# albums to show
-   $yearsince = 1999;
-#images FIXME - this is stylesheet's job
-   $img["left"] = "left.png";
-   $img["right"] = "right.png";
-   $img["top"] = "top.png";
-# ===========================================================================
-#thumbnail behaviour
-   //keep this unset for dynamic thumbnail size
-   //$thumbsize = "fixed";
-   //How the previous and Next thumbnails should be scaled
-   // 1 is 1:1, >1 is smaller, <1 is bigger
-   $PNthumbScale = 1.5;
-# Photos Copyright
-#	CHANGE THIS! I am not trying to take over the world ;)
-	 $copy = "Software : GNU/GPL <a href=\"http://jimmac.musichall.cz/original.php\">Original</a> Copyright &copy; 1999-2005 Jakub Steiner - End user interface <a href=\"http://www.ryxeo.com/WebPhotoAlbum.html\">RyXeo WebPhotoAlbum</a> &copy; 2012 Eric Seigne";
-#app info
-   $app["name"] = "RyXeo WebPhotoAlbum"; // opensource remote image gallery,
-                              // initialy not as lovely 
-   $app["url"] = "http://www.ryxeo.com/WebPhotoAlbum.html";
-   $app["version"] = "1.0";
-   $exif_show = array("DateTime"=>__("Time Taken"), 
-		      "Make"=>__("Camera Manufacturer"), 
-		      "Model"=>__("Camera Model"), 
-		      "FocalLength"=>__("Real Focal Length"), 
-		      "FocalLengthIn35mmFilm"=>__("Focal Length Relative to 35mm Film"),
-		      "FNumber"=>__("F Stop"), 
-		      "Copyright"=>__("Copyright"), 
-		      "Artist"=>__("Artist"), 
-		      "ExposureTime"=>__("Time of Exposure"), 
-		      "ISOSpeedRatings"=>__("Film/Chip Sensitivity"),
-		      "Flash"=>__("Flash"));
-# ===========================================================================
-## Gallery Directory
-# This is a path relative to the directory where original is installed
-# eg. it can be "../galleries" to use a galleries dir above the original dir.
-  $gallery_dir="galleries";
-
-#Enable this to access extended tracking functionality
-#depends on sqlite
+//Enable this to access extended tracking functionality
+//depends on sqlite
 $have_sqlite = 0;
 
-# This controls wheather web visitors will be able to post
-# comments to images
+// This controls wheather web visitors will be able to post
+// comments to images
 $comments = 1;
 
-# Access Log/Counter
-# $log_access = 0; // no access logging
+// Access Log/Counter
+// $log_access = 0; // no access logging
 $log_access = 1; 
 
-#css styles
-   $themes = array(
-               "dark" => "inc/styles/dark/dark.css",
-               "classic" => "inc/styles/classic/classic.css",
-               "gorilla" => "inc/styles/gorilla/gorilla.css"
-   );
+//css styles
+$themes = array(
+		"dark" => "inc/styles/dark/dark.css",
+		"classic" => "inc/styles/classic/classic.css",
+		"gorilla" => "inc/styles/gorilla/gorilla.css"
+		);
 
 ?>
diff --git a/www/inc/funkce.inc.php b/www/inc/funkce.inc.php
index 27e1dbd..4195422 100644
--- a/www/inc/funkce.inc.php
+++ b/www/inc/funkce.inc.php
@@ -1,124 +1,124 @@
 <?php
 
 function check($file) {
-   global $gallery_dir, $page;
+  global $gallery_dir, $page;
    
-#   if (eregi("[^0-9a-z\_\-\ ]",$file) || !file_exists("$gallery_dir/$file")) {
-#   if (eregi("CVS",$file) || !file_exists("$gallery_dir/$file")) {
-   if (!file_exists("$gallery_dir/$file")) {
-      echo "funkce.inc.php/check(): Bad input";
-      $page->footer();
-      exit;
-   }
-}
+  //   if (eregi("[^0-9a-z\_\-\ ]",$file) || !file_exists("$gallery_dir/$file")) {
+  //   if (eregi("CVS",$file) || !file_exists("$gallery_dir/$file")) {
+  if (!file_exists("$gallery_dir/$file")) {
+    echo "funkce.inc.php/check(): Bad input";
+    $page->footer();
+    exit;
+  }
+  }
 
 function browserCheck() {
-   global $HTTP_USER_AGENT;
+  global $HTTP_USER_AGENT;
    
-	 $HTTP_USER_AGENT=$_SERVER["HTTP_USER_AGENT"];
-   if (eregi("(MSIE.[456789]).*Mac.*",$HTTP_USER_AGENT)) {
-        return("macie4+");
-   } elseif (eregi("(MSIE.[678])",$HTTP_USER_AGENT)) {
-        return("ie6+");
-   } elseif (eregi("(MSIE.[45])",$HTTP_USER_AGENT)) {
-        return("ie4+");
-   } elseif (eregi("Opera",$HTTP_USER_AGENT)) {
-        return("opera");
-   } elseif (eregi("(Mozilla.4)",$HTTP_USER_AGENT)) {
-        return("netscape4");
-   } elseif (eregi("(Mozilla.[5-9])",$HTTP_USER_AGENT)) {
-        return("mozilla");
-   } elseif (eregi("KMeleon",$HTTP_USER_AGENT)) {
-        return("mozilla");
-   } else {
-        return("Netscape3");
-   }
+  $HTTP_USER_AGENT=$_SERVER["HTTP_USER_AGENT"];
+  if (eregi("(MSIE.[456789]).*Mac.*",$HTTP_USER_AGENT)) {
+    return("macie4+");
+  } elseif (eregi("(MSIE.[678])",$HTTP_USER_AGENT)) {
+    return("ie6+");
+  } elseif (eregi("(MSIE.[45])",$HTTP_USER_AGENT)) {
+    return("ie4+");
+  } elseif (eregi("Opera",$HTTP_USER_AGENT)) {
+    return("opera");
+  } elseif (eregi("(Mozilla.4)",$HTTP_USER_AGENT)) {
+    return("netscape4");
+  } elseif (eregi("(Mozilla.[5-9])",$HTTP_USER_AGENT)) {
+    return("mozilla");
+  } elseif (eregi("KMeleon",$HTTP_USER_AGENT)) {
+    return("mozilla");
+  } else {
+    return("Netscape3");
+  }
 }
 
 function infoParse ($infofile) {
 	
-	$info_array = file($infofile);
-	foreach ($info_array as $line) {
-		list($key,$value) = split("\|",$line);
-		$result[$key]=$value;
-	}
-	return $result;
+  $info_array = file($infofile);
+  foreach ($info_array as $line) {
+    list($key,$value) = split("\|",$line);
+    $result[$key]=$value;
+  }
+  return $result;
 }
 
 function readInfo ($infofile, $file) {
-	global $galerieyear, $galeriemonth, $galerieday, $galeriedesc, $galerieauthor,
-	       $galeriename, $galerielogin, $galeriepw, $gallery_dir;
+  global $galerieyear, $galeriemonth, $galerieday, $galeriedesc, $galerieauthor,
+    $galeriename, $galerielogin, $galeriepw, $gallery_dir;
 	
-	if (file_exists($infofile)) {
-		//read from info.txt
-		$info_array = infoParse($infofile);
-		if ($info_array["date"]) {
-			// try to be a little smarter about format
-			if (ereg("([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})",
-				$info_array["date"])) {
-				// remain compatible - DD.MM.YYYY
-				list($day,$month,$year) = split("\.", $info_array["date"]);
-				$year = rtrim($year);
-				$month = rtrim($month);
-				$day = rtrim($day);
-				$info_array["date"] = "$year-$month-$day"; //make it US date
-			}
-			// US date format at this point
-			$tstamp = strtotime($info_array["date"]);
-		} else {
-			$tstamp = filemtime("$gallery_dir/$file");// Get from filesystem
-		}
-		$galerieyear["$file"] = date("Y", $tstamp);
-		$galeriemonth["$file"] = date("m", $tstamp);
-		$galerieday["$file"] = date("d", $tstamp);
+  if (file_exists($infofile)) {
+    //read from info.txt
+    $info_array = infoParse($infofile);
+    if ($info_array["date"]) {
+      // try to be a little smarter about format
+      if (ereg("([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})",
+	       $info_array["date"])) {
+	// remain compatible - DD.MM.YYYY
+	list($day,$month,$year) = split("\.", $info_array["date"]);
+	$year = rtrim($year);
+	$month = rtrim($month);
+	$day = rtrim($day);
+	$info_array["date"] = "$year-$month-$day"; //make it US date
+      }
+      // US date format at this point
+      $tstamp = strtotime($info_array["date"]);
+    } else {
+      $tstamp = filemtime("$gallery_dir/$file");// Get from filesystem
+    }
+    $galerieyear["$file"] = date("Y", $tstamp);
+    $galeriemonth["$file"] = date("m", $tstamp);
+    $galerieday["$file"] = date("d", $tstamp);
 		
-		if (@$info_array["description"]) {
-			$galeriedesc["$file"] = rtrim($info_array["description"]);
-		}
+    if (@$info_array["description"]) {
+      $galeriedesc["$file"] = rtrim($info_array["description"]);
+    }
 		
-		if (@$info_array["author"]) {
-			$galerieauthor["$file"] = rtrim($info_array["author"]);
-		}
+    if (@$info_array["author"]) {
+      $galerieauthor["$file"] = rtrim($info_array["author"]);
+    }
 		
-		if (@$info_array["name"]) {
-			$galeriename["$file"] = rtrim($info_array["name"]);
-		}
+    if (@$info_array["name"]) {
+      $galeriename["$file"] = rtrim($info_array["name"]);
+    }
 		
-		if (@$info_array["restricted_user"]) {
-			$galerielogin["$file"] = rtrim($info_array["restricted_user"]);
-			$galeriepw["$file"] = rtrim($info_array["restricted_password"]);
-		}
- } else { // Get Dates from modification stamp
-		$mtime = filemtime("$gallery_dir/$file");
-		$galerieyear["$file"] = date("Y", $mtime);
-		$galeriemonth["$file"] = date("m", $mtime); //F
-		$galerieday["$file"] = date("d", $mtime);
- }
+    if (@$info_array["restricted_user"]) {
+      $galerielogin["$file"] = rtrim($info_array["restricted_user"]);
+      $galeriepw["$file"] = rtrim($info_array["restricted_password"]);
+    }
+  } else { // Get Dates from modification stamp
+    $mtime = filemtime("$gallery_dir/$file");
+    $galerieyear["$file"] = date("Y", $mtime);
+    $galeriemonth["$file"] = date("m", $mtime); //F
+    $galerieday["$file"] = date("d", $mtime);
+  }
 }
 
 function access_check($login, $password,$realm) {
-   if (!($_SERVER['PHP_AUTH_USER']=="$login" && $_SERVER['PHP_AUTH_PW']=="$password")) {
-      header("WWW-authenticate: Basic Realm=$realm");
-      Header("HTTP/1.0 401 Unauthorized");
-			$err = new C_www;
-      $err->header("Access Denied");
-			echo "<div class=\"error\">\n";
-			echo "<h1>Access Denied</h1>\n";
-			echo "<p>Sorry, this gallery is restricted</p>\n";
-			echo "<p><a href=\"index.php\">Return to index</a></p>\n";
-			echo "</div>\n";
-			$err->footer();
-      exit;
-   }
+  if (!($_SERVER['PHP_AUTH_USER']=="$login" && $_SERVER['PHP_AUTH_PW']=="$password")) {
+    header("WWW-authenticate: Basic Realm=$realm");
+    Header("HTTP/1.0 401 Unauthorized");
+    $err = new C_www;
+    $err->header("Access Denied");
+    echo "<div class=\"error\">\n";
+    echo "<h1>Access Denied</h1>\n";
+    echo "<p>Sorry, this gallery is restricted</p>\n";
+    echo "<p><a href=\"index.php\">Return to index</a></p>\n";
+    echo "</div>\n";
+    $err->footer();
+    exit;
+  }
 
 }
 
 function random_digits($times) {
-	$random="";
-	for ($i=0;$i<$times;$i++) {
-		$random .= rand(0,9);
-	}
-	return $random;
+  $random="";
+  for ($i=0;$i<$times;$i++) {
+    $random .= rand(0,9);
+  }
+  return $random;
 }
 
 function get_photo_title($galerie, $id) {
diff --git a/www/index.php b/www/index.php
index b925fd5..e61027b 100644
--- a/www/index.php
+++ b/www/index.php
@@ -1,8 +1,8 @@
 <?php
-# uncomment this to check for uninitialized variables etc.:
-# error_reporting (E_ALL);
+// uncomment this to check for uninitialized variables etc.:
+// error_reporting (E_ALL);
 
-#language support
+//language support
 require_once ("lib/lib.l10n.php");
 require_once("inc/config.inc.php");
 require_once("inc/www.class.inc.php");
@@ -10,17 +10,14 @@ require_once("inc/funkce.inc.php");
 //session_name("navstevnik");
 //session_register("page");
 
-#set the language translation
+//set the language translation
 l10n::set("$root/l10n/".$sclang."/main.lang");
 l10n::set("$root/l10n/".$sclang."/date.lang");
 
-
-
-
-# always get sorted directory entries
+// always get sorted directory entries
 $adr = new SortDir("$gallery_dir");
 
-# get variables passed in from the URL:
+// get variables passed in from the URL:
 $galerie='';
 if (isset($_GET['galerie'])) $galerie=$_GET["galerie"];
 if (isset($_GET['gallery'])) $galerie=$_GET["gallery"];
@@ -42,16 +39,16 @@ $page = new C_www;
 
 if (!is_dir("$gallery_dir/$galerie/thumbs")) {
   $galerie = "";
-}
+ }
 
 //read interesting stuff from info.txt
 if ($galerie) { 
-	readInfo("$root/$gallery_dir/$galerie/info.txt", $galerie);
-//check for restricted access
-	if ($galerielogin[$galerie]) {
-			 access_check($galerielogin[$galerie],$galeriepw[$galerie],$galerie);
-	}
-}
+  readInfo("$root/$gallery_dir/$galerie/info.txt", $galerie);
+  //check for restricted access
+  if ($galerielogin[$galerie]) {
+    access_check($galerielogin[$galerie],$galeriepw[$galerie],$galerie);
+  }
+ }
 
 $page->process_comment_form();
 
@@ -60,8 +57,8 @@ $page->process_comment_form();
 //ryxeo
 if($_GET['slideshow'] == 'play')
   $slideshow = true;
-else
-  $slideshow = false;
+ else
+   $slideshow = false;
 
 if($_GET['directdownload'] == "true") {
   require_once("$root/inc/photo.class.inc.php");
@@ -78,7 +75,7 @@ if($_GET['directdownload'] == "true") {
   readfile($picture->preview);
   //print_r($picture);
   exit;
-}
+ }
 
 $page->header("Photos");
 require("inc/header.inc.php");
@@ -87,332 +84,332 @@ require("inc/header.inc.php");
 //print "<div class=\"navigation\"><a href=\"$ThisScript\">" . $scnamegallery . "</a>";
 print "<div class=\"navigation\"><a href=\"./\">" . $scnamegallery . "</a>";
 
-#############################
-# 	Overall Gallery Index		#
-#############################
+//############################
+// 	Overall Gallery Index
+//############################
 if (!$galerie) {
-   # finish off navigation bar
-   print "</div>\n\n<!-- listing galleries-->\n\n";  
-	 # I've nuked date.txt to replace it with a more generic info.txt
-   # It optionally supplies i18n name, camera model, author and date
-	 # TODO: imgconv script support
-   while ($file = $adr->Read()) {
-      // checking for inc is only really needed when gallery_dir == $root
-      // hopefully not many galleries will be named inc ;)
-      if (is_dir("$gallery_dir/$file") && !ereg("\.", $file) && $file!="inc") { 
-         // Use date file for gallery date if avaliable
-				 // info.txt format described in README
-         readInfo("$root/$gallery_dir/$file/info.txt", $file);
-         
-      }
-   }
-
-	 if (!isset($galeriemonth)) $galeriemonth = array();
-   if (!isset($galerieday)) $galerieday = array();
-	 //sort within month depending on $sortinmonth
-	 if ($sortinmonth) {
-		 //alphabetically
-		 ksort($galeriemonth);
-		 reset($galeriemonth);
-	 } else {//by date
-		 arsort($galerieday);
-		 reset($galerieday);
-	 }
-
-
-	 $thisyear = 0;
-	 if (!$yearto) $yearto = date("Y");
-   for ($i = $yearto; $i >= $yearsince; $i--) {
-      for ($thismonth=12; $thismonth>0; $thismonth--) { // go year by year, month by month
-																												// down
-				 foreach ($galerieday as $foldername => $day) { //using $galerieday (for when sorted)
-						if ($galeriemonth["$foldername"] == $thismonth && 
-							      $galerieyear["$foldername"] == $i) { //such Y/M exists
-
-								$galerieyearordered["$foldername"]=$galerieyear["$foldername"];
-								$galeriemonthordered["$foldername"]=$galeriemonth["$foldername"];
-						}
-				 }
+  // finish off navigation bar
+  print "</div>\n\n<!-- listing galleries-->\n\n";  
+  // I've nuked date.txt to replace it with a more generic info.txt
+  // It optionally supplies i18n name, camera model, author and date
+  // TODO: imgconv script support
+  while ($file = $adr->Read()) {
+    // checking for inc is only really needed when gallery_dir == $root
+    // hopefully not many galleries will be named inc ;)
+    if (is_dir("$gallery_dir/$file") && !ereg("\.", $file) && $file!="inc") { 
+      // Use date file for gallery date if avaliable
+      // info.txt format described in README
+      readInfo("$root/$gallery_dir/$file/info.txt", $file);
+      
+    }
+  }
+  
+  if (!isset($galeriemonth)) $galeriemonth = array();
+  if (!isset($galerieday)) $galerieday = array();
+  //sort within month depending on $sortinmonth
+  if ($sortinmonth) {
+    //alphabetically
+    ksort($galeriemonth);
+    reset($galeriemonth);
+  } else {//by date
+    arsort($galerieday);
+    reset($galerieday);
+  }
+  
+  
+  $thisyear = 0;
+  if (!$yearto) $yearto = date("Y");
+  for ($i = $yearto; $i >= $yearsince; $i--) {
+    for ($thismonth=12; $thismonth>0; $thismonth--) { // go year by year, month by month
+      // down
+      foreach ($galerieday as $foldername => $day) { //using $galerieday (for when sorted)
+	if ($galeriemonth["$foldername"] == $thismonth && 
+	    $galerieyear["$foldername"] == $i) { //such Y/M exists
+	  
+	  $galerieyearordered["$foldername"]=$galerieyear["$foldername"];
+	  $galeriemonthordered["$foldername"]=$galeriemonth["$foldername"];
+	}
       }
-   }
-
-
-	 $months = array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'),
-	 __('September'), __('October'), __('November'), __('December'));
-	 $one_out = false;
-	 foreach ($galerieyearordered as $foldername => $year) {
-		  $one_out = true;
-			if (@$thisyear!=$year) { #if the year is not equal to the current year
-				 #This is the first year
-				 if (@$thisyear) { print "   </div>\n</div>\n";}// end last year if this is 
-																				 // not the first one
-				 #This is a new year
-				 unset($thismonth);
-				 print "<div class=\"year\"><h3>$year</h3>\n";
-				 print "";
-			}
-			$month=$galeriemonth["$foldername"];
-			# now months
-			if (@$thismonth!=$month) {
-				 #first one
-				 if (@$thismonth) { print "   </div>\n"; } // end of last month if
-																							// this is not the first one
-				 #new month
-				 $monthindex = $month - 1;
-				 $monthname = $months[$monthindex];
-				 print "   <div class=\"month\"><h4>$monthname</h4>\n";
-			}
-			#galleries within month	
-			if ($galerielogin[$foldername]) {
-				print "      <p class=\"restricted\"><a ";
-			} else {
-				print "      <p><a ";
-			}
-			if (@$galeriename[$foldername]) {
-				print " href=\"$ThisScript?galerie=$foldername\">";
-				print $galeriename[$foldername];
-				print "</a>";
-			} else {
-				print " href=\"$ThisScript?galerie=$foldername\">$foldername</a>";
-			}
-			if (@$galeriedesc[$foldername]) {
-				print "<span class=\"desc\">" . $galeriedesc[$foldername];
-				print "</span>\n";
-			}
-			if (@$galerieauthor[$foldername]) {
-				print "<span class=\"author\">by&nbsp;" . $galerieauthor[$foldername];
-				print "</span>\n";
-			}
-			if (@$galerieday[$foldername]) {
-				print "<span class=\"date\">";
-				print "$monthname&nbsp;" . $galerieday[$foldername];
-				print "</span>\n";
-			}
-			print "</p>\n";
-			$thisyear=$year;
-			$thismonth=$month;
-	 }
-	 if ($one_out) print ("   </div>\n</div>\n\n");
+    }
+  }
+  
+  
+  $months = array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'),
+		  __('September'), __('October'), __('November'), __('December'));
+  $one_out = false;
+  foreach ($galerieyearordered as $foldername => $year) {
+    $one_out = true;
+    if (@$thisyear!=$year) { //if the year is not equal to the current year
+      //This is the first year
+      if (@$thisyear) { print "   </div>\n</div>\n";}// end last year if this is 
+      // not the first one
+      //This is a new year
+      unset($thismonth);
+      print "<div class=\"year\"><h3>$year</h3>\n";
+      print "";
+    }
+    $month=$galeriemonth["$foldername"];
+    // now months
+    if (@$thismonth!=$month) {
+      //first one
+      if (@$thismonth) { print "   </div>\n"; } // end of last month if
+      // this is not the first one
+      //new month
+      $monthindex = $month - 1;
+      $monthname = $months[$monthindex];
+      print "   <div class=\"month\"><h4>$monthname</h4>\n";
+    }
+    //galleries within month	
+    if ($galerielogin[$foldername]) {
+      print "      <p class=\"restricted\"><a ";
+    } else {
+      print "      <p><a ";
+    }
+    if (@$galeriename[$foldername]) {
+      print " href=\"$ThisScript?galerie=$foldername\">";
+      print $galeriename[$foldername];
+      print "</a>";
+    } else {
+      print " href=\"$ThisScript?galerie=$foldername\">$foldername</a>";
+    }
+    if (@$galeriedesc[$foldername]) {
+      print "<span class=\"desc\">" . $galeriedesc[$foldername];
+      print "</span>\n";
+    }
+    if (@$galerieauthor[$foldername]) {
+      print "<span class=\"author\">by&nbsp;" . $galerieauthor[$foldername];
+      print "</span>\n";
+    }
+    if (@$galerieday[$foldername]) {
+      print "<span class=\"date\">";
+      print "$monthname&nbsp;" . $galerieday[$foldername];
+      print "</span>\n";
+    }
+    print "</p>\n";
+    $thisyear=$year;
+    $thismonth=$month;
+  }
+  if ($one_out) print ("   </div>\n</div>\n\n");
    
-##############################
-#  Individual Gallery Index  #
-##############################
-} elseif (!$snimek) {
+  //#############################
+  //  Individual Gallery Index  #
+  //#############################
+ } elseif (!$snimek) {
 	 
-   # finish off navigation header
+   // finish off navigation header
 	 
    print "\n &gt; ";
-	 if ($galeriename[$galerie]) {
-		 print $galeriename[$galerie];
-	 } else {
-		 print $galerie;
-	 }
-	 print "</div>\n\n";
+   if ($galeriename[$galerie]) {
+     print $galeriename[$galerie];
+   } else {
+     print $galerie;
+   }
+   print "</div>\n\n";
 
-	 //thumbnails
-	 print "<p class=\"bigthumbnails\">\n";
+   //thumbnails
+   print "<p class=\"bigthumbnails\">\n";
    $path = "$gallery_dir/$galerie/thumbs";
    $imgfiles = new SortDir($path);
    check($galerie); // check for nasty input
    while ($file = $imgfiles->read()) {
-      if (is_file("$path/$file") && eregi("^img-([0-9]+)\.(png|jpe?g)", $file, $x)) {
+     if (is_file("$path/$file") && eregi("^img-([0-9]+)\.(png|jpe?g)", $file, $x)) {
 				 				 
-         $thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}";
-         $imgsize = getimagesize("$root/$thumb");
-				 //check for portraits
-				 $portrait = "false";
-				 $class = "";
-				 if($imgsize[0]<100) {
-					 //portraits need a special class for styling
-					 $class = "portrait";
-				 }
-				 //check for number of comments per photo
-				 if ($comments) { //there probably won't be user comments if it's off
-				   $NumOfComments = 0;
-					 if (file_exists("$gallery_dir/$galerie/comments/user_${x[1]}.txt")) {
-							if ($class) $class .= " ";
-							$class .= "hascomments";
-							//now let's count'em
-							$fh = fopen("$gallery_dir/$galerie/comments/user_${x[1]}.txt","r");
-							while (!feof($fh)) {
-								$line = fgets($fh);
-								if (eregi("commententry",$line)) $NumOfComments++;
-							}
-							fclose($fh);
-					 }
-					 if ($NumOfComments==1) {
-						 $NumOfComments = $NumOfComments . " " . __('Comment');
-					 } else {
-						 $NumOfComments = $NumOfComments . " " . __('Comments');
-					 }
-				 }
-	 if (file_exists("$gallery_dir/$galerie/comments/${x[1]}.txt") &&
-		   $title = file_get_contents("$gallery_dir/$galerie/comments/${x[1]}.txt")) {
-	     $title = ereg_replace("(\"|\')","",trim(strip_tags($title)));
-	     $title = ereg_replace("(.{77}).*","\\1",$title);
-	 } else 
-	   $title = "Photo ${x[1]}";
-
-         print "   <a href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}\"";
-				 print " title=\"$title, $NumOfComments\"";
-				 if ($class) print " class=\"$class\"";
-				 print ">";
-         print "<img ";
-         if (isset($thumbsize)) {
-            print "width=\"120\" height=\"80\" ";
-         } else {
-            // scale portraits to 80 height
-            if ($portrait) {
-							//portrait
-               print "width=\"";
-               $scaled = round($imgsize[0] / 1.5);
-               print $scaled;
-               print "\" height=\"${imgsize[0]}\"";
-            } else {
-							//landscape
-               print $imgsize[3]; 
-            }
-         }
-         print " src=\"$thumb\" ";
-         print "alt=\"photo No. ${x[1]}\" />";
-         print "</a>\n";
-      }
+       $thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}";
+       $imgsize = getimagesize("$root/$thumb");
+       //check for portraits
+       $portrait = "false";
+       $class = "";
+       if($imgsize[0]<100) {
+	 //portraits need a special class for styling
+	 $class = "portrait";
+       }
+       //check for number of comments per photo
+       if ($comments) { //there probably won't be user comments if it's off
+	 $NumOfComments = 0;
+	 if (file_exists("$gallery_dir/$galerie/comments/user_${x[1]}.txt")) {
+	   if ($class) $class .= " ";
+	   $class .= "hascomments";
+	   //now let's count'em
+	   $fh = fopen("$gallery_dir/$galerie/comments/user_${x[1]}.txt","r");
+	   while (!feof($fh)) {
+	     $line = fgets($fh);
+	     if (eregi("commententry",$line)) $NumOfComments++;
+	   }
+	   fclose($fh);
+	 }
+	 if ($NumOfComments==1) {
+	   $NumOfComments = $NumOfComments . " " . __('Comment');
+	 } else {
+	   $NumOfComments = $NumOfComments . " " . __('Comments');
+	 }
+       }
+       if (file_exists("$gallery_dir/$galerie/comments/${x[1]}.txt") &&
+	   $title = file_get_contents("$gallery_dir/$galerie/comments/${x[1]}.txt")) {
+	 $title = ereg_replace("(\"|\')","",trim(strip_tags($title)));
+	 $title = ereg_replace("(.{77}).*","\\1",$title);
+       } else 
+	 $title = "Photo ${x[1]}";
+
+       print "   <a href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}\"";
+       print " title=\"$title, $NumOfComments\"";
+       if ($class) print " class=\"$class\"";
+       print ">";
+       print "<img ";
+       if (isset($thumbsize)) {
+	 print "width=\"120\" height=\"80\" ";
+       } else {
+	 // scale portraits to 80 height
+	 if ($portrait) {
+	   //portrait
+	   print "width=\"";
+	   $scaled = round($imgsize[0] / 1.5);
+	   print $scaled;
+	   print "\" height=\"${imgsize[0]}\"";
+	 } else {
+	   //landscape
+	   print $imgsize[3]; 
+	 }
+       }
+       print " src=\"$thumb\" ";
+       print "alt=\"photo No. ${x[1]}\" />";
+       print "</a>\n";
+     }
    }
    print "</p>\n";
 
-	 //info
-	 print "<div id=\"info\">\n";
-	 if ($galeriedesc[$galerie]) {
-		 print "<p>";
-		 print "<span class=\"value\">";
-		 print $galeriedesc[$galerie] . "</span></p>\n";
-	 }
-	 if ($galerieauthor[$galerie]) {
-		 print "<p><span class=\"key\">Author: </span>";
-		 print "<span class=\"value\">";
-		 print $galerieauthor[$galerie] . "</span></p>\n";
-	 }
-	 print "</div>\n";
+   //info
+   print "<div id=\"info\">\n";
+   if ($galeriedesc[$galerie]) {
+     print "<p>";
+     print "<span class=\"value\">";
+     print $galeriedesc[$galerie] . "</span></p>\n";
+   }
+   if ($galerieauthor[$galerie]) {
+     print "<p><span class=\"key\">Author: </span>";
+     print "<span class=\"value\">";
+     print $galerieauthor[$galerie] . "</span></p>\n";
+   }
+   print "</div>\n";
 
    //and links to archived images:
    print "\n<p class=\"archives\">\n";
    if (file_exists("$gallery_dir/$galerie/zip/mq.zip")) {
-      print "[ <a href=\"$gallery_dir/$galerie/zip/mq.zip\">" . __('zipped MQ images') . "</a> ] ";
+     print "[ <a href=\"$gallery_dir/$galerie/zip/mq.zip\">" . __('zipped MQ images') . "</a> ] ";
    }
    if (file_exists("$gallery_dir/$galerie/zip/mq.tar.bz2")) {
-      print "[ <a href=\"$gallery_dir/$galerie/zip/mq.tar.bz2\">" . __('MQ images tarball') . "</a> ] ";
+     print "[ <a href=\"$gallery_dir/$galerie/zip/mq.tar.bz2\">" . __('MQ images tarball') . "</a> ] ";
    }
    if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
-      print "[ <a href=\"$gallery_dir/$galerie/zip/hq.zip\">" . __('zipped HQ images') . "</a> ]";
+     print "[ <a href=\"$gallery_dir/$galerie/zip/hq.zip\">" . __('zipped HQ images') . "</a> ]";
    }
    if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
-      print "[ <a href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">" . __('HQ images tarball') . "</a> ]";
+     print "[ <a href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">" . __('HQ images tarball') . "</a> ]";
    }
    print "</p>";
 
-#######################
-# 	Individual Image	#
-#######################
-} else { //low-res image
-   # finish off header
-   print "\n &gt; <a href=\"$ThisScript?galerie=$galerie\">";
-	 if ($galeriename[$galerie]) {
-		 print $galeriename[$galerie];
-	 } else {
-		 print $galerie;
-	 }
-	 print "</a>\n &gt; Photo";
-   print " $snimek</div>";
-   $path = "$gallery_dir/$galerie/thumbs";
-   $imgfiles = new SortDir("$path");
-   check($galerie);
-   $path = "$gallery_dir/$galerie/lq";
-   $file = "$path/img-$snimek.jpg";
-   if (!file_exists($file)) {
-      print __('No such image');
-      $page->footer();
-      exit;
-   }
+   //######################
+   // 	Individual Image
+   //######################
+   } else { //low-res image
+  // finish off header
+  print "\n &gt; <a href=\"$ThisScript?galerie=$galerie\">";
+  if ($galeriename[$galerie]) {
+    print $galeriename[$galerie];
+  } else {
+    print $galerie;
+  }
+  print "</a>\n &gt; Photo";
+  print " $snimek</div>";
+  $path = "$gallery_dir/$galerie/thumbs";
+  $imgfiles = new SortDir("$path");
+  check($galerie);
+  $path = "$gallery_dir/$galerie/lq";
+  $file = "$path/img-$snimek.jpg";
+  if (!file_exists($file)) {
+    print __('No such image');
+    $page->footer();
+    exit;
+  }
 	 
-	 if (!$picture) { //picture may have been created if commentform submitted
-	    require_once("$root/inc/photo.class.inc.php");
-	    $picture = new C_photo($file, $snimek);
-	 }
-
-   // mini thumbnail roll
-
-   if ($show_thumbs) {
-     print "\n<!--mini thumbnail roll-->\n<div id=\"thumbs\" class=\"navigation\" style=\"visibility: hidden\"><ul class=\"thumbs noscript\" style=\"display:none\">";
-      print "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
-      print "\">";
-      print "</a>\n";
-      print " : \n";
-      while ($thumbfile = $imgfiles->read()) {
-         if ( eregi("^img-([0-9]+)\.(png|jpe?g)",
-             $thumbfile, $x)) {
-            $thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}";
-            print "   <li><a class=\"thumb\" href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}&amp;directdownload=true\"";
-	    print " name=\"" . get_photo_title($galerie, $x[1]) . "\" title=\"" . get_photo_title($galerie, $x[1]) . "\">";
-            print "</a></li> \n";
-         }
+  if (!$picture) { //picture may have been created if commentform submitted
+    require_once("$root/inc/photo.class.inc.php");
+    $picture = new C_photo($file, $snimek);
+  }
+
+  // mini thumbnail roll
+
+  if ($show_thumbs) {
+    print "\n<!--mini thumbnail roll-->\n<div id=\"thumbs\" class=\"navigation\" style=\"visibility: hidden\"><ul class=\"thumbs noscript\" style=\"display:none\">";
+    print "<a id=\"minus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
+    print "\">";
+    print "</a>\n";
+    print " : \n";
+    while ($thumbfile = $imgfiles->read()) {
+      if ( eregi("^img-([0-9]+)\.(png|jpe?g)",
+		 $thumbfile, $x)) {
+	$thumb = "$gallery_dir/$galerie/thumbs/img-${x[1]}.${x[2]}";
+	print "   <li><a class=\"thumb\" href=\"$ThisScript?galerie=$galerie&amp;photo=${x[1]}&amp;directdownload=true\"";
+	print " name=\"" . get_photo_title($galerie, $x[1]) . "\" title=\"" . get_photo_title($galerie, $x[1]) . "\">";
+	print "</a></li> \n";
       }
-      if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
-         print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.zip\">";
-         print "zip<span /></a>";
-      }
-      if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
-         print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">";
-         print "zip<span /></a>";
-      }
-      print "</ul></div>\n";
-   } else {
-      // show the popup button
-      print "\n<!--mini thumbnail popup-->\n<div class=\"thumbroll\">";
-      print "<a id=\"plus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
-      print "&amp;show_thumbs=yes\"";
-			print " title=\"" . __('Show Thumbnail Navigation') . "\">";
-      print "</a>\n";
-      print "</div>\n";
-   }
-
-   /* main image + thumbnail navigation (prev/next) */
-
-   if($slideshow) {
-     print "
+    }
+    if (file_exists("$gallery_dir/$galerie/zip/hq.zip")) {
+      print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.zip\">";
+      print "zip<span /></a>";
+    }
+    if (file_exists("$gallery_dir/$galerie/zip/hq.tar.bz2")) {
+      print "<a id=\"zip\" href=\"$gallery_dir/$galerie/zip/hq.tar.bz2\">";
+      print "zip<span /></a>";
+    }
+    print "</ul></div>\n";
+  } else {
+    // show the popup button
+    print "\n<!--mini thumbnail popup-->\n<div class=\"thumbroll\">";
+    print "<a id=\"plus\" href=\"$ThisScript?galerie=$galerie&amp;photo=$snimek";
+    print "&amp;show_thumbs=yes\"";
+    print " title=\"" . __('Show Thumbnail Navigation') . "\">";
+    print "</a>\n";
+    print "</div>\n";
+  }
+
+  /* main image + thumbnail navigation (prev/next) */
+
+  if($slideshow) {
+    print "
 <div id=\"gallery\" class=\"content\">
   <div class=\"slideshow-container\">
    <div id=\"loading\" class=\"loader\"></div>
    <div id=\"slideshow\" class=\"slideshow\" style=\"height:480;\"></div>
   </div>
 </div>\n";
-   }
-   else {
-     $picture->renderPreview();
-     $page->navigation($galerie, $snimek, "prev");
-     $page->navigation($galerie, $snimek, "next");
-   }
-   print "</div>\n"; //end image div
-
-
-   if(!$slideshow) {
-     if (function_exists(exif_read_data)) require("$root/inc/exif.inc.php"); 
-     /* Image comment
-	really poor naming here, it is caption.
-     */
-     $picture->renderCaption();
+  }
+  else {
+    $picture->renderPreview();
+    $page->navigation($galerie, $snimek, "prev");
+    $page->navigation($galerie, $snimek, "next");
+  }
+  print "</div>\n"; //end image div
+
+
+  if(!$slideshow) {
+    if (function_exists(exif_read_data)) require("$root/inc/exif.inc.php"); 
+    /* Image comment
+       really poor naming here, it is caption.
+    */
+    $picture->renderCaption();
      
      
-     //show page counter
-     if ($log_access) {
-       $picture->renderCounter();
-     }
+    //show page counter
+    if ($log_access) {
+      $picture->renderCounter();
+    }
      
-     $picture->renderBigSize();
+    $picture->renderBigSize();
      
-     $page->user_comments($picture->number);
-     $page->navigation($galerie, $snimek, null);
-   }
-}
+    $page->user_comments($picture->number);
+    $page->navigation($galerie, $snimek, null);
+  }
+ }
 
 require("inc/footer.inc.php");
 
@@ -430,7 +427,7 @@ $(document).ready(function() {
   });
 });
 </script>\n";
-}
+ }
 
 $page->footer();
 ?>
