// View the specification Files in the folder
$fileList = array();
function visitFile($path)
{
global $fileList;
$path = str_replace("\", "/", $path);
$fdir = dir($path);
while (($file = $fdir->read()) !== false)
{
if($file == '.' || $file == '..'){ continue; }
$pathSub = preg_replace("*/{2,}*", "/", $path."/".$ file); // Replace multiple backslashes
$fileList[] = is_dir($pathSub) ? $pathSub."/" : $pathSub;
if(is_dir($pathSub)){ visitFile($ pathSub); }
}
$fdir->close();
return $fileList;
}
?>
if(!empty($path)){
$path = preg_replace("*/{2,}*", "/", $path);
$files = visitFile($path);
switch(strtolower($_GET["action"]))
{
case "view":
foreach($files as $key => $value)
{
printf ("No.%4d·%s
rn", $key+1, $value);
}
break;
case "delete":
$faileFiles = array() ;
foreach(array_reverse($files) as $value)
{
if(!unlink($value))
{
array_push($faileFiles, $value);
}
}
if(!unlink($path)) { array_push($faileFiles, $path); }
if(count($faileFiles) > 0)
{
printf ("
Deletion failed file (%d):
rn", count($faileFiles));
foreach( $faileFiles as $key => $value)
{
printf("No.%4d·%s
rn", $key+1, $value);
}
}
break;
}
}
?>