function getOptionsSupported() { global $_zp_gallery; $themename = $_zp_gallery->getCurrentTheme(); $curdir = getcwd(); $root = SERVERPATH . '/' . THEMEFOLDER . '/' . $themename . '/'; chdir($root); $filelist = safe_glob('*.php'); $list = array(); foreach ($filelist as $file) { $file = filesystemToInternal($file); $list[$file] = str_replace('.php', '', $file); } $list = array_diff($list, standardScripts()); $all = query_full_array('SELECT `aux` FROM ' . prefix('plugin_storage') . ' WHERE `type`="favorites"'); $disable = false; $text = gettext('If enabled a user may have multiple (named) favorites.'); foreach ($all as $aux) { $instance = getSerializedArray($aux['aux']); if (isset($instance[1])) { $disable = true; $text .= '<br /><span class="warningbox">' . gettext('Named favorites are present.') . '</span>'; break; } } $options = array(gettext('Link text') => array('key' => 'favorites_linktext', 'type' => OPTION_TYPE_TEXTBOX, 'multilingual' => true, 'order' => 2, 'desc' => gettext('The text for the link to the favorites page.')), gettext('Multiple sets') => array('key' => 'favorites_multi', 'type' => OPTION_TYPE_CHECKBOX, 'order' => 6, 'disabled' => $disable, 'desc' => $text), gettext('Add button') => array('key' => 'favorites_add_button', 'type' => OPTION_TYPE_TEXTBOX, 'multilingual' => true, 'order' => 6, 'desc' => gettext('Default text for the <em>add to favorites</em> button.')), gettext('Remove button') => array('key' => 'favorites_remove_button', 'type' => OPTION_TYPE_TEXTBOX, 'multilingual' => true, 'order' => 7, 'desc' => gettext('Default text for the <em>remove from favorites</em> button.')), gettext('Title') => array('key' => 'favorites_title', 'type' => OPTION_TYPE_TEXTBOX, 'multilingual' => true, 'order' => 3, 'desc' => gettext('The favorites page title text.')), gettext('Description') => array('key' => 'favorites_desc', 'type' => OPTION_TYPE_TEXTAREA, 'multilingual' => true, 'order' => 5, 'desc' => gettext('The favorites page description text.')), gettext('Sort albums by') => array('key' => 'favorites_albumsort', 'type' => OPTION_TYPE_CUSTOM, 'order' => 9, 'desc' => ''), gettext('Sort images by') => array('key' => 'favorites_imagesort', 'type' => OPTION_TYPE_CUSTOM, 'order' => 10, 'desc' => '')); if (!MOD_REWRITE) { $options['note'] = array('key' => 'favorites_note', 'type' => OPTION_TYPE_NOTE, 'order' => 0, 'desc' => gettext('<p class="notebox">Favorites requires the <code>mod_rewrite</code> option be enabled.</p>')); } return $options; }
/** * Adds a new download item to the database. For internal use. * @param string $path Path of the download item */ function adddownloadListItem($path) { $path = filesystemToInternal($path); $checkitem = query_single_row("SELECT `data` FROM " . prefix('plugin_storage') . " WHERE `aux` = " . db_quote($path) . " AND `type` = 'downloadList'"); if (!$checkitem) { query("INSERT INTO " . prefix('plugin_storage') . " (`type`,`aux`,`data`) VALUES ('downloadList'," . db_quote($path) . ",'0')"); } }
function loadAlbumNames($albumdir) { if (!is_dir($albumdir) || !is_readable($albumdir)) { return array(); } $dir = opendir($albumdir); $albums = array(); while ($dirname = readdir($dir)) { $dirname = filesystemToInternal($dirname); if (is_dir($albumdir . $dirname) && $dirname[0] != '.') { $albums = array_merge(array($dirname), $this->loadAlbumNames($albumdir . $dirname . '/')); } } closedir($dir); return $albums; }
/** * * enumerates the files in folder(s) * @param $folder */ function getResidentFiles($folder, $exclude) { global $_zp_resident_files; $dirs = array_diff(scandir($folder), $exclude); $localfiles = array(); $localfolders = array(); foreach ($dirs as $file) { $file = str_replace('\\', '/', $file); $key = str_replace(SERVERPATH . '/', '', filesystemToInternal($folder . '/' . $file)); if (is_dir($folder . '/' . $file)) { $localfolders[] = $key; $localfolders = array_merge($localfolders, getResidentFiles($folder . '/' . $file, $exclude)); } else { $localfiles[] = $key; } } return array_merge($localfiles, $localfolders); }
function getOptionsSupported() { global $_zp_gallery; $themename = $_zp_gallery->getCurrentTheme(); $curdir = getcwd(); $root = SERVERPATH . '/' . THEMEFOLDER . '/' . $themename . '/'; chdir($root); $filelist = safe_glob('*.php'); $list = array(); foreach ($filelist as $file) { $file = filesystemToInternal($file); $list[$file] = str_replace('.php', '', $file); } $list = array_diff($list, standardScripts()); $options = array(gettext('Link text') => array('key' => 'favorites_linktext', 'type' => OPTION_TYPE_TEXTBOX, 'multilingual' => true, 'order' => 2, 'desc' => gettext('The text for the link to the favorites page.')), gettext('Multiple sets') => array('key' => 'favorites_multi', 'type' => OPTION_TYPE_CHECKBOX, 'order' => 6, 'desc' => gettext('If enabled a user may have multiple (named) favorites.')), gettext('Add button') => array('key' => 'favorites_add_button', 'type' => OPTION_TYPE_TEXTBOX, 'multilingual' => true, 'order' => 6, 'desc' => gettext('Default text for the <em>add to favorites</em> button.')), gettext('Remove button') => array('key' => 'favorites_remove_button', 'type' => OPTION_TYPE_TEXTBOX, 'multilingual' => true, 'order' => 7, 'desc' => gettext('Default text for the <em>remove from favorites</em> button.')), gettext('Title') => array('key' => 'favorites_title', 'type' => OPTION_TYPE_TEXTBOX, 'multilingual' => true, 'order' => 3, 'desc' => gettext('The favorites page title text.')), gettext('Description') => array('key' => 'favorites_desc', 'type' => OPTION_TYPE_TEXTAREA, 'multilingual' => true, 'order' => 5, 'desc' => gettext('The favorites page description text.')), gettext('Sort albums by') => array('key' => 'favorites_albumsort', 'type' => OPTION_TYPE_CUSTOM, 'order' => 9, 'desc' => ''), gettext('Sort images by') => array('key' => 'favorites_imagesort', 'type' => OPTION_TYPE_CUSTOM, 'order' => 10, 'desc' => '')); if (!MOD_REWRITE) { $options['note'] = array('key' => 'favorites_note', 'type' => OPTION_TYPE_NOTE, 'order' => 0, 'desc' => gettext('<p class="notebox">Favorites requires the <code>mod_rewrite</code> option be enabled.</p>')); } return $options; }
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; }
function getFolderList($root) { $curdir = getcwd(); chdir($root); $filelist = safe_glob('*'); $list = array(); foreach ($filelist as $file) { if (is_dir($file) && $file != '.' && $file != '..') { $internal = filesystemToInternal($file); if (!file_exists("{$root}/{$file}/persona.properties")) { continue; } $props = new Properties(); $props->load(file_get_contents("{$root}/{$file}/persona.properties")); $name = $props->getProperty('name'); if (!isset($name)) { continue; } $list[$name] = $internal; } } chdir($curdir); return $list; }
/** * Returns a list of available fonts * * @return array */ function zp_getFonts() { global $_imagick_fontlist; if (!is_array($_imagick_fontlist)) { @($_imagick_fontlist = Imagick::queryFonts()); $_imagick_fontlist = array('system' => '') + array_combine($_imagick_fontlist, $_imagick_fontlist); $basefile = SERVERPATH . '/' . USER_PLUGIN_FOLDER . '/imagick_fonts/'; if (is_dir($basefile)) { chdir($basefile); $filelist = safe_glob('*.ttf'); foreach ($filelist as $file) { $key = filesystemToInternal(str_replace('.ttf', '', $file)); $_imagick_fontlist[$key] = getcwd() . '/' . $file; } } chdir(dirname(__FILE__)); } return $_imagick_fontlist; }
/** * Load all of the filenames that are found in this Albums directory on disk. * Returns an array with all the names. * * @param $dirs Whether or not to return directories ONLY with the file array. * @return array */ function loadFileNames($dirs = false) { if ($this->isDynamic()) { // there are no 'real' files return array(); } $albumdir = $this->localpath; if (!is_dir($albumdir) || !is_readable($albumdir)) { if (!is_dir($albumdir)) { $msg = sprintf(gettext("Error: The album named %s cannot be found."), $this->name); } else { $msg = sprintf(gettext("Error: The album %s is not readable."), $this->name); } zp_error($msg, false); return array(); } $dir = opendir($albumdir); $files = array(); $others = array(); while (false !== ($file = readdir($dir))) { $file8 = filesystemToInternal($file); if ($dirs && (is_dir($albumdir . $file) && substr($file, 0, 1) != '.' || hasDynamicAlbumSuffix($file))) { $files[] = $file8; } else { if (!$dirs && is_file($albumdir . $file)) { if (is_valid_other_type($file)) { $files[] = $file8; $others[] = $file8; } else { if (is_valid_image($file)) { $files[] = $file8; } } } } } closedir($dir); if (count($others) > 0) { $others_thumbs = array(); foreach ($others as $other) { $others_root = substr($other, 0, strrpos($other, ".")); foreach ($files as $image) { $image_root = substr($image, 0, strrpos($image, ".")); if ($image_root == $others_root && $image != $other && is_valid_image($image)) { $others_thumbs[] = $image; } } } $files = array_diff($files, $others_thumbs); } if ($dirs) { return zp_apply_filter('album_filter', $files); } else { return zp_apply_filter('image_filter', $files); } }
/** * Generates a selection list from files found on disk * * @param strig $currentValue the current value of the selector * @param string $root directory path to search * @param string $suffix suffix to select for * @param bool $descending set true to get a reverse order sort */ function generateListFromFiles($currentValue, $root, $suffix, $descending = false) { if (is_dir($root)) { $curdir = getcwd(); chdir($root); $filelist = safe_glob('*' . $suffix); $list = array(); foreach ($filelist as $file) { $file = str_replace($suffix, '', $file); $list[] = filesystemToInternal($file); } generateListFromArray(array($currentValue), $list, $descending, false); chdir($curdir); } }
unset($installed_files[$key]); break; case 'plugins': $plugin_subfolders[] = implode('/', $folders); unset($installed_files[$key]); // this will be taken care of later break; case STATIC_CACHE_FOLDER: $Cache_html_subfolders[] = implode('/', $folders); unset($installed_files[$key]); break; } } $filelist = ''; foreach ($installed_files as $extra) { $filelist .= filesystemToInternal(str_replace($base, '', $extra) . '<br />'); } if (class_exists('zpFunctions') && zpFunctions::hasPrimaryScripts() && count($installed_files) > 0) { if (defined('TEST_RELEASE') && TEST_RELEASE) { $msg1 = gettext("Zenphoto core files [This is a <em>debug</em> build. Some files are missing or seem wrong]"); } else { $msg1 = gettext("Zenphoto core files [Some files are missing or seem wrong]"); } $msg2 = gettext('Perhaps there was a problem with the upload. You should check the following files: ') . '<br /><code>' . substr($filelist, 0, -6) . '</code>'; $mark = -1; } else { if (defined('TEST_RELEASE') && TEST_RELEASE) { $mark = -1; $msg1 = gettext("Zenphoto core files [This is a <em>debug</em> build]"); } else { $msg1 = '';
function checkFolder($folder) { global $albums, $gallery, $count, $albumcount; $files = scandir(ALBUM_FOLDER_SERVERPATH . '/' . $folder); $display = true; if (!empty($folder)) { $album = new Album($gallery, filesystemToInternal($folder)); } foreach ($files as $file) { $file = str_replace('\\', '/', $file); $key = str_replace(SERVERPATH . '/', '', $folder . '/' . $file); if (is_dir(ALBUM_FOLDER_SERVERPATH . $folder . '/' . $file) && $file != '..' && $file != '.') { if (empty($folder)) { $albumname = $file; } else { $albumname = $folder . '/' . $file; } checkFolder($albumname); } else { if (is_valid_image($file) || is_valid_other_type($file)) { $filename = internalToFilesystem($file); $seoname = seoFriendly($filename); if ($seoname != $filename) { $old = filesystemToInternal($file); $image = newImage($album, $old); if (!($e = $image->rename($seoname))) { if ($display) { echo '<p>' . filesystemToInternal($folder) . "</p>\n"; $display = false; } echo ' '; printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $old, $seoname); echo "<br />\n"; $count++; ?> <script type="text/javascript"> <!-- imagecount = <?php echo $count; ?> ; //--> </script> <?php } } } } } if (!empty($folder)) { $albumname = internalToFilesystem($folder); $file = basename($albumname); $seoname = seoFriendly($file); if ($seoname != $file) { $newname = dirname($albumname); if (empty($newname) || $newname == '.') { $newname = $seoname; } else { $newname .= '/' . $seoname; } if (!$album->rename($newname)) { printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $albumname, $newname); echo "<br />\n"; $albumcount++; ?> <script type="text/javascript"> <!-- albumcount = <?php echo $albumcount; ?> ; //--> </script> <?php } } } }
/** * Prints the selector for custom pages * * @return string */ function printCustomPageSelector($current) { global $_zp_gallery; ?> <select id="custompageselector" name="custompageselect"> <?php $curdir = getcwd(); $themename = $_zp_gallery->getCurrentTheme(); $root = SERVERPATH . '/' . THEMEFOLDER . '/' . $themename . '/'; chdir($root); $filelist = safe_glob('*.php'); $list = array(); foreach ($filelist as $file) { $file = filesystemToInternal($file); $list[$file] = str_replace('.php', '', $file); } generateListFromArray(array($current), $list, false, true); chdir($curdir); ?> </select> <?php }
/** * Creates a "prime" album for the user. Album name is based on the userid */ function createPrimealbum($new = true, $name = NULL) { // create his album $t = 0; $ext = ''; if (is_null($name)) { $filename = internalToFilesystem(str_replace(array('<', '>', ':', '"' . '/' . '\\', '|', '?', '*'), '_', seoFriendly($this->getUser()))); } else { $filename = internalToFilesystem(str_replace(array('<', '>', ':', '"' . '/' . '\\', '|', '?', '*'), '_', $name)); } while ($new && file_exists(ALBUM_FOLDER_SERVERPATH . $filename . $ext)) { $t++; $ext = '-' . $t; } $path = ALBUM_FOLDER_SERVERPATH . $filename . $ext; $albumname = filesystemToInternal($filename . $ext); if (@mkdir_recursive($path, FOLDER_MOD)) { $album = newAlbum($albumname); if ($title = $this->getName()) { $album->setTitle($title); } $album->save(); $this->setAlbum($album); $this->setRights($this->getRights() | ALBUM_RIGHTS); if (getOption('user_album_edit_default')) { $subrights = MANAGED_OBJECT_RIGHTS_EDIT; } else { $subrights = 0; } if ($this->getRights() & UPLOAD_RIGHTS) { $subrights = $subrights | MANAGED_OBJECT_RIGHTS_UPLOAD; } $objects = $this->getObjects(); $objects[] = array('data' => $albumname, 'name' => $albumname, 'type' => 'album', 'edit' => $subrights); $this->setObjects($objects); } }
<?php zp_register_filter('themeSwitcher_head', 'switcher_head'); zp_register_filter('themeSwitcher_Controllink', 'switcher_controllink'); zp_register_filter('theme_head', 'css_head', 500); enableExtension('zenpage', 0, false); // we do not support it $curdir = getcwd(); chdir(SERVERPATH . "/themes/" . basename(dirname(__FILE__)) . "/styles"); $filelist = safe_glob('*.css'); $themecolors = array(); foreach ($filelist as $file) { $themecolors[] = stripSuffix(filesystemToInternal($file)); } chdir($curdir); 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"; }
function getImageRotation($imgfile) { $imgfile = substr(filesystemToInternal($imgfile), strlen(ALBUM_FOLDER_SERVERPATH)); $result = query_single_row('SELECT EXIFOrientation FROM ' . prefix('images') . ' AS i JOIN ' . prefix('albums') . ' as a ON i.albumid = a.id WHERE ' . db_quote($imgfile) . ' = CONCAT(a.folder,"/",i.filename)'); if (is_array($result) && array_key_exists('EXIFOrientation', $result)) { $splits = preg_split('/!([(0-9)])/', $result['EXIFOrientation']); $rotation = $splits[0]; switch ($rotation) { case 1: return false; // none // none case 2: return false; // mirrored // mirrored case 3: return 180; // upside-down (not 180 but close) // upside-down (not 180 but close) case 4: return 180; // upside-down mirrored // upside-down mirrored case 5: return 270; // 90 CW mirrored (not 270 but close) // 90 CW mirrored (not 270 but close) case 6: return 270; // 90 CCW // 90 CCW case 7: return 90; // 90 CCW mirrored (not 90 but close) // 90 CCW mirrored (not 90 but close) case 8: return 90; // 90 CW } } return false; }
function processPlugins() { global $_zp_current_admin_obj; $curdir = getcwd(); $basepath = SERVERPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . '/'; chdir($basepath); $filelist = safe_glob('*.php'); foreach ($filelist as $file) { $titlelink = stripSuffix(filesystemToInternal($file)); $author = stripSuffix(basename(__FILE__)); $sql = 'SELECT `id` FROM ' . prefix('news') . ' WHERE `titlelink`=' . db_quote($titlelink); $result = query_single_row($sql); if (empty($result)) { $plugin_news = new ZenpageNews($titlelink); $fp = fopen($basepath . $file, 'r'); $empty = true; $desc = '<p>'; $tags = array($titlelink); $incomment = false; while ($line = fgets($fp)) { if (strpos($line, '/*') !== false) { $incomment = true; } if ($incomment) { if (strpos($line, '*/') !== false) { break; } $i = strpos($line, '*'); $line = trim(trim(substr($line, $i + 1), '*')); if (empty($line)) { if (!$empty) { $desc .= '<p>'; } $empty = true; } else { if (strpos($line, '@') === 0) { $line = trim($line, '@'); $i = strpos($line, ' '); $mod = substr($line, 0, $i); $line = trim(substr($line, $i + 1)); switch ($mod) { case 'author': $desc .= 'Author: ' . html_encode($line) . ' '; $empty = false; preg_match_all('|\\((.+?)\\)|', $line, $matches); $tags = array_merge($tags, $matches[1]); $author = array_shift($matches[1]); break; case 'package': case 'subpackage': $tags[] = $line; break; case 'tags': $pluginTags = explode(',', $line); foreach ($pluginTags as $tag) { $tags[] = trim(unQuote($tag)); } break; } } else { $desc .= html_encode($line) . ' '; $empty = false; } } } } $desc .= '</p>'; fclose($fp); $plugin_news->setShow(0); $plugin_news->setDateTime(date('Y-m-d H:i:s'), filemtime($file)); $plugin_news->setAuthor($author); $plugin_news->setTitle($titlelink); $plugin_news->setContent($desc); $plugin_news->setTags($tags); $plugin_news->setCategories(array('officially-supported', 'extensions')); $plugin_news->setCustomData("http://www.zenphoto.org/documentation/plugins/_" . PLUGIN_FOLDER . "---" . $titlelink . ".html"); $plugin_news->save(); } } chdir($curdir); }
static function getTileResources($type, $folder = NULL) { $curdir = getcwd(); $theme = basename(dirname(dirname(__FILE__))); $root = SERVERPATH . "/themes/{$theme}/tiles"; chdir($root); $filelist = safe_glob('*'); $list = array(); foreach ($filelist as $file) { if (is_dir($file) && $file != '.' && $file != '..') { $internal = filesystemToInternal($file); $filename = "{$root}/{$internal}/{$internal}.{$type}"; if (!file_exists($filename)) { continue; } $list[WEBPATH . "/themes/{$theme}/tiles/{$internal}/{$internal}.{$type}"] = $filename; } } $root = SERVERPATH . "/themes/{$theme}/{$folder}"; if (is_dir($root)) { chdir($root); $filelist = safe_glob("*.{$type}"); foreach ($filelist as $file) { $internal = filesystemToInternal($file); $list[WEBPATH . "/themes/{$theme}/{$folder}/{$internal}"] = SERVERPATH . "/themes/{$theme}/{$folder}/{$internal}"; } } chdir($curdir); return $list; }
static function getPersonaIconList($persona) { $list = array(); if (!isset($persona) || trim($persona) == '') { return $list; } $theme = $theme = basename(dirname(dirname(__FILE__))); $root = SERVERPATH . "/themes/{$theme}/personality/{$persona}/icons"; $curdir = getcwd(); chdir($root); $filelist = safe_glob('*.png'); foreach ($filelist as $file) { $internal = filesystemToInternal($file); $list[] = $internal; } chdir($curdir); return $list; }
$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'); }
/** * returns an array of the theme scripts not in the exclude array * @param array $exclude those scripts to ignore * @return array */ function getThemeFiles($exclude) { global $_zp_gallery; $files = array(); foreach (array_keys($_zp_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)) { $files[$theme][] = filesystemToInternal($file); } } chdir($curdir); } return $files; }
<select id="custom_index_page" name="custom_index_page"<?php echo $disable; ?> > <option value="" style="background-color:LightGray"><?php echo gettext('none'); ?> </option> <?php $curdir = getcwd(); $root = SERVERPATH . '/' . THEMEFOLDER . '/' . $themename . '/'; chdir($root); $filelist = safe_glob('*.php'); $list = array(); foreach ($filelist as $file) { $file = filesystemToInternal($file); $list[$file] = str_replace('.php', '', $file); } $list = array_diff($list, standardScripts()); generateListFromArray(array(getThemeOption('custom_index_page', $album, $themename)), $list, false, true); chdir($curdir); ?> </select> </td> <td><?php echo gettext("If this option is not empty, the Gallery Index URL that would normally link to the theme <code>index.php</code> script will instead link to this script. This frees up the <code>index.php</code> script so that you can create a customized <em>Home page</em> script. This option applies only to the main theme for the <em>Gallery</em>."); ?> </td> </tr> <?php }
/** * primitive theme setup for image handling scripts * * we need to conserve memory so loading the classes is out of the question. * * @param string $album * @return string */ function themeSetup($album) { // we need to conserve memory in i.php so loading the classes is out of the question. $id = NULL; $theme = getAlbumInherited(filesystemToInternal($album), 'album_theme', $id); if (empty($theme)) { $galleryoptions = getSerializedArray(getOption('gallery_data')); $theme = @$galleryoptions['current_theme']; } loadLocalOptions($id, $theme); return $theme; }
/** * Populates the theme array and returns it. The theme array contains information about * all the currently available themes. * @return array */ function getThemes() { if (empty($this->themes)) { $themedir = SERVERPATH . "/themes"; if ($dp = @opendir($themedir)) { while (false !== ($dir = readdir($dp))) { if (substr($dir, 0, 1) != "." && is_dir("{$themedir}/{$dir}")) { $themefile = $themedir . "/{$dir}/theme_description.php"; $dir8 = filesystemToInternal($dir); $this->themes[$dir8] = array('name' => gettext('Unknown'), 'author' => gettext('Unknown'), 'version' => gettext('Unknown'), 'desc' => gettext('<strong>Missing theme info file!</strong>'), 'date' => gettext('Unknown')); if (file_exists($themefile)) { $theme_description = array(); require $themefile; $this->themes[$dir8] = $theme_description; } } } ksort($this->themes, SORT_LOCALE_STRING); } } return $this->themes; }
/** * Get a custom sized version of this image based on the parameters. * * @param string $alt Alt text for the url * @param int $size size * @param int $width width * @param int $height height * @param int $cropw crop width * @param int $croph crop height * @param int $cropx crop x axis * @param int $cropy crop y axis * @param string $class Optional style class * @param string $id Optional style id * @param bool $thumbStandin set to true to treat as thumbnail * @param bool $effects ignored * @return string */ function getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy, $thumbStandin = false, $effects = NULL) { if ($thumbStandin) { $wmt = getOption('Video_watermark'); if (empty($wmt)) { $wmt = getWatermarkParam($this, WATERMARK_THUMB); } } else { $wmt = NULL; } if ($thumbStandin & 1) { $args = array($size, $width, $height, $cropw, $croph, $cropx, $cropy, NULL, $thumbStandin, NULL, $thumbStandin, NULL, NULL, NULL); if ($this->objectsThumb == NULL) { $filename = makeSpecialImageName($this->getThumbImageFile()); if (!getOption('video_watermark_default_images')) { $args[11] = '!'; } $mtime = NULL; } else { $filename = filesystemToInternal($this->objectsThumb); $mtime = filemtime(ALBUM_FOLDER_SERVERPATH . '/' . internalToFilesystem($this->imagefolder) . '/' . $this->objectsThumb); } return getImageURI($args, $this->album->name, $filename, $this->filemtime); } else { $args = getImageParameters(array($size, $width, $height, $cropw, $croph, $cropx, $cropy, NULL, $thumbStandin, NULL, $thumbStandin, $wmt, NULL, $effects), $this->album->name); $filename = $this->filename; return getImageURI($args, $this->album->name, $filename, $this->filemtime); } }
/** * Returns a list of available fonts * * @return array */ function zp_getFonts() { global $_gd_fontlist; if (!is_array($_gd_fontlist)) { $_gd_fontlist = array('system' => ''); $curdir = getcwd(); $basefile = SERVERPATH . '/' . USER_PLUGIN_FOLDER . 'gd_fonts/'; if (is_dir($basefile)) { chdir($basefile); $filelist = safe_glob('*.gdf'); foreach ($filelist as $file) { $key = filesystemToInternal(str_replace('.gdf', '', $file)); $_gd_fontlist[$key] = $basefile . '/' . $file; } } chdir($basefile = SERVERPATH . '/' . ZENFOLDER . '/gd_fonts'); $filelist = safe_glob('*.gdf'); foreach ($filelist as $file) { $key = filesystemToInternal(preg_replace('/\\.gdf/i', '', $file)); $_gd_fontlist[$key] = $basefile . '/' . $file; } if (GD_FREETYPE) { $basefile = rtrim(getOption('GD_FreeType_Path') . '/'); if (is_dir($basefile)) { chdir($basefile); $filelist = safe_glob('*.ttf'); foreach ($filelist as $file) { $key = filesystemToInternal($file); $_gd_fontlist[$key] = $basefile . '/' . $file; } } } chdir($curdir); } return $_gd_fontlist; }
/** * 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; }
/** * Gets the actual download list included all subfolders and files * @param string $dir8 An optional different folder to generate the list that overrides the folder set on the option. * This could be a subfolder of the main download folder set on the plugin's options. You have to include the base directory as like this: * "folder" or "folder/subfolder" or "../folder" * You can also set any folder within or without the root of your Zenphoto installation as a download folder with this directly * @param string $listtype "ol" or "ul" for the type of HTML list you want to use * @param array $filters8 an array of files to exclude from the list. Standard items are '.', '..','.DS_Store','Thumbs.db','.htaccess','.svn' * @param array $excludesuffixes an array of file suffixes (without trailing dot to exclude from the list (e.g. "jpg") * @param string $sort 'asc" or "desc" (default) for alphabetical ascending or descending list * @return array */ function getdownloadList($dir8, $filters8, $excludesuffixes, $sort) { $filters = array('Thumbs.db'); foreach ($filters8 as $key => $file) { $filters[$key] = internalToFilesystem($file); } if (empty($dir8)) { $dir = SERVERPATH . '/' . getOption('downloadList_directory'); } else { if (substr($dir8, 0, 1) == '/' || strpos($dir8, ':') !== false) { $dir = internalToFilesystem($dir8); } else { $dir = SERVERPATH . '/' . internalToFilesystem($dir8); } } if (empty($excludesuffixes)) { $excludesuffixes = getOption('downloadList_excludesuffixes'); } if (empty($excludesuffixes)) { $excludesuffixes = array(); } elseif (!is_array($excludesuffixes)) { $excludesuffixes = explode(',', $excludesuffixes); } if ($sort == 'asc') { $direction = 0; } else { $direction = 1; } $dirs = array_diff(scandir($dir, $direction), $filters); $dir_array = array(); if ($sort == 'asc') { natsort($dirs); } foreach ($dirs as $file) { if (@$file[0] != '.') { // exclude "hidden" files if (is_dir(internalToFilesystem($dir) . '/' . $file)) { $dirN = filesystemToInternal($dir) . "/" . filesystemToInternal($file); $dir_array[$file] = getdownloadList($dirN, $filters8, $excludesuffixes, $sort); } else { if (!in_array(getSuffix($file), $excludesuffixes)) { $dir_array[$file] = $dir . '/' . filesystemToInternal($file); } } } } return $dir_array; }
/** * album validity check * @param type $folder8 * @return boolean */ protected function _albumCheck($folder8, $folderFS, $quiet) { $this->localpath = rtrim($this->localpath, '/'); $msg = false; if (empty($folder8)) { $msg = gettext('Invalid album instantiation: No album name'); } else { if (filesystemToInternal($folderFS) != $folder8) { // an attempt to spoof the album name. $msg = sprintf(gettext('Invalid album instantiation: %1$s!=%2$s'), html_encode(filesystemToInternal($folderFS)), html_encode($folder8)); } else { if (!file_exists($this->localpath) || is_dir($this->localpath)) { $msg = sprintf(gettext('Invalid album instantiation: %s does not exist.'), html_encode($folder8)); } } } if ($msg) { $this->exists = false; if (!$quiet) { trigger_error($msg, E_USER_ERROR); } return false; } return true; }
if (@unlink($folder . $target)) { if (SYMLINK && @symlink(SERVERPATH . '/' . $target, $folder . $target)) { if ($folder . $target == $link) { $msg[] = sprintf(gettext('The existing file <code>%s</code> was replaced.'), $folder . filesystemToInternal($target)) . "<br />\n"; } else { $msg[] = sprintf(gettext('The existing symlink <code>%s</code> was replaced.'), $folder . filesystemToInternal($target)) . "<br />\n"; } } else { $msg[] = sprintf(gettext('The existing file <code>%s</code> was removed but Link creation failed.'), $target) . "<br />\n"; $success = false; } } else { if ($folder . $target == $link) { $msg[] = sprintf(gettext('The existing file <code>%s</code> could not be removed.'), $folder . filesystemToInternal($target)) . "<br />\n"; } else { $msg[] = sprintf(gettext('The existing symlink <code>%s</code> could not be removed.'), $folder . filesystemToInternal($target)) . "<br />\n"; } $success = false; } break; } } else { if (SYMLINK && @symlink(SERVERPATH . '/' . $target, $folder . $target)) { $msg[] = sprintf(gettext('<code>%s</code> Link created.'), $target) . "<br />\n"; } else { $msg[] = sprintf(gettext('<code>%s</code> Link creation failed.'), $target) . "<br />\n"; $success = false; } } } }