Ejemplo n.º 1
0
function accessAlbums($attr, $path, $data, $volume)
{
    //	restrict access to his albums
    $base = explode('/', str_replace(getAlbumFolder(SERVERPATH), '', str_replace('\\', '/', $path) . '/'));
    $base = array_shift($base);
    $block = !$base && $attr == 'write';
    if ($block || access($attr, $path, $data, $volume)) {
        return !($attr == 'read' || $attr == 'write');
    }
    return NULL;
}
Ejemplo n.º 2
0
    /**
     * Prints the JS configuration of flv player
     *
     * @param string $moviepath the direct path of a movie (within the slideshow), if empty (within albums) the zenphoto function getUnprotectedImageURL() is used
     * @param string $imagetitle the title of the movie to be passed to the player for display (within slideshow), if empty (within albums) the function getImageTitle() is used
     * @param string $count unique text for when there are multiple player items on a page
     */
    function getPlayerConfig($moviepath = '', $imagetitle = '', $count = '')
    {
        global $_zp_current_image, $_zp_current_album;
        if (empty($moviepath)) {
            $moviepath = getUnprotectedImageURL();
            $ext = strtolower(strrchr(getUnprotectedImageURL(), "."));
        } else {
            $ext = strtolower(strrchr($moviepath, "."));
        }
        if (empty($imagetitle)) {
            $imagetitle = getImageTitle();
        }
        if (!empty($count)) {
            $count = "-" . $count;
        }
        $imgextensions = array(".jpg", ".jpeg", ".gif", ".png");
        if (is_null($_zp_current_image)) {
            $albumfolder = $moviepath;
            $filename = $imagetitle;
            $videoThumb = '';
        } else {
            $album = $_zp_current_image->getAlbum();
            $albumfolder = $album->name;
            $filename = $_zp_current_image->filename;
            $videoThumb = checkObjectsThumb(getAlbumFolder() . $albumfolder, $filename);
            if (!empty($videoThumb)) {
                $videoThumb = getAlbumFolder(WEBPATH) . $albumfolder . '/' . $videoThumb;
            }
        }
        $output = '';
        $output .= '<p id="player' . $count . '"><a href="http://www.macromedia.com/go/getflashplayer">' . gettext("Get Flash") . '</a> to see this player.</p>
			<script type="text/javascript">';
        if ($ext === ".mp3" and !isset($videoThumb)) {
            $output .= '	var so = new SWFObject("' . WEBPATH . '/' . ZENFOLDER . '/plugins/flvplayer/' . getOption("flv_player_version") . '.swf","player' . $count . '","' . getOption('flv_player_width') . '","' . FLV_PLAYER_MP3_HEIGHT . '","7");';
        } else {
            $output .= '	var so = new SWFObject("' . WEBPATH . '/' . ZENFOLDER . '/plugins/flvplayer/' . getOption("flv_player_version") . '.swf","player' . $count . '","' . getOption('flv_player_width') . '","' . getOption('flv_player_height') . '","7");';
            $output .= 'so.addVariable("displayheight","' . getOption('flv_player_displayheight') . '");';
        }
        $output .= 'so.addParam("allowfullscreen","true");
			so.addVariable("file","' . $moviepath . '&amp;title=' . strip_tags($imagetitle) . '");
			' . (!empty($videoThumb) ? 'so.addVariable("image","' . $videoThumb . '")' : '') . '
			so.addVariable("backcolor","' . getOption('flv_player_backcolor') . '");
			so.addVariable("frontcolor","' . getOption('flv_player_frontkcolor') . '");
			so.addVariable("lightcolor","' . getOption('flv_player_lightcolor') . '");
			so.addVariable("screencolor","' . getOption('flv_player_screencolor') . '");
			so.addVariable("autostart","' . (getOption('flv_player_autostart') ? 'true' : 'false') . '");
			so.addVariable("overstretch","true");
			so.addVariable("bufferlength","' . getOption('flv_player_buffer') . '");
			so.addVariable("controlbar","' . getOption('flv_player_controlbar') . '");
			so.write("player' . $count . '");
			</script>';
        return $output;
    }
Ejemplo n.º 3
0
/**
 * Creates a zip file of the album
 *
 * @param string $album album folder
 */
function createAlbumZip($album)
{
    global $_zp_zip_list;
    if (!checkAlbumPassword($album, $hint)) {
        pageError();
        exit;
    }
    $album = UTF8ToFilesystem($album);
    $rp = realpath(getAlbumFolder() . $album) . '/';
    $p = $album . '/';
    include_once 'archive.php';
    $dest = realpath(getAlbumFolder()) . '/' . urlencode($album) . ".zip";
    $persist = getOption('persistent_archive');
    if (!$persist || !file_exists($dest)) {
        if (file_exists($dest)) {
            unlink($dest);
        }
        $z = new zip_file($dest);
        $z->set_options(array('basedir' => $rp, 'inmemory' => 0, 'recurse' => 0, 'storepaths' => 1));
        if ($dh = opendir($rp)) {
            $_zp_zip_list[] = '*.*';
            while (($file = readdir($dh)) !== false) {
                if ($file != '.' && $file != '..') {
                    if (is_dir($rp . $file)) {
                        $base_a = explode("/", $album);
                        unset($base_a[count($base_a) - 1]);
                        $base = implode('/', $base_a);
                        zipAddSubalbum($rp, $base, $file, $z);
                    }
                }
            }
            closedir($dh);
        }
        $z->add_files($_zp_zip_list);
        $z->create_archive();
    }
    header('Content-Type: application/zip');
    header('Content-Disposition: attachment; filename="' . urlencode($album) . '.zip"');
    header("Content-Length: " . filesize($dest));
    printLargeFileContents($dest);
    if (!$persist) {
        unlink($dest);
    }
}
 function getOptionsSupported()
 {
     global $_zp_supported_images, $_zp_extra_filetypes, $mysetoptions;
     $albums = $this->loadAlbumNames(getAlbumFolder());
     $albums = array_unique($albums);
     natsort($albums);
     $lista = array();
     foreach ($albums as $album) {
         $lista[$album] = 'filter_file_searches_albums_' . $album;
     }
     natsort($_zp_supported_images);
     $types = array_keys($_zp_extra_filetypes);
     natsort($types);
     $list = array_merge($_zp_supported_images, $types);
     $listi = array();
     foreach ($list as $suffix) {
         $listi[$suffix] = 'filter_file_searches_images_' . $suffix;
     }
     return array(gettext('Albums') => array('key' => 'filter_file_searches_albums', 'type' => 7, 'checkboxes' => $lista, 'currentvalues' => $mysetoptions, 'desc' => gettext("Check album names to be ignored.")), gettext('Images') => array('key' => 'filter_file_searches_images', 'type' => 7, 'checkboxes' => $listi, 'currentvalues' => $mysetoptions, 'desc' => gettext('Check image suffixes to be ingnored.')));
 }
