示例#1
0
function accessMedia($attr, $path, $data, $volume)
{
    //allow only tinyMCE recognized media suffixes
    $valid = array("mp3", "wav", "mp4", "webm", "ogg", "swf");
    if (access($attr, $path, $data, $volume) || !is_dir($path) && !in_array(getSuffix($path), $valid)) {
        return !($attr == 'read' || $attr == 'write');
    }
    return NULL;
}
示例#2
0
function getImageProcessorURIFromCacheName($match, $watermarks)
{
    $args = array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    $set = array();
    $done = false;
    $params = explode('_', stripSuffix($match));
    while (!$done && count($params) > 1) {
        $check = array_pop($params);
        if (is_numeric($check) && !isset($set['w']) && !isset($set['h'])) {
            $set['s'] = $check;
            break;
        } else {
            $c = substr($check, 0, 1);
            if ($c == 'w' || $c == 'h') {
                if (is_numeric($v = substr($check, 1))) {
                    $set[$c] = (int) $v;
                    continue;
                }
            }
            if ($c == 'c') {
                $c = substr($check, 0, 2);
                if (is_numeric($v = substr($check, 2))) {
                    $set[$c] = (int) $v;
                    continue;
                }
            }
            if (!isset($set['w']) && !isset($set['h']) && !isset($set['s'])) {
                if (!isset($set['wm']) && in_array($check, $watermarks)) {
                    $set['wmk'] = $check;
                } else {
                    if ($check == 'thumb') {
                        $set['t'] = true;
                    } else {
                        $set['effects'] = $check;
                    }
                }
            } else {
                array_push($params, $check);
                break;
            }
        }
    }
    if (!isset($set['wmk'])) {
        $set['wmk'] = '!';
    }
    $image = preg_replace('~.*/' . CACHEFOLDER . '/~', '', implode('_', $params)) . '.' . getSuffix($match);
    //	strip out the obfustication
    $album = dirname($image);
    $image = preg_replace('~^[0-9a-f]{' . CACHE_HASH_LENGTH . '}\\.~', '', basename($image));
    $image = $album . '/' . $image;
    return array($image, getImageArgs($set));
}
示例#3
0
 /**
  * Takes an image filename and returns a GD Image using the correct function
  * for the image's format (imagecreatefrom*). Supports JPEG, GIF, and PNG.
  * @param string $imagefile the full path and filename of the image to load.
  * @return image the loaded GD image object.
  *
  */
 function zp_imageGet($imgfile)
 {
     $ext = getSuffix($imgfile);
     switch ($ext) {
         case 'png':
             return imagecreatefrompng($imgfile);
         case 'wbmp':
             return imagecreatefromwbmp($imgfile);
         case 'jpeg':
         case 'jpg':
             return imagecreatefromjpeg($imgfile);
         case 'gif':
             return imagecreatefromgif($imgfile);
     }
     return false;
 }
示例#4
0
function getPHPFiles($folder, $exclude, &$files = array())
{
    $dir = opendir($folder);
    while (($file = readdir($dir)) !== false) {
        $file = str_replace('\\', '/', $file);
        if (strpos($file, '.') !== 0) {
            if (is_dir($folder . '/' . $file) && !in_array($file, $exclude)) {
                getPHPFiles($folder . '/' . $file, $exclude, $files);
            } else {
                if (getSuffix($file) == 'php') {
                    $entry = $folder . '/' . $file;
                    $files[] = $entry;
                }
            }
        }
    }
    closedir($dir);
    return $files;
}
示例#5
0
/**
 *
 * enumerates the files in folder(s)
 * @param $folder
 */
function getResidentFiles($folder)
{
    global $_zp_resident_files;
    $localfiles = array();
    $localfolders = array();
    if (file_exists($folder)) {
        $dirs = scandir($folder);
        foreach ($dirs as $file) {
            if ($file[0] != '.') {
                $file = str_replace('\\', '/', $file);
                $key = $folder . '/' . $file;
                if (is_dir($folder . '/' . $file)) {
                    $localfolders = array_merge($localfolders, getResidentFiles($folder . '/' . $file));
                } else {
                    if (getSuffix($key) == 'php') {
                        $localfiles[] = $key;
                    }
                }
            }
        }
    }
    return array_merge($localfiles, $localfolders);
}
示例#6
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
    }
