function loadAlbumNames($albumdir) { if (!is_dir($albumdir) || !is_readable($albumdir)) { return array(); } $dir = opendir($albumdir); $albums = array(); while ($dirname = readdir($dir)) { $dirname = FilesystemToUTF8($dirname); if (is_dir($albumdir . $dirname) && substr($dirname, 0, 1) != '.') { $albums[] = $dirname; $albums = array_merge($albums, $this->loadAlbumNames($albumdir . $dirname . '/')); } } closedir($dir); return $albums; }
/** * 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"; $themes = array(); 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 = FilesystemToUTF8($dir); if (file_exists($themefile)) { $theme_description = array(); require $themefile; $themes[$dir8] = sanitize($theme_description, 1); } else { if (file_exists($themedir . "/{$dir}/theme.txt")) { $themes[$dir8] = parseThemeDef($themedir . "/{$dir}/theme.txt"); } } } } ksort($themes); } $this->themes = $themes; } return $this->themes; }
/** * 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) { $curdir = getcwd(); chdir($root); $filelist = safe_glob('*' . $suffix); $list = array(); foreach ($filelist as $file) { $file = str_replace($suffix, '', $file); $list[] = FilesystemToUTF8($file); } generateListFromArray(array($currentValue), $list, $descending, false); chdir($curdir); }
<tr> <td><?php echo gettext("User registration page:"); ?> </td> <td> <select id="user_registration_page" name="user_registration_page"> <option value=''> <?php $curdir = getcwd(); $root = SERVERPATH . '/' . THEMEFOLDER . '/' . $themename . '/'; chdir($root); $filelist = safe_glob('*.php'); $list = array(); foreach ($filelist as $file) { $list[] = str_replace('.php', '', FilesystemToUTF8($file)); } $list = array_diff($list, array('themeoptions', 'theme_description', '404', 'slideshow', 'search', 'image', 'index', 'album', 'customfunctions', 'news', 'pages')); generateListFromArray(array(getThemeOption($album, 'user_registration_page')), $list, false, false); chdir($curdir); ?> </select> <br /> <?php echo gettext('Link text') . ' '; print_language_string_list(getThemeOption($album, 'user_registration_text'), 'user_registration_text'); ?> <br /> <?php echo gettext('Hint text') . ' '; print_language_string_list(getThemeOption($album, 'user_registration_tip'), 'user_registration_tip');
echo "\n<body>"; printLogoAndLinks(); echo "\n" . '<div id="main">'; printTabs('plugins'); echo "\n" . '<div id="content">'; /* Page code */ if ($saved) { echo '<div class="messagebox" id="fade-message">'; echo "<h2>" . gettext("Saved") . "</h2>"; echo '</div>'; } $curdir = getcwd(); chdir(SERVERPATH . "/" . ZENFOLDER . PLUGIN_FOLDER); $filelist = safe_glob('*' . 'php'); foreach ($filelist as $key => $plugin) { $filelist[$key] = FilesystemToUTF8($plugin); } natcasesort($filelist); echo "<h1>Plugins</h1>\n"; echo '<p>'; echo gettext("Plugins provide optional functionality for Zenphoto.") . ' '; echo gettext("They may be provided as part of the Zenphoto distribution or as offerings from third parties.") . ' '; echo gettext("Plugins are placed in the <code>zp-core/plugins</code> folder and are automatically discovered.") . ' '; echo gettext("If the plugin checkbox is checked, the plugin will be loaded and its functions made available to theme pages. If the checkbox is not checked the plugin is disabled and occupies no resources."); echo "</p>\n"; echo '<form action="?action=saveplugins" method="post">' . "\n"; echo '<input type="hidden" name="saveplugins" value="yes" />' . "\n"; echo '<input type="submit" value=' . gettext('save') . ' />' . "\n"; echo "<table class=\"bordered\" width=\"100%\">\n"; foreach ($filelist as $extension) { $ext = substr($extension, 0, strlen($extension) - 4);
/** * 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 %s cannot be found."), $this->name); } else { $msg = sprintf(gettext("Error: The album %s is not readable."), $this->name); } die($msg); } $dir = opendir($albumdir); $files = array(); $others = array(); while (false !== ($file = readdir($dir))) { $file8 = FilesystemToUTF8($file); if ($dirs && (is_dir($albumdir . $file) && substr($file, 0, 1) != '.' || hasDyanmicAlbumSuffix($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) { $others_thumbs[] = $image; } } } $files = array_diff($files, $others_thumbs); } if ($dirs) { $filter = 'album_filter'; } else { $filter = 'image_filter'; } return apply_filter($filter, $files); }
function themeSetup($album) { // a real hack--but we need to conserve memory in i.php so loading the classes is out of the question. $theme = getOption('current_theme'); $folders = explode('/', str_replace('\\', '/', $album)); if (isset($_GET['album'])) { //it is an album thumb if (count($folders) <= 1) { // and the album is in the gallery return $theme; } } $uralbum = FilesystemToUTF8($folders[0]); $sql = 'SELECT `id`, `album_theme` FROM ' . prefix('albums') . ' WHERE `folder`="' . $uralbum . '"'; $result = query_single_row($sql); if (!empty($result['album_theme'])) { $theme = $result['album_theme']; //load the album theme options $sql = "SELECT `name`, `value` FROM " . prefix('options') . ' WHERE `ownerid`=' . $result['id']; $optionlist = query_full_array($sql, true); if ($optionlist !== false) { foreach ($optionlist as $option) { setOption($option['name'], $option['value'], false); } } } return $theme; }