Beispiel #1
0
    static function toolbox($albumname, $imagename)
    {
        $album = newAlbum($albumname);
        if ($album->isMyItem(ALBUM_RIGHTS)) {
            $image = newimage($album, $imagename);
            if (isImagePhoto($image)) {
                ?>
				<li>
					<a href="<?php 
                echo WEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER;
                ?>
/crop_image.php?a=<?php 
                echo pathurlencode($albumname);
                ?>
						 &amp;i=<?php 
                echo urlencode($imagename);
                ?>
&amp;performcrop=frontend "><?php 
                echo gettext("Crop image");
                ?>
</a>
				</li>
				<?php 
            }
        }
    }
Beispiel #2
0
 function checkFolder($album)
 {
     global $count, $albumcount;
     $subalbums = $album->getAlbums(0);
     foreach ($subalbums as $subalbum) {
         $obj = newAlbum($subalbum);
         cleanAlbum($obj);
     }
     $folder = $album->name . '/';
     $files = $album->getImages(0);
     foreach ($files as $filename) {
         $seoname = seoFriendly($filename);
         if (stripSuffix($seoname) != stripSuffix($filename)) {
             $image = newImage($album, $filename);
             if ($e = $image->rename($seoname)) {
                 $error = getE($e, $filename, $seoname);
                 printf(gettext('<em>%1$s</em> rename to <em>%2$s</em> failed: %3$s'), $folder . $filename, $seoname, $error);
                 echo "<br />\n";
             } else {
                 $image->save();
                 clearstatcache();
                 echo '&nbsp;&nbsp;';
                 printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $folder . $filename, $seoname);
                 echo "<br />\n";
                 $count++;
             }
         }
     }
 }
Beispiel #3
0
 static function createImages($rows)
 {
     global $_zp_gallery;
     $images = array();
     $g = empty($_zp_gallery) ? new Gallery() : $_zp_gallery;
     foreach ($rows as $r) {
         $image = newImage(newAlbum($r['folder']), $r['filename']);
         $images[] = $image;
     }
     return $images;
 }
function unpublishSubalbums($album)
{
    global $_zp_gallery;
    $albums = $album->getAlbums();
    foreach ($albums as $albumname) {
        $subalbum = newAlbum($albumname);
        $subalbum->setShow(false);
        $subalbum->save();
        unpublishSubalbums($subalbum);
    }
}
Beispiel #5
0
 function getOptionsSupported()
 {
     $showdates_checkboxes = array(gettext('Albums') => 'libratus_date_albums', gettext('Images') => 'libratus_date_images', gettext('News') => 'libratus_date_news', gettext('Pages') => 'libratus_date_pages');
     $stats_checkboxes = array(gettext('Images - Popular') => 'libratus_stats_images_popular', gettext('Images - Latest by ID') => 'libratus_stats_images_latestbyid', gettext('Images - Latest by Date') => 'libratus_stats_images_latestbydate', gettext('Images - Latest by mtime') => 'libratus_stats_images_latestbymtime', gettext('Images - Latest by Publish Date') => 'libratus_stats_images_latestbypdate', gettext('Images - Most Rated') => 'libratus_stats_images_mostrated', gettext('Images - Top Rated') => 'libratus_stats_images_toprated', gettext('Albums - Popular') => 'libratus_stats_albums_popular', gettext('Albums - Latest by ID') => 'libratus_stats_albums_latestbyid', gettext('Albums - Latest by Date') => 'libratus_stats_albums_latestbydate', gettext('Albums - Latest by mtime') => 'libratus_stats_albums_latestbymtime', gettext('Albums - Latest by Publish Date') => 'libratus_stats_albums_latestbypdate', gettext('Albums - Most Rated') => 'libratus_stats_albums_mostrated', gettext('Albums - Top Rated') => 'libratus_stats_albums_toprated', gettext('Albums - Latest Updated') => 'libratus_stats_albums_latestupdated');
     $bottom_stats_checkboxes = array(gettext('Gallery - Description') => 'libratus_stats_gal_desc_bottom', gettext('News - Latest') => 'libratus_stats_news_latest_bottom', gettext('Comments - Latest') => 'libratus_stats_comments_latest_bottom', gettext('Images - Popular') => 'libratus_stats_images_popular_bottom', gettext('Images - Latest by ID') => 'libratus_stats_images_latestbyid_bottom', gettext('Images - Latest by Date') => 'libratus_stats_images_latestbydate_bottom', gettext('Images - Latest by mtime') => 'libratus_stats_images_latestbymtime_bottom', gettext('Images - Latest by Publish Date') => 'libratus_stats_images_latestbypdate_bottom', gettext('Images - Most Rated') => 'libratus_stats_images_mostrated_bottom', gettext('Images - Top Rated') => 'libratus_stats_images_toprated_bottom', gettext('Albums - Popular') => 'libratus_stats_albums_popular_bottom', gettext('Albums - Latest by ID') => 'libratus_stats_albums_latestbyid_bottom', gettext('Albums - Latest by Date') => 'libratus_stats_albums_latestbydate_bottom', gettext('Albums - Latest by mtime') => 'libratus_stats_albums_latestbymtime_bottom', gettext('Albums - Latest by Publish Date') => 'libratus_stats_albums_latestbypdate_bottom', gettext('Albums - Most Rated') => 'libratus_stats_albums_mostrated_bottom', gettext('Albums - Top Rated') => 'libratus_stats_albums_toprated_bottom', gettext('Albums - Latest Updated') => 'libratus_stats_albums_latestupdated_bottom');
     global $_zp_gallery;
     $albumlist = array();
     $albumlist['Entire Gallery'] = '';
     $albums = getNestedAlbumList(null, 9999999, false);
     foreach ($albums as $album) {
         $albumobj = newAlbum($album['name'], true);
         $albumlist[$album['name']] = $album['name'];
     }
     return array(gettext('Max Width of Site') => array('key' => 'libratus_maxwidth', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 1, 'multilingual' => 0, 'desc' => gettext('Set the max-width of site in pixels.  Site is fluid but will not expand beyond this width.')), gettext('Home Slideshow Type') => array('key' => 'libratus_ss_type', 'type' => OPTION_TYPE_SELECTOR, 'order' => 2, 'selections' => array(gettext('Random') => 'random', gettext('Popular') => 'popular', gettext('Latest by ID') => 'latestbyid', gettext('Latest by Date') => 'latestbydate', gettext('Latest by mtime') => 'latestbymtime', gettext('Latest by Publish Date') => 'latestbypdate', gettext('Most Rated') => 'mostrated', gettext('Top Rated') => 'toprated'), 'desc' => gettext('Select what image statistic to show on the frontpage slideshow.')), gettext('Home Slideshow from Album') => array('key' => 'libratus_ss_album', 'type' => OPTION_TYPE_SELECTOR, 'order' => 3, 'selections' => $albumlist, 'desc' => gettext('Optionally select a specific album the Home Slideshow pulls from. Default is "Entire Gallery", which pulls from the entire gallery. Be careful with this option to ensure there are images that meet the statistic and they are viewable (rights), otherwise no images will show.')), gettext('Slideshow Interval') => array('key' => 'libratus_ss_interval', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 4, 'multilingual' => 0, 'desc' => gettext('In milliseconds (default 5000).')), gettext('Home Page Full-width') => array('key' => 'libratus_index_fullwidth', 'type' => OPTION_TYPE_CHECKBOX, 'order' => 5, 'desc' => gettext("Check for album thumbs to full-width on home page (no sidebar statistics menu with search).")), gettext('Show Date') => array('key' => 'libratus_date', 'type' => OPTION_TYPE_CHECKBOX_ARRAY, 'order' => 6, 'checkboxes' => $showdates_checkboxes, 'desc' => gettext("Toggle whether to display dates in albums, images, news, and pages. On \"pages\", libratus shows last updated date if checked. Note that you need to show dates on images, or on news, for those to show on the archive page.")), gettext('Download Button') => array('key' => 'libratus_download', 'type' => OPTION_TYPE_CHECKBOX, 'order' => 7, 'desc' => gettext("Check to enable users the ability to download original image from image details page. If you want a save dialog, you will need to set the appropriate option in options->image as well (protected, download).")), gettext('Simple Social Sharing?') => array('key' => 'libratus_social', 'type' => OPTION_TYPE_CHECKBOX, 'order' => 8, 'desc' => gettext("Check to display simple links (lightweight) for users to share to their Facebook, Google, and Twitter accounts. Make sure to enable the meta tags plugin and enable the og entries for these sites to pull the correct thumbs, titles, and descriptions upon share.")), gettext('Custom CSS') => array('key' => 'libratus_customcss', 'type' => OPTION_TYPE_TEXTAREA, 'order' => 9, 'multilingual' => 0, 'desc' => gettext('Enter any custom CSS, safely carries over upon theme upgrade. Will be placed between style tags in the head.')), gettext('Google Tracking Code') => array('key' => 'libratus_analytics', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 10, 'multilingual' => 0, 'desc' => gettext('Enter your Google Analytics Universal Tracking Id here to auto insert the tracking code on every page (UA-...). Leave blank to omit. Note that the analytics code will not be outputted for admin users, so that administrator page visits will not be counted.')), gettext('Tracking Type') => array('key' => 'libratus_analytics_type', 'type' => OPTION_TYPE_RADIO, 'order' => 11, 'buttons' => array(gettext('Universal') => 'universal', gettext('Classic') => 'classic'), 'desc' => gettext("Select what type of analytics you are using. See your Google analytics account for explanations.")), gettext('Facebook Link') => array('key' => 'libratus_facebook', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 12, 'multilingual' => 0, 'desc' => gettext('Enter your full Facebook page link (http://....). Leave blank to omit.')), gettext('Twitter Link') => array('key' => 'libratus_twitter', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 13, 'multilingual' => 0, 'desc' => gettext('Enter your full Twitter page link (http://....). Leave blank to omit.')), gettext('Google+ Link') => array('key' => 'libratus_google', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 14, 'multilingual' => 0, 'desc' => gettext('Enter your full Google+ page link (http://....). Leave blank to omit.')), gettext('Copyright Text') => array('key' => 'libratus_copy', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 15, 'multilingual' => 0, 'desc' => gettext('Edit text for footer copyright. Leave blank to omit.')), gettext('Statistical Pages on Archive') => array('key' => 'libratus_stats', 'type' => OPTION_TYPE_CHECKBOX_ARRAY, 'order' => 16, 'checkboxes' => $stats_checkboxes, 'desc' => gettext('Select which statistical pages to show in the archive side menu and homepage side menu (optional), if any.')), gettext('Statistical Pages Number') => array('key' => 'libratus_stats_number', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 17, 'multilingual' => 0, 'desc' => gettext('Enter the number of images or albums to show for each statistic on the archive pages (default 30).')), gettext('Bottom Stats Items per Row') => array('key' => 'libratus_bottom_stats_perrow', 'type' => OPTION_TYPE_RADIO, 'order' => 18, 'buttons' => array(gettext('Disable') => 0, gettext('1') => 1, gettext('2') => 2, gettext('3') => 3, gettext('4') => 4), 'desc' => gettext("Select how many items per row for the bottom stats, if any.")), gettext('Bottom Stats') => array('key' => 'libratus_bottom_stats', 'type' => OPTION_TYPE_CHECKBOX_ARRAY, 'order' => 19, 'checkboxes' => $bottom_stats_checkboxes, 'desc' => gettext('Select what to show in the bottom row, if not disabled above. Recommended to choose multiples of the option items per row.')), gettext('Number of Images in Bottom Stats') => array('key' => 'libratus_bottom_stats_number', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 20, 'multilingual' => 0, 'desc' => gettext('Enter the number of images or albums to show for each selected statistic in the bottom footer.')), gettext('Related Max Number') => array('key' => 'libratus_related_maxnumber', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 21, 'multilingual' => 0, 'desc' => gettext('Enter the MAX number of related albums and images to show on their respective pages (if plugin is enabled).')));
 }
