IMAGE BROWSER
# yet another very simple image browser
# $CUSTOM_CHARSET = “UTF-8″;
# preferences
$ALBUMS_ROOT = “albums”;
$LEGAL_FILE_EXTENSIONS = array(“JPG”,”GIF”);
$THUMBNAIL_WIDTH=200;
# see if the user chose an album
$ALBUM = “”;
if(isset($HTTP_GET_VARS["album"]))
{
$ALBUM = $HTTP_GET_VARS["album"];
# delete foul parameters
$ALBUM = preg_replace(array(“/\.\./”,”/^\//”,”/\/$/”),”",$ALBUM);
$ALBUM = preg_replace(“/\/\//”,”/”,$ALBUM);
}
$file_extns_regex = “/(“.join(“|”,$LEGAL_FILE_EXTENSIONS).”)$/i”;
# root dir
$imgroot = $_SERVER['DOCUMENT_ROOT'].$ALBUMS_ROOT;
# read the categories
$cats = array();
$d = dir($imgroot);
while (false !== ($entry = $d->read()))
{
$current_dir = $imgroot.”/”.$entry;
if(is_dir($current_dir) && ($entry != “.”) && ($entry != “..”))
{
# see if there are albums inside this category
$album_dir = dir($current_dir);
$album_entries = array();
while (false !== ($album_entry = $album_dir->read()))
{
$current_dir = $imgroot.”/”.$entry.”/”.$album_entry;
if(is_dir($current_dir) && ($album_entry != “.”) && ($album_entry != “..”))
{
$filestats = stat($current_dir);
$filetime = $filestats[9]; #mtime
array_push($album_entries, array($album_entry => $filetime));
}
}
$cats[$entry] = $album_entries;
}
}
$d->close();
$LEFT_NAV = “”;
foreach($cats as $catname => $albums)
{
$LEFT_NAV .= “
$catname
“;
foreach($albums as $album)
{
$LEFT_NAV .= “
“.key($album).”
“;
}
}
# determine default album
if($ALBUM != “”)
{
$current_album = $ALBUM;
}
else
{
$catnames = array_keys($cats);
$firstcat = $catnames[0];
$albums = $cats[$firstcat][0];
$albumnames = array_keys($albums);
$firstalbum = $albumnames[0];
$current_album = $firstcat.”/”.$firstalbum ;
}
$album_dir = $imgroot.”/”.$current_album;
$album_url = $ALBUMS_ROOT.”/”.$current_album;
$CAT_NAME = preg_replace(“/^(.+?)\/.*$/”,”$1″, $current_album);
$ALBUM_NAME = preg_replace(“/^.+?\/(.+)$/”,”$1″, $current_album);
$DOCTITLE = “ravn.de Fotoalbum: $CAT_NAME – $ALBUM_NAME”;
$SPITZMARKE = “$CAT_NAME”;
$HEADLINE = “Album: $ALBUM_NAME”;
include “components/header.inc.php”;
?>
include “components/footer.inc.php”;
?>
