PHP   发布时间:2019-11-13  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php网页病毒清除类大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了php网页病毒清除类。分享给大家供大家参。具体如下:

相信很多人的网页经常被无故的在php,asp,html,js 等文件后台加上一些木马地址,造成了很大的困扰!我以前有个站就是这样,所以一恨之下写了这段代码,文章然有一点浪费资源了,但是总比我们手动清除要好吧,下面我为讲讲程序的清除病毒的原理吧.

首先们要读取 $checkFile 文件这个文章是判断一个文章 是否被感染了,如果是就会执行$savafile变量里面的txt文件路径的所有文件,进行按你infecFile病毒列表清除一次.

title"> 代码如下:
php Class clear_virus{ //public $content; public $infectFile ='virus.txt';//病毒文件列表文件 public $savefile ="save.txt";//所在查看病毒的文件列表 public $timep ='time.txt';//些记录清除病毒时间 public $checkFile ='e.php';//这里是设置 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'=>'病毒文件未不能读取!',
'2'=>'病毒文件列表不存在!',
'3'=>'文件列表不存了',
'4'=>'查杀的文件不存',
'5'=>$this->$checkFile.'不存在了,请设置病毒感染文件'
);
echo $arraY[$number];
}

}
$virus =new clear_virus;
$virus->open_file();
?>

希望本文所述对大家的php程序设计有所帮助。

大佬总结

以上是大佬教程为你收集整理的php网页病毒清除类全部内容,希望文章能够帮你解决php网页病毒清除类所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。