Beispiel #6
0
function getSubalbumImages($folder)
{
    global $imagelist, $_zp_gallery;
    $album = newAlbum($folder);
    if ($album->isDynamic()) {
        return;
    }
    $images = $album->getImages();
    foreach ($images as $image) {
        $imagelist[] = '/' . $folder . '/' . $image;
    }
    $albums = $album->getAlbums();
    foreach ($albums as $folder) {
        getSubalbumImages($folder);
    }
}
Beispiel #7
0
function uploadPhoto($ip, $image, $nick, $email, $path, $albumName)
{
    $existsAlbum = isAlbum($nick, $albumName);
    if (!$existsAlbum) {
        if (!newAlbum($ip, $nick, $email, $albumName, "private", "DEFAULT")) {
            return '1';
        }
    }
    if (uploadImage($image, $path)) {
        $newPhoto = addPhoto($nick, $path, $albumName);
        if (!newPhoto and !$existsAlbum) {
            deleteAlbum($nick, $albumName);
            // Remove Photo
            return '2';
        }
        addAction($nick, $email, $ip, 'new_photo');
        return '0';
    }
    return '3';
}
/**
 * currently this splitts only sitemaps for albums and its images. Spliting the images itself requires a major rework...
 *
 * Gets links to all images for all albums (album by album)
 *
 * @return string
 */
