File Directory Php


function GetListArray( $fileRoot, $matchFile, $isWin) {
$foundList = array();
$subList = array();
$filePath = ""; //file path relative to current file $ web directories
$path = $fileRoot;
do {
$path = $fileRoot.$filePath;
$Hdir = opendir($path);
if ($Hdir) {
while (false !== ($file = readdir($Hdir))) {
if (($file != '.') && ($file != '..')) {
if ($isWin) {
if ($file === $matchFile)
array_push($foundList, $filePath."\\".$file);
if (is_dir( $fileRoot.$filePath."\\".$file ))
array_push($subList, $filePath."\\".$file);
} // if isWin
else {
if ($file === $matchFile)
array_push($foundList, $filePath.'/'.$file);
if (is_dir( $fileRoot.$filePath.'/'.$file ))
array_push($subList, $filePath.'/'.$file);
} // else isWin
} // if . or ..
} // while file
}// if Hdir
$continue= false;
if (list($key, $val)= each($subList)) {
$continue=true;
$filePath = $val;
array_shift($subList);
} // if subList
} while ($continue);
sort($foundList);
return $foundList;
} // GetListArray function;
// main code
if (isset($_GET['delete'])) {
$tmp = $_GET['delete'];
// var_dump($tmp);
unlink($tmp);
}
$errFile = ini_get('error_log');
$me = $_SERVER['SCRIPT_NAME'];
$sub = substr( $_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
$webRoot = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$sub;
$dirRoot = getcwd();
$isWin = (strrpos($dirRoot, '\\')=== FALSE) ? FALSE : TRUE;
$List = GetListArray( $dirRoot, $errFile, $isWin);
?>



'."\n";
} // foreach list
print '

List of all log files (specified by "error_log" in php.ini file) at or below the current directory.


print "

error_log setting: $errFile

\n";
print "

current web directory: $webRoot

\n";
print "

current file direcory: $dirRoot

\n";
foreach ($List as $dir){
$tmp = str_replace("\\", '/', $dir);
$ds = $me.'?delete='.$dirRoot.$dir;
print '
view'.$dir.'delete
'."\n";
?>





flush();
exit;
?>