function getSubalbumImages($folder)
{
    global $imagelist;
    if (hasDyanmicAlbumSuffix($folder)) {
        return;
    }
    $album = new Album($gallery, $folder);
    $images = $album->getImages();
    foreach ($images as $image) {
        $imagelist[] = '/' . $folder . '/' . $image;
    }
    $albums = $album->getSubalbums();
    foreach ($albums as $folder) {
        getSubalbumImages($folder);
    }
}
Exemplo n.º 2
0
/**
 * rewrite_get_album_image - Fix special characters in the album and image names if mod_rewrite is on:
 * This is redundant and hacky; we need to either make the rewriting completely internal,
 * or fix the bugs in mod_rewrite. The former is probably a good idea.
 *
 *  Old explanation:
 *    rewrite_get_album_image() parses the album and image from the requested URL
 *    if mod_rewrite is on, and replaces the query variables with corrected ones.
 *    This is because of bugs in mod_rewrite that disallow certain characters.
 *
 * @param string $albumvar "$_GET" parameter for the album
 * @param string $imagevar "$_GET" parameter for the image
 */
function rewrite_get_album_image($albumvar, $imagevar)
{
    if (getOption('mod_rewrite')) {
        $uri = urldecode(sanitize($_SERVER['REQUEST_URI'], 0));
        $path = substr($uri, strlen(WEBPATH) + 1);
        // Only extract the path when the request doesn't include the running php file (query request).
        if (strlen($path) > 0 && strpos($_SERVER['REQUEST_URI'], $_SERVER['PHP_SELF']) === false && isset($_GET[$albumvar])) {
            $im_suffix = getOption('mod_rewrite_image_suffix');
            $suf_len = strlen($im_suffix);
            $qspos = strpos($path, '?');
            if ($qspos !== false) {
                $path = substr($path, 0, $qspos);
            }
            // Strip off the image suffix (could interfere with the rest, needs to go anyway).
            if ($suf_len > 0 && substr($path, -$suf_len) == $im_suffix) {
                $path = substr($path, 0, -$suf_len);
            }
            if (substr($path, -1, 1) == '/') {
                $path = substr($path, 0, strlen($path) - 1);
            }
            $pagepos = strpos($path, '/page/');
            $slashpos = strrpos($path, '/');
            $imagepos = strpos($path, '/image/');
            $albumpos = strpos($path, '/album/');
            if ($imagepos !== false) {
                $ralbum = substr($path, 0, $imagepos);
                $rimage = substr($path, $slashpos + 1);
            } else {
                if ($albumpos !== false) {
                    $ralbum = substr($path, 0, $albumpos);
                    $rimage = substr($path, $slashpos + 1);
                } else {
                    if ($pagepos !== false) {
                        $ralbum = substr($path, 0, $pagepos);
                        $rimage = null;
                    } else {
                        if ($slashpos !== false) {
                            $ralbum = substr($path, 0, $slashpos);
                            $rimage = substr($path, $slashpos + 1);
                            if (is_dir(getAlbumFolder() . UTF8ToFilesystem($ralbum . '/' . $rimage)) || hasDyanmicAlbumSuffix($rimage)) {
                                $ralbum = $ralbum . '/' . $rimage;
                                $rimage = null;
                            }
                        } else {
                            $ralbum = $path;
                            $rimage = null;
                        }
                    }
                }
            }
            return array($ralbum, $rimage);
        }
    }
    // No mod_rewrite, or no album, etc. Just send back the query args.
    $ralbum = isset($_GET[$albumvar]) ? sanitize_path($_GET[$albumvar]) : null;
    $rimage = isset($_GET[$imagevar]) ? sanitize_path($_GET[$imagevar]) : null;
    return array($ralbum, $rimage);
}
Exemplo n.º 3
0
 /**
  * Load all of the albums names that are found in the Albums directory on disk.
  * Returns an array containing this list.
  *
  * @return array
  */
 function loadAlbumNames()
 {
     $albumdir = $this->getAlbumDir();
     if (!is_dir($albumdir) || !is_readable($albumdir)) {
         if (!is_dir($albumdir)) {
             $msg .= sprintf(gettext('Error: The \'albums\' directory (%s) cannot be found.'), $this->albumdir);
         } else {
             $msg .= sprintf(gettext('Error: The \'albums\' directory (%s) is not readable.'), $this->albumdir);
         }
         die($msg);
     }
     $dir = opendir($albumdir);
     $albums = array();
     while ($dirname = readdir($dir)) {
         $dirname = FilesystemToUTF8($dirname);
         if (is_dir($albumdir . $dirname) && substr($dirname, 0, 1) != '.' || hasDyanmicAlbumSuffix($dirname)) {
             $albums[] = $dirname;
         }
     }
     closedir($dir);
     return apply_filter('album_filter', $albums);
 }
Exemplo n.º 4
0
 /**
  * Load all of the filenames that are found in this Albums directory on disk.
  * Returns an array with all the names.
  *
  * @param  $dirs Whether or not to return directories ONLY with the file array.
  * @return array
  */
 function loadFileNames($dirs = false)
 {
     if ($this->isDynamic()) {
         // there are no 'real' files
         return array();
     }
     $albumdir = $this->localpath;
     if (!is_dir($albumdir) || !is_readable($albumdir)) {
         if (!is_dir($albumdir)) {
             $msg = sprintf(gettext("Error: The album %s cannot be found."), $this->name);
         } else {
             $msg = sprintf(gettext("Error: The album %s is not readable."), $this->name);
         }
         die($msg);
     }
     $dir = opendir($albumdir);
     $files = array();
     $others = array();
     while (false !== ($file = readdir($dir))) {
         $file8 = FilesystemToUTF8($file);
         if ($dirs && (is_dir($albumdir . $file) && substr($file, 0, 1) != '.' || hasDyanmicAlbumSuffix($file))) {
             $files[] = $file8;
         } else {
             if (!$dirs && is_file($albumdir . $file)) {
                 if (is_valid_other_type($file)) {
                     $files[] = $file8;
                     $others[] = $file8;
                 } else {
                     if (is_valid_image($file)) {
                         $files[] = $file8;
                     }
                 }
             }
         }
     }
     closedir($dir);
     if (count($others) > 0) {
         $others_thumbs = array();
         foreach ($others as $other) {
             $others_root = substr($other, 0, strrpos($other, "."));
             foreach ($files as $image) {
                 $image_root = substr($image, 0, strrpos($image, "."));
                 if ($image_root == $others_root && $image != $other) {
                     $others_thumbs[] = $image;
                 }
             }
         }
         $files = array_diff($files, $others_thumbs);
     }
     if ($dirs) {
         $filter = 'album_filter';
     } else {
         $filter = 'image_filter';
     }
     return apply_filter($filter, $files);
 }