Subversion Repositories php-qbpwcf

Rev

Rev 165 | Rev 198 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 165 Rev 168
Line 22673... Line 22673...
22673
 
22673
 
22674
			#回傳結果
22674
			#回傳結果
22675
			return $result;
22675
			return $result;
22676
 
22676
 
22677
			}#if end
22677
			}#if end
22678
	
22678
		
22679
		#取得 http 存取記錄的 log
22679
		#取得 http 存取記錄的 log
22680
		#函式說明:
22680
		#函式說明:
22681
		#檢查指令的輸出是否含有關鍵字
22681
		#檢查指令的輸出是否含有關鍵字
22682
		#回傳結果:
22682
		#回傳結果:
22683
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
22683
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 22734... Line 22734...
22734
			#回傳結果
22734
			#回傳結果
22735
			return $result;
22735
			return $result;
22736
		
22736
		
22737
			}#if end
22737
			}#if end
22738
		
22738
		
22739
		#如果不是只抓清單
-
 
22740
		if($conf["getIplistOnly"]==="false"){
-
 
22741
		
-
 
22742
			#清空 access_log
-
 
22743
			#函式說明:
-
 
22744
			#將檔案內容清空
-
 
22745
			#回傳結果:
-
 
22746
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
-
 
22747
			#$result["error"],錯誤訊息陣列
-
 
22748
			#必填參數:
-
 
22749
			#$conf["fileAddr"],字串,要清空的檔案位置與名稱.
-
 
22750
			$conf["fileAccess::emptyFile"]["fileAddr"]=$conf["logPath"]."/access_log";
-
 
22751
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
22752
			$conf["fileAccess::emptyFile"]["fileArgu"]=$conf["fileArgu"];
-
 
22753
			#可省略參數:
-
 
22754
			#可省略參數:
-
 
22755
			#$conf["web"],"true"代表為網頁系統,"false"代表檔案系統,預設為"false".
-
 
22756
			$conf["fileAccess::emptyFile"]["web"]="false";
-
 
22757
			$emptyFile=fileAccess::emptyFile($conf["fileAccess::emptyFile"]);
-
 
22758
			unset($conf["fileAccess::emptyFile"]);
-
 
22759
			
-
 
22760
			#如果執行失敗
-
 
22761
			if($emptyFile["status"]==="false"){
-
 
22762
			
-
 
22763
				#設置執行失敗
-
 
22764
				$result["status"]="false";
-
 
22765
 
-
 
22766
				#設置錯誤訊息
-
 
22767
				$result["error"]=$emptyFile;
-
 
22768
 
-
 
22769
				#回傳結果
-
 
22770
				return $result;
-
 
22771
			
-
 
22772
				}#if end
-
 
22773
			
-
 
22774
			}#if end
-
 
22775
		
-
 
22776
		#過濾掉對於含有 ".css" ".js" "favicon.ico" ".jpg" ".png" 關鍵字串的結果.  	
22739
		#過濾掉對於含有 ".css" ".js" "favicon.ico" ".jpg" ".png" 關鍵字串的結果.  	
22777
		#函式說明:
22740
		#函式說明:
22778
		#檢查多個字串中的每個字串是否有多個關鍵字
22741
		#檢查多個字串中的每個字串是否有多個關鍵字
22779
		#回傳的結果:
22742
		#回傳的結果:
22780
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
22743
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
Line 22996... Line 22959...
22996
 
22959
 
22997
			#回傳結果
22960
			#回傳結果
22998
			return $result;
22961
			return $result;
22999
		
22962
		
23000
			}#if end
22963
			}#if end
23001
				
-
 
23002
		#如果不是只抓清單
-
 
23003
		if($conf["getIplistOnly"]==="false"){
-
 
23004
		
-
 
23005
			#清空 ssl_access_log
-
 
23006
			#函式說明:
-
 
23007
			#將檔案內容清空
-
 
23008
			#回傳結果:
-
 
23009
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
-
 
23010
			#$result["error"],錯誤訊息陣列
-
 
23011
			#必填參數:
-
 
23012
			#$conf["fileAddr"],字串,要清空的檔案位置與名稱.
-
 
23013
			$conf["fileAccess::emptyFile"]["fileAddr"]=$conf["logPath"]."/ssl_access_log";
-
 
23014
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
23015
			$conf["fileAccess::emptyFile"]["fileArgu"]=$conf["fileArgu"];
-
 
23016
			#可省略參數:
-
 
23017
			#無
-
 
23018
			$emptyFile=fileAccess::emptyFile($conf["fileAccess::emptyFile"]);
-
 
23019
			unset($conf["fileAccess::emptyFile"]);
-
 
23020
			
-
 
23021
			#如果執行失敗
-
 
23022
			if($emptyFile["status"]==="false"){
-
 
23023
			
-
 
23024
				#設置執行失敗
-
 
23025
				$result["status"]="false";
-
 
23026
 
-
 
23027
				#設置錯誤訊息
-
 
23028
				$result["error"]=$emptyFile;
-
 
23029
 
-
 
23030
				#回傳結果
-
 
23031
				return $result;
-
 
23032
			
-
 
23033
				}#if end
-
 
23034
				
-
 
23035
			}#if end
