Beispiel #1
0
function no_show_hideAlbum($albumObj)
{
    $check = checkAlbumPassword($albumObj);
    if ($check == 'zp_public_access') {
        $albumObj->exists = $albumObj->getShow();
    }
    return $albumObj;
}
/**
 * Creates a zip file of the album
 *
 * @param string $album album folder
 */
function createAlbumZip($album)
{
    global $_zp_zip_list;
    if (!checkAlbumPassword($album, $hint)) {
        pageError();
        exit;
    }
    $album = UTF8ToFilesystem($album);
    $rp = realpath(getAlbumFolder() . $album) . '/';
    $p = $album . '/';
    include_once 'archive.php';
    $dest = realpath(getAlbumFolder()) . '/' . urlencode($album) . ".zip";
    $persist = getOption('persistent_archive');
    if (!$persist || !file_exists($dest)) {
        if (file_exists($dest)) {
            unlink($dest);
        }
        $z = new zip_file($dest);
        $z->set_options(array('basedir' => $rp, 'inmemory' => 0, 'recurse' => 0, 'storepaths' => 1));
        if ($dh = opendir($rp)) {
            $_zp_zip_list[] = '*.*';
            while (($file = readdir($dh)) !== false) {
                if ($file != '.' && $file != '..') {
                    if (is_dir($rp . $file)) {
                        $base_a = explode("/", $album);
                        unset($base_a[count($base_a) - 1]);
                        $base = implode('/', $base_a);
                        zipAddSubalbum($rp, $base, $file, $z);
                    }
                }
            }
            closedir($dh);
        }
        $z->add_files($_zp_zip_list);
        $z->create_archive();
    }
    header('Content-Type: application/zip');
    header('Content-Disposition: attachment; filename="' . urlencode($album) . '.zip"');
    header("Content-Length: " . filesize($dest));
    printLargeFileContents($dest);
    if (!$persist) {
        unlink($dest);
    }
}
Beispiel #3
0
/**
 * Creates a zip file of the album
 *
 * @param string $albumname album folder
 */
function createAlbumZip($albumname)
{
    global $_zp_zip_list, $zip_gallery;
    $zip_gallery = new Gallery();
    $album = new Album($zip_gallery, $albumname);
    if (!$album->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumname)) {
        pageError(403, gettext("Forbidden"));
        exit;
    }
    if (!$album->exists) {
        pageError(404, gettext('Album not found'));
        exit;
    }
    $persist = $zip_gallery->getPersistentArchive();
    $dest = $album->localpath . '.zip';
    if (!$persist || !file_exists($dest)) {
        include_once 'archive.php';
        $curdir = getcwd();
        chdir($album->localpath);
        $_zp_zip_list = array();
        $z = new zip_file($dest);
        $z->set_options(array('basedir' => realpath($album->localpath . '/'), 'inmemory' => 0, 'recurse' => 0, 'storepaths' => 1));
        zipAddAlbum($album, strlen($albumname), $z);
        $z->add_files($_zp_zip_list);
        $z->create_archive();
        unset($_zp_zip_list);
        chdir($curdir);
    }
    header('Content-Type: application/zip');
    header('Content-Disposition: attachment; filename="' . pathurlencode($albumname) . '.zip"');
    header("Content-Length: " . filesize($dest));
    printLargeFileContents($dest);
    if (!$persist) {
        unlink($dest);
    }
    unset($zip_gallery);
    unset($album);
    unset($persist);
    unset($dest);
}
Beispiel #4
0
/**
 * Prints the Galleria slideshow for albums or search results.
 *
 * Two ways to use (see readme/documentation):
 * a) Used on the included theme slideshow.php page and called via printSlideShowLink() from the core slideshow plugin:
 * b) Calling directly via printGslideshow() function in a template file or codeblock.
 *
 * @param obj $albumobj The object of the album to show the slideshow of. Not needed if calling slideshow from album, image, or search.
 * @param obj $imageobj The object of the image to start the slideshow with. If not set the slideshow starts with the first image of the album, or current image if called from image.php. Not needed if calling slideshow from album, image, or search.
 * @param bool $linkslides Set to true if you want the slides to be linked to their image pages
 * @param mixed $autoplay true to autoplay slideshow with interval set in options, false to start with slideshow stopped.  Set integer in milliseconds to autoplay at that interval (Ex. 4000), overriding plugin option set.
 * @param bool $shuffle Set to true if you want random (shuffled) order of the slides
 *
 * */
function printGslideshow($albumobj = null, $imageobj = null, $linkslides = true, $autoplay = true, $forceheight = false, $shuffle = false)
{
    $data = 'data';
    // no POST data from slidehow link and $albumobj provided is not valid, exit
    if (!isset($_POST['albumid']) and !is_object($albumobj)) {
        echo "<div class=\"errorbox\" id=\"message\"><h2>" . gettext("Invalid linking to the slideshow page.") . "</h2></div>";
        echo "</div></body></html>";
        exitZP();
    }
    global $_zp_current_image, $_zp_current_album, $_zp_gallery, $_myFavorites, $_zp_conf_vars;
    $imagenumber = 0;
    //getting the image to start with
    if (!empty($_POST['imagenumber']) and !is_object($imageobj)) {
        $imagenumber = sanitize_numeric($_POST['imagenumber']) - 1;
        // slideshows starts with 0, but zp with 1.
    } elseif (is_object($imageobj)) {
        makeImageCurrent($imageobj);
        $imagenumber = imageNumber() - 1;
    }
    // set pagenumber to 0 if not called via POST link
    if (isset($_POST['pagenr'])) {
        $pagenumber = sanitize_numeric($_POST['pagenr']);
    } else {
        $pagenumber = 1;
    }
    // getting the number of images
    if (!empty($_POST['numberofimages'])) {
        $numberofimages = sanitize_numeric($_POST['numberofimages']);
    } elseif (is_object($albumobj)) {
        $numberofimages = $albumobj->getNumImages();
    } else {
        $numberofimages = 0;
    }
    if ($imagenumber < 2 || $imagenumber > $numberofimages) {
        $imagenumber = 0;
    }
    //getting the album to show
    if (!empty($_POST['albumid']) && !is_object($albumobj)) {
        $albumid = sanitize_numeric($_POST['albumid']);
        $embedded = false;
    } elseif (is_object($albumobj)) {
        $albumid = $albumobj->getID();
        $embedded = true;
    } else {
        $albumid = 0;
        $embedded = false;
    }
    if ($numberofimages == 0) {
        return NULL;
    }
    // get slideshow data
    if (isset($_POST['preserve_search_params'])) {
        // search page
        $search = new SearchEngine();
        $params = sanitize($_POST['preserve_search_params']);
        $search->setSearchParams($params);
        $images = $search->getImages(0);
        $searchwords = $search->getSearchWords();
        $searchdate = $search->getSearchDate();
        $searchfields = $search->getSearchFields(true);
        $page = $search->page;
        $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
        $albumtitle = gettext('Search');
    } else {
        if (isset($_POST['favorites_page'])) {
            $album = $_myFavorites;
            $albumtitle = gettext('My Favorites');
            $images = $album->getImages(0);
            $returnpath = rewrite_path(favorites::getFavorites_link() . '/' . $pagenumber, FULLWEBPATH . '/index.php?p=favorites' . '&page=' . $pagenumber);
        } else {
            $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
            $album = newAlbum($albumq['folder']);
            $albumtitle = $album->getTitle();
            if (!$album->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumq['folder'])) {
                echo gettext("This album is password protected!");
                exitZP();
            }
            $dynamic = $album->isDynamic();
            $images = $album->getImages(0);
            // return path to get back to the page we called the slideshow from
            if (empty($_POST['imagenumber'])) {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/page/' . $pagenumber, '/index.php?album=' . urlencode($album->name) . '&page=' . $pagenumber);
            } else {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/' . rawurlencode(sanitize($_POST['imagefile'])) . getOption('mod_rewrite_image_suffix'), '/index.php?album=' . urlencode($album->name) . '&image=' . urlencode($_POST['imagefile']));
            }
        }
    }
    if ($shuffle) {
        shuffle($images);
    }
    // slideshow display section
    ?>

			<script>
				var data = [
				<?php 
    for ($imgnr = 0, $cntr = 0, $idx = 0; $imgnr < $numberofimages; $imgnr++, $idx++) {
        if (is_array($images[$idx])) {
            $filename = $images[$idx]['filename'];
            $album = newAlbum($images[$idx]['folder']);
            $image = newImage($album, $filename);
        } else {
            $filename = $images[$idx];
            $image = newImage($album, $filename);
        }
        $ext = isImagePhoto($image);
        if ($ext) {
            makeImageCurrent($image);
            echo '{' . "\n";
            echo 'thumb: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_thumbsize'), getOption('gslideshow_thumbsize')) . '\',' . "\n";
            echo 'image: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_mediumsize'), getOption('gslideshow_mediumsize')) . '\',' . "\n";
            echo 'big: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_bigsize'), getOption('gslideshow_bigsize')) . '\',' . "\n";
            echo 'title: \'' . js_encode($image->getTitle()) . '\',' . "\n";
            $desc = $image->getDesc();
            $desc = str_replace("\r\n", '<br />', $desc);
            $desc = str_replace("\r", '<br />', $desc);
            echo 'description: \'' . js_encode($desc) . '\',' . "\n";
            if ($linkslides) {
                echo 'link: \'' . html_encode($image->getLink()) . '\'' . "\n";
            }
            if ($imgnr == $numberofimages - 1) {
                echo '}' . "\n";
            } else {
                echo '},' . "\n";
            }
        }
    }
    echo "\n";
    ?>
				];
			</script>
			<?php 
    printGalleriaRun($data, $linkslides, $autoplay, $embedded, $forceheight, $imagenumber, $albumtitle, $returnpath);
    //restore_context(); // needed if the slideshow is for example called directly via album object before the next_album loop on index.php
}
/**
 * Gets news articles and images of a gallery to show them together on the news section
 *
 * NOTE: This function does not exclude articles that are password protected via a category
 *
 * @param int $articles_per_page The number of articles to get
 * @param string $mode 	"latestimages-thumbnail"
 *											"latestimages-thumbnail-customcrop"
 *											"latestimages-sizedimage"
 *											"latestalbums-thumbnail"
 *		 									"latestalbums-thumbnail-customcrop"
 *		 									"latestalbums-sizedimage"
 *		 									"latestimagesbyalbum-thumbnail"
 *		 									"latestimagesbyalbum-thumbnail-customcrop"
 *		 									"latestimagesbyalbum-sizedimage"
 *		 									"latestupdatedalbums-thumbnail" (for RSS and getLatestNews() used only)
 *		 									"latestupdatedalbums-thumbnail-customcrop" (for RSS and getLatestNews() used only)
 *		 									"latestupdatedalbums-sizedimage" (for RSS and getLatestNews() used only)
 *	NOTE: The "latestupdatedalbums" variants do NOT support pagination as required on the news loop!
 *
 * @param string $published "published" for published articles,
 * 													"unpublished" for un-published articles,
 * 													"all" for all articles
 * @param string $sortorder 	id, date or mtime, only for latestimages-... modes
 * @param bool $sticky set to true to place "sticky" articles at the front of the list.
 * @return array
 */
