首页 > 编程 > PHP > 正文

PHP删除当前目录下统计代码块

2019-11-14 12:09:53
字体:
来源:转载
供稿:网友
<?php /*** * 删除文件中百度统计代码 * */ new delTJ(); class delTJ { PRivate $dir = '.'; //文件存放的目录 private $dirHandler; public function __construct() { $this->del(); } private function del() { if(is_dir($this->dir)){ echo '找到文件目录!'; $this->dirHandler = opendir($this->dir); if($this->dirHandler){ while (false !== ($file = readdir($this->dirHandler)) ) { if($file !== '.' && $file !== '..'){ $filename = dirname(__FILE__).DIRECTORY_SEPARATOR.$file; echo $filename; $content = file_get_contents(dirname(__FILE__).DIRECTORY_SEPARATOR.$file); $content = preg_replace('/<!--mytest.com(.*)/n(.*)/n(.*)/n(.*)/n(.*)<//script>/', '', $content); file_put_contents($filename,$content); } } } } } } ?>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表