/**
 * Registers a filtering function
 * Filtering functions are used to post process zenphoto elements or to trigger functions when a filter occur
 *
 * Typical use:
 *
 *		zp_register_filter('some_hook', 'function_handler_for_hook');
 *
 * global array $_zp_filters Storage for all of the filters
 * @param string $hook the name of the zenphoto element to be filtered
 * @param callback $function_name the name of the function that is to be called.
 * @param integer $priority optional. Used to specify the order in which the functions associated with a particular
 * 																		action are executed (default=5, lower=earlier execution, and functions with
 * 																		the same priority are executed in the order in which they were added to the filter)
 * @param int $accepted_args optional. The number of arguments the function accept (default is the number provided).
 */
function zp_register_filter($hook, $function_name, $priority = NULL, $accepted_args = NULL)
{
    global $_zp_filters, $_EnabledPlugins;
    $bt = @debug_backtrace();
    if (is_array($bt)) {
        $b = array_shift($bt);
        $base = basename($b['file']);
    } else {
        $base = 'unknown';
    }
    if (is_null($priority)) {
        $priority = @$_EnabledPlugins[stripSuffix($base)];
        if (is_null($priority)) {
            $priority = 5;
        } else {
            $priority = $priority & PLUGIN_PRIORITY;
        }
    }
    // At this point, we cannot check if the function exists, as it may well be defined later (which is OK)
    $id = zp_filter_unique_id($hook, $function_name, $priority);
    $_zp_filters[$hook][$priority][$id] = array('function' => $function_name, 'accepted_args' => $accepted_args, 'script' => $base);
    if (DEBUG_FILTERS) {
        debugLog($base . '=>' . $function_name . ' registered to ' . $hook . ' at priority ' . $priority);
    }
}
Example #2
0
function zipAddAlbum($album, $base, $zip)
{
    global $_zp_zip_list, $zip_gallery;
    $albumbase = '.' . substr($album->name, $base) . '/';
    foreach ($album->sidecars as $suffix) {
        $f = $albumbase . $album->name . '.' . $suffix;
        if (file_exists($f)) {
            $_zp_zip_list[] = $f;
        }
    }
    $images = $album->getImages();
    foreach ($images as $imagename) {
        $image = newImage($album, $imagename);
        $_zp_zip_list[] = $albumbase . $image->filename;
        $imagebase = stripSuffix($image->filename);
        foreach ($image->sidecars as $suffix) {
            $f = $albumbase . $imagebase . '.' . $suffix;
            if (file_exists($f)) {
                $_zp_zip_list[] = $f;
            }
        }
    }
    $albums = $album->getAlbums();
    foreach ($albums as $albumname) {
        $subalbum = new Album($zip_gallery, $albumname);
        if ($subalbum->exists && !$album->isDynamic()) {
            zipAddAlbum($subalbum, $base, $zip);
        }
    }
}
 function __construct()
 {
     foreach (getPluginFiles('*.php') as $extension => $plugin) {
         $deprecated = stripSuffix($plugin) . '/deprecated-functions.php';
         if (file_exists($deprecated)) {
             $plugin = basename(dirname($deprecated));
             $content = preg_replace('~#.*function~', '', file_get_contents($deprecated));
             //	remove the comments!
             preg_match_all('~@deprecated\\s+.*since\\s+.*(\\d+\\.\\d+\\.\\d+)~', $content, $versions);
             preg_match_all('/([public static|static]*)\\s*function\\s+(.*)\\s?\\(.*\\)\\s?\\{/', $content, $functions);
             if ($plugin == 'deprecated-functions') {
                 $plugin = 'core';
                 $suffix = '';
             } else {
                 $suffix = ' (' . $plugin . ')';
             }
             foreach ($functions[2] as $key => $function) {
                 if ($functions[1][$key]) {
                     $flag = '_method';
                     $star = '*';
                 } else {
                     $star = $flag = '';
                 }
                 $name = $function . $star . $suffix;
                 $option = 'deprecated_' . $plugin . '_' . $function . $flag;
                 setOptionDefault($option, 1);
                 $this->unique_functions[strtolower($function)] = $this->listed_functions[$name] = array('plugin' => $plugin, 'function' => $function, 'class' => trim($functions[1][$key]), 'since' => @$versions[1][$key], 'option' => $option, 'multiple' => array_key_exists($function, $this->unique_functions));
             }
         }
     }
 }
Example #4
0
function iconColor($icon)
{
    global $themeColor;
    if (getOption('css_style') == 'dark') {
        $icon = stripSuffix($icon) . '-white.png';
    }
    return $icon;
}
Example #5
0
/**
 * backs-up and updates the Zenphoto configuration file
 *
 * @param string $zp_cfg
 */
function storeConfig($zp_cfg)
{
    debugLogBacktrace(gettext('Updating the configuration file'));
    $mod = fileperms(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE) & 0777;
    @rename(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE, $backkup = SERVERPATH . '/' . DATA_FOLDER . '/' . stripSuffix(CONFIGFILE) . '.bak.php');
    @chmod($backup, $mod);
    file_put_contents(SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE, $zp_cfg);
    @chmod($backup, SERVERPATH . '/' . DATA_FOLDER . '/' . CONFIGFILE, $mod);
}
Example #6
0
function iconColor($icon)
{
    global $themeColor;
    if (!$themeColor) {
        $themeColor = getOption('Theme_colors');
    }
    if (strpos($themeColor, 'dark') !== false) {
        $icon = stripSuffix($icon) . '-white.png';
    }
    return $icon;
}
/**
 * backs-up and updates the configuration file
 *
 * @param string $zp_cfg
 */
function storeConfig($zp_cfg, $folder = NULL)
{
    if (is_null($folder)) {
        $folder = SERVERPATH . '/';
    }
    $mod = fileperms($folder . DATA_FOLDER . '/' . CONFIGFILE) & 0777;
    @rename($folder . DATA_FOLDER . '/' . CONFIGFILE, $backkup = $folder . DATA_FOLDER . '/' . stripSuffix(CONFIGFILE) . '.bak.php');
    @chmod($backup, $mod);
    file_put_contents($folder . DATA_FOLDER . '/' . CONFIGFILE, $zp_cfg);
    clearstatcache();
    @chmod($folder . DATA_FOLDER . '/' . CONFIGFILE, $mod);
}
Example #8
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));
}
 function getOptionsSupported()
 {
     global $_zp_gallery;
     $options = array(gettext('Minimum items') => array('key' => 'bxslider_minitems', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("The minimum number of slides to be shown. Slides will be sized down if carousel becomes smaller than the original size."), 'order' => 1), gettext('Maximum items') => array('key' => 'bxslider_maxitems', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("The maximum number of slides to be shown. Slides will be sized up if carousel becomes larger than the original size."), 'order' => 2), gettext('Width') => array('key' => 'bxslider_width', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("Width of the thumb. Note that the CSS might need to be adjusted."), 'order' => 3), gettext('Height') => array('key' => 'bxslider_height', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("Height of the thumb. Note that the CSS might need to be adjusted."), 'order' => 4), gettext('Crop width') => array('key' => 'bxslider_cropw', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => "", 'order' => 5), gettext('Crop height') => array('key' => 'bxslider_croph', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => "", 'order' => 6), gettext('Speed') => array('key' => 'bxslider_speed', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("The speed in miliseconds the slides advance when clicked.)"), 'order' => 7), gettext('Full image link') => array('key' => 'bxslider_fullimagelink', 'type' => OPTION_TYPE_CHECKBOX, 'desc' => gettext("If checked the thumbs link to the full image instead of the image page."), 'order' => 8), gettext('Mode') => array('key' => 'bxslider_mode', 'type' => OPTION_TYPE_SELECTOR, 'selections' => array(gettext('Horizontal') => "horizontal", gettext('Vertical') => "vertical", gettext('Fade') => "fade"), 'desc' => gettext("The mode of the thumb nav. Note this might require theme changes."), 'order' => 9));
     foreach (getThemeFiles(array('404.php', 'themeoptions.php', 'theme_description.php', 'functions.php', 'password.php', 'sidebar.php', 'register.php', 'contact.php')) as $theme => $scripts) {
         $list = array();
         foreach ($scripts as $script) {
             $list[$script] = 'bxslider_' . $theme . '_' . stripSuffix($script);
         }
         $options[$theme] = array('key' => 'bxslider_' . $theme . '_scripts', 'type' => OPTION_TYPE_CHECKBOX_ARRAY, 'checkboxes' => $list, 'desc' => gettext('The scripts for which BxSlider is enabled. {If themes require it they might set this, otherwise you need to do it manually!}'));
     }
     return $options;
 }
