function dirlist($DIR = FALSE) { $r = array(); if (!$DIR or !is_dir($DIR)) { return $r; } # $r ist hier noch leer if (substr($DIR, -1) != "/") { $DIR .= "/"; } if (!is_readable($DIR)) { return $r; } # $r ist hier noch leer if (false !== ($d = dir($DIR))) { while (false !== ($n = $d->read())) { if ($n == "." or $n == "..") { continue; } if (is_file($DIR . $n)) { $r[] = $DIR . $n; } if (is_dir($DIR . $n)) { $r = array_merge($r, dirlist($DIR . $n)); } } $d->close(); } return $r; }
function dirlist(&$files, $dir) { global $cfg; if ($handle = opendir($dir)) { while ($file = readdir($handle)) { if ($file == '.' || $file == '..') { continue; } $fullpath = str_replace('//', '/', $dir . '/' . $file); if (is_dir($fullpath)) { $indent = str_repeat(' ', count(explode('/', trim(str_replace($cfg['root_dir'], '', $dir), '/'))) * 2); $files[] = array('value' => absPath(str_replace($cfg['root_dir'], '', $fullpath) . '/'), 'text' => $indent . ucfirst(basename($fullpath))); dirlist($files, $fullpath); } } closedir($handle); asort($files); return true; } return false; }
function dirlist($path) { global $indent; $indent++; //print "//dirlist($path)<br/>\n"; $c = 0; foreach(glob("$path/*",GLOB_ONLYDIR ) as $dir) { $c++; if (($dir != ".") && ($dir != "..") ) { $dir = basename($dir); //print $dir."<br/>\n"; if ($c>1) { print ",";} str_repeat("\t",$indent); print "$dir:{\n"; dirlist("$path/$dir"); str_repeat("\t",$indent); print "\n}\n"; } } //$c = 0; //print "//$path/*.js<br/>\n"; $files=glob("$path/*.htm"); if ($files) { foreach($files as $file) { $c++; $f = basename($file,'.htm'); if ($c>1) { print ",";} str_repeat("\t",$indent); $text = file_get_contents($file); $text =str_replace("'","\\'",$text); $text =str_replace("\r","",$text); $text =str_replace("\n","\\n",$text); print "$f:'".$text."'"; //print $file."<br/>\n"; } } }
<?php //遍历所有版本号。 $base_dir = __DIR__ . '/target'; foreach (dirlist($base_dir) as $i) { $version_dir = $base_dir . DIRECTORY_SEPARATOR . $i; if (!is_dir($version_dir)) { continue; } //遍历每个版本号下面,en(翻译)改为zh_cn. foreach (dirlist($version_dir) as $j) { $lang_dir = $version_dir . DIRECTORY_SEPARATOR . $j; if ($j == 'en') { //内部的所有文件,如果是xml的额外处理 foreach (dirlist($lang_dir) as $file) { $filename = $lang_dir . DIRECTORY_SEPARATOR . $file; if (!is_file($filename)) { continue; } if (substr($filename, -4) != '.xml') { continue; } $content = file_get_contents($filename); //这个doctype被标准化了 $content = str_replace('<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">', '', $content); file_put_contents($filename, $content); } rename($version_dir . DIRECTORY_SEPARATOR . 'en', $version_dir . DIRECTORY_SEPARATOR . 'zh_cn'); } } }
function dirlist($path) { global $indent; $indent++; //print "//dirlist($path)<br/>\n"; $c = 0; foreach(glob("$path/*",GLOB_ONLYDIR ) as $dir) { $c++; if (($dir != ".") && ($dir != "..") ) { $dir = basename($dir); //print $dir."<br/>\n"; if ($c>1) { print ",";} str_repeat("\t",$indent); print "$dir:{\n"; dirlist("$path/$dir"); str_repeat("\t",$indent); print "\n}\n"; } } //$c = 0; //print "//$path/*.js<br/>\n"; $ls = glob("$path/*.js"); if ($ls) { foreach($ls as $file) { $c++; $f = basename($file,'.js'); if ($c>1) { print ",";} str_repeat("\t",$indent); print "$f:".file_get_contents($file); //print $file."<br/>\n"; } } }
function dirlist($dir = '.', $currdir = '.', $prefix = ' ') { // Recursive function to list out directories, subdirectories, and their files. global $DIRLIST_LINK_TEMPLATE; global $menu_index; $dirpath = realpath($currdir . '/' . $dir); if ($dh = @opendir($dirpath)) { // Fill array with file names. $files = array(); while (($file = readdir($dh)) !== false) { if ($file == '.') { continue; } if ($file == '..') { continue; } //////////////////////// // Filter files here. // //////////////////////// // no filters... $files[] = $file; } closedir($dh); sort($files, SORT_STRING); // List directories first for ($i = 0; $i < count($files); $i++) { $file = $files[$i]; if (!is_dir($dirpath . '/' . $file)) { continue; } $symbol = menu_symbol($menu_index); $class = ' class="' . menu_li_class($menu_index) . '"'; $style = ' style="' . menu_ul_style($menu_index) . '"'; $menu_index++; print "\n{$prefix}<li{$class}>{$symbol}{$file}"; print "\n{$prefix} <ul{$style}>"; // Recursive call. dirlist($file, ($currdir ? "{$currdir}/" : '') . $dir, $prefix . ' '); print "\n{$prefix} </ul>"; print "\n{$prefix}</li>"; } // List files next for ($i = 0; $i < count($files); $i++) { $file = $files[$i]; if (is_dir($dirpath . '/' . $file)) { continue; } $symbol = '<span class="' . get_file_type($file) . '"></span>'; if ($DIRLIST_LINK_TEMPLATE) { $link = $DIRLIST_LINK_TEMPLATE; $link = preg_replace('/\\$file/', $file, $link); $linkdir = $currdir . '/' . $dir; $linkdir = preg_replace('|^(\\./)+|', '', $linkdir); $link = preg_replace('/\\$dir/', $linkdir, $link); } else { $link = $file; } print "\n{$prefix}<li>{$symbol}{$link}</li>"; } } else { //print "\n<br>Cannot open $dirpath."; $symbol = '<span class="symbol-error"></span>'; print "\n{$prefix}<li>{$symbol}{$dir}</li>"; } }
function dirlist($dir) { foreach (php4_scandir($dir) as $entry) { if ($entry != '.' && $entry != '..') { $entry = $dir . '/' . $entry; if (is_dir($entry)) { $path = pathinfo($entry); $listarray[$path['basename']] = dirlist($entry); } else { $path = pathinfo($entry); $listarray[] = $path['basename']; } } } return $listarray; }
$dir .= "./data"; require_once "./modules/utils.php"; $date = isset($_POST['date']) ? $_POST['date'] : Date("Y/m/d"); $name = isset($_POST['name']) ? $_POST['name'] : ""; $message = isset($_POST['message']) ? $_POST['message'] : ""; $ticket = isset($_POST['ticket']) ? $_POST['ticket'] : ""; $mode = isset($_POST['mode']) ? $_POST['mode'] : "lookup"; switch ($mode) { case "lookup": lookup($date); break; case "add": add($date, $name, $message, $ticket); break; case "dirlist": dirlist($dir); break; } //---- end of main ----// function lookup($date) { $temp = split("/", $date); $monthname = $temp[0] . $temp[1]; $folder = "./data/{$monthname}"; $drc = dir($folder); $datas = array(); $count = 0; if ($drc != null) { while ($fl = $drc->read()) { $lfl = $folder . "/" . $fl; $din = pathinfo($lfl);
function dirlist($dir, &$c_file_count, &$all_c) { $thisdir = dir($dir . '/'); //include the trailing slash while (($file = $thisdir->read()) !== false) { if ($file != '.' && $file != '..') { $path = $thisdir->path . $file; if (is_dir($path) == true) { dirlist($path, $c_file_count, $all_c); } else { if (preg_match("/\\w+\\.c\$/", $file)) { $all_c[$c_file_count] = $path; $c_file_count++; } } } } return; }
} div.txt pre, div.txt .pre { /*width: 10px;*/ font-family: "Lucida Console", monospace; } --></style> </head> <body> <h1>Directory: <?php echo $rq; ?> </h1> <?php if (file_exists('..' . $rq . 'readme.txt')) { ?> <div class="txt"><div class="fsub"> <div class="pre"><?php echo str_replace(array(' ', "\n", "\t"), array(' ', "<br />\n", ' '), htmlspecialchars(file_get_contents('..' . $rq . 'readme.txt'))); ?> </div> </div></div> <?php } ?> <?php dirlist('..' . $rq, TRUE, '', '', substr($rq, 1)); ?> </body> </html>
<?php require 'cache.php'; $Cache = new CACHE(); function dirlist() { $d = dir("raw/"); $contents = ""; $i = 0; while (false !== ($entry = $d->read())) { if ($i > 2) { $contents .= $entry . "\n"; } $i++; } return $contents; } $d = dirlist(); $a = explode("\n", $d); $id = rand(0, count($a)); echo "<a href='/{$a[$id]}'><img src='/{$a[$id]}'></a>";
function dirlist($arr) { $dir = scandir($arr, 1); $arr2 = str_replace(ARTICLES, '', $arr); for ($i = 0; $i < count($dir) - 2; $i++) { $title = ""; $submenu = ""; if (preg_match('/\\.dat$/i', $dir[$i])) { if (preg_match('/(^main)|(^404)\\.dat/iu', $dir[$i])) { continue; } if (file_exists($arr . '/' . $dir[$i])) { $data = file_get_contents($arr . '/' . $dir[$i]); $head = articlesparam('title', $data); $descr = articlesparam('description', $data); $incl = articlesparam('myinclude', $data); $page = cc_link($arr2 . '/' . preg_replace('/\\.dat$/i', '.html', $dir[$i])); $fsize = convert_fsize(filesize($arr . '/' . $dir[$i])); if ($incl == 'photo') { $tempdir = scandir(PICTURES, 1); $temparr = array_filter($tempdir, 'onlycat'); $countdir = count($temparr); $countdir = $countdir > 0 ? ': ' . $countdir . ' ' . __('каталога') : ''; $temparr = array_filter($tempdir, 'onlypic'); $countpic = count($temparr); $countdir .= $countpic > 0 ? ' ' . $countpic . ' ' . __('картинок') : ''; echo '<li class="photo"><a href="' . $page . '" title="' . $descr . '">' . $head . '</a> (' . __('Каталог') . $countdir . ")\n"; echo "<ul>"; listpict(PICTURES); echo '</ul></li>'; } else { echo '<li class="file"><a href="' . $page . '" title="' . $descr . '">' . $head . '</a> (' . __('размер') . ': ' . $fsize . ")</li>\n"; } } } else { if (preg_match('/(^\\.)|(\\.[a-z]*)/iu', $dir[$i])) { continue; } $submenu = ""; if (file_exists($arr . '/' . $dir[$i] . '/main.dat')) { $fh = @fopen($arr . '/' . $dir[$i] . '/main.dat', 'r'); $data = fread($fh, filesize($arr . '/' . $dir[$i] . '/main.dat')); fclose($fh); $head = str_replace("\n", '', articlesparam('title', $data)); $descr = str_replace("\n", '', articlesparam('description', $data)); $incl = str_replace("\n", '', articlesparam('myinclude', $data)); $page = cc_link($arr2 . '/' . $dir[$i] . '/'); $tempdir = scandir($arr . '/' . $dir[$i], 1); $tempdir = array_filter($tempdir, 'onlydat'); $countindir = count($tempdir); $countindir = $countindir > 0 ? ': ' . $countindir . ' ' . __('файла/каталога') : ''; echo '<li class="folder"><a href="' . $page . '" title="' . $descr . '">' . $head . '</a> (' . __('Каталог') . $countindir . ')'; if ($countindir !== '') { echo '<ul>'; dirlist($arr . '/' . $dir[$i]); echo '</ul>'; } echo '</li>'; } } } }
if ($argc > 1) { if ($argv[1] === "-") { $file = "php://stdin"; } else { $file = $argv[1]; } } elseif (stdin_is_readable()) { $file = "php://stdin"; } else { $file = "./package.xml"; } if ($xml = simplexml_load_file($file)) { $xml_files = xmllist($xml->contents[0]); $dirs = ["."]; while ($dir = array_shift($dirs)) { foreach (dirlist($dir) as $file) { if (is_gitignored($file)) { continue; } if (is_commonly_ignored($file)) { continue; } if (!is_dir($file)) { if (!in_array($file, $xml_files)) { echo "Missing file {$file}\n"; } } else { $base = basename($file); if ($base[0] !== ".") { array_push($dirs, $file); }
function rrd_clean() { $rrds = db_fetch_assoc("SELECT plugin_rrdclean.name FROM plugin_rrdclean WHERE plugin_rrdclean.local_data_id = '0'"); foreach ($rrds as $rrd) { db_execute("INSERT INTO plugin_rrdclean_action VALUES('', '" . $rrd["name"] . "','0','1')"); db_execute("DELETE FROM plugin_rrdclean WHERE plugin_rrdclean.name = '" . $rrd["name"] . "'"); } // remove empty rrd directory include dirname(__FILE__) . "/include/global.php"; $dirs = dirlist($config['rra_path'], array("archive", "backup"), TRUE); foreach ($dirs as $dir) { rmdir($dir); } }