function getCombiNews($articles_per_page = '', $mode = '', $published = NULL, $sortorder = '', $sticky = true)
{
    deprecated_function_notify(gettext('Use the Zenpage class method instead.'));
    global $_zp_gallery, $_zp_flash_player;
    processExpired('news');
    if (is_null($published)) {
        if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
            $published = "all";
        } else {
            $published = "published";
        }
    }
    if (empty($mode)) {
        $mode = getOption("zenpage_combinews_mode");
    }
    if ($published == "published") {
        $show = " WHERE `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'";
        $imagesshow = " AND images.show = 1 ";
    } else {
        $show = "";
        $imagesshow = "";
    }
    $passwordcheck = "";
    if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
        $albumWhere = "";
        $passwordcheck = "";
    } else {
        $albumscheck = query_full_array("SELECT * FROM " . prefix('albums') . " ORDER BY title");
        foreach ($albumscheck as $albumcheck) {
            if (!checkAlbumPassword($albumcheck['folder'])) {
                $albumpasswordcheck = " AND albums.id != " . $albumcheck['id'];
                $passwordcheck = $passwordcheck . $albumpasswordcheck;
            }
        }
        $albumWhere = "AND albums.show=1" . $passwordcheck;
    }
    $limit = getLimitAndOffset($articles_per_page);
    if (empty($sortorder)) {
        $combinews_sortorder = getOption("zenpage_combinews_sortorder");
    } else {
        $combinews_sortorder = $sortorder;
    }
    $stickyorder = '';
    if ($sticky) {
        $stickyorder = 'sticky DESC,';
    }
    $type3 = query("SET @type3:='0'");
    switch ($mode) {
        case "latestimages-thumbnail":
        case "latestimages-thumbnail-customcrop":
        case "latestimages-sizedimage":
            $sortorder = "images." . $combinews_sortorder;
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='images'");
            switch ($combinews_sortorder) {
                case 'id':
                case 'date':
                    $imagequery = "(SELECT albums.folder, images.filename, images.date, @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
                case 'mtime':
                    $imagequery = "(SELECT albums.folder, images.filename, FROM_UNIXTIME(images.mtime), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            break;
        case "latestalbums-thumbnail":
        case "latestalbums-thumbnail-customcrop":
        case "latestalbums-sizedimage":
            $sortorder = $combinews_sortorder;
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='albums'");
            switch ($combinews_sortorder) {
                case 'id':
                case 'date':
                    $albumquery = "(SELECT albums.folder, albums.title, albums.date, @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                    break;
                case 'mtime':
                    $albumquery = "(SELECT albums.folder, albums.title, FROM_UNIXTIME(albums.mtime), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $albumquery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            break;
        case "latestimagesbyalbum-thumbnail":
        case "latestimagesbyalbum-thumbnail-customcrop":
        case "latestimagesbyalbum-sizedimage":
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='albums'");
            if (empty($combinews_sortorder) || $combinews_sortorder != "date" || $combinews_sortorder != "mtime") {
                $combinews_sortorder = "date";
            }
            $combinews_sortorder = "date";
            $sortorder = "images." . $combinews_sortorder;
            switch ($combinews_sortorder) {
                case "date":
                    $imagequery = "(SELECT DISTINCT DATE_FORMAT(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.`date`,'%Y-%m-%d'), @type2 FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
                case "mtime":
                    $imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.`mtime`,'%Y-%m-%d'), @type2 FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER By date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            //echo "<pre>"; print_r($result); echo "</pre>";
            //$result = "";
            break;
        case "latestupdatedalbums-thumbnail":
        case "latestupdatedalbums-thumbnail-customcrop":
        case "latestupdatedalbums-sizedimage":
            $latest = getNewsArticles($articles_per_page, '', NULL, true);
            $counter = '';
            foreach ($latest as $news) {
                $article = new ZenpageNews($news['titlelink']);
                if ($article->checkAccess($hint, $show)) {
                    $counter++;
                    $latestnews[$counter] = array("albumname" => $article->getTitle(), "titlelink" => $article->getTitlelink(), "date" => $article->getDateTime(), "type" => "news");
                }
            }
            $albums = getAlbumStatistic($articles_per_page, "latestupdated");
            $latestalbums = array();
            $counter = "";
            foreach ($albums as $album) {
                $counter++;
                $tempalbum = new Album($_zp_gallery, $album['folder']);
                $tempalbumthumb = $tempalbum->getAlbumThumbImage();
                $timestamp = $tempalbum->get('mtime');
                if ($timestamp == 0) {
                    $albumdate = $tempalbum->getDateTime();
                } else {
                    $albumdate = strftime('%Y-%m-%d %H:%M:%S', $timestamp);
                }
                $latestalbums[$counter] = array("albumname" => $tempalbum->getFolder(), "titlelink" => $tempalbum->getTitle(), "date" => $albumdate, "type" => 'albums');
            }
            //$latestalbums = array_merge($latestalbums, $item);
            $latest = array_merge($latestnews, $latestalbums);
            $result = sortMultiArray($latest, "date", true);
            if (count($result) > $articles_per_page) {
                $result = array_slice($result, 0, 10);
            }
            break;
    }
    //$result = "";
    return $result;
}
Beispiel #6
0
 /**
  * Creates a zip file of the album
  *
  * @param string $albumname album folder
  * @param bool fromcache if true, images will be the "sized" image in the cache file
  */
 static function create($albumname, $fromcache)
 {
     global $_zp_zip_list, $_zp_gallery, $defaultSize;
     $album = newAlbum($albumname);
     if (!$album->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumname)) {
         self::pageError(403, gettext("Forbidden"));
     }
     if (!$album->exists) {
         self::pageError(404, gettext('Album not found'));
     }
     $_zp_zip_list = array();
     if ($fromcache) {
         $opt = array('large_file_size' => 5 * 1024 * 1024, 'comment' => sprintf(gettext('Created from cached images of %1$s on %2$s.'), $album->name, zpFormattedDate(DATE_FORMAT, time())));
         loadLocalOptions(false, $_zp_gallery->getCurrentTheme());
         $defaultSize = getOption('image_size');
         self::AddAlbumCache($album, strlen($albumname), SERVERPATH . '/' . CACHEFOLDER . '/' . $albumname);
     } else {
         $opt = array('large_file_size' => 5 * 1024 * 1024, 'comment' => sprintf(gettext('Created from images in %1$s on %2$s.'), $album->name, zpFormattedDate(DATE_FORMAT, time())));
         self::AddAlbum($album, strlen($albumname), SERVERPATH . '/' . ALBUMFOLDER . '/' . $albumname);
     }
     $zip = new ZipStream($albumname . '.zip', $opt);
     foreach ($_zp_zip_list as $path => $file) {
         @set_time_limit(6000);
         $zip->add_file_from_path(internalToFilesystem($file), internalToFilesystem($path));
     }
     $zip->finish();
 }
/**
 * Checks to see if a password is needed
 * displays a password form if log-on is required
 *
 * Returns true if a login form has been displayed
 *
 * The password protection is hereditary. This normally only impacts direct url access to an album or image since if
 * you are going down the tree you will be stopped at the first place a password is required.
 *
 * If the gallery is password protected then every album & image will require that password.
 *
 * If an album is password protected then all subalbums and images treed below that album will require
 * the password. If there are multiple passwords in the tree and you direct link, the password that is
 * required will be that of the nearest parent that has a password. (The gallery is the ur-parrent to all
 * albums.)
 *
 * @param bool $silent set to true to inhibit the logon form
 * @return bool
 * @since 1.1.3
 */
function checkforPassword($silent = false)
{
    global $_zp_current_album, $_zp_current_search, $_zp_gallery, $_zp_loggedin;
    if (zp_loggedin(MAIN_RIGHTS | VIEWALL_RIGHTS | ALL_ALBUMS_RIGHTS)) {
        return false;
    }
    // you're the admin, you don't need the passwords.
    if (in_context(ZP_SEARCH)) {
        // search page
        $hash = getOption('search_password');
        $show = getOption('search_user') != '';
        $hint = get_language_string(getOption('search_hint'));
        $authType = 'zp_search_auth';
        if (empty($hash)) {
            $hash = getOption('gallery_password');
            $show = getOption('gallery_user') != '';
            $hint = get_language_string(getOption('gallery_hint'));
            $authType = 'zp_gallery_auth';
        }
        if (!empty($hash)) {
            if (zp_getCookie($authType) != $hash) {
                if (!$silent) {
                    printPasswordForm($hint, true, getOption('login_user_field') || $show);
                }
                return true;
            }
        }
    } else {
        if (isset($_GET['album'])) {
            // album page
            list($album, $image) = rewrite_get_album_image('album', 'image');
            if (checkAlbumPassword($album, $hint)) {
                return false;
            } else {
                if (!$silent) {
                    $alb = new Album($_zp_gallery, $album);
                    printPasswordForm($hint, true, getOption('login_user_field') || $alb->getUser() != '');
                }
                return true;
            }
        } else {
            // index page
            if ($_zp_loggedin) {
                return false;
            }
            $hash = getOption('gallery_password');
            $hint = get_language_string(getOption('gallery_hint'));
            if (!empty($hash)) {
                if (zp_getCookie('zp_gallery_auth') != $hash) {
                    if (!$silent) {
                        printPasswordForm($hint, true, getOption('login_user_field') || getOption('gallery_user') != '');
                    }
                    return true;
                }
            }
        }
    }
    return false;
}
Beispiel #8
0
/**
 * Prints the rating star form and the current rating
 * Insert this function call in the page script where you
 * want the star ratings to appear.
 *
 * NOTE:
 * If $vote is false or the rating_recast option is false then
 * the stars shown will be the rating. Otherwise the stars will
 * show the value of the viewer's last vote.
 *
 * @param bool $vote set to false to disable voting
 * @param object $object optional object for the ratings target. If not set, the current page object is used
 * @param bool $text if false, no annotation text is displayed
 */
function printRating($vote = 3, $object = NULL, $text = true)
{
    global $_zp_gallery_page;
    if (is_null($object)) {
        $object = jquery_rating::getCurrentPageObject();
    }
    if (!is_object($object)) {
        return;
    }
    $table = $object->table;
    $vote = min($vote, getOption('rating_status'), $object->get('rating_status'));
    switch ($vote) {
        case 1:
            // members only
            if (!zp_loggedin()) {
                $vote = 0;
            }
            break;
        case 2:
            // members & guests
            switch ($_zp_gallery_page) {
                case 'album.php':
                    $album = $object;
                    $hint = '';
                    if (!(zp_loggedin() || checkAlbumPassword($album->name))) {
                        $vote = 0;
                    }
                    break;
                case 'pages.php':
                case 'news.php':
                    if (!zp_loggedin()) {
                        // no guest password
                        $vote = 0;
                    }
                    break;
                default:
                    $album = $object->getAlbum();
                    $hint = '';
                    if (!(zp_loggedin() || checkAlbumPassword($album->name))) {
                        $vote = 0;
                    }
                    break;
            }
    }
    $stars = ceil(getOption('rating_stars_count'));
    $recast = getOption('rating_recast');
    $split_stars = max(1, getOption('rating_split_stars'));
    $rating = $object->get('rating');
    $votes = $object->get('total_votes');
    $id = $object->getID();
    $unique = '_' . $table . '_' . $id;
    $ip = jquery_rating::id();
    $oldrating = jquery_rating::getRatingByIP($ip, $object->get('used_ips'), $object->get('rating'));
    if ($vote && $recast == 2 && $oldrating) {
        $starselector = round($oldrating * $split_stars);
    } else {
        $starselector = round($rating * $split_stars);
    }
    $disable = !$vote || $oldrating && !$recast;
    if ($rating > 0) {
        $msg = sprintf(ngettext('Rating %2$.1f (%1$u vote)', 'Rating %2$.1f (%1$u votes)', $votes), $votes, $rating);
    } else {
        $msg = gettext('Not yet rated');
    }
    if ($split_stars > 1) {
        $step = $split_stars;
        $split = " {split:{$step}}";
        $step = 1 / $step;
    } else {
        $split = '';
        $step = 1;
    }
    ?>
	<form name="star_rating<?php 
    echo $unique;
    ?>
" id="star_rating<?php 
    echo $unique;
    ?>
" action="submit">
		<?php 
    $j = 0;
    for ($i = $step; $i <= $stars; $i = $i + $step) {
        $v = ceil($i);
        $j++;
        ?>
			<input type="radio" class="star<?php 
        echo $split;
        ?>
" name="star_rating-value<?php 
        echo $unique;
        ?>
" value="<?php 
        echo $j;
        ?>
" title="<?php 
        printf(ngettext('%u star', '%u stars', $v), $v);
        ?>
" />
			<?php 
    }
    if (!$disable) {
        ?>
			<span id="submit_button<?php 
        echo $unique;
        ?>
">
				<input type="button" class="button buttons" value="<?php 
        echo gettext('Submit »');
        ?>
" onclick="cast<?php 
        echo $unique;
        ?>
();" />
			</span>
			<?php 
    }
    ?>
	</form>
	<span class="clearall" ></span>
	<span class="vote" id="vote<?php 
    echo $unique;
    ?>
" <?php 
    if (!$text) {
        echo 'style="display:none;"';
    }
    ?>
>
		<?php 
    echo $msg;
    ?>
	</span>
	<script type="text/javascript">
		// <!-- <![CDATA[
		var recast<?php 
    echo $unique;
    ?>
 = <?php 
    printf('%u', $recast && $oldrating);
    ?>
;
		$(document).ready(function () {
			$('#star_rating<?php 
    echo $unique;
    ?>
 :radio.star').rating('select', '<?php 
    echo $starselector;
    ?>
');
	<?php 
    if ($disable) {
        ?>
				$('#star_rating<?php 
        echo $unique;
        ?>
 :radio.star').rating('disable');
		<?php 
    }
    ?>
		});

		function cast<?php 
    echo $unique;
    ?>
() {
			var dataString = $('#star_rating<?php 
    echo $unique;
    ?>
').serialize();
			if (dataString || recast<?php 
    echo $unique;
    ?>
) {
	<?php 
    if ($recast) {
        ?>
					if (!dataString) {
						dataString = 'star_rating-value<?php 
        echo $unique;
        ?>
=0';
					}
		<?php 
    } else {
        ?>
					$('#star_rating<?php 
        echo $unique;
        ?>
 :radio.star').rating('disable');
					$('#submit_button<?php 
        echo $unique;
        ?>
').hide();
		<?php 
    }
    ?>
				$.ajax({
					type: 'POST',
					cache: false,
					url: '<?php 
    echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/' . substr(basename(__FILE__), 0, -4);
    ?>
/update.php',
					data: dataString + '&id=<?php 
    echo $id;
    ?>
&table=<?php 
    echo $table;
    ?>
'
				});
				recast<?php 
    echo $unique;
    ?>
 = <?php 
    printf('%u', $recast);
    ?>
;
				$('#vote<?php 
    echo $unique;
    ?>
').html('<?php 
    echo gettext('Vote Submitted');
    ?>
');
			} else {
				$('#vote<?php 
    echo $unique;
    ?>
').html('<?php 
    echo gettext('nothing to submit');
    ?>
');
			}
		}
		// ]]> -->
	</script>
	<?php 
}
Beispiel #9
0
    static function printSlideShow($heading = true, $speedctl = false, $albumobj = "", $imageobj = "", $width = "", $height = "")
    {
        if (!isset($_POST['albumid']) and !is_object($albumobj)) {
            echo "<div class=\"errorbox\" id=\"message\"><h2>" . gettext("Invalid linking to the slideshow page.") . "</h2></div>";
            echo "</div></body></html>";
            exit;
        }
        global $_zp_flash_player, $_zp_current_image, $_zp_current_album, $_zp_gallery;
        //getting the image to start with
        if (!empty($_POST['imagenumber']) and !is_object($imageobj)) {
            $imagenumber = $_POST['imagenumber'] - 1;
            // slideshows starts with 0, but zp with 1.
        } elseif (is_object($imageobj)) {
            makeImageCurrent($imageobj);
            $imagenumber = imageNumber() - 1;
        } else {
            $imagenumber = 0;
        }
        // set pagenumber to 0 if not called via POST link
        if (isset($_POST['pagenr'])) {
            $pagenumber = sanitize_numeric($_POST['pagenr']);
        } else {
            $pagenumber = 0;
        }
        // getting the number of images
        if (!empty($_POST['numberofimages'])) {
            $numberofimages = sanitize_numeric($_POST['numberofimages']);
        } elseif (is_object($albumobj)) {
            $numberofimages = $albumobj->getNumImages();
        }
        //getting the album to show
        if (!empty($_POST['albumid']) and !is_object($albumobj)) {
            $albumid = sanitize_numeric($_POST['albumid']);
        } elseif (is_object($albumobj)) {
            $albumid = $albumobj->id;
        } else {
            $albumid = -1;
        }
        // setting the image size
        if (!empty($width) and !empty($height)) {
            $width = sanitize_numeric($width);
            $height = sanitize_numeric($height);
        } else {
            $width = getOption("slideshow_width");
            $height = getOption("slideshow_height");
        }
        $option = getOption("slideshow_mode");
        // jQuery Cycle slideshow config
        // get slideshow data
        $gallery = new Gallery();
        if ($albumid <= 0) {
            // search page
            $dynamic = 2;
            $search = new SearchEngine();
            $params = $_POST['preserve_search_params'];
            $search->setSearchParams($params);
            $images = $search->getImages(0);
            $searchwords = $search->words;
            $searchdate = $search->dates;
            $searchfields = $search->fields;
            $page = $search->page;
            if (empty($_POST['imagenumber'])) {
                $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . abs($albumid));
                $album = new Album($gallery, $albumq['folder']);
                $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
                //$returnpath = rewrite_path('/'.pathurlencode($album->name).'/page/'.$pagenumber,'/index.php?album='.urlencode($album->name).'&page='.$pagenumber);
            } else {
                $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
            }
            $albumtitle = gettext('Search');
        } else {
            $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
            $album = new Album($gallery, $albumq['folder']);
            $albumtitle = $album->getTitle();
            if (!checkAlbumPassword($albumq['folder'], $hint)) {
                echo gettext("This album is password protected!");
                exit;
            }
            $dynamic = $album->isDynamic();
            $images = $album->getImages(0);
            // return path to get back to the page we called the slideshow from
            if (empty($_POST['imagenumber'])) {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/page/' . $pagenumber, '/index.php?album=' . urlencode($album->name) . '&page=' . $pagenumber);
            } else {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/' . rawurlencode($_POST['imagefile']) . getOption('mod_rewrite_image_suffix'), '/index.php?album=' . urlencode($album->name) . '&image=' . urlencode($_POST['imagefile']));
            }
        }
        // slideshow display section
        switch ($option) {
            case "jQuery":
                $validtypes = array('jpg', 'jpeg', 'gif', 'png', 'mov', '3gp');
                ?>
					<script type="text/javascript">
						$(document).ready(function(){
							$(function() {
								var ThisGallery = '<?php 
                echo html_encode($albumtitle);
                ?>
';
								var ImageList = new Array();
								var TitleList = new Array();
								var DescList = new Array();
								var ImageNameList = new Array();
								var DynTime=(<?php 
                echo getOption("slideshow_timeout");
                ?>
) * 1.0;	// force numeric
								<?php 
                for ($imgnr = 0, $cntr = 0, $idx = $imagenumber; $imgnr < $numberofimages; $imgnr++, $idx++) {
                    if ($dynamic) {
                        $filename = $images[$idx]['filename'];
                        $album = new Album($gallery, $images[$idx]['folder']);
                        $image = newImage($album, $filename);
                    } else {
                        $filename = $images[$idx];
                        $image = newImage($album, $filename);
                    }
                    $ext = is_valid($filename, $validtypes);
                    if ($ext) {
                        makeImageCurrent($image);
                        $img = getCustomSizedImageMaxSpace($width, $height);
                        //$img = WEBPATH . '/' . ZENFOLDER . '/i.php?a=' . pathurlencode($image->album->name) . '&i=' . urlencode($filename) . '&s=' . $imagesize;
                        echo 'ImageList[' . $cntr . '] = "' . $img . '";' . "\n";
                        echo 'TitleList[' . $cntr . '] = "' . js_encode($image->getTitle()) . '";' . "\n";
                        if (getOption("slideshow_showdesc")) {
                            $desc = $image->getDesc();
                            $desc = str_replace("\r\n", '<br />', $desc);
                            $desc = str_replace("\r", '<br />', $desc);
                            echo 'DescList[' . $cntr . '] = "' . js_encode($desc) . '";' . "\n";
                        } else {
                            echo 'DescList[' . $cntr . '] = "";' . "\n";
                        }
                        if ($idx == $numberofimages - 1) {
                            $idx = -1;
                        }
                        echo 'ImageNameList[' . $cntr . '] = "' . urlencode($filename) . '";' . "\n";
                        $cntr++;
                    }
                }
                echo "\n";
                $numberofimages = $cntr;
                ?>
								var countOffset = <?php 
                echo $imagenumber;
                ?>
;
								var totalSlideCount = <?php 
                echo $numberofimages;
                ?>
;
								var currentslide = 2;
			
								function onBefore(curr, next, opts) {
									//$(next).parent().animate({opacity: 0});

									if (opts.timeout != DynTime) {
										opts.timeout = DynTime;
									}
									if (!opts.addSlide)
										return;
							
									var currentImageNum = currentslide;
									currentslide++;
									if (currentImageNum == totalSlideCount) {
										opts.addSlide = null;
										return;
									}
									var relativeSlot = (currentslide + countOffset) % totalSlideCount;
									if (relativeSlot == 0) {relativeSlot = totalSlideCount;}
									var htmlblock = "<span class='slideimage'><h4><strong>" + ThisGallery + ":</strong> ";
									htmlblock += TitleList[currentImageNum]  + " (" + relativeSlot + "/" + totalSlideCount + ")</h4>";
									htmlblock += "<img src='" + ImageList[currentImageNum] + "'/>";
									htmlblock += "<p class='imgdesc'>" + DescList[currentImageNum] + "</p></span>";
									opts.addSlide(htmlblock);

								}
			
								function onAfter(curr, next, opts){
									<?php 
                if (!isMyALbum($album->name, ALL_RIGHTS)) {
                    ?>
									//Only register at hit count the first time the image is viewed.
									if ($(next).attr( 'viewed') != 1) {
										$.get("<?php 
                    echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER;
                    ?>
/slideshow/slideshow-counter.php?album=<?php 
                    echo pathurlencode($album->name);
                    ?>
&img="+ImageNameList[opts.currSlide]);
										$(next).attr( 'viewed', 1 );
									}
									<?php 
                }
                ?>

									//THE MISSING LINE
									$(next).parent().height(
										$(next).find('img').height() + $(next).find('p').height() + $(next).find('h4').height() + 40
									); //.animate({opacity: 1}, 'normal', 'linear');
									//getOption('slideshow_onafter'); //make it generic
									//END MISSING LINE
								}
			
								$('#slides').cycle({
										fx:     '<?php 
                echo getOption("slideshow_effect");
                ?>
',
										speed:   <?php 
                echo getOption("slideshow_speed");
                ?>
,
										timeout: DynTime,
										next:   '#next',
										prev:   '#prev',
										cleartype: 1,
										before: onBefore,
										after: onAfter
								});
			
								$('#speed').change(function () {
									DynTime = this.value;
									return false;
								});
			
								$('#pause').click(function() { $('#slides').cycle('pause'); return false; });
								$('#play').click(function() { $('#slides').cycle('resume'); return false; });
							});
			
						});	// Documentready()
			
						</script>
						<div id="slideshow" align="center">
						<?php 
                // 7/21/08dp
                if ($speedctl) {
                    echo '<div id="speedcontrol">';
                    // just to keep it away from controls for sake of this demo
                    $minto = getOption("slideshow_speed");
                    while ($minto % 500 != 0) {
                        $minto += 100;
                        if ($minto > 10000) {
                            break;
                        }
                        // emergency bailout!
                    }
                    $dflttimeout = getOption("slideshow_timeout");
                    /* don't let min timeout = speed */
                    $thistimeout = $minto == getOption("slideshow_speed") ? $minto + 250 : $minto;
                    echo 'Select Speed: <select id="speed" name="speed">';
                    while ($thistimeout <= 60000) {
                        // "around" 1 minute :)
                        echo "<option value={$thistimeout} " . ($thistimeout == $dflttimeout ? " selected='selected'>" : ">") . round($thistimeout / 1000, 1) . " sec</option>";
                        /* put back timeout to even increments of .5 */
                        if ($thistimeout % 500 != 0) {
                            $thistimeout -= 250;
                        }
                        $thistimeout += $thistimeout < 1000 ? 500 : ($thistimeout < 10000 ? 1000 : 5000);
                    }
                    echo "</select> </div>";
                }
                if (!is_object($albumobj)) {
                    // disable controls if calling the slideshow directly on homepage for example
                    ?>
						<div id="controls">
						<div><span><a href="#" id="prev"
							title="<?php 
                    echo gettext("Previous");
                    ?>
"></a></span> <a
							href="<?php 
                    echo $returnpath;
                    ?>
" id="stop"
							title="<?php 
                    echo gettext("Stop and return to album or image page");
                    ?>
"></a>
						<a href="#" id="pause"
							title="<?php 
                    echo gettext("Pause (to stop the slideshow without returning)");
                    ?>
"></a>
						<a href="#" id="play" title="<?php 
                    echo gettext("Play");
                    ?>
"></a> <a
							href="#" id="next" title="<?php 
                    echo gettext("Next");
                    ?>
"></a>
						</div>
						</div>
						<?php 
                }
                ?>
						<div id="slides" class="pics">
						<?php 
                if ($cntr > 1) {
                    $cntr = 1;
                }
                for ($imgnr = 0, $idx = $imagenumber; $imgnr <= $cntr; $idx++) {
                    if ($idx >= $numberofimages) {
                        $idx = 0;
                    }
                    if ($dynamic) {
                        $folder = $images[$idx]['folder'];
                        $dalbum = new Album($gallery, $folder);
                        $filename = $images[$idx]['filename'];
                        $image = newImage($dalbum, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename);
                    } else {
                        $folder = $album->name;
                        $filename = $images[$idx];
                        //$filename = $animage;
                        $image = newImage($album, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename);
                    }
                    $ext = is_valid($filename, $validtypes);
                    if ($ext) {
                        $imgnr++;
                        echo "<span class='slideimage'><h4><strong>" . $albumtitle . gettext(":") . "</strong> " . $image->getTitle() . " (" . ($idx + 1) . "/" . $numberofimages . ")</h4>";
                        if ($ext == "3gp") {
                            echo '</a>
												<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="352" height="304" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
												<param name="src" value="' . $imagepath . '"/>
												<param name="autoplay" value="false" />
												<param name="type" value="video/quicktime" />
												<param name="controller" value="true" />
												<embed src="' . $imagepath . '" width="352" height="304" autoplay="false" controller"true" type="video/quicktime"
												pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
												</object>
												<a>';
                        } elseif ($ext == "mov") {
                            echo '</a>
									 			<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="640" height="496" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
										 		<param name="src" value="' . $imagepath . '"/>
										 		<param name="autoplay" value="false" />
										 		<param name="type" value="video/quicktime" />
										 		<param name="controller" value="true" />
										 		<embed src="' . $imagepath . '" width="640" height="496" autoplay="false" controller"true" type="video/quicktime"
										 		pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
												</object>
												<a>';
                        } else {
                            makeImageCurrent($image);
                            printCustomSizedImageMaxSpace($alt = '', $width, $height, NULL, NULL, false);
                            //echo "<img src='".WEBPATH."/".ZENFOLDER."/i.php?a=".urlencode($folder)."&i=".urlencode($filename)."&s=".$imagesize."' alt='".html_encode($image->getTitle())."' title='".html_encode($image->getTitle())."' />\n";
                        }
                        if (getOption("slideshow_showdesc")) {
                            $desc = $image->getDesc();
                            $desc = str_replace("\r\n", '<br />', $desc);
                            $desc = str_replace("\r", '<br />', $desc);
                            echo "<p class='imgdesc'>" . $desc . "</p>";
                        }
                        echo "</span>";
                    }
                }
                break;
            case "flash":
                if ($heading) {
                    echo "<span class='slideimage'><h4><strong>" . $albumtitle . "</strong> (" . $numberofimages . " images) | <a style='color: white' href='" . $returnpath . "' title='" . gettext("back") . "'>" . gettext("back") . "</a></h4>";
                }
                echo "<span id='slideshow'></span>";
                ?>
 
					<script type="text/javascript">
					$("#slideshow").flashembed({
						  src:'<?php 
                echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER;
                ?>
/flowplayer/FlowPlayerLight.swf',
						  width:<?php 
                echo getOption("slideshow_flow_player_width");
                ?>
,
						  height:<?php 
                echo getOption("slideshow_flow_player_height");
                ?>
						},
						{config: {
						  autoPlay: true,
						  useNativeFullScreen: true,
						  playList: [
													<?php 
                echo "\n";
                $count = 0;
                foreach ($images as $animage) {
                    if ($dynamic) {
                        $folder = $animage['folder'];
                        $filename = $animage['filename'];
                        $salbum = new Album($_zp_gallery, $folder);
                        $image = newImage($salbum, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($salbum->name) . "/" . urlencode($filename);
                    } else {
                        $folder = $album->name;
                        $filename = $animage;
                        $image = newImage($album, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . pathurlencode($filename);
                    }
                    $ext = is_valid($filename, array('jpg', 'jpeg', 'gif', 'png', 'flv', 'mp3', 'mp4'));
                    if ($ext) {
                        if ($ext == "flv" || $ext == "mp3" || $ext == "mp4") {
                            $duration = "";
                        } else {
                            $duration = ", duration: " . getOption("slideshow_speed") / 10;
                        }
                        if ($count > 0) {
                            echo ",\n";
                        }
                        echo "{ url: '" . FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename) . "'" . $duration . " }";
                        $count++;
                    }
                }
                echo "\n";
                ?>
												],
						  showPlayListButtons: true,
						  showStopButton: true,
						  controlBarBackgroundColor: 0,
						 	showPlayListButtons: true,
						 	controlsOverVideo: 'ease',
						 	controlBarBackgroundColor: '<?php 
                echo getOption('flow_player_controlbarbackgroundcolor');
                ?>
',
						  controlsAreaBorderColor: '<?php 
                echo getOption('flow_player_controlsareabordercolor');
                ?>
'
						}}
				  );
					</script> 
					<?php 
                echo "</span>";
                echo "<p>";
                printf(gettext("Click on %s on the right in the player control bar to view full size."), "<img style='position: relative; top: 4px; border: 1px solid gray' src='" . WEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . "/slideshow/flowplayerfullsizeicon.png' />");
                echo "</p>";
                break;
        }
        ?>
			</div>
		</div>
			<?php 
    }
/**
 * returns the auth type of a guest login
 *
 * @param string $hint
 * @param string $show
 * @return string
 */
function checkForGuest(&$hint = NULL, &$show = NULL)
{
    global $_zp_gallery, $_zp_gallery_page, $_zp_current_zenpage_page, $_zp_current_category, $_zp_current_zenpage_news;
    $authType = zp_apply_filter('checkForGuest', NULL);
    if (!is_null($authType)) {
        return $authType;
    }
    if (in_context(ZP_SEARCH)) {
        // search page
        $hash = getOption('search_password');
        if (getOption('search_user') != '') {
            $show = true;
        }
        $hint = get_language_string(getOption('search_hint'));
        $authType = 'zp_search_auth';
        if (empty($hash)) {
            $hash = $_zp_gallery->getPassword();
            if ($_zp_gallery->getUser() != '') {
                $show = true;
            }
            $hint = $_zp_gallery->getPasswordHint();
            $authType = 'zp_gallery_auth';
        }
        if (!empty($hash) && zp_getCookie($authType) == $hash) {
            return $authType;
        }
    } else {
        if (!is_null($_zp_current_zenpage_news)) {
            $authType = $_zp_current_zenpage_news->checkAccess($hint, $show);
            return $authType;
        } else {
            if (isset($_GET['album'])) {
                // album page
                list($album, $image) = rewrite_get_album_image('album', 'image');
                if ($authType = checkAlbumPassword($album, $hint)) {
                    return $authType;
                } else {
                    $alb = newAlbum($album);
                    if ($alb->getUser() != '') {
                        $show = true;
                    }
                    return false;
                }
            } else {
                // other page
                $hash = $_zp_gallery->getPassword();
                if ($_zp_gallery->getUser() != '') {
                    $show = true;
                }
                $hint = $_zp_gallery->getPasswordHint();
                if (!empty($hash) && zp_getCookie('zp_gallery_auth') == $hash) {
                    return 'zp_gallery_auth';
                }
            }
        }
    }
    if (empty($hash)) {
        return 'zp_public_access';
    }
    return false;
}
Beispiel #11
0
/**
 * To show the content of an media album with .flv/.mp4/.mp3 movie/audio files only as a playlist or as separate players with flv player
 * NOTE: The flv player plugin needs to be installed (This plugin currently internally uses FLV player 3 because of FLV player 4 Api changes!)
 *
 * The playlist is meant to replace the 'next_image()' loop on a theme's album.php.
 * It can be used with a special 'album theme' that can be assigned to media albums with with .flv/.mp4/.mp3s
 * movie/audio files only. See the examples below
 * You can either show a 'one player window' playlist or show all items as separate players paginated
 * (set in the settings for thumbs per page) on one page (like on a audio or podcast blog).
 *
 * If there is no preview image for a mp3 file existing only the player control bar is shown.
 *
 * The two modes:
 * a) 'playlist'
 * Replace the entire 'next_image()' loop on album.php with this:
 * <?php flvPlaylist("playlist"); ?>
 *
 * It uses a xspf file found in 'zp-core/flvplayer/flvplayer/playlist.php' for the playlist that you also can modify. You can also use other XML formats for a playlist See http://developer.longtailvideo.com/trac/wiki/FlashFormats
 *
 * b) 'players'
 * Modify the 'next_image()' loop on album.php like this:
 * <?php
 * while (next_image():
 * printImageTitle();
 * flvPlaylist("players");
 * endwhile;
 * ?>
 * Of course you can add further functions to b) like title, description, date etc., too.
 *
 * @param string $option the mode to use "playlist" or "players"
 */
function flvPlaylist($option = '')
{
    global $_zp_current_album, $_zp_current_image, $_flv_player, $_zp_flash_player;
    if (checkAlbumPassword($_zp_current_album->getFolder(), $hint)) {
        if ($option === "players") {
            $moviepath = getUnprotectedImageURL();
            $ext = strtolower(strrchr(getUnprotectedImageURL(), "."));
        }
        $imagetitle = getImageTitle();
    }
    $albumid = getAlbumID();
    switch ($option) {
        case "playlist":
            if (getNumImages() != 0) {
                ?>
	<div id="flvplaylist"><?php 
                echo gettext("The flv player is not installed. Please install or activate the flv player plugin.");
                ?>
</div>
	<script type="text/javascript">

		var so = new SWFObject('<?php 
                echo WEBPATH . '/' . USER_PLUGIN_FOLDER;
                ?>
/flvplayer/<?php 
                echo $_flv_player;
                ?>
','flvplaylist','<?php 
                echo getOption('flvplaylist_width');
                ?>
','<?php 
                echo getOption('flvplaylist_height');
                ?>
','8');
		so.addParam('allowfullscreen','true');
		so.addVariable('stretching','<?php 
                echo getOption('flv_player_stretching');
                ?>
');
		so.addVariable('playlist', '<?php 
                echo getOption('flvplaylist_position');
                ?>
');
		so.addVariable('playlistsize','<?php 
                echo getOption('flvplaylist_size');
                ?>
');
		so.addVariable('repeat','<?php 
                echo getOption('flvplaylist_repeat');
                ?>
');
		so.addVariable('backcolor','<?php 
                echo getOptionColor('flv_player_backcolor');
                ?>
');
		so.addVariable('frontcolor','<?php 
                echo getOptionColor('flv_player_frontcolor');
                ?>
');
		so.addVariable('lightcolor','<?php 
                echo getOptionColor('flv_player_lightcolor');
                ?>
');
		so.addVariable('screencolor','<?php 
                echo getOptionColor('flv_player_screencolor');
                ?>
');
		so.addVariable('file','<?php 
                echo WEBPATH . "/" . USER_PLUGIN_FOLDER;
                ?>
/flvplayer/playlist.php?albumid=<?php 
                echo $albumid;
                ?>
');
		so.addVariable('javascriptid','jstest');
		so.addVariable('enablejs','true');
		so.write('flvplaylist');
	</script>
	<?php 
            }
            break;
        case "players":
            if ($ext == ".flv" || $ext == ".mp3" || $ext == ".mp4") {
                if (is_null($_zp_flash_player)) {
                    echo "<img src='" . WEBPATH . '/' . ZENFOLDER . "'/images/err-noflashplayer.gif' alt='" . gettext('The flv player is not installed. Please install or activate the flv player plugin.') . "' />";
                } else {
                    $_zp_flash_player->printPlayerConfig(getFullImageURL(), $_zp_current_image->getTitle(), $_zp_current_image->get("id"));
                }
            }
            break;
    }
}
Beispiel #12
0
/**
 * Prints the rating star form and the current rating
 * Insert this function call in the page script where you
 * want the star ratings to appear.
 *
 * NOTE:
 * If $vote is false or the rating_recast option is false then
 * the stars shown will be the rating. Otherwise the stars will
 * show the value of the viewer's last vote.
 *
 * @param bool $vote set to false to disable voting
 * @param object $object optional object for the ratings target. If not set, the current page object is used
 * @param bool $text if false, no annotation text is displayed
 */
function printRating($vote = 3, $object = NULL, $text = true)
{
    global $_zp_gallery_page;
    if (is_null($object)) {
        $object = getCurrentPageObject();
    }
    if (!is_object($object)) {
        return;
    }
    $table = $object->table;
    $vote = min($vote, getOption('rating_status'), $object->get('rating_status'));
    switch ($vote) {
        case 1:
            // members only
            if (!zp_loggedin()) {
                $vote = 0;
            }
            break;
        case 2:
            // members & guests
            switch ($_zp_gallery_page) {
                case 'album.php':
                    $album = $object;
                    $hint = '';
                    if (!(zp_loggedin() || checkAlbumPassword($album->name))) {
                        $vote = 0;
                    }
                    break;
                case 'pages.php':
                case 'news.php':
                    if (!zp_loggedin()) {
                        // no guest password
                        $vote = 0;
                    }
                    break;
                default:
                    $album = $object->getAlbum();
                    $hint = '';
                    if (!(zp_loggedin() || checkAlbumPassword($album->name))) {
                        $vote = 0;
                    }
                    break;
            }
    }
    $rating = $object->get('rating');
    $votes = $object->get('total_votes');
    $id = $object->get('id');
    $unique = '_' . $table . '_' . $id;
    if (getOption('rating_hash_ip')) {
        $ip = sha1(getUserIP());
    } else {
        $ip = getUserIP();
    }
    $recast = getOption('rating_recast');
    $split_stars = getOption('rating_split_stars') + 1;
    $oldrating = getRatingByIP($ip, $object->get('used_ips'), $object->get('rating'));
    if ($vote && $recast == 2 && $oldrating) {
        $starselector = round($oldrating * $split_stars);
    } else {
        $starselector = round($rating * $split_stars);
    }
    $disable = !$vote || $oldrating && !$recast;
    if ($rating > 0) {
        $msg = sprintf(ngettext('Rating %2$.1f (%1$u vote)', 'Rating %2$.1f (%1$u votes)', $votes), $votes, $rating);
    } else {
        $msg = gettext('Not yet rated');
    }
    if ($split_stars > 1) {
        $split = ' {split:2}';
    } else {
        $split = '';
    }
    ?>
		<form name="star_rating<?php 
    echo $unique;
    ?>
" id="star_rating<?php 
    echo $unique;
    ?>
" action="submit">
			<input type="radio" class="star<?php 
    echo $split;
    ?>
" name="star_rating-value<?php 
    echo $unique;
    ?>
" value="1" title="<?php 
    echo gettext('1 star');
    ?>
" />
			<input type="radio" class="star<?php 
    echo $split;
    ?>
" name="star_rating-value<?php 
    echo $unique;
    ?>
" value="2" title="<?php 
    echo gettext('1 star');
    ?>
" />
			<input type="radio" class="star<?php 
    echo $split;
    ?>
" name="star_rating-value<?php 
    echo $unique;
    ?>
" value="3" title="<?php 
    echo gettext('2 stars');
    ?>
" />
			<input type="radio" class="star<?php 
    echo $split;
    ?>
" name="star_rating-value<?php 
    echo $unique;
    ?>
" value="4" title="<?php 
    echo gettext('2 stars');
    ?>
" />
			<input type="radio" class="star<?php 
    echo $split;
    ?>
" name="star_rating-value<?php 
    echo $unique;
    ?>
" value="5" title="<?php 
    echo gettext('3 stars');
    ?>
" />
			<?php 
    if ($split_stars > 1) {
        ?>
				<input type="radio" class="star {split:2}" name="star_rating-value<?php 
        echo $unique;
        ?>
" value="6" title="<?php 
        echo gettext('3 stars');
        ?>
" />
				<input type="radio" class="star {split:2}" name="star_rating-value<?php 
        echo $unique;
        ?>
" value="7" title="<?php 
        echo gettext('4 stars');
        ?>
" />
				<input type="radio" class="star {split:2}" name="star_rating-value<?php 
        echo $unique;
        ?>
" value="8" title="<?php 
        echo gettext('4 stars');
        ?>
" />
				<input type="radio" class="star {split:2}" name="star_rating-value<?php 
        echo $unique;
        ?>
" value="9" title="<?php 
        echo gettext('5 stars');
        ?>
" />
				<input type="radio" class="star {split:2}" name="star_rating-value<?php 
        echo $unique;
        ?>
" value="10" title="<?php 
        echo gettext('5 stars');
        ?>
" />
				<?php 
    }
    if (!$disable) {
        ?>
				<span id="submit_button<?php 
        echo $unique;
        ?>
">
					<input type="button" value="<?php 
        echo gettext('Submit &raquo;');
        ?>
" onclick="javascript:cast<?php 
        echo $unique;
        ?>
();" />
				</span>
				<?php 
    }
    ?>
		</form>
		<span style="line-height: 0em;"><br clear="all" /></span>
		<span class="vote" id="vote<?php 
    echo $unique;
    ?>
" <?php 
    if (!$text) {
        echo 'style="display:none;"';
    }
    ?>
>
			<?php 
    echo $msg;
    ?>
		</span>
	<script type="text/javascript">
		// <!-- <![CDATA[
		var recast<?php 
    echo $unique;
    ?>
 = <?php 
    printf('%u', $recast && $oldrating);
    ?>
;
		$(document).ready(function() {
			$('#star_rating<?php 
    echo $unique;
    ?>
 :radio.star').rating('select','<?php 
    echo $starselector;
    ?>
');
			<?php 
    if ($disable) {
        ?>
				$('#star_rating<?php 
        echo $unique;
        ?>
 :radio.star').rating('disable');
				<?php 
    }
    ?>
		});

		function cast<?php 
    echo $unique;
    ?>
() {
			var dataString = $('#star_rating<?php 
    echo $unique;
    ?>
').serialize();
			if (dataString || recast<?php 
    echo $unique;
    ?>
) {
				<?php 
    if ($recast) {
        ?>
					if (!dataString) {
						dataString = 'star_rating-value<?php 
        echo $unique;
        ?>
=0';
					}
					<?php 
    } else {
        ?>
					$('#star_rating<?php 
        echo $unique;
        ?>
 :radio.star').rating('disable');
					$('#submit_button<?php 
        echo $unique;
        ?>
').hide();
					<?php 
    }
    ?>
				$.ajax({
					type: 'POST',
					url: '<?php 
    echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/' . substr(basename(__FILE__), 0, -4);
    ?>
/update.php',
					data: dataString+'&id=<?php 
    echo $id;
    ?>
&table=<?php 
    echo $table;
    ?>
'
				});
				recast<?php 
    echo $unique;
    ?>
 = <?php 
    printf('%u', $recast);
    ?>
;
				$('#vote<?php 
    echo $unique;
    ?>
').html('<?php 
    echo gettext('Vote Submitted');
    ?>
');
			} else {
				$('#vote<?php 
    echo $unique;
    ?>
').html('<?php 
    echo gettext('nothing to submit');
    ?>
');
			}
		}
		function star_click<?php 
    echo $unique;
    ?>
() {


alert('star click');

			$('#vote<?php 
    echo $unique;
    ?>
').html('<?php 
    echo gettext('Vote pending');
    ?>
');
		}
		// ]]> -->
	</script>
	<?php 
}
/**
 * Returns a list of image statistic according to $option
 *
 * @param string $number the number of images to get
 * @param string $option "popular" for the most popular images,
 *                       "latest" for the latest uploaded,
 *                       "latest-date" for the latest uploaded, but fetched by date,
 * 											 "latest-mtime" for the latest uploaded, but fetched by mtime,
 *                       "mostrated" for the most voted,
 *                       "toprated" for the best voted
 * @param string $albumfolder foldername of an specific album
 * @param bool $collection only if $albumfolder is set: true if you want to get statistics from this album and all of its subalbums
 * @return string
 */
function getImageStatistic($number, $option, $albumfolder = '', $collection = false)
{
    global $_zp_gallery;
    if (zp_loggedin()) {
        $albumWhere = " AND albums.folder != ''";
        $imageWhere = "";
        $passwordcheck = "";
    } else {
        $passwordcheck = '';
        $albumscheck = query_full_array("SELECT * FROM " . prefix('albums') . " ORDER BY title");
        foreach ($albumscheck as $albumcheck) {
            if (!checkAlbumPassword($albumcheck['folder'], $hint)) {
                $albumpasswordcheck = " AND albums.id != " . $albumcheck['id'];
                $passwordcheck = $passwordcheck . $albumpasswordcheck;
            }
        }
        $albumWhere = " AND albums.folder != '' AND albums.show=1" . $passwordcheck;
        $imageWhere = " AND images.show=1";
    }
    if (!empty($albumfolder)) {
        if ($collection) {
            $specificalbum = " albums.folder LIKE '" . $albumfolder . "/%' AND ";
        } else {
            $specificalbum = " albums.folder = '" . $albumfolder . "' AND ";
        }
    } else {
        $specificalbum = "";
    }
    switch ($option) {
        case "popular":
            $sortorder = "images.hitcounter";
            break;
        case "latest-date":
            $sortorder = "images.date";
            break;
        case "latest-mtime":
            $sortorder = "images.mtime";
            break;
        case "latest":
            $sortorder = "images.id";
            break;
        case "mostrated":
            $sortorder = "images.total_votes";
            break;
        case "toprated":
            $sortorder = "(images.total_value/images.total_votes)";
            break;
    }
    $imageArray = array();
    $images = query_full_array("SELECT images.albumid, images.filename AS filename, images.mtime as mtime, images.title AS title, " . "albums.folder AS folder, images.show, albums.show, albums.password FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums " . " WHERE " . $specificalbum . "images.albumid = albums.id " . $imageWhere . $albumWhere . " AND albums.folder != ''" . " ORDER BY " . $sortorder . " DESC LIMIT {$number}");
    foreach ($images as $imagerow) {
        $filename = $imagerow['filename'];
        $albumfolder2 = $imagerow['folder'];
        $desc = $imagerow['title'];
        // Album is set as a reference, so we can't re-assign to the same variable!
        $image = newImage(new Album($_zp_gallery, $albumfolder2), $filename);
        $imageArray[] = $image;
    }
    return $imageArray;
}
 /**
  * Returns an array of image names found in the search
  *
  * @return array
  */
 function getSearchImages()
 {
     $images = array();
     $searchstring = $this->getSearchString();
     $searchdate = $this->dates;
     if (empty($searchstring) && empty($searchdate)) {
         return $images;
     }
     // nothing to find
     $albumfolder = getAlbumFolder();
     $fields = $this->fields;
     $tagsSearch = $fields & SEARCH_TAGS;
     $fields = $fields & ~SEARCH_TAGS;
     $sql = $this->getSearchSQL($searchstring, $searchdate, 'images', $fields);
     if (!empty($sql)) {
         // valid fields exist
         $search_results = query_full_array($sql, true);
     }
     if ($tagsSearch && count($searchstring) > 0) {
         $idlist = array();
         if (isset($search_results) && is_array($search_results)) {
             foreach ($search_results as $row) {
                 $idlist[] = $row['id'];
             }
         }
         $search_results = $this->searchTags($searchstring, 'images', $idlist);
     }
     if (isset($search_results) && is_array($search_results)) {
         foreach ($search_results as $row) {
             $albumid = $row['albumid'];
             $query = "SELECT id, title, folder,`show` FROM " . prefix('albums') . " WHERE id = {$albumid}";
             $row2 = query_single_row($query);
             // id is unique
             $albumname = $row2['folder'];
             if (file_exists($albumfolder . UTF8ToFilesystem($albumname) . '/' . UTF8ToFilesystem($row['filename']))) {
                 if (checkAlbumPassword($albumname, $hint)) {
                     $images[] = array('filename' => $row['filename'], 'folder' => $albumname);
                 }
             }
         }
     }
     return $images;
 }
Beispiel #15
0
 static function getShow($heading, $speedctl, $albumobj, $imageobj, $width, $height, $crop, $shuffle, $linkslides, $controls, $returnpath, $imagenumber)
 {
     global $_zp_gallery, $_zp_gallery_page;
     setOption('cycle-slideshow_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page), 1);
     if (!$albumobj->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumobj)) {
         return '<div class="errorbox" id="message"><h2>' . gettext('This album is password protected!') . '</h2></div>';
     }
     // setting the image size
     if (empty($width) || empty($height)) {
         $width = getOption('cycle-slideshow_width');
         $height = getOption('cycle-slideshow_height');
     }
     if ($crop) {
         $cropw = $width;
         $croph = $height;
     } else {
         $cropw = NULL;
         $croph = NULL;
     }
     //echo $imagenumber;
     $slides = $albumobj->getImages(0);
     $numslides = $albumobj->getNumImages();
     if ($shuffle) {
         // means random order, not the effect!
         shuffle($slides);
     }
     //echo "<pre>";
     // print_r($slides);
     //echo "</pre>";
     //cycle2 in progressive loading mode cannot start with specific slides as it does not "know" them.
     //The start slide needs to be set manually so I remove and append those before the desired start slide at the end
     if ($imagenumber != 0) {
         // if start slide not the first
         $count = -1;
         //cycle2 starts with 0
         $extractslides = array();
         foreach ($slides as $slide) {
             $count++;
             if ($count < $imagenumber) {
                 $extractslides[] = $slide;
                 unset($slides[$count]);
             }
         }
         $slides = array_merge($slides, $extractslides);
     }
     //echo "<pre>";
     // print_r($slides);
     //echo "</pre>";
     //$albumid = $albumobj->getID();
     if (getOption('cycle-slideshow_swipe')) {
         $option_swipe = 'true';
     } else {
         $option_swipe = 'false';
     }
     if (getOption('cycle-slideshow_pausehover')) {
         $option_pausehover = 'true';
     } else {
         $option_pausehover = 'false';
     }
     $option_fx = getOption('cycle-slideshow_effect');
     $option_tilevertical = '';
     if ($option_fx == 'tileSlide' || $option_fx == 'tileBlind') {
         $option_tileextra = getOption('cycle-slideshow_tileeffect');
         switch ($option_tileextra) {
             case 'tileVert':
                 $option_tilevertical = 'data-cycle-tile-vertical=true';
                 break;
             case 'tileHorz':
                 $option_tilevertical = 'data-cycle-tile-vertical=false';
                 break;
             default:
                 $option_tilevertical = '';
                 break;
         }
     }
     if ($numslides == 0) {
         return '<div class="errorbox" id="message"><h2>' . gettext('No images for the slideshow!') . '</h2></div>';
     }
     $slideshow = '<section class="slideshow"><!-- extra class with album id so we can address slides! -->' . "\n";
     if ($controls) {
         $slideshow .= '<ul class="slideshow_controls">' . "\n";
         $slideshow .= '<li><a href="#" data-cycle-cmd="prev" class="cycle-slideshow-prev icon-backward" title="' . gettext('prev') . '"></a></li>' . "\n";
         $slideshow .= '<li><a href="' . $returnpath . '" class="cycle-slideshow-stop icon-stop" title="' . gettext('stop') . '"></a></li>' . "\n";
         $slideshow .= '<li><a href="#" data-cycle-cmd="pause" class="cycle-slideshow-pause icon-pause" title="' . gettext('pause') . '"></a></li>' . "\n";
         $slideshow .= '<li><a href="#" data-cycle-cmd="resume" class="cycle-slideshow-resume icon-play" title="' . gettext('play') . '"></a></li>' . "\n";
         $slideshow .= '<li><a href="#" data-cycle-cmd="next" class="cycle-slideshow-next icon-forward" title="' . gettext('next') . '"></a></li>' . "\n";
         $slideshow .= '</ul>' . "\n";
     }
     //class cylce-slideshow is mandatory!
     $slideshow .= '<div class="cycle-slideshow"' . "\n";
     $slideshow .= 'data-cycle-pause-on-hover=' . $option_pausehover . "\n";
     $slideshow .= 'data-cycle-fx="' . $option_fx . '"' . "\n";
     $slideshow .= $option_tilevertical . "\n";
     $slideshow .= 'data-cycle-speed=' . getOption('cycle-slideshow_speed') . "\n";
     $slideshow .= 'data-cycle-timeout=' . getOption('cycle-slideshow_timeout') . "\n";
     $slideshow .= 'data-cycle-slides=".slide"' . "\n";
     $slideshow .= 'data-cycle-auto-height=true' . "\n";
     $slideshow .= 'data-cycle-center-horz=true' . "\n";
     $slideshow .= 'data-cycle-center-vert=true' . "\n";
     $slideshow .= 'data-cycle-swipe=' . $option_swipe . "\n";
     $slideshow .= 'data-cycle-loader=true' . "\n";
     $slideshow .= 'data-cycle-progressive=".slides"' . "\n";
     $slideshow .= '>';
     // first slide manually for progressive slide loading
     $firstslide = array_shift($slides);
     /*
      * This obj stuff could be done within printslides but we
      * might need to exclude types although cycle2 should display all
      * In that case we need the filename before printSlide as
      * otherwise the slides count is disturbed as it is done on all
      */
     $slideobj = cycle::getSlideObj($firstslide, $albumobj);
     //$ext = slideshow::is_valid($slideobj->filename, $validtypes);
     //if ($ext) {
     $slideshow .= cycle::getSlide($albumobj, $slideobj, $width, $height, $cropw, $croph, $linkslides, false);
     //}
     $slideshow .= '<script class="slides" type="text/cycle" data-cycle-split="---">' . "\n";
     $count = '';
     foreach ($slides as $slide) {
         $count++;
         $slideobj = cycle::getSlideObj($slide, $albumobj);
         $slideshow .= cycle::getSlide($albumobj, $slideobj, $width, $height, $cropw, $croph, $linkslides, false);
         if ($count != $numslides) {
             $slideshow .= "---\n";
             // delimiter for the progressive slide loading
         }
     }
     $slideshow .= '</script>' . "\n";
     $slideshow .= '</div>' . "\n";
     $slideshow .= '</section>' . "\n";
     return $slideshow;
 }
 /**
  * Returns an array of image names found in the search
  *
  * @param string $sorttype what to sort on
  * @param string $sortdirection what direction
  * @param bool $mine set true/false to overried ownership
  * @return array
  */
 function getSearchImages($sorttype, $sortdirection, $mine = NULL)
 {
     if (getOption('search_no_images') || $this->search_no_images) {
         return array();
     }
     $hint = '';
     $images = array();
     $searchstring = $this->getSearchString();
     $searchdate = $this->dates;
     if (empty($searchstring) && empty($searchdate)) {
         return $images;
     }
     // nothing to find
     if (empty($searchdate)) {
         $search_results = $this->searchFieldsAndTags($searchstring, 'images', $sorttype, $sortdirection);
     } else {
         $search_results = $this->SearchDate($searchstring, $searchdate, 'images', $sorttype, $sortdirection);
     }
     if (isset($search_results) && is_array($search_results)) {
         foreach ($search_results as $row) {
             $albumid = $row['albumid'];
             $query = "SELECT id, title, folder,`show` FROM " . prefix('albums') . " WHERE id = {$albumid}";
             $row2 = query_single_row($query);
             // id is unique
             $albumname = $row2['folder'];
             if (file_exists(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($albumname) . '/' . internalToFilesystem($row['filename']))) {
                 $album = new Album(new gallery(), $albumname);
                 if ($mine || is_null($mine) && ($album->isMyItem(LIST_RIGHTS) || checkAlbumPassword($albumname) && $row2['show'])) {
                     if (empty($this->album_list) || in_array($albumname, $this->album_list)) {
                         $images[] = array('filename' => $row['filename'], 'folder' => $albumname);
                     }
                 }
             }
         }
     }
     if (empty($searchdate)) {
         zp_apply_filter('search_statistics', $searchstring, 'images', !empty($images), $this->dynalbumname, $this->iteration++);
     }
     return $images;
 }
Beispiel #17
0
 /**
  * Returns an array of image names found in the search
  *
  * @param string $sorttype what to sort on
  * @param string $sortdirection what direction
  * @param bool $mine set true/false to overried ownership
  * @return array
  */
 private function getSearchImages($sorttype, $sortdirection, $mine = NULL)
 {
     if (getOption('search_no_images') || $this->search_no_images) {
         return array();
     }
     list($sorttype, $sortdirection) = $this->sortKey($sorttype, $sortdirection, 'title', 'images');
     if (is_null($mine) && zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS)) {
         $mine = true;
     }
     $searchstring = $this->getSearchString();
     $searchdate = $this->dates;
     if (empty($searchstring) && empty($searchdate)) {
         return array();
     }
     // nothing to find
     $criteria = $this->getCacheTag('images', serialize($searchstring) . ' ' . $searchdate, $sorttype . ' ' . $sortdirection . ' ' . $mine);
     if ($criteria == $this->searches['images']) {
         return $this->images;
     }
     $images = $this->getCachedSearch($criteria);
     if (is_null($images)) {
         if (empty($searchdate)) {
             list($search_query, $weights) = $this->searchFieldsAndTags($searchstring, 'images', $sorttype, $sortdirection);
         } else {
             $search_query = $this->searchDate($searchstring, $searchdate, 'images', $sorttype, $sortdirection);
         }
         if (empty($search_query)) {
             $search_result = false;
         } else {
             $search_result = query($search_query);
         }
         $albums_seen = $images = array();
         if ($search_result) {
             while ($row = db_fetch_assoc($search_result)) {
                 $albumid = $row['albumid'];
                 if (array_key_exists($albumid, $albums_seen)) {
                     $albumrow = $albums_seen[$albumid];
                 } else {
                     $query = "SELECT folder, `show` FROM " . prefix('albums') . " WHERE id = {$albumid}";
                     $row2 = query_single_row($query);
                     // id is unique
                     if ($row2) {
                         $albumname = $row2['folder'];
                         $allow = false;
                         $album = newAlbum($albumname);
                         $uralbum = getUrAlbum($album);
                         $viewUnpublished = $this->search_unpublished || zp_loggedin() && $uralbum->albumSubRights() & (MANAGED_OBJECT_RIGHTS_EDIT | MANAGED_OBJECT_RIGHTS_VIEW);
                         switch (checkPublishDates($row)) {
                             case 1:
                                 $imageobj = newImage($this, $row['filename']);
                                 $imageobj->setShow(0);
                                 $imageobj->save();
                             case 2:
                                 $row['show'] = 0;
                                 break;
                         }
                         if ($mine || is_null($mine) && ($album->isMyItem(LIST_RIGHTS) || checkAlbumPassword($albumname) && ($album->getShow() || $viewUnpublished))) {
                             $allow = empty($this->album_list) || in_array($albumname, $this->album_list);
                         }
                         $albums_seen[$albumid] = $albumrow = array('allow' => $allow, 'viewUnpublished' => $viewUnpublished, 'folder' => $albumname, 'localpath' => ALBUM_FOLDER_SERVERPATH . internalToFilesystem($albumname) . '/');
                     } else {
                         $albums_seen[$albumid] = $albumrow = array('allow' => false, 'viewUnpublished' => false, 'folder' => '', 'localpath' => '');
                     }
                 }
                 if ($albumrow['allow'] && ($row['show'] || $albumrow['viewUnpublished'])) {
                     if (file_exists($albumrow['localpath'] . internalToFilesystem($row['filename']))) {
                         //	still exists
                         $data = array('title' => $row['title'], 'filename' => $row['filename'], 'folder' => $albumrow['folder']);
                         if (isset($weights)) {
                             $data['weight'] = $weights[$row['id']];
                         }
                         $images[] = $data;
                     }
                 }
             }
             db_free_result($search_result);
             if (is_null($sorttype) && isset($weights)) {
                 $images = sortMultiArray($images, 'weight', true, true, false, false, array('weight'));
             }
             if ($sorttype == '`title`') {
                 $images = sortByMultilingual($images, 'title', $sortdirection);
             }
         }
         if (empty($searchdate)) {
             zp_apply_filter('search_statistics', $searchstring, 'images', !empty($images), $this->dynalbumname, $this->iteration++);
         }
         $this->cacheSearch($criteria, $images);
     }
     $this->searches['images'] = $criteria;
     return $images;
 }
Beispiel #18
0
/**
 * Returns a list of album IDs that the current viewer is not allowed to see
 *
 * @return array
 */
function getNotViewableAlbums()
{
    global $_zp_not_viewable_album_list;
    if (zp_loggedin(ADMIN_RIGHTS | MANAGE_ALL_ALBUM_RIGHTS)) {
        return array();
    }
    //admins can see all
    if (is_null($_zp_not_viewable_album_list)) {
        $sql = 'SELECT `folder`, `id`, `password`, `show` FROM ' . prefix('albums') . ' WHERE `show`=0 OR `password`!=""';
        $result = query($sql);
        if ($result) {
            $_zp_not_viewable_album_list = array();
            while ($row = db_fetch_assoc($result)) {
                if (checkAlbumPassword($row['folder'])) {
                    $album = newAlbum($row['folder']);
                    if (!($row['show'] || $album->isMyItem(LIST_RIGHTS))) {
                        $_zp_not_viewable_album_list[] = $row['id'];
                    }
                } else {
                    $_zp_not_viewable_album_list[] = $row['id'];
                }
            }
            db_free_result($result);
        }
    }
    return $_zp_not_viewable_album_list;
}
Beispiel #19
0
/**
 * Prints a tag cloud list of the tags in one album and optionally its subalbums. Returns FALSE if no value.
 *
 * @param string $albumname folder name of the album to get the tags from ($subalbums = true this is the base albums)- This value is mandatory.
 * @param bool $subalbums TRUE if the tags of subalbum should be. FALSE is default
 * @param string $mode "images" for image tags, "albums" for album tags."images" is default.
 * @return array
 */
function getAllTagsFromAlbum($albumname, $subalbums = false, $mode = 'images')
{
    global $_zp_gallery;
    $passwordcheck = '';
    $imageWhere = '';
    $tagWhere = "";
    if (empty($albumname)) {
        return FALSE;
    }
    $albumobj = newAlbum($albumname);
    if (!$albumobj->exists) {
        return FALSE;
    }
    if (zp_loggedin()) {
        $albumWhere = "WHERE `dynamic`=0";
    } else {
        $albumscheck = query_full_array("SELECT * FROM " . prefix('albums') . " ORDER BY title");
        foreach ($albumscheck as $albumcheck) {
            if (!checkAlbumPassword($albumcheck['folder'])) {
                $albumpasswordcheck = " AND id != " . $albumcheck['id'];
                $passwordcheck = $passwordcheck . $albumpasswordcheck;
            }
        }
        $albumWhere = "WHERE `dynamic`=0 AND `show`=1" . $passwordcheck;
    }
    if ($subalbums) {
        $albumWhere .= " AND `folder` LIKE " . db_quote(db_LIKE_escape($albumname) . "%");
    } else {
        $albumWhere .= " AND `folder` = " . db_quote($albumname);
    }
    $albumids = query_full_array("SELECT id, folder FROM " . prefix('albums') . $albumWhere);
    switch ($mode) {
        case "images":
            if (count($albumids) == 0) {
                return FALSE;
            } else {
                $imageWhere = " WHERE ";
                $count = "";
                foreach ($albumids as $albumid) {
                    $count++;
                    $imageWhere .= 'albumid=' . $albumid['id'];
                    if ($count != count($albumids)) {
                        $imageWhere .= " OR ";
                    }
                }
            }
            $imageids = query_full_array("SELECT id, albumid FROM " . prefix('images') . $imageWhere);
            // if the album has no direct images and $subalbums is set to false
            if (count($imageids) == 0) {
                return FALSE;
            } else {
                $count = "";
                $tagWhere = " WHERE ";
                foreach ($imageids as $imageid) {
                    $count++;
                    $tagWhere .= '(o.objectid =' . $imageid['id'] . " AND o.tagid = t.id AND o.type = 'images')";
                    if ($count != count($imageids)) {
                        $tagWhere .= " OR ";
                    }
                }
            }
            if (empty($tagWhere)) {
                return FALSE;
            } else {
                $tags = query_full_array("SELECT DISTINCT t.name, t.id, (SELECT DISTINCT COUNT(*) FROM " . prefix('obj_to_tag') . " WHERE tagid = t.id AND type = 'images') AS count FROM  " . prefix('obj_to_tag') . " AS o," . prefix('tags') . " AS t" . $tagWhere . " ORDER BY t.name");
            }
            break;
        case "albums":
            $count = "";
            if (count($albumids) == 0) {
                return FALSE;
            } else {
                $tagWhere = " WHERE ";
                foreach ($albumids as $albumid) {
                    $count++;
                    $tagWhere .= '(o.objectid =' . $albumid['id'] . " AND o.tagid = t.id AND o.type = 'albums')";
                    if ($count != count($albumids)) {
                        $tagWhere .= " OR ";
                    }
                }
            }
            if (empty($tagWhere)) {
                return FALSE;
            } else {
                $tags = query_full_array("SELECT DISTINCT t.name, t.id, (SELECT DISTINCT COUNT(*) FROM " . prefix('obj_to_tag') . " WHERE tagid = t.id AND o.type = 'albums') AS count FROM " . prefix('obj_to_tag') . " AS o," . prefix('tags') . " AS t" . $tagWhere . " ORDER BY t.name");
            }
            break;
    }
    return $tags;
}
Beispiel #20
0
    static function getShow($heading, $speedctl, $albumobj, $imageobj, $width, $height, $crop, $shuffle, $linkslides, $controls, $returnpath, $imagenumber)
    {
        global $_zp_gallery, $_zp_gallery_page;
        setOption('slideshow_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page), 1);
        if (!$albumobj->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumobj)) {
            return '<div class="errorbox" id="message"><h2>' . gettext('This album is password protected!') . '</h2></div>';
        }
        $slideshow = '';
        $numberofimages = $albumobj->getNumImages();
        // setting the image size
        if ($width) {
            $wrapperwidth = $width;
        } else {
            $width = $wrapperwidth = getOption("slideshow_width");
        }
        if ($height) {
            $wrapperheight = $height;
        } else {
            $height = $wrapperheight = getOption("slideshow_height");
        }
        if ($numberofimages == 0) {
            return '<div class="errorbox" id="message"><h2>' . gettext('No images for the slideshow!') . '</h2></div>';
        }
        $option = getOption("slideshow_mode");
        // jQuery Cycle slideshow config
        // get slideshow data
        $showdesc = getOption("slideshow_showdesc");
        // slideshow display section
        $validtypes = array('jpg', 'jpeg', 'gif', 'png', 'mov', '3gp');
        $slideshow .= '
				<script type="text/javascript">
				// <!-- <![CDATA[
				$(document).ready(function(){
				$(function() {
				var ThisGallery = "' . html_encode($albumobj->getTitle()) . '";
				var ImageList = new Array();
				var TitleList = new Array();
				var DescList = new Array();
				var ImageNameList = new Array();
				var DynTime=(' . (int) getOption("slideshow_timeout") . ');
				';
        $images = $albumobj->getImages(0);
        if ($shuffle) {
            shuffle($images);
        }
        for ($imgnr = 0, $cntr = 0, $idx = $imagenumber; $imgnr < $numberofimages; $imgnr++, $idx++) {
            if (is_array($images[$idx])) {
                $filename = $images[$idx]['filename'];
                $album = newAlbum($images[$idx]['folder']);
                $image = newImage($album, $filename);
            } else {
                $filename = $images[$idx];
                $image = newImage($albumobj, $filename);
            }
            $ext = slideshow::is_valid($filename, $validtypes);
            if ($ext) {
                if ($crop) {
                    $img = $image->getCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, NULL, NULL);
                } else {
                    $maxwidth = $width;
                    $maxheight = $height;
                    getMaxSpaceContainer($maxwidth, $maxheight, $image);
                    $img = $image->getCustomImage(NULL, $maxwidth, $maxheight, NULL, NULL, NULL, NULL, NULL, NULL);
                }
                $slideshow .= 'ImageList[' . $cntr . '] = "' . $img . '";' . "\n";
                $slideshow .= 'TitleList[' . $cntr . '] = "' . js_encode($image->getTitle()) . '";' . "\n";
                if ($showdesc) {
                    $desc = $image->getDesc();
                    $desc = str_replace("\r\n", '<br />', $desc);
                    $desc = str_replace("\r", '<br />', $desc);
                    $slideshow .= 'DescList[' . $cntr . '] = "' . js_encode($desc) . '";' . "\n";
                } else {
                    $slideshow .= 'DescList[' . $cntr . '] = "";' . "\n";
                }
                if ($idx == $numberofimages - 1) {
                    $idx = -1;
                }
                $slideshow .= 'ImageNameList[' . $cntr . '] = "' . urlencode($filename) . '";' . "\n";
                $cntr++;
            }
        }
        $slideshow .= "\n";
        $numberofimages = $cntr;
        $slideshow .= '
				var countOffset = ' . $imagenumber . ';
				var totalSlideCount = ' . $numberofimages . ';
				var currentslide = 2;
				function onBefore(curr, next, opts) {
				if (opts.timeout != DynTime) {
				opts.timeout = DynTime;
		}
		if (!opts.addSlide)
		return;
		var currentImageNum = currentslide;
		currentslide++;
		if (currentImageNum == totalSlideCount) {
		opts.addSlide = null;
		return;
		}
		var relativeSlot = (currentslide + countOffset) % totalSlideCount;
		if (relativeSlot == 0) {relativeSlot = totalSlideCount;}
		var htmlblock = "<span class=\\"slideimage\\"><h4><strong>" + ThisGallery + ":</strong> ";
		htmlblock += TitleList[currentImageNum]  + " (" + relativeSlot + "/" + totalSlideCount + ")</h4>";
		';
        if ($linkslides) {
            if (MOD_REWRITE) {
                $slideshow .= 'htmlblock += "<a href=\\"' . pathurlencode($albumobj->name) . '/"+ImageNameList[currentImageNum]+"' . getOption('mod_rewrite_image_suffix') . '\\">";';
            } else {
                $slideshow .= 'htmlblock += "<a href=\\"index.php?album=' . pathurlencode($albumobj->name) . '&image="+ImageNameList[currentImageNum]+"\\">";';
            }
        }
        $slideshow .= ' htmlblock += "<img src=\\"" + ImageList[currentImageNum] + "\\"/>";';
        if ($linkslides) {
            $slideshow .= ' htmlblock += "</a>";';
        }
        $slideshow .= 'htmlblock += "<p class=\\"imgdesc\\">" + DescList[currentImageNum] + "</p></span>";';
        $slideshow .= 'opts.addSlide(htmlblock);';
        $slideshow .= '}';
        $slideshow .= '
				function onAfter(curr, next, opts){
				';
        if (!$albumobj->isMyItem(LIST_RIGHTS)) {
            $slideshow .= '
					//Only register at hit count the first time the image is viewed.
					if ($(next).attr("viewed") != 1) {
					$.get("' . FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/slideshow/slideshow-counter.php?album=' . pathurlencode($albumobj->name) . '&img="+ImageNameList[opts.currSlide]);
					$(next).attr("viewed", 1 );
				}
				';
        }
        $slideshow .= '}';
        $slideshow .= '
				$("#slides").cycle({
				fx:     "' . getOption("slideshow_effect") . '",
				speed:   "' . getOption("slideshow_speed") . '",
				timeout: DynTime,
				next:   "#next",
				prev:   "#prev",
				cleartype: 1,
				before: onBefore,
				after: onAfter
		});

		$("#speed").change(function () {
		DynTime = this.value;
		return false;
		});

		$("#pause").click(function() { $("#slides").cycle("pause"); return false; });
		$("#play").click(function() { $("#slides").cycle("resume"); return false; });
		});

		});	// Documentready()
		// ]]> -->
		</script>
		<div id="slideshow" style="height:' . ($wrapperheight + 40) . 'px; width:' . $wrapperwidth . 'px;">
		';
        // 7/21/08dp
        if ($speedctl) {
            $slideshow .= '<div id="speedcontrol">';
            // just to keep it away from controls for sake of this demo
            $minto = getOption("slideshow_speed");
            while ($minto % 500 != 0) {
                $minto += 100;
                if ($minto > 10000) {
                    break;
                }
                // emergency bailout!
            }
            $dflttimeout = (int) getOption("slideshow_timeout");
            /* don't let min timeout = speed */
            $thistimeout = $minto == getOption("slideshow_speed") ? $minto + 250 : $minto;
            $slideshow .= 'Select Speed: <select id="speed" name="speed">';
            while ($thistimeout <= 60000) {
                // "around" 1 minute :)
                $slideshow .= "<option value={$thistimeout} " . ($thistimeout == $dflttimeout ? " selected='selected'>" : ">") . round($thistimeout / 1000, 1) . " sec</option>";
                /* put back timeout to even increments of .5 */
                if ($thistimeout % 500 != 0) {
                    $thistimeout -= 250;
                }
                $thistimeout += $thistimeout < 1000 ? 500 : ($thistimeout < 10000 ? 1000 : 5000);
            }
            $slideshow .= '</select> </div>';
        }
        if ($controls) {
            $slideshow .= '
					<div id="controls">
					<div>
					<a href="#" id="prev" title="' . gettext("Previous") . '"></a>
					<a href="' . html_encode($returnpath) . '" id="stop" title="' . gettext("Stop and return to album or image page") . '"></a>
					<a href="#" id="pause" title="' . gettext("Pause (to stop the slideshow without returning)") . '"></a>
					<a href="#" id="play" title="' . gettext("Play") . '"></a>
					<a href="#" id="next" title="' . gettext("Next") . '"></a>
					</div>
					</div>
					';
        }
        $slideshow .= '
				<div id="slides" class="pics">
				';
        if ($cntr > 1) {
            $cntr = 1;
        }
        for ($imgnr = 0, $idx = $imagenumber; $imgnr <= $cntr; $idx++) {
            if ($idx >= $numberofimages) {
                $idx = 0;
            }
            if (is_array($images[$idx])) {
                $folder = $images[$idx]['folder'];
                $dalbum = newAlbum($folder);
                $filename = $images[$idx]['filename'];
                $image = newImage($dalbum, $filename);
                $imagepath = FULLWEBPATH . ALBUM_FOLDER_EMPTY . $folder . "/" . $filename;
            } else {
                $folder = $albumobj->name;
                $filename = $images[$idx];
                //$filename = $animage;
                $image = newImage($albumobj, $filename);
                $imagepath = FULLWEBPATH . ALBUM_FOLDER_EMPTY . $folder . "/" . $filename;
            }
            $ext = slideshow::is_valid($filename, $validtypes);
            if ($ext) {
                $imgnr++;
                $slideshow .= '<span class="slideimage"><h4><strong>' . $albumobj->getTitle() . gettext(":") . '</strong> ' . $image->getTitle() . ' (' . ($idx + 1) . '/' . $numberofimages . ')</h4>';
                if ($ext == "3gp") {
                    $slideshow .= '</a>
							<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="352" height="304" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
							<param name="src" value="' . pathurlencode(internalToFilesystem($imagepath)) . '"/>
							<param name="autoplay" value="false" />
							<param name="type" value="video/quicktime" />
							<param name="controller" value="true" />
							<embed src="' . pathurlencode(internalToFilesystem($imagepath)) . '" width="352" height="304" autoplay="false" controller"true" type="video/quicktime"
							pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
							</object>
							<a>';
                } elseif ($ext == "mov") {
                    $slideshow .= '</a>
							<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="640" height="496" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
							<param name="src" value="' . pathurlencode(internalToFilesystem($imagepath)) . '"/>
							<param name="autoplay" value="false" />
							<param name="type" value="video/quicktime" />
							<param name="controller" value="true" />
							<embed src="' . pathurlencode(internalToFilesystem($imagepath)) . '" width="640" height="496" autoplay="false" controller"true" type="video/quicktime"
							pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
							</object>
							<a>';
                } else {
                    if ($linkslides) {
                        $slideshow .= '<a href="' . html_encode($image->getLink()) . '">';
                    }
                    if ($crop) {
                        $img = $image->getCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, NULL, NULL);
                    } else {
                        $maxwidth = $width;
                        $maxheight = $height;
                        getMaxSpaceContainer($maxwidth, $maxheight, $image);
                        $img = $image->getCustomImage(NULL, $maxwidth, $maxheight, NULL, NULL, NULL, NULL, NULL, NULL);
                    }
                    $slideshow .= '<img src="' . html_encode(pathurlencode($img)) . '" alt="" />';
                    if ($linkslides) {
                        $slideshow .= '</a>';
                    }
                }
                if ($showdesc) {
                    $desc = $image->getDesc();
                    $desc = str_replace("\r\n", '<br />', $desc);
                    $desc = str_replace("\r", '<br />', $desc);
                    $slideshow .= '<p class="imgdesc">' . $desc . '</p>';
                }
                $slideshow .= '</span>';
            }
        }
        $slideshow .= '
		</div>
		</div>
		';
        return $slideshow;
    }
Beispiel #21
0
function printBaseSlideShow()
{
    global $_zp_gallery, $_zp_gallery_page, $_myFavorites, $_zp_conf_vars, $_zp_themeroot, $isMobile, $isTablet;
    if (!isset($_POST['albumid'])) {
        return '<div class="errorbox" id="message"><h2>' . gettext('Invalid linking to the slideshow page.') . '</h2></div>';
    }
    //getting the image to start with
    if (!empty($_POST['imagenumber'])) {
        $imagenumber = sanitize_numeric($_POST['imagenumber']) - 1;
        // slideshows starts with 0, but zp with 1.
    } else {
        $imagenumber = 0;
    }
    // set pagenumber to 0 if not called via POST link
    if (isset($_POST['pagenr'])) {
        $pagenumber = sanitize_numeric($_POST['pagenr']);
    } else {
        $pagenumber = 1;
    }
    // getting the number of images
    if (!empty($_POST['numberofimages'])) {
        $numberofimages = sanitize_numeric($_POST['numberofimages']);
    } else {
        $numberofimages = 0;
    }
    //if ($imagenumber < 2 || $imagenumber > $numberofimages) {
    //	$imagenumber = 0;
    //}
    //getting the album to show
    if (!empty($_POST['albumid'])) {
        $albumid = sanitize_numeric($_POST['albumid']);
    } else {
        $albumid = 0;
    }
    if (isset($_POST['preserve_search_params'])) {
        // search page
        $search = new SearchEngine();
        $params = sanitize($_POST['preserve_search_params']);
        $search->setSearchParams($params);
        $searchwords = $search->getSearchWords();
        $searchdate = $search->getSearchDate();
        $searchfields = $search->getSearchFields(true);
        $page = $search->page;
        $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
        $albumobj = new AlbumBase(NULL, false);
        $albumobj->setTitle(gettext('Search'));
        $albumobj->images = $search->getImages(0);
        $albumtitle = gettext('Search');
    } else {
        if (isset($_POST['favorites_page'])) {
            $albumobj = $_myFavorites;
            $returnpath = rewrite_path($_myFavorites->getLink() . '/' . $pagenumber, FULLWEBPATH . '/index.php?p=favorites' . '&page=' . $pagenumber);
            $albumtitle = gettext('Favorites');
        } else {
            $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
            $albumobj = newAlbum($albumq['folder']);
            $albumtitle = $albumobj->getTitle();
            if (empty($_POST['imagenumber'])) {
                $returnpath = $albumobj->getLink($pagenumber);
            } else {
                $image = newImage($albumobj, sanitize($_POST['imagefile']));
                $returnpath = $image->getLink();
            }
        }
    }
    if (!$albumobj->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumobj)) {
        return '<div class="errorbox" id="message"><h2>' . gettext('This album is password protected!') . '</h2></div>';
    }
    $slideshow = '';
    $numberofimages = $albumobj->getNumImages();
    if ($numberofimages == 0) {
        return '<div class="errorbox" id="message"><h2>' . gettext('No images for the slideshow!') . '</h2></div>';
    }
    $images = $albumobj->getImages(0);
    // slideshow generate data for galleria
    ?>
		<script>
			var data = [
			<?php 
    for ($c = 0, $idx = 0; $c < $numberofimages; $c++, $idx++) {
        if (is_array($images[$idx])) {
            $filename = $images[$idx]['filename'];
            $album = newAlbum($images[$idx]['folder']);
            $image = newImage($album, $filename);
        } else {
            $filename = $images[$idx];
            $image = newImage($albumobj, $filename);
        }
        if (isImagePhoto($image)) {
            makeImageCurrent($image);
            echo '{' . "\n";
            echo 'thumb: \'' . getImageThumb() . '\',' . "\n";
            echo 'image: \'' . getDefaultSizedImage() . '\',' . "\n";
            echo 'big: \'' . getCustomImageURL(getOption('zpbase_galbigsize')) . '\',' . "\n";
            echo 'title: \'' . js_encode($image->getTitle()) . '\',' . "\n";
            $desc = $image->getDesc();
            $desc = str_replace("\r\n", '<br />', $desc);
            $desc = str_replace("\r", '<br />', $desc);
            echo 'description: \'' . js_encode($desc) . '\',' . "\n";
            if (!getOption('zpbase_nodetailpage')) {
                echo 'link: \'' . html_encode($image->getLink()) . '\'' . "\n";
            }
            if ($c == $numberofimages - 1) {
                echo '}' . "\n";
            } else {
                echo '},' . "\n";
            }
        } else {
            if ($imagenumber > 0 && $imagenumber > $c) {
                $imagenumber--;
            }
        }
    }
    echo "\n";
    ?>
			];
		</script>
		<?php 
    $sspage = true;
    require_once 'inc/galleria-jscall.php';
}
Beispiel #22
0
 /**
  * Checks if guest is loggedin for the album
  * @param unknown_type $hint
  * @param unknown_type $show
  */
 function checkforGuest(&$hint = NULL, &$show = NULL)
 {
     if (!parent::checkForGuest()) {
         return false;
     }
     return checkAlbumPassword($this, $hint);
 }
Beispiel #23
0
/**
 * Returns a list of album IDs that the current viewer is allowed to see
 *
 * @return array
 */
function getNotViewableAlbums()
{
    if (zp_loggedin(ADMIN_RIGHTS | ALL_ALBUMS_RIGHTS)) {
        return array();
    }
    //admins can see all
    $hint = '';
    global $_zp_not_viewable_album_list;
    if (is_null($_zp_not_viewable_album_list)) {
        $sql = 'SELECT `folder`, `id`, `password`, `show` FROM ' . prefix('albums') . ' WHERE `show`=0 OR `password`!=""';
        $result = query_full_array($sql);
        if (is_array($result)) {
            $_zp_not_viewable_album_list = array();
            foreach ($result as $row) {
                if (!checkAlbumPassword($row['folder'], $hint)) {
                    $_zp_not_viewable_album_list[] = $row['id'];
                } else {
                    if (!($row['show'] || isMyAlbum($row['folder'], ALL_RIGHTS))) {
                        $_zp_not_viewable_album_list[] = $row['id'];
                    }
                }
            }
        }
    }
    return $_zp_not_viewable_album_list;
}