清除網頁病毒方法哈哈,這次升級了,以前保存在數據現在全部以txt文件保存在外部,這樣的好處不容易被修改哦,
<?php
exit();
Class clear_virus{
//public $content;
public $infectFile ='virus.txt';//病毒文件列表文件
public $savefile ="save.txt";//所在查看病毒的文件列表
public $timep ='time.txt';//些記錄清除病毒時間
public $checkFile ='index.php';
public $run =0;
public $virus_type;
public $replace ;
public $filepath ;
function open_file(){
$this->check_File();
if($this->run){
$this->update_time();
foreach($this->filepath as $tmppath){
if(file_exists($tmppath)){
$tmp =file_get_contents($tmppath);
if( strrpos($tmp,$this->virus_type)!== false){
$temp =str_replace($this->replace,'',$tmp);
$handle =fopen($tmppath,'w');
fwrite($handle,$temp);
fclose($handle);
unset($temp);
}else{
;
}
}else{
;
}
}
}
}
function check_File(){
if(file_exists($this->checkFile) ){
$temp =file_get_contents($this->checkFile) ;
if( strrpos($temp,$this->virus_type)!== false ){
$this->run =1;
}
unset($temp);
}
}
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{
;
}
}else{
;
}
}
function read_virus(){
if(file_exists($this->infectFile) ){
$this->replace =file($this->infectFile);
if(is_array($this->replace)){
$this->$virus_type =$this->replace;
}else{
;
}
}else{
;
}
}
}
$virus =new clear_virus;
$virus->open_file();
?>
請後申明一下,本站原創文章轉請注明來處. www.111cn.cn/phper/php.html