Webpage Virus Removal Method _php Tutorial

Source: Internet
Author: User
Your Web page is not often without reason in the Php,asp,html,js and other file backstage add some Trojan address it? I used to have a station like this, so a hate to write this code, although the article has a little waste of resources, but it is better than our manual removal, Let me tell you how to clean up the virus in the program.

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.

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 ();
?>
The final statement of the original site transfer please indicate from www.111cn.cn/phper/php.html

http://www.bkjia.com/PHPjc/629746.html www.bkjia.com true http://www.bkjia.com/PHPjc/629746.html techarticle your Web page is not often without reason in the Php,asp,html,js and other file backstage add some Trojan address it? I used to have a station like this, so a hate to write this code, although the article has ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.