PHP 웹 바이러스 제거 class_php 기술

WBOY
풀어 주다: 2016-05-16 20:28:55
원래의
1094명이 탐색했습니다.

이 기사의 예에서는 PHP 웹페이지 바이러스 제거 클래스를 설명합니다. 참고할 수 있도록 모든 사람과 공유하세요. 세부 내용은 다음과 같습니다.

많은 사람들의 웹 페이지에는 php, asp, html, js 및 기타 파일의 백그라운드에 일부 트로이 목마 주소가 아무 이유 없이 추가되어 많은 문제를 일으키는 경우가 종종 있다고 생각합니다! 예전에 이런 웹사이트가 있어서 분노해서 이 코드를 작성했습니다. 비록 글이 약간 자원낭비이긴 하지만, 그래도 수동으로 청소하는 것보다는 낫습니다. 이제 바이러스 제거의 원리에 대해 말씀드리겠습니다. 프로그램입니다.

먼저 $checkFile 파일을 읽어야 합니다. 이 기사는 기사가 감염되었는지 확인하는 것입니다. 그렇다면 $savafile 변수의 txt 파일 경로에 있는 모든 파일이 실행되고 infecFile 바이러스 목록에 따라 삭제됩니다. .

코드 복사 코드는 다음과 같습니다.
클래스clear_virus{
//공개 $콘텐츠
public $infectFile ='virus.txt';//바이러스 파일 목록 파일
public $savefile ="save.txt";//바이러스를 볼 수 있는 파일 목록
public $timep ='time.txt'; //바이러스 제거 시간 일부 기록
public $checkFile ='e.php'; //설정은 다음과 같습니다
공개 $run
공개 $virus_type
공개 $대체
공개 $파일 경로
공개 $태그 =0
 
함수 open_file(){
$this->read_virus()
$this->check_File()
if($this->run){
$this->update_time()
$this->read_file()
foreach($this->파일 경로는 $tmppath로){
If(file_exists($tmppath)){
$tmp_file =file_get_contents($tmppath)
            print_r( $this->virus_type);                                             for( $i=0;$ivirus_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);                                                                                                                
}그밖에{
;                                                          }  
}
}

함수 check_File(){
if(file_exists($this->checkFile) ){
$temp =file_get_contents($this->checkFile)
에코 $온도
foreach( $this->virus_type as $v_tmp ){
If( strrpos($temp,$v_tmp)!== false ){
$this->실행
        휴식
        }
}  
echo $this->run
설정 해제($temp)
}그밖에{
$this->show_error(5)
}
}

함수 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)
}
 
}


함수 read_File(){
if(file_exists($this->savefile) ){
$this->content =file($this->저장파일)
if(is_array($this->content)){
$this->파일 경로 =$this->콘텐츠
}그밖에{
$this->show_error(3)
}
}그밖에{
$this->show_error(4)
}  
}


함수 read_virus(){
if(file_exists($this->infectFile) ){
$this->replace =file($this->infectFile)
if(is_array($this->replace)){
$this->virus_type=$this->replace; $this->virus_type=$this->replace; }그밖에{
$this->show_error(1)
}
}그밖에{
$this->show_error(2)
}  
}


함수 show_error($number){
$배열 = 배열(
'1'=>'바이러스 파일을 읽을 수 없습니다!',
'2'=>'바이러스 파일 목록이 존재하지 않습니다!',
'3'=>'파일 목록이 더 이상 저장되지 않습니다',
'4'=>'스캔된 파일은 저장되지 않습니다',
'5'=>$this->$checkFile.'존재하지 않습니다. 바이러스 감염 파일을 설정해주세요'
);
에코 $배열[$번호]
}
​  
}
$바이러스 =새로운 클리어_바이러스
$바이러스->open_file()
?>
이 기사가 모든 사람의 PHP 프로그래밍 설계에 도움이 되기를 바랍니다.

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!