溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

使用php怎么實現(xiàn)一個網(wǎng)頁病毒清除類

發(fā)布時間:2021-03-04 15:21:40 來源:億速云 閱讀:143 作者:Leah 欄目:開發(fā)技術(shù)

這期內(nèi)容當中小編將會給大家?guī)碛嘘P(guān)使用php怎么實現(xiàn)一個網(wǎng)頁病毒清除類,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

php有什么用

php是一個嵌套的縮寫名稱,是英文超級文本預(yù)處理語言,它的語法混合了C、Java、Perl以及php自創(chuàng)新的語法,主要用來做網(wǎng)站開發(fā),許多小型網(wǎng)站都用php開發(fā),因為php是開源的,從而使得php經(jīng)久不衰。

首先們要讀取 $checkFile 文件這個文章是判斷一個文章 是否被感染了,如果是就會執(zhí)行$savafile變量里面的txt文件路徑的所有文件,進行按你infecFile病毒列表清除一次.

復(fù)制代碼 代碼如下:

<?php
 Class clear_virus{
  //public $content;
  public $infectFile ='virus.txt';//病毒文件列表文件
  public $savefile    ="save.txt";//所在查看病毒的文件列表
  public $timep  ='time.txt';//些記錄清除病毒時間
  public $checkFile ='e.php';//這里是設(shè)置
  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.'不存在了,請設(shè)置病毒感染文件'
   );
   echo $array[$number];
  }
    
 }
 $virus =new clear_virus;
 $virus->open_file();
?>

上述就是小編為大家分享的使用php怎么實現(xiàn)一個網(wǎng)頁病毒清除類了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

php
AI