本文整理汇总了PHP中safe_glob函数的典型用法代码示例。如果您正苦于以下问题:PHP safe_glob函数的具体用法?PHP safe_glob怎么用?PHP safe_glob使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safe_glob函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: folderPermissions
function folderPermissions($folder)
{
global $chmod, $f;
$curdir = getcwd();
chdir($folder);
$files = safe_glob('*.*');
chdir($curdir);
foreach ($files as $file) {
$path = $folder . '/' . $file;
if (is_dir($path)) {
if ($file != '.' && $file != '..') {
@chmod($path, $chmod);
clearstatcache();
if ((fileperms($path) & 0777) == $chmod) {
if (!folderPermissions($path)) {
return false;
}
} else {
return false;
}
}
} else {
@chmod($path, 0666 & $chmod);
clearstatcache();
if ((fileperms($path) & 0777) != (0666 & $chmod)) {
return false;
}
}
}
return true;
}
示例2: getOptionsSupported
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;
}
示例3: getTileResources
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;
}
示例4: timer_handler
/**
* Handles the periodic start of the backup/restore utility to backup the database
* @param string $discard
*/
static function timer_handler($discard)
{
global $_backupMutex;
$_backupMutex->lock();
if (getOption('last_backup_run') + getOption('backup_interval') * 86400 < time()) {
// maybe a race condition? Only need one execution
$curdir = getcwd();
$folder = SERVERPATH . "/" . BACKUPFOLDER;
if (!is_dir($folder)) {
mkdir($folder, FOLDER_MOD);
}
chdir($folder);
$filelist = safe_glob('*' . '.zdb');
$list = array();
foreach ($filelist as $file) {
$list[$file] = filemtime($file);
}
chdir($curdir);
asort($list);
$list = array_flip($list);
$keep = getOption('backups_to_keep');
while (!empty($list) && count($list) >= $keep) {
$file = array_shift($list);
@chmod(SERVERPATH . "/" . BACKUPFOLDER . '/' . $file, 0777);
unlink(SERVERPATH . "/" . BACKUPFOLDER . '/' . $file);
}
cron_starter(SERVERPATH . '/' . ZENFOLDER . '/' . UTILITIES_FOLDER . '/backup_restore.php', array('backup' => 1, 'autobackup' => 1, 'compress' => sprintf('%u', getOption('backup_compression')), 'XSRFTag' => 'backup'), 3);
setOption('last_backup_run', time());
}
$_backupMutex->unlock();
return $discard;
}
示例5: timer_handler
/**
* Handles the periodic start of the backup/restore utility to backup the database
* @param string $discard
*/
static function timer_handler($discard)
{
$curdir = getcwd();
$folder = SERVERPATH . "/" . BACKUPFOLDER;
if (!is_dir($folder)) {
mkdir($folder, FOLDER_MOD);
}
chdir($folder);
$filelist = safe_glob('*' . '.zdb');
$list = array();
foreach ($filelist as $file) {
$list[$file] = filemtime($file);
}
chdir($curdir);
asort($list);
$list = array_flip($list);
$keep = getOption('backups_to_keep');
while (count($list) >= $keep) {
$file = array_shift($list);
@chmod(SERVERPATH . "/" . BACKUPFOLDER . '/' . $file, 0777);
unlink(SERVERPATH . "/" . BACKUPFOLDER . '/' . $file);
}
cron_starter(SERVERPATH . '/' . ZENFOLDER . '/' . UTILITIES_FOLDER . '/backup_restore.php', array('backup' => 1, 'autobackup' => 1, 'compress' => sprintf('%u', getOption('backup_compression')), 'XSRFTag' => 'backup'), 3);
return $discard;
}
示例6: safe_glob
/**
* A safe empowered glob().
*
* Function glob() is prohibited on some server (probably in safe mode)
* (Message "Warning: glob() has been disabled for security reasons in
* (script) on line (line)") for security reasons as stated on:
* http://seclists.org/fulldisclosure/2005/Sep/0001.html
*
* safe_glob() intends to replace glob() using readdir() & fnmatch() instead.
* Supported flags: GLOB_MARK, GLOB_NOSORT, GLOB_ONLYDIR
* Additional flags: GLOB_NODIR, GLOB_PATH, GLOB_NODOTS, GLOB_RECURSE
* (not original glob() flags)
*
* @author BigueNique AT yahoo DOT ca
* @updates
* - 080324 Added support for additional flags: GLOB_NODIR, GLOB_PATH,
* GLOB_NODOTS, GLOB_RECURSE
*/
function safe_glob($pattern, $flags = 0)
{
$split = explode('/', str_replace('\\', '/', $pattern));
$mask = array_pop($split);
$path = implode('/', $split);
if (($dir = @opendir($path)) !== false) {
$glob = array();
while (($file = readdir($dir)) !== false) {
// Recurse subdirectories (GLOB_RECURSE); speedup: no need to sort the intermediate results
if ($flags & GLOB_RECURSE && is_dir($file) && !in_array($file, array('.', '..'))) {
$glob = array_merge($glob, array_prepend(safe_glob($path . '/' . $file . '/' . $mask, $flags | GLOB_NOSORT), $flags & GLOB_PATH ? '' : $file . '/'));
}
// Match file mask
if (fnmatch($mask, $file)) {
if ((!($flags & GLOB_ONLYDIR) || is_dir($path . '/' . $file)) && (!($flags & GLOB_NODIR) || !is_dir($path . '/' . $file)) && (!($flags & GLOB_NODOTS) || !in_array($file, array('.', '..')))) {
$glob[] = ($flags & GLOB_PATH ? $path . '/' : '') . $file . ($flags & GLOB_MARK && is_dir($path . '/' . $file) ? '/' : '');
}
}
}
closedir($dir);
if (!($flags & GLOB_NOSORT)) {
sort($glob);
}
return $glob;
} else {
return false;
}
}
示例7: gallerystats_filesize_r
function gallerystats_filesize_r($path)
{
if (!file_exists($path)) {
return 0;
}
if (is_file($path)) {
return filesize($path);
}
$ret = 0;
foreach (safe_glob($path . "/*") as $fn) {
$ret += gallerystats_filesize_r($fn);
}
return $ret;
}
示例8: getOptionsSupported
/**
* Reports the supported options
*
* @return array
*/
function getOptionsSupported()
{
$buttons = array(gettext('Allow') => 'allow', gettext('Block') => 'block');
$text = array_flip($buttons);
$cwd = getcwd();
chdir(SERVERPATH . '/' . UPLOAD_FOLDER);
$list = safe_glob('*.txt');
chdir($cwd);
$files = array('' => '');
foreach ($list as $file) {
$files[$file] = $file;
}
$options = array(gettext('IP list') => array('key' => 'ipBlocker_IP', 'type' => OPTION_TYPE_CUSTOM, 'order' => 5, 'desc' => sprintf(gettext('List of IP ranges to %s.'), $text[getOption('ipBlocker_type')])), gettext('Import list') => array('key' => 'ipBlocker_import', 'type' => OPTION_TYPE_SELECTOR, 'order' => 6, 'selections' => $files, 'nullselection' => '', 'disabled' => !extensionEnabled('ipBlocker'), 'desc' => sprintf(gettext('Import an external IP list. <p class="notebox"><strong>NOTE:</strong> If this list is large it may exceed the capacity of zenphoto and %s to process and store the results.'), DATABASE_SOFTWARE)), gettext('Action') => array('key' => 'ipBlocker_type', 'type' => OPTION_TYPE_RADIO, 'order' => 4, 'buttons' => $buttons, 'desc' => gettext('How the plugin will interpret the IP list.')), gettext('Logon threshold') => array('key' => 'ipBlocker_threshold', 'type' => OPTION_TYPE_NUMBER, 'order' => 1, 'desc' => gettext('Admin page requests will be ignored after this many failed tries.')), gettext('404 threshold') => array('key' => 'ipBlocker_404_threshold', 'type' => OPTION_TYPE_NUMBER, 'order' => 1, 'desc' => gettext('Access will be suspended after this many 404 errors.')), gettext('Cool off') => array('key' => 'ipBlocker_timeout', 'type' => OPTION_TYPE_NUMBER, 'order' => 3, 'desc' => gettext('The block will be removed after this many minutes.')));
if (!extensionEnabled('ipBlocker')) {
$options['note'] = array('key' => 'ipBlocker_note', 'type' => OPTION_TYPE_NOTE, 'order' => 0, 'desc' => '<p class="notebox">' . gettext('IP list ranges cannot be managed with the plugin disabled') . '</p>');
}
return $options;
}
示例9: getOptionsSupported
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;
}
示例10: getOptionsSupported
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;
}
示例11: getFolderList
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;
}
示例12: gettext
?>
</td>
<td>
<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>
示例13: array
}
$zenphoto_tabs['options'] = array('text' => gettext("options"), 'link' => WEBPATH . "/" . ZENFOLDER . '/admin-options.php?page=options' . $optiondefault, 'subtabs' => $subtabs, 'default' => 'gallery');
}
if ($_zp_loggedin & THEMES_RIGHTS) {
$zenphoto_tabs['themes'] = array('text' => gettext("themes"), 'link' => WEBPATH . "/" . ZENFOLDER . '/admin-themes.php', 'subtabs' => NULL);
}
if ($_zp_loggedin & ADMIN_RIGHTS) {
list($subtabs, $default) = getPluginTabs();
$zenphoto_tabs['plugins'] = array('text' => gettext("plugins"), 'link' => WEBPATH . "/" . ZENFOLDER . '/admin-plugins.php', 'subtabs' => $subtabs, 'default' => $default);
}
if ($_zp_loggedin & ADMIN_RIGHTS) {
list($subtabs, $default, $new) = getLogTabs();
$zenphoto_tabs['logs'] = array('text' => gettext("logs"), 'link' => WEBPATH . "/" . ZENFOLDER . '/admin-logs.php?page=logs', 'subtabs' => $subtabs, 'alert' => $new, 'default' => $default);
}
if (!$_zp_current_admin_obj->getID()) {
$filelist = safe_glob(SERVERPATH . "/" . BACKUPFOLDER . '/*.zdb');
if (count($filelist) > 0) {
$zenphoto_tabs['restore'] = array('text' => gettext("Restore"), 'link' => WEBPATH . "/" . ZENFOLDER . '/utilities/backup_restore.php?page=backup', 'subtabs' => NULL);
}
}
$zenphoto_tabs = zp_apply_filter('admin_tabs', $zenphoto_tabs);
foreach ($zenphoto_tabs as $tab => $value) {
if (is_null($value)) {
unset($zenphoto_tabs[$tab]);
}
}
// so as to make it generally available as we make much use of it
if (OFFSET_PATH != 2) {
require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/colorbox_js.php';
}
loadLocalOptions(false, $_zp_gallery->getCurrentTheme());
示例14: getFullImageURL
/**
* 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;
}
示例15: chdir
chdir(dirname(__FILE__));
$persona = safe_glob('*', GLOB_ONLYDIR);
chdir($cwd);
$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;
}
}