php网页病毒清除类


Posted in PHP onDecember 08, 2014

本文实例讲述了php网页病毒清除类。分享给大家供大家参考。具体如下:

相信很多人的网页经常被无故的在php,asp,html,js 等文件后台加上一些木马地址,造成了很大的困扰!我以前有个站就是这样,所以一恨之下写了这段代码,文章虽然有一点浪费资源了,但是总比我们手动清除要好吧,下面我为讲讲程序的清除病毒的原理吧.

首先们要读取 $checkFile 文件这个文章是判断一个文章 是否被感染了,如果是就会执行$savafile变量里面的txt文件路径的所有文件,进行按你infecFile病毒列表清除一次.

<?php 

 Class clear_virus{ 

  //public $content; 

  public $infectFile ='virus.txt';//病毒文件列表文件 

  public $savefile    ="save.txt";//所在查看病毒的文件列表 

  public $timep  ='time.txt';//些记录清除病毒时间 

  public $checkFile ='e.php';//这里是设置 

  public $run   =0; 

  public $virus_type; 

  public $replace  ; 

  public $filepath ;  

  public $tag         =0;  

    

  function open_file(){ 

   $this->read_virus();    

   $this->check_File(); 

   if($this->run){  

    $this->update_time();  

    $this->read_file() ;     

    foreach($this->filepath as $tmppath){ 

     if(file_exists($tmppath)){ 

      $tmp_file =file_get_contents($tmppath);  

      print_r( $this->virus_type);       

        for( $i=0;$i<sizeof($this->virus_type);$i++ ){ 

         if( strrpos($tmp_file,$this->virus_type[$i])!== false){ 

          $tmp_file =str_replace($this->virus_type[$i],'',$tmp_file); 

          $this->tag =1;           

         }          

        } 

        if( $this->tag ){ 

         $handle =fopen($tmppath,'w'); 

         fwrite($handle,$tmp_file); 

         fclose($handle); 

         unset($tmp_file);  

        }      

       

     }else{ 

      ; 

     }       

    }  

   } 

  } 

   

  function check_File(){ 

   if(file_exists($this->checkFile) ){ 

    $temp =file_get_contents($this->checkFile) ; 

    echo $temp; 

     foreach( $this->virus_type as $v_tmp ){ 

      if( strrpos($temp,$v_tmp)!== false ){ 

       $this->run =1; 

       break; 

      } 

     } 

     echo $this->run; 

     unset($temp);     

   }else{ 

    $this->show_error(5); 

   } 

  } 

   

  function update_time(){ 

   if(file_exists($this->timep) ){ 

    $tmp_time =date("Y-m-d H:i:s").chr(13).'|'; 

    $tmp_fp  =fopen($this->timep,'a+'); 

    fwrite($tmp_fp,$tmp_time); 

    fclose($tmp_fp);     

   } 

    

  } 

   

   

  function read_File(){   

   if(file_exists($this->savefile) ){    

    $this->content =file($this->savefile);     

    if(is_array($this->content)){     

     $this->filepath =$this->content;      

    }else{ 

     $this->show_error(3); 

    } 

   }else{ 

    $this->show_error(4); 

   }  

  } 

   

   

  function read_virus(){   

   if(file_exists($this->infectFile) ){    

    $this->replace =file($this->infectFile);     

    if(is_array($this->replace)){     

     $this->virus_type=$this->replace;      

    }else{ 

     $this->show_error(1); 

    } 

   }else{ 

    $this->show_error(2); 

   }  

  } 

   

   

  function show_error($number){ 

   $array = array( 

    '1'=>'病毒文件未不能读取!', 

    '2'=>'病毒文件列表不存在!', 

    '3'=>'文件列表不存了', 

    '4'=>'查杀的文件不存', 

    '5'=>$this->$checkFile.'不存在了,请设置病毒感染文件' 

   );

   echo $array[$number]; 

  } 

     

 } 

 $virus =new clear_virus; 

 $virus->open_file(); 

?>

希望本文所述对大家的PHP程序设计有所帮助。

