php web virus removal category, php web virus removal
The example in this article describes the PHP web page virus removal class. Share it with everyone for your reference. The details are as follows:
I believe that many people’s web pages are often added with some Trojan addresses in the background of php, asp, html, js and other files for no reason, causing a lot of trouble! I used to have a website like this, so I wrote this code out of anger. Although the article is a bit of a waste of resources, it is still better than cleaning it manually. Now I will talk about the principle of virus removal through the program.
First we need to read the $checkFile file. This article is to determine whether an article is infected. If so, all files in the txt file path in the $savafile variable will be executed and cleared according to your infecFile virus list.
Copy code The code is as follows:
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 ='e.php';//Here are the settings
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;$ivirus_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; $this->virus_type=$this->replace;
}else{
$this->show_error(1);
}
}else{
$this->show_error(2);
}
}
function show_error($number){
$array = array(
'1'=>'The virus file cannot be read!',
'2'=>'The virus file list does not exist!',
'3'=>'The file list is no longer saved',
'4'=>'The scanned files are not saved',
'5'=>$this->$checkFile.'Does not exist, please set the virus infection file'
);
echo $array[$number];
}
}
$virus =new clear_virus;
$virus->open_file();
?>
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/923908.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/923908.htmlTechArticlephp web virus removal class, php web virus removal This article describes the php web virus removal class with examples. Share it with everyone for your reference. The details are as follows: I believe that many people’s web pages are often deleted...