示例#7
0
        $_zp_gallery_page = 'password.php';
        $_zp_script = $_zp_themeroot . '/password.php';
        if (!file_exists(internalToFilesystem($_zp_script))) {
            $_zp_script = SERVERPATH . '/' . ZENFOLDER . '/password.php';
        }
        header('Content-Type: text/html; charset=' . LOCAL_CHARSET);
        header("HTTP/1.0 302 Found");
        header("Status: 302 Found");
        header('Last-Modified: ' . ZP_LAST_MODIFIED);
        include internalToFilesystem($_zp_script);
        exposeZenPhotoInformations($_zp_script, array(), $theme);
        exitZP();
    }
}
$image_path = $imageobj->localpath;
$suffix = getSuffix($image_path);
switch ($suffix) {
    case 'wbm':
    case 'wbmp':
        $suffix = 'wbmp';
        break;
    case 'jpg':
        $suffix = 'jpeg';
        break;
    case 'png':
    case 'gif':
    case 'jpeg':
        break;
    default:
        if ($disposal == 'Download') {
            require_once dirname(__FILE__) . '/lib-MimeTypes.php';
示例#8
0
function isTextFile($file)
{
    global $ok_extensions;
    $ext = strtolower(getSuffix($file));
    return in_array($ext, $ok_extensions);
}
示例#9
0
     $album->setOwner($_zp_current_admin_obj->getUser());
     $album->save();
 }
 @chmod($targetPath, CHMOD_VALUE);
 $error = zp_apply_filter('check_upload_quota', UPLOAD_ERR_OK, $tempFile);
 if (!$error) {
     if (is_valid_image($name) || is_valid_other_type($name)) {
         $seoname = seoFriendly($name);
         if (strrpos($seoname, '.') === 0) {
             $seoname = sha1($name) . $seoname;
         }
         // soe stripped out all the name.
         $targetFile = $targetPath . '/' . internalToFilesystem($seoname);
         if (file_exists($targetFile)) {
             $append = '_' . time();
             $seoname = stripSuffix($seoname) . $append . '.' . getSuffix($seoname);
             $targetFile = $targetPath . '/' . internalToFilesystem($seoname);
         }
         if (move_uploaded_file($tempFile, $targetFile)) {
             @chmod($targetFile, 0666 & CHMOD_VALUE);
             $album = new Album($gallery, $folder);
             $image = newImage($album, $seoname);
             $image->setOwner($_zp_current_admin_obj->getUser());
             if ($name != $seoname && $image->getTitle() == substr($seoname, 0, strrpos($seoname, '.'))) {
                 $image->setTitle(substr($name, 0, strrpos($name, '.')));
             }
             $image->save();
         } else {
             $error = UPLOAD_ERR_NO_FILE;
         }
     } else {
示例#10
0
/**
 * Checks for a zip file
 *
 * @param string $filename name of the file
 * @return bool
 */
function is_zip($filename)
{
    $ext = getSuffix($filename);
    return $ext == "zip";
}
示例#11
0
/**
 * 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;
}
示例#12
0
                }
            }
        }
        $sql = 'SELECT * FROM ' . prefix($table) . ' WHERE `' . $field . '` REGEXP "<img.*src\\s*=\\s*\\".*' . CACHEFOLDER . '((\\.|[^\\"])*)"';
        $result = query($sql);
        if ($result) {
            while ($row = db_fetch_assoc($result)) {
                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 
示例#13
0
/**
 * Creates the cache folder version of the image, including watermarking
 *
 * @param string $newfilename the name of the file when it is in the cache
 * @param string $imgfile the image name
 * @param array $args the cropping arguments
 * @param bool $allow_watermark set to true if image may be watermarked
 * @param string $theme the current theme
 * @param string $album the album containing the image
 */
function cacheImage($newfilename, $imgfile, $args, $allow_watermark = false, $theme, $album)
{
    @(list($size, $width, $height, $cw, $ch, $cx, $cy, $quality, $thumb, $crop, $thumbstandin, $passedWM, $adminrequest, $effects) = $args);
    // Set the config variables for convenience.
    $image_use_side = getOption('image_use_side');
    $upscale = getOption('image_allow_upscale');
    $allowscale = true;
    $sharpenthumbs = getOption('thumb_sharpen');
    $sharpenimages = getOption('image_sharpen');
    $id = NULL;
    $watermark_use_image = getAlbumInherited($album, 'watermark', $id);
    if (empty($watermark_use_image)) {
        $watermark_use_image = IMAGE_WATERMARK;
    }
    if (!$effects) {
        if ($thumb && getOption('thumb_gray')) {
            $effects = 'gray';
        } else {
            if (getOption('image_gray')) {
                $effects = 'gray';
            }
        }
    }
    $newfile = SERVERCACHE . $newfilename;
    if (DEBUG_IMAGE) {
        debugLog("cacheImage(\$imgfile=" . basename($imgfile) . ", \$newfilename={$newfilename}, \$allow_watermark={$allow_watermark}, \$theme={$theme}) \$size={$size}, \$width={$width}, \$height={$height}, \$cw={$cw}, \$ch={$ch}, \$cx=" . (is_null($cx) ? 'NULL' : $cx) . ", \$cy=" . (is_null($cy) ? 'NULL' : $cy) . ", \$quality={$quality}, \$thumb={$thumb}, \$crop={$crop} \$image_use_side={$image_use_side}; \$upscale={$upscale};");
    }
    // Check for the source image.
    if (!file_exists($imgfile) || !is_readable($imgfile)) {
        imageError(gettext('Image not found or is unreadable.'), 'err-imagenotfound.png');
    }
    $rotate = false;
    if (zp_imageCanRotate() && getOption('auto_rotate')) {
        $rotate = getImageRotation($imgfile);
    }
    if ($im = zp_imageGet($imgfile)) {
        if ($rotate) {
            $im = zp_rotateImage($im, $rotate);
        }
        $w = zp_imageWidth($im);
        $h = zp_imageHeight($im);
        // Give the sizing dimension to $dim
        $ratio_in = '';
        $ratio_out = '';
        $crop = $crop || $cw != 0 || $ch != 0;
        if (!empty($size)) {
            $dim = $size;
            $width = $height = false;
            if ($crop) {
                $dim = $size;
                if (!$ch) {
                    $ch = $size;
                }
                if (!$cw) {
                    $cw = $size;
                }
            }
        } else {
            if (!empty($width) && !empty($height)) {
                $ratio_in = $h / $w;
                $ratio_out = $height / $width;
                if ($ratio_in > $ratio_out) {
                    // image is taller than desired, $height is the determining factor
                    $thumb = true;
                    $dim = $width;
                    if (!$ch) {
                        $ch = $height;
                    }
                } else {
                    // image is wider than desired, $width is the determining factor
                    $dim = $height;
                    if (!$cw) {
                        $cw = $width;
                    }
                }
            } else {
                if (!empty($width)) {
                    $dim = $width;
                    $size = $height = false;
                } else {
                    if (!empty($height)) {
                        $dim = $height;
                        $size = $width = false;
                    } else {
                        // There's a problem up there somewhere...
                        imageError(gettext("Unknown error! Please report to the developers at <a href=\"http://www.zenphoto.org/\">www.zenphoto.org</a>"), 'err-imagegeneral.png');
                    }
                }
            }
        }
        $sizes = propSizes($size, $width, $height, $w, $h, $thumb, $image_use_side, $dim);
        list($neww, $newh) = $sizes;
        if (DEBUG_IMAGE) {
            debugLog("cacheImage:" . basename($imgfile) . ": \$size={$size}, \$width={$width}, \$height={$height}, \$w={$w}; \$h={$h}; \$cw={$cw}, " . "\$ch={$ch}, \$cx={$cx}, \$cy={$cy}, \$quality={$quality}, \$thumb={$thumb}, \$crop={$crop}, \$newh={$newh}, \$neww={$neww}, \$dim={$dim}, " . "\$ratio_in={$ratio_in}, \$ratio_out={$ratio_out} \$upscale={$upscale} \$rotate={$rotate} \$effects={$effects}");
        }
        if (!$upscale && $newh >= $h && $neww >= $w) {
            // image is the same size or smaller than the request
            $neww = $w;
            $newh = $h;
            $allowscale = false;
            if ($crop) {
                if ($width > $neww) {
                    $width = $neww;
                }
                if ($height > $newh) {
                    $height = $newh;
                }
            }
            if (DEBUG_IMAGE) {
                debugLog("cacheImage:no upscale " . basename($imgfile) . ":  \$newh={$newh}, \$neww={$neww}, \$crop={$crop}, \$thumb={$thumb}, \$rotate={$rotate}, watermark=" . $watermark_use_image);
            }
        }
        // Crop the image if requested.
        if ($crop) {
            if ($cw > $ch) {
                $ir = $ch / $cw;
            } else {
                $ir = $cw / $ch;
            }
            if ($size) {
                $neww = $size;
                $newh = $ir * $size;
            } else {
                $neww = $width;
                $newh = $height;
                if ($neww > $newh) {
                    if ($newh === false) {
                        $newh = $ir * $neww;
                    }
                } else {
                    if ($neww === false) {
                        $neww = $ir * $newh;
                    }
                }
            }
            if (is_null($cx) && is_null($cy)) {
                // scale crop to max of image
                // set crop scale factor
                $cf = 1;
                if ($cw) {
                    $cf = min($cf, $cw / $neww);
                }
                if ($ch) {
                    $cf = min($cf, $ch / $newh);
                }
                //	set the image area of the crop (use the most image possible, rule of thirds positioning)
                if (!$cw || $w / $cw * $ch > $h) {
                    $cw = round($h / $ch * $cw * $cf);
                    $ch = round($h * $cf);
                    $cx = round(($w - $cw) / 3);
                } else {
                    $ch = round($w / $cw * $ch * $cf);
                    $cw = round($w * $cf);
                    $cy = round(($h - $ch) / 3);
                }
            } else {
                // custom crop
                if (!$cw || $cw > $w) {
                    $cw = $w;
                }
                if (!$ch || $ch > $h) {
                    $ch = $h;
                }
            }
            // force the crop to be within the image
            if ($cw + $cx > $w) {
                $cx = $w - $cw;
            }
            if ($cx < 0) {
                $cw = $cw + $cx;
                $cx = 0;
            }
            if ($ch + $cy > $h) {
                $cy = $h - $ch;
            }
            if ($cy < 0) {
                $ch = $ch + $cy;
                $cy = 0;
            }
            if (DEBUG_IMAGE) {
                debugLog("cacheImage:crop " . basename($imgfile) . ":\$size={$size}, \$width={$width}, \$height={$height}, \$cw={$cw}, \$ch={$ch}, \$cx={$cx}, \$cy={$cy}, \$quality={$quality}, \$thumb={$thumb}, \$crop={$crop}, \$rotate={$rotate}");
            }
            $newim = zp_createImage($neww, $newh);
            zp_resampleImage($newim, $im, 0, 0, $cx, $cy, $neww, $newh, $cw, $ch);
        } else {
            if ($allowscale) {
                $sizes = propSizes($size, $width, $height, $w, $h, $thumb, $image_use_side, $dim);
                list($neww, $newh) = $sizes;
            }
            if (DEBUG_IMAGE) {
                debugLog("cacheImage:no crop " . basename($imgfile) . ":\$size={$size}, \$width={$width}, \$height={$height}, \$dim={$dim}, \$neww={$neww}; \$newh={$newh}; \$quality={$quality}, \$thumb={$thumb}, \$crop={$crop}, \$rotate={$rotate}; \$allowscale={$allowscale};");
            }
            $newim = zp_createImage($neww, $newh);
            zp_resampleImage($newim, $im, 0, 0, 0, 0, $neww, $newh, $w, $h);
        }
        $imgEffects = explode(',', $effects);
        if (in_array('gray', $imgEffects)) {
            zp_imageGray($newim);
        }
        if ($thumb && $sharpenthumbs || !$thumb && $sharpenimages) {
            zp_imageUnsharpMask($newim, getOption('sharpen_amount'), getOption('sharpen_radius'), getOption('sharpen_threshold'));
        }
        $watermark_image = false;
        if ($passedWM) {
            if ($passedWM != NO_WATERMARK) {
                $watermark_image = getWatermarkPath($passedWM);
                if (!file_exists($watermark_image)) {
                    $watermark_image = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
                }
            }
        } else {
            if ($allow_watermark) {
                $watermark_image = $watermark_use_image;
                if ($watermark_image) {
                    if ($watermark_image != NO_WATERMARK) {
                        $watermark_image = getWatermarkPath($watermark_image);
                        if (!file_exists($watermark_image)) {
                            $watermark_image = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
                        }
                    }
                }
            }
        }
        if ($watermark_image) {
            $offset_h = getOption('watermark_h_offset') / 100;
            $offset_w = getOption('watermark_w_offset') / 100;
            $watermark = zp_imageGet($watermark_image);
            $watermark_width = zp_imageWidth($watermark);
            $watermark_height = zp_imageHeight($watermark);
            $imw = zp_imageWidth($newim);
            $imh = zp_imageHeight($newim);
            $nw = sqrt($imw * $imh * $percent * ($watermark_width / $watermark_height));
            $nh = $nw * ($watermark_height / $watermark_width);
            $percent = getOption('watermark_scale') / 100;
            $r = sqrt($imw * $imh * $percent / ($watermark_width * $watermark_height));
            if (!getOption('watermark_allow_upscale')) {
                $r = min(1, $r);
            }
            $nw = round($watermark_width * $r);
            $nh = round($watermark_height * $r);
            if ($nw != $watermark_width || $nh != $watermark_height) {
                $watermark = zp_imageResizeAlpha($watermark, $nw, $nh);
            }
            // Position Overlay in Bottom Right
            $dest_x = max(0, floor(($imw - $nw) * $offset_w));
            $dest_y = max(0, floor(($imh - $nh) * $offset_h));
            if (DEBUG_IMAGE) {
                debugLog("Watermark:" . basename($imgfile) . ": \$offset_h={$offset_h}, \$offset_w={$offset_w}, \$watermark_height={$watermark_height}, \$watermark_width={$watermark_width}, \$imw={$imw}, \$imh={$imh}, \$percent={$percent}, \$r={$r}, \$nw={$nw}, \$nh={$nh}, \$dest_x={$dest_x}, \$dest_y={$dest_y}");
            }
            zp_copyCanvas($newim, $watermark, $dest_x, $dest_y, 0, 0, $nw, $nh);
            zp_imageKill($watermark);
        }
        // Create the cached file (with lots of compatibility)...
        mkdir_recursive(dirname($newfile));
        if (zp_imageOutput($newim, getSuffix($newfile), $newfile, $quality)) {
            //	successful save of cached image
            if (getOption('ImbedIPTC') && getSuffix($newfilename) == 'jpg') {
                // the imbed function works only with JPEG images
                $iptc_data = zp_imageIPTC($imgfile);
                if (empty($iptc_data)) {
                    global $_zp_extra_filetypes;
                    //	because we are doing the require in a function!
                    if (!$_zp_extra_filetypes) {
                        $_zp_extra_filetypes = array();
                    }
                    require_once dirname(__FILE__) . '/functions.php';
                    //	it is ok to increase memory footprint now since the image processing is complete
                    $gallery = new Gallery();
                    $iptc = array('1#090' => chr(0x1b) . chr(0x25) . chr(0x47), '2#115' => $gallery->getTitle());
                    $imgfile = str_replace(ALBUM_FOLDER_SERVERPATH, '', $imgfile);
                    $imagename = basename($imgfile);
                    $albumname = dirname($imgfile);
                    $image = newImage(new Album(new Gallery(), $albumname), $imagename);
                    $copyright = $image->getCopyright();
                    if (empty($copyright)) {
                        $copyright = getOption('default_copyright');
                    }
                    if (!empty($copyright)) {
                        $iptc['2#116'] = $copyright;
                    }
                    $credit = $image->getCredit();
                    if (!empty($credit)) {
                        $iptc['2#110'] = $credit;
                    }
                    foreach ($iptc as $tag => $string) {
                        $tag_parts = explode('#', $tag);
                        $iptc_data .= iptc_make_tag($tag_parts[0], $tag_parts[1], $string);
                    }
                } else {
                    if (GRAPHICS_LIBRARY == 'Imagick' && IMAGICK_RETAIN_PROFILES) {
                        //	Imageick has preserved the metadata
                        $iptc_data = false;
                    }
                }
                if ($iptc_data) {
                    $content = iptcembed($iptc_data, $newfile);
                    $fw = fopen($newfile, 'w');
                    fwrite($fw, $content);
                    fclose($fw);
                    clearstatcache();
                }
            }
            if (DEBUG_IMAGE) {
                debugLog('Finished:' . basename($imgfile));
            }
        } else {
            if (DEBUG_IMAGE) {
                debugLog('cacheImage: failed to create ' . $newfile);
            }
        }
        @chmod($newfile, 0666 & CHMOD_VALUE);
        zp_imageKill($newim);
        zp_imageKill($im);
    }
}
示例#14
0
 /**
  * Filter for handling image objects
  *
  * @param object $image
  * @return object
  */
 static function new_image($image)
 {
     global $_zp_exifvars;
     $source = '';
     $metadata_path = '';
     $files = safe_glob(substr($image->localpath, 0, strrpos($image->localpath, '.')) . '.*');
     if (count($files) > 0) {
         foreach ($files as $file) {
             if (strtolower(getSuffix($file)) == XMP_EXTENSION) {
                 $metadata_path = $file;
                 break;
             }
         }
     }
     if (!empty($metadata_path)) {
         $source = self::extractXMP(file_get_contents($metadata_path));
     } else {
         if (getOption('xmpMetadata_examine_images_' . strtolower(substr(strrchr($image->localpath, "."), 1)))) {
             $f = file_get_contents($image->localpath);
             $l = filesize($image->localpath);
             $abort = 0;
             $i = 0;
             while ($i < $l && $abort < 200 && !$source) {
                 $tag = bin2hex(substr($f, $i, 2));
                 $size = hexdec(bin2hex(substr($f, $i + 2, 2)));
                 switch ($tag) {
                     case 'ffe1':
                         // EXIF
                     // EXIF
                     case 'ffe2':
                         // EXIF extension
                     // EXIF extension
                     case 'fffe':
                         // COM
                     // COM
                     case 'ffe0':
                         // IPTC marker
                         $source = self::extractXMP($f);
                         $i = $i + $size + 2;
                         $abort = 0;
                         break;
                     default:
                         if ($f[$i] == '<') {
                             $source = self::extractXMP($f);
                         }
                         $i = $i + 1;
                         $abort++;
                         break;
                 }
             }
         }
     }
     if (!empty($source)) {
         $metadata = self::extract($source);
         $image->set('hasMetadata', count($metadata > 0));
         foreach ($metadata as $field => $element) {
             if (array_key_exists($field, $_zp_exifvars)) {
                 if (!$_zp_exifvars[$field][5]) {
                     continue;
                     //	the field has been disabled
                 }
             }
             $v = self::to_string($element);
             switch ($field) {
                 case 'EXIFDateTimeOriginal':
                     $image->setDateTime($element);
                     break;
                 case 'IPTCImageCaption':
                     $image->setDesc($v);
                     break;
                 case 'IPTCCity':
                     $image->setCity($v);
                     break;
                 case 'IPTCState':
                     $image->setState($v);
                     break;
                 case 'IPTCLocationName':
                     $image->setCountry($v);
                     break;
                 case 'IPTCSubLocation':
                     $image->setLocation($v);
                     break;
                 case 'EXIFExposureTime':
                     $v = formatExposure(self::rationalNum($element));
                     break;
                 case 'EXIFFocalLength':
                     $v = self::rationalNum($element) . ' mm';
                     break;
                 case 'EXIFAperatureValue':
                 case 'EXIFFNumber':
                     $v = 'f/' . self::rationalNum($element);
                     break;
                 case 'EXIFExposureBiasValue':
                 case 'EXIFGPSAltitude':
                     $v = self::rationalNum($element);
                     break;
                 case 'EXIFGPSLatitude':
                 case 'EXIFGPSLongitude':
                     $ref = substr($element, -1, 1);
                     $image->set($field . 'Ref', $ref);
                     $element = substr($element, 0, -1);
                     $n = explode(',', $element);
                     if (count($n) == 3) {
                         $v = $n[0] + ($n[1] + $n[2] / 60 / 60);
                     } else {
                         $v = $n[0] + $n[1] / 60;
                     }
                     break;
                 case 'rating':
                     $v = min(getoption('rating_stars_count'), $v) * min(1, getOption('rating_split_stars'));
                     $image->set('total_value', $v);
                     $image->set('total_votes', 1);
                     break;
                 case 'watermark':
                 case 'watermark_use':
                 case 'custom_data':
                 case 'codeblock':
                 case 'owner':
                     $image->set($field, $v);
                     break;
                 case 'IPTCKeywords':
                     if (!is_array($element)) {
                         $element = explode(',', $element);
                     }
                     $image->setTags($element);
                     break;
             }
             if (array_key_exists($field, $_zp_exifvars)) {
                 $image->set($field, $v);
             }
         }
         $image->save();
     }
     return $image;
 }
示例#15
0
/**
 * Returns the object "type" of the "image".
 *
 * Note:
 * 	If the root object is a video object then
 * 	If a mediaplayer is enabled a sub-type of video or audio will
 * 	be determined from the suffix. If it is not one of the
 * 	known suffixes or if the mediaplayer is not enabled then 'other' is
 * 	returned as the object type.
 *
 * 	Pure images return empty for an object type.
 *
 * @return string
 */
function getImageType($imageobj)
{
    $imageType = strtolower(get_class($imageobj));
    switch ($imageType) {
        case 'video':
            $imagesuffix = getSuffix($imageobj->filename);
            switch ($imagesuffix) {
                case 'flv':
                case 'mp4':
                case 'm4v':
                    $imageType = 'video';
                    break;
                case 'mp3':
                case 'fla':
                case 'm4a':
                    $imageType = 'audio';
                    break;
            }
            break;
        case 'image':
            $imageType = '';
            break;
        default:
            $parent = strtolower(get_parent_class($imageobj));
            if ($parent == 'textobject') {
                $imageType = 'textobject';
            }
            break;
    }
    return $imageType;
}
示例#16
0
/**
 * Gets the actual download list included all subfolders and files
 * @param string $dir An optional different folder to generate the list that overrides the folder set on the option.
 * 										This could be a subfolder of the main download folder set on the plugin's options. You have to include the base directory as like this:
 * 										"folder" or "folder/subfolder" or "../folder"
 * 										You can also set any folder within or without the root of your Zenphoto installation as a download folder with this directly
 * @param string $listtype "ol" or "ul" for the type of HTML list you want to use
 * @param array $filters an array of files to exclude from the list. Standard items are '.', '..','.DS_Store','Thumbs.db','.htaccess','.svn'
 * @param array $excludesuffixes an array of file suffixes (without trailing dot to exclude from the list (e.g. "jpg")
 * @param string $sort 'asc" or "desc" (default) for alphabetical ascending or descending list
 * @return array
 */
function getdownloadList($dir, $filters, $excludesuffixes, $sort)
{
    if (empty($dir)) {
        $dir = getOption('downloadList_directory');
    }
    if (empty($excludesuffixes)) {
        $excludesuffixes = getOption('downloadList_excludesuffixes');
    }
    if (empty($excludesuffixes)) {
        $excludesuffixes = array();
    } elseif (!is_array($excludesuffixes)) {
        $excludesuffixes = explode(',', $excludesuffixes);
    }
    if ($sort == 'asc') {
        $direction = 0;
    } else {
        $direction = 1;
    }
    $dirs = array_diff(scandir($dir, $direction), array_merge(array('.', '..', '.DS_Store', 'Thumbs.db', '.htaccess', '.svn'), $filters));
    $dir_array = array();
    if ($sort == 'asc') {
        natsort($dirs);
    }
    foreach ($dirs as $file) {
        if (is_dir($dir . '/' . $file)) {
            $dir_array[$file] = getdownloadList($dir . "/" . $file, $filters, $excludesuffixes, $sort);
        } else {
            if (!in_array(getSuffix($file), $excludesuffixes)) {
                $dir_array[$file] = $dir . '/' . $file;
            }
        }
    }
    return $dir_array;
}
示例#17
0
 /**
  * Takes an image filename and returns an Imagick image object
  *
  * @param string $imgfile the full path and filename of the image to load
  * @return Imagick
  */
 function zp_imageGet($imgfile)
 {
     global $_lib_Imagick_info;
     if (array_key_exists(strtoupper(getSuffix($imgfile)), $_lib_Imagick_info)) {
         $image = new Imagick();
         $maxHeight = getOption('magick_max_height');
         $maxWidth = getOption('magick_max_width');
         if ($maxHeight > lib_Imagick_Options::$ignore_size && $maxWidth > lib_Imagick_Options::$ignore_size) {
             $image->setOption('jpeg:size', $maxWidth . 'x' . $maxHeight);
         }
         $image->readImage(imgSrcURI($imgfile));
         //Generic CMYK to RGB conversion
         if ($image->getImageColorspace() == Imagick::COLORSPACE_CMYK) {
             $image->transformimagecolorspace(Imagick::COLORSPACE_SRGB);
         }
         return $image;
     }
     return false;
 }
示例#18
0
 /**
  * Gets the feed item data in a gallery feed
  *
  * @param object $item Object of an image or album
  * @return array
  */
 protected function getItemGallery($item)
 {
     if ($this->mode == "albums") {
         $albumobj = newAlbum($item['folder']);
         $totalimages = $albumobj->getNumImages();
         $itemlink = $this->host . $albumobj->getLink();
         $thumb = $albumobj->getAlbumThumbImage();
         $thumburl = '<img border="0" src="' . PROTOCOL . '://' . $this->host . html_encode(pathurlencode($thumb->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '" alt="' . html_encode($albumobj->getTitle($this->locale)) . '" />';
         $title = $albumobj->getTitle($this->locale);
         if (true || $this->sortorder == "latestupdated") {
             $filechangedate = filectime(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($albumobj->name));
             $latestimage = query_single_row("SELECT mtime FROM " . prefix('images') . " WHERE albumid = " . $albumobj->getID() . " AND `show` = 1 ORDER BY id DESC");
             if ($latestimage && $this->sortorder == 'latestupdated') {
                 $count = db_count('images', "WHERE albumid = " . $albumobj->getID() . " AND mtime = " . $latestimage['mtime']);
             } else {
                 $count = $totalimages;
             }
             if ($count != 0) {
                 $imagenumber = sprintf(ngettext('%s (%u image)', '%s (%u images)', $count), $title, $count);
             } else {
                 $imagenumber = $title;
             }
             $feeditem['desc'] = '<a title="' . $title . '" href="' . PROTOCOL . '://' . $itemlink . '">' . $thumburl . '</a>' . '<p>' . html_encode($imagenumber) . '</p>' . $albumobj->getDesc($this->locale) . '<br />' . sprintf(gettext("Last update: %s"), zpFormattedDate(DATE_FORMAT, $filechangedate));
         } else {
             if ($totalimages != 0) {
                 $imagenumber = sprintf(ngettext('%s (%u image)', '%s (%u images)', $totalimages), $title, $totalimages);
             }
             $feeditem['desc'] = '<a title="' . html_encode($title) . '" href="' . PROTOCOL . '://' . $itemlink . '">' . $thumburl . '</a>' . $item->getDesc($this->locale) . '<br />' . sprintf(gettext("Date: %s"), zpFormattedDate(DATE_FORMAT, $item->get('mtime')));
         }
         $ext = getSuffix($thumb->localpath);
     } else {
         $ext = getSuffix($item->localpath);
         $albumobj = $item->getAlbum();
         $itemlink = $this->host . $item->getLink();
         $fullimagelink = $this->host . html_encode(pathurlencode($item->getFullImageURL()));
         $thumburl = '<img border="0" src="' . PROTOCOL . '://' . $this->host . html_encode(pathurlencode($item->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '" alt="' . $item->getTitle($this->locale) . '" /><br />';
         $title = $item->getTitle($this->locale);
         $albumtitle = $albumobj->getTitle($this->locale);
         $datecontent = '<br />Date: ' . zpFormattedDate(DATE_FORMAT, $item->get('mtime'));
         if ($ext == "flv" || $ext == "mp3" || $ext == "mp4" || $ext == "3gp" || $ext == "mov" and $this->mode != "album") {
             $feeditem['desc'] = '<a title="' . html_encode($title) . ' in ' . html_encode($albumobj->getTitle($this->locale)) . '" href="' . PROTOCOL . '://' . $itemlink . '">' . $thumburl . '</a>' . $item->getDesc($this->locale) . $datecontent;
         } else {
             $feeditem['desc'] = '<a title="' . html_encode($title) . ' in ' . html_encode($albumobj->getTitle($this->locale)) . '" href="' . PROTOCOL . '://' . $itemlink . '"><img src="' . PROTOCOL . '://' . $this->host . html_encode(pathurlencode($item->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '" alt="' . html_encode($title) . '" /></a>' . $item->getDesc($this->locale) . $datecontent;
         }
     }
     // title
     if ($this->mode != "albums") {
         $feeditem['title'] = sprintf('%1$s (%2$s)', $item->getTitle($this->locale), $albumobj->getTitle($this->locale));
     } else {
         $feeditem['title'] = $imagenumber;
     }
     //link
     $feeditem['link'] = PROTOCOL . '://' . $itemlink;
     // enclosure
     $feeditem['enclosure'] = '';
     if (getOption("RSS_enclosure") and $this->mode != "albums") {
         $feeditem['enclosure'] = '<enclosure url="' . PROTOCOL . '://' . $fullimagelink . '" type="' . getMimeString($ext) . '" length="' . filesize($item->localpath) . '" />';
     }
     //category
     if ($this->mode != "albums") {
         $feeditem['category'] = html_encode($albumobj->getTitle($this->locale));
     } else {
         $feeditem['category'] = html_encode($albumobj->getTitle($this->locale));
     }
     //media content
     $feeditem['media_content'] = '';
     $feeditem['media_thumbnail'] = '';
     if (getOption("RSS_mediarss") and $this->mode != "albums") {
         $feeditem['media_content'] = '<media:content url="' . PROTOCOL . '://' . $fullimagelink . '" type="image/jpeg" />';
         $feeditem['media_thumbnail'] = '<media:thumbnail url="' . PROTOCOL . '://' . $fullimagelink . '" width="' . $this->imagesize . '"	height="' . $this->imagesize . '" />';
     }
     //date
     if ($this->mode != "albums") {
         $feeditem['pubdate'] = date("r", strtotime($item->getDateTime()));
     } else {
         $feeditem['pubdate'] = date("r", strtotime($albumobj->getDateTime()));
     }
     return $feeditem;
 }
示例#19
0
     if (defined('TEST_RELEASE') && TEST_RELEASE) {
         $mark = -1;
         $msg1 = gettext("Zenphoto core files [This is a <em>debug</em> build]");
     } else {
         $msg1 = '';
         $mark = 1;
     }
     $msg2 = '';
 }
 checkMark($mark, gettext("Zenphoto core files"), $msg1, $msg2, false);
 if (setupUserAuthorized() && $connection) {
     primeMark(gettext('Installation files'));
     $systemlist = $filelist = array();
     $phi_ini_count = $svncount = 0;
     foreach ($_zp_resident_files as $extra) {
         if (getSuffix($extra) == 'xxx') {
             @unlink($extra);
             //	presumed to be protected copies of the setup files
         } else {
             if (strpos($extra, 'php.ini') !== false) {
                 $phi_ini_count++;
             } else {
                 if (defined('TEST_RELEASE') && TEST_RELEASE || strpos($extra, '/.svn') === false) {
                     $systemlist[] = $extra;
                     $filelist[] = $_zp_UTF8->convert(str_replace($base, '', $extra), FILESYSTEM_CHARSET, 'UTF-8');
                 } else {
                     $svncount++;
                 }
             }
         }
     }
示例#20
0
    echo '<option value="' . $timeselect . '">' . $timeselect . ':00</option>';
    $timeselect++;
}
echo '</select>';
// Day
echo '<select name="day">';
$dayselect = '1';
$month_length = date("t");
while ($dayselect < $current_day) {
    echo '<option value="' . $dayselect . '">' . getSuffix($dayselect) . '</option>';
    $dayselect++;
}
echo '<option value="' . $dayselect . '" selected>' . getSuffix($dayselect) . '</option>';
$dayselect++;
while ($dayselect <= $month_length) {
    echo '<option value="' . $dayselect . '">' . getSuffix($dayselect) . '</option>';
    $dayselect++;
}
echo '</select>';
// Month
$month = array(1 => "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
echo '<select name="month">';
foreach ($month as $key => $val) {
    if ($key == $current_month) {
        echo '<option value="' . $key . '" selected>' . $val . '</option>';
    } else {
        echo '<option value="' . $key . '">' . $val . '</option>';
    }
}
echo '</select>';
// Year
示例#21
0
/**
 * Returns the path of an image for uses in caching it
 * NOTE: character set if for the filesystem
 *
 * @param string $album album folder
 * @param string $image image file name
 * @param array $args cropping arguments
 * @return string
 */
function getImageCacheFilename($album8, $image8, $args)
{
    global $_zp_supported_images, $_zp_cachefileSuffix;
    // this function works in FILESYSTEM_CHARSET, so convert the file names
    $album = internalToFilesystem($album8);
    if (is_array($image8)) {
        $image8 = $image8['name'];
    }
    if (IMAGE_CACHE_SUFFIX) {
        $suffix = IMAGE_CACHE_SUFFIX;
    } else {
        $suffix = @$_zp_cachefileSuffix[strtoupper(getSuffix($image8))];
        if (empty($suffix)) {
            $suffix = 'jpg';
        }
    }
    if (is_array($image8)) {
        $image = internalToFilesystem($image8['name']);
    } else {
        $image = stripSuffix(internalToFilesystem($image8));
    }
    // Set default variable values.
    $postfix = getImageCachePostfix($args);
    if (empty($album)) {
        $albumsep = '';
    } else {
        if (SAFE_MODE) {
            $albumsep = SAFE_MODE_ALBUM_SEP;
            $album = str_replace(array('/', "\\"), $albumsep, $album);
        } else {
            $albumsep = '/';
        }
    }
    if (getOption('obfuscate_cache')) {
        $result = '/' . $album . $albumsep . sha1($image . HASH_SEED . $postfix) . '.' . $image . $postfix . '.' . $suffix;
    } else {
        $result = '/' . $album . $albumsep . $image . $postfix . '.' . $suffix;
    }
    return $result;
}
/**
 * Removes unwanted images from the list returned from the filesystem
 *
 * @param array $image_array the list of images found
 * @return array
 */
function filterImages($image_array)
{
    $new_list = array();
    foreach ($image_array as $image) {
        if (!getOption('filter_file_searches_images_' . getSuffix($image))) {
            $new_list[] = $image;
        }
    }
    return $new_list;
}
示例#23
0
 /**
  *
  * "video" metadata support function
  */
 private function getMetaDataID3()
 {
     $suffix = getSuffix($this->localpath);
     if (in_array($suffix, array('m4a', 'm4v', 'mp3', 'mp4', 'flv', 'fla', 'mov', '3gp'))) {
         $getID3 = new getID3();
         @set_time_limit(30);
         $ThisFileInfo = $getID3->analyze($this->localpath);
         getid3_lib::CopyTagsToComments($ThisFileInfo);
         // output desired information in whatever format you want
         if (is_array($ThisFileInfo)) {
             return $ThisFileInfo;
         }
     }
     return NULL;
     // don't try to cover other files even if getid3 reads images as well
 }
示例#24
0
 /**
  * Loads a font and returns its font id
  *
  * @param string $font
  * @return int
  */
 function zp_imageLoadFont($font = NULL, $size = 18)
 {
     global $_gd_freetype_fonts;
     if (!empty($font)) {
         if (file_exists($font)) {
             switch (getSuffix($font)) {
                 case 'gdf':
                     return imageloadfont($font);
                 case 'ttf':
                     $index = -count($_gd_freetype_fonts);
                     array_push($_gd_freetype_fonts, array('path' => $font, 'size' => $size));
                     return $index;
             }
         }
     }
     return 5;
     // default to the largest inbuilt font
 }
示例#25
0
 /**
  * Returns the content of the text file
  *
  * @param int $w optional width
  * @param int $h optional height
  * @return string
  */
 function getContent($w = NULL, $h = NULL)
 {
     $this->updateDimensions();
     if (is_null($w)) {
         $w = $this->getWidth();
     }
     if (is_null($h)) {
         $h = $this->getHeight();
     }
     $providers = array('' => '<img src="' . html_encode(pathurlencode($this->getThumb())) . '">', 'google' => '<iframe src="http://docs.google.com/viewer?url=%s&amp;embedded=true" width="' . $w . 'px" height="' . $h . 'px" frameborder="0" border="none" scrolling="auto"></iframe>', 'zoho' => '<iframe src="http://viewer.zoho.com/api/urlview.do?url=%s&amp;embed=true" width="' . $w . 'px" height="' . $h . 'px" frameborder="0" border="none" scrolling="auto"></iframe>', 'local' => '<iframe src="%s" width="' . $w . 'px" height="' . $h . 'px" frameborder="0" border="none" scrolling="auto"></iframe>');
     switch ($suffix = getSuffix($this->filename)) {
         case 'ppt':
             $suffix = 'pps';
         case 'tiff':
             $suffix = substr($suffix, 0, 3);
         case 'tif':
         case 'pps':
         case 'pdf':
             $provider = 'WEBdocs_' . $suffix . '_provider';
             return sprintf($providers[getOption($provider)], html_encode($this->getFullImageURL(FULLWEBPATH)));
         default:
             // just in case we extend and are lazy...
             return '<img src="' . html_encode(pathurlencode($this->getThumb())) . '">';
     }
 }
示例#26
0
/**
 * Gets the actual download list included all subfolders and files
 * @param string $dir8 An optional different folder to generate the list that overrides the folder set on the option.
 * 										This could be a subfolder of the main download folder set on the plugin's options. You have to include the base directory as like this:
 * 										"folder" or "folder/subfolder" or "../folder"
 * 										You can also set any folder within or without the root of your Zenphoto installation as a download folder with this directly
 * @param string $listtype "ol" or "ul" for the type of HTML list you want to use
 * @param array $filters8 an array of files to exclude from the list. Standard items are '.', '..','.DS_Store','Thumbs.db','.htaccess','.svn'
 * @param array $excludesuffixes an array of file suffixes (without trailing dot to exclude from the list (e.g. "jpg")
 * @param string $sort 'asc" or "desc" (default) for alphabetical ascending or descending list
 * @return array
 */
function getdownloadList($dir8, $filters8, $excludesuffixes, $sort)
{
    $filters = array('Thumbs.db');
    foreach ($filters8 as $key => $file) {
        $filters[$key] = internalToFilesystem($file);
    }
    if (empty($dir8)) {
        $dir = SERVERPATH . '/' . getOption('downloadList_directory');
    } else {
        if (substr($dir8, 0, 1) == '/' || strpos($dir8, ':') !== false) {
            $dir = internalToFilesystem($dir8);
        } else {
            $dir = SERVERPATH . '/' . internalToFilesystem($dir8);
        }
    }
    if (empty($excludesuffixes)) {
        $excludesuffixes = getOption('downloadList_excludesuffixes');
    }
    if (empty($excludesuffixes)) {
        $excludesuffixes = array();
    } elseif (!is_array($excludesuffixes)) {
        $excludesuffixes = explode(',', $excludesuffixes);
    }
    if ($sort == 'asc') {
        $direction = 0;
    } else {
        $direction = 1;
    }
    $dirs = array_diff(scandir($dir, $direction), $filters);
    $dir_array = array();
    if ($sort == 'asc') {
        natsort($dirs);
    }
    foreach ($dirs as $file) {
        if (@$file[0] != '.') {
            //	exclude "hidden" files
            if (is_dir(internalToFilesystem($dir) . '/' . $file)) {
                $dirN = filesystemToInternal($dir) . "/" . filesystemToInternal($file);
                $dir_array[$file] = getdownloadList($dirN, $filters8, $excludesuffixes, $sort);
            } else {
                if (!in_array(getSuffix($file), $excludesuffixes)) {
                    $dir_array[$file] = $dir . '/' . filesystemToInternal($file);
                }
            }
        }
    }
    return $dir_array;
}
示例#27
0
 /**
  * Returns the file extension if the item passed is displayable by the player
  *
  * @param mixed $image either an image object or the filename of an image.
  * @param array $valid_types list of the types we will accept
  * @return string;
  */
 static function is_valid($image, $valid_types)
 {
     if (is_object($image)) {
         $image = $image->filename;
     }
     $ext = getSuffix($image);
     if (in_array($ext, $valid_types)) {
         return $ext;
     }
     return false;
 }
示例#28
0
 $quality = getOption('full_image_quality');
 $rotate = false;
 if (zp_imageCanRotate()) {
     $rotate = getImageRotation($imgpath);
 }
 if (DEBUG_IMAGE) {
     debugLog("image_crop: crop " . basename($imgpath) . ":\$cw={$cw}, \$ch={$ch}, \$cx={$cx}, \$cy={$cy} \$rotate={$rotate}");
 }
 if ($rotate) {
     $timg = zp_rotateImage($timg, $rotate);
 }
 $newim = zp_createImage($cw, $ch);
 zp_resampleImage($newim, $timg, 0, 0, $cx, $cy, $cw, $ch, $cw, $ch, getSuffix($imagename));
 @chmod($imgpath, 0777);
 @unlink($imgpath);
 if (zp_imageOutput($newim, getSuffix($imgpath), $imgpath, $quality)) {
     if (DEBUG_IMAGE) {
         debugLog('image_crop Finished:' . basename($imgpath));
     }
 } else {
     if (DEBUG_IMAGE) {
         debugLog('image_crop: failed to create ' . $imgpath);
     }
 }
 @chmod($imgpath, FILE_MOD);
 zp_imageKill($newim);
 zp_imageKill($timg);
 Gallery::clearCache(SERVERCACHE . '/' . $albumname);
 // update the image data
 $imageobj->set('EXIFOrientation', 0);
 $imageobj->updateDimensions();
示例#29
0
 /**
  * Delete the entire album PERMANENTLY. Be careful! This is unrecoverable.
  * Returns true if successful
  *
  * @return bool
  */
 function remove()
 {
     $rslt = false;
     if (PersistentObject::remove()) {
         foreach ($this->getImages() as $filename) {
             $image = newImage($this, $filename);
             $image->remove();
         }
         foreach ($this->getAlbums() as $folder) {
             $subalbum = newAlbum($folder);
             $subalbum->remove();
         }
         $curdir = getcwd();
         chdir($this->localpath);
         $filelist = safe_glob('*');
         foreach ($filelist as $file) {
             if ($file != '.' && $file != '..') {
                 @chmod($file, 0777);
                 unlink($this->localpath . $file);
                 // clean out any other files in the folder
             }
         }
         chdir($curdir);
         clearstatcache();
         query("DELETE FROM " . prefix('options') . "WHERE `ownerid`=" . $this->id);
         query("DELETE FROM " . prefix('comments') . "WHERE `type`='albums' AND `ownerid`=" . $this->id);
         query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='albums' AND `objectid`=" . $this->id);
         $success = true;
         $filestoremove = safe_glob(substr($this->localpath, 0, strrpos($this->localpath, '.')) . '.*');
         foreach ($filestoremove as $file) {
             if (in_array(strtolower(getSuffix($file)), $this->sidecars)) {
                 @chmod($file, 0777);
                 $success = $success && unlink($file);
             }
         }
         @chmod($this->localpath, 0777);
         $rslt = @rmdir($this->localpath) && $success;
         $cachepath = SERVERCACHE . '/' . pathurlencode($this->name) . '/';
         @chmod($cachepath, 0777);
         @rmdir($cachepath);
     }
     clearstatcache();
     return $rslt;
 }
示例#30
0
function processFilters()
{
    require_once SERVERPATH . '/' . ZENFOLDER . '/setup/setup-functions.php';
    global $_zp_resident_files;
    $classes = $subclasses = $oldfilterlist = array();
    $htmlfile = SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/filterDoc/filter list.html';
    $prolog = $epilog = '';
    if (file_exists($htmlfile)) {
        $oldhtml = file_get_contents($htmlfile);
        $i = strpos($oldhtml, '<!-- Begin filter descriptions -->');
        if ($i !== false) {
            $prolog = substr($oldhtml, 0, $i);
        }
        $i = strpos($oldhtml, '<!-- End filter descriptions -->');
        if ($i !== false) {
            $epilog = trim(substr($oldhtml, $i + 32));
        }
        preg_match_all('|<!-- description(.+?)-(.+?) -->(.+?)<!--e-->|', $oldhtml, $matches);
        foreach ($matches[2] as $key => $filter) {
            $oldfilterlist[$filter]['desc'] = $matches[3][$key];
            $class = explode('.', trim($matches[1][$key], '()'));
            $oldfilterlist[$filter]['class'] = $class[0];
            $oldfilterlist[$filter]['subclass'] = $class[1];
        }
        preg_match_all('|<!-- classhead (.+?) -->(.+?)<!--e-->|', $oldhtml, $classheads);
        foreach ($classheads[1] as $key => $head) {
            $classes[$head] = $classheads[2][$key];
        }
        preg_match_all('|<!-- subclasshead (.+?) -->(.+?)<!--e-->|', $oldhtml, $subclassheads);
        foreach ($subclassheads[1] as $key => $head) {
            $subclasses[$head] = $subclassheads[2][$key];
        }
    }
    $filterDescriptions = array();
    $filterdesc = SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/filterDoc/filter descriptions.txt';
    if (file_exists($filterdesc)) {
        $t = file_get_contents($filterdesc);
        $t = explode("\n", $t);
        foreach ($t as $d) {
            $d = trim($d);
            if (!empty($d)) {
                $f = explode(':=', $d);
                $filterDescriptions[$f[0]] = trim($f[1]);
            }
        }
    }
    getResidentZPFiles(SERVERPATH . '/' . ZENFOLDER);
    getResidentZPFiles(SERVERPATH . '/' . THEMEFOLDER);
    $key = array_search(SERVERPATH . '/' . ZENFOLDER . '/functions-filter.php', $_zp_resident_files);
    unset($_zp_resident_files[$key]);
    $key = array_search(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/deprecated-functions.php', $_zp_resident_files);
    unset($_zp_resident_files[$key]);
    $filterlist = array();
    $useagelist = array();
    foreach ($_zp_resident_files as $file) {
        if (getSuffix($file) == 'php') {
            $size = filesize($file);
            $text = file_get_contents($file);
            $script = str_replace(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/', '<em>plugin</em>/', $file);
            $script = str_replace(SERVERPATH . '/' . ZENFOLDER . '/', '<!--sort first-->/', $script);
            $script = str_replace(SERVERPATH . '/' . THEMEFOLDER . '/', '<em>theme</em>/', $script);
            preg_match_all('|zp_apply_filter\\s*\\((.+?)\\).?|', $text, $matches);
            foreach ($matches[1] as $paramsstr) {
                $filter = explode(',', $paramsstr);
                foreach ($filter as $key => $element) {
                    $filter[$key] = unQuote(trim($element));
                }
                $filtername = array_shift($filter);
                if (array_key_exists($filtername, $filterlist)) {
                    $filterlist[$filtername][0][] = $script;
                } else {
                    array_unshift($filter, array($script));
                    $filterlist[$filtername] = $filter;
                }
            }
            preg_match_all('|zp_register_filter\\s*\\((.+?)\\).?|', $text, $matches);
            foreach ($matches[1] as $paramsstr) {
                $filter = explode(',', $paramsstr);
                $filtername = unQuote(array_shift($filter));
                $useagelist[] = array('filter' => $filtername, 'script' => $script, 'scriptsize' => $size);
            }
        }
    }
    $useagelist = sortMultiArray($useagelist, 'scriptsize', false, false, false);
    $filterCategories = array();
    $newfilterlist = array();
    foreach ($filterlist as $key => $params) {
        if (count($params[0])) {
            sort($params[0]);
            $calls = array();
            $class = '';
            $subclass = '';
            $lastscript = $params[0][0];
            $count = 0;
            foreach ($params[0] as $script) {
                if (!$class) {
                    $basename = basename($script);
                    if (strpos($script, '<em>theme</em>') !== false) {
                        $class = 'Theme';
                        $subclass = 'Script';
                    } else {
                        if (strpos($basename, 'user') !== false || strpos($basename, 'auth') !== false || strpos($basename, 'logon') !== false || strpos($key, 'login') !== false) {
                            $class = 'User_management';
                            $subclass = 'Miscellaneous';
                        } else {
                            if (strpos($key, 'upload') !== false) {
                                $class = 'Upload';
                                $subclass = 'Miscellaneous';
                            } else {
                                if (strpos($key, 'texteditor') !== false) {
                                    $class = 'Miscellaneous';
                                    $subclass = 'Miscellaneous';
                                } else {
                                    if (strpos($basename, 'class') !== false) {
                                        $class = 'Object';
                                        if (strpos($basename, 'zenpage') !== false) {
                                            $class = 'Object';
                                            $subclass = 'Zenpage';
                                        } else {
                                            if (!$subclass) {
                                                switch ($basename) {
                                                    case 'classes.php':
                                                        $subclass = 'Root_class';
                                                        break;
                                                    case 'class-load.php':
                                                    case 'class-gallery.php':
                                                        $subclass = 'Miscellaneous';
                                                        break;
                                                    case 'class-album.php':
                                                    case 'class-image.php':
                                                    case 'class-transientimage.php':
                                                    case 'class-textobject.php':
                                                    case 'class-textobject_core.php':
                                                    case 'class-Anyfile.php':
                                                    case 'class-video.php':
                                                    case 'Class-WEBdocs.php':
                                                        $subclass = 'Media';
                                                        break;
                                                    case 'class-comment.php':
                                                        $subclass = 'Comments';
                                                        break;
                                                    case 'class-search.php':
                                                        $subclass = 'Search';
                                                        break;
                                                }
                                                if (strpos($key, 'image') !== false || strpos($key, 'album') !== false) {
                                                    $subclass = 'Media';
                                                }
                                            }
                                        }
                                    } else {
                                        if (strpos($script, 'admin') !== false) {
                                            $class = 'Admin';
                                            if (strpos($script, 'zenpage') !== false) {
                                                $subclass = 'Zenpage';
                                            } else {
                                                if (strpos($basename, 'comment') !== false || strpos($key, 'comment')) {
                                                    $subclass = 'Comment';
                                                } else {
                                                    if (strpos($basename, 'edit') !== false || strpos($key, 'album') !== false || strpos($key, 'image') !== false) {
                                                        $subclass = 'Media';
                                                    }
                                                }
                                            }
                                        } else {
                                            if (strpos($script, 'template') !== false) {
                                                $class = 'Template';
                                            } else {
                                                if (strpos($basename, 'zenpage') !== false) {
                                                    $class = 'Zenpage';
                                                } else {
                                                    $class = 'Miscellaneous';
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (!$subclass) {
                        $subclass = 'Miscellaneous';
                    }
                    if (array_key_exists($key, $oldfilterlist)) {
                        if ($class != $oldfilterlist[$key]['class'] || $subclass != $oldfilterlist[$key]['subclass']) {
                            $class = $oldfilterlist[$key]['class'];
                            $subclass = $oldfilterlist[$key]['subclass'];
                        }
                    }
                    if (!array_key_exists($class, $filterCategories)) {
                        $filterCategories[$class] = array('class' => $class, 'subclass' => '', 'count' => 0);
                    }
                    if (!array_key_exists($class . '_' . $subclass, $filterCategories)) {
                        $filterCategories[$class . '_' . $subclass] = array('class' => $class, 'subclass' => $subclass, 'count' => $filterCategories[$class]['count']++);
                    }
                    if (!array_key_exists('*' . $class, $filterDescriptions)) {
                        $filterDescriptions['*' . $class] = '';
                    }
                    if (!array_key_exists('*' . $class . '.' . $subclass, $filterDescriptions)) {
                        $filterDescriptions['*' . $class . '.' . $subclass] = '';
                    }
                }
                if ($script == $lastscript) {
                    $count++;
                } else {
                    if ($count > 1) {
                        $count .= " ({$count})";
                    } else {
                        $count = '';
                    }
                    $calls[] = $lastscript . $count;
                    $count = 0;
                    $lastscript = $script;
                }
            }
            if ($count > 0) {
                if ($count > 1) {
                    $count .= " ({$count})";
                } else {
                    $count = '';
                }
                $calls[] = $lastscript . $count;
            }
        }
        array_shift($params);
        $newparms = array();
        foreach ($params as $param) {
            switch ($param) {
                case 'true':
                case 'false':
                    $newparms[] = 'bool';
                    break;
                case '$this':
                    $newparms[] = 'object';
                    break;
                default:
                    if (substr($param, 0, 1) == '$') {
                        $newparms[] = trim($param, '$');
                    } else {
                        $newparms[] = 'string';
                    }
                    break;
            }
        }
        $newfilterlist[$key] = array('filter' => $key, 'calls' => $calls, 'users' => array(), 'params' => $newparms, 'desc' => '*Edit Description*', 'class' => $class, 'subclass' => $subclass);
        if (!array_key_exists($key, $filterDescriptions)) {
            $filterDescriptions[$key] = '';
        }
    }
    foreach ($useagelist as $use) {
        if (array_key_exists($use['filter'], $newfilterlist)) {
            $newfilterlist[$use['filter']]['users'][] = $use['script'];
        }
    }
    $newfilterlist = sortMultiArray($newfilterlist, array('class', 'subclass', 'filter'), false, false);
    $f = fopen($htmlfile, 'w');
    $class = $subclass = NULL;
    if ($prolog) {
        fwrite($f, $prolog);
    }
    fwrite($f, "<!-- Begin filter descriptions -->\n");
    $ulopen = false;
    foreach ($newfilterlist as $filter) {
        if ($class !== $filter['class']) {
            $class = $filter['class'];
            if (array_key_exists('*' . $class, $filterDescriptions)) {
                $classhead = '<p>' . $filterDescriptions['*' . $class] . '</p>';
            } else {
                $classhead = '';
            }
            if ($subclass) {
                fwrite($f, "\t\t\t</ul><!-- filterdetail -->\n");
            }
            fwrite($f, "\t" . '<h5><a name="' . $class . '"></a>' . $class . " filters</h5>\n");
            fwrite($f, "\t" . '<!-- classhead ' . $class . ' -->' . $classhead . "<!--e-->\n");
            $subclass = NULL;
        }
        if ($subclass !== $filter['subclass']) {
            // new subclass
            if (!is_null($subclass)) {
                fwrite($f, "\t\t\t</ul><!-- filterdetail -->\n");
            }
            $subclass = $filter['subclass'];
            if (array_key_exists('*' . $class . '.' . $subclass, $filterDescriptions)) {
                $subclasshead = '<p>' . $filterDescriptions['*' . $class . '.' . $subclass] . '</p>';
            } else {
                $subclasshead = '';
            }
            if ($subclass && $filterCategories[$class]['count'] > 1) {
                //	Class doc is adequate.
                fwrite($f, "\t\t\t" . '<h6 class="filter"><a name="' . $class . '_' . $subclass . '"></a>' . $subclass . "</h6>\n");
                fwrite($f, "\t\t\t" . '<!-- subclasshead ' . $class . '.' . $subclass . ' -->' . $subclasshead . "<!--e-->\n");
            }
            fwrite($f, "\t\t\t" . '<ul class="filterdetail">' . "\n");
        }
        fwrite($f, "\t\t\t\t" . '<li class="filterdetail">' . "\n");
        fwrite($f, "\t\t\t\t\t" . '<p class="filterdef"><tt><strong>' . $filter['filter'] . '</strong></tt>(<em>' . implode(', ', $filter['params']) . "</em>)</p>\n");
        if (array_key_exists($filter['filter'], $filterDescriptions)) {
            $filter['desc'] = '<p>' . $filterDescriptions[$filter['filter']] . '</p>';
        }
        fwrite($f, "\t\t\t\t\t" . '<!-- description(' . $class . '.' . $subclass . ')-' . $filter['filter'] . ' -->' . $filter['desc'] . "<!--e-->\n");
        $user = array_shift($filter['users']);
        if (!empty($user)) {
            fwrite($f, "\t\t\t\t\t" . '<p class="handlers">For example see ' . mytrim($user) . '</p>' . "\n");
        }
        fwrite($f, "\t\t\t\t\t" . '<p class="calls">Invoked from:' . "</p>\n");
        fwrite($f, "\t\t\t\t\t<ul><!-- calls -->\n");
        $calls = $filter['calls'];
        $limit = 4;
        foreach ($calls as $call) {
            $limit--;
            if ($limit > 0) {
                fwrite($f, "\t\t\t\t\t\t" . '<li class="call_list">' . mytrim($call) . "</li>\n");
            } else {
                fwrite($f, "\t\t\t\t\t\t<li>...</li>\n");
                break;
            }
        }
        fwrite($f, "\t\t\t\t\t" . "</ul><!-- calls -->\n");
        fwrite($f, "\t\t\t\t" . '</li><!-- filterdetail -->' . "\n");
    }
    fwrite($f, "\t\t\t" . '</ul><!-- filterdetail -->' . "\n");
    fwrite($f, "<!-- End filter descriptions -->\n");
    if ($epilog) {
        fwrite($f, $epilog);
    }
    fclose($f);
    $filterCategories = sortMultiArray($filterCategories, array('class', 'subclass', 'text'), false, false);
    $indexfile = SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/filterDoc/filter list_index.html';
    $f = fopen($indexfile, 'w');
    fwrite($f, '<li>' . "\t\n");
    fwrite($f, "\t" . '<a href="#filters">List of Zenphoto filters</a>' . "\n");
    fwrite($f, "\t<ul>\n");
    $ulopen = false;
    foreach ($filterCategories as $element) {
        $class = $element['class'];
        $subclass = $element['subclass'];
        if ($subclass == '') {
            // this is a new class element
            $count = $element['count'];
            if ($ulopen) {
                fwrite($f, "\t\t</ul>\n");
                $ulopen = false;
            }
            fwrite($f, "\t\t" . '<li><a title="' . $class . ' filters" href="#' . $class . '">' . $class . " filters</a></li>\n");
        } else {
            if ($class != $subclass) {
                if ($count > 1) {
                    if (!$ulopen) {
                        fwrite($f, "\t\t<ul>\n");
                        $ulopen = true;
                    }
                    fwrite($f, "\t\t\t\t" . '<li><a title="' . $subclass . ' ' . $class . ' filters" href="#' . $class . '_' . $subclass . '">' . $subclass . ' ' . str_replace('_', ' ', strtolower($class)) . " filters</a></li>\n");
                } else {
                    unset($filterDescriptions['*' . $class . '.' . $subclass]);
                }
            }
        }
    }
    if ($ulopen) {
        fwrite($f, "\t\t</ul>\n");
    }
    fwrite($f, "\t</ul>\n");
    fwrite($f, "</li>\n");
    fclose($f);
    $f = fopen($filterdesc, 'w');
    asort($filterDescriptions);
    foreach ($filterDescriptions as $filter => $desc) {
        fwrite($f, $filter . ':=' . $desc . "\n");
    }
    fclose($f);
}