<?php
/**
* @desc 递归删除当前目录下的无效软连接
* @author mengdj<mengdj@outlook.com> 2014.10.03 1118
*/
//定义脚本持续执行直到退出为止
set_time_limit(0);
ignore_user_abort(true);
//递归删除指定文件类型
if(!function_exists("scan_links")){
function scan_links($baseDir){
if($file_handler=opendir($baseDir)){
while(($file=readdir($file_handler))!==false){
if($file!='.'&&$file!='..'){
$tmpFile=$baseDir."/".$file;
if(is_dir($tmpFile)){
scan_links($tmpFile);
}else if(!is_file($tmpFile)&&is_link($tmpFile)&&!opendir($tmpFile)){
echo $tmpFile." has found,it will be delete.";
system("rm -rf ".$tmpFile,$retval);
echo $retval."<br/>";
}
} }
closedir($file_handler);
}
}
}
$baseDir=dirname(__FILE__);;
isset($_GET['dir'])&&$baseDir=trim($_GET['dir']);
scan_links($baseDir);
?>