本文整理汇总了PHP中scan_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP scan_dir函数的具体用法?PHP scan_dir怎么用?PHP scan_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scan_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scan_dir
function scan_dir($path, $project)
{
global $projects;
$children = [];
$dh = opendir($path);
while (($entry = readdir($dh)) !== false) {
if (preg_match('/^[.]/', $entry)) {
continue;
}
$entry_path = $path . '/' . $entry;
if (is_dir($entry_path)) {
$entry_children = scan_dir($entry_path, $project);
if (!empty($entry_children)) {
$children[] = ['text' => $entry, 'id' => $entry_path, 'lines' => [], 'children' => $entry_children];
}
} elseif (preg_match('/[.]php$/', $entry)) {
$lines = [];
foreach (explode("\n", file_get_contents($entry_path)) as $i => $line) {
$lines[] = ['line' => $i, 'code' => $line];
}
$children[] = ['leaf' => true, 'id' => preg_replace('/^' . preg_quote($projects[$project], '/') . '/', $project, $entry_path), 'text' => $entry, 'lines' => $lines];
}
}
closedir($dh);
return $children;
}
示例2: wlist
function wlist()
{
$lines = null;
$args = func_get_args();
switch ($args[0]) {
case 'scan':
if ($elements = scan_dir($args[2]['path'], 'DIR')) {
foreach ($elements as $value) {
if (is_file($args[2]['path'] . $value . $args[2]['find'])) {
$about = @parse_ini_file($args[2]['path'] . $value . '/protocol/about.gl.php');
$name = $about['product'] ? $about['product'] : $value;
$lines[$name] = $args[3] ? href(THIS, $args[3], $value) : href($value);
unset($about);
}
}
}
break;
default:
if (is_array($args[2])) {
foreach ($args[2] as $link => $name) {
$lines[$link] = href(THIS, $args[3], $name);
}
}
break;
}
//Выводим массив ссылок ;)
if ($lines) {
foreach ($lines as $name => $link) {
form("label", icon($args[1]) . '<a href="' . $link . '">' . $name . '</a>');
}
} else {
html('<br> Wlist lib. (C) Kazin Fedor, 2010');
}
}
示例3: scan_dir
function scan_dir($id)
{
$result = true;
foreach ($GLOBALS['db']->select("dir", ['owner' => $_SESSION["username"], 'parent' => $id]) as $d) {
$result = scan_dir($d["id"]);
}
$result = delete_dir($id);
return $result;
}
示例4: get_icons
function get_icons()
{
$files = scan_dir('images/games', true);
$string = '<option value="0">' . CHOOSE . '</option>';
foreach ($files as $value) {
$string .= '<option value="' . $value . '">' . $value . '</option>';
}
return $string;
}
示例5: get_topic_pics
function get_topic_pics($pic = '')
{
$pics = '<option value="0">' . CHOOSE . '</option>';
$folder = scan_dir('images/topics/', true);
foreach ($folder as $value) {
$pic == $value ? $sub = 'selected' : ($sub = '');
$pics .= '<option ' . $sub . ' value="' . $value . '">' . $value . '</option>';
}
return $pics;
}
示例6: scan_dir
function scan_dir($id, $per)
{
$result = true;
foreach ($GLOBALS['db']->select("dir", ['parent' => $id]) as $k) {
$result = $GLOBALS['db']->update("dir", ['share' => $per], ['id' => $k['id']]);
$result = scan_dir($k["id"], $per);
}
foreach ($GLOBALS['db']->select("file", ['dir' => $id]) as $d) {
$result = $GLOBALS['db']->update("file", ['share' => $per], ['id' => $d['id']]);
}
return $result;
}
示例7: appendix_scan_dir
function appendix_scan_dir($link = ' ')
{
$dir = scan_dir(str_replace('kernel/', '', GLISS_DIR) . 'appendix', DIR);
foreach ($dir as $key => $value) {
if ($link == $value) {
$sel = '" selected >';
} else {
$sel = '" >';
}
echo '<option value="' . $value . $sel . $value . '</option>' . "\n";
}
}
示例8: scan_dir
function scan_dir($dir, $pfix = "")
{
$r = array();
$dh = opendir($dir);
while ($fn = readdir($dh)) {
if (is_dir("{$dir}/{$pfix}{$fn}")) {
$r += scan_dir($dir, "{$pfix}{$fn}/");
} else {
$r[] = "{$pfix}{$fn}";
}
}
return $r;
}
示例9: scan_dir
function scan_dir ($dir, $exceptions_array){
$scand_dir = scandir($dir);
$scan_dir_string = array();
foreach ($scand_dir as $file) {
if(!in_array(strtolower($file), $exceptions_array)){
$scan_file = $dir.'/'.$file;
if(is_dir($scan_file)){
$scan_file= scan_dir ($scan_file, $exceptions_array);
}
array_push($scan_dir_string, $scan_file);
}
}
return implode(',', $scan_dir_string);
}
示例10: scan_dir
function scan_dir($location)
{
$output = '';
foreach ($GLOBALS['db']->select('dir', ['parent' => $location, 'owner' => $_SESSION["username"], 'recycle' => '0']) as $d) {
$sdir = $GLOBALS['db']->select('dir', ['parent' => $d["id"], 'owner' => $_SESSION["username"], 'recycle' => '0']);
if ($sdir[0]["id"] != null) {
$output .= '<li><span class="tree-indicator"><i class="ion-ios7-minus-empty"></i></span>
<a href="#" class="filetreeselector" data-id="' . $d["id"] . '">' . $d["name"] . '</a>
<ul class="dir-tree" data-parent="' . $d["id"] . '">' . scan_dir($d["id"]) . '</ul></li>';
} else {
$output .= '<li><a href="#" class="filetreeselector" data-id="' . $d["id"] . '" >' . $d["name"] . '</a></li>';
}
}
return $output;
}
示例11: admin_settings
function admin_settings()
{
global $db, $countries;
if (isset($_POST['submit'])) {
unset($_POST['submit']);
$_POST['SITE_URL'] = strrpos($_POST['SITE_URL'], '/') !== strlen($_POST['SITE_URL']) - 1 ? check_url($_POST['SITE_URL'] . '/') : check_url($_POST['SITE_URL']);
$sql = 'UPDATE ' . DB_PRE . 'ecp_settings SET ';
foreach ($_POST as $key => $value) {
$sql .= $key . ' = "' . strsave($value) . '", ';
}
$sql = substr($sql, 0, strlen($sql) - 2);
if ($db->query($sql)) {
header('Location: ?section=admin&site=settings');
}
} else {
$dir = scan_dir('templates', true);
$designs = '';
foreach ($dir as $value) {
if (is_dir('templates/' . $value)) {
$designs .= '<option ' . ($value == DESIGN ? 'selected="selected"' : '') . ' value="' . $value . '">' . $value . '</option>';
}
}
$tpl = new smarty();
$tpl->assign('designs', $designs);
$tpl->assign('langs', get_languages());
$dir = scan_dir('module', true);
$start = '';
foreach ($dir as $value) {
if (is_dir('module/' . $value)) {
$start .= '<option ' . ('modul|' . $value == STARTSEITE ? 'selected="selected"' : '') . ' value="modul|' . $value . '">' . $value . '</option>';
}
}
$start .= '<option value="">-----' . OWN_SITES . '----</option>';
$db->query('SELECT headline, cmsID FROM ' . DB_PRE . 'ecp_cms ORDER BY headline ASC');
while ($row = $db->fetch_assoc()) {
$title = json_decode($row['headline'], true);
isset($title[LANGUAGE]) ? $title = $title[LANGUAGE] : ($title = $title[DEFAULT_LANG]);
$start .= '<option ' . ('cms|' . $row['cmsID'] == STARTSEITE ? 'selected="selected"' : '') . ' value="cms|' . $row['cmsID'] . '">' . $title . '</option>';
}
$tpl->assign('startseite', $start);
ob_start();
$tpl->display(DESIGN . '/tpl/admin/settings.html');
$content = ob_get_contents();
ob_end_clean();
main_content(SETTINGS, $content, '', 1);
}
}
示例12: scan_dir
function scan_dir($dir)
{
if (!is_dir($dir)) {
return;
}
foreach (glob("{$dir}/*") as $file) {
if (is_dir($file)) {
if (basename($file) != "CVS") {
scan_dir($file);
}
} else {
if (fnmatch("*.h", $file)) {
scan_file($file);
}
}
}
}
示例13: scan_dir
function scan_dir($location, $current)
{
$output = '';
foreach ($GLOBALS['db']->select('dir', ['parent' => $location, 'owner' => $_SESSION["username"], 'recycle' => '0']) as $d) {
$sdir = $GLOBALS['db']->select('dir', ['parent' => $d["id"], 'owner' => $_SESSION["username"], 'recycle' => '0']);
if ($current == $d["id"]) {
$ct = ' class="current"';
} else {
$ct = '';
}
if ($sdir[0]["id"] != null) {
$output .= '<li' . $ct . '><i class="fa fa-folder-open"></i> <a href="home.php?dir=' . $d["id"] . '" data-id="' . $d["id"] . '">' . $d["name"] . '</a>
<ul data-parent="' . $d["id"] . '">' . scan_dir($d["id"], $_GET["current"]) . '</ul></li>';
} else {
$output .= '<li' . $ct . '><i class="fa fa-folder"></i> <a href="home.php?dir=' . $d["id"] . '" data-id="' . $d["id"] . '" >' . $d["name"] . '</a></li>';
}
}
return $output;
}
示例14: scan_dir
function scan_dir($dir)
{
$BANNED_FILES = array("dev", ".", "..", "Thumbs.db", "desktop.ini");
$directory = scandir($dir);
foreach ($directory as $file) {
if (!is_in_array($file, $BANNED_FILES)) {
if (is_dir($dir . "/" . $file)) {
echo "<optgroup label='" . $file . "'>";
scan_dir($dir . "/" . $file);
echo "</optgroup>\n";
} else {
echo "<option label='" . basename($file, ".png") . "' value='" . $dir . "/" . $file . "'";
if ($file == "nes-8x8.png") {
echo " selected";
}
echo ">" . $file . "</option>\n";
}
}
}
}
示例15: help_invoke_main
function help_invoke_main()
{
$section = REQ('section');
$path = SKIN . '/help/sections/';
$scan = scan_dir($path);
$result = array();
foreach ($scan as $id) {
$id = str_replace('.tpl', '', $id);
if (!$section || $section && $section == $id) {
$result[$id] = proc_tpl("help/sections/{$id}");
}
}
cn_assign('help_sections', $result);
if ($section) {
echo exec_tpl('window', "style=help/style.css", "title=HELP - {$section}", 'content=' . exec_tpl('help/main'));
} else {
echoheader('-@help/style.css', 'Help section');
echo exec_tpl('help/main');
echofooter();
}
}