Example #10
0
 function getOptionsSupported()
 {
     global $_zp_gallery;
     $options = array(gettext('Thumbs number') => array('key' => 'jcarousel_scroll', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("The number of thumbs to scroll by. Note that the CSS might need to be adjusted.")), gettext('width') => array('key' => 'jcarousel_width', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("Width of the carousel. Note that the CSS might need to be adjusted.")), gettext('height') => array('key' => 'jcarousel_height', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("Height of the carousel. Note that the CSS might need to be adjusted.")), gettext('Crop width') => array('key' => 'jcarousel_cropw', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => ""), gettext('Crop height') => array('key' => 'jcarousel_croph', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => ""), gettext('Full image link') => array('key' => 'jcarousel_fullimagelink', 'type' => OPTION_TYPE_CHECKBOX, 'desc' => gettext("If checked the thumbs link to the full image instead of the image page.")), gettext('Vertical') => array('key' => 'jcarousel_vertical', 'type' => OPTION_TYPE_CHECKBOX, 'desc' => gettext("If checked the carousel will flow vertically instead of the default horizontal. Changing this may require theme changes!")));
     foreach (getThemeFiles(array('404.php', 'themeoptions.php', 'theme_description.php', 'functions.php', 'password.php', 'sidebar.php', 'register.php', 'contact.php')) as $theme => $scripts) {
         $list = array();
         foreach ($scripts as $script) {
             $list[$script] = 'jcarousel_' . $theme . '_' . stripSuffix($script);
         }
         $options[$theme] = array('key' => 'jcarousel_' . $theme . '_scripts', 'type' => OPTION_TYPE_CHECKBOX_ARRAY, 'checkboxes' => $list, 'desc' => gettext('The scripts for which jCarousel is enabled. {If themes require it they might set this, otherwise you need to do it manually!}'));
     }
     return $options;
 }
Example #11
0
 function __construct($folder8, $cache = true, $quiet = false)
 {
     $folder8 = trim($folder8, '/');
     $folderFS = internalToFilesystem($folder8);
     $localpath = ALBUM_FOLDER_SERVERPATH . $folderFS;
     $this->linkname = $this->name = $folder8;
     $this->localpath = rtrim($localpath, '/');
     if (!($this->exists = AlbumBase::albumCheck($folder8, $folderFS, $quiet, !file_exists($this->localpath) || is_dir($this->localpath)))) {
         return;
     }
     $data = explode("\n", file_get_contents($localpath));
     foreach ($data as $param) {
         $parts = explode('=', $param);
         switch (trim($parts[0])) {
             case 'USER':
                 $owner = trim($parts[1]);
                 break;
             case 'TITLE':
                 $this->instance = trim($parts[1]);
                 break;
             case 'THUMB':
                 $this->set('thumb', trim($parts[1]));
                 break;
         }
     }
     $new = $this->instantiate('albums', array('folder' => $this->name), 'folder', $cache);
     $title = $this->getTitle('all');
     $desc = $this->getDesc('all');
     parent::__construct($owner);
     $this->exists = true;
     if (!is_dir(stripSuffix($this->localpath))) {
         $this->linkname = stripSuffix($folder8);
     }
     $this->name = $folder8;
     $this->setTitle($title);
     $this->setDesc($desc);
     if ($new) {
         $title = $this->get('title');
         $this->set('title', stripSuffix($title));
         // Strip the suffix
         $this->setDateTime(strftime('%Y-%m-%d %H:%M:%S', $this->get('mtime')));
         $this->save();
         zp_apply_filter('new_album', $this);
     }
     zp_apply_filter('album_instantiate', $this);
 }
Example #12
0
 function getOptionsSupported()
 {
     global $_zp_gallery;
     $themes = getPluginFiles('colorbox_js/themes/*.*');
     $list = array('Custom (theme based)' => 'custom');
     foreach ($themes as $theme) {
         $theme = stripSuffix(basename($theme));
         $list[ucfirst($theme)] = $theme;
     }
     $opts = array(gettext('Colorbox theme') => array('key' => 'colorbox_theme', 'type' => OPTION_TYPE_SELECTOR, 'order' => 0, 'selections' => $list, 'desc' => gettext("The Colorbox script comes with 5 example themes you can select here. If you select <em>custom (within theme)</em> you need to place a folder <em>colorbox_js</em> containing a <em>colorbox.css</em> file and a folder <em>images</em> within the current theme to override to use a custom Colorbox theme.")));
     $c = 1;
     foreach (getThemeFiles(array('404.php', 'themeoptions.php', 'theme_description.php')) as $theme => $scripts) {
         $list = array();
         foreach ($scripts as $script) {
             $list[$script] = 'colorbox_' . $theme . '_' . stripSuffix($script);
         }
         $opts[$theme] = array('key' => 'colorbox_' . $theme . '_scripts', 'type' => OPTION_TYPE_CHECKBOX_ARRAY, 'order' => $c++, 'checkboxes' => $list, 'desc' => gettext('The scripts for which Colorbox is enabled. {Should have been set by the themes!}'));
     }
     return $opts;
 }
Example #13
0
 function getOptionsSupported()
 {
     $gallery = new Gallery();
     $opts = array();
     $exclude = array('404.php', 'themeoptions.php', 'theme_description.php');
     foreach (array_keys($gallery->getThemes()) as $theme) {
         $curdir = getcwd();
         $root = SERVERPATH . '/' . THEMEFOLDER . '/' . $theme . '/';
         chdir($root);
         $filelist = safe_glob('*.php');
         $list = array();
         foreach ($filelist as $file) {
             if (!in_array($file, $exclude)) {
                 $list[$script = stripSuffix(filesystemToInternal($file))] = 'colorbox_' . $theme . '_' . $script;
             }
         }
         chdir($curdir);
         $opts[$theme] = array('key' => 'colorbox_' . $theme . '_scripts', 'type' => OPTION_TYPE_CHECKBOX_ARRAY, 'checkboxes' => $list, 'desc' => gettext('The scripts for which Colorbox is enabled. {Should have been set by the themes!}'));
     }
     return $opts;
 }
