/**
 *
 * used to get a list of albums to be further processed
 * @param object $obj from whence to get the albums
 * @param array $albumlist collects the list
 */
function getImageAlbumAlbumList($obj, &$albumlist)
{
    global $_zp_gallery;
    $hint = $show = false;
    $locallist = $obj->getAlbums();
    foreach ($locallist as $folder) {
        $album = new Album($_zp_gallery, $folder);
        if (!$album->isDynamic() && $album->checkAccess($hint, $show)) {
            $albumlist[] = $album->getID();
            getImageAlbumAlbumList($album, $albumlist);
        }
    }
}
/**
 * Gets the content of a news article
 *
 * If using the CombiNews feature this returns the description for gallery items (see printNewsContent for more)
 *
 * @param int $shorten The optional length of the content for the news list for example, will override the plugin option setting if set, "" (empty) for full content (not used for image descriptions!)
 * @param string $shortenindicator The placeholder to mark the shortening (e.g."(...)"). If empty the Zenpage option for this is used.
 * @param string $readmore The text for the "read more" link. If empty the term set in Zenpage option is used.
 *
 * @return string
 */
function getNewsContent($shorten = false, $shortenindicator = NULL, $readmore = NULL)
{
    global $_zp_flash_player, $_zp_current_image, $_zp_gallery, $_zp_current_zenpage_news, $_zp_page;
    $newstype = getNewsType();
    switch ($newstype) {
        case 'news':
            if (!$_zp_current_zenpage_news->checkAccess()) {
                return '<p>' . gettext('<em>This article belongs to a protected category.</em>') . '</p>';
            }
            break;
        case 'image':
            $album = getNewsAlbumName();
            $albumobj = new Album($_zp_gallery, $album);
            if (!$albumobj->checkAccess()) {
                return '<p>' . gettext('<em>This entry belongs to a protected album.</em>') . '</p>';
            }
            break;
        case 'album':
            if (!$_zp_current_zenpage_news->checkAccess()) {
                return '<p>' . gettext('<em>This entry belongs to a protected album.</em>') . '</p>';
            }
            break;
    }
    $excerptbreak = false;
    if (!$shorten && !is_NewsArticle()) {
        $shorten = ZP_SHORTEN_LENGTH;
    }
    $articlecontent = "";
    $size = ZP_CN_IMAGESIZE;
    $width = ZP_CN_THUMBWIDTH;
    $height = ZP_CN_THUMBHEIGHT;
    $cropwidth = ZP_CN_CROPWIDTH;
    $cropheight = ZP_CN_CROPHEIGHT;
    $cropx = ZP_CN_CROPX;
    $cropy = ZP_CN_CROPY;
    $mode = ZP_CN_MODE;
    switch ($newstype) {
        case 'news':
            $articlecontent = $_zp_current_zenpage_news->getContent();
            if (!is_NewsArticle()) {
                $articlecontent = getContentShorten($articlecontent, $shorten, $shortenindicator, $readmore, getNewsURL($_zp_current_zenpage_news->getTitlelink()));
            }
            break;
        case 'image':
            switch ($mode) {
                case 'latestimages-sizedimage':
                    if (isImagePhoto($_zp_current_zenpage_news)) {
                        $articlecontent = '<a href="' . html_encode($_zp_current_zenpage_news->getImageLink()) . '" title="' . html_encode($_zp_current_zenpage_news->getTitle()) . '">';
                        $articlecontent .= '<img src="' . html_encode($_zp_current_zenpage_news->getSizedImage($size)) . '" alt="' . html_encode($_zp_current_zenpage_news->getTitle()) . '" />';
                        $articlecontent .= '</a>';
                    } else {
                        if (isImageVideo($_zp_current_zenpage_news)) {
                            $articlecontent .= $_zp_current_zenpage_news->getSizedImage($size);
                        } else {
                            $articlecontent = '<a href="' . html_encode($_zp_current_zenpage_news->getImageLink()) . '" title="' . html_encode($_zp_current_zenpage_news->getTitle()) . '">';
                            $articlecontent .= '<img src="' . html_encode($_zp_current_zenpage_news->getCustomImage($size, NULL, NULL, NULL, NULL, NULL, NULL, true)) . '" alt="' . html_encode($_zp_current_zenpage_news->getTitle()) . '" />';
                            $articlecontent .= '</a>';
                        }
                    }
                    break;
                case 'latestimages-thumbnail':
                    $articlecontent = '<a href="' . html_encode($_zp_current_zenpage_news->getImageLink()) . '" title="' . html_encode($_zp_current_zenpage_news->getTitle()) . '"><img src="' . html_encode($_zp_current_zenpage_news->getThumb()) . '" alt="' . html_encode($_zp_current_zenpage_news->getTitle()) . '" /></a>';
                    break;
                case 'latestimages-thumbnail-customcrop':
                    if (isImagePhoto($_zp_current_zenpage_news)) {
                        $articlecontent = '<a href="' . html_encode($_zp_current_zenpage_news->getImageLink()) . '" title="' . html_encode($_zp_current_zenpage_news->getTitle()) . '"><img src="' . html_encode($_zp_current_zenpage_news->getCustomImage(NULL, $width, $height, $cropwidth, $cropheight, $cropx, $cropy)) . '" alt="' . html_encode($_zp_current_zenpage_news->getTitle()) . '" /></a>';
                    } else {
                        $articlecontent = '<a href="' . html_encode($_zp_current_zenpage_news->getImageLink()) . '" title="' . html_encode($_zp_current_zenpage_news->getTitle()) . '"><img src="' . html_encode($_zp_current_zenpage_news->getCustomImage(NULL, $width, $height, $cropwidth, $cropheight, $cropx, $cropy, true)) . '" alt="' . html_encode($_zp_current_zenpage_news->getTitle()) . '" /></a>';
                    }
                    break;
            }
            $articlecontent .= getContentShorten($_zp_current_zenpage_news->getDesc(), $shorten, $shortenindicator, $readmore, $_zp_current_zenpage_news->getImageLink());
            break;
        case 'video':
            $articlecontent = getNewsVideoContent($_zp_current_zenpage_news, $shorten);
            break;
        case 'album':
            $_zp_page = 1;
            $albumdesc = getContentShorten($_zp_current_zenpage_news->getDesc(), $shorten, $shortenindicator, $readmore, $_zp_current_zenpage_news->getAlbumLink());
            $albumthumbobj = $_zp_current_zenpage_news->getAlbumThumbImage();
            switch ($mode) {
                case 'latestalbums-sizedimage':
                    if (isImagePhoto($albumthumbobj)) {
                        $imgurl = html_encode($albumthumbobj->getSizedImage($size));
                    } else {
                        $imgurl = html_encode($albumthumbobj->getCustomImage($size, NULL, NULL, NULL, NULL, NULL, NULL, true));
                    }
                    $articlecontent = '<a href="' . html_encode($_zp_current_zenpage_news->getAlbumLink()) . '" title="' . html_encode($_zp_current_zenpage_news->getTitle()) . '"><img src="' . $imgurl . '" alt="' . html_encode($_zp_current_zenpage_news->getTitle()) . '" /></a>' . $albumdesc;
                    break;
                case 'latestalbums-thumbnail':
                    $articlecontent = '<a href="' . html_encode($_zp_current_zenpage_news->getAlbumLink()) . '" title="' . html_encode($_zp_current_zenpage_news->getTitle()) . '"><img src="' . html_encode($_zp_current_zenpage_news->getAlbumThumb()) . '" alt="' . html_encode($_zp_current_zenpage_news->getTitle()) . '" /></a>' . $albumdesc;
                    break;
                case 'latestalbums-thumbnail-customcrop':
                    $articlecontent = '<a href="' . html_encode($_zp_current_zenpage_news->getAlbumLink()) . '" title="' . html_encode($_zp_current_zenpage_news->getTitle()) . '"><img src="' . html_encode($albumthumbobj->getCustomImage(NULL, $width, $height, $cropwidth, $cropheight, $cropx, $cropy, true)) . '" alt="' . html_encode($_zp_current_zenpage_news->getTitle()) . '" /></a>' . $albumdesc;
                    break;
                case 'latestimagesbyalbum-thumbnail':
                case 'latestimagesbyalbum-thumbnail-customcrop':
                case 'latestimagesbyalbum-sizedimage':
                    $images = query_full_array("SELECT title, filename FROM " . prefix('images') . " AS images WHERE date LIKE '" . $_zp_current_zenpage_news->getDateTime() . "%' AND albumid = " . $_zp_current_zenpage_news->id . " ORDER BY date DESC");
                    foreach ($images as $image) {
                        $imageobj = newImage($_zp_current_zenpage_news, $image['filename']);
                        if (getOption('combinews-latestimagesbyalbum-imgdesc')) {
                            $imagedesc = $imageobj->getDesc();
                            $imagedesc = getContentShorten($imagedesc, $shorten, $shortenindicator, $readmore, $imageobj->getImageLink());
                        } else {
                            $imagedesc = '';
                        }
                        $articlecontent .= '<div class="latestimagesbyalbum">';
                        // entry wrapper
                        switch ($mode) {
                            case 'latestimagesbyalbum-thumbnail':
                                if (getOption('combinews-latestimagesbyalbum-imgtitle')) {
                                    $articlecontent .= '<h4>' . html_encode($imageobj->getTitle()) . '</h4>';
                                }
                                $articlecontent .= '<a href="' . html_encode($imageobj->getImageLink()) . '" title="' . html_encode($imageobj->getTitle()) . '"><img src="' . html_encode($imageobj->getThumb()) . '" alt="' . html_encode($imageobj->getTitle()) . '" /></a>' . $imagedesc;
                                break;
                            case 'latestimagesbyalbum-thumbnail-customcrop':
                                if (getOption('combinews-latestimagesbyalbum-imgtitle')) {
                                    $articlecontent .= '<h4>' . html_encode($imageobj->getTitle()) . '</h4>';
                                }
                                if (isImagePhoto($imageobj)) {
                                    $articlecontent .= '<a href="' . html_encode($imageobj->getImageLink()) . '" title="' . html_encode($imageobj->getTitle()) . '"><img src="' . html_encode($imageobj->getCustomImage(NULL, $width, $height, $cropwidth, $cropheight, $cropx, $cropy)) . '" alt="' . html_encode($imageobj->getTitle()) . '" /></a>' . $imagedesc;
                                } else {
                                    if (isImageVideo($imageobj)) {
                                        $articlecontent .= getNewsVideoContent($imageobj) . $imagedesc;
                                    } else {
                                        $articlecontent .= '<a href="' . html_encode($imageobj->getImageLink()) . '" title="' . html_encode($imageobj->getTitle()) . '"><img src="' . html_encode($imageobj->getCustomImage(NULL, $width, $height, $cropwidth, $cropheight, $cropx, $cropy, true)) . '" alt="' . html_encode($imageobj->getTitle()) . '" /></a>' . $imagedesc;
                                    }
                                }
                                break;
                            case 'latestimagesbyalbum-sizedimage':
                                if (getOption('combinews-latestimagesbyalbum-imgtitle')) {
                                    $articlecontent .= '<h4>' . html_encode($imageobj->getTitle()) . '</h4>';
                                }
                                if (isImagePhoto($imageobj)) {
                                    $articlecontent .= '<a href="' . html_encode($imageobj->getImageLink()) . '" title="' . html_encode($imageobj->getTitle()) . '"><img src="' . pathurlencode($imageobj->getSizedImage($size)) . '" alt="' . html_encode($imageobj->getTitle()) . '" /></a>' . $imagedesc;
                                } else {
                                    if (isImageVideo($imageobj)) {
                                        $articlecontent .= getNewsVideoContent($imageobj) . $imagedesc;
                                    } else {
                                        $articlecontent .= '<a href="' . html_encode($imageobj->getImageLink()) . '" title="' . html_encode($imageobj->getTitle()) . '"><img src="' . html_encode($imageobj->getCustomImage($size, NULL, NULL, NULL, NULL, NULL, NULL, true)) . '" alt="' . html_encode($imageobj->getTitle()) . '" /></a>' . $imagedesc;
                                    }
                                }
                                break;
                        }
                        // switch "latest images by album end"
                        $articlecontent .= '</div>';
                        // entry wrapper end
                    }
                    // foreach end
                    break;
            }
            // switch "albums mode end"
    }
    // main switch end
    return $articlecontent;
}
Example #3
0
/* Prevent hotlinking to the full image from other servers. */
$server = $_SERVER['SERVER_NAME'];
if (isset($_SERVER['HTTP_REFERER'])) {
    $test = strpos($_SERVER['HTTP_REFERER'], $server);
} else {
    $test = true;
}
if ($test == FALSE && getOption('hotlink_protection')) {
    /* It seems they are directly requesting the full image. */
    $i = 'index.php?album=' . $album8 . '&image=' . $image8;
    header("Location: {$i}");
    exit;
}
$_zp_gallery = new Gallery();
$albumobj = new Album($_zp_gallery, $album8);
if (!$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
    $hash = getOption('protected_image_password');
    $authType = 'zp_image_auth';
    $hint = get_language_string(getOption('protected_image_hint'));
    $show = getOption('protected_image_user');
    if (empty($hash)) {
        // check for album password
        $hash = $albumobj->getPassword();
        $authType = "zp_album_auth_" . $albumobj->get('id');
        $hint = $albumobj->getPasswordHint();
        $show = $albumobj->getUser();
        if (empty($hash)) {
            $albumobj = $albumobj->getParent();