| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- $dirToTraverse = -1;
- function GET_DIR_CONTENTS($dir, &$results = array()) {
- $files = scandir($dir);
- foreach ($files as $key => $value) {
- $path = realpath($dir . DIRECTORY_SEPARATOR . $value);
- if (!is_dir($path)) {
- $results[] = $path;
- } else if ($value != "." && $value != "..") {
- GET_DIR_CONTENTS($path, $results);
- $results[] = $path;
- }
- }
- return $results;
- }
- // =================================================================
- if (isset($argv[1])){
-
- $dirToTraverse = $argv[1];
- echo " > Check passed; Traversal Directory = [" . $dirToTraverse . "]\n";
- }
- $contents = array();
- GET_DIR_CONTENTS($dirToTraverse, $contents);
- // var_dump($contents);
- echo " > FILE AND DIRECTORY LIST:\n ================================\n";
- foreach ($contents as $c){
-
- echo " " . $c . "\n";
- }
- echo " ================================\n";
|