function getSitemapImages()
{
    global $_zp_gallery, $sitemap_number;
    $data = '';
    $sitemap_locales = generateLanguageList();
    $imagechangefreq = getOption('sitemap_changefreq_images');
    $imagelastmod = getOption('sitemap_lastmod_images');
    $limit = sitemap_getDBLimit(1);
    $albums = array();
    getSitemapAlbumList($_zp_gallery, $albums, 'passImages');
    $offset = $sitemap_number - 1;
    $albums = array_slice($albums, $offset, SITEMAP_CHUNK);
    if ($albums) {
        $data .= sitemap_echonl('<?xml version="1.0" encoding="UTF-8"?>');
        if (GOOGLE_SITEMAP) {
            $data .= sitemap_echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">');
        } else {
            $data .= sitemap_echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
        }
        foreach ($albums as $album) {
            @set_time_limit(120);
            //	Extend script timeout to allow for gathering the images.
            $albumobj = newAlbum($album['folder']);
            $images = $albumobj->getImages();
            // print plain images links if available
            if ($images) {
                foreach ($images as $image) {
                    $imageobj = newImage($albumobj, $image);
                    $ext = getSuffix($imageobj->filename);
                    $date = sitemap_getDateformat($imageobj, $imagelastmod);
                    switch (SITEMAP_LOCALE_TYPE) {
                        case 1:
                            foreach ($sitemap_locales as $locale) {
                                $path = seo_locale::localePath(true, $locale) . '/' . pathurlencode($albumobj->name) . '/' . urlencode($imageobj->filename) . IM_SUFFIX;
                                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $path . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $imagechangefreq . "</changefreq>\n\t\t<priority>0.6</priority>\n");
                                if (GOOGLE_SITEMAP) {
                                    $data .= getSitemapGoogleImageVideoExtras($albumobj, $imageobj, $locale);
                                }
                                $data .= sitemap_echonl("</url>");
                            }
                            break;
                        case 2:
                            foreach ($sitemap_locales as $locale) {
                                $path = rewrite_path(pathurlencode($albumobj->name) . '/' . urlencode($imageobj->filename) . IM_SUFFIX, '?album=' . pathurlencode($albumobj->name) . '&amp;image=' . urlencode($imageobj->filename), dynamic_locale::fullHostPath($locale));
                                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $path . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $imagechangefreq . "</changefreq>\n\t\t<priority>0.6</priority>\n");
                                if (GOOGLE_SITEMAP) {
                                    $data .= getSitemapGoogleImageVideoExtras($albumobj, $imageobj, $locale);
                                }
                                $data .= sitemap_echonl("</url>");
                            }
                            break;
                        default:
                            $path = rewrite_path(pathurlencode($albumobj->name) . '/' . urlencode($imageobj->filename) . IM_SUFFIX, '?album=' . pathurlencode($albumobj->name) . '&amp;image=' . urlencode($imageobj->filename), FULLWEBPATH);
                            $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $path . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $imagechangefreq . "</changefreq>\n\t\t<priority>0.6</priority>\n");
                            if (GOOGLE_SITEMAP) {
                                $data .= getSitemapGoogleImageVideoExtras($albumobj, $imageobj, NULL);
                            }
                            $data .= sitemap_echonl("</url>");
                            break;
                    }
                }
            }
        }
        $data .= sitemap_echonl('</urlset>');
        // End off the <urlset> tag
    }
    return $data;
}
Beispiel #9
0
/**
 * generates a nested list of albums for the album tab sorting
 * Returns an array of "albums" each element contains:
 * 								'name' which is the folder name
 * 								'sort_order' which is an array of the sort order set
 *
 * @param $subalbum root level album (NULL is the gallery)
 * @param $levels how far to nest
 * @param $level internal for keeping the sort order elements
 * @return array
 */
function getNestedAlbumList($subalbum, $levels, $level = array())
{
    global $_zp_gallery;
    $cur = count($level);
    $levels--;
    // make it 0 relative to sync with $cur
    if (is_null($subalbum)) {
        $albums = $_zp_gallery->getAlbums();
    } else {
        $albums = $subalbum->getAlbums();
    }
    $list = array();
    foreach ($albums as $analbum) {
        $albumobj = newAlbum($analbum);
        if (!is_null($subalbum) || $albumobj->isMyItem(ALBUM_RIGHTS)) {
            $level[$cur] = sprintf('%03u', $albumobj->getSortOrder());
            $list[] = array('name' => $analbum, 'sort_order' => $level);
            if ($cur < $levels && $albumobj->getNumAlbums() && !$albumobj->isDynamic()) {
                $list = array_merge($list, getNestedAlbumList($albumobj, $levels + 1, $level));
            }
        }
    }
    return $list;
}
/**
 * support to show an image from an album
 * The imagename is optional. If absent the album thumb image will be
 * used and the link will be to the album. If present the link will be
 * to the image.
 *
 * @param string $albumname
 * @param string $imagename
 * @param int $size the size to make the image. If omitted image will be 50% of 'image_size' option.
 * @param bool $linkalbum set true to link specific image to album instead of image
 */
