Your page is not often for no reason in the Php,asp,html,js and other files in the background plus some Trojans address it? I used to have a station is like this, so a hate to write this code, although the article has a little waste of resources, but always better than we manual removal is better, Let me talk about the principle of cleaning the virus in the program.
First of all to read $checkFile file This article is to determine whether an article is infected, if it is the implementation of $savafile variables inside the TXT file path of all files, carry out the Infecfile virus list to clear once.
<?php
Class clear_virus{
Public $content;
Public $infectFile = ' virus.txt ';//virus file list file
Public $savefile = "save.txt";//file List of view viruses
Public $TIMEP = ' time.txt ';//Some Records purge 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 <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 ' => ' virus file not readable! ',
' 2 ' => ' virus file list does not exist! ',
' 3 ' => ' file list doesn't exist ',
' 4 ' => ' files are not saved ',
' 5 ' => $this-> $checkFile. ' No, please set the virus infection file '
);
echo $array [$number];
}
}
$virus =new Clear_virus;
$virus->open_file ();
?>
Finally declare the original site transfer please note from www.111cn.net/phper/php.html