Ejemplo n.º 5
0
function getImageRotation($imgfile)
{
    $imgfile = substr($imgfile, strlen(getAlbumFolder()));
    $result = query_single_row('SELECT EXIFOrientation FROM ' . prefix('images') . ' AS i JOIN ' . prefix('albums') . ' as a ON i.albumid = a.id WHERE "' . $imgfile . '" = CONCAT(a.folder,"/",i.filename)');
    if (is_array($result) && array_key_exists('EXIFOrientation', $result)) {
        $splits = preg_split('/!([(0-9)])/', $result['EXIFOrientation']);
        $rotation = $splits[0];
        switch ($rotation) {
            case 1:
                return false;
                break;
            case 2:
                return false;
                break;
                // mirrored
            // mirrored
            case 3:
                return 180;
                break;
                // upsidedown (not 180 but close)
            // upsidedown (not 180 but close)
            case 4:
                return 180;
                break;
                // upsidedown mirrored
            // upsidedown mirrored
            case 5:
                return 270;
                break;
                // 90 CW mirrored (not 270 but close)
            // 90 CW mirrored (not 270 but close)
            case 6:
                return 270;
                break;
                // 90 CCW
            // 90 CCW
            case 7:
                return 90;
                break;
                // 90 CCW mirrored (not 90 but close)
            // 90 CCW mirrored (not 90 but close)
            case 8:
                return 90;
                break;
                // 90 CW
            // 90 CW
            default:
                return false;
        }
    }
    return false;
}
Ejemplo n.º 6
0
 /**
  * Returns a path to the original image in the original folder.
  *
  * @param string $path the "path" to the image. Defaults to the simple WEBPATH
  *
  * @return string
  */
 function getFullImage($path = WEBPATH)
 {
     return getAlbumFolder($path) . $this->album->name . "/" . $this->filename;
 }
/**
 * A helper function that only prints a item of the loop within printAlbumStatistic()
 * Not for standalone use.
 *
 * @param array $album the array that getAlbumsStatistic() submitted
 * @param string $option "popular" for the most popular albums,
 *                  "latest" for the latest uploaded,
 *                  "mostrated" for the most voted,
 *                  "toprated" for the best voted
 * 									"latestupdated" for the latest updated
 * @param bool $showtitle if the album title should be shown
 * @param bool $showdate if the album date should be shown
 * @param bool $showdesc if the album description should be shown
 * @param integer $desclength the length of the description to be shown
 * @param string $showstatistic "hitcounter" for showing the hitcounter (views),
 * 															"rating" for rating,
 * 															"rating+hitcounter" for both.
 * @param integer $width the width/cropwidth of the thumb if crop=true else $width is longest size. (Default 85px)
 * @param integer $height the height/cropheight of the thumb if crop=true else not used.  (Default 85px)
 * @param bool $crop 'true' (default) if the thumb should be cropped, 'false' if not
 */
function printAlbumStatisticItem($album, $option, $showtitle = false, $showdate = false, $showdesc = false, $desclength = 40, $showstatistic = '', $width = 85, $height = 85, $crop = true)
{
    global $_zp_gallery;
    $albumpath = rewrite_path("/", "index.php?album=");
    $tempalbum = new Album($_zp_gallery, $album['folder']);
    echo "<li><a href=\"" . $albumpath . pathurlencode($tempalbum->name) . "\" title=\"" . html_encode($tempalbum->getTitle()) . "\">\n";
    $albumthumb = $tempalbum->getAlbumThumbImage();
    $thumb = newImage($tempalbum, $albumthumb->filename);
    if ($crop) {
        echo "<img src=\"" . $thumb->getCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, TRUE) . "\" alt=\"" . html_encode($thumb->getTitle()) . "\" /></a>\n<br />";
    } else {
        echo "<img src=\"" . $thumb->getCustomImage($width, NULL, NULL, NULL, NULL, NULL, NULL, TRUE) . "\" alt=\"" . html_encode($thumb->getTitle()) . "\" /></a>\n<br />";
    }
    if ($showtitle) {
        echo "<h3><a href=\"" . $albumpath . pathurlencode($tempalbum->name) . "\" title=\"" . html_encode($tempalbum->getTitle()) . "\">\n";
        echo $tempalbum->getTitle() . "</a></h3>\n";
    }
    if ($showdate) {
        if ($option === "latestupdated") {
            $filechangedate = filectime(getAlbumFolder() . UTF8ToFilesystem($tempalbum->name));
            $latestimage = query_single_row("SELECT mtime FROM " . prefix('images') . " WHERE albumid = " . $tempalbum->getAlbumID() . " AND `show` = 1 ORDER BY id DESC");
            $lastuploaded = query("SELECT COUNT(*) FROM " . prefix('images') . " WHERE albumid = " . $tempalbum->getAlbumID() . " AND mtime = " . $latestimage['mtime']);
            $row = mysql_fetch_row($lastuploaded);
            $count = $row[0];
            echo "<p>" . sprintf(gettext("Last update: %s"), zpFormattedDate(getOption('date_format'), $filechangedate)) . "</p>";
            if ($count <= 1) {
                $image = gettext("image");
            } else {
                $image = gettext("images");
            }
            echo "<span>" . sprintf(gettext('%1$u new %2$s'), $count, $image) . "</span>";
        } else {
            echo "<p>" . zpFormattedDate(getOption('date_format'), strtotime($tempalbum->getDateTime())) . "</p>";
        }
    }
    if ($showstatistic === "rating" or $showstatistic === "rating+hitcounter") {
        $votes = $tempalbum->get("total_votes");
        $value = $tempalbum->get("total_value");
        if ($votes != 0) {
            $rating = round($value / $votes, 1);
        }
        echo "<p>" . sprintf(gettext('Rating: %1$u (Votes: %2$u )'), $rating, $tempalbum->get("total_votes")) . "</p>";
    }
    if ($showstatistic === "hitcounter" or $showstatistic === "rating+hitcounter") {
        $hitcounter = $tempalbum->get("hitcounter");
        if (empty($hitcounter)) {
            $hitcounter = "0";
        }
        echo "<p>" . sprintf(gettext("Views: %u"), $hitcounter) . "</p>";
    }
    if ($showdesc) {
        echo "<p>" . truncate_string($tempalbum->getDesc(), $desclength) . "</p>";
    }
    echo "</li>";
}
Ejemplo n.º 8
0
 /**
  * Returns the image file name for the thumbnail image.
  *
  * @return string
  */
 function getThumbImageFile()
 {
     if ($this->objectsThumb != NULL) {
         $imgfile = getAlbumFolder() . $this->album->name . '/' . $this->objectsThumb;
     } else {
         $imgfile = SERVERPATH . '/' . THEMEFOLDER . '/' . UTF8ToFilesystem($this->album->gallery->getCurrentTheme()) . '/images/multimediaDefault.png';
         if (!file_exists($imgfile)) {
             $imgfile = SERVERPATH . "/" . ZENFOLDER . PLUGIN_FOLDER . substr(basename(__FILE__), 0, -4) . '/multimediaDefault.png';
         }
     }
     return $imgfile;
 }