function zenpageAlbumImage($albumname, $imagename = NULL, $size = NULL, $linkalbum = false)
{
    global $_zp_gallery;
    echo '<br />';
    $album = newAlbum($albumname);
    if ($album->loaded) {
        if (is_null($size)) {
            $size = floor(getOption('image_size') * 0.5);
        }
        $image = NULL;
        if (is_null($imagename)) {
            $linkalbum = true;
            $image = $album->getAlbumThumbImage();
        } else {
            $image = newImage($album, $imagename);
        }
        if ($image && $image->loaded) {
            makeImageCurrent($image);
            if ($linkalbum) {
                rem_context(ZP_IMAGE);
                echo '<a href="' . html_encode($album->getLink()) . '"   title="' . sprintf(gettext('View the %s album'), $albumname) . '">';
                add_context(ZP_IMAGE);
                printCustomSizedImage(sprintf(gettext('View the album %s'), $albumname), $size);
                rem_context(ZP_IMAGE | ZP_ALBUM);
                echo '</a>';
            } else {
                echo '<a href="' . html_encode(getImageURL()) . '" title="' . sprintf(gettext('View %s'), $imagename) . '">';
                printCustomSizedImage(sprintf(gettext('View %s'), $imagename), $size);
                rem_context(ZP_IMAGE | ZP_ALBUM);
                echo '</a>';
            }
        } else {
            ?>
			<span style="background:red;color:black;">
				<?php 
            printf(gettext('<code>zenpageAlbumImage()</code> did not find the image %1$s:%2$s'), $albumname, $imagename);
            ?>
			</span>
			<?php 
        }
    } else {
        ?>
		<span style="background:red;color:black;">
			<?php 
        printf(gettext('<code>zenpageAlbumImage()</code> did not find the album %1$s'), $albumname);
        ?>
		</span>
		<?php 
    }
}
/**
* Prints a dropdown menu of all albums(not context sensitive)
* Is used by the wrapper function printAlbumMenu() if the options "jump" is choosen. For standalone use, too.
*
* Usage: add the following to the php page where you wish to use these menus:
* enable this extension on the zenphoto admin plugins tab;
* Call the function printAlbumMenuJump() at the point where you want the menu to appear.
*
* @param string $option "count" for a image counter in brackets behind the album name, "" = for no image numbers
* @param string $indexname insert the name (default "Gallery Index") how you want to call the link to the gallery index, insert "" if you don't use it, it is not printed then.
* @param bool $firstimagelink If set to TRUE and if the album has images the link will point to page of the first image instead the album thumbnail page
* @param string $css_class see printAlbumMenuList
* @param bool $skipform If set to false this prints a full form option select list (default), if set to true it will only print the options
*/
function printAlbumMenuJump($option = "count", $indexname = "Gallery Index", $firstimagelink = false, $showsubs = NULL, $skipform = false)
{
    global $_zp_gallery, $_zp_current_album, $_zp_gallery_page;
    if (!is_null($_zp_current_album) || $_zp_gallery_page == 'album.php') {
        $currentfolder = $_zp_current_album->name;
    }
    if (is_null($showsubs)) {
        $showsubs = ALBUM_MENU_SHOWSUBS;
    }
    if ($showsubs && !is_numeric($showsubs)) {
        $showsubs = 9999999999.0;
    }
    if (!$skipform) {
        ?>
	<script type="text/javaScript">
		// <!-- <![CDATA[
		function gotoLink(form) {
		var OptionIndex=form.ListBoxURL.selectedIndex;
		parent.location = form.ListBoxURL.options[OptionIndex].value;
		}
		// ]]> -->
	</script>
	<form name="AutoListBox" action="#">
		<p>
			<select name="ListBoxURL" size="1" onchange="gotoLink(this.form);">
				<?php 
        if (!empty($indexname)) {
            $selected = checkSelectedAlbum("", "index");
            ?>
					<option <?php 
            echo $selected;
            ?>
 value="<?php 
            echo html_encode(getGalleryIndexURL());
            ?>
"><?php 
            echo $indexname;
            ?>
</option>
					<?php 
        }
    }
    $albums = getNestedAlbumList(null, $showsubs, false);
    foreach ($albums as $album) {
        $albumobj = newAlbum($album['name'], true);
        $count = '';
        if ($option == "count") {
            $numimages = $albumobj->getNumImages();
            if ($numimages != 0) {
                $count = " (" . $numimages . ")";
            }
        }
        $sortorder = count($album['sort_order']);
        $arrow = '';
        if ($sortorder > 1) {
            for ($c = 1; $c != $sortorder; $c++) {
                $arrow .= '» ';
            }
        }
        $selected = checkSelectedAlbum($albumobj->name, "album");
        if ($firstimagelink && $numimages != 0) {
            $link = "<option {$selected} value='" . html_encode($albumobj->getImage(0)->getLink()) . "'>" . $arrow . getBare($albumobj->getTitle()) . $count . "</option>";
        } else {
            $link = "<option {$selected} value='" . html_encode($albumobj->getLink(1)) . "'>" . $arrow . getBare($albumobj->getTitle()) . $count . "</option>";
        }
        echo $link;
    }
    if (!$skipform) {
        ?>
			</select>
		</p>
	</form>
	<?php 
    }
}
Beispiel #12
0
$album = internalToFilesystem($album8);
$image = internalToFilesystem($image8);
/* Prevent hotlinking to the full image from other domains. */
if (getOption('hotlink_protection') && isset($_SERVER['HTTP_REFERER'])) {
    preg_match('|(.*)//([^/]*)|', $_SERVER['HTTP_REFERER'], $matches);
    $checkstring = preg_replace('/^www./', '', strtolower($matches[2]));
    if (strpos($checkstring, ":")) {
        $checkstring = substr($checkstring, 0, strpos($checkstring, ":"));
    }
    if (preg_replace('/^www./', '', strtolower($_SERVER['SERVER_NAME'])) != $checkstring) {
        /* It seems they are directly requesting the full image. */
        header('Location: ' . FULLWEBPATH . '/index.php?album=' . $album8 . '&image=' . $image8);
        exitZP();
    }
}
$albumobj = newAlbum($album8, true, true);
$imageobj = newImage($albumobj, $image8, true);
$args = getImageArgs($_GET);
$args[0] = 'FULL';
$adminrequest = $args[12];
if ($forbidden = getOption('image_processor_flooding_protection') && (!isset($_GET['check']) || $_GET['check'] != sha1(HASH_SEED . serialize($args)))) {
    // maybe it was from the tinyZenpage javascript which does not know better!
    zp_session_start();
    $forbidden = !isset($_SESSION['adminRequest']) || $_SESSION['adminRequest'] != @$_COOKIE['zp_user_auth'];
}
$args[0] = 'FULL';
$hash = getOption('protected_image_password');
if (($hash || !$albumobj->checkAccess()) && !zp_loggedin(VIEW_FULLIMAGE_RIGHTS)) {
    //	handle password form if posted
    zp_handle_password('zp_image_auth', getOption('protected_image_password'), getOption('protected_image_user'));
    //check for passwords
    }
    $albumparm = '&amp;album=' . pathurlencode($folder);
}
if (isset($_GET['refresh'])) {
    if (empty($imageid)) {
        $metaURL = $backurl;
    } else {
        if (!empty($ret)) {
            $ret = '&amp;return=' . $ret;
        }
        $metaURL = $redirecturl = '?' . $type . 'refresh=continue&amp;id=' . $imageid . $albumparm . $ret . '&XSRFToken=' . getXSRFToken('refresh');
    }
} else {
    if ($type !== 'prune&amp;') {
        if (!empty($folder)) {
            $album = newAlbum($folder);
            if (!$album->isMyItem(ALBUM_RIGHTS)) {
                if (!zp_apply_filter('admin_managed_albums_access', false, $return)) {
                    header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php');
                    exitZP();
                }
            }
            $sql = "SELECT `id` FROM " . prefix('albums') . " WHERE `folder`=" . db_quote($folder);
            $row = query_single_row($sql);
            $id = $row['id'];
        }
        if (!empty($id)) {
            $imagewhere = "WHERE `albumid`={$id}";
            $r = " {$folder}";
            $albumwhere = "WHERE `parentid`={$id}";
        }
Beispiel #14
0
 public function getitems()
 {
     $items = array();
     if ($album = @$this->options['album']) {
         if ($image = @$this->options['image']) {
             if (!is_array($image)) {
                 $image = array($image);
             }
             foreach ($image as $filename) {
                 $obj = newImage(NULL, array('folder' => $album, 'filename' => $filename), true);
                 if ($obj->exists) {
                     $items[] = $obj;
                 }
             }
         } else {
             if (!is_array($album)) {
                 $album = array($album);
             }
             foreach ($album as $folder) {
                 $obj = newAlbum($folder, true);
                 if ($obj->exists) {
                     $items[] = $obj;
                 }
             }
         }
         return $items;
     }
     if ($this->feedtype == 'news' && ($news = @$this->options['titlelink'])) {
         if (!is_array($news)) {
             $news = array($news);
         }
         foreach ($news as $article) {
             $obj = new ZenpageNews($article, false);
             if ($obj->loaded) {
                 $items[] = array('titlelink' => $article);
             }
         }
         return $items;
     }
     if ($this->feedtype == 'pages' && ($pages = @$this->options['titlelink'])) {
         if (!is_array($pages)) {
             $pages = array($pages);
         }
         foreach ($pages as $page) {
             $obj = new ZenpagePage($page, false);
             if ($obj->loaded) {
                 $items[] = array('titlelink' => $page);
             }
         }
         return $items;
     }
     return parent::getitems();
 }
Beispiel #15
0
$combi = $obj->getOldCombiNews();
$cat = new ZenpageCategory('combiNews', true);
$cat->setTitle(gettext('combiNews'));
$cat->setDesc(gettext('Auto category for ported combi-news articles.'));
$cat->save();
foreach ($combi as $article) {
    switch ($article['type']) {
        case 'images':
            $obj = newImage(NULL, array('folder' => $article['albumname'], 'filename' => $article['titlelink']), false);
            if ($obj->exists) {
                $obj->setPublishDate($article['date']);
                self::publishArticle($obj, 'combiNews');
            }
            break;
        case 'albums':
            $obj = newAlbum($article['albumname'], false);
            if ($obj->exists) {
                $obj->setPublishDate($article['date']);
                self::publishArticle($obj, 'combiNews');
            }
            break;
    }
}
purgeOption('zenpage_combinews');
purgeOption('combinews-customtitle');
purgeOption('combinews-customtitle-imagetitles');
purgeOption("zenpage_combinews_sortorder");
purgeOption('zenpage_combinews_imagesize');
purgeOption('combinews-thumbnail-width');
purgeOption('combinews-thumbnail-height');
purgeOption('combinews-thumbnail-cropwidth');
Beispiel #16
0
         unset($_POST['instance']);
     }
     $id = sanitize($_POST['id']);
     switch ($_POST['type']) {
         case 'images':
             $img = newImage(NULL, array('folder' => dirname($id), 'filename' => basename($id)));
             if ($_POST['addToFavorites']) {
                 if ($img->loaded) {
                     $___Favorites->addImage($img);
                 }
             } else {
                 $___Favorites->removeImage($img);
             }
             break;
         case 'albums':
             $alb = newAlbum($id);
             if ($_POST['addToFavorites']) {
                 if ($alb->loaded) {
                     $___Favorites->addAlbum($alb);
                 }
             } else {
                 $___Favorites->removeAlbum($alb);
             }
             break;
     }
     unset($___Favorites);
     if (isset($_instance)) {
         unset($_instance);
     }
 }
 $_myFavorites = new favorites($_zp_current_admin_obj->getUser());
