本文整理汇总了PHP中directory_list函数的典型用法代码示例。如果您正苦于以下问题:PHP directory_list函数的具体用法?PHP directory_list怎么用?PHP directory_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了directory_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: directory_list
/**
* This function returns a recursive list of all subdirectories from a given directory
*
* @access public
* @param string $directory: from this dir the recursion will start.
* @param bool $show_hidden (optional): if set to TRUE also hidden dirs (.dir) will be shown.
* @param int $recursion_deep (optional): An optional integer to test the recursions-deep at all.
* @param array $aList (optional): A simple storage list for the recursion.
* @param string $ignore (optional): This is the part of the "path" to be "ignored"
*
* @return array
*
* @example:
* /srv/www/httpdocs/wb/media/a/b/c/
* /srv/www/httpdocs/wb/media/a/b/d/
*
* if $ignore is set - directory_list('/srv/www/httpdocs/wb/media/') will return:
* /a
* /a/b
* /a/b/c
* /a/b/d
*
*/
function directory_list($directory, $show_hidden = false, $recursion_deep = 0, &$aList = null, &$ignore = "")
{
if ($aList == null) {
$aList = array();
}
if (is_dir($directory)) {
// Open the directory
$dir = dir($directory);
if ($dir != NULL) {
while (false !== ($entry = $dir->read())) {
// Skip hidden files
if ($entry[0] == '.' && $show_hidden == false) {
continue;
}
$temp_dir = $directory . "/" . $entry;
if (is_dir($temp_dir)) {
// Add dir and contents to list
$aList[] = str_replace($ignore, "", $temp_dir);
$temp_result = directory_list($temp_dir, $show_hidden, $recursion_deep + 1, $aList, $ignore);
}
}
$dir->close();
}
}
if ($recursion_deep == 0) {
natcasesort($aList);
return $aList;
}
}
示例2: directory_list
/**
* directory_list
* return an array containing optionally all files, only directiories or only files at a file system path
* @author cgray The Metamedia Corporation www.metamedia.us
*
* @param $base_path string either absolute or relative path
* @param $filter_dir boolean Filter directories from result (ignored except in last directory if $recursive is true)
* @param $filter_files boolean Filter files from result
* @param $exclude string Pipe delimited string of files to always ignore
* @param $recursive boolean Descend directory to the bottom?
* @return $result_list array Nested array or false
* @access public
* @license GPL v3
*/
function directory_list($directory_base_path, $filter_dir = false, $filter_files = false, $exclude = ".|..|.DS_Store|.svn", $recursive = true)
{
$directory_base_path = rtrim($directory_base_path, "/") . "/";
if (!is_dir($directory_base_path)) {
error_log(__FUNCTION__ . "File at: {$directory_base_path} is not a directory.");
return false;
}
$result_list = array();
$exclude_array = explode("|", $exclude);
if (!($folder_handle = opendir($directory_base_path))) {
error_log(__FUNCTION__ . "Could not open directory at: {$directory_base_path}");
return false;
} else {
while (false !== ($filename = readdir($folder_handle))) {
if (!in_array($filename, $exclude_array)) {
if (is_dir($directory_base_path . $filename . "/")) {
if ($recursive && strcmp($filename, ".") != 0 && strcmp($filename, "..") != 0) {
// prevent infinite recursion
error_log($directory_base_path . $filename . "/");
$result_list[$filename] = directory_list("{$directory_base_path}{$filename}/", $filter_dir, $filter_files, $exclude, $recursive);
} elseif (!$filter_dir) {
$result_list[] = $filename;
}
} elseif (!$filter_files) {
$result_list[] = $filename;
}
}
}
closedir($folder_handle);
return $result_list;
}
}
示例3: test_directory_clear
public function test_directory_clear()
{
directory_create(self::getDir() . '/another_dir');
file_create(self::getDir() . '/another_file.txt');
$this->assertTrue(count(directory_list(self::getDir())) > 0);
directory_clear(self::getDir());
$this->assertEquals(0, count(directory_list(self::getDir())));
}
示例4: media_dirs_rw
function media_dirs_rw(&$wb)
{
global $database;
// if user is admin or home-folders not activated then there are no restrictions
// at first read any dir and subdir from /media
$full_list = directory_list(LEPTON_PATH . MEDIA_DIRECTORY);
$allow_list = array();
if ($wb->get_user_id() == 1 || !HOME_FOLDERS) {
return $full_list;
}
//( $wb->get_user_id() == 1 ) || !HOME_FOLDERS
// add own home_folder to allow-list
if ($wb->get_home_folder()) {
$allow_list[] = $wb->get_home_folder();
}
//$wb->get_home_folder()
// get groups of current user
$curr_groups = $wb->get_groups_id();
// if current user is in admin-group
if (($admin_key = array_search('1', $curr_groups)) !== false) {
// remove admin-group from list
unset($curr_groups[$admin_key]);
// search for all users where the current user is admin from
foreach ($curr_groups as $group) {
$sql = 'SELECT `home_folder` FROM `' . TABLE_PREFIX . 'users` ';
$sql .= 'WHERE (FIND_IN_SET(\'' . $group . '\', `groups_id`) > 0) AND `home_folder` <> \'\' AND `user_id` <> ' . $wb->get_user_id();
if (($res_hf = $database->query($sql)) != null) {
while (false !== ($rec_hf = $res_hf->fetchrow(MYSQL_ASSOC))) {
$allow_list[] = $rec_hf['home_folder'];
}
//false !== ( $rec_hf = $res_hf->fetchrow( MYSQL_ASSOC ) )
}
//( $res_hf = $database->query( $sql ) ) != null
}
//$curr_groups as $group
}
//( $admin_key = array_search( '1', $curr_groups ) ) !== false
$tmp_array = $full_list;
// create a list for readwrite dir
$array = array();
while (sizeof($tmp_array) > 0) {
$tmp = array_shift($tmp_array);
$x = 0;
while ($x < sizeof($allow_list)) {
if (strpos($tmp, $allow_list[$x])) {
$array[] = $tmp;
}
//strpos( $tmp, $allow_list[ $x ] )
$x++;
}
//$x < sizeof( $allow_list )
}
//sizeof( $tmp_array ) > 0
$tmp = array();
$full_list = array_merge($tmp, $array);
return $full_list;
}
示例5: array
}
/**
* TinyMCE beallitasai
*/
if ($_REQUEST['type'] == "mce") {
$lang_title = $locale->get('mce_title');
//szukseges tombok feltoltese
$mce_theme = array('advanced' => 'advanced', 'simple' => 'simple');
//tema kivalasztasa
$form->addElement('select', 'theme', $locale->get('mce_field_theme'), $mce_theme);
//nyelv kivalasztasa
$form->addElement('select', 'lang', $locale->get('mce_field_lang'), directory_list($libs_dir . '/tiny_mce/langs/', 'js', array(), '1'));
//mappa, ahova a tiny-bol feltolti a fileokat
$form->addElement('text', 'mcedir', $locale->get('mce_field_updir'));
//a css, amit hasznalunk az oldalon
$form->addElement('select', 'css', $locale->get('mce_field_css'), directory_list($theme_dir . '/' . $theme . '/', 'css', array(), '1'));
//oldal tartalmi reszenek a szelessege - kell az elonezet plugin-hoz
$form->addElement('text', 'pwidth', $locale->get('mce_field_pagewidth'));
//lekerdezzuk a config tablat, es az eredmenyeket beallitjuk alapertelmezettnek
$query = "\n\t\t\tSELECT *\n\t\t\tFROM iShark_Configs\n\t\t";
$result = $mdb2->query($query);
while ($row = $result->fetchRow()) {
if ($row['mce_uploaddir'] == "") {
$uploaddir = substr($_SERVER['PHP_SELF'], 0, strlen($_SERVER['PHP_SELF']) - strlen('admin.php')) . 'uploads/tiny_mce/';
} else {
$uploaddir = $row['mce_uploaddir'];
}
$form->setDefaults(array('theme' => $row['mce_theme'], 'lang' => $row['mce_lang'], 'mcedir' => $uploaddir, 'css' => $row['mce_css'], 'pwidth' => $row['mce_pagewidth']));
}
$form->applyFilter('__ALL__', 'trim');
$form->addRule('theme', $locale->get('mce_error_theme'), 'required');
示例6: directory_selection
function directory_selection($source_value, $command, $entryToExclude, $directoryToExclude)
{
global $langParentDir, $langTo, $langMove, $langCancel;
global $groupset;
$backUrl = documentBackLink($entryToExclude);
if (!empty($groupset)) {
$groupset = '?' . $groupset;
}
$dirList = directory_list();
$dialogBox = "\n <div class='row'>\n <div class='col-xs-12'>\n <div class='form-wrapper'>\n <form class='form-horizontal' role='form' action='{$_SERVER['SCRIPT_NAME']}{$groupset}' method='post'>\n <fieldset>\n <input type='hidden' name='source' value='" . q($source_value) . "'>\n <div class='form-group'>\n <label for='{$command}' class='col-sm-2 control-label' >{$langMove} {$langTo}:</label>\n <div class='col-sm-10'>\n <select name='{$command}' class='form-control'>";
if ($entryToExclude !== '/' and $entryToExclude !== '') {
$dialogBox .= "<option value=''>{$langParentDir}</option>";
}
/* build html form inputs */
foreach ($dirList as $path => $filename) {
$disabled = '';
$depth = substr_count($path, '/');
$tab = str_repeat(' ', $depth);
if ($directoryToExclude !== '/' and $directoryToExclude !== '') {
$disabled = strpos($path, $directoryToExclude) === 0 ? ' disabled' : '';
}
if ($disabled === '' and $entryToExclude !== '/' and $entryToExclude !== '') {
$disabled = $path === $entryToExclude ? ' disabled' : '';
}
$dialogBox .= "<option{$disabled} value='" . q($path) . "'>{$tab}" . q($filename) . "</option>";
}
$dialogBox .= "</select>\n </div>\n </div>\n <div class='form-group'>\n <div class='col-sm-offset-2 col-sm-10'>\n <input class='btn btn-primary' type='submit' value='{$langMove}' >\n <a href='{$backUrl}' class='btn btn-default' >{$langCancel}</a>\n </div>\n </div>\n </fieldset>\n </form>\n </div>\n </div>\n </div>";
return $dialogBox;
}
示例7: make_dir
make_dir($temp_subdir);
// Include the PclZip class file
require_once LEPTON_PATH . '/modules/lib_lepton/pclzip/pclzip.lib.php';
// Setup the PclZip object
$archive = new PclZip($temp_file);
// Unzip the files to the temp unzip folder
$list = $archive->extract(PCLZIP_OPT_PATH, $temp_subdir);
/** *****************************
* Check for GitHub zip archive.
*/
if (!file_exists($temp_subdir . "info.php")) {
if (!function_exists("directory_list")) {
require LEPTON_PATH . "/framework/functions/function.directory_list.php";
}
$temp_dirs = array();
directory_list($temp_subdir, false, 0, $temp_dirs);
foreach ($temp_dirs as &$temp_path) {
if (file_exists($temp_path . "/info.php")) {
$temp_subdir = $temp_path . "/";
break;
}
}
}
// Check if uploaded file is a valid Add-On zip file
if (!($list && file_exists($temp_subdir . 'index.php'))) {
cleanup($temp_unzip, $temp_file);
$admin->print_error($MESSAGE['GENERIC_INVALID_ADDON_FILE'] . "[1]");
}
// As we are going to check for a valid info.php, let's unset all vars expected
// there to see if they're set correctly
foreach (array('module_license', 'module_author', 'module_name', 'module_directory', 'module_version', 'module_function', 'module_description', 'module_platform') as $varname) {
示例8: directory_list_dg
/**
* @param string|callable $directory
* @param int|callable $order_flag
* @param resource|callable|null $context
* @return callable
*/
function directory_list_dg($directory, $order_flag = SCANDIR_SORT_ASCENDING, $context = null)
{
if (!is_callable($directory)) {
$directory = return_dg($directory);
}
if (!is_callable($order_flag)) {
$order_flag = return_dg($order_flag);
}
if (!is_callable($context)) {
$context = return_dg($context);
}
return function () use($directory, $order_flag, $context) {
$args = func_get_args();
return directory_list(call_user_func_array($directory, $args), call_user_func_array($order_flag, $args), call_user_func_array($context, $args));
};
}
示例9: pathinfo
// initialize template data
$dir = pathinfo(dirname(__FILE__), PATHINFO_BASENAME);
$data = array_merge(array('FTAN' => method_exists($admin, 'getFTAN') ? $admin->getFTAN() : '', 'files' => array()), $fetch_content);
if (!defined('WYSIWYG_EDITOR') || WYSIWYG_EDITOR == "none" || !file_exists(WB_PATH . '/modules/' . WYSIWYG_EDITOR . '/include.php')) {
function show_wysiwyg_editor($name, $id, $content, $width, $height)
{
return '<textarea name="' . $name . '" id="' . $id . '" style="width: ' . $width . '; height: ' . $height . ';">' . $content . '</textarea>';
}
} else {
$id_list = array("content");
require_once WB_PATH . '/modules/' . WYSIWYG_EDITOR . '/include.php';
}
// list of existing files
$wbpath = str_replace('\\', '/', WB_PATH);
$basepath = str_replace('\\', '/', WB_PATH . MEDIA_DIRECTORY . '/' . $dlgmodname);
$folder_list = directory_list($basepath);
array_push($folder_list, $basepath);
sort($folder_list);
foreach ($folder_list as $name) {
// note: the file_list() method returns the full path
$file_list = file_list($name, array('index.php'));
sort($file_list);
foreach ($file_list as $filename) {
$thumb_count = substr_count($filename, '/thumbs/');
if ($thumb_count == 0) {
$data['files'][] = array(WB_URL . str_replace($wbpath, '', $filename), str_replace($basepath . '/', '', $filename));
}
$thumb_count = "";
}
}
// list of existing groups
示例10: ivr_show_edit
//.........这里部分代码省略.........
">
<?php
$vm_results = voicemail_getVoicemail();
$vmcontexts = array_keys($vm_results);
foreach ($vmcontexts as $vmc) {
if ($vmc != 'general' && $vmc != 'zonemessages') {
echo '<option value="' . $vmc . '"' . ($vmc == $ivr_details['dircontext'] ? ' SELECTED' : '') . '>' . $vmc . "</option>\n";
}
}
?>
</select>
</td>
</tr>
<?php
}
?>
<tr>
<td><a href="#" class="info"><?php
echo _("VM Return to IVR");
?>
<span><?php
echo _("If checked, upon exiting voicemail a caller will be returned to this IVR if they got a users voicemail");
?>
</span></a></td>
<td><input type="checkbox" name="retvm" <?php
echo $ivr_details['retvm'];
?>
tabindex="<?php
echo ++$tabindex;
?>
"></td>
</tr>
<?php
if (!function_exists('directory_list')) {
?>
<tr>
<td><a href="#" class="info"><?php
echo _("Enable Direct Dial");
?>
<span><?php
echo _("Let callers into the IVR dial an extension directly");
?>
</span></a></td>
<td><input type="checkbox" name="ena_directdial" <?php
echo $ivr_details['enable_directdial'];
?>
tabindex="<?php
echo ++$tabindex;
?>
"></td>
</tr>
<?php
} else {
?>
<tr>
<td><a href="#" class="info"><?php
echo _("Direct Dial Options");
?>
<span><?php
echo _("Provides options for callers to direct dial an extension. Direct dialing can be completely disabled, it can be enabled for all extensions on a system, or it can be tied to a Company Directory allowing any member listed in that directory to be dialed directly if their extension is known. If an extension in the chosen directory is overridden, only that overridden number is dialable");
?>
</span></a></td>
<td>
<select name="ena_directdial" tabindex="<?php
echo ++$tabindex;
?>
示例11: color
});
echo color('(' . ($c = count($s3_files)) . ')', 'g') . ' - 100% - ' . color('取得檔案成功!', 'C') . "\n";
echo str_repeat('-', 80) . "\n";
} catch (Exception $e) {
echo ' - ' . color('取得檔案失敗!', 'R') . "\n";
exit;
}
// // ========================================================================
// // ========================================================================
// // ========================================================================
$i = 0;
$c = 5;
$local_files = array();
echo ' ➜ ' . color('列出即將上傳所有檔案', 'g');
$files = array();
merge_array_recursive(directory_list('..'), $files, '..');
$files = array_filter($files, function ($file) {
return in_array(pathinfo($file, PATHINFO_EXTENSION), array('html', 'txt'));
});
$files = array_map(function ($file) {
return array('path' => $file, 'md5' => md5_file($file), 'uri' => preg_replace('/^(\\.\\.\\/)/', '', $file));
}, $files);
echo "\r ➜ " . color('列出即將上傳所有檔案', 'g') . color('(' . count($local_files = array_merge($local_files, $files)) . ')', 'g') . ' - ' . sprintf('% 3d%% ', 100 / $c * ++$i);
$files = array();
merge_array_recursive(directory_map('../css'), $files, '../css');
$files = array_filter($files, function ($file) {
return in_array(pathinfo($file, PATHINFO_EXTENSION), array('css'));
});
$files = array_map(function ($file) {
return array('path' => $file, 'md5' => md5_file($file), 'uri' => preg_replace('/^(\\.\\.\\/)/', '', $file));
}, $files);
示例12: directory_selection
function directory_selection($source_value, $command, $entryToExclude)
{
global $langParentDir, $langTo, $langMoveFrom, $langMove, $moveFileNameAlias;
global $groupset;
if (!empty($groupset)) {
$groupset = '?' . $groupset;
}
$dirList = directory_list();
$dialogBox = "\n <div class='row'>\n <div class='col-xs-12'>\n <div class='form-wrapper'>\n <form class='form-horizontal' role='form' action='{$_SERVER['SCRIPT_NAME']}{$groupset}' method='post'>\n <fieldset>\n <input type='hidden' name='source' value='{$source_value}'>\n <div class='form-group'>\n <label for='{$command}' class='col-sm-4 control-label word-wrapping' >{$langMoveFrom} <b>{$moveFileNameAlias}</b> {$langTo}:</label>\n <div class='col-sm-8'>\n <select name='{$command}' class='form-control'>";
if ($entryToExclude != '/') {
$dialogBox .= "<option value=''>{$langParentDir}</option>";
}
/* build html form inputs */
foreach ($dirList as $path => $filename) {
$depth = substr_count($path, '/');
$tab = str_repeat(' ', $depth);
if ($path != $entryToExclude) {
$dialogBox .= "<option value='{$path}'>{$tab}{$filename}</option>";
}
}
$dialogBox .= "</select>\n </div>\n </div>\n <div class='form-group'>\n <div class='col-sm-offset-3 col-sm-9'>\n <input class='btn btn-primary' type='submit' value='{$langMove}' >\n </div>\n </div>\n </fieldset>\n </form>\n </div>\n </div>\n </div>";
return $dialogBox;
}
示例13: save_media_settings
function save_media_settings($pathsettings)
{
global $database, $admin;
$retvalue = 0;
include_once get_include(LEPTON_PATH . '/framework/summary.functions.php');
if (!is_null($admin->get_post_escaped("save"))) {
$sql = 'SELECT COUNT(`name`) FROM `' . TABLE_PREFIX . 'settings` ';
$where_sql = 'WHERE `name` = \'mediasettings\' ';
$sql = $sql . $where_sql;
//Check for existing settings entry, if not existing, create a record first!
if (($row = $database->get_one($sql)) == 0) {
$sql = 'INSERT INTO `' . TABLE_PREFIX . 'settings` SET ';
$where_sql = '';
} else {
$sql = 'UPDATE `' . TABLE_PREFIX . 'settings` SET ';
}
/**
* directory_list has been modify.
*/
$dirs = array();
$skip = LEPTON_PATH;
directory_list(LEPTON_PATH . MEDIA_DIRECTORY, false, 0, $dirs, $skip);
foreach ($dirs as &$name) {
$r = str_replace(array('/', ' '), '_', $name);
if ($admin->get_post_escaped($r . '-w') != null) {
$w = (int) $admin->get_post_escaped($r . '-w');
$retvalue++;
} else {
$w = isset($pathsettings[$r]['width']) ? $pathsettings[$r]['width'] : '-';
}
$pathsettings[$r]['width'] = $w;
if ($admin->get_post_escaped($r . '-h') != null) {
$h = (int) $admin->get_post_escaped($r . '-h');
$retvalue++;
} else {
$h = isset($pathsettings[$r]['height']) ? $pathsettings[$r]['height'] : '-';
}
$pathsettings[$r]['height'] = $h;
}
$pathsettings['global']['admin_only'] = $admin->get_post_escaped('admin_only') != null ? (bool) $admin->get_post_escaped('admin_only') : false;
$pathsettings['global']['show_thumbs'] = $admin->get_post_escaped('show_thumbs') != null ? (bool) $admin->get_post_escaped('show_thumbs') : false;
$fieldSerialized = serialize($pathsettings);
$sql .= '`value` = \'' . $fieldSerialized . '\' ';
$sql .= $where_sql;
if ($database->query($sql)) {
return $retvalue;
}
}
return $retvalue;
}
示例14: log_message
$codelistfile = !($argv[3] == "default") ? $argv[3] : null;
if (file_exists("../data/rdf/codelists.rdf")) {
$codelists->load("../data/rdf/codelists.rdf");
log_message("Found an existing code-list file to work from", 0);
} else {
log_message("No code-list file found");
}
//Set set up our target model for questions
$questions = ModelFactory::getDefaultModel();
$questions->addWithoutDuplicates(new Statement(new Resource("http://www.w3.org/Home/Lassila"), new Resource("http://description.org/schema/Description"), new Literal("Lassila's personal Homepage", "en")));
//Add namespaces
add_namespaces(&$questions, $ns);
add_namespaces(&$codelists, $ns);
print_r($codelists);
//Get our list of files and now loop through them to process
$files = directory_list();
foreach ($files as $file => $name) {
$n++;
if ($n > 2) {
break 1;
}
// Limit routine - make sure we only run through a few times
if (!file_exists("../data/rdf/{$name}.rdf")) {
log_message("Processing {$name}");
parse_file($file, $name, $context, $ns, &$questions, &$codelists);
log_message("Processed");
} else {
log_message("{$name} has already been converted");
}
}
$questions->writeAsHTML();
示例15: directory_list
$acttpl = 'error';
$tpl->assign('errormsg', $locale->get('error_permission_denied'));
return;
}
$tpl->assign('self', $module_name);
$tpl->assign('title_module', $title_module);
if (isset($_GET['file'])) {
include_once 'admin/settings/' . $_GET['file'];
} else {
if ($act == "lst") {
//lekerdezzuk es kiirjuk a rendszerben talalhato fooldali modulokat
$query = "\n\t\t\tSELECT DISTINCT m.module_id AS mid, m.module_name AS mname, m.file_name AS mfname, m.file_ext AS mfext, \n\t\t\t\tm.description AS mdesc, m.is_active AS mactive, m.type AS mtypem \n\t\t\tFROM iShark_Modules AS m \n\t\t\tWHERE m.is_active = 1 \n\t\t\tGROUP BY m.file_name \n\t\t\tORDER BY m.module_name\n\t\t";
$result = $mdb2->query($query);
//ha ures a lista, akkor uzenet
if ($result->numRows() != 0) {
$dirlist = directory_list('admin/settings', 'php', array(), 1);
$i = 0;
$itemdata = array();
while ($row = $result->fetchRow()) {
//csak akkor rakjuk bele a tombbe, ha letezik hozza adminisztracios file is
if (is_array($dirlist) && count($dirlist) > 0 && in_array($row['mfname'], $dirlist) && file_exists('admin/settings/' . $row['mfname'] . $row['mfext'])) {
$itemdata[$i]['mname'] = $row['mname'];
$itemdata[$i]['mfile'] = $row['mfname'];
$itemdata[$i]['mext'] = $row['mfext'];
$i++;
}
}
//atadjuk a smarty-nak a kiirando cuccokat
$tpl->assign('settinglist', $itemdata);
}
//megadjuk a tpl file nevet, amit atadunk az admin.php-nek