<% /* #### Begin PHP functions #### */ function load_galleries() { if ($dh = opendir(".")) { while ($dir = readdir($dh)) { if (is_dir($dir)) { if (!strcmp($dir, ".")) continue; if (!strcmp($dir, "..")) continue; $gallery = "$dir/gallery.dat"; if (!file_exists($gallery)) continue; $galleries[$gallery]["dir"] = $dir; if (!($gal_fp = fopen($gallery, "r"))) continue; while (!feof($gal_fp)) { $line = fgets($gal_fp, 1024); if (preg_match("/^INDEX-TITLE/", $line)) { list($junk,$title) = preg_split("/ ---- /", $line, 2); $galleries[$gallery]["title"] = $title; } elseif (preg_match("/^INDEX-DATE/", $line)) { list($junk,$title) = preg_split("/ ---- /", $line, 2); $galleries[$gallery]["date"] = $title; } } fclose($gal_fp); if (file_exists("$dir/gallery.jpg")) { $galleries[$gallery]["thumb"] = "$dir/gallery.jpg"; } } } closedir($dh); } return $galleries; } function get_thumb($thumb) { if (file_exists($thumb)) { return $thumb; } else { return "default.jpg"; } } function bydate($a, $b) { return strcmp($b["date"], $a["date"]); } /* #### End PHP functions #### */ /* Get page title */ $title = "Jabr's Photo Albums"; if (file_exists('gallery.dat')) { if (($fp = fopen('gallery.dat', "r"))) { while (!feof($fp)) { $line = fgets($fp, 1024); if (preg_match("/^INDEX-DATE/", $line)) { list($junk,$date) = preg_split("/ ---- /", $line, 2); $title = "Photos for $date"; } } fclose($fp); } } %> <%= $title %>

Parent Folder

<%= $title %>
<% $galleries = load_galleries(); %>
<% $num_columns = 5; usort($galleries, "bydate"); while ( ($strip[0] = array_shift($galleries)) != NULL ) { /* #### 1. gather up one row #### */ for ( $i = 1; $i < $num_columns; $i++ ) { $strip[$i] = array_shift($galleries); } %>

<% /* #### 2. make one row of images #### */ for ( $i = 0; $i < $num_columns; $i++ ) { $gallery = $strip[$i]; if ($gallery == NULL) break; %> <% } %> <% /* #### 3. make one row of titles #### */ for ( $i = 0; $i < $num_columns; $i++ ) { $gallery = $strip[$i]; if ($gallery == NULL) break; %> <% }%>
"> " width=113 height=75 border=0>
<%= $gallery["date"] %>
<%= $gallery["title"] %>
<% } %>