Example #14
0
$personalities = array();
foreach ($persona as $personality) {
    if (file_exists(SERVERPATH . '/' . THEMEFOLDER . '/effervescence_plus/' . $personality . '/functions.php')) {
        $personalities[ucfirst(str_replace('_', ' ', $personality))] = $personality;
    }
}
$personality = strtolower(getOption('effervescence_personality'));
if (!in_array($personality, $personalities)) {
    $persona = $personalities;
    $personality = array_shift($persona);
}
chdir(SERVERPATH . "/themes/" . basename(dirname(__FILE__)) . "/styles");
$filelist = safe_glob('*.txt');
$themecolors = array();
foreach ($filelist as $file) {
    $themecolors[basename($file)] = stripSuffix(filesystemToInternal($file));
}
chdir($cwd);
if (!OFFSET_PATH) {
    if (extensionEnabled('themeSwitcher')) {
        $themeColor = getOption('themeSwitcher_effervescence_color');
        if (isset($_GET['themeColor'])) {
            $new = $_GET['themeColor'];
            if (in_array($new, $themecolors)) {
                setOption('themeSwitcher_effervescence_color', $new);
                $themeColor = $new;
            }
        }
        if (!$themeColor) {
            $themeColor = getThemeOption('Theme_colors');
        }
Example #15
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 {
Example #16
0
    /**
     * Creates a list of logon buttons for federated logon handlers.
     * Note that it will use an image if one exists. The name of the image
     * should be cononical to the name of the logon handler, but without the "_logon'.
     * The image must be a PNG file.
     *
     * The styling of the buttons is done by the "federated_logon_buttons.css". If you do not like the
     * one provided place an alternate version in your theme folder or the plugins/federated_logon
     * folder.
     */
    static function buttons($redirect = NULL)
    {
        $alt_handlers = federated_logon::alt_login_handler('');
        ?>
		<ul class="logon_buttons">
			<?php 
        foreach ($alt_handlers as $handler => $details) {
            $script = $details['script'];
            $authority = str_replace('_logon', '', stripSuffix(basename($script)));
            if (is_null($redirect)) {
                $details['params'][] = 'redirect=/' . ZENFOLDER . '/admin.php';
            } else {
                if (!empty($redirect)) {
                    $details['params'][] = 'redirect=' . $redirect;
                }
            }
            if (count($details['params'])) {
                $params = "'" . implode("','", $details['params']) . "'";
            } else {
                $params = '';
            }
            ?>
				<li>
					<span class="fed_buttons">
						<a href="javascript:launchScript('<?php 
            echo $script;
            ?>
',[<?php 
            echo $params;
            ?>
]);" title="<?php 
            echo $authority;
            ?>
" >
							<?php 
            $logo = ltrim(str_replace(WEBPATH, '', dirname($script)) . '/' . $authority . '.png', '/');
            if (file_exists(SERVERPATH . '/' . $logo)) {
                ?>
								<img src="<?php 
                echo WEBPATH . '/' . $logo;
                ?>
" alt="<?php 
                echo $authority;
                ?>
" title="<?php 
                printf(gettext('Login using %s'), $authority);
                ?>
" />
								<?php 
            } else {
                echo $authority;
            }
            ?>
						</a>
					</span>
				</li>
				<?php 
        }
        ?>
		</ul>
		<?php 
    }
Example #17
0
    static function getShow($heading, $speedctl, $albumobj, $imageobj, $width, $height, $crop, $shuffle, $linkslides, $controls, $returnpath, $imagenumber)
    {
        global $_zp_gallery, $_zp_gallery_page;
        setOption('slideshow_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page), 1);
        if (!$albumobj->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumobj)) {
            return '<div class="errorbox" id="message"><h2>' . gettext('This album is password protected!') . '</h2></div>';
        }
        $slideshow = '';
        $numberofimages = $albumobj->getNumImages();
        // setting the image size
        if ($width) {
            $wrapperwidth = $width;
        } else {
            $width = $wrapperwidth = getOption("slideshow_width");
        }
        if ($height) {
            $wrapperheight = $height;
        } else {
            $height = $wrapperheight = getOption("slideshow_height");
        }
        if ($numberofimages == 0) {
            return '<div class="errorbox" id="message"><h2>' . gettext('No images for the slideshow!') . '</h2></div>';
        }
        $option = getOption("slideshow_mode");
        // jQuery Cycle slideshow config
        // get slideshow data
        $showdesc = getOption("slideshow_showdesc");
        // slideshow display section
        $validtypes = array('jpg', 'jpeg', 'gif', 'png', 'mov', '3gp');
        $slideshow .= '
				<script type="text/javascript">
				// <!-- <![CDATA[
				$(document).ready(function(){
				$(function() {
				var ThisGallery = "' . html_encode($albumobj->getTitle()) . '";
				var ImageList = new Array();
				var TitleList = new Array();
				var DescList = new Array();
				var ImageNameList = new Array();
				var DynTime=(' . (int) getOption("slideshow_timeout") . ');
				';
        $images = $albumobj->getImages(0);
        if ($shuffle) {
            shuffle($images);
        }
        for ($imgnr = 0, $cntr = 0, $idx = $imagenumber; $imgnr < $numberofimages; $imgnr++, $idx++) {
            if (is_array($images[$idx])) {
                $filename = $images[$idx]['filename'];
                $album = newAlbum($images[$idx]['folder']);
                $image = newImage($album, $filename);
            } else {
                $filename = $images[$idx];
                $image = newImage($albumobj, $filename);
            }
            $ext = slideshow::is_valid($filename, $validtypes);
            if ($ext) {
                if ($crop) {
                    $img = $image->getCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, NULL, NULL);
                } else {
                    $maxwidth = $width;
                    $maxheight = $height;
                    getMaxSpaceContainer($maxwidth, $maxheight, $image);
                    $img = $image->getCustomImage(NULL, $maxwidth, $maxheight, NULL, NULL, NULL, NULL, NULL, NULL);
                }
                $slideshow .= 'ImageList[' . $cntr . '] = "' . $img . '";' . "\n";
                $slideshow .= 'TitleList[' . $cntr . '] = "' . js_encode($image->getTitle()) . '";' . "\n";
                if ($showdesc) {
                    $desc = $image->getDesc();
                    $desc = str_replace("\r\n", '<br />', $desc);
                    $desc = str_replace("\r", '<br />', $desc);
                    $slideshow .= 'DescList[' . $cntr . '] = "' . js_encode($desc) . '";' . "\n";
                } else {
                    $slideshow .= 'DescList[' . $cntr . '] = "";' . "\n";
                }
                if ($idx == $numberofimages - 1) {
                    $idx = -1;
                }
                $slideshow .= 'ImageNameList[' . $cntr . '] = "' . urlencode($filename) . '";' . "\n";
                $cntr++;
            }
        }
        $slideshow .= "\n";
        $numberofimages = $cntr;
        $slideshow .= '
				var countOffset = ' . $imagenumber . ';
				var totalSlideCount = ' . $numberofimages . ';
				var currentslide = 2;
				function onBefore(curr, next, opts) {
				if (opts.timeout != DynTime) {
				opts.timeout = DynTime;
		}
		if (!opts.addSlide)
		return;
		var currentImageNum = currentslide;
		currentslide++;
		if (currentImageNum == totalSlideCount) {
		opts.addSlide = null;
		return;
		}
		var relativeSlot = (currentslide + countOffset) % totalSlideCount;
		if (relativeSlot == 0) {relativeSlot = totalSlideCount;}
		var htmlblock = "<span class=\\"slideimage\\"><h4><strong>" + ThisGallery + ":</strong> ";
		htmlblock += TitleList[currentImageNum]  + " (" + relativeSlot + "/" + totalSlideCount + ")</h4>";
		';
        if ($linkslides) {
            if (MOD_REWRITE) {
                $slideshow .= 'htmlblock += "<a href=\\"' . pathurlencode($albumobj->name) . '/"+ImageNameList[currentImageNum]+"' . getOption('mod_rewrite_image_suffix') . '\\">";';
            } else {
                $slideshow .= 'htmlblock += "<a href=\\"index.php?album=' . pathurlencode($albumobj->name) . '&image="+ImageNameList[currentImageNum]+"\\">";';
            }
        }
        $slideshow .= ' htmlblock += "<img src=\\"" + ImageList[currentImageNum] + "\\"/>";';
        if ($linkslides) {
            $slideshow .= ' htmlblock += "</a>";';
        }
        $slideshow .= 'htmlblock += "<p class=\\"imgdesc\\">" + DescList[currentImageNum] + "</p></span>";';
        $slideshow .= 'opts.addSlide(htmlblock);';
        $slideshow .= '}';
        $slideshow .= '
				function onAfter(curr, next, opts){
				';
        if (!$albumobj->isMyItem(LIST_RIGHTS)) {
            $slideshow .= '
					//Only register at hit count the first time the image is viewed.
					if ($(next).attr("viewed") != 1) {
					$.get("' . FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/slideshow/slideshow-counter.php?album=' . pathurlencode($albumobj->name) . '&img="+ImageNameList[opts.currSlide]);
					$(next).attr("viewed", 1 );
				}
				';
        }
        $slideshow .= '}';
        $slideshow .= '
				$("#slides").cycle({
				fx:     "' . getOption("slideshow_effect") . '",
				speed:   "' . getOption("slideshow_speed") . '",
				timeout: DynTime,
				next:   "#next",
				prev:   "#prev",
				cleartype: 1,
				before: onBefore,
				after: onAfter
		});

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

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

		});	// Documentready()
		// ]]> -->
		</script>
		<div id="slideshow" style="height:' . ($wrapperheight + 40) . 'px; width:' . $wrapperwidth . 'px;">
		';
        // 7/21/08dp
        if ($speedctl) {
            $slideshow .= '<div id="speedcontrol">';
            // just to keep it away from controls for sake of this demo
            $minto = getOption("slideshow_speed");
            while ($minto % 500 != 0) {
                $minto += 100;
                if ($minto > 10000) {
                    break;
                }
                // emergency bailout!
            }
            $dflttimeout = (int) getOption("slideshow_timeout");
            /* don't let min timeout = speed */
            $thistimeout = $minto == getOption("slideshow_speed") ? $minto + 250 : $minto;
            $slideshow .= 'Select Speed: <select id="speed" name="speed">';
            while ($thistimeout <= 60000) {
                // "around" 1 minute :)
                $slideshow .= "<option value={$thistimeout} " . ($thistimeout == $dflttimeout ? " selected='selected'>" : ">") . round($thistimeout / 1000, 1) . " sec</option>";
                /* put back timeout to even increments of .5 */
                if ($thistimeout % 500 != 0) {
                    $thistimeout -= 250;
                }
                $thistimeout += $thistimeout < 1000 ? 500 : ($thistimeout < 10000 ? 1000 : 5000);
            }
            $slideshow .= '</select> </div>';
        }
        if ($controls) {
            $slideshow .= '
					<div id="controls">
					<div>
					<a href="#" id="prev" title="' . gettext("Previous") . '"></a>
					<a href="' . html_encode($returnpath) . '" id="stop" title="' . gettext("Stop and return to album or image page") . '"></a>
					<a href="#" id="pause" title="' . gettext("Pause (to stop the slideshow without returning)") . '"></a>
					<a href="#" id="play" title="' . gettext("Play") . '"></a>
					<a href="#" id="next" title="' . gettext("Next") . '"></a>
					</div>
					</div>
					';
        }
        $slideshow .= '
				<div id="slides" class="pics">
				';
        if ($cntr > 1) {
            $cntr = 1;
        }
        for ($imgnr = 0, $idx = $imagenumber; $imgnr <= $cntr; $idx++) {
            if ($idx >= $numberofimages) {
                $idx = 0;
            }
            if (is_array($images[$idx])) {
                $folder = $images[$idx]['folder'];
                $dalbum = newAlbum($folder);
                $filename = $images[$idx]['filename'];
                $image = newImage($dalbum, $filename);
                $imagepath = FULLWEBPATH . ALBUM_FOLDER_EMPTY . $folder . "/" . $filename;
            } else {
                $folder = $albumobj->name;
                $filename = $images[$idx];
                //$filename = $animage;
                $image = newImage($albumobj, $filename);
                $imagepath = FULLWEBPATH . ALBUM_FOLDER_EMPTY . $folder . "/" . $filename;
            }
            $ext = slideshow::is_valid($filename, $validtypes);
            if ($ext) {
                $imgnr++;
                $slideshow .= '<span class="slideimage"><h4><strong>' . $albumobj->getTitle() . gettext(":") . '</strong> ' . $image->getTitle() . ' (' . ($idx + 1) . '/' . $numberofimages . ')</h4>';
                if ($ext == "3gp") {
                    $slideshow .= '</a>
							<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="352" height="304" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
							<param name="src" value="' . pathurlencode(internalToFilesystem($imagepath)) . '"/>
							<param name="autoplay" value="false" />
							<param name="type" value="video/quicktime" />
							<param name="controller" value="true" />
							<embed src="' . pathurlencode(internalToFilesystem($imagepath)) . '" width="352" height="304" autoplay="false" controller"true" type="video/quicktime"
							pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
							</object>
							<a>';
                } elseif ($ext == "mov") {
                    $slideshow .= '</a>
							<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="640" height="496" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
							<param name="src" value="' . pathurlencode(internalToFilesystem($imagepath)) . '"/>
							<param name="autoplay" value="false" />
							<param name="type" value="video/quicktime" />
							<param name="controller" value="true" />
							<embed src="' . pathurlencode(internalToFilesystem($imagepath)) . '" width="640" height="496" autoplay="false" controller"true" type="video/quicktime"
							pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
							</object>
							<a>';
                } else {
                    if ($linkslides) {
                        $slideshow .= '<a href="' . html_encode($image->getLink()) . '">';
                    }
                    if ($crop) {
                        $img = $image->getCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, NULL, NULL);
                    } else {
                        $maxwidth = $width;
                        $maxheight = $height;
                        getMaxSpaceContainer($maxwidth, $maxheight, $image);
                        $img = $image->getCustomImage(NULL, $maxwidth, $maxheight, NULL, NULL, NULL, NULL, NULL, NULL);
                    }
                    $slideshow .= '<img src="' . html_encode(pathurlencode($img)) . '" alt="" />';
                    if ($linkslides) {
                        $slideshow .= '</a>';
                    }
                }
                if ($showdesc) {
                    $desc = $image->getDesc();
                    $desc = str_replace("\r\n", '<br />', $desc);
                    $desc = str_replace("\r", '<br />', $desc);
                    $slideshow .= '<p class="imgdesc">' . $desc . '</p>';
                }
                $slideshow .= '</span>';
            }
        }
        $slideshow .= '
		</div>
		</div>
		';
        return $slideshow;
    }
Example #18
0
            if (preg_match('~^' . THEMEFOLDER . '/~', $owner)) {
                if ($owner == THEMEFOLDER . '/') {
                    $where = ' WHERE `creator` = "' . THEMEFOLDER . '/"';
                } else {
                    $where = ' WHERE `creator` LIKE ' . db_quote('%' . basename($owner) . '/themeoptions.php');
                }
                $sql = 'DELETE FROM ' . prefix('options') . $where;
                $result = query($sql);
            } else {
                purgeOption('zp_plugin_' . stripSuffix(basename($owner)));
            }
        }
    }
    if (isset($_POST['missingplugin'])) {
        foreach ($_POST['missingplugin'] as $plugin) {
            purgeOption('zp_plugin_' . stripSuffix($plugin));
        }
    }
}
printAdminHeader('options', '');
?>
<link rel="stylesheet" href="purgeOptions.css" type="text/css">
</head>
<body>
	<?php 
