Eine selbst geschriebene Klasse zum rekursiven Scannen des gegebenen Start-Verzeichnisses.
Die Kommentare sollten die meisten Fragen erklären. Die Klasse ist grundlegend für eine PHP Shell, stellt aber keine vollständige Shell dar!
<?php /* Recursive Directory Scanner Class Eminently Suitable For PHP Shell By B1nary @ Toolbase.me */ class RecursiveProc { public $hide = array(); private $list = ''; /* Surf every directory and display subfolder and files. Recursive handling of subfolders */ public function scan_dir($path) { // Open given directory if ($content = @opendir($path)): $this->list .= '<ul>'; while (($item = readdir($content)) !== false): // Hide defined directories and files if (!in_array($item, $this->hide)): // Element is a directory if (is_dir($path.'/'.$item)): /* Add found directory to the list and check if this directory itself contains more subfolders or files */ $this->list .= '<li><b>'.$item.'</b>'; $this->scan_dir($path.'/'.$item); $this->list .= '</li>'; // Element is a file else: // Add found file to the list and make it clickable $this->list .= '<li><a href="'.$path.'/'.$item.'" target="_blank">'.$item.'</a></li>'; endif; endif; endwhile; closedir($content); $this->list .= '</ul>'; // The given root directory wasn't found. Exiting... else: exit('Directory not found!'); endif; return $this->list; } } // Initiate class $shell = new RecursiveProc; /* Add any directory or file that should NOT be displayed. Use it for both virtual directories (. and ..) or system files of no interest */ $shell->hide = array('.', '..', '.DS_Store'); // Start recursive scan echo $shell->scan_dir('./'); ?>