<?<span php
</span><span /*</span><span *
* 删除当DIR路径下N分钟前创建的所有文件
* 整理:脚本学堂 www.jbxue.com
</span><span */</span>
<span //</span><span delfile("upload",10);</span>
<span function</span> delfile(<span $dir</span>,<span $n</span><span )
{
</span><span if</span>(<span is_dir</span>(<span $dir</span><span ))
{
</span><span if</span>(<span $dh</span>=<span opendir</span>(<span $dir</span><span ))
{
</span><span while</span> (<span false</span> !== (<span $file</span> = <span readdir</span>(<span $dh</span><span )))
{
</span><span if</span>(<span $file</span>!="." && <span $file</span>!=".."<span )
{
</span><span $fullpath</span>=<span $dir</span>."/".<span $file</span><span ;
</span><span if</span>(!<span is_dir</span>(<span $fullpath</span><span ))
{
</span><span //</span><span $filedate=date("Y-m-d", filemtime($fullpath)); </span>
<span $filedate</span>=<span date</span>("Y-m-d h:i:s", <span filemtime</span>(<span $fullpath</span><span ));
</span><span //</span><span $d1=strtotime(date("Y-m-d")); </span>
<span $d1</span>=<span strtotime</span>(<span date</span>("Y-m-d h:i:s"<span ));
</span><span $d2</span>=<span strtotime</span>(<span $filedate</span><span );
</span><span //</span><span $Days=round(($d1-$d2)/3600/24); </span>
<span $Days</span>=<span round</span>((<span $d1</span>-<span $d2</span>)/60<span );
</span><span if</span>(<span $Days</span>><span $n</span><span )
</span><span unlink</span>(<span $fullpath</span>); <span //</span><span //删除文件</span>
<span
}
}
}
}
</span><span closedir</span>(<span $dh</span><span );
}
}
</span>?>
Salin selepas log masuk
http://www.bkjia.com/PHPjc/440200.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/440200.htmlTechArticle? delfile( , ( ( ( = ( ( !== ( = ( ( !="." !=".." = ."/". (! ( = ("Y-m-d h:i:s", ( = ( ("Y-m-d h:i:s" = ( = (( - )/60 ( ( ); ( ?...