printLogoAndLinks();
?>
	<div id="main">
		<?php 
printTabs();
?>
Example #19
0
 /**
  * returns URL to the original image or to a high quality alternate
  * e.g. ogg, avi, wmv files that can be handled by the client browser
  *
  * @param unknown_type $path
  */
 function getFullImageURL()
 {
     // Search for a high quality version of the video
     if ($vid = parent::getFullImageURL()) {
         $folder = ALBUM_FOLDER_SERVERPATH . internalToFilesystem($this->album->getFileName());
         $video = stripSuffix($this->filename);
         $curdir = getcwd();
         chdir($folder);
         $candidates = safe_glob($video . '.*');
         chdir($curdir);
         foreach ($candidates as $target) {
             $ext = getSuffix($target);
             if (in_array($ext, $this->videoalt)) {
                 $vid = stripSuffix($vid) . '.' . substr(strrchr($target, "."), 1);
             }
         }
     }
     return $vid;
 }
Example #20
0
    /**
     * Prints html meta data to be used in the <head> section of a page
     *
     */
    static function getHTMLMetaData()
    {
        global $_zp_gallery, $_zp_galley_page, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_gallery_page, $_zp_current_category, $_zp_authority, $_zp_conf_vars, $_myFavorites, $htmlmetatags_need_cache, $_zp_page;
        zp_register_filter('image_processor_uri', 'htmlmetatags::ipURI');
        $host = sanitize("http://" . $_SERVER['HTTP_HOST']);
        $url = $host . getRequestURI();
        // Convert locale shorttag to allowed html meta format
        $locale = str_replace("_", "-", getUserLocale());
        $canonicalurl = '';
        // generate page title, get date
        $pagetitle = "";
        // for gallery index setup below switch
        $date = strftime(DATE_FORMAT);
        // if we don't have a item date use current date
        $desc = getBareGalleryDesc();
        $thumb = '';
        if (getOption('htmlmeta_sitelogo')) {
            $thumb = getOption('htmlmeta_sitelogo');
        }
        if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
            $ogimage_width = getOption('htmlmeta_ogimage_width');
            $ogimage_height = getOption('htmlmeta_ogimage_height');
            if (empty($ogimage_width)) {
                $ogimage_width = 1280;
            }
            if (empty($ogimage_height)) {
                $ogimage_height = 900;
            }
        }
        $type = 'article';
        switch ($_zp_gallery_page) {
            case 'index.php':
                $desc = getBareGalleryDesc();
                //$canonicalurl = $host . getGalleryIndexURL();
                $canonicalurl = $host . getPageNumURL($_zp_page);
                $type = 'website';
                break;
            case 'album.php':
                $pagetitle = getBareAlbumTitle() . " - ";
                $date = getAlbumDate();
                $desc = getBareAlbumDesc();
                $canonicalurl = $host . getPageNumURL($_zp_page);
                if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
                    $thumbimg = $_zp_current_album->getAlbumThumbImage();
                    getMaxSpaceContainer($ogimage_width, $ogimage_height, $thumbimg, false);
                    $thumb = $host . html_encode(pathurlencode($thumbimg->getCustomImage(NULL, $ogimage_width, $ogimage_height, NULL, NULL, NULL, NULL, false, NULL)));
                }
                break;
            case 'image.php':
                $pagetitle = getBareImageTitle() . " (" . getBareAlbumTitle() . ") - ";
                $date = getImageDate();
                $desc = getBareImageDesc();
                $canonicalurl = $host . getImageURL();
                if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
                    $thumb = $host . html_encode(pathurlencode(getCustomSizedImageMaxSpace($ogimage_width, $ogimage_height)));
                }
                break;
            case 'news.php':
                if (function_exists("is_NewsArticle")) {
                    if (is_NewsArticle()) {
                        $pagetitle = getBareNewsTitle() . " - ";
                        $date = getNewsDate();
                        $desc = trim(getBare(getNewsContent()));
                        $canonicalurl = $host . $_zp_current_zenpage_news->getLink();
                    } else {
                        if (is_NewsCategory()) {
                            $pagetitle = $_zp_current_category->getTitlelink() . " - ";
                            $date = strftime(DATE_FORMAT);
                            $desc = trim(getBare($_zp_current_category->getDesc()));
                            $canonicalurl = $host . $_zp_current_category->getLink();
                            $type = 'category';
                        } else {
                            $pagetitle = gettext('News') . " - ";
                            $desc = '';
                            $canonicalurl = $host . getNewsIndexURL();
                            $type = 'website';
                        }
                    }
                    if ($_zp_page != 1) {
                        $canonicalurl .= '/' . $_zp_page;
                    }
                }
                break;
            case 'pages.php':
                $pagetitle = getBarePageTitle() . " - ";
                $date = getPageDate();
                $desc = trim(getBare(getPageContent()));
                $canonicalurl = $host . $_zp_current_zenpage_page->getLink();
                break;
            default:
                // for all other possible static custom pages
                $custompage = stripSuffix($_zp_gallery_page);
                $standard = array('contact' => gettext('Contact'), 'register' => gettext('Register'), 'search' => gettext('Search'), 'archive' => gettext('Archive view'), 'password' => gettext('Password required'));
                if (is_object($_myFavorites)) {
                    $standard['favorites'] = gettext('My favorites');
                }
                if (array_key_exists($custompage, $standard)) {
                    $pagetitle = $standard[$custompage] . " - ";
                } else {
                    $pagetitle = $custompage . " - ";
                }
                $desc = '';
                $canonicalurl = $host . getCustomPageURL($custompage);
                if ($_zp_page != 1) {
                    $canonicalurl .= '/' . $_zp_page;
                }
                break;
        }
        // shorten desc to the allowed 200 characters if necesssary.
        $desc = html_encode(trim(substr(getBare($desc), 0, 160)));
        $pagetitle = $pagetitle . getBareGalleryTitle();
        // get master admin
        $admin = $_zp_authority->getMasterUser();
        $author = $admin->getName();
        $meta = '';
        if (getOption('htmlmeta_http-equiv-cache-control')) {
            $meta .= '<meta http-equiv="Cache-control" content="' . getOption("htmlmeta_cache_control") . '">' . "\n";
        }
        if (getOption('htmlmeta_http-equiv-pragma')) {
            $meta .= '<meta http-equiv="pragma" content="' . getOption("htmlmeta_pragma") . '">' . "\n";
        }
        if (getOption('htmlmeta_name-keywords')) {
            $meta .= '<meta name="keywords" content="' . htmlmetatags::getMetaKeywords() . '">' . "\n";
        }
        if (getOption('htmlmeta_name-description')) {
            $meta .= '<meta name="description" content="' . $desc . '">' . "\n";
        }
        if (getOption('htmlmeta_name-page-topic')) {
            $meta .= '<meta name="page-topic" content="' . $desc . '">' . "\n";
        }
        if (getOption('htmlmeta_name-robots')) {
            $meta .= '<meta name="robots" content="' . getOption("htmlmeta_robots") . '">' . "\n";
        }
        if (getOption('htmlmeta_name-publisher')) {
            $meta .= '<meta name="publisher" content="' . FULLWEBPATH . '">' . "\n";
        }
        if (getOption('htmlmeta_name-creator')) {
            $meta .= '<meta name="creator" content="' . FULLWEBPATH . '">' . "\n";
        }
        if (getOption('htmlmeta_name-author')) {
            $meta .= '<meta name="author" content="' . $author . '">' . "\n";
        }
        if (getOption('htmlmeta_name-copyright')) {
            $meta .= '<meta name="copyright" content=" (c) ' . FULLWEBPATH . ' - ' . $author . '">' . "\n";
        }
        if (getOption('htmlmeta_name-rights')) {
            $meta .= '<meta name="rights" content="' . $author . '">' . "\n";
        }
        if (getOption('htmlmeta_name-generator')) {
            $meta .= '<meta name="generator" content="Zenphoto ' . ZENPHOTO_VERSION . '">' . "\n";
        }
        if (getOption('htmlmeta_name-revisit-after')) {
            $meta .= '<meta name="revisit-after" content="' . getOption("htmlmeta_revisit_after") . '">' . "\n";
        }
        if (getOption('htmlmeta_name-expires')) {
            $expires = getOption("htmlmeta_expires");
            if ($expires == (int) $expires) {
                $expires = preg_replace('|\\s\\-\\d+|', '', date('r', time() + $expires)) . ' GMT';
            }
            $meta .= '<meta name="expires" content="' . $expires . '">' . "\n";
        }
        // OpenGraph meta
        if (getOption('htmlmeta_og-title')) {
            $meta .= '<meta property="og:title" content="' . $pagetitle . '">' . "\n";
        }
        if (getOption('htmlmeta_og-image') && !empty($thumb)) {
            $meta .= '<meta property="og:image" content="' . $thumb . '">' . "\n";
        }
        if (getOption('htmlmeta_og-description')) {
            $meta .= '<meta property="og:description" content="' . $desc . '">' . "\n";
        }
        if (getOption('htmlmeta_og-url')) {
            $meta .= '<meta property="og:url" content="' . html_encode($url) . '">' . "\n";
        }
        if (getOption('htmlmeta_og-type')) {
            $meta .= '<meta property="og:type" content="' . $type . '">' . "\n";
        }
        // Social network extras
        if (getOption('htmlmeta_name-pinterest')) {
            $meta .= '<meta name="pinterest" content="nopin">' . "\n";
        }
        // dissalow users to pin images on Pinterest
        // Twitter card
        $twittername = getOption('htmlmeta_twittername');
        if (getOption('htmlmeta_twittercard') || !empty($twittername)) {
            $meta .= '<meta property="twitter:creator" content="' . $twittername . '">' . "\n";
            $meta .= '<meta property="twitter:site" content="' . $twittername . '">' . "\n";
            $meta .= '<meta property="twitter:card" content="summary">' . "\n";
            $meta .= '<meta property="twitter:title" content="' . $pagetitle . '">' . "\n";
            $meta .= '<meta property="twitter:description" content="' . $desc . '">' . "\n";
            if (!empty($thumb)) {
                $meta .= '<meta property="twitter:image" content="' . $thumb . '">' . "\n";
            }
        }
        // Canonical url
        if (getOption('htmlmeta_canonical-url')) {
            $meta .= '<link rel="canonical" href="' . $canonicalurl . '">' . "\n";
            if (METATAG_LOCALE_TYPE) {
                $langs = generateLanguageList();
                if (count($langs) != 1) {
                    foreach ($langs as $text => $lang) {
                        $langcheck = zpFunctions::getLanguageText($lang, '-');
                        //	for hreflang we need en-US
                        if ($langcheck != $locale) {
                            switch (METATAG_LOCALE_TYPE) {
                                case 1:
                                    $altlink = seo_locale::localePath(true, $lang);
                                    break;
                                case 2:
                                    $altlink = dynamic_locale::fullHostPath($lang);
                                    break;
                            }
                            switch ($_zp_gallery_page) {
                                case 'index.php':
                                    $altlink .= '/';
                                    break;
                                case 'gallery.php':
                                    $altlink .= '/' . _PAGE_ . '/gallery';
                                    break;
                                case 'album.php':
                                    $altlink .= '/' . html_encode($_zp_current_album->name) . '/';
                                    break;
                                case 'image.php':
                                    $altlink .= '/' . html_encode($_zp_current_album->name) . '/' . html_encode($_zp_current_image->filename) . IM_SUFFIX;
                                    break;
                                case 'news.php':
                                    if (function_exists("is_NewsArticle")) {
                                        if (is_NewsArticle()) {
                                            $altlink .= '/' . _NEWS_ . '/' . html_encode($_zp_current_zenpage_news->getTitlelink());
                                        } else {
                                            if (is_NewsCategory()) {
                                                $altlink .= '/' . _NEWS_ . '/' . html_encode($_zp_current_category->getTitlelink());
                                            } else {
                                                $altlink .= '/' . _NEWS_;
                                            }
                                        }
                                    }
                                    break;
                                case 'pages.php':
                                    $altlink .= '/' . _PAGES_ . '/' . html_encode($_zp_current_zenpage_page->getTitlelink());
                                    break;
                                case 'archive.php':
                                    $altlink .= '/' . _ARCHIVE_;
                                    break;
                                case 'search.php':
                                    $altlink .= '/' . _SEARCH_ . '/';
                                    break;
                                case 'contact.php':
                                    $altlink .= '/' . _CONTACT_ . '/';
                                    break;
                                default:
                                    // for all other possible none standard custom pages
                                    $altlink .= '/' . _PAGE_ . '/' . html_encode($pagetitle);
                                    break;
                            }
                            // switch
                            //append page number if needed
                            switch ($_zp_gallery_page) {
                                case 'index.php':
                                case 'album.php':
                                    if ($_zp_page != 1) {
                                        $altlink .= _PAGE_ . '/' . $_zp_page . '/';
                                    }
                                    break;
                                case 'gallery.php':
                                case 'news.php':
                                    if ($_zp_page != 1) {
                                        $altlink .= '/' . $_zp_page;
                                    }
                                    break;
                            }
                            $meta .= '<link rel="alternate" hreflang="' . $langcheck . '" href="' . $altlink . '">' . "\n";
                        }
                        // if lang
                    }
                    // foreach
                }
                // if count
            }
            // if option
        }
        // if canonical
        if (!empty($htmlmetatags_need_cache)) {
            $meta .= '<script type="text/javascript">' . "\n";
            $meta .= 'var caches = ["' . implode('","', $htmlmetatags_need_cache) . '"];' . "\n";
            $meta .= '
					window.onload = function() {
						var index,value;
						for (index in caches) {
								value = caches[index];
								$.ajax({
									cache: false,
									type: "GET",
									url: value
								});
						}
					}
					';
            $meta .= '</script>' . "\n";
        }
        zp_remove_filter('image_processor_uri', 'htmlmetatags::ipURI');
        echo $meta;
    }
 * allow your plugin to co-exist with other custom field extender plugins.
 *
 * @author Stephen Billard (sbillard)
 * @package plugins
 * @subpackage example
 * @category package
 *
 */
