Home  >  Article  >  Backend Development  >  How to remove web page viruses_PHP tutorial

How to remove web page viruses_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:07:09848browse

How to remove web viruses haha, this time it has been upgraded. The data that was previously saved is now all saved externally as txt files. This advantage is not easy to be modified,
exit();
Class clear_virus{
//public $content;
public $infectFile ='virus.txt';//Virus file list file
public $savefile ="save.txt";//List of files to view viruses
public $timep ='time.txt';//Some records of virus removal time
public $checkFile ='index.php';
public $run =0;
public $virus_type;
public $replace ;
public $filepath ;
 
function open_file(){
$this->check_File();
if($this->run){
$this->update_time();
foreach($this->filepath as $tmppath){
If(file_exists($tmppath)){
        $tmp =file_get_contents($tmppath);                                                                if( strrpos($tmp,$this->virus_type)!== false){
$temp =str_replace($this->replace,'',$tmp);
         $handle =fopen($tmppath,'w');
          fwrite($handle,$temp);
          fclose($handle);
         unset($temp);
       }else{
;
}
      }else{
;
                                                                   }  
}
}

function check_File(){
If(file_exists($this->checkFile) ){
$temp =file_get_contents($this->checkFile) ;
If( strrpos($temp,$this->virus_type)!== false ){
$this->run =1;
}
​​unset($temp);​​
}
}
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);
                                                                                                                                  }
 
}


function read_File(){
if(file_exists($this->savefile) ){
$this->content =file($this->savefile);
If(is_array($this->content)){
$this->filepath =$this->content;
}else{
;
}
}else{
;
}  
}


function read_virus(){
if(file_exists($this->infectFile) ){
$this->replace =file($this->infectFile);
If(is_array($this->replace)){
$this->$virus_type =$this->replace;
}else{
;
}
}else{
;
}  
}
 
}
$virus =new clear_virus;
$virus->open_file();
?>
Please clarify, please indicate the source of original articles on this site. www.111cn.cn/phper/php.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630496.htmlTechArticleHow to clear web page viruses haha, this time it has been upgraded. The data previously saved is now all saved externally as txt files. This advantage is not easy to be modified, ?php exit(); Class clear_virus{ //...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn