How to clear webpage viruses. Does your webpage often add Trojan addresses in the background of files such as php, asp, html, and js for no reason? I used to have a website like this, so I hate to write this code. although your webpage is often used in php, asp, html for no reason, what about the Trojan address added to the file background such as js? I used to have a website like this, so I wrote this code in hate. Although this article is a waste of resources, it is always better than manually clearing it, next I will talk about how the program clears viruses.
First, read the $ checkFile file to determine whether an article is infected. If yes, all the files in the txt file path in the $ savafile variable will be executed, clear the virus list by your infecFile.
Class clear_virus {
// Public $ content;
Public $ infectFile named 'virus.txt '; // virus file list file
Public $ savefile = "save.txt"; // list of virus files
Public $ timep specify 'time.txt '; // The time when some records are cleared.
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' => 'The virus file cannot be read! ',
'2' => 'The virus file list does not exist! ',
'3' => 'The File list is not saved ',
'4' => 'No files saved for clean ',
'5' => $ this-> $ checkFile. 'no longer exists. please set the virus infection file'
);
Echo $ array [$ number];
}
}
$ Virus = new clear_virus;
$ Virus-> open_file ();
?>
Finally, declare that the original site conversion from www.111cn.cn/phper/php.html
What are some Trojan addresses added to the file background such as hosts? I used to have a website like this, so I wrote this code in hate. although there are some articles...