-
 
23036
		
22964
		
23037
		#過濾掉對於含有 ".css",".js","favicon.ico",".jpg",".png" 關鍵字串的結果.  	
22965
		#過濾掉對於含有 ".css",".js","favicon.ico",".jpg",".png" 關鍵字串的結果.  	
23038
		#函式說明:
22966
		#函式說明:
23039
		#檢查多個字串中的每個字串是否有多個關鍵字
22967
		#檢查多個字串中的每個字串是否有多個關鍵字
23040
		#回傳的結果:
22968
		#回傳的結果:
Line 23216... Line 23144...
23216
		#$result["statusCode"],執行結束後的代碼.
23144
		#$result["statusCode"],執行結束後的代碼.
23217
		#必填參數:
23145
		#必填參數:
23218
		#$conf["command"],字串,要執行的指令與.
23146
		#$conf["command"],字串,要執行的指令與.
23219
		$conf["external::callShell"]["command"]="journalctl";
23147
		$conf["external::callShell"]["command"]="journalctl";
23220
		#$conf["fileArgu"],字串,變數__FILE__的內容.
23148
		#$conf["fileArgu"],字串,變數__FILE__的內容.
23221
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
23149
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
23222
		#可省略參數:
23150
		#可省略參數:
23223
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
23151
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
23224
		$conf["external::callShell"]["argu"]=array("-a","-e","--unit=postfix.service","|","grep","SASL LOGIN authentication failed");
23152
		$conf["external::callShell"]["argu"]=array("-a","-e","--unit=postfix.service","|","grep","SASL LOGIN authentication failed");
23225
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
23153
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函式的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
23226
		#$conf["arguIsAddr"]=array();	
23154
		#$conf["arguIsAddr"]=array();	
Line 24834... Line 24762...
24834
				
24762
				
24835
				}#if end
24763
				}#if end
24836
			
24764
			
24837
			#針對每行分割出來的內容
24765
			#針對每行分割出來的內容
24838
			for($i=0;$i<$searchOutPut["count"];$i++){
24766
			for($i=0;$i<$searchOutPut["count"];$i++){
24839
										
24767
			
24840
				#如果不存在 IP
24768
				#如果不存在 IP
24841
				if(!isset($spiltMutiString["spiltString"][$i]["dataArray"][3])){
24769
				if(!isset($spiltMutiString["spiltString"][$i]["dataArray"][3])){
24842
				
24770
				
24843
					#跳過
24771
					#跳過
24844
					continue;
24772
					continue;
Line 24951... Line 24879...
24951
				#無.
24879
				#無.
24952
				$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
24880
				$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
24953
				unset($conf["search::getEqualVar"]);
24881
				unset($conf["search::getEqualVar"]);
24954
			
24882
			
24955
				#如果執行失敗
24883
				#如果執行失敗
24956
				if($getEqualVar["status"]==="false")
24884
				if($getEqualVar["status"]==="false"){
24957
				{
24885
				
24958
					#設置執行失敗
24886
					#設置執行失敗
24959
					$result["status"]="false";
24887
					$result["status"]="false";
24960
 
24888
 
24961
					#設置錯誤訊息
24889
					#設置錯誤訊息
24962
					$result["error"]=$getEqualVar;
24890
					$result["error"]=$getEqualVar;
24963
 
24891
 
24964
					#回傳結果
24892
					#回傳結果
24965
					return $result;
24893
					return $result;
24966
				
24894
				
24967
				}#if end
24895
					}#if end
24968
			
24896
			
24969
				#如果在白名單ip裡面
24897
				#如果在白名單ip裡面
24970
				if($getEqualVar["founded"]==="true")
24898
				if($getEqualVar["founded"]==="true"){
24971
				{
-
 
24972
				
24899
				
24973
					#跳過該ip
24900
					#跳過該ip
24974
					continue;
24901
					continue;
24975
				
24902
				
24976
				}#if end
24903
					}#if end
24977
			
24904
			
24978
				#如果不是要動態阻擋
24905
				#如果不是要動態阻擋
24979
				if($conf["dynamic"]==="false"){
24906
				if($conf["dynamic"]==="false"){
24980
				
24907
				
24981
					#函式說明:
24908
					#函式說明:
Line 25134... Line 25061...
25134
		#反之
25061
		#反之
25135
		else{
25062
		else{
25136
		
25063
		
25137
			#取得有問題的IP資訊清單
25064
			#取得有問題的IP資訊清單
25138
			$result["content"]=$ips_to_block;
25065
			$result["content"]=$ips_to_block;
25139
					
25066
			
25140
			}#else end
25067
			}#else end
25141
			
25068
			
25142
		#設置執行正常
25069
		#設置執行正常
25143
		$result["status"]="true";
25070
		$result["status"]="true";
25144
 
25071