
/** |
* 遍历删除目录里的所有目录和文件 |
* |
* @param unknown $path |
*/ |
function deldir($path){ |
if(file_exists($path)){ |
if(is_file($path)){ |
P_unlink($path); |
}else{ |
$handle = opendir($path); // 展开目录 |
// 遍历目录里的所有文件 |
while($file = readdir($handle)){ |
if(($file != ".") && ($file != "..") && ($file != "")){ |
if(is_dir("$path/$file")){ |
deldir("$path/$file"); |
}else{ |
P_unlink("$path/$file"); |
} |
} |
} |
closedir($handle); |
rmdir($path); |
} |
} |
} |
function P_unlink($filename){ |
strpos($filename,'..') !== false && exit('Forbidden'); |
return @unlink($filename); |
} |



