function getDirectoryContentsExec($directory) { $directory = rtrim($directory, '/'); $directory_tree = array(); if (getDirectoryReadability($directory)) { $directory_list = opendir($directory); while (FALSE !== ($file = readdir($directory_list))) { if ($file != '.' && $file != '..') { $path = $directory . '/' . $file; if (is_readable($path)) { $subdirectories = explode('/', $path); $end = end($subdirectories); $mtime = filemtime($path); $sorting = $end; if (is_dir($path)) { $directory_tree[$sorting] = array('path' => $path, 'name' => $end, 'date' => $mtime, 'kind' => 'directory'); } elseif (is_file($path)) { $exp = explode('.', $end); $extension = end($exp); $filename = $exp[0]; $directory_tree[$sorting] = array('path' => $path, 'name' => $end, 'extension' => $extension, 'filename' => $filename, 'size' => filesize($path), 'date' => $mtime, 'kind' => 'file'); } } } } ksort($directory_tree, SORT_STRING); closedir($directory_list); } return $directory_tree; }
</head> <body> <div class="page"> <div class="title"><?php echo SITE_NAME; ?> </div> <?php //some startup checks of configuration etc function notify($message) { if (NOTIFICATIONS) { echo '<div class="notification">' . $message . '</div>'; } } if (!getDirectoryReadability(GALLERIES_DIR)) { notify('Warning: The galleries directory is not readable or does not exist.'); } if (!getDirectoryWritability(THUMBS_DIR)) { notify('Warning: The thumbs directory is not writable or does not exist. This will severely affect performance!'); } if ($gallery == '') { if (LIST_GALLERIES) { $galleries = getGalleries(); if ($galleries) { //render gallery list foreach ($galleries as $k => $v) { $name = $v['name']; $url = './?gallery=' . urlencode($name); echo <<<EOD \t<div class="gallery">