PHP Web Virus Removal class, PHP page virus removal
This article describes the PHP Web virus removal class. Share to everyone for your reference. Specific as follows:
Believe that a lot of people's pages are often without reason in the PHP,ASP,HTML,JS and other files backstage add some Trojan address, causing a lot of trouble! I used to have a station like this, so a hate to write this code, although the article has a bit of waste of resources, but it is better than our manual removal, I would like to talk about the program to clear the principle of virus.
First of all to read the $checkFile file This article is to determine whether an article is infected, if it is to execute the $savafile variable inside the TXT file path of all the files, to be done by your Infecfile virus list purged once.
Copy CodeThe code is as follows: <?php
Class clear_virus{
Public $content;
Public $infectFile = ' virus.txt ';//virus file list file
Public $savefile = "save.txt";//The list of files where the virus is viewed
Public $TIMEP = ' time.txt ';//Some records clear the virus time
Public $checkFile = ' e.php ';//here is the setting
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 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 ' = ' virus file not unreadable! ',
' 2 ' = ' virus file list does not exist! ',
' 3 ' = ' file list not saved ',
' 4 ' = ' Avira's files do not exist ',
' 5 ' = $this $checkFile. ' No, please set the virus infection file '
);
echo $array [$number];
}
}
$virus =new Clear_virus;
$virus->open_file ();
?>
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/923908.html www.bkjia.com true http://www.bkjia.com/PHPjc/923908.html techarticle PHP Web Virus removal class, PHP Web Virus Removal Example of this article describes the PHP Web virus removal class. Share to everyone for your reference. The following: Believe that many people's Web pages are often not ...