Beispiel #17
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();
 }
function getUploadImagesInAlbum($albumlist)
{
    $numbers = array();
    foreach ($albumlist as $key => $value) {
        $obj = newAlbum($key);
        $numbers[] = $obj->getNumImages();
    }
    $numimages = count($numbers);
    $content = $count = '';
    foreach ($numbers as $number) {
        $content .= "'";
        $count++;
        $content .= $number;
        if ($count < $numimages) {
            $content .= "',";
            // js array entry end
        } else {
            $content .= "'";
            // js array end
        }
    }
    return $content;
}
    static function thumb($image, $i, $field, $type)
    {
        global $albumHeritage;
        if ($type == 'save') {
            if (isset($_POST[$i . '-' . $field['name']])) {
                if ($thumbnail = $_POST[$i . '-' . $field['name']]) {
                    $talbum = newAlbum($thumbnail);
                    if ($image->imagefolder == $thumbnail) {
                        $talbum->setThumb($image->filename);
                    } else {
                        $talbum->setThumb('/' . $image->imagefolder . '/' . $image->filename);
                    }
                    $talbum->save();
                }
            }
            return NULL;
        } else {
            $item = NULL;
            if ($image->album->subRights() & MANAGED_OBJECT_RIGHTS_EDIT) {
                ob_start();
                ?>
				<select name="<?php 
                echo $i . '-' . $field['name'];
                ?>
" >
					<option value=""></option>
					<?php 
                generateListFromArray(array(), $albumHeritage, false, true);
                ?>
				</select>
				<?php 
                $item = ob_get_contents();
                ob_end_clean();
            }
            return $item;
        }
    }
Beispiel #20
0
/**
 * Prints an image or album statistic slideshow using the {@link http://galleria.io/  jQuery plugin Galleria}
 *
 * See readme/documentation for usage:
 * Call directly in a template file or codeblock.
 *
 * NOTE: movie and audio files not supported.
 *
 * @param string $type return statistics of either 'images' or 'albums'
 * @param integer $number the number of items to get (images or albums, depending on $type set)
 * @param string $option
 *  	"popular" for the most popular
 *		"latest" for the latest uploaded by id (Discovery)
 * 		"latest-date" for the latest by date
 * 		"latest-mtime" for the latest by mtime
 *   	"latest-publishdate" for the latest by publishdate
 *      "mostrated" for the most voted
 *		"toprated" for the best voted
 *		"latestupdated" for the latest updated
 *		"random" for random order (yes, strictly no statistical order...)
 * @param string $albumfolder foldername of a specific album to pull items from
 * @param bool $collection only if $albumfolder is set: true if you want to get statistics from this album and all of its subalbums
 * @param bool $linkslides true to link to image or album on slide, else click advances slideshow instead
 * @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 integer $threshold the minimum number of ratings an image must have to be included in the list. (Default 0)
 *
 */
