function archive($name) { $this->options = array('basedir' => ".", 'name' => internalToFilesystem($name), 'prepend' => "", 'inmemory' => 0, 'overwrite' => 0, 'recurse' => 1, 'storepaths' => 1, 'followlinks' => 0, 'level' => 3, 'method' => 1, 'sfx' => "", 'type' => "", 'comment' => ""); $this->files = array(); $this->exclude = array(); $this->storeonly = array(); $this->error = array(); }
function removeAlbum($alb) { $folder = $alb->name; $sql = 'DELETE FROM ' . prefix('plugin_storage') . ' WHERE `type`="favorites" AND `aux`=' . db_quote($this->getInstance()) . ' AND `data`=' . db_quote(serialize(array('type' => 'albums', 'id' => $folder))); query($sql); $this->_removeCache(internalToFilesystem($folder)); zp_apply_filter('favoritesHandler_action', 'remove', $alb, $this->name); }
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); }
function css_head($ignore) { global $themecolors, $zenCSS, $themeColor, $_zp_themeroot; if (!$themeColor) { $themeColor = getThemeOption('Theme_colors'); } if ($editorConfig = getOption('tinymce4_comments')) { if (strpos($themeColor, 'dark') !== false) { setOption('tinymce4_comments', 'dark_' . $editorConfig, false); } } $zenCSS = $_zp_themeroot . '/styles/' . $themeColor . '.css'; $unzenCSS = str_replace(WEBPATH, '', $zenCSS); if (!file_exists(SERVERPATH . internalToFilesystem($unzenCSS))) { $zenCSS = $_zp_themeroot . "/styles/light.css"; } return $ignore; }
function parseCSSDef($file) { $file = str_replace(WEBPATH, '', $file); $file = SERVERPATH . internalToFilesystem($file); if (is_readable($file) && ($fp = @fopen($file, "r"))) { while ($line = fgets($fp)) { if (!(false === strpos($line, "#main2 {"))) { $line = fgets($fp); $line = trim($line); $item = explode(":", $line); $rslt = trim(substr($item[1], 0, -1)); return $rslt; } } } return "#0b9577"; /* the default value */ }
function flowplayer_playlistJS() { $theme = getCurrentTheme(); $css = SERVERPATH . '/' . THEMEFOLDER . '/' . internalToFilesystem($theme) . '/flowplayer3_playlist.css'; if (file_exists($css)) { $css = WEBPATH . '/' . THEMEFOLDER . '/' . $theme . '/flowplayer3_playlist.css'; } else { $css = WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/flowplayer3/flowplayer3_playlist.css'; } ?> <script type="text/javascript" src="<?php echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /flowplayer3/jquery.tools.min.js"></script> <link rel="stylesheet" type="text/css" href="<?php echo pathurlencode($css); ?> " /> <?php }
static function themeJS() { $theme = getCurrentTheme(); $css = SERVERPATH . '/' . THEMEFOLDER . '/' . internalToFilesystem($theme) . '/jquery.bxslider.css'; if (file_exists($css)) { $css = WEBPATH . '/' . THEMEFOLDER . '/' . $theme . '/jquery.bxslider.css'; } else { $css = WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/bxslider_thumb_nav/jquery.bxslider.css'; } ?> <script type="text/javascript" src="<?php echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /bxslider_thumb_nav/jquery.bxslider.min.js"></script> <link rel="stylesheet" type="text/css" href="<?php echo html_encode($css); ?> " /> <?php }
static function themeJS() { $theme = getCurrentTheme(); $css = SERVERPATH . '/' . THEMEFOLDER . '/' . internalToFilesystem($theme) . '/jcarousel.css'; if (file_exists($css)) { $css = WEBPATH . '/' . THEMEFOLDER . '/' . $theme . '/jcarousel.css'; } else { $css = WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/jcarousel_thumb_nav/jcarousel.css'; } ?> <script> (function($) { var userAgent = navigator.userAgent.toLowerCase(); $.browser = { version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [0, '0'])[1], safari: /webkit/.test(userAgent), opera: /opera/.test(userAgent), msie: /msie/.test(userAgent) && !/opera/.test(userAgent), mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent) }; })(jQuery); </script> <script type="text/javascript" src="<?php echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /jcarousel_thumb_nav/jquery.jcarousel.pack.js"></script> <link rel="stylesheet" type="text/css" href="<?php echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /jcarousel_thumb_nav/jquery.jcarousel.css" /> <link rel="stylesheet" type="text/css" href="<?php echo html_encode($css); ?> " /> <?php }
/** * 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 . pathurlencode($albumobj->getLink()); $thumb = $albumobj->getAlbumThumbImage(); $title = $albumobj->getTitle($this->locale); $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'] = $albumobj->getDesc($this->locale); $feeditem['title'] = $imagenumber; $feeditem['pubdate'] = date("r", strtotime($albumobj->getDateTime())); } else { if (isAlbumClass($item)) { $albumobj = $item; $thumb = $albumobj->getAlbumThumbImage(); } else { $albumobj = $item->getAlbum(); $thumb = $item; } $itemlink = $this->host . $item->getLink(); $title = $item->getTitle($this->locale); $feeditem['desc'] = $item->getDesc($this->locale); $feeditem['title'] = sprintf('%1$s (%2$s)', $item->getTitle($this->locale), $albumobj->getTitle($this->locale)); $feeditem['pubdate'] = date("r", strtotime($item->getDateTime())); } //link $feeditem['link'] = $itemlink; //category $feeditem['category'] = html_encode($albumobj->getTitle($this->locale)); //media content $feeditem['media_content'] = '<image url="' . PROTOCOL . '://' . html_encode($thumb->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE)) . '" />'; $feeditem['media_thumbnail'] = '<thumbnail url="' . PROTOCOL . '://' . html_encode($thumb->getThumb()) . '" />'; return $feeditem; }
/** * 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; }
$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 { if (is_zip($name)) {
header('Content-Type: text/html; charset=' . LOCAL_CHARSET); header("HTTP/1.0 200 OK"); header("Status: 200 OK"); header('Last-Modified: ' . $_zp_last_modified); zp_apply_filter('theme_headers'); include internalToFilesystem($_zp_obj); } else { // If the requested object does not exist, issue a 404 and redirect to the theme's // 404.php page, or a 404.php in the zp-core folder. if (is_object($_zp_HTML_cache)) { $_zp_HTML_cache->abortHTMLCache(); } list($album, $image) = rewrite_get_album_image('album', 'image'); debug404($album, $image, $theme); $_zp_gallery_page = '404.php'; $errpage = THEMEFOLDER . '/' . internalToFilesystem($theme) . '/404.php'; header('Content-Type: text/html; charset=' . LOCAL_CHARSET); header("HTTP/1.0 404 Not Found"); header("Status: 404 Not Found"); zp_apply_filter('theme_headers'); if (file_exists(SERVERPATH . "/" . $errpage)) { if ($custom) { require_once $custom; } include $errpage; } else { include ZENFOLDER . '/404.php'; } } //$_zp_script_timer['theme script load'] = microtime(); exposeZenPhotoInformations($_zp_obj, $_zp_loaded_plugins, $theme);
/** * Creates a zip file of the album * * @param string $albumname album folder * @param bool fromcache if true, images will be the "sized" image in the cache file */ static function create($albumname, $fromcache) { global $_zp_zip_list, $_zp_gallery, $defaultSize; $album = newAlbum($albumname); if (!$album->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumname)) { self::pageError(403, gettext("Forbidden")); } if (!$album->exists) { self::pageError(404, gettext('Album not found')); } $_zp_zip_list = array(); if ($fromcache) { $opt = array('large_file_size' => 5 * 1024 * 1024, 'comment' => sprintf(gettext('Created from cached images of %1$s on %2$s.'), $album->name, zpFormattedDate(DATE_FORMAT, time()))); loadLocalOptions(false, $_zp_gallery->getCurrentTheme()); $defaultSize = getOption('image_size'); self::AddAlbumCache($album, strlen($albumname), SERVERPATH . '/' . CACHEFOLDER . '/' . $albumname); } else { $opt = array('large_file_size' => 5 * 1024 * 1024, 'comment' => sprintf(gettext('Created from images in %1$s on %2$s.'), $album->name, zpFormattedDate(DATE_FORMAT, time()))); self::AddAlbum($album, strlen($albumname), SERVERPATH . '/' . ALBUMFOLDER . '/' . $albumname); } $zip = new ZipStream($albumname . '.zip', $opt); foreach ($_zp_zip_list as $path => $file) { @set_time_limit(6000); $zip->add_file_from_path(internalToFilesystem($file), internalToFilesystem($path)); } $zip->finish(); }
} $theme = setupTheme($albumobj); $custom = $_zp_themeroot . '/functions.php'; if (file_exists($custom)) { require_once $custom; } $_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':
/** * Returns the image file name for the thumbnail image. * * @param string $path override path * * @return s */ function getThumbImageFile($path = NULL) { global $_zp_gallery; if (is_null($path)) { $path = SERVERPATH; } if (is_null($this->objectsThumb)) { switch (getSuffix($this->filename)) { case "pdf": $img = '/pdfDefault.png'; break; case 'ppt': case 'pps': $img = '/ppsDefault.png'; break; case 'tif': case 'tiff': $img = '/tifDefault.png'; break; } $imgfile = $path . '/' . THEMEFOLDER . '/' . internalToFilesystem($_zp_gallery->getCurrentTheme()) . '/images/' . $img; if (!file_exists($imgfile)) { $imgfile = $path . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . '/' . substr(basename(__FILE__), 0, -4) . '/' . $img; } } else { $imgfile = ALBUM_FOLDER_SERVERPATH . internalToFilesystem($this->imagefolder) . '/' . $this->objectsThumb; } return $imgfile; }
static function header_js() { $theme = getCurrentTheme(); $css = SERVERPATH . '/' . THEMEFOLDER . '/' . internalToFilesystem($theme) . '/slideshow.css'; if (file_exists($css)) { $css = WEBPATH . '/' . THEMEFOLDER . '/' . $theme . '/slideshow.css'; } else { $css = WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/slideshow/slideshow.css'; } ?> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow/jquery.cycle.all.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="<?php echo $css; ?> " /> <?php }
/** * Copy a theme directory to create a new custom theme * * @param $source source directory * @param $target target directory * @return bool|string either true or an error message * @author Ozh * @since 1.3 */ function copyThemeDirectory($source, $target, $newname) { global $_zp_current_admin_obj; $message = true; $source = SERVERPATH . '/themes/' . internalToFilesystem($source); $target = SERVERPATH . '/themes/' . internalToFilesystem($target); // If the target theme already exists, nothing to do. if (is_dir($target)) { return gettext('Cannot create new theme.') . ' ' . sprintf(gettext('Directory “%s” already exists!'), basename($target)); } // If source dir is missing, exit too if (!is_dir($source)) { return gettext('Cannot create new theme.') . ' ' . sprintf(gettext('Cannot find theme directory “%s” to copy!'), basename($source)); } // We must be able to write to the themes dir. if (!is_writable(dirname($target))) { return gettext('Cannot create new theme.') . ' ' . gettext('The <tt>/themes</tt> directory is not writable!'); } // We must be able to create the directory if (!mkdir($target, FOLDER_MOD)) { return gettext('Cannot create new theme.') . ' ' . gettext('Could not create directory for the new theme'); } @chmod($target, FOLDER_MOD); // Get a list of files to copy: get all files from the directory, remove those containing '/.svn/' $source_files = array_filter(listDirectoryFiles($source), create_function('$str', 'return strpos($str, "/.svn/") === false;')); // Determine nested (sub)directories structure to create: go through each file, explode path on "/" // and collect every unique directory $dirs_to_create = array(); foreach ($source_files as $path) { $path = explode('/', dirname(str_replace($source . '/', '', $path))); $dirs = ''; foreach ($path as $subdir) { if ($subdir == '.svn' or $subdir == '.') { continue 2; } $dirs = "{$dirs}/{$subdir}"; $dirs_to_create[$dirs] = $dirs; } } // Create new directory structure foreach ($dirs_to_create as $dir) { mkdir("{$target}/{$dir}", FOLDER_MOD); @chmod("{$target}/{$dir}", FOLDER_MOD); } // Now copy every file foreach ($source_files as $file) { $newfile = str_replace($source, $target, $file); if (!copy("{$file}", "{$newfile}")) { return sprintf(gettext("An error occurred while copying files. Please delete manually the new theme directory “%s” and retry or copy files manually."), basename($target)); } @chmod("{$newfile}", FOLDER_MOD); } // Rewrite the theme header. if (file_exists($target . '/theme_description.php')) { $theme_description = array(); require $target . '/theme_description.php'; $theme_description['desc'] = sprintf(gettext('Your theme, based on theme %s'), $theme_description['name']); } else { $theme_description['desc'] = gettext('Your theme'); } $theme_description['name'] = $newname; $theme_description['author'] = $_zp_current_admin_obj->getUser(); $theme_description['version'] = '1.0'; $theme_description['date'] = date('Y-m-d H:m:s', time()); $description = sprintf('<' . '?php // Theme definition file $theme_description["name"] = "%s"; $theme_description["author"] = "%s"; $theme_description["version"] = "%s"; $theme_description["date"] = "%s"; $theme_description["desc"] = "%s"; ?' . '>', html_encode($theme_description['name']), html_encode($theme_description['author']), html_encode($theme_description['version']), html_encode($theme_description['date']), html_encode($theme_description['desc'])); $f = fopen($target . '/theme_description.php', 'w'); if ($f !== FALSE) { @fwrite($f, $description); fclose($f); $message = gettext('New custom theme created successfully!'); } else { $message = gettext('New custom theme created, but its description could not be updated'); } // Make a slightly custom theme image if (file_exists("{$target}/theme.png")) { $themeimage = "{$target}/theme.png"; } else { if (file_exists("{$target}/theme.gif")) { $themeimage = "{$target}/theme.gif"; } else { if (file_exists("{$target}/theme.jpg")) { $themeimage = "{$target}/theme.jpg"; } else { $themeimage = false; } } } if ($themeimage) { if ($im = zp_imageGet($themeimage)) { $x = zp_imageWidth($im) / 2 - 45; $y = zp_imageHeight($im) / 2 - 10; $text = "CUSTOM COPY"; $font = zp_imageLoadFont(); $ink = zp_colorAllocate($im, 0xff, 0xff, 0xff); // create a blueish overlay $overlay = zp_createImage(zp_imageWidth($im), zp_imageHeight($im)); $back = zp_colorAllocate($overlay, 0x60, 0x60, 0x90); zp_imageFill($overlay, 0, 0, $back); // Merge theme image and overlay zp_imageMerge($im, $overlay, 0, 0, 0, 0, zp_imageWidth($im), zp_imageHeight($im), 45); // Add text zp_writeString($im, $font, $x - 1, $y - 1, $text, $ink); zp_writeString($im, $font, $x + 1, $y + 1, $text, $ink); zp_writeString($im, $font, $x, $y, $text, $ink); // Save new theme image zp_imageOutput($im, 'png', $themeimage); } } return $message; }
} } else { // no test file $msg1 = sprintf(gettext('The Zenphoto filesystem character define is %1$s [no test performed]'), $charset_defined); $msg2 = '<p>' . sprintf(gettext('Setup did not perform a test of the filesystem character set. You can cause setup to test for a proper definition by creating a file in your <code>%1$s</code> folder named <strong><code>%2$s</code></strong> and re-running setup.'), DATA_FOLDER, 'charset_tést') . '</p>' . $msg2; if (isset($_zp_conf_vars['FILESYSTEM_CHARSET'])) { // but we have a define value $notice = -3; } else { // no defined value, who knows.... $notice = -1; } } checkMark($notice, $msg, $msg1, sprintf($msg2, charsetSelector(FILESYSTEM_CHARSET))); // UTF-8 URI if ($notice != -1 && @copy(SERVERPATH . '/' . ZENFOLDER . '/images/pass.png', $serverpath . '/' . DATA_FOLDER . '/' . internalToFilesystem('tést.jpg'))) { $test_image = WEBPATH . '/' . DATA_FOLDER . '/' . urlencode('tést.jpg'); $req_iso = gettext('Image URIs appear require the <em>filesystem</em> character set.'); $req_UTF8 = gettext('Image URIs appear to require the UTF-8 character set.'); ?> <script type="text/javascript"> // <!-- <![CDATA[ function uri(enable) { var text; if (enable) { text = 'true'; } else { text = 'false'; } $('#setUTF8URI').val(enable); $('#UTF8_uri_warn').hide();
/** * Returns an array of image names found in the search * * @param string $sorttype what to sort on * @param string $sortdirection what direction * @param bool $mine set true/false to overried ownership * @return array */ function getSearchImages($sorttype, $sortdirection, $mine = NULL) { if (getOption('search_no_images') || $this->search_no_images) { return array(); } $hint = ''; $images = array(); $searchstring = $this->getSearchString(); $searchdate = $this->dates; if (empty($searchstring) && empty($searchdate)) { return $images; } // nothing to find if (empty($searchdate)) { $search_results = $this->searchFieldsAndTags($searchstring, 'images', $sorttype, $sortdirection); } else { $search_results = $this->SearchDate($searchstring, $searchdate, 'images', $sorttype, $sortdirection); } if (isset($search_results) && is_array($search_results)) { foreach ($search_results as $row) { $albumid = $row['albumid']; $query = "SELECT id, title, folder,`show` FROM " . prefix('albums') . " WHERE id = {$albumid}"; $row2 = query_single_row($query); // id is unique $albumname = $row2['folder']; if (file_exists(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($albumname) . '/' . internalToFilesystem($row['filename']))) { $album = new Album(new gallery(), $albumname); if ($mine || is_null($mine) && ($album->isMyItem(LIST_RIGHTS) || checkAlbumPassword($albumname) && $row2['show'])) { if (empty($this->album_list) || in_array($albumname, $this->album_list)) { $images[] = array('filename' => $row['filename'], 'folder' => $albumname); } } } } } if (empty($searchdate)) { zp_apply_filter('search_statistics', $searchstring, 'images', !empty($images), $this->dynalbumname, $this->iteration++); } return $images; }
static function cycleJS() { ?> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/jquery.cycle2.min.js" type="text/javascript"></script> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/jquery.cycle2.center.min.js" type="text/javascript"></script> <!-- effect plugins --> <?php if (getOption('cycle-slideshow_effect') == 'flipHorz' || getOption('cycle-slideshow_effect') == 'flipVert') { ?> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/jquery.cycle2.flip.min.js" type="text/javascript"></script> <?php } ?> <!--[if lt IE 9]> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/jquery.cycle2.ie-fade.min.js" type="text/javascript"></script> <![endif]--> <?php if (getOption('cycle-slideshow_effect') == 'shuffle') { ?> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/jquery.cycle2.shuffle.min.js" type="text/javascript"></script> <?php } ?> <?php if (getOption('cycle-slideshow_effect') == 'tileSlide' || getOption('cycle-slideshow_effect') == 'tileBlind') { ?> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/jquery.cycle2.tile.min.js" type="text/javascript"></script> <?php } ?> <?php if (getOption('cycle-slideshow_effect') == 'scrollVert') { ?> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/jquery.cycle2.scrollVert.min.js" type="text/javascript"></script> <?php } ?> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/jquery.cycle2.carousel.min.js" type="text/javascript"></script> <!-- swipe with iOS fix --> <?php if (getOption('cycle-slideshow_swipe')) { ?> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/jquery.cycle2.swipe.min.js" type="text/javascript"></script> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/ios6fix.js" type="text/javascript"></script> <?php } $theme = getCurrentTheme(); $css = SERVERPATH . '/' . THEMEFOLDER . '/' . internalToFilesystem($theme) . '/slideshow2.css'; if (file_exists($css)) { $css = WEBPATH . '/' . THEMEFOLDER . '/' . $theme . '/slideshow2.css'; } else { $css = WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/slideshow2/slideshow2.css'; } ?> <link rel="stylesheet" type="text/css" href="<?php echo $css; ?> " /> <!--[if lte IE 7]> <link rel="stylesheet" type="text/css" href="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/fonts/ie7.css" /> <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?> /slideshow2/fonts/ie7.js" type="text/javascript"></script> <![endif]--> <?php }
XSRFdefender('cloneZenphoto'); $msg = array(); $folder = sanitize($_GET['clonePath']); $path = str_replace(WEBPATH, '/', SERVERPATH); $newinstall = trim(str_replace($path, '', $folder), '/') . '/'; if (trim($folder, '/') == SERVERPATH) { $msg[] = gettext('You attempted to clone to the master install.'); $success = false; } else { $success = true; $targets = array(ZENFOLDER => 'dir', USER_PLUGIN_FOLDER => 'dir', 'index.php' => 'file'); $zplist = $_zp_gallery->getThemes(); foreach ($zplist as $theme => $data) { $targets[THEMEFOLDER . '/' . $theme] = 'dir'; } foreach (array(internalToFilesystem('charset_tést'), internalToFilesystem('charset.tést')) as $charset) { if (file_exists(SERVERPATH . '/' . DATA_FOLDER . '/' . $charset)) { $targets[DATA_FOLDER . '/' . $charset] = 'file'; } } if (!is_dir($folder . DATA_FOLDER)) { @mkdir($folder . DATA_FOLDER); } if (!is_dir($folder . THEMEFOLDER)) { @mkdir($folder . THEMEFOLDER); } foreach ($targets as $target => $type) { if (file_exists($folder . $target)) { $link = str_replace('\\', '/', @readlink($folder . $target)); switch ($type) { case 'dir':
$themefiles_to_ext = array(); if (themeIsEditable($theme)) { foreach ($themefiles as $file) { if (isTextFile($file)) { $themefiles_to_ext[getSuffix($file)][] = $file; // array(['php']=>array('file.php', 'image.php'),['css']=>array('style.css')) } else { unset($themefiles[$file]); // $themefile will eventually have all editable files and nothing else } } if (isset($_GET['file'])) { if (!in_array($themedir . '/' . $_GET['file'], $themefiles)) { $messages['errorbox'][] = gettext('Cannot edit this file!'); } $file_to_edit = str_replace('\\', '/', SERVERPATH . '/themes/' . internalToFilesystem($theme) . '/' . sanitize($_GET['file'])); } // Handle POST that updates a file if (isset($_POST['action']) && $_POST['action'] == 'edit_file' && $file_to_edit && !isset($messages['errorbox'])) { XSRFdefender('edit_theme'); $file_content = sanitize($_POST['newcontent'], 0); $theme = urlencode($theme); if (is_writeable($file_to_edit)) { //is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable $f = @fopen($file_to_edit, 'w+'); if ($f !== FALSE) { @fwrite($f, $file_content); fclose($f); clearstatcache(); $messages['messagebox fade-message'][] = array(gettext('File updated successfully'), 'notebox'); } else {
/** * Ends the static caching. * */ protected function endCache() { $caching = getOption($this->feed . "_cache") && !zp_loggedin(); if ($caching) { $cachefilepath = internalToFilesystem($this->getCacheFilename()); if (!empty($cachefilepath)) { $cachefilepath = SERVERPATH . '/' . STATIC_CACHE_FOLDER . '/' . strtolower($this->feed) . '/' . $cachefilepath; mkdir_recursive(SERVERPATH . '/' . STATIC_CACHE_FOLDER . '/' . strtolower($this->feed) . '/', FOLDER_MOD); $pagecontent = ob_get_contents(); ob_end_clean(); if ($fh = @fopen($cachefilepath, "w")) { fputs($fh, $pagecontent); fclose($fh); clearstatcache(); } echo $pagecontent; } } }
/** * Returns the fully qualified file name of the plugin file. * * Note: order of selection is: * 1-theme folder file (if $inTheme is set) * 2-user plugin folder file * 3-zp-extensions file * first file found is used * * @param string $plugin is the name of the plugin file, typically something.php * @param bool $inTheme tells where to find the plugin. * true means look in the current theme * false means look in the zp-core/plugins folder. * @param bool $webpath return a WEBPATH rather than a SERVERPATH * * @return string */ function getPlugin($plugin, $inTheme = false, $webpath = false) { global $_zp_gallery; $pluginFile = NULL; if ($inTheme === true) { $inTheme = $_zp_gallery->getCurrentTheme(); } if ($inTheme) { $pluginFile = '/' . THEMEFOLDER . '/' . internalToFilesystem($inTheme . '/' . $plugin); if (!file_exists(SERVERPATH . $pluginFile)) { $pluginFile = false; } } if (!$pluginFile) { $pluginFile = '/' . USER_PLUGIN_FOLDER . '/' . internalToFilesystem($plugin); if (!file_exists(SERVERPATH . $pluginFile)) { $pluginFile = '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/' . internalToFilesystem($plugin); if (!file_exists(SERVERPATH . $pluginFile)) { $pluginFile = false; } } } if ($pluginFile) { if ($webpath) { if (is_string($webpath)) { return $webpath . filesystemToInternal($pluginFile); } else { return WEBPATH . filesystemToInternal($pluginFile); } } else { return SERVERPATH . $pluginFile; } } return false; }
header("HTTP/1.0 302 Found"); header("Status: 302 Found"); header('Location: ' . $uri); exitZP(); } } if (isset($_GET['fromlogout'])) { header("HTTP/1.0 302 Found"); header("Status: 302 Found"); header('Location: ' . WEBPATH . '/index.php'); exitZP(); } $obj = @$_zp_gallery_page; $_zp_gallery_page = '404.php'; if (isset($_index_theme)) { $_zp_script = SERVERPATH . "/" . THEMEFOLDER . '/' . internalToFilesystem($_index_theme) . '/404.php'; } else { $_zp_script = NULL; } header('Content-Type: text/html; charset=' . LOCAL_CHARSET); header("HTTP/1.0 404 Not Found"); header("Status: 404 Not Found"); zp_apply_filter('theme_headers'); debug404($album, $image, @$_index_theme); if ($_zp_script && file_exists($_zp_script)) { if (isset($custom) && $custom) { require_once $custom; } include $_zp_script; } else { ?>
/** * Returns the path to a watermark * * @param string $wm watermark name * @return string */ function getWatermarkPath($wm) { $path = SERVERPATH . '/' . ZENFOLDER . '/watermarks/' . internalToFilesystem($wm) . '.png'; if (!file_exists($path)) { $path = SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/watermarks/' . internalToFilesystem($wm) . '.png'; } return $path; }
/** * Gets the select layout page and returns it to the load_theme_script filter * * @param string $path Path of the layout file * @return string * @return string */ function getLayout($path) { global $_zp_gallery, $_zp_gallery_page, $_zp_current_image, $_zp_current_album, $_zp_current_zenpage_page, $_zp_current_zenpage_news, $_zp_current_category, $_zp_current_search; if ($path) { $themepath = THEMEFOLDER . '/' . $_zp_gallery->getCurrentTheme() . '/'; $getlayout = false; switch ($_zp_gallery_page) { case 'album.php': if (getOption('multiple_layouts_albums')) { $getlayout = getSelectedLayout($_zp_current_album, 'multiple_layouts_albums'); } break; case 'image.php': if (getOption('multiple_layouts_images')) { $currentalbumname = $_zp_current_album->name; if (in_context(ZP_SEARCH_LINKED) && !in_context(ZP_ALBUM_LINKED)) { if (!($album = $_zp_current_search->getDynamicAlbum())) { $album = $_zp_current_album; } } else { $getlayout = getSelectedLayout($_zp_current_image, 'multiple_layouts_images'); $album = $_zp_current_album; } if ($album && !$getlayout) { $getlayout = checkLayoutUseForImages($album); } } break; case 'pages.php': if (getOption('multiple_layouts_pages')) { $getlayout = getSelectedLayout($_zp_current_zenpage_page, 'multiple_layouts_pages'); } break; case 'news.php': if (getOption('multiple_layouts_news_categories') && in_context(ZP_ZENPAGE_NEWS_CATEGORY)) { $getlayout = getSelectedLayout($_zp_current_category, 'multiple_layouts_news_categories'); } elseif (getOption('multiple_layouts_news') && in_context(ZP_ZENPAGE_SINGLE)) { $getlayout = getSelectedLayout($_zp_current_zenpage_news, 'multiple_layouts_news'); } break; } if ($getlayout && $getlayout['data'] && file_exists(internalToFilesystem(SERVERPATH . '/' . $themepath . $getlayout['data']))) { return $themepath . $getlayout['data']; } } return $path; }
header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin-edit.php?page=edit" . $albumdir . "&ndeleted=" . $nd); exitZP(); break; case 'newalbum': XSRFdefender('newalbum'); $name = sanitize($_GET['name']); $folder = sanitize($_GET['folder']); $seoname = seoFriendly($name); if (empty($folder) || $folder == '/' || $folder == '.') { $albumdir = ''; $folder = $seoname; } else { $albumdir = "&album=" . pathurlencode($folder); $folder = $folder . '/' . $seoname; } $uploaddir = $_zp_gallery->albumdir . internalToFilesystem($folder); if (is_dir($uploaddir)) { if ($name != $seoname) { $name .= ' (' . $seoname . ')'; } if (isset($_GET['albumtab'])) { if (empty($albumdir)) { $tab = ''; } else { $tab = '&tab=subalbuminfo'; } } else { $tab = '&tab=albuminfo'; } header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin-edit.php?page=edit{$albumdir}&exists=" . urlencode($name) . $tab); exitZP();
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); }
/** * Returns an img src link to the password protect thumb substitute * * @param string $extra extra stuff to put in the HTML * @return string */ function getPasswordProtectImage($extra) { global $_zp_themeroot; $image = ''; $themedir = SERVERPATH . '/themes/' . basename($_zp_themeroot); if (file_exists(internalToFilesystem($themedir . '/images/err-passwordprotected.png'))) { $image = $_zp_themeroot . '/images/err-passwordprotected.png'; } else { if (file_exists(internalToFilesystem($themedir . '/images/err-passwordprotected.gif'))) { $image = $_zp_themeroot . '/images/err-passwordprotected.gif'; } else { $image = WEBPATH . '/' . ZENFOLDER . '/images/err-passwordprotected.png'; } } return '<img src="' . $image . '" ' . $extra . ' alt="protected" />'; }