Created
March 10, 2021 09:37
-
-
Save rmpel/b4a575c3fc96f90396cb40d39f393bac to your computer and use it in GitHub Desktop.
File/Folder crawler; list all files and folders in a CSV file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** QUICK AND VERY DIRTY */ | |
header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename=crawl.csv'); | |
?> | |
type,path,timestamp,date | |
<?php | |
___T(__DIR__); | |
function ___T($s) { | |
$l = array_merge( glob($s .'/.*'), glob($s .'/*') ); | |
natcasesort($l); | |
foreach ($l as $e) { | |
$b = basename($e); | |
if ($b == '.' || $b === '..' || !trim($b)) { | |
continue; | |
} | |
if (is_dir($e)) { | |
echo '"d","' . $e . '",' . filemtime($e) . ',"' . date('r', filemtime($e)) .'"' ."\n"; | |
___T($e); | |
} | |
else { | |
echo '"f","' . $e . '",' . filemtime($e) . ',"' . date('r', filemtime($e)) .'"' ."\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment