Home > php教程 > php手册 > body text

一键删除runtime运行时目录

WBOY
Release: 2016-06-07 11:37:50
Original
1537 people have browsed it

根据这个问题:http://www.thinkphp.cn/topic/31728.html 想到的,因为之前我的第一个私单怕拿不到钱就想做一个一键删除网站的后门(。。。),但是后来客户给钱了,所以就没做,然后今天看到这个问题就写了一下,代码如下:
private function _deleteDir($R){<br>         $handle = opendir($R);<br>         while(($item = readdir($handle)) !== false){<br>             if($item != '.' and $item != '..'){<br>                 if(is_dir($R.'/'.$item)){<br>                     $this->_deleteDir($R.'/'.$item);<br>                 }else{<br>                     if(!unlink($R.'/'.$item))<br>                         die('error!');<br>                 }<br>             }<br>         }<br>         closedir( $handle );<br>         return rmdir($R); <br>     }<br>     public function clearRuntime(){<br>         <br>         $R = $_GET['path'] ? $_GET['path']  : RUNTIME_PATH;<br>         if($this->_deleteDir($R))<br>             die("cleared!");<br>             <br>     }使用说明:将上面这两个方法放入到你的管理后台的控制器里面,然后浏览器进入clearRuntime操作即可。
支持通过get传值删除你想删的文件夹(注意别把有用的目录删掉,如果想删掉整个网站可以输入 ./ 哈哈~),新手秀代码,求大牛喷~~~

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template