-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtreeview.txt
More file actions
33 lines (31 loc) · 849 Bytes
/
treeview.txt
File metadata and controls
33 lines (31 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
// File listings in current dir and walks all below
echo "<pre>\n";
echo "Self: ".$_SERVER["PHP_SELF"]."\n";
$startdir = dirname( $_SERVER["SCRIPT_FILENAME"] );
$startdir = "/var/www/wordpress";
echo "Starting at $startdir\n";
walkdir( $startdir );
echo "</pre>\n";
function walkdir( $dir ){
$dh = opendir( $dir );
$aDirs = array();
$aFiles = array();
while( false !== ( $file = readdir( $dh ) ) ){
$file = trim( $file );
if( $file == "." || $file == ".." ) continue;
if( is_dir( $dir."/".$file ) ) $aDirs[] = $file;
else $aFiles[] = $file;
}
closedir( $dh );
foreach( $aFiles as $f ){
echo "[f] $f\n";
}
foreach( $aDirs as $d ){
echo "[d] $dir/$d\n";
echo "<blockquote>";
walkdir( $dir."/".$d );
echo "</blockquote>";
}
}
?>