function printGslideshowStatistic($type, $number, $option, $albumfolder = '', $collection = false, $linkslides = true, $autoplay = true, $threshold = 0)
{
    save_context();
    $data = 'data';
    $embedded = true;
    $forceheight = true;
    $imagenumber = 0;
    $albumtitle = '';
    $returnpath = '';
    require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/image_album_statistics.php';
    if ($type == 'album' || $type == 'albums') {
        $albums = getAlbumStatistic($number, $option, $albumfolder);
    } else {
        $images = getImageStatistic($number, $option, $albumfolder, $collection, $threshold);
    }
    ?>

			<script>
				var data = [

	<?php 
    if ($type == 'album' || $type == 'albums') {
        $c = 1;
        foreach ($albums as $album) {
            $tempalbum = newAlbum($album['folder']);
            $albumpath = html_encode(rewrite_path("/" . pathurlencode($tempalbum->name), "index.php?album=" . pathurlencode($tempalbum->name)));
            $albumthumb = $tempalbum->getAlbumThumbImage();
            $image = newImage($tempalbum, $albumthumb->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: \'' . html_encode($tempalbum->getTitle()) . '\',' . "\n";
                $desc = $tempalbum->getDesc();
                $desc = str_replace("\r\n", '<br />', $desc);
                $desc = str_replace("\r", '<br />', $desc);
                echo 'description: \'' . js_encode($desc) . '\',' . "\n";
                echo 'link: \'' . $albumpath . '\'' . "\n";
                if ($c == $number) {
                    echo '}' . "\n";
                } else {
                    echo '},' . "\n";
                }
            }
            $c++;
        }
        echo "\n";
    } else {
        $c = 1;
        foreach ($images as $image) {
            $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: \'' . html_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";
                echo 'link: \'' . html_encode($image->getLink()) . '\'' . "\n";
                if ($c == $number) {
                    echo '}' . "\n";
                } else {
                    echo '},' . "\n";
                }
            }
            $c++;
        }
        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
}
Beispiel #21
0
 /**
  * Gets the feed item data in a comments feed
  *
  * @param array $item Array of a comment
  * @return array
  */
 protected function getitemComments($item)
 {
     if ($item['anon']) {
         $author = "";
     } else {
         $author = " " . gettext("by") . " " . $item['name'];
     }
     $commentpath = $imagetag = $title = '';
     switch ($item['type']) {
         case 'images':
             $title = get_language_string($item['title']);
             $obj = newImage(array('folder' => $item['folder'], 'filename' => $item['filename']));
             $link = $obj->getlink();
             $feeditem['pubdate'] = date("r", strtotime($item['date']));
             $category = get_language_string($item['albumtitle']);
             $website = $item['website'];
             $title = $category . ": " . $title;
             $commentpath = PROTOCOL . '://' . $this->host . $link . "#" . $item['id'];
             break;
         case 'albums':
             $obj = newAlbum($item['folder']);
             $link = rtrim($obj->getLink(), '/');
             $feeditem['pubdate'] = date("r", strtotime($item['date']));
             $title = get_language_string($item['albumtitle']);
             $website = $item['website'];
             $commentpath = PROTOCOL . '://' . $this->host . $link . "#" . $item['id'];
             break;
         case 'news':
         case 'pages':
             if (extensionEnabled('zenpage')) {
                 $feeditem['pubdate'] = date("r", strtotime($item['date']));
                 $category = '';
                 $title = get_language_string($item['title']);
                 $titlelink = $item['titlelink'];
                 $website = $item['website'];
                 if ($item['type'] == 'news') {
                     $obj = newArticle($titlelink);
                 } else {
                     $obj = newPage($titlelink);
                 }
                 $commentpath = PROTOCOL . '://' . $this->host . html_encode($obj->getLink()) . "#" . $item['id'];
             } else {
                 $commentpath = '';
             }
             break;
     }
     $feeditem['title'] = getBare($title . $author);
     $feeditem['link'] = $commentpath;
     $feeditem['desc'] = $item['comment'];
     return $feeditem;
 }
Beispiel #22
0
 static function getSlideshowPlayer($album, $controls = false, $width = NULL, $height = NULL)
 {
     $albumobj = NULL;
     if (!empty($album)) {
         $albumobj = newAlbum($album, NULL, true);
     }
     if (is_object($albumobj) && $albumobj->loaded) {
         $returnpath = rewrite_path(pathurlencode($albumobj->name) . '/', '/index.php?album=' . urlencode($albumobj->name));
         return cycle::getShow(false, false, $albumobj, NULL, $width, $height, false, false, false, $controls, $returnpath, 0);
     } else {
         return '<div class="errorbox" id="message"><h2>' . gettext('Invalid slideshow album name!') . '</h2></div>';
     }
 }
Beispiel #23
0
     $album = newAlbum($alb);
     $albumtitle = $album->getTitle();
     $themename = $album->getAlbumTheme();
 }
 if (!empty($_REQUEST['optiontheme'])) {
     $themename = sanitize($_REQUEST['optiontheme']);
 }
 if (empty($alb)) {
     foreach ($themelist as $albumtitle => $alb) {
         break;
     }
     if (empty($alb)) {
         $album = NULL;
     } else {
         $alb = sanitize_path($alb);
         $album = newAlbum($alb);
         $albumtitle = $album->getTitle();
         $themename = $album->getAlbumTheme();
     }
 }
 if (!(false === ($requirePath = getPlugin('themeoptions.php', $themename)))) {
     require_once $requirePath;
     $optionHandler = new ThemeOptions();
     $supportedOptions = $optionHandler->getOptionsSupported();
     if (method_exists($optionHandler, 'getOptionsDisabled')) {
         $unsupportedOptions = $optionHandler->getOptionsDisabled();
     } else {
         $unsupportedOptions = array();
     }
 } else {
     $unsupportedOptions = array();
/**
 *
 * Checks for bad parentIDs from old move/copy bug
 * @param unknown_type $albumname
 * @param unknown_type $id
 */
function checkAlbumParentid($albumname, $id, $recorder)
{
    $album = newAlbum($albumname);
    $oldid = $album->getParentID();
    if ($oldid != $id) {
        $album->set('parentid', $id);
        $album->save();
        if (is_null($oldid)) {
            $oldid = '<em>NULL</em>';
        }
        if (is_null($id)) {
            $id = '<em>NULL</em>';
        }
        $msg = sprintf('Fixed album <strong>%1$s</strong>: parentid was %2$s should have been %3$s<br />', $albumname, $oldid, $id);
        $recorder($msg, true);
    }
    $id = $album->getID();
    if (!$album->isDynamic()) {
        $albums = $album->getAlbums();
        foreach ($albums as $albumname) {
            checkAlbumParentid($albumname, $id, $recorder);
        }
    }
}
Beispiel #25
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 #26
0
 /**
  * Gets an array of the album ids of all accessible albums (publich or user dependend)
  *
  * @param object $obj from whence to get the albums
  * @param array $albumlist collects the list
  */
 protected function getAllAccessibleAlbums($obj, &$albumlist)
 {
     $locallist = $obj->getAlbums();
     foreach ($locallist as $folder) {
         $album = newAlbum($folder);
         if (!$album->isDynamic() && $album->checkAccess()) {
             $albumlist[] = $album->getID();
             self::getAllAccessibleAlbums($album, $albumlist);
         }
     }
 }
Beispiel #27
0
    /**
     * Prints a playlist using jPlayer. Several playlists per page supported.
     *
     * 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, although Flowplayer 3 also supports images
     * Replace the entire 'next_image()' loop on album.php with this:
     * <?php printjPlayerPlaylist("playlist"); ?> or <?php printjPlayerPlaylist("playlist-audio"); ?>
     *
     * @param string $option "playlist" use for pure video and mixed video/audio playlists or if you want to show the poster/videothumb with audio only playlists,
     * 											 "playlist-audio" use for pure audio playlists (m4a,mp3,fla supported only) if you don't need the poster/videothumb to be shown only.
     * @param string $albumfolder album name to get a playlist from directly
     */
    function printjPlayerPlaylist($option = "playlist", $albumfolder = "")
    {
        global $_zp_current_album, $_zp_current_search;
        if (empty($albumfolder)) {
            if (in_context(ZP_SEARCH)) {
                $albumobj = $_zp_current_search;
            } else {
                $albumobj = $_zp_current_album;
            }
        } else {
            $albumobj = newAlbum($albumfolder);
        }
        $entries = $albumobj->getImages(0);
        if (($numimages = count($entries)) != 0) {
            switch ($option) {
                case 'playlist':
                    $suffixes = array('m4a', 'm4v', 'mp3', 'mp4', 'flv', 'fla');
                    break;
                case 'playlist-audio':
                    $suffixes = array('m4a', 'mp3', 'fla');
                    break;
                default:
                    //	an invalid option parameter!
                    return;
            }
            $id = $albumobj->getID();
            ?>
			<script type="text/javascript">
								//<![CDATA[
								$(document).ready(function(){
				new jPlayerPlaylist({
				jPlayer: "#jquery_jplayer_<?php 
            echo $id;
            ?>
",
								cssSelectorAncestor: "#jp_container_<?php 
            echo $id;
            ?>
"
				}, [
			<?php 
            $count = '';
            $number = '';
            foreach ($entries as $entry) {
                $count++;
                if (is_array($entry)) {
                    $ext = getSuffix($entry['filename']);
                } else {
                    $ext = getSuffix($entry);
                }
                $numbering = '';
                if (in_array($ext, $suffixes)) {
                    $number++;
                    if (getOption('jplayer_playlist_numbered')) {
                        $numbering = '<span>' . $number . '</span>';
                    }
                    $video = newImage($albumobj, $entry);
                    $videoThumb = '';
                    $this->setModeAndSuppliedFormat($ext);
                    if ($option == 'playlist' && getOption('jplayer_poster')) {
                        $videoThumb = ',poster:"' . $video->getCustomImage(null, $this->width, $this->height, $this->width, $this->height, null, null, true) . '"';
                    }
                    $playtime = '';
                    if (getOption('jplayer_playlist_playtime')) {
                        $playtime = ' (' . $video->get('VideoPlaytime') . ')';
                    }
                    ?>
						{
						title:"<?php 
                    echo $numbering . html_encode($video->getTitle()) . $playtime;
                    ?>
",
					<?php 
                    if (getOption('jplayer_download')) {
                        ?>
							free:true,
					<?php 
                    }
                    ?>
					<?php 
                    echo $this->supplied;
                    ?>
:"<?php 
                    echo html_encode(pathurlencode($url = $video->getFullImageURL(FULLWEBPATH)));
                    ?>
"
					<?php 
                    echo $this->getCounterpartFiles($url, $ext);
                    ?>
					<?php 
                    echo $videoThumb;
                    ?>
						}
					<?php 
                    if ($numimages != $count) {
                        echo ',';
                    }
                }
                // if video
            }
            // foreach
            // for some reason the playlist must run with supplied: "flash,html" because otherwise neither videothumbs(poster) nor flv/flv work on Safari 4.1.
            // Seems the flash fallback fails here
            ?>
				], {
				swfPath: "<?php 
            echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER;
            ?>
/jplayer/js",
								solution: "flash,html",
			<?php 
            if ($option == 'playlist') {
                ?>
					supplied: "m4v, mp4, m4a, mp3, fla, flv<?php 
                echo $this->supplied_counterparts;
                ?>
"
			<?php 
            } else {
                ?>
					supplied: "m4a, mp3, fla<?php 
                echo $this->supplied_counterparts;
                ?>
"
				<?php 
            }
            if ($option != 'playlist-audio') {
                ?>
					, size: {
					width: "<?php 
                echo $this->width;
                ?>
px",
									height: "<?php 
                echo $this->height;
                ?>
px",
									cssClass: "<?php 
                echo $this->playersize;
                ?>
"
					}
			<?php 
            }
            ?>
				useStateClassSkin: true,
								autoBlur: false,
								smoothPlayBar: true,
								keyEnabled: true,
								remainingDuration: true,
								toggleDuration: true
				});
				});
								//]]>
			</script>
			<?php 
            if ($option == 'playlist') {
                ?>
				<div id="jp_container_<?php 
                echo $id;
                ?>
" class="jp-video <?php 
                echo $this->playersize;
                ?>
" role="application" aria-label="media player">
					<div class="jp-type-playlist">
						<div id="jquery_jplayer_<?php 
                echo $id;
                ?>
" class="jp-jplayer"></div>
						<div class="jp-gui">
							<div class="jp-video-play">
								<button class="jp-video-play-icon" role="button" tabindex="0"><?php 
                echo gettext('play');
                ?>
</button>
							</div>
							<div class="jp-interface">
								<div class="jp-progress">
									<div class="jp-seek-bar">
										<div class="jp-play-bar"></div>
									</div>
								</div>
								<div class="jp-current-time" role="timer" aria-label="time">&nbsp;</div>
								<div class="jp-duration" role="timer" aria-label="duration">&nbsp;</div>
								<div class="jp-controls-holder">
									<?php 
                echo $this->getPlayerHTMLparts('video', 'controls-playlist');
                ?>
									<div class="jp-volume-controls">
										<button class="jp-mute" role="button" tabindex="0"><?php 
                echo gettext('mute');
                ?>
</button>
										<button class="jp-volume-max" role="button" tabindex="0"><?php 
                echo gettext('max volume');
                ?>
</button>
										<div class="jp-volume-bar">
											<div class="jp-volume-bar-value"></div>
										</div>
									</div>
									<?php 
                echo $this->getPlayerHTMLparts('video', 'toggles-playlist');
                ?>
								</div>
								<div class="jp-details">
									<div class="jp-title" aria-label="title">&nbsp;</div>
								</div>
							</div>
						</div>
						<div class="jp-playlist">
							<ul>
								<!-- The method Playlist.displayPlaylist() uses this unordered list -->
								<li>&nbsp;</li>
							</ul>
						</div>
						<?php 
                echo $this->getPlayerHTMLparts('video', 'no-solution');
                ?>
					</div>
				</div>
				<?php 
            } else {
                // playlist-audio
                ?>
				<div id="jquery_jplayer_<?php 
                echo $id;
                ?>
" class="jp-jplayer"></div>
				<div id="jp_container_<?php 
                echo $id;
                ?>
" class="jp-audio" role="application" aria-label="media player">
					<div class="jp-type-playlist">
						<div class="jp-gui jp-interface">
							<?php 
                echo $this->getPlayerHTMLparts('audio', 'controls-playlist');
                ?>
							<div class="jp-progress">
								<div class="jp-seek-bar">
									<div class="jp-play-bar"></div>
								</div>
							</div>
							<div class="jp-volume-controls">
								<button class="jp-mute" role="button" tabindex="0"><?php 
                echo gettext('mute');
                ?>
</button>
								<button class="jp-volume-max" role="button" tabindex="0"><?php 
                echo gettext('max volume');
                ?>
</button>
								<div class="jp-volume-bar">
									<div class="jp-volume-bar-value"></div>
								</div>
							</div>
							<div class="jp-time-holder">
								<div class="jp-current-time" role="timer" aria-label="time">&nbsp;</div>
								<div class="jp-duration" role="timer" aria-label="duration">&nbsp;</div>
							</div>
							<?php 
                echo $this->getPlayerHTMLparts('audio', 'toggles-playlist');
                ?>
						</div>
						<div class="jp-playlist">
							<ul>
								<li>&nbsp;</li>
							</ul>
						</div>
						<?php 
                echo $this->getPlayerHTMLparts('audio', 'no-solution');
                ?>
					</div>
				</div>

				<?php 
            }
            // if else playlist
        }
        // if no images at all end
    }
    /** Prints the jQuery bxslider HTML setup to be replaced by JS
     *
     * @param int $minitems The minimum number of thumbs to be visible always if resized regarding responsiveness.
     * @param int $maxitems The maximum number of thumbs to be visible always if resized regarding responsiveness.
     * @param int $width Width Set to NULL if you want to use the backend plugin options.
     * @param int $height Height Set to NULL if you want to use the backend plugin options.
     * @param int $cropw Crop width Set to NULL if you want to use the backend plugin options.
     * @param int $croph Crop heigth Set to NULL if you want to use the backend plugin options.
     * @param bool $crop TRUE for cropped thumbs, FALSE for un-cropped thumbs. $width and $height then will be used as maxspace. Set to NULL if you want to use the backend plugin options.
     * @param bool $fullimagelink Set to TRUE if you want the thumb link to link to the full image instead of the image page. Set to NULL if you want to use the backend plugin options.
     * @param string $mode 'horizontal','vertical', 'fade'
     * @param int $speed The speed in miliseconds the slides advance when clicked
     */
    function printThumbNav($minitems = NULL, $maxitems = NULL, $width = NULL, $height = NULL, $cropw = NULL, $croph = NULL, $fullimagelink = NULL, $mode = NULL, $speed = NULL)
    {
        global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_search, $_zp_gallery_page;
        //	Just incase the theme has not set the option, at least second try will work!
        setOptionDefault('bxslider_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page), 1);
        $items = "";
        if (is_object($_zp_current_album) && $_zp_current_album->getNumImages() >= 2) {
            if (is_null($minitems)) {
                $minitems = getOption('bxslider_minitems');
            } else {
                $minitems = sanitize_numeric($minitems);
            }
            $minitems = max(1, (int) $minitems);
            if (is_null($maxitems)) {
                $maxitems = getOption('bxslider_maxitems');
            } else {
                $maxitems = sanitize_numeric($maxitems);
            }
            $maxitems = max(1, (int) $maxitems);
            if (is_null($width)) {
                $width = getOption('bxslider_width');
            } else {
                $width = sanitize_numeric($width);
            }
            if (is_null($height)) {
                $height = getOption('bxslider_height');
            } else {
                $height = sanitize_numeric($height);
            }
            if (is_null($cropw)) {
                $cropw = getOption('bxslider_cropw');
            } else {
                $cropw = sanitize_numeric($cropw);
            }
            if (is_null($croph)) {
                $croph = getOption('bxslider_croph');
            } else {
                $croph = sanitize_numeric($croph);
            }
            if (is_null($fullimagelink)) {
                $fullimagelink = getOption('bxslider_fullimagelink');
            } else {
                $fullimagelink = sanitize($fullimagelink);
            }
            if (is_null($mode)) {
                $mode = getOption('bxslider_mode');
            } else {
                $mode = sanitize($mode);
            }
            if (is_null($speed)) {
                $speed = getOption('bxslider_speed');
            } else {
                $speed = sanitize_numeric($speed);
            }
            if (in_context(ZP_SEARCH_LINKED)) {
                if ($_zp_current_search->getNumImages() === 0) {
                    $searchimages = false;
                } else {
                    $searchimages = true;
                }
            } else {
                $searchimages = false;
            }
            if (in_context(ZP_SEARCH_LINKED) && $searchimages) {
                $bxslider_items = $_zp_current_search->getImages();
            } else {
                $bxslider_items = $_zp_current_album->getImages();
            }
            if (count($bxslider_items) >= 2) {
                foreach ($bxslider_items as $item) {
                    if (is_array($item)) {
                        $imgobj = newImage(newAlbum($item['folder']), $item['filename']);
                    } else {
                        $imgobj = newImage($_zp_current_album, $item);
                    }
                    if ($fullimagelink) {
                        $link = $imgobj->getFullImageURL();
                    } else {
                        $link = $imgobj->getLink();
                    }
                    if (!is_null($_zp_current_image)) {
                        if ($_zp_current_album->isDynamic()) {
                            if ($_zp_current_image->filename == $imgobj->filename && $_zp_current_image->getAlbum()->name == $imgobj->getAlbum()->name) {
                                $active = ' class="activeimg" ';
                            } else {
                                $active = '';
                            }
                        } else {
                            if ($_zp_current_image->filename == $imgobj->filename) {
                                $active = ' class="activeimg" ';
                            } else {
                                $active = '';
                            }
                        }
                    } else {
                        $active = '';
                    }
                    $imageurl = $imgobj->getCustomImage(NULL, $width, $height, $cropw, $croph, NULL, NULL, true);
                    $items[] = '<li' . $active . '><a href="' . $link . '"><img src="' . html_encode($imageurl) . '" alt="' . html_encode($imgobj->getTitle()) . '"></a></li>';
                }
            }
            $albumid = $_zp_current_album->get('id');
            //$items = substr($items, 0, -2);
            $numimages = getNumImages();
            if (!is_null($_zp_current_image)) {
                $imgnumber = imageNumber() - 1;
            } else {
                $imgnumber = 0;
            }
            ?>
			<ul class="bxslider<?php 
            echo $albumid;
            ?>
">
				<?php 
            $count = '';
            foreach ($items as $item) {
                echo $item;
            }
            ?>
			</ul>
			<script type="text/javascript">
				$(document).ready(function() {
					var index = $('.bxslider<?php 
            echo $albumid;
            ?>
 li.activeimg').index();
					index = ++index;
					currentPager = parseInt(index / <?php 
            echo $maxitems;
            ?>
)
					$('.bxslider<?php 
            echo $albumid;
            ?>
').bxSlider({
						mode: '<?php 
            echo $mode;
            ?>
',
						minSlides: <?php 
            echo $minitems;
            ?>
,
						maxSlides: <?php 
            echo $maxitems;
            ?>
,
						speed: <?php 
            echo $speed;
            ?>
,
						slideWidth: <?php 
            echo $width;
            ?>
,
						slideMargin: 5,
						moveSlides: <?php 
            echo $maxitems;
            ?>
 - 1,
						pager: false,
						adaptiveHeight: true,
						useCSS: false,
						startSlide: currentPager
					});
				});
			</script>
			<?php 
        }
    }
Beispiel #29
0
 /**
  * For every image in the album, look for its file. Delete from the database
  * if the file does not exist. Same for each sub-directory/album.
  *
  * @param bool $deep set to true for a thorough cleansing
  */
 function garbageCollect($deep = false)
 {
     if (is_null($this->images)) {
         $this->getImages();
     }
     $result = query("SELECT * FROM " . prefix('images') . " WHERE `albumid` = '" . $this->id . "'");
     $dead = array();
     $live = array();
     $files = $this->loadFileNames();
     // Does the filename from the db row match any in the files on disk?
     while ($row = db_fetch_assoc($result)) {
         if (!in_array($row['filename'], $files)) {
             // In the database but not on disk. Kill it.
             $dead[] = $row['id'];
         } else {
             if (in_array($row['filename'], $live)) {
                 // Duplicate in the database. Kill it.
                 $dead[] = $row['id'];
                 // Do something else here? Compare titles/descriptions/metadata/update dates to see which is the latest?
             } else {
                 $live[] = $row['filename'];
             }
         }
     }
     db_free_result($result);
     if (count($dead) > 0) {
         $sql = "DELETE FROM " . prefix('images') . " WHERE `id` = '" . array_pop($dead) . "'";
         $sql2 = "DELETE FROM " . prefix('comments') . " WHERE `type`='albums' AND `ownerid` = '" . array_pop($dead) . "'";
         foreach ($dead as $id) {
             $sql .= " OR `id` = '{$id}'";
             $sql2 .= " OR `ownerid` = '{$id}'";
         }
         query($sql);
         query($sql2);
     }
     // Get all sub-albums and make sure they exist.
     $result = query("SELECT * FROM " . prefix('albums') . " WHERE `folder` LIKE " . db_quote(db_LIKE_escape($this->name) . '%'));
     $dead = array();
     $live = array();
     // Does the dirname from the db row exist on disk?
     while ($row = db_fetch_assoc($result)) {
         if (!is_dir(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($row['folder'])) || in_array($row['folder'], $live) || substr($row['folder'], -1) == '/' || substr($row['folder'], 0, 1) == '/') {
             $dead[] = $row['id'];
         } else {
             $live[] = $row['folder'];
         }
     }
     db_free_result($result);
     if (count($dead) > 0) {
         $sql = "DELETE FROM " . prefix('albums') . " WHERE `id` = '" . array_pop($dead) . "'";
         $sql2 = "DELETE FROM " . prefix('comments') . " WHERE `type`='albums' AND `ownerid` = '" . array_pop($dead) . "'";
         foreach ($dead as $albumid) {
             $sql .= " OR `id` = '{$albumid}'";
             $sql2 .= " OR `ownerid` = '{$albumid}'";
         }
         query($sql);
         query($sql2);
     }
     if ($deep) {
         foreach ($this->getAlbums(0) as $dir) {
             $subalbum = newAlbum($dir);
             // Could have been deleted if it didn't exist above...
             if ($subalbum->exists) {
                 $subalbum->garbageCollect($deep);
             }
         }
     }
 }
/**
 * 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;
}