% /* #### 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 %> |
|