Ejemplo n.º 9
0
$playlist = $album->getImages();
echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n";
echo "<title>Sample XSPF Playlist</title>";
echo "<info>http://www.what.de</info>";
echo "<annotation>An example of a playlist with commercial</annotation>";
echo "<trackList>\n";
$imgextensions = array(".jpg", ".jpeg", ".gif", ".png");
foreach ($playlist as $item) {
    $image = newImage($album, $item);
    $ext = strtolower(strrchr($item, "."));
    if ($ext == ".flv" || $ext == ".mp3" || $ext == ".mp4") {
        $videoThumb = $image->objectsThumb;
        if (!empty($videoThumb)) {
            $videoThumb = '../../' . getAlbumFolder('') . $album->name . "/" . $videoThumb;
        }
        echo "\t<track>\n";
        echo "\t\t<title>" . $image->getTitle() . " (" . $ext . ")</title>\n";
        // As documentated on the fvl player's site movies and mp3 have are called via differently relative urls...
        // http://www.jeroenwijering.com/?item=Supported_Playlists
        if ($ext == ".flv" or $ext == ".mp4") {
            echo "\t\t<location>../../" . getAlbumFolder('') . $album->name . "/" . $item . "</location>\n";
        } else {
            echo "\t\t<location>.." . getAlbumFolder('') . $album->name . "/" . $item . "</location>\n";
        }
        echo "\t\t<image>" . $videoThumb . "</image>\n";
        echo "\t\t<info>../../" . WEBPATH . '/' . getAlbumFolder('') . $item . "</info>\n";
        echo "\t</track>\n";
    }
}
echo "</trackList>\n";
echo "</playlist>\n";
Ejemplo n.º 10
0
                preg_match_all('~\\<img.*src\\s*=\\s*"((\\.|[^"])*)~', $row[$field], $matches);
                foreach ($matches[1] as $key => $match) {
                    $updated = false;
                    if (preg_match('~/' . CACHEFOLDER . '/~', $match)) {
                        $found++;
                        list($image, $args) = getImageProcessorURIFromCacheName($match, $watermarks);
                        $try = $_zp_supported_images;
                        $base = stripSuffix($image);
                        $prime = getSuffix($image);
                        array_unshift($try, $prime);
                        $try = array_unique($try);
                        $missing = true;
                        //see if we can match the cache name to an image in the album.
                        //Note that the cache suffix may not match the image suffix
                        foreach ($try as $suffix) {
                            if (file_exists(getAlbumFolder() . $base . '.' . $suffix)) {
                                $missing = false;
                                $image = $base . '.' . $suffix;
                                $uri = getImageURI($args, dirname($image), basename($image), NULL);
                                if (strpos($uri, 'i.php?') !== false) {
                                    $fixed++;
                                    $title = getTitle($table, $row);
                                    ?>
											<a href="<?php 
                                    echo html_encode($uri);
                                    ?>
&amp;debug" title="<?php 
                                    echo $title;
                                    ?>
">
												<?php 
Ejemplo n.º 11
0
 function getCounterpartfile($moviepath, $ext, $definition)
 {
     $counterpartFile = '';
     $counterpart = str_replace("mp4", $ext, $moviepath);
     $albumPath = substr(ALBUM_FOLDER_WEBPATH, strlen(WEBPATH));
     $vidPath = getAlbumFolder() . str_replace(FULLWEBPATH . $albumPath, "", $counterpart);
     switch (strtoupper($definition)) {
         case "HD":
             if (file_exists($vidPath)) {
                 $counterpartFile = '<source src="' . pathurlencode($counterpart) . '" label="HD" />';
             }
             break;
         case "SD":
             $vidPath = str_replace(rtrim(getAlbumFolder(), "/"), rtrim(getAlbumFolder(), "/") . ".SD", $vidPath);
             $counterpart = str_replace(rtrim(ALBUM_FOLDER_WEBPATH, "/"), rtrim(ALBUM_FOLDER_WEBPATH, "/") . ".SD", $counterpart);
             if (file_exists($vidPath)) {
                 $counterpartFile = '<source src="' . pathurlencode($counterpart) . '" label="SD" />';
             }
             break;
     }
     return $counterpartFile;
 }
Ejemplo n.º 12
0
     break;
 }
 // process these photos
 while ($r = mysql_fetch_array($result)) {
     // get album infos
     $id = $r['albumid'];
     if ($albumnr != "") {
         $sql = "SELECT * FROM " . prefix("albums") . " WHERE `show` = 1 AND id = {$albumnr}";
     } else {
         $sql = "SELECT * FROM " . prefix("albums") . " WHERE `show` = 1 AND id = {$id}";
     }
     $album = mysql_query($sql);
     $a = mysql_fetch_array($album);
     // sanitize database
     if (!file_exists(getAlbumFolder() . $a['folder'] . "/" . $r['filename'])) {
         echo '<!-- file ' . getAlbumFolder() . $a['folder'] . "/" . $r['filename'] . ' doesnt exist-->';
         $sql = "DELETE FROM " . prefix("images") . " WHERE id = " . $r['id'];
         mysql_query($sql);
         continue;
     }
     // check if new post : first photo, or album changed, or more than 1 hour between two photos
     if (!isset($preva) || $preva['id'] != $a['id'] || $prevr['mtime'] - $r['mtime'] > $skiptime) {
         // check if this first photo of the post is older than 1 hour
         $skip = $mtime_now - $r['mtime'] <= $skiptime + 1;
         // begin new post
         if (!$skip) {
             $nentries++;
             if ($nentries > $items) {
                 break;
             }
             $nphotos = 0;
Ejemplo n.º 13
0
/**
 * rewrite_get_album_image - Fix special characters in the album and image names if mod_rewrite is on:
 * This is redundant and hacky; we need to either make the rewriting completely internal,
 * or fix the bugs in mod_rewrite. The former is probably a good idea.
 *
 *  Old explanation:
 *    rewrite_get_album_image() parses the album and image from the requested URL
 *    if mod_rewrite is on, and replaces the query variables with corrected ones.
 *    This is because of bugs in mod_rewrite that disallow certain characters.
 *
 * @param string $albumvar "$_GET" parameter for the album
 * @param string $imagevar "$_GET" parameter for the image
 */
function rewrite_get_album_image($albumvar, $imagevar)
{
    if (getOption('mod_rewrite')) {
        $uri = urldecode(sanitize($_SERVER['REQUEST_URI'], 0));
        $path = substr($uri, strlen(WEBPATH) + 1);
        // Only extract the path when the request doesn't include the running php file (query request).
        if (strlen($path) > 0 && strpos($_SERVER['REQUEST_URI'], $_SERVER['PHP_SELF']) === false && isset($_GET[$albumvar])) {
            $im_suffix = getOption('mod_rewrite_image_suffix');
            $suf_len = strlen($im_suffix);
            $qspos = strpos($path, '?');
            if ($qspos !== false) {
                $path = substr($path, 0, $qspos);
            }
            // Strip off the image suffix (could interfere with the rest, needs to go anyway).
            if ($suf_len > 0 && substr($path, -$suf_len) == $im_suffix) {
                $path = substr($path, 0, -$suf_len);
            }
            if (substr($path, -1, 1) == '/') {
                $path = substr($path, 0, strlen($path) - 1);
            }
            $pagepos = strpos($path, '/page/');
            $slashpos = strrpos($path, '/');
            $imagepos = strpos($path, '/image/');
            $albumpos = strpos($path, '/album/');
            if ($imagepos !== false) {
                $ralbum = substr($path, 0, $imagepos);
                $rimage = substr($path, $slashpos + 1);
            } else {
                if ($albumpos !== false) {
                    $ralbum = substr($path, 0, $albumpos);
                    $rimage = substr($path, $slashpos + 1);
                } else {
                    if ($pagepos !== false) {
                        $ralbum = substr($path, 0, $pagepos);
                        $rimage = null;
                    } else {
                        if ($slashpos !== false) {
                            $ralbum = substr($path, 0, $slashpos);
                            $rimage = substr($path, $slashpos + 1);
                            if (is_dir(getAlbumFolder() . UTF8ToFilesystem($ralbum . '/' . $rimage)) || hasDyanmicAlbumSuffix($rimage)) {
                                $ralbum = $ralbum . '/' . $rimage;
                                $rimage = null;
                            }
                        } else {
                            $ralbum = $path;
                            $rimage = null;
                        }
                    }
                }
            }
            return array($ralbum, $rimage);
        }
    }
    // No mod_rewrite, or no album, etc. Just send back the query args.
    $ralbum = isset($_GET[$albumvar]) ? sanitize_path($_GET[$albumvar]) : null;
    $rimage = isset($_GET[$imagevar]) ? sanitize_path($_GET[$imagevar]) : null;
    return array($ralbum, $rimage);
}
Ejemplo n.º 14
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 = mysql_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'];
             }
         }
     }
     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 '" . mysql_real_escape_string($this->name) . "/%'");
     $dead = array();
     $live = array();
     // Does the dirname from the db row exist on disk?
     while ($row = mysql_fetch_assoc($result)) {
         if (!is_dir(getAlbumFolder() . UTF8ToFilesystem($row['folder'])) || in_array($row['folder'], $live) || substr($row['folder'], -1) == '/' || substr($row['folder'], 0, 1) == '/') {
             $dead[] = $row['id'];
         } else {
             $live[] = $row['folder'];
         }
     }
     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->getSubAlbums(0) as $dir) {
             $subalbum = new Album($this->gallery, $dir);
             // Could have been deleted if it didn't exist above...
             if ($subalbum->exists) {
                 $subalbum->garbageCollect($deep);
             }
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * Returns a path to the original image in the original folder.
  *
  * @param string $path the "path" to the image. Defaults to the simple WEBPATH
  *
  * @return string
  */
 protected function getFullImage($path = WEBPATH)
 {
     global $_zp_conf_vars;
     if ($path == WEBPATH && $_zp_conf_vars['album_folder_class'] == 'external') {
         return false;
     }
     if (is_array($this->filename)) {
         $album = dirname($this->filename['source']);
         $image = basename($this->filename['source']);
     } else {
         $album = $this->imagefolder;
         $image = $this->filename;
     }
     return getAlbumFolder($path) . $album . "/" . $image;
 }
Ejemplo n.º 16
0
        break;
    default:
        if (secureServer()) {
            define('PROTOCOL', 'https');
        } else {
            define('PROTOCOL', 'http');
        }
        break;
}
define('FULLWEBPATH', PROTOCOL . "://" . $_SERVER['HTTP_HOST'] . WEBPATH);
define('SAFE_MODE_ALBUM_SEP', '__');
define('SERVERCACHE', SERVERPATH . '/' . CACHEFOLDER);
define('MOD_REWRITE', getOption('mod_rewrite'));
define('ALBUM_FOLDER_WEBPATH', getAlbumFolder(WEBPATH));
define('ALBUM_FOLDER_SERVERPATH', getAlbumFolder(SERVERPATH));
define('ALBUM_FOLDER_EMPTY', getAlbumFolder(''));
define('IMAGE_WATERMARK', getOption('fullimage_watermark'));
define('FULLIMAGE_WATERMARK', getOption('fullsizeimage_watermark'));
define('THUMB_WATERMARK', getOption('Image_watermark'));
define('DATE_FORMAT', getOption('date_format'));
define('IM_SUFFIX', getOption('mod_rewrite_image_suffix'));
define('UTF8_IMAGE_URI', getOption('UTF8_image_URI'));
define('MEMBERS_ONLY_COMMENTS', getOption('comment_form_members_only'));
define('HASH_SEED', getOption('extra_auth_hash_text'));
define('IP_TIED_COOKIES', getOption('IP_tied_cookies'));
// Set the version number.
$_zp_conf_vars['version'] = ZENPHOTO_VERSION;
/**
 * Decodes HTML Special Characters.
 *
 * @param string $text
Ejemplo n.º 17
0
 /**
  * Returns a path to the original image in the original folder.
  *
  * @return string
  */
 function getFullImage()
 {
     return getAlbumFolder(WEBPATH) . pathurlencode($this->album->name) . "/" . rawurlencode($this->filename);
 }
	/**
	 * @param string $path override path
	 * @return string filesystem path, for internal processing
	 */
	function getThumbImageFile($path = NULL) {
		if (is_null($path)) {$path = SERVERPATH;}
		if ($this->objectsThumb != NULL) {
			$imgfile = getAlbumFolder().$this->album->name.'/'.$this->objectsThumb;
		} else {
			/* use a small filmstrip JPG in ZP;
			 * check if it's in the current theme, first */
			$img = 'movie.jpg';
			$imgfile = $path.'/'.THEMEFOLDER.'/'.
				internalToFilesystem($this->album->gallery->getCurrentTheme()).
				'/images/'.$img;
			if ( ! file_exists($imgfile)) {
				$imgfile = $path.'/plugins/'.substr(basename(__FILE__), 0, -4).
					'/'.$img;
			}
		}
		return $imgfile;
	}
/**
 * Returns the url to original image.
 * It will return a protected image is the option "protect_full_image" is set
 *
 * @return string
 */
function getFullImageURL()
{
    global $_zp_current_image;
    if (is_null($_zp_current_image)) {
        return false;
    }
    $outcome = getOption('protect_full_image');
    if ($outcome == 'No access') {
        return null;
    }
    $url = getUnprotectedImageURL();
    if (is_valid_video($url)) {
        // Download, Protected View, and Unprotected access all allowed
        $album = $_zp_current_image->getAlbum();
        $folder = $album->getFolder();
        $original = checkVideoOriginal(getAlbumFolder() . $folder, $_zp_current_image->getFileName());
        if ($original) {
            return getAlbumFolder(WEBPATH) . $folder . "/" . $original;
        } else {
            return $url;
        }
    } else {
        // normal image
        if ($outcome == 'Unprotected') {
            return $url;
        } else {
            return getProtectedImageURL();
        }
    }
}
Ejemplo n.º 20
0
    /**
     * Prints the JS configuration of flv player
     *
     * @param string $moviepath the direct path of a movie (within the slideshow), if empty (within albums) the ZenPhoto function getUnprotectedImageURL() is used
     * @param string $imagetitle the title of the movie to be passed to the player for display (within slideshow), if empty (within albums) the function getImageTitle() is used
     * @param string $count unique text for when there are multiple player items on a page
     */
    function getPlayerConfig($moviepath = '', $imagetitle = '', $count = '')
    {
        global $_zp_current_image, $_zp_current_album, $_flv_player;
        if (empty($moviepath)) {
            $moviepath = getUnprotectedImageURL();
            $ext = strtolower(strrchr(getUnprotectedImageURL(), "."));
        } else {
            $ext = strtolower(strrchr($moviepath, "."));
        }
        if (empty($imagetitle)) {
            $imagetitle = getImageTitle();
        }
        if (!empty($count)) {
            $count = "-" . $count;
        }
        $imgextensions = array(".jpg", ".jpeg", ".gif", ".png");
        if (is_null($_zp_current_image)) {
            $albumfolder = $moviepath;
            $filename = $imagetitle;
            $videoThumb = '';
        } else {
            $album = $_zp_current_image->getAlbum();
            $albumfolder = $album->name;
            $filename = $_zp_current_image->filename;
            $videoThumb = $_zp_current_image->objectsThumb;
            if (!empty($videoThumb)) {
                $videoThumb = getAlbumFolder(WEBPATH) . $albumfolder . '/' . $videoThumb;
            }
        }
        $output = '';
        $output .= '<p id="player' . $count . '">' . gettext('The flv player is not installed. Please install or activate the flv player plugin.') . '</p>
			<script type="text/javascript">' . "\n\n";
        if ($ext === ".mp3" and !isset($videoThumb)) {
            $output .= 'var so = new SWFObject("' . WEBPATH . "/" . USER_PLUGIN_FOLDER . '/flvplayer/' . $_flv_player . '","player' . $count . '","' . getOption('flv_player_width') . '","' . FLV_PLAYER_MP3_HEIGHT . '",7);' . "\n";
        } else {
            $output .= 'var so = new SWFObject("' . WEBPATH . "/" . USER_PLUGIN_FOLDER . '/flvplayer/' . $_flv_player . '","player' . $count . '","' . getOption('flv_player_width') . '","' . getOption('flv_player_height') . '","7");' . "\n";
        }
        $output .= 'so.addVariable("file","' . $moviepath . '&amp;title=' . strip_tags($imagetitle) . '");' . "\n";
        if (!empty($videoThumb)) {
            $output .= 'so.addVariable("image","' . $videoThumb . '");' . "\n";
        }
        $output .= 'so.addVariable("backcolor","' . getOptionColor('flv_player_backcolor') . '");' . "\n";
        $output .= 'so.addVariable("frontcolor","' . getOptionColor('flv_player_frontcolor') . '");' . "\n";
        $output .= 'so.addVariable("lightcolor","' . getOptionColor('flv_player_lightcolor') . '");' . "\n";
        $output .= 'so.addVariable("screencolor","' . getOptionColor('flv_player_screencolor') . '");' . "\n";
        $output .= 'so.addVariable("autostart",' . (getOption('flv_player_autostart') ? 'true' : 'false') . ');' . "\n";
        $output .= 'so.addVariable("stretching","' . getOption('flv_player_stretching') . '");' . "\n";
        $output .= 'so.addVariable("bufferlength",' . getOption('flv_player_buffer') . ');' . "\n";
        $output .= 'so.addVariable("controlbar","' . getOption('flv_player_controlbar') . '");' . "\n";
        $output .= 'so.addParam("allowfullscreen",true);' . "\n";
        $output .= 'so.write("player' . $count . '");' . "\n";
        $output .= "\n</script>\n";
        return $output;
    }
Ejemplo n.º 21
0
 /**
  * Returns the size in bytes of the albums folder. WARNING: VERY SLOW.
  * @return int
  */
 function sizeOfImages()
 {
     $imagefolder = substr(getAlbumFolder(), 0, -1);
     if (is_dir($imagefolder)) {
         return dirsize($imagefolder);
     } else {
         return 0;
     }
 }
Ejemplo n.º 22
0
        break;
    default:
        pageError(405, gettext("Method Not Allowed"));
        exit;
}
if (getOption('cache_full_image')) {
    $cache_path = SERVERCACHE . '/' . UTF8ToFilesystem($cache_file);
} else {
    $cache_path = NULL;
}
if (!getOption('watermark_image')) {
    // no processing needed
    if (getOption('album_folder_class') != 'external' && !getOption('protect_full_image') == 'Download') {
        // local album system, return the image directly
        header('Content-Type: image/' . $suffix);
        header("Location: " . getAlbumFolder(FULLWEBPATH) . pathurlencode($_zp_current_album->name) . "/" . rawurlencode($_zp_current_image->filename));
        exit;
    } else {
        // the web server does not have access to the image, have to supply it
        $fp = fopen($image_path, 'rb');
        // send the right headers
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header("Content-Type: image/{$suffix}");
        if (getOption('protect_full_image') == 'Download') {
            header('Content-Disposition: attachment; filename="' . $_zp_current_image->filename . '"');
            // enable this to make the image a download
        }
        header("Content-Length: " . filesize($image_path));
        // dump the picture and stop the script
        fpassthru($fp);
        fclose($fp);
Ejemplo n.º 23
0
/**
 * Handles the special cases of album/image[rewrite_suffix]
 *
 * Separates the image part from the album if it is an image reference
 * Strips off the mod_rewrite_suffix if present
 * Handles dynamic album names that do not have the .alb suffix appended
 *
 * @param string $albumvar	$_GET index for "albums"
 * @param string $imagevar	$_GET index for "images"
 */
function rewrite_get_album_image($albumvar, $imagevar)
{
    global $_zp_rewritten, $_zp_albumHandlers;
    $ralbum = isset($_GET[$albumvar]) ? trim(sanitize_path($_GET[$albumvar]), '/') : NULL;
    $rimage = isset($_GET[$imagevar]) ? sanitize($_GET[$imagevar]) : NULL;
    //	we assume that everything is correct if rewrite rules were not applied
    if ($_zp_rewritten) {
        if (!empty($ralbum) && empty($rimage)) {
            //	rewrite rules never set the image part!
            $path = internalToFilesystem(getAlbumFolder(SERVERPATH) . $ralbum);
            if (IM_SUFFIX) {
                // require the rewrite have the suffix as well
                if (preg_match('|^(.*)' . preg_quote(IM_SUFFIX) . '$|', $ralbum, $matches)) {
                    //has an IM_SUFFIX attached
                    $rimage = basename($matches[1]);
                    $ralbum = trim(dirname($matches[1]), '/');
                    $path = internalToFilesystem(getAlbumFolder(SERVERPATH) . $ralbum);
                }
            } else {
                //	have to figure it out
                if (Gallery::validImage($ralbum) || Gallery::validImageAlt($ralbum)) {
                    //	it is an image request
                    $rimage = basename($ralbum);
                    $ralbum = trim(dirname($ralbum), '/');
                    $path = internalToFilesystem(getAlbumFolder(SERVERPATH) . $ralbum);
                }
            }
            if (!is_dir($path)) {
                if ($suffix = isHandledAlbum($path)) {
                    //	it is a dynamic album sans suffix
                    $ralbum .= '.' . $suffix;
                }
            }
        }
        if (empty($ralbum)) {
            unset($_GET[$albumvar]);
        } else {
            $_GET[$albumvar] = $ralbum;
        }
        if (empty($rimage)) {
            unset($_GET[$imagevar]);
        } else {
            $_GET[$imagevar] = $rimage;
        }
    }
    return array($ralbum, $rimage);
}
Ejemplo n.º 24
0
<?php

// force UTF-8// Ø
list($album, $image) = rewrite_get_album_image('album', 'image');
$folders = explode('/', $album);
if (array_key_exists(0, $folders) && $folders[0] == CACHEFOLDER) {
    // a failed reference to a cached image?
    require_once SERVERPATH . '/' . ZENFOLDER . '/admin-functions.php';
    require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/cacheManager/functions.php';
    unset($folders[0]);
    list($image, $args) = getImageProcessorURIFromCacheName(implode('/', $folders) . '/' . $image, getWatermarks());
    if (file_exists(getAlbumFolder() . $image)) {
        $uri = getImageURI($args, dirname($image), basename($image), NULL);
        header("HTTP/1.0 302 Found");
        header("Status: 302 Found");
        header('Location: ' . $uri);
        exitZP();
    }
}
if (isset($_GET['fromlogout'])) {
    header("HTTP/1.0 302 Found");
    header("Status: 302 Found");
    header('Location: ' . WEBPATH . '/index.php');
    exitZP();
}
$obj = @$_zp_gallery_page;
$_zp_gallery_page = '404.php';
if (isset($_index_theme)) {
    $_zp_script = SERVERPATH . "/" . THEMEFOLDER . '/' . internalToFilesystem($_index_theme) . '/404.php';
} else {
    $_zp_script = NULL;
Ejemplo n.º 25
0
    static function printSlideShow($heading = true, $speedctl = false, $albumobj = "", $imageobj = "", $width = "", $height = "")
    {
        if (!isset($_POST['albumid']) and !is_object($albumobj)) {
            echo "<div class=\"errorbox\" id=\"message\"><h2>" . gettext("Invalid linking to the slideshow page.") . "</h2></div>";
            echo "</div></body></html>";
            exit;
        }
        global $_zp_flash_player, $_zp_current_image, $_zp_current_album, $_zp_gallery;
        //getting the image to start with
        if (!empty($_POST['imagenumber']) and !is_object($imageobj)) {
            $imagenumber = $_POST['imagenumber'] - 1;
            // slideshows starts with 0, but zp with 1.
        } elseif (is_object($imageobj)) {
            makeImageCurrent($imageobj);
            $imagenumber = imageNumber() - 1;
        } else {
            $imagenumber = 0;
        }
        // set pagenumber to 0 if not called via POST link
        if (isset($_POST['pagenr'])) {
            $pagenumber = sanitize_numeric($_POST['pagenr']);
        } else {
            $pagenumber = 0;
        }
        // getting the number of images
        if (!empty($_POST['numberofimages'])) {
            $numberofimages = sanitize_numeric($_POST['numberofimages']);
        } elseif (is_object($albumobj)) {
            $numberofimages = $albumobj->getNumImages();
        }
        //getting the album to show
        if (!empty($_POST['albumid']) and !is_object($albumobj)) {
            $albumid = sanitize_numeric($_POST['albumid']);
        } elseif (is_object($albumobj)) {
            $albumid = $albumobj->id;
        } else {
            $albumid = -1;
        }
        // setting the image size
        if (!empty($width) and !empty($height)) {
            $width = sanitize_numeric($width);
            $height = sanitize_numeric($height);
        } else {
            $width = getOption("slideshow_width");
            $height = getOption("slideshow_height");
        }
        $option = getOption("slideshow_mode");
        // jQuery Cycle slideshow config
        // get slideshow data
        $gallery = new Gallery();
        if ($albumid <= 0) {
            // search page
            $dynamic = 2;
            $search = new SearchEngine();
            $params = $_POST['preserve_search_params'];
            $search->setSearchParams($params);
            $images = $search->getImages(0);
            $searchwords = $search->words;
            $searchdate = $search->dates;
            $searchfields = $search->fields;
            $page = $search->page;
            if (empty($_POST['imagenumber'])) {
                $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . abs($albumid));
                $album = new Album($gallery, $albumq['folder']);
                $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
                //$returnpath = rewrite_path('/'.pathurlencode($album->name).'/page/'.$pagenumber,'/index.php?album='.urlencode($album->name).'&page='.$pagenumber);
            } else {
                $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
            }
            $albumtitle = gettext('Search');
        } else {
            $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
            $album = new Album($gallery, $albumq['folder']);
            $albumtitle = $album->getTitle();
            if (!checkAlbumPassword($albumq['folder'], $hint)) {
                echo gettext("This album is password protected!");
                exit;
            }
            $dynamic = $album->isDynamic();
            $images = $album->getImages(0);
            // return path to get back to the page we called the slideshow from
            if (empty($_POST['imagenumber'])) {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/page/' . $pagenumber, '/index.php?album=' . urlencode($album->name) . '&page=' . $pagenumber);
            } else {
                $returnpath = rewrite_path('/' . pathurlencode($album->name) . '/' . rawurlencode($_POST['imagefile']) . getOption('mod_rewrite_image_suffix'), '/index.php?album=' . urlencode($album->name) . '&image=' . urlencode($_POST['imagefile']));
            }
        }
        // slideshow display section
        switch ($option) {
            case "jQuery":
                $validtypes = array('jpg', 'jpeg', 'gif', 'png', 'mov', '3gp');
                ?>
					<script type="text/javascript">
						$(document).ready(function(){
							$(function() {
								var ThisGallery = '<?php 
                echo html_encode($albumtitle);
                ?>
';
								var ImageList = new Array();
								var TitleList = new Array();
								var DescList = new Array();
								var ImageNameList = new Array();
								var DynTime=(<?php 
                echo getOption("slideshow_timeout");
                ?>
) * 1.0;	// force numeric
								<?php 
                for ($imgnr = 0, $cntr = 0, $idx = $imagenumber; $imgnr < $numberofimages; $imgnr++, $idx++) {
                    if ($dynamic) {
                        $filename = $images[$idx]['filename'];
                        $album = new Album($gallery, $images[$idx]['folder']);
                        $image = newImage($album, $filename);
                    } else {
                        $filename = $images[$idx];
                        $image = newImage($album, $filename);
                    }
                    $ext = is_valid($filename, $validtypes);
                    if ($ext) {
                        makeImageCurrent($image);
                        $img = getCustomSizedImageMaxSpace($width, $height);
                        //$img = WEBPATH . '/' . ZENFOLDER . '/i.php?a=' . pathurlencode($image->album->name) . '&i=' . urlencode($filename) . '&s=' . $imagesize;
                        echo 'ImageList[' . $cntr . '] = "' . $img . '";' . "\n";
                        echo 'TitleList[' . $cntr . '] = "' . js_encode($image->getTitle()) . '";' . "\n";
                        if (getOption("slideshow_showdesc")) {
                            $desc = $image->getDesc();
                            $desc = str_replace("\r\n", '<br />', $desc);
                            $desc = str_replace("\r", '<br />', $desc);
                            echo 'DescList[' . $cntr . '] = "' . js_encode($desc) . '";' . "\n";
                        } else {
                            echo 'DescList[' . $cntr . '] = "";' . "\n";
                        }
                        if ($idx == $numberofimages - 1) {
                            $idx = -1;
                        }
                        echo 'ImageNameList[' . $cntr . '] = "' . urlencode($filename) . '";' . "\n";
                        $cntr++;
                    }
                }
                echo "\n";
                $numberofimages = $cntr;
                ?>
								var countOffset = <?php 
                echo $imagenumber;
                ?>
;
								var totalSlideCount = <?php 
                echo $numberofimages;
                ?>
;
								var currentslide = 2;
			
								function onBefore(curr, next, opts) {
									//$(next).parent().animate({opacity: 0});

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

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

									//THE MISSING LINE
									$(next).parent().height(
										$(next).find('img').height() + $(next).find('p').height() + $(next).find('h4').height() + 40
									); //.animate({opacity: 1}, 'normal', 'linear');
									//getOption('slideshow_onafter'); //make it generic
									//END MISSING LINE
								}
			
								$('#slides').cycle({
										fx:     '<?php 
                echo getOption("slideshow_effect");
                ?>
',
										speed:   <?php 
                echo getOption("slideshow_speed");
                ?>
,
										timeout: DynTime,
										next:   '#next',
										prev:   '#prev',
										cleartype: 1,
										before: onBefore,
										after: onAfter
								});
			
								$('#speed').change(function () {
									DynTime = this.value;
									return false;
								});
			
								$('#pause').click(function() { $('#slides').cycle('pause'); return false; });
								$('#play').click(function() { $('#slides').cycle('resume'); return false; });
							});
			
						});	// Documentready()
			
						</script>
						<div id="slideshow" align="center">
						<?php 
                // 7/21/08dp
                if ($speedctl) {
                    echo '<div id="speedcontrol">';
                    // just to keep it away from controls for sake of this demo
                    $minto = getOption("slideshow_speed");
                    while ($minto % 500 != 0) {
                        $minto += 100;
                        if ($minto > 10000) {
                            break;
                        }
                        // emergency bailout!
                    }
                    $dflttimeout = getOption("slideshow_timeout");
                    /* don't let min timeout = speed */
                    $thistimeout = $minto == getOption("slideshow_speed") ? $minto + 250 : $minto;
                    echo 'Select Speed: <select id="speed" name="speed">';
                    while ($thistimeout <= 60000) {
                        // "around" 1 minute :)
                        echo "<option value={$thistimeout} " . ($thistimeout == $dflttimeout ? " selected='selected'>" : ">") . round($thistimeout / 1000, 1) . " sec</option>";
                        /* put back timeout to even increments of .5 */
                        if ($thistimeout % 500 != 0) {
                            $thistimeout -= 250;
                        }
                        $thistimeout += $thistimeout < 1000 ? 500 : ($thistimeout < 10000 ? 1000 : 5000);
                    }
                    echo "</select> </div>";
                }
                if (!is_object($albumobj)) {
                    // disable controls if calling the slideshow directly on homepage for example
                    ?>
						<div id="controls">
						<div><span><a href="#" id="prev"
							title="<?php 
                    echo gettext("Previous");
                    ?>
"></a></span> <a
							href="<?php 
                    echo $returnpath;
                    ?>
" id="stop"
							title="<?php 
                    echo gettext("Stop and return to album or image page");
                    ?>
"></a>
						<a href="#" id="pause"
							title="<?php 
                    echo gettext("Pause (to stop the slideshow without returning)");
                    ?>
"></a>
						<a href="#" id="play" title="<?php 
                    echo gettext("Play");
                    ?>
"></a> <a
							href="#" id="next" title="<?php 
                    echo gettext("Next");
                    ?>
"></a>
						</div>
						</div>
						<?php 
                }
                ?>
						<div id="slides" class="pics">
						<?php 
                if ($cntr > 1) {
                    $cntr = 1;
                }
                for ($imgnr = 0, $idx = $imagenumber; $imgnr <= $cntr; $idx++) {
                    if ($idx >= $numberofimages) {
                        $idx = 0;
                    }
                    if ($dynamic) {
                        $folder = $images[$idx]['folder'];
                        $dalbum = new Album($gallery, $folder);
                        $filename = $images[$idx]['filename'];
                        $image = newImage($dalbum, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename);
                    } else {
                        $folder = $album->name;
                        $filename = $images[$idx];
                        //$filename = $animage;
                        $image = newImage($album, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename);
                    }
                    $ext = is_valid($filename, $validtypes);
                    if ($ext) {
                        $imgnr++;
                        echo "<span class='slideimage'><h4><strong>" . $albumtitle . gettext(":") . "</strong> " . $image->getTitle() . " (" . ($idx + 1) . "/" . $numberofimages . ")</h4>";
                        if ($ext == "3gp") {
                            echo '</a>
												<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="352" height="304" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
												<param name="src" value="' . $imagepath . '"/>
												<param name="autoplay" value="false" />
												<param name="type" value="video/quicktime" />
												<param name="controller" value="true" />
												<embed src="' . $imagepath . '" width="352" height="304" autoplay="false" controller"true" type="video/quicktime"
												pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
												</object>
												<a>';
                        } elseif ($ext == "mov") {
                            echo '</a>
									 			<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="640" height="496" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
										 		<param name="src" value="' . $imagepath . '"/>
										 		<param name="autoplay" value="false" />
										 		<param name="type" value="video/quicktime" />
										 		<param name="controller" value="true" />
										 		<embed src="' . $imagepath . '" width="640" height="496" autoplay="false" controller"true" type="video/quicktime"
										 		pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
												</object>
												<a>';
                        } else {
                            makeImageCurrent($image);
                            printCustomSizedImageMaxSpace($alt = '', $width, $height, NULL, NULL, false);
                            //echo "<img src='".WEBPATH."/".ZENFOLDER."/i.php?a=".urlencode($folder)."&i=".urlencode($filename)."&s=".$imagesize."' alt='".html_encode($image->getTitle())."' title='".html_encode($image->getTitle())."' />\n";
                        }
                        if (getOption("slideshow_showdesc")) {
                            $desc = $image->getDesc();
                            $desc = str_replace("\r\n", '<br />', $desc);
                            $desc = str_replace("\r", '<br />', $desc);
                            echo "<p class='imgdesc'>" . $desc . "</p>";
                        }
                        echo "</span>";
                    }
                }
                break;
            case "flash":
                if ($heading) {
                    echo "<span class='slideimage'><h4><strong>" . $albumtitle . "</strong> (" . $numberofimages . " images) | <a style='color: white' href='" . $returnpath . "' title='" . gettext("back") . "'>" . gettext("back") . "</a></h4>";
                }
                echo "<span id='slideshow'></span>";
                ?>
 
					<script type="text/javascript">
					$("#slideshow").flashembed({
						  src:'<?php 
                echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER;
                ?>
/flowplayer/FlowPlayerLight.swf',
						  width:<?php 
                echo getOption("slideshow_flow_player_width");
                ?>
,
						  height:<?php 
                echo getOption("slideshow_flow_player_height");
                ?>
						},
						{config: {
						  autoPlay: true,
						  useNativeFullScreen: true,
						  playList: [
													<?php 
                echo "\n";
                $count = 0;
                foreach ($images as $animage) {
                    if ($dynamic) {
                        $folder = $animage['folder'];
                        $filename = $animage['filename'];
                        $salbum = new Album($_zp_gallery, $folder);
                        $image = newImage($salbum, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($salbum->name) . "/" . urlencode($filename);
                    } else {
                        $folder = $album->name;
                        $filename = $animage;
                        $image = newImage($album, $filename);
                        $imagepath = FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . pathurlencode($filename);
                    }
                    $ext = is_valid($filename, array('jpg', 'jpeg', 'gif', 'png', 'flv', 'mp3', 'mp4'));
                    if ($ext) {
                        if ($ext == "flv" || $ext == "mp3" || $ext == "mp4") {
                            $duration = "";
                        } else {
                            $duration = ", duration: " . getOption("slideshow_speed") / 10;
                        }
                        if ($count > 0) {
                            echo ",\n";
                        }
                        echo "{ url: '" . FULLWEBPATH . getAlbumFolder('') . pathurlencode($folder) . "/" . urlencode($filename) . "'" . $duration . " }";
                        $count++;
                    }
                }
                echo "\n";
                ?>
												],
						  showPlayListButtons: true,
						  showStopButton: true,
						  controlBarBackgroundColor: 0,
						 	showPlayListButtons: true,
						 	controlsOverVideo: 'ease',
						 	controlBarBackgroundColor: '<?php 
                echo getOption('flow_player_controlbarbackgroundcolor');
                ?>
',
						  controlsAreaBorderColor: '<?php 
                echo getOption('flow_player_controlsareabordercolor');
                ?>
'
						}}
				  );
					</script> 
					<?php 
                echo "</span>";
                echo "<p>";
                printf(gettext("Click on %s on the right in the player control bar to view full size."), "<img style='position: relative; top: 4px; border: 1px solid gray' src='" . WEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . "/slideshow/flowplayerfullsizeicon.png' />");
                echo "</p>";
                break;
        }
        ?>
			</div>
		</div>
			<?php 
    }
Ejemplo n.º 26
0
/**
 * Unzips an image archive
 *
 * @param file $file the archive
 * @param string $dir where the images go
 */
function unzip($file, $dir)
{
    //check if zziplib is installed
    if (function_exists('zip_open')) {
        $zip = zip_open($file);
        if ($zip) {
            while ($zip_entry = zip_read($zip)) {
                // Skip non-images in the zip file.
                $fname = zip_entry_name($zip_entry);
                $soename = UTF8toFilesystem(seoFriendlyURL($fname));
                if (is_valid_image($soename) || is_valid_other_type($soename)) {
                    if (zip_entry_open($zip, $zip_entry, "r")) {
                        $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                        $path_file = str_replace("/", DIRECTORY_SEPARATOR, $dir . '/' . $soename);
                        $fp = fopen($path_file, "w");
                        fwrite($fp, $buf);
                        fclose($fp);
                        zip_entry_close($zip_entry);
                        $albumname = substr($dir, strlen(getAlbumFolder()));
                        $album = new Album(new Gallery(), $albumname);
                        $image = newImage($album, $soename);
                        if ($fname != $soename) {
                            $image->setTitle($name);
                            $image->save();
                        }
                    }
                }
            }
            zip_close($zip);
        }
    } else {
        // Use Zlib http://www.phpconcept.net/pclzip/index.en.php
        require_once dirname(__FILE__) . '/lib-pclzip.php';
        $zip = new PclZip($file);
        if ($zip->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
            die("Error : " . $zip->errorInfo(true));
        }
    }
}
if (isset($_POST['savealbum'])) {
    $albumname = $_POST['album'];
    if (!isMyAlbum($albumname, EDIT_RIGHTS)) {
        die(gettext("You do not have edit rights on this album."));
    }
    $album = $_POST['albumselect'];
    $words = $_POST['words'];
    if (isset($_POST['thumb'])) {
        $thumb = $_POST['thumb'];
    } else {
        $thumb = '';
    }
    $fields = $search->fields;
    $redirect = $album . '/' . $albumname . ".alb";
    if (!empty($albumname)) {
        $f = fopen(UTF8ToFilesystem(getAlbumFolder() . $redirect), 'w');
        if ($f !== false) {
            fwrite($f, "WORDS={$words}\nTHUMB={$thumb}\nFIELDS={$fields}\n");
            fclose($f);
            // redirct to edit of this album
            header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin-edit.php?page=edit&album=" . urlencode($redirect));
            exit;
        }
    }
}
$_GET['page'] = 'edit';
// pretend to be the edit page.
printAdminHeader();
echo "\n</head>";
echo "\n<body>";
printLogoAndLinks();
Ejemplo n.º 28
0
 /**
  * Returns an array of image names found in the search
  *
  * @return array
  */
 function getSearchImages()
 {
     $images = array();
     $searchstring = $this->getSearchString();
     $searchdate = $this->dates;
     if (empty($searchstring) && empty($searchdate)) {
         return $images;
     }
     // nothing to find
     $albumfolder = getAlbumFolder();
     $fields = $this->fields;
     $tagsSearch = $fields & SEARCH_TAGS;
     $fields = $fields & ~SEARCH_TAGS;
     $sql = $this->getSearchSQL($searchstring, $searchdate, 'images', $fields);
     if (!empty($sql)) {
         // valid fields exist
         $search_results = query_full_array($sql, true);
     }
     if ($tagsSearch && count($searchstring) > 0) {
         $idlist = array();
         if (isset($search_results) && is_array($search_results)) {
             foreach ($search_results as $row) {
                 $idlist[] = $row['id'];
             }
         }
         $search_results = $this->searchTags($searchstring, 'images', $idlist);
     }
     if (isset($search_results) && is_array($search_results)) {
         foreach ($search_results as $row) {
             $albumid = $row['albumid'];
             $query = "SELECT id, title, folder,`show` FROM " . prefix('albums') . " WHERE id = {$albumid}";
             $row2 = query_single_row($query);
             // id is unique
             $albumname = $row2['folder'];
             if (file_exists($albumfolder . UTF8ToFilesystem($albumname) . '/' . UTF8ToFilesystem($row['filename']))) {
                 if (checkAlbumPassword($albumname, $hint)) {
                     $images[] = array('filename' => $row['filename'], 'folder' => $albumname);
                 }
             }
         }
     }
     return $images;
 }
Ejemplo n.º 29
0
    $process = 2;
}
if (isset($_GET['q'])) {
    $quality = sanitize_numeric($_GET['q']);
} else {
    $quality = getOption('full_image_quality');
}
if (!($process || $force_cache)) {
    // no processing needed
    if (getOption('album_folder_class') != 'external' && $disposal != 'Download') {
        // local album system, return the image directly
        header('Content-Type: image/' . $suffix);
        if (UTF8_IMAGE_URI) {
            header("Location: " . getAlbumFolder(FULLWEBPATH) . pathurlencode($album8) . "/" . rawurlencode($image8));
        } else {
            header("Location: " . getAlbumFolder(FULLWEBPATH) . pathurlencode($album) . "/" . rawurlencode($image));
        }
        exitZP();
    } else {
        // the web server does not have access to the image, have to supply it
        $fp = fopen($image_path, 'rb');
        // send the right headers
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header("Content-Type: image/{$suffix}");
        if ($disposal == 'Download') {
            header('Content-Disposition: attachment; filename="' . $image . '"');
            // enable this to make the image a download
        }
        header("Content-Length: " . filesize($image_path));
        // dump the picture and stop the script
        fpassthru($fp);
Ejemplo n.º 30
0
    $albumobj = newAlbum(filesystemToInternal($album));
    if (!$albumobj->checkAccess()) {
        imageError('403 Forbidden', gettext("Forbidden(1)"));
    }
}
$args = getImageArgs($_GET);
$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'];
}
if (!isset($_GET['s']) && !isset($_GET['w']) && !isset($_GET['h'])) {
    // No image parameters specified
    if (getOption('album_folder_class') !== 'external') {
        header("Location: " . getAlbumFolder(FULLWEBPATH) . pathurlencode(filesystemToInternal($album)) . "/" . rawurlencode(filesystemToInternal($image)));
        return;
    }
}
$args = getImageParameters($args, filesystemToInternal($album));
list($size, $width, $height, $cw, $ch, $cx, $cy, $quality, $thumb, $crop, $thumbstandin, $passedWM, $adminrequest, $effects) = $args;
if (DEBUG_IMAGE) {
    debugLog("i.php({$ralbum}, {$rimage}): \$size={$size}, \$width={$width}, \$height={$height}, \$cw={$cw}, \$ch={$ch}, \$cx={$cx}, \$cy={$cy}, \$quality={$quality}, \$thumb={$thumb}, \$crop={$crop}, \$thumbstandin={$thumbstandin}, \$passedWM={$passedWM}, \$adminrequest={$adminrequest}, \$effects={$effects}");
}
$allowWatermark = !$thumb && !$adminrequest;
// Construct the filename to save the cached image.
$newfilename = getImageCacheFilename(filesystemToInternal($album), filesystemToInternal($image), $args);
$newfile = SERVERCACHE . $newfilename;
if (trim($album) == '') {
    $imgfile = ALBUM_FOLDER_SERVERPATH . $image;
} else {