PHP 相关文章推荐
杏林同学录(二)
Oct 09 PHP
php下获取客户端ip地址的函数
Mar 15 PHP
APACHE的AcceptPathInfo指令使用介绍
Jan 18 PHP
FireFox浏览器使用Javascript上传大文件
Oct 30 PHP
PHP return语句的另一个作用
Jul 30 PHP
PHP基于CURL进行POST数据上传实例
Nov 10 PHP
php检查字符串中是否有外链的方法
Jul 29 PHP
YiiFramework入门知识点总结(图文教程)
Dec 28 PHP
PHP数组实例详解
Jun 26 PHP
php加密解密字符串示例
Oct 13 PHP
phpstorm 正则匹配删除空行、注释行(替换注释行为空行)
Jan 21 PHP
JS中彻底删除JSON对象组成的数组中的元素
Sep 22 PHP
ThinkPHP入口文件设置及相关注意事项分析
Dec 05 #PHP
简单实用的PHP防注入类实例
Dec 05 #PHP
ThinkPHP连接数据库的方式汇总
Dec 05 #PHP
PHP生成RSS文件类实例
Dec 05 #PHP
php实现两表合并成新表并且有序排列的方法
Dec 05 #PHP
ThinkPHP中redirect用法分析
Dec 05 #PHP
php查询ip所在地的方法
Dec 05 #PHP
You might like
PHP乱码问题,UTF-8乱码常见问题小结
2012/04/09 PHP
thinkphp3.2中Lite文件替换框架入口文件或应用入口文件的方法
2015/05/21 PHP
PHP简单实现DES加密解密的方法
2016/07/12 PHP
用JavaScript页面不刷新时全选择,全删除(GridView)
2009/04/14 Javascript
css值转换成数值请抛弃parseInt
2011/10/24 Javascript
jquery indexOf使用方法
2013/08/19 Javascript
javascript history对象(历史记录)使用方法(实现浏览器前进后退)
2014/01/07 Javascript
脚本合并提升javascript性能示例
2014/02/24 Javascript
一个JavaScript递归实现反转数组字符串的实例
2014/10/14 Javascript
jquery.fastLiveFilter.js实现输入自动过滤的方法
2015/08/11 Javascript
Zero Clipboard实现浏览器复制到剪贴板的方法(多个复制按钮)
2016/03/24 Javascript
node.js中module.exports与exports用法上的区别
2016/09/02 Javascript
深入理解nodejs中Express的中间件
2017/05/19 NodeJs
JS文件中加载jquery.js的实例代码
2018/05/05 jQuery
微信小程序实现长按删除图片的示例
2018/05/18 Javascript
[01:13]DOTA2群星解读国服召集令 一起说出回归的理由
2013/07/17 DOTA
Python 详解基本语法_函数_返回值
2017/01/22 Python
使用python读取txt文件的内容,并删除重复的行数方法
2018/04/18 Python
解决PySide+Python子线程更新UI线程的问题
2019/01/11 Python
详解Python3中的 input() 函数
2020/03/18 Python
python工具——Mimesis的简单使用教程
2021/01/16 Python
Lee牛仔裤澳大利亚官网:美国著名牛仔裤品牌
2017/09/02 全球购物
英国玛莎百货美国官网:Marks & Spencer美国
2018/11/06 全球购物
流行文化收藏品:Sideshow(DC漫画,星球大战,漫威)
2019/03/17 全球购物
JBL加拿大官方商店:扬声器、耳机等
2020/10/23 全球购物
Linux Interview Questions For software testers
2012/06/02 面试题
什么是servlet
2012/05/08 面试题
旅游管理实习自我鉴定
2013/09/29 职场文书
小学生期末自我鉴定
2014/01/19 职场文书
天猫某品牌专卖店运营计划书
2014/03/21 职场文书
大学生英语演讲稿
2014/04/24 职场文书
党支部承诺书
2015/01/20 职场文书
面试感谢信范文
2015/01/22 职场文书
鸟的天堂导游词
2015/01/31 职场文书
论文致谢词范文
2015/05/14 职场文书
Elasticsearch6.2服务器升配后的bug(避坑指南)
2022/09/23 Servers