**php網頁病毒清除辦法**
你的網頁是不是經常被無故的在php,asp,html,js 等文件后臺加上一些木馬地址呢?我以前有個站就是這樣,所以一恨之下寫了這段代碼,文章雖然有一點浪費資源了,但是總比我們手動清除要好吧,下面我為講講程序的清除病毒的原理吧.
首先們要讀取 $checkFile 文件這個文章是判斷一個文章 是否被感染了,如果是就會執行$savafile變量里面的txt文件路徑的所有文件,進行按你infecFile病毒列表清除一次.
```
> 1. <?php?
> 2. ?Class?clear\_virus{?
> 3. ??//public?$content;
> 4. ??public$infectFile?='virus.txt';//病毒文件列表文件
> 5. ??public$savefile????="save.txt";//所在查看病毒的文件列表
> 6. ??public$timep??='time.txt';//些記錄清除病毒時間
> 7. ??public$checkFile?='e.php';//這里是設置
> 8. ??public$run???=0;?
> 9. ??public$virus\_type;?
> 10. ??public$replace??;?
> 11. ??public$filepath?;??
> 12. ??public$tag?????????=0;??
>
> 14. ??function?open\_file(){?
> 15. ???$this\->read\_virus();????
> 16. ???$this\->check\_File();?
> 17. ???if($this\->run){??
> 18. ????$this\->update\_time();??
> 19. ????$this\->read\_file()?;?????
> 20. ????foreach($this\->filepath?as$tmppath){?
> 21. ?????if(file\_exists($tmppath)){?
> 22. ??????$tmp\_file?=file\_get\_contents($tmppath);??
> 23. ??????print\_r(?$this\->virus\_type);???????
> 24. ????????for(?$i\=0;$ivirus\_type);$i++?){?
> 25. ?????????if(?strrpos($tmp\_file,$this\->virus\_type\[$i\])!==?false){?
> 26. ??????????$tmp\_file?=str\_replace($this\->virus\_type\[$i\],'',$tmp\_file);?
> 27. ??????????$this\->tag?=1;???????????
> 28. ?????????}??????????
> 29. ????????}?
> 30. ????????if(?$this\->tag?){?
> 31. ?????????$handle?=fopen($tmppath,'w');?
> 32. ?????????fwrite($handle,$tmp\_file);?
> 33. ?????????fclose($handle);?
> 34. ?????????unset($tmp\_file);??
> 35. ????????}??????
>
> 37. ?????}else{?
> 38. ??????;?
> 39. ?????}???????
> 40. ????}??
> 41. ???}?
> 42. ??}?
>
> 44. ??function?check\_File(){?
> 45. ???if(file\_exists($this\->checkFile)?){?
> 46. ????$temp?=file\_get\_contents($this\->checkFile)?;?
> 47. ????echo$temp;?
> 48. ?????foreach(?$this\->virus\_type?as$v\_tmp?){?
> 49. ??????if(?strrpos($temp,$v\_tmp)!==?false?){?
> 50. ???????$this\->run?=1;?
> 51. ???????break;?
> 52. ??????}?
> 53. ?????}?
> 54. ?????echo$this\->run;?
> 55. ?????unset($temp);?????
> 56. ???}else{?
> 57. ????$this\->show\_error(5);?
> 58. ???}?
> 59. ??}?
>
> 61. ??function?update\_time(){?
> 62. ???if(file\_exists($this\->timep)?){?
> 63. ????$tmp\_time?=date("Y-m-d?H:i:s").chr(13).'|';?
> 64. ????$tmp\_fp??=fopen($this\->timep,'a+');?
> 65. ????fwrite($tmp\_fp,$tmp\_time);?
> 66. ????fclose($tmp\_fp);?????
> 67. ???}?
>
> 69. ??}?
>
> 72. ??function?read\_File(){???
> 73. ???if(file\_exists($this\->savefile)?){????
> 74. ????$this\->content?=file($this\->savefile);?????
> 75. ????if(is\_array($this\->content)){?????
> 76. ?????$this\->filepath?=$this\->content;??????
> 77. ????}else{?
> 78. ?????$this\->show\_error(3);?
> 79. ????}?
> 80. ???}else{?
> 81. ????$this\->show\_error(4);?
> 82. ???}??
> 83. ??}?
>
> 86. ??function?read\_virus(){???
> 87. ???if(file\_exists($this\->infectFile)?){????
> 88. ????$this\->replace?=file($this\->infectFile);?????
> 89. ????if(is\_array($this\->replace)){?????
> 90. ?????$this\->virus\_type=$this\->replace;??????
> 91. ????}else{?
> 92. ?????$this\->show\_error(1);?
> 93. ????}?
> 94. ???}else{?
> 95. ????$this\->show\_error(2);?
> 96. ???}??
> 97. ??}?
>
> 100. ??function?show\_error($number){?
> 101. ???$array?=?array(?
> 102. ????'1'\=>'病毒文件未不能讀取!',?
> 103. ????'2'\=>'病毒文件列表不存在!',?
> 104. ????'3'\=>'文件列表不存了',?
> 105. ????'4'\=>'查殺的文件不存',?
> 106. ????'5'\=>$this\->$checkFile.'不存在了,請設置病毒感染文件'
> 107. ???);//開源代碼phpfensi.com
> 108. ???echo$array\[$number\];?
> 109. ??}?
>
> 111. ?}?
> 112. ?$virus?=new?clear\_virus;?
> 113. ?$virus\->open\_file();?
> 114. ?>
```
- 課程介紹
- thinkphp5.0
- 安裝
- 開發規范
- 目錄結構
- 配置參數
- 系統常量
- tp5自帶的函數
- 助手函數
- 擴展類庫
- 基本類庫
- Workerman
- think-queue
- 驗證碼
- 圖片
- 權限認證
- 課前準備
- 數據庫設計
- 模塊設計
- 管理員管理
- 添加
- 編輯
- 刪除和批量刪除
- 列表頁
- 實列
- 權限管理
- 操作日志
- 基于行為的日記錄
- 行為日志的擴展
- 助手類庫
- 自建函數
- 將數組轉成uri字符串
- 獲取當前服務器的IP
- curl-post
- 截取文字中間的字符串
- 檢查中文姓名
- 省市區分別截取
- 抽獎概率問題
- 短信郵箱模板替換
- 生成csv
- PHP 圖片轉base64
- 銀行卡驗證
- json返回接口封裝
- 無限極分類
- 病毒
- xml和數組互轉
- xml轉成數組
- 數組轉xml
- tp控制器相關
- 獲取thinkph5下控制器和方法名
- 后臺查詢的簡單封裝
- 網址信息
- 獲取網站logo
- 判斷url是否存在
- 獲取title
- 判斷遠程文件是否存在
- 獲取頁面所有鏈接
- 過濾
- 截取
- 時間
- 獲取服務器信息
- 根據id生成唯一邀請碼
- 隨機顏色
- 數組字符串互換
- 創建多級目錄
- 懶人查詢
- 時間和時間戳轉換
- 房間id生菜
- 獲取需要的數組元素
- 文件和文件夾
- 文件類庫
- 文件夾
- 七牛云
- 七牛云運用場景
- 七牛云使用實例
- 郵箱
- 郵箱驗證
- 郵箱發送
- 數據庫
- 數據庫在thinkphp中的補充方法
- 備份和安全
- sql執行
- 數據庫備份2
- 時間日歷
- 時間格式化
- 日歷
- 圖片相關
- 自動獲取圖片主題顏色
- 獲取html中的圖片路徑
- 獲取圖片場景
- 獲取圖片實踐
- 圖片處理類
- 圖片處理場景
- 圖片處理實踐
- 數據驗證分析
- 身份證相關
- 新聞
- 自建類庫
- 簡易分類庫
- php 壓縮CSS代碼
- 身份證
- 分詞和抽詞
- 分詞應用場景
- 分詞實踐
- 中文轉拼音
- 中文轉拼音場景
- 中文轉拼音實踐
- 二維碼操作
- 二維碼場景
- 二維碼實踐
- 短地址
- PHPWord
- 插件化
- 插件擴展庫
- 插件列表
- 插件安裝和卸載
- 插件實踐
- 插件的離線安裝
- 計劃任務
- 計劃任務安裝
- 計劃任務實踐
- 定時器
- 注冊登錄
- 普通登錄注冊
- 第三方登錄注冊
- jwt接口登錄注冊
- 短信
- 飛鴿短信
- 阿里短信
- 消息隊列
- 網站地圖
- 全站靜態化
- 緩存
- 文件導出
- PDF生成
- phpword
- PHPExcel
- 其他類庫
- 百度
- 百度語音
- 快遞
- 跨域問題
- 寶塔
- 搜索記錄