function fim_dir_tree($directory, $return_link, $title) { global $PUBLIC_HTML_DIR, $current_dir; $dir = str_replace($PUBLIC_HTML_DIR, "", $directory); if ($dir == $current_dir) { $html .= "<li><b><a href=\"javascript:browser.enterDir('{$dir}');\">{$title}</a></b></li>"; } else { $html .= "<li><a href=\"javascript:browser.enterDir('{$dir}');\">{$title}</a></li>"; } // Get and sort directories/files $files = function_exists("scandir") ? scandir($directory) : php4_scandir($directory); natcasesort($files); // filter directories $dirs = array(); foreach ($files as $file) { if (is_dir("{$directory}{$file}")) { array_push($dirs, $file); } } // Filter hidden dirs starting with underscore (sample _thumbs) foreach ($dirs as $key => $dir) { if (substr($dir, 0, 1) == ".") { unset($dirs[$key]); } } if (count($dirs) > 0) { $html .= "<ul>"; foreach ($dirs as $dir) { $html .= fim_dir_tree($directory . $dir . "/", $return_link, $dir); } $html .= "</ul>"; } return $html; }
function php_file_tree_dir($directory, $return_link, $extensions = array(), $first_call = true) { // Recursive function called by php_file_tree() to list directories/files // Get and sort directories/files if (function_exists("scandir")) { $file = scandir($directory); } else { $file = php4_scandir($directory); } natcasesort($file); // Make directories first $files = $dirs = array(); foreach ($file as $this_file) { if (is_dir("{$directory}/{$this_file}")) { $dirs[] = $this_file; } else { $files[] = $this_file; } } $file = array_merge($dirs, $files); // Filter unwanted extensions if (!empty($extensions)) { foreach (array_keys($file) as $key) { if (!is_dir("{$directory}/{$file[$key]}")) { $ext = substr($file[$key], strrpos($file[$key], ".") + 1); if (!in_array($ext, $extensions)) { unset($file[$key]); } } } } if (count($file) > 2) { // Use 2 instead of 0 to account for . and .. "directories" $php_file_tree = "<ul"; if ($first_call) { $php_file_tree .= " class=\"php-file-tree\""; $first_call = false; } $php_file_tree .= ">"; foreach ($file as $this_file) { if ($this_file != "." && $this_file != "..") { if (is_dir("{$directory}/{$this_file}")) { // Directory $link = str_replace("[link]", "{$directory}/{$this_file}", $return_link); $php_file_tree .= "<li class=\"pft-directory\"><input type='checkbox' id='test' name='test[]' value=\"{$link}\"><a href=/tests/gui//"#/">{$this_file}</a>"; $php_file_tree .= php_file_tree_dir("{$directory}/{$this_file}", $return_link, $extensions, false); $php_file_tree .= "</li>"; } else { // File // Get extension (prepend 'ext-' to prevent invalid classes from extensions that begin with numbers) $ext = "ext-" . substr($this_file, strrpos($this_file, ".") + 1); $link = str_replace("[link]", "{$directory}/{$this_file}", $return_link); $php_file_tree .= "<li class=\"pft-file " . strtolower($ext) . "\"><input type='checkbox' name='test[]' value=\"{$link}\">{$this_file}</a></li>"; } } } $php_file_tree .= "</ul>"; } return $php_file_tree; }
public static function php_file_tree_dir($directory, $uaction, $extensions = array(), $first_call = true) { if (function_exists('scandir')) { $file = scandir($directory); } else { $file = php4_scandir($directory); } natcasesort($file); // Make directories first $files = $dirs = array(); foreach ($file as $this_file) { if (is_dir($directory . '/' . $this_file)) { $dirs[] = $this_file; } else { $files[] = $this_file; } } $file = array_merge($dirs, $files); // Filter unwanted extensions if (!empty($extensions)) { foreach (array_keys($file) as $key) { if (!is_dir($directory . '/' . $file[$key])) { $ext = substr($file[$key], strrpos($file[$key], '.') + 1); if (!in_array($ext, $extensions)) { unset($file[$key]); } } } } if (count($file) > 2) { // Use 2 instead of 0 to account for . and .. directories $php_file_tree = '<ul'; if ($first_call) { $php_file_tree .= ' class="php-file-tree"'; $first_call = false; } $php_file_tree .= '>'; foreach ($file as $this_file) { if ($this_file != '.' && $this_file != '..') { if (is_dir($directory . '/' . $this_file)) { // Directory $php_file_tree .= '<li class="pft-directory"><span>' . htmlspecialchars($this_file) . '</span>'; $php_file_tree .= \filetree::php_file_tree_dir($directory . '/' . $this_file, $uaction, $extensions, false); $php_file_tree .= '</li>'; } else { // File // Get extension (prepend 'ext-' to prevent invalid classes from extensions that begin with numbers) $ext = 'ext-' . substr($this_file, strrpos($this_file, '.') + 1); // $link = '/adm/index.php?i=-forumhulp-upload-acp-upload_module&sid=90b2a79945e6a0c1f0b33626e9ffcffc&mode=main&file=' . $directory . '/' . urlencode($this_file); $link = $uaction . '&file=' . $directory . '/' . urlencode($this_file); $php_file_tree .= '<li class="pft-file ' . strtolower($ext) . (!in_array(strtolower($ext), array('ext-png', 'ext-jpg', 'ext-gif')) ? '" onclick="loadXMLDoc(\'' . $link . '\')"' : '') . ' title="' . $this_file . '"><span>' . htmlspecialchars($this_file) . '</span></li>'; } } } $php_file_tree .= '</ul>'; } return $php_file_tree; }
function returnmodules() { $modules_directories = array(); $modules_files = php4_scandir('components/modules/'); foreach ($modules_files as $file) { if (is_dir('components/modules/' . $file) && $file != '.' && $file != '..') { $modules_directories[] = $file; } } return $modules_directories; }
function LayoutList_dir($directory, $extensions = '', $first_call = true) { // Recursive function called by LayoutList() to list directories/files $LayoutList = ''; // Get and sort directories/files if (function_exists("scandir")) { $file = scandir($directory); } else { $file = php4_scandir($directory); } natcasesort($file); // Make directories first $files = $dirs = array(); foreach ($file as $this_file) { if (is_dir("{$directory}/{$this_file}")) { $dirs[] = $this_file; } else { $files[] = $this_file; } } $file = array_merge($dirs, $files); // Filter unwanted extensions if (!empty($extensions)) { foreach (array_keys($file) as $key) { if (!is_dir("{$directory}/{$file[$key]}")) { $ext = substr($file[$key], strrpos($file[$key], ".") + 1); if ($ext != $extensions) { unset($file[$key]); } } } } if (count($file) > 2) { // Use 2 instead of 0 to account for . and .. "directories" if ($first_call) { $LayoutList .= ''; $first_call = false; } $LayoutList .= ''; foreach ($file as $this_file) { if ($this_file != "." && $this_file != "..") { if (!is_dir("{$directory}/{$this_file}")) { $ext = substr($this_file, strrpos($this_file, ".") + 1); if ($ext == 'tpl') { $data = file_get_contents("{$directory}/{$this_file}"); $LayoutList .= '<div class="bloque"><div class="LayoutBox">' . $data . '</div></div>'; } } } } } return $LayoutList; $LayoutList = ''; }
} array_push($dirArray, basename($file)); } closedir($handle); } return $dirArray; } } require_once ABSPATH . 'wp-admin/admin.php'; $_POST['dir'] = urldecode($_POST['dir']); $root_dir = ''; if (file_exists($root_dir . $_POST['dir'])) { if (function_exists('scandir')) { $files = scandir($root_dir . $_POST['dir']); } else { $files = php4_scandir($root_dir . $_POST['dir']); } natcasesort($files); if (count($files) > 2) { echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">"; // All dirs foreach ($files as $file) { if (file_exists($root_dir . $_POST['dir'] . $file) && $file != '.' && $file != '..' && is_dir($root_dir . $_POST['dir'] . $file)) { echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "/\">" . htmlentities($file) . "</a></li>"; } } // All files foreach ($files as $file) { if (file_exists($root_dir . $_POST['dir'] . $file) && $file != '.' && $file != '..' && !is_dir($root_dir . $_POST['dir'] . $file)) { $ext = preg_replace('/^.*\\./', '', $file); echo "<li class=\"file ext_{$ext}\"><a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "\">" . htmlentities($file) . "</a></li>";
function php_file_tree_dir($directory, $return_link, $extensions = array(), $first_call = true) { # Recursive function called by php_file_tree() to list directories/files # Get and sort directories/files if (function_exists("scandir")) { $file = scandir($directory); } else { $file = php4_scandir($directory); } natcasesort($file); # Make directories first $files = $dirs = array(); foreach ($file as $this_file) { if (is_dir("{$directory}/{$this_file}")) { $dirs[] = $this_file; } else { $files[] = $this_file; } } #unset($dirs[$key = array_search('images', $dirs)]); $file = array_merge($dirs, $files); # Filter unwanted extensions if (!empty($extensions)) { foreach (array_keys($file) as $key) { if (!is_dir("{$directory}/{$file[$key]}")) { $ext = substr($file[$key], strrpos($file[$key], ".") + 1); if (!in_array($ext, $extensions)) { unset($file[$key]); } } } } $theme_file_tree = ""; if (count($file) > 2) { # Use 2 instead of 0 to account for . and .. "directories" $theme_file_tree = "<ul"; if ($first_call) { $theme_file_tree .= " class=\"theme-file-tree\""; $first_call = false; } $theme_file_tree .= ">"; foreach ($file as $this_file) { if ($this_file != "." && $this_file != "..") { if (is_dir("{$directory}/{$this_file}")) { # Directory $theme_file_tree .= "<li class=\"pft-dir\"><a href=\"#\">" . htmlspecialchars($this_file) . "</a>"; $theme_file_tree .= php_file_tree_dir("{$directory}/{$this_file}", $return_link, $extensions, false); $theme_file_tree .= "</li>"; } else { # File - Get extension (prepend 'ext-' to prevent invalid classes from extensions that begin with numbers) # $ext = "ext-" . substr($this_file, strrpos($this_file, ".") + 1); $theme = Config::current()->theme; $len = strlen($theme); $dir = substr(stristr($directory, $theme . "/"), $len); $link = str_replace("[link]", "{$dir}/" . urlencode($this_file), $return_link); $theme_file_tree .= "<li class=\"pft-file\"><em><a href=\"{$link}\">" . htmlspecialchars($this_file) . "</a></em></li>"; } } } $theme_file_tree .= "</ul>"; } return $theme_file_tree; }
function php_file_tree_dir($directory, $return_link, $extensions = array(), $first_call = true) { global $i; // Recursive function called by php_file_tree() to list directories/files $php_file_tree = ''; // Get and sort directories/files if (function_exists("scandir")) { $file = @scandir($directory); } else { $file = @php4_scandir($directory); } @natcasesort($file); // Make directories first $files = $dirs = array(); if (is_array($file) || is_object($file)) { foreach ($file as $this_file) { if (is_dir("{$directory}/{$this_file}")) { $dirs[] = $this_file; } else { $files[] = $this_file; } } } $file = array_merge($dirs, $files); // Filter unwanted extensions if (!empty($extensions)) { foreach (array_keys($file) as $key) { if (!is_dir("{$directory}/{$file[$key]}")) { $ext = substr($file[$key], strrpos($file[$key], ".") + 1); if (!in_array($ext, $extensions)) { unset($file[$key]); } } } } if (count($file) > 2) { // Use 2 instead of 0 to account for . and .. "directories" $php_file_tree = "<ul"; if ($first_call) { $php_file_tree .= " class=\"php-file-tree\""; $first_call = false; } $php_file_tree .= ">"; foreach ($file as $this_file) { if ($this_file != "." && $this_file != "..") { if (is_dir("{$directory}/{$this_file}")) { // Directory $php_file_tree .= "<li class=\"pft-directory\"><a href=\"#\">" . htmlspecialchars($this_file) . "</a>"; $php_file_tree .= php_file_tree_dir("{$directory}/{$this_file}", $return_link, $extensions, false); $php_file_tree .= "</li>"; } else { // File // Get extension (prepend 'ext-' to prevent invalid classes from extensions that begin with numbers) $i++; $ext = "ext-" . substr($this_file, strrpos($this_file, ".") + 1); $link = str_replace("[link]", "{$directory}/" . urlencode($this_file), $return_link); $link = str_replace("[id]", $i, $link); $php_file_tree .= "<li class=\"pft-file " . strtolower($ext) . "\"><a class='FileTree' id='FileTreeId_" . $i . "' href=\"{$link}\">" . htmlspecialchars($this_file) . "</a></li>"; } } } $php_file_tree .= "</ul>"; } return $php_file_tree; }
function php_file_tree_dir($directory, $return_link, $extensions = array(), $first_call = true) { // Recursive function called by php_file_tree() to list directories/files // Get and sort directories/files if (function_exists("scandir")) { $file = scandir($directory); } else { $file = php4_scandir($directory); } natcasesort($file); // Make directories first $files = $dirs = array(); foreach ($file as $this_file) { if (is_dir("{$directory}/{$this_file}")) { $dirs[] = $this_file; } else { $files[] = $this_file; } } $file = array_merge($dirs, $files); // Filter unwanted extensions if (!empty($extensions)) { foreach (array_keys($file) as $key) { if (!is_dir("{$directory}/{$file[$key]}")) { $ext = substr($file[$key], strrpos($file[$key], ".") + 1); if (!in_array($ext, $extensions)) { unset($file[$key]); } } } } if (count($file) > 2) { // Use 2 instead of 0 to account for . and .. "directories" $php_file_tree = "<ul id='tree-theme'"; if ($first_call) { $php_file_tree .= " class=\"php-file-tree\""; $first_call = false; } $php_file_tree .= ">"; foreach ($file as $this_file) { $files = htmlspecialchars($this_file); if ($this_file != "." && $this_file != "..") { if (is_dir("{$directory}/{$this_file}")) { // Directory $php_file_tree .= "<li class=\"pft-directory\"><a href=\"#\">" . htmlspecialchars($this_file) . "</a>"; $php_file_tree .= php_file_tree_dir("{$directory}/{$this_file}", $return_link, $extensions, false); $php_file_tree .= "</li>"; } else { if ($files != 'spot_position.php' and $files != 'spot_position.gif' and $files != 'theme_details.php' and $files != 'theme_image.gif' and $files != 'theme_image.jpg' and $files != 'theme_image.png' and $files != 'theme_details.jpg' and $files != 'Thumbs.db' and $files != 'theme_details.png' and $files != 'index.html') { // File // Get extension (prepend 'ext-' to prevent invalid classes from extensions that begin with numbers) $ext = "ext-" . substr($this_file, strrpos($this_file, ".") + 1); $link = str_replace("[link]", "{$directory}/" . urlencode($this_file), $return_link); $php_file_tree .= "<li class=\"pft-file " . strtolower($ext) . "\"><a class=\"thmfile\" src=\"{$directory}\" style=\"cursor : pointer;\" >" . htmlspecialchars($this_file) . "</a></li>"; } } } } $php_file_tree .= "</ul>"; } return $php_file_tree; }
function php_file_tree_dir($directory, $return_link, $whole, $extensions = array(), $ignored_files = array(), $call_level = 0) { global $main_folder, $default_content; $php_file_tree = ''; $page = isset($_GET['p']) ? $_GET['p'] : $default_content; // Show only entries related to current path (one level more) if ($whole == false && should_hide($directory, $page, $call_level)) { return ""; } // Get and sort directories/files if (function_exists("scandir")) { $file = scandir($directory); } else { $file = php4_scandir($directory); } natcasesort($file); // Purge unwanted / unneeded elements from the scanned array foreach (array_keys($file) as $key) { // Filter unwanted extensions if (!empty($extensions)) { if (!is_dir("{$directory}/{$file[$key]}")) { $ext = substr($file[$key], strrpos($file[$key], ".") + 1); if (!in_array($ext, $extensions)) { unset($file[$key]); continue; } } } // Filter unwanted files (array) if (!empty($ignored_files)) { if (in_array($file[$key], $ignored_files)) { unset($file[$key]); continue; } } // Filter unwanted files (filename) if (substr($file[$key], 0, 1) == "_") { unset($file[$key]); continue; } } if (count($file) > 0) { $php_file_tree = "<ul>"; foreach ($file as $this_file) { if ($this_file[0] != ".") { $link = str_replace("[link]", "{$directory}/" . urlencode(pathinfo($this_file, PATHINFO_FILENAME)), $return_link); $link = str_replace($main_folder, "", $link); $menu_name = apply_menu_icon(htmlspecialchars(sanitize_entry($this_file))); if (is_dir("{$directory}/{$this_file}")) { // Directory $php_file_tree .= "<li><a href=\"{$link}\">" . $menu_name . "</a>"; $php_file_tree .= php_file_tree_dir("{$directory}/{$this_file}", $return_link, $whole, $extensions, $ignored_files, $call_level + 1); $php_file_tree .= "</li>"; } else { // File $php_file_tree .= "<li><a href=\"{$link}\">" . $menu_name . "</a></li>"; } } } $php_file_tree .= "</ul>"; } return $php_file_tree; }
die(xml_response('alert', $DLG['select_dir'])); } if (!file_exists($path)) { die(xml_response('error', $DLG['dir_not_found'] . " [b]({$file})[/b]")); } if (!validate_path($path)) { die(xml_response('error', $DLG['invalid_dir'] . " [b]({$dir}{$file})[/b]")); } if (!is_dir($path)) { die(xml_response('alert', $DLG['not_dir'] . " [b]({$file})[/b]")); } if (!is_writable($path)) { die(xml_response('error', $DLG['no_permission'] . " [b]({$file})[/b]")); } //reads directories and file in dir $files = function_exists("scandir") ? scandir($path) : php4_scandir($path); // Filter hidden dirs starting with . (sample: .thumbs) and parent dirs .. foreach ($files as $key => $f) { if (substr($f, 0, 1) == ".") { unset($files[$key]); } } //check is dir empty if (count($files) > 0) { die(xml_response('alert', $DLG['dir_not_empty'] . " [b]({$file})[/b]")); } if ($_POST['confirm']) { $info = swampy_pathinfo($path); $delete_ok = true; //Deletes all posibal same image formats foreach ($IMAGE_FORMATS as $format) {
**/ include '../configs.php'; include "../lang/{$LANG}.php"; include 'common.php'; $dir = $_POST['dir']; $directory = $PUBLIC_HTML_DIR . $dir; if (!file_exists($directory)) { die(xml_response('error', $DLG['dir_not_found'] . " [b]({$directory})[/b]")); } if (!is_dir($directory)) { die(xml_response('error', $DLG['not_dir'] . " [b]({$directory})[/b]")); } if (!validate_path($directory)) { die(xml_response('error', $DLG['invalid_dir'] . " [b]({$directory})[/b]")); } $files = function_exists("scandir") ? scandir($directory) : php4_scandir($directory); /* Make directories first */ $ofiles = $odirs = array(); foreach ($files as $file) { if (is_dir($directory . $file)) { array_push($odirs, $file); } else { array_push($ofiles, $file); } } $files = array_merge($odirs, $ofiles); /* Parent dir */ $parent_dir = str_replace(basename($dir) . "/", "", $dir); if (validate_path($parent_dir)) { $xml = "\t<file type='parent' dir='{$parent_dir}' file='' extension='' size='' dimentions='' bg=''>{$DLG['up']}</file>\n"; }
function FolderSystemUL_dir($directory, $return_link, $extensions = array(), $first_call = true) { $LOC = \LOCAL_FILESYSTEM; // Recursive function called by FolderSystemUL() to list directories/files $FolderSystemUL = ''; // Get and sort directories/files if (function_exists("scandir")) { $file = scandir($directory); } else { $file = php4_scandir($directory); } natcasesort($file); // Make directories first $files = $dirs = array(); foreach ($file as $this_file) { if (is_dir("{$directory}/{$this_file}")) { $dirs[] = $this_file; } else { $files[] = $this_file; } } $file = array_merge($dirs, $files); // Filter unwanted extensions if (!empty($extensions)) { foreach (array_keys($file) as $key) { if (!is_dir("{$directory}/{$file[$key]}")) { $ext = substr($file[$key], strrpos($file[$key], ".") + 1); if (!in_array($ext, $extensions)) { unset($file[$key]); } } } } if (count($file) > 2) { // Use 2 instead of 0 to account for . and .. "directories" $FolderSystemUL = "<ul"; if ($first_call) { $FolderSystemUL .= " class=\"FolderSystemUL\""; $first_call = false; } $FolderSystemUL .= ">"; foreach ($file as $this_file) { if ($this_file != "." && $this_file != ".." && $this_file != "icons" && $this_file != "productos" && $this_file != "images") { $F = new \CmsDev\AdminFilesystem\FileDataRecovery(); $FLocalFile = str_replace('../../', '/', $directory); $FLocalFile = $LOC . $FLocalFile; $FLocalFile = str_replace('AdminFiles/', '', $FLocalFile); $FLocalFile = $FLocalFile . '/' . $this_file; //G:/xampp/htdocs/sekitocmsDemoV4/_Sekito_FileSystems/esp/ejemplo.ppt $F->File($FLocalFile); if (is_dir("{$directory}/{$this_file}")) { // Directory if ($this_file != "productos" && $this_file != "images") { $FolderSystemUL .= "<li class=\"pft-directory\"><span class=\"iconfolder\"></span><a href=\"javascript:void(0);\"><span>" . htmlspecialchars($this_file) . "</span></a>"; $FolderSystemUL .= FolderSystemUL_dir("{$directory}/{$this_file}", $return_link, $extensions, false); $FolderSystemUL .= "</li>"; } } else { // File $typeFile = 'rel="no"'; $ext = "ext-" . substr($this_file, strrpos($this_file, ".") + 1); if ($ext == 'ext-gif' || $ext == 'ext-jpg' || $ext == 'ext-jpeg' || $ext == 'ext-png') { $typeFile = 'rel="image"'; $link = str_replace("[link]", "{$directory}/" . urlencode($this_file), $return_link); $FolderSystemUL .= "<li class=\"pft-file " . strtolower($ext) . "\" " . $typeFile . " title=\"" . str_replace('../../', '', $directory) . "/" . $this_file . "\" rev=\"" . $F->kb('kb', false) . "\"><a href=\"javascript:void(0)\" ><span>" . htmlspecialchars($this_file) . "" . $F->kb('kb') . "</span></a></li>"; } else { $typeFile = 'rel="download"'; $link = str_replace("[link]", "{$directory}/" . urlencode($this_file), $return_link); $FolderSystemUL .= "<li class=\"pft-file " . strtolower($ext) . "\" " . $typeFile . " title=\"" . str_replace('../../', '', $directory) . "/" . $this_file . "\" rev=\"" . $F->kb('kb', false) . "\"><a href=\"javascript:void(0)\" ><span>" . htmlspecialchars($this_file) . "" . $F->kb('kb') . "</span></a></li>"; } } } } $FolderSystemUL .= "</ul>"; } return $FolderSystemUL; }
function find_downloads($dir) { global $found_downloads, $extensions; $root_dir = ''; if (file_exists($root_dir . $dir)) { if (function_exists('scandir')) { $files = scandir($root_dir . $dir); } else { $files = php4_scandir($root_dir . $dir); } if (count($files) > 2) { // All dirs foreach ($files as $file) { if (file_exists($root_dir . $dir . $file) && $file != '.' && $file != '..' && is_dir($root_dir . $dir . $file)) { find_downloads(htmlentities($dir . $file . '/')); } } // All files foreach ($files as $file) { if (file_exists($root_dir . $dir . $file) && $file != '.' && $file != '..' && !is_dir($root_dir . $dir . $file)) { $ext = preg_replace('/^.*\\./', '', $file); if ($ext != 'php' && (in_array($ext, $extensions) || sizeof($extensions) == 0)) { $info = pathinfo($file); $found_downloads[] = array('path' => htmlentities($dir . $file), 'title' => trim(ucwords(htmlentities(str_replace('_', ' ', str_replace('.' . $info['extension'], '', $file)))))); } } } } } }
function php_file_tree_dir($directory, $return_link, $extensions = array(), $chkOn, $first_call = true) { // Recursive function called by php_file_tree() to list directories/files // Get and sort directories/files if (function_exists("scandir")) { $file = scandir($directory); } else { $file = php4_scandir($directory); } natcasesort($file); // Make directories first $files = $dirs = array(); foreach ($file as $this_file) { if (is_dir("{$directory}/{$this_file}")) { $dirs[] = $this_file; } else { $files[] = $this_file; } } array_sort_by_month($dirs); // rsort($dirs); // ss - reverse sort years/days, by most recent first // echo '<pre>'; // print_r($dirs); $file = array_merge($dirs, $files); // var_dump($dirs);die(); // Filter unwanted extensions if (!empty($extensions)) { foreach (array_keys($file) as $key) { if (!is_dir("{$directory}/{$file[$key]}")) { $ext = substr($file[$key], strrpos($file[$key], ".") + 1); if (!in_array($ext, $extensions)) { unset($file[$key]); } } } } // SS - initialize $php_file_tree as appears to throw an error sometimes for unknown reason $php_file_tree = ''; if (count($file) > 2) { // Use 2 instead of 0 to account for . and .. "directories" $php_file_tree = "<ul"; if ($first_call) { $php_file_tree .= " class=\"php-file-tree\""; $first_call = false; } $php_file_tree .= ">"; foreach ($file as $this_file) { if ($this_file != "." && $this_file != "..") { if (is_dir("{$directory}/{$this_file}")) { // Directory $php_file_tree .= "<li class=\"pft-directory\"><a href=\"#\">" . htmlspecialchars($this_file) . "</a>"; $php_file_tree .= php_file_tree_dir("{$directory}/{$this_file}", $return_link, $extensions, $chkOn, false); $php_file_tree .= "</li>"; } else { // File // Get extension (prepend 'ext-' to prevent invalid classes from extensions that begin with numbers) $ext = "ext-" . substr($this_file, strrpos($this_file, ".") + 1); $link = str_replace("[link]", "{$directory}/" . urlencode($this_file), $return_link); if ($chkOn === true) { // append checkbox $php_file_tree .= "<li class=\"pft-file " . strtolower($ext) . "\"><input type=\"checkbox\" value=\"{$link}\" name=\"CheckBxFile\" id=\"CheckBxFile\"/>" . htmlspecialchars($this_file) . "</li>"; } else { $php_file_tree .= "<li class=\"pft-file " . strtolower($ext) . "\"><a href=\"#noLink\" {$link}>" . htmlspecialchars($this_file) . "</a></li>"; // #noLink used in URL href to avoid when click on file that the page jumps to top } } } } $php_file_tree .= "</ul>"; } return $php_file_tree; }
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; }