$plugin_is_filter = 5 | CLASS_PLUGIN;
//	if you have such a plugin you probably want to use it
$plugin_description = gettext('Adds user defined fields to database tables');
$plugin_author = "Stephen Billard (sbillard)";
if (file_exists(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/common/fieldExtender.php')) {
    require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/common/fieldExtender.php';
} else {
    require_once stripSuffix(__FILE__) . '/fieldExtender.php';
}
//NOTE: you should choose a unique class name to be sure not to conflict with another custom field extender plugin
class customFieldExtender extends fieldExtender
{
    /*
     * For definition of this array see fieldExtender.php in the extensions/common folder
     */
    static $fields = array(array('table' => 'albums', 'name' => 'Album_Custom', 'desc' => 'Custom album field', 'type' => 'varchar', 'size' => 50, 'edit' => 'multilingual'), array('table' => 'albums', 'name' => 'custom_field2', 'desc' => 'Custom field 2', 'type' => 'varchar', 'size' => 75, 'searchDefault' => 1, 'bulkAction' => array('Custom field 2' => 'mass_customText_data')), array('table' => 'images', 'name' => 'custom_field1', 'desc' => 'Custom field 1', 'type' => 'varchar', 'size' => 75, 'searchDefault' => 1, 'edit' => 'function', 'function' => 'customFieldExtender::custom_option'), array('table' => 'images', 'name' => 'custom_field2', 'desc' => 'Custom field 2', 'type' => 'varchar', 'size' => 75, 'searchDefault' => 1, 'bulkAction' => array('Custom field 2' => 'mass_customText_data')), array('table' => 'news', 'name' => 'News_Custom', 'desc' => 'Custom News field', 'type' => 'varchar', 'size' => 50), array('table' => 'news', 'name' => 'custom_field2', 'desc' => 'Custom field 2', 'type' => 'varchar', 'size' => 75, 'searchDefault' => 1, 'bulkAction' => array('Custom field 2' => 'mass_customText_data')), array('table' => 'pages', 'name' => 'Page_custom', 'desc' => 'Custom Page field', 'type' => 'varchar', 'size' => 50), array('table' => 'pages', 'name' => 'custom_field2', 'desc' => 'Custom field 2', 'type' => 'text', 'searchDefault' => 1, 'bulkAction' => array('Custom field 2' => 'mass_customTextarea_data')));
    function __construct()
    {
        parent::constructor('customFieldExtender', self::$fields);
    }
    static function fields()
    {
        return self::$fields;
Example #22
0
            header("Content-Type: {$mimetype}");
            header("Content-Length: " . filesize($image_path));
            // dump the picture and stop the script
            fpassthru($fp);
            fclose($fp);
        } else {
            header('Location: ' . $imageobj->getFullImageURL(), true, 301);
        }
        exitZP();
}
if ($force_cache = getOption('cache_full_image')) {
    $cache_file = getImageCacheFilename($album, $image, $args);
    $cache_path = SERVERCACHE . $cache_file;
    mkdir_recursive(dirname($cache_path), FOLDER_MOD);
} else {
    $cache_file = $album . "/" . stripSuffix($image) . '_FULL.' . $suffix;
    $cache_path = NULL;
}
$process = $rotate = false;
if (zp_imageCanRotate()) {
    $rotate = getImageRotation($imageobj);
    $process = $rotate;
}
$watermark_use_image = getWatermarkParam($imageobj, WATERMARK_FULL);
if ($watermark_use_image == NO_WATERMARK) {
    $watermark_use_image = '';
} else {
    $process = 2;
}
if (isset($_GET['q'])) {
    $quality = sanitize_numeric($_GET['q']);
<?php

/**
 * PHP sendmail mailing handler
 *
 * @author Stephen Billard (sbillard)
 *
 * @package plugins
 * @subpackage mail
 */
$plugin_is_filter = defaultExtension(5 | CLASS_PLUGIN);
$plugin_description = gettext("Outgoing mail handler based on the PHP <em>mail</em> facility.");
$plugin_author = "Stephen Billard (sbillard)";
$plugin_disable = zp_has_filter('sendmail') && !extensionEnabled('zenphoto_sendmail') ? sprintf(gettext('Only one Email handler plugin may be enabled. <a href="#%1$s"><code>%1$s</code></a> is already enabled.'), stripSuffix(get_filterScript('sendmail'))) : '';
if ($plugin_disable) {
    enableExtension('zenphoto_sendmail', 0);
} else {
    zp_register_filter('sendmail', 'zenphoto_sendmail');
}
function zenphoto_sendmail($msg, $email_list, $subject, $message, $from_mail, $from_name, $cc_addresses, $replyTo, $html = false)
{
    $headers = sprintf('From: %1$s <%2$s>', $from_name, $from_mail) . "\n";
    if (count($cc_addresses) > 0) {
        $cclist = '';
        foreach ($cc_addresses as $cc_name => $cc_mail) {
            $cclist .= ',' . $cc_mail;
        }
        $headers .= 'Cc: ' . substr($cclist, 1) . "\n";
    }
    if ($replyTo) {
        $headers .= 'Reply-To: ' . array_shift($replyTo) . "\n";
/**
 * Checks to see if a password is needed
 *
 * Returns true if access is allowed
 *
 * The password protection is hereditary. This normally only impacts direct url access to an object since if
 * you are going down the tree you will be stopped at the first place a password is required.
 *
 *
 * @param string $hint the password hint
 * @param bool $show whether there is a user associated with the password.
 * @return bool
 * @since 1.1.3
 */
function checkAccess(&$hint = NULL, &$show = NULL)
{
    global $_zp_current_album, $_zp_current_search, $_zp_gallery, $_zp_gallery_page, $_zp_current_zenpage_page, $_zp_current_zenpage_news;
    if (GALLERY_SECURITY != 'public') {
        // only registered users allowed
        $show = true;
    }
    //	therefore they will need to supply their user id is something fails below
    if ($_zp_gallery->isUnprotectedPage(stripSuffix($_zp_gallery_page))) {
        return true;
    }
    if (zp_loggedin()) {
        $fail = zp_apply_filter('isMyItemToView', NULL);
        if (!is_null($fail)) {
            //	filter had something to say about access, honor it
            return $fail;
        }
        switch ($_zp_gallery_page) {
            case 'album.php':
            case 'image.php':
                if ($_zp_current_album->isMyItem(LIST_RIGHTS)) {
                    return true;
                }
                break;
            case 'search.php':
                if (zp_loggedin(VIEW_SEARCH_RIGHTS)) {
                    return true;
                }
                break;
            default:
                if (zp_loggedin(VIEW_GALLERY_RIGHTS)) {
                    return true;
                }
                break;
        }
    }
    if (GALLERY_SECURITY == 'public' && ($access = checkForGuest($hint, $show))) {
        return $access;
        // public page or a guest is logged in
    }
    return false;
}
Example #25
0
/**
 * Worker function for creating layout selectors. Returns the HTML
 *
 * @param object $obj
 * @param string $type
 * @param string $text
 * @param string$secondary
 */
function getLayoutSelector($obj, $type, $text, $prefix = '', $secondary = false)
{
    global $_zp_gallery;
    $selectdefault = '';
    $selected = '';
    $files = array();
    $list = array();
    $getlayout = '';
    $table = $obj->table;
    $path = SERVERPATH . '/' . THEMEFOLDER . '/' . $_zp_gallery->getCurrentTheme() . '/';
    $defaultlayout = '';
    $defaulttext = gettext('default');
    switch ($table) {
        case 'albums':
            if ($secondary) {
                //	the selector for the image default of the album
                $filesmask = 'image';
            } else {
                $filesmask = 'album';
            }
            $child = $obj->getParentID();
            $defaulttext = gettext('inherited');
            break;
        case 'images':
            $filesmask = 'image';
            $album = $obj->album;
            $child = $album->getID();
            $defaulttext = gettext('album default');
            break;
        case 'pages':
            $filesmask = 'pages';
            $child = $obj->getParentID();
            $defaulttext = gettext('inherited');
            break;
        case 'news':
            $child = false;
            $categories = $obj->getCategories();
            if ($categories) {
                foreach ($categories as $cat) {
                    $cat = new ZenpageCategory($cat['titlelink']);
                    $getlayout = getSelectedLayout($cat, 'multiple_layouts_news_categories');
                    if ($getlayout && $getlayout['data']) {
                        //	in at least one news category with an alternate page
                        $defaulttext = gettext('inherited');
                        $defaultlayout = gettext('from category');
                        break;
                    }
                }
            }
            $filesmask = 'news';
            break;
        case 'news_categories':
            $child = $obj->getParentID();
            $defaulttext = gettext('inherited');
            $filesmask = 'news';
            break;
    }
    $curdir = getcwd();
    chdir($path);
    $files = safe_glob($filesmask . '*.php');
    chdir($curdir);
    if ($child) {
        $defaultlayout = checkParentLayouts($obj, $type);
        $defaultlayout = $defaultlayout['data'];
    }
    if ($defaultlayout) {
        $defaultlayout = stripSuffix($defaultlayout);
    } else {
        $defaultlayout = $filesmask;
    }
    if ($obj->transient) {
        $getlayout = false;
    } else {
        $getlayout = query_single_row("SELECT * FROM " . prefix('plugin_storage') . ' WHERE `aux` = ' . $obj->getID() . ' AND `type` = "' . $type . '"');
    }
    if (!$child && ($key = array_search($filesmask . '.php', $files)) !== false) {
        unset($files[$key]);
    }
    foreach ($files as $file) {
        $file = filesystemToInternal($file);
        $list[stripSuffix($file)] = $file;
    }
    ksort($list);
    $html = $text;
    if (count($files) != 0) {
        $html .= '<select id="' . $type . $prefix . '" name="' . $prefix . $type . '">' . "\n";
        if (is_array($getlayout)) {
            $selectedlayout = $getlayout['data'];
        } else {
            $selectedlayout = '';
        }
        $html .= '<option value=""' . ($selectedlayout == '' ? ' selected="selected"' : '') . ' style="background-color:LightGray" >*' . $defaulttext . '* (' . $defaultlayout . ')</option>' . "\n";
        foreach ($list as $display => $file) {
            $html .= '<option value="' . html_encode($file) . '"' . ($selectedlayout == $file ? ' selected="selected"' : '') . '>' . $display . '</option>' . "\n";
        }
        $html .= '</select>' . "\n";
    } else {
        $html = '<p class="no_extra">' . sprintf(gettext('No extra <em>%s</em> theme pages available'), $filesmask) . '</p>' . "\n";
    }
    return $html;
}
Example #26
0
/**
 * recovers search parameters from stored cookie, clears the cookie
 *
 * @param string $what the page type
 * @param string $album Name of the album
 * @param string $image Name of the image
 */
function handleSearchParms($what, $album = NULL, $image = NULL)
{
    global $_zp_current_search, $zp_request, $_zp_last_album, $_zp_current_album, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_gallery, $_zp_loggedin;
    $_zp_last_album = zp_getCookie('zenphoto_last_album');
    if (is_object($zp_request) && get_class($zp_request) == 'SearchEngine') {
        //	we are are on a search
        return $zp_request->getAlbumList();
    }
    $params = zp_getCookie('zenphoto_search_params');
    if (!empty($params)) {
        $context = get_context();
        $_zp_current_search = new SearchEngine();
        $_zp_current_search->setSearchParams($params);
        // check to see if we are still "in the search context"
        if (!is_null($image)) {
            $dynamic_album = $_zp_current_search->getDynamicAlbum();
            if ($_zp_current_search->getImageIndex($album->name, $image->filename) !== false) {
                if ($dynamic_album) {
                    $_zp_current_album = $dynamic_album;
                }
                $context = $context | ZP_SEARCH_LINKED | ZP_IMAGE_LINKED;
            }
        }
        if (!is_null($album)) {
            $albumname = $album->name;
            zp_setCookie('zenphoto_last_album', $albumname);
            if (hasDynamicAlbumSuffix($albumname) && !is_dir(ALBUM_FOLDER_SERVERPATH . $albumname)) {
                $albumname = stripSuffix($albumname);
                // strip off the suffix as it will not be reflected in the search path
            }
            //	see if the album is within the search context. NB for these purposes we need to look at all albums!
            $save_logon = $_zp_loggedin;
            $_zp_loggedin = $_zp_loggedin | VIEW_ALL_RIGHTS;
            $search_album_list = $_zp_current_search->getAlbums(0);
            $_zp_loggedin = $save_logon;
            foreach ($search_album_list as $searchalbum) {
                if (strpos($albumname, $searchalbum) !== false) {
                    $context = $context | ZP_SEARCH_LINKED | ZP_ALBUM_LINKED;
                    break;
                }
            }
        } else {
            zp_clearCookie('zenphoto_last_album');
        }
        if (!is_null($_zp_current_zenpage_page)) {
            $pages = $_zp_current_search->getPages();
            if (!empty($pages)) {
                $tltlelink = $_zp_current_zenpage_page->getTitlelink();
                foreach ($pages as $apage) {
                    if ($apage == $tltlelink) {
                        $context = $context | ZP_SEARCH_LINKED;
                        break;
                    }
                }
            }
        }
        if (!is_null($_zp_current_zenpage_news)) {
            $news = $_zp_current_search->getArticles(0, NULL, true);
            if (!empty($news)) {
                $tltlelink = $_zp_current_zenpage_news->getTitlelink();
                foreach ($news as $anews) {
                    if ($anews['titlelink'] == $tltlelink) {
                        $context = $context | ZP_SEARCH_LINKED;
                        break;
                    }
                }
            }
        }
        if ($context & ZP_SEARCH_LINKED) {
            set_context($context);
        } else {
            // not an object in the current search path
            $_zp_current_search = null;
            rem_context(ZP_SEARCH);
            if (!isset($_REQUEST['preserve_serch_params'])) {
                zp_clearCookie("zenphoto_search_params");
            }
        }
    }
}
Example #27
0
        if (strpos($key, 'gallery_page_unprotected_') === 0) {
            purgeOption($key);
        }
    }
}
//	cleanup options for missing elements
$sql = 'SELECT DISTINCT `creator` FROM ' . prefix('options') . ' WHERE `creator` IS NOT NULL';
$result = query_full_array($sql);
if (is_array($result)) {
    foreach ($result as $row) {
        $filename = $row['creator'];
        if (!file_exists(SERVERPATH . '/' . $filename)) {
            $sql = 'DELETE FROM ' . prefix('options') . ' WHERE `creator`=' . db_quote($filename);
            query($sql);
            if (strpos($filename, PLUGIN_FOLDER) !== false || strpos($filename, USER_PLUGIN_FOLDER) !== false) {
                purgeOption('zp_plugin_' . stripSuffix(basename($filename)));
            }
        }
    }
}
// missing themes
$sql = 'SELECT DISTINCT `theme` FROM ' . prefix('options') . ' WHERE `theme` IS NOT NULL';
$result = query_full_array($sql);
if (is_array($result)) {
    foreach ($result as $row) {
        $filename = THEMEFOLDER . '/' . $row['theme'];
        if ($filename && !file_exists(SERVERPATH . '/' . $filename)) {
            $sql = 'DELETE FROM ' . prefix('options') . ' WHERE `theme`=' . db_quote($row['theme']);
            query($sql);
        }
    }
Example #28
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;
}
Example #29
0
 function __construct($folder8, $cache = true, $quiet = false)
 {
     $folder8 = trim($folder8, '/');
     $folderFS = internalToFilesystem($folder8);
     $localpath = ALBUM_FOLDER_SERVERPATH . $folderFS . "/";
     $this->linkname = $this->name = $folder8;
     $this->localpath = $localpath;
     if (!$this->_albumCheck($folder8, $folderFS, $quiet)) {
         return;
     }
     $this->instantiate('albums', array('folder' => $this->name), 'folder', $cache, empty($folder8));
     $this->exists = true;
     if (!is_dir(stripSuffix($this->localpath))) {
         $this->linkname = stripSuffix($folder8);
     }
     $new = !$this->get('search_params');
     if ($new || filemtime($this->localpath) > $this->get('mtime')) {
         $constraints = '';
         $data = file_get_contents($this->localpath);
         while (!empty($data)) {
             $data1 = trim(substr($data, 0, $i = strpos($data, "\n")));
             if ($i === false) {
                 $data1 = $data;
                 $data = '';
             } else {
                 $data = substr($data, $i + 1);
             }
             if (strpos($data1, 'WORDS=') !== false) {
                 $words = "words=" . urlencode(substr($data1, 6));
             }
             if (strpos($data1, 'THUMB=') !== false) {
                 $thumb = trim(substr($data1, 6));
                 $this->set('thumb', $thumb);
             }
             if (strpos($data1, 'FIELDS=') !== false) {
                 $fields = "&searchfields=" . trim(substr($data1, 7));
             }
             if (strpos($data1, 'CONSTRAINTS=') !== false) {
                 $constraint = trim(substr($data1, 12));
                 $constraints = '&' . $constraint;
             }
         }
         if (!empty($words)) {
             if (empty($fields)) {
                 $fields = '&searchfields=tags';
             }
             $this->set('search_params', $words . $fields . $constraints);
         }
         $this->set('mtime', filemtime($this->localpath));
         if ($new) {
             $title = $this->get('title');
             $this->set('title', stripSuffix($title));
             // Strip the suffix
             $this->save();
             zp_apply_filter('new_album', $this);
         }
     }
     zp_apply_filter('album_instantiate', $this);
 }
Example #30
0
/**
 * control when and how setup scripts are turned back into PHP files
 * @param int reason
 * 						 1	No prior install signature
 * 						 2	restore setup files button
 * 						 4	Clone request
 * 						 5	Setup run with proper XSRF token
 * 						 6	checkSignature and no prior signature
 * 						11	No config file
 * 						12	No database specified
 * 						13	No DB connection
 * 						14	checkInstall Version has changed
 */
function restoreSetupScrpts($reason)
{
    //log setup file restore no matter what!
    require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/security-logger.php';
    switch ($reason) {
        default:
            $addl = sprintf(gettext('to run setup [%s]'), $reason);
            break;
        case 2:
            $addl = gettext('by Admin request');
            break;
        case 4:
            $addl = gettext('by cloning');
            break;
    }
    $allowed = defined('ADMIN_RIGHTS') && zp_loggedin(ADMIN_RIGHTS) && zpFunctions::hasPrimaryScripts();
    security_logger::log_setup($allowed, 'restore', $addl);
    if ($allowed) {
        if (!defined('FILE_MOD')) {
            define('FILE_MOD', 0666);
        }
        chdir(dirname(__FILE__) . '/setup/');
        $found = safe_glob('*.xxx');
        foreach ($found as $script) {
            chmod($script, 0777);
            if (@rename($script, stripSuffix($script) . '.php')) {
                chmod(stripSuffix($script) . '.php', FILE_MOD);
            } else {
                chmod($script, FILE_MOD);
            }
        }
    }
}