国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php網頁病毒清除類

2024-05-04 23:28:41
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了php網頁病毒清除類,可實現針對網頁病毒的簡單清理功能,是非常實用的技巧,需要的朋友可以參考下
 
 

本文實例講述了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程序設計有所幫助。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 文安县| 朝阳市| 大名县| 锦州市| 成安县| 吉隆县| 改则县| 长子县| 马山县| 县级市| 宝鸡市| 广丰县| 柳江县| 逊克县| 和林格尔县| 青龙| 措美县| 老河口市| 沙坪坝区| 阿拉善左旗| 仲巴县| 东宁县| 边坝县| 广平县| 隆化县| 莱芜市| 祁阳县| 福贡县| 平陆县| 高安市| 西和县| 柯坪县| 永靖县| 双辽市| 义马市| 桑植县| 贵港市| 宜阳县| 嘉善县| 体育| 扶绥县|