温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用php怎么实现一个网页病毒清除类

发布时间:2021-03-04 15:21:40 来源:亿速云 阅读:130 作者:Leah 栏目:开发技术

这期内容当中小编将会给大家带来有关使用php怎么实现一个网页病毒清除类,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

php有什么用

php是一个嵌套的缩写名称,是英文超级文本预处理语言,它的语法混合了C、Java、Perl以及php自创新的语法,主要用来做网站开发,许多小型网站都用php开发,因为php是开源的,从而使得php经久不衰。

首先们要读取 $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怎么实现一个网页病毒清除类了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php
AI