Subversion Repositories php-qbpwcf

Rev

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

Rev 66 Rev 218
Line 3595... Line 3595...
3595
				
3595
				
3596
				}#if end
3596
				}#if end
3597
				
3597
				
3598
			#取得類別圖表格htmlCode
3598
			#取得類別圖表格htmlCode
3599
			$result["diagramCode"][]=$classDiagram["diagramCode"][$i]["diagramCode"];	
3599
			$result["diagramCode"][]=$classDiagram["diagramCode"][$i]["diagramCode"];	
3600
						
3600
			
3601
			}#for end
3601
			}#for end
3602
			
3602
			
3603
		#執行到這邊代表執行成功
3603
		#執行到這邊代表執行成功
3604
		$result["status"]="true";
3604
		$result["status"]="true";
3605
		
3605
		
Line 3608... Line 3608...
3608
		
3608
		
3609
		}#function classDiagramsMaker end
3609
		}#function classDiagramsMaker end
3610
		
3610
		
3611
	/*
3611
	/*
3612
	#函式說明:
3612
	#函式說明:
3613
	#更新程式檔案開頭版權宣告的年份
3613
	#更新程式檔案開頭版權宣告的年份,以及作者清單.
3614
	#回傳結果:
3614
	#回傳結果:
3615
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3615
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3616
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
3616
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
3617
	#$result["function"],當前執行的函式名稱.
3617
	#$result["function"],當前執行的函式名稱.
-
 
3618
	#$result["argu"],本函式使用的參數.
3618
	#$result["content"],有更新的檔案清單,其元素有被取代的檔案路徑與名稱跟replacedInfo,其中replacedInfo為陣列,其key為要變動的行號(從0開始算),其數值有"from"代表要被取代的原始內容,"to"代表要置換成的新內容.
3619
	#$result["content"],有更新的檔案清單,其元素有被取代的檔案路徑與名稱跟replacedInfo,其中replacedInfo為陣列,其key為要變動的行號(從0開始算),其數值有"from"代表要被取代的原始內容,"to"代表要置換成的新內容.
3619
	#$result["scannedFile"],陣列,有檢查過的檔案清單其完整路徑與檔案名稱.
3620
	#$result["scannedFile"],陣列,有檢查過的檔案清單其完整路徑與檔案名稱.
3620
	#必填參數:
3621
	#必填參數:
3621
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3622
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3622
	$conf["fileArgu"]=__FILE__;
3623
	$conf["fileArgu"]=__FILE__;
Line 3625... Line 3626...
3625
	#$conf["replaceFrom"]=array();
3626
	#$conf["replaceFrom"]=array();
3626
	#$conf["yearFrom],字串,起始年份,預設為西元"2014"年.
3627
	#$conf["yearFrom],字串,起始年份,預設為西元"2014"年.
3627
	#$conf["yearFrom"]="2014";
3628
	#$conf["yearFrom"]="2014";
3628
	#$conf["yearTo],字串,結束年份,預設為西元"gmdate('Y')"年.
3629
	#$conf["yearTo],字串,結束年份,預設為西元"gmdate('Y')"年.
3629
	#$conf["yearTo"]=gmdate('Y');
3630
	#$conf["yearTo"]=gmdate('Y');
3630
	#$conf["Authors"],陣列,該套件的參與者,預設為array("Min-Jhin,Chen");
3631
	#$conf["Authors"],陣列,該套件的參與者,預設為array("MIN-ZHI, CHEN");
3631
	#$conf["Authors"]=array("Min-Jhin,Chen");
3632
	#$conf["Authors"]=array("MIN-ZHI, CHEN");
3632
	#$conf["searchPath"],陣列,要搜尋哪些地方的檔案要更新版權宣告年份,預設為使用中的本套件位置.
3633
	#$conf["searchPath"],陣列,要搜尋哪些地方的檔案要更新版權宣告年份,預設為使用中的本套件位置.
3633
	#$conf["searchPath"]=array("");
3634
	#$conf["searchPath"]=array("");
3634
	#$conf["skipHiddenFolder"],字串,要略過隱藏的資料夾,預設為"true";反之為"false";
3635
	#$conf["skipHiddenFolder"],字串,要略過隱藏的資料夾,預設為"true";反之為"false";
3635
	#$conf["skipHiddenFolder"]="true";
3636
	#$conf["skipHiddenFolder"]="true";
3636
	#$conf["includeHiddenFolder"],陣列,符合名稱的隱藏資料夾會存取,預設不指定;
3637
	#$conf["includeHiddenFolder"],陣列,符合名稱的隱藏資料夾會存取,預設不指定;
Line 3650... Line 3651...
3650
	#$conf["log"],字串,log的檔案位置與名稱,預設不使用.
3651
	#$conf["log"],字串,log的檔案位置與名稱,預設不使用.
3651
	#$conf["log"]="";
3652
	#$conf["log"]="";
3652
	#參考資料:
3653
	#參考資料:
3653
	#無.
3654
	#無.
3654
	#備註:
3655
	#備註:
3655
	#無.
3656
	#建構中...
3656
	*/
3657
	*/
3657
	public static function updateCopyRightYear(&$conf){
3658
	public static function updateCopyRightYear(&$conf){
3658
	
3659
	
3659
		#初始化要回傳的結果
3660
		#初始化要回傳的結果
3660
		$result=array();
3661
		$result=array();
Line 3676... Line 3677...
3676
 
3677
 
3677
			}#if end
3678
			}#if end
3678
 
3679
 
3679
		#取得參數
3680
		#取得參數
3680
		$result["argu"]=$conf;
3681
		$result["argu"]=$conf;
-
 
3682
		
-
 
3683
		#debug,break point.
-
 
3684
		#var_dump(__LINE__,$result);exit(1);
3681
 
3685
 
3682
		#如果 $conf 不為陣列
3686
		#如果 $conf 不為陣列
3683
		if(gettype($conf)!=="array"){
3687
		if(gettype($conf)!=="array"){
3684
 
3688
 
3685
			#設置執行失敗
3689
			#設置執行失敗
Line 3722... Line 3726...
3722
		#備註:
3726
		#備註:
3723
		#無.
3727
		#無.
3724
		$getFileAddressAndNameAndFileExtention=fileAccess::getFileAddressAndNameAndFileExtention($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
3728
		$getFileAddressAndNameAndFileExtention=fileAccess::getFileAddressAndNameAndFileExtention($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
3725
		unset($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
3729
		unset($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
3726
		
3730
		
-
 
3731
		#debug,break point.
3727
		#var_dump($getFileAddressAndNameAndFileExtention);exit;
3732
		#var_dump(__LINE__,$getFileAddressAndNameAndFileExtention);exit;
3728
		
3733
		
3729
		#如果執行失敗
3734
		#如果執行失敗
3730
		if($getFileAddressAndNameAndFileExtention["status"]==="false"){
3735
		if($getFileAddressAndNameAndFileExtention["status"]==="false"){
3731
			
3736
			
3732
			#設置錯誤識別
3737
			#設置錯誤識別
Line 3742... Line 3747...
3742
		
3747
		
3743
		#初始化有異動的檔案清單
3748
		#初始化有異動的檔案清單
3744
		$result["content"]=array();
3749
		$result["content"]=array();
3745
		
3750
		
3746
		#取得當前使用套件的路徑
3751
		#取得當前使用套件的路徑
3747
		$libPath=$getFileAddressAndNameAndFileExtention["filePath"]."../";
3752
		$libPath=$getFileAddressAndNameAndFileExtention["filePath"]."../../../";
-
 
3753
		
-
 
3754
		#debug,break point.
-
 
3755
		#var_dump(__LINE__,$libPath);exit(1);
3748
		
3756
		
3749
		#函式說明:
3757
		#函式說明:
3750
		#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
3758
		#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
3751
		#回傳結果:
3759
		#回傳結果:
3752
		#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
3760
		#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
Line 3782... Line 3790...
3782
			}#if end
3790
			}#if end
3783
		
3791
		
3784
		#取得直觀的絕對路徑
3792
		#取得直觀的絕對路徑
3785
		$libPath=$changeDirByDotDotSolidus["changedPath"];
3793
		$libPath=$changeDirByDotDotSolidus["changedPath"];
3786
		
3794
		
-
 
3795
		#debug
-
 
3796
		#var_dump(__LINE__,$libPath);exit(1);
-
 
3797
		
3787
		#設置要取代的內容關鍵字陣列 - start
3798
		#設置要取代的內容關鍵字陣列 - start
3788
		
3799
		
3789
		$replaceFromArray=array();
3800
		$replaceFromArray=array();
3790
		
3801
		
3791
		$replaceFromArray[]="        QBPWCF, Quick Build PHP website Component base on Fedora Linux.";
3802
		$replaceFromArray[]="        QBPWCF, Quick Build PHP website Component base on Fedora Linux.";
Line 3861... Line 3872...
3861
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3872
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3862
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("replaceFrom","yearFrom","yearTo","Authors","searchPath","skipHiddenFolder","includeHiddenFolder","excludeDirName","excludeMineType","excludeSecondName","multiThread","log","threadType","socket");
3873
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("replaceFrom","yearFrom","yearTo","Authors","searchPath","skipHiddenFolder","includeHiddenFolder","excludeDirName","excludeMineType","excludeSecondName","multiThread","log","threadType","socket");
3863
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
3874
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
3864
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string","array","array","string","array","array","array","array","string","string","string","string");
3875
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string","array","array","string","array","array","array","array","string","string","string","string");
3865
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3876
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3866
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array($replaceFromArray,"2014",gmdate("Y"),array("Min-Jhin,Chen"),array($libPath),"true",null,array("free-lib","non-free-lib","composer"),array("image/*","video/*","audio/*","media/*","application/*"),array("log","csv","sql","js","css","html"),"false",null,"socket",qbpwcf_usock_path);
3877
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array($replaceFromArray,"2014",gmdate("Y"),array("MIN-ZHI, CHEN"),array($libPath),"true",null,array("free-lib","non-free-lib","composer"),array("image/*","video/*","audio/*","media/*","application/*"),array("log","csv","sql","js","css","html"),"false",null,"socket",qbpwcf_usock_path);
3867
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
3878
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
3868
		#$conf["variableCheck::checkArguments"]["disallowAllSkipableVarIsEmpty"]="true";
3879
		#$conf["variableCheck::checkArguments"]["disallowAllSkipableVarIsEmpty"]="true";
3869
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
3880
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
3870
		#$conf["variableCheck::checkArguments"]["disallowAllSkipableVarIsEmptyArray"]="true";
3881
		#$conf["variableCheck::checkArguments"]["disallowAllSkipableVarIsEmptyArray"]="true";
3871
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
3882
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
Line 3939... Line 3950...
3939
		$uuid=$uuid["content"];
3950
		$uuid=$uuid["content"];
3940
		
3951
		
3941
		#針對 $conf["searchPath"] 的每個路徑
3952
		#針對 $conf["searchPath"] 的每個路徑
3942
		foreach($conf["searchPath"] as $path){
3953
		foreach($conf["searchPath"] as $path){
3943
		
3954
		
-
 
3955
			#debug
-
 
3956
			var_dump(__LINE__,"searching path:".$path);
-
 
3957
		
3944
			#取得 $path 底下的所有檔案.
3958
			#取得 $path 底下的所有檔案.
3945
			#函式說明:
3959
			#函式說明:
3946
			#取得目錄底下的詳細資訊.
3960
			#取得目錄底下的詳細資訊.
3947
			#回傳結果:
3961
			#回傳結果:
3948
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3962
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 4088... Line 4102...
4088
							}#if end
4102
							}#if end
4089
							
4103
							
4090
						#記錄有掃描的資料夾路徑與名稱 
4104
						#記錄有掃描的資料夾路徑與名稱 
4091
						$result["scannedFile"][]=$NodePathAndName;
4105
						$result["scannedFile"][]=$NodePathAndName;
4092
						
4106
						
-
 
4107
						#debug
-
 
4108
						var_dump(__LINE__,"seartched node:".$NodePathAndName);
-
 
4109
						
4093
						#合併 content - start
4110
						#合併 content - start
4094
						
4111
						
4095
						#函式說明:
4112
						#函式說明:
4096
						#將多個一維陣列串聯起來,key從0開始排序.
4113
						#將多個一維陣列串聯起來,key從0開始排序.
4097
						#回傳的結果:
4114
						#回傳的結果:
Line 4224... Line 4241...
4224
 
4241
 
4225
#使用命名空間qbpwcf
4242
#使用命名空間qbpwcf
4226
namespace qbpwcf;
4243
namespace qbpwcf;
4227
 
4244
 
4228
#匯入套件
4245
#匯入套件
-
 
4246
PHP;
-
 
4247
 
-
 
4248
						#匯入套件的路徑
4229
require_once("qbpwcf/allInOne.php");
4249
						$cmdString=$cmdString.PHP_EOL."require_once(\"".$libPath."/qbpwcf/allInOne.php\");";
-
 
4250
 
-
 
4251
						#要執行的php程式內容,設定建議的 log 位置.
-
 
4252
						$cmdString=$cmdString.PHP_EOL.<<<'PHP'
4230
 
4253
 
4231
#建議的log位置
4254
#建議的log位置
4232
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
4255
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
4233
 
4256
 
4234
PHP;
4257
PHP;
Line 4288... Line 4311...
4288
PHP;
4311
PHP;
4289
					
4312
					
4290
						#設置多執行序的類型
4313
						#設置多執行序的類型
4291
						$threadType=$conf["threadType"];
4314
						$threadType=$conf["threadType"];
4292
						
4315
						
-
 
4316
						#debug,break point
-
 
4317
						var_dump(__LINE__,$threadType);exit(1);
-
 
4318
						
4293
						#判斷多執行序的類型
4319
						#判斷多執行序的類型
4294
						switch($threadType){
4320
						switch($threadType){
4295
						
4321
						
4296
							#若是直接用 proc
4322
							#若是直接用 proc
4297
							case "proc":
4323
							case "proc":
Line 4419... Line 4445...
4419
								
4445
								
4420
									#設置錯誤識別
4446
									#設置錯誤識別
4421
									$result["status"]="false";
4447
									$result["status"]="false";
4422
									
4448
									
4423
									#設置錯誤訊息
4449
									#設置錯誤訊息
4424
									$result["error"]=$proc;
4450
									$result["error"]=$socket;
4425
									
4451
									
4426
									#回傳結果
4452
									#回傳結果
4427
									return $result;
4453
									return $result;
4428
								
4454
								
4429
									}#if end
4455
									}#if end
Line 4555... Line 4581...
4555
						
4581
						
4556
							}#if end
4582
							}#if end
4557
					
4583
					
4558
						}#if end
4584
						}#if end
4559
					
4585
					
4560
					#debug
-
 
4561
					#var_dump(__LINE__,$NodePathAndName,$node["mimeType"]);
-
 
4562
				
-
 
4563
					#記錄有掃描的檔案路徑與名稱 
4586
					#記錄有掃描的檔案路徑與名稱 
4564
					$result["scannedFile"][]=$NodePathAndName;
4587
					$result["scannedFile"][]=$NodePathAndName;
4565
				
-
 
4566
					#取得檔案的內容
-
 
4567
					#函式說明:
-
 
4568
					#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
-
 
4569
					#回傳的變數說明:
-
 
4570
					#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
-
 
4571
					#$result["error"],錯誤訊息提示.
-
 
4572
					#$result["warning"],警告訊息.
-
 
4573
					#$result["function"],當前執行的函數名稱.
-
 
4574
					#$result["fileContent"],爲檔案的內容陣列.
-
 
4575
					#$result["lineCount"],爲檔案內容總共的行數.
-
 
4576
					#$result["fullContent"],為檔案的完整內容.
-
 
4577
					#$result["base64data"],為檔案的base64內容.
-
 
4578
					#$result["mimeType"],為檔案的mime type.
-
 
4579
					#必填參數:
-
 
4580
					#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
-
 
4581
					$conf["fileAccess::getFileContent"]["filePositionAndName"]=$NodePathAndName;
-
 
4582
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
4583
					$conf["fileAccess::getFileContent"]["fileArgu"]=$conf["fileArgu"];
-
 
4584
					#可省略參數:
-
 
4585
					#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
-
 
4586
					#$conf["web"]="true";
-
 
4587
					#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
-
 
4588
					#$conf["createIfnotExist"]="false";
-
 
4589
					#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
-
 
4590
					#$conf["autoDeleteSpaceOnEachLineStart"]="false";
-
 
4591
					#參考資料:
-
 
4592
					#file(),取得檔案內容的行數.
-
 
4593
					#file=>http:#php.net/manual/en/function.file.php
-
 
4594
					#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
-
 
4595
					#filesize=>http://php.net/manual/en/function.filesize.php
-
 
4596
					#參考資料:
-
 
4597
					#無.
-
 
4598
					#備註:
-
 
4599
					#無.
-
 
4600
					$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
-
 
4601
					unset($conf["fileAccess::getFileContent"]);
-
 
4602
				
-
 
4603
					#如果執行失敗
-
 
4604
					if($getFileContent["status"]==="false"){
-
 
4605
					
4588
					
4606
						#設置錯誤識別
-
 
4607
						$result["status"]="false";
-
 
4608
						
4589
					#debug
4609
						#設置錯誤訊息
-
 
4610
						$result["error"]=$getFileContent;
4590
					var_dump(__LINE__,"found file:".$NodePathAndName." mimeType:".$node["mimeType"]);
4611
						
-
 
4612
						#回傳結果
-
 
4613
						return $result;
-
 
4614
					
-
 
4615
						}#if end
-
 
4616
				
-
 
4617
					#關鍵字行搜尋的索引預設數值為0
-
 
4618
					$keyWordLineIndex=0;
-
 
4619
				
4591
				
4620
					#針對檔案每行原始內容
4592
					#如果沒有用多執行序
4621
					for($oriLineContentIndex=0;$oriLineContentIndex<$getFileContent["lineCount"];$oriLineContentIndex++){
-
 
4622
					
-
 
4623
						#取得原始內容行
4593
					if($conf["multiThread"]==="false"){
4624
						$oriLineContent=$getFileContent["fileContent"][$oriLineContentIndex];
-
 
4625
					
4594
					
-
 
4595
						#取得檔案的內容
-
 
4596
						#函式說明:
-
 
4597
						#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
-
 
4598
						#回傳的變數說明:
-
 
4599
						#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
-
 
4600
						#$result["error"],錯誤訊息提示.
-
 
4601
						#$result["warning"],警告訊息.
-
 
4602
						#$result["function"],當前執行的函數名稱.
-
 
4603
						#$result["fileContent"],爲檔案的內容陣列.
-
 
4604
						#$result["lineCount"],爲檔案內容總共的行數.
-
 
4605
						#$result["fullContent"],為檔案的完整內容.
-
 
4606
						#$result["base64data"],為檔案的base64內容.
-
 
4607
						#$result["mimeType"],為檔案的mime type.
-
 
4608
						#必填參數:
-
 
4609
						#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
-
 
4610
						$conf["fileAccess::getFileContent"]["filePositionAndName"]=$NodePathAndName;
-
 
4611
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
4612
						$conf["fileAccess::getFileContent"]["fileArgu"]=$conf["fileArgu"];
-
 
4613
						#可省略參數:
-
 
4614
						#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
-
 
4615
						#$conf["web"]="true";
-
 
4616
						#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
-
 
4617
						#$conf["createIfnotExist"]="false";
-
 
4618
						#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
-
 
4619
						#$conf["autoDeleteSpaceOnEachLineStart"]="false";
-
 
4620
						#參考資料:
4626
						#預設調整後的原始內容跟原本一樣
4621
						#file(),取得檔案內容的行數.
-
 
4622
						#file=>http:#php.net/manual/en/function.file.php
-
 
4623
						#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
-
 
4624
						#filesize=>http://php.net/manual/en/function.filesize.php
-
 
4625
						#參考資料:
-
 
4626
						#無.
-
 
4627
						#備註:
-
 
4628
						#無.
-
 
4629
						$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
4627
						$modifiedOriLineContent=$oriLineContent;
4630
						unset($conf["fileAccess::getFileContent"]);
4628
					
4631
					
4629
						#如果要log
4632
						#如果執行失敗
4630
						if(isset($conf["log"])){
4633
						if($getFileContent["status"]==="false"){
4631
							
4634
						
4632
							#提示正在比對哪個檔案的第幾行
-
 
4633
							$log="比對 檔案(".$path."/".$node["name"].") 的第 ".($oriLineContentIndex+1)." 行...".PHP_EOL;
-
 
4634
							
-
 
4635
							#提示原始內容
4635
							#設置錯誤識別
4636
							$log=$log."原始內容為:".PHP_EOL;
4636
							$result["status"]="false";
4637
							
4637
							
4638
							#印出原始內容
4638
							#設置錯誤訊息
4639
							$log=$log.$oriLineContent.PHP_EOL;
4639
							$result["error"]=$getFileContent;
4640
							
4640
							
4641
							#log的路徑與名稱
-
 
4642
							$path="/tmp/".basename($conf["log"]).":".$uuid.":".$node["name"].".log";
-
 
4643
						
-
 
4644
							#函式說明:
-
 
4645
							#撰寫log
-
 
4646
							#回傳結果:
4641
							#回傳結果
4647
							#$result["status"],狀態,"true"或"false".
-
 
4648
							#$result["error"],錯誤訊息陣列.
-
 
4649
							#$result["function"],當前函式的名稱.
-
 
4650
							#$result["argu"],使用的參數.
-
 
4651
							#必填參數:
-
 
4652
							#$conf["path"],字串,log檔案的路徑與名稱.
-
 
4653
							$conf["logs::record"]["path"]=$path;
-
 
4654
							#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
4655
							$conf["logs::record"]["content"]=$log;
-
 
4656
							#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
4657
							$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
4658
							#可省略參數:
-
 
4659
							#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
4660
							#$conf["rewrite"]="false";
-
 
4661
							#參考資料:
-
 
4662
							#無.
-
 
4663
							#備註:
-
 
4664
							#無.
-
 
4665
							$record=logs::record($conf["logs::record"]);
-
 
4666
							unset($conf["logs::record"]);
-
 
4667
						
-
 
4668
							#如果出錯
-
 
4669
							if($record["status"]==="false"){
-
 
4670
						
-
 
4671
								#設置錯誤識別
-
 
4672
								$result["status"]="false";
-
 
4673
								
-
 
4674
								#設置錯誤訊息
-
 
4675
								$result["error"]=$getFileContent;
-
 
4676
								
-
 
4677
								#回傳結果
-
 
4678
								return $result;
4642
							return $result;
4679
								
-
 
4680
								}#if end
-
 
4681
						
4643
						
4682
							}#if end
4644
							}#if end
4683
					
4645
					
4684
						#無窮迴圈
-
 
4685
						while(true){
-
 
4686
						
-
 
4687
							#嘗試移除開頭的 空格 跟 \t
-
 
4688
							
-
 
4689
							#函式說明:
-
 
4690
							#取得符合多個特定字首與字尾的字串
4646
						#關鍵字行搜尋的索引預設數值為0
4691
							#回傳結果:
-
 
4692
							#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
-
 
4693
							#$result["function"],當前執行的函數名稱.
-
 
4694
							#$result["error"],錯誤訊息陣列.
-
 
4695
							#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
-
 
4696
							#$result["content"],符合條件的字串,去掉字首字尾後的結果.
-
 
4697
							#$result["returnString"],爲符合字首字、尾條件的字串內容.
-
 
4698
							#$result["meetConditions"],為符合的條件,會是$conf["keyWord"]中的其中一個元素.
-
 
4699
							#$result["argu"],使用的參數.
-
 
4700
							#必填參數:
-
 
4701
							#$conf["checkString"],字串,要檢查的字串.
-
 
4702
							$conf["search::getMeetMultiConditionsString"]["checkString"]=$modifiedOriLineContent;
-
 
4703
							#$conf["keyWord"],字串陣列,用來檢查字首、字尾應該要有哪些字串之一,每個元素代表一個可能的條件,key為front者代表開頭的關鍵字,key為tail為代表結尾的官關鍵字.
-
 
4704
							$conf["search::getMeetMultiConditionsString"]["keyWord"]=array(array("front"=>" "),array("front"=>"\t"));
-
 
4705
							#可省略參數:
-
 
4706
							#無.
-
 
4707
							#參考資料:
-
 
4708
							#無.
-
 
4709
							#備註:
-
 
4710
							#無.
-
 
4711
							$getMeetMultiConditionsString=search::getMeetMultiConditionsString($conf["search::getMeetMultiConditionsString"]);
-
 
4712
							unset($conf["search::getMeetMultiConditionsString"]);
-
 
4713
							
-
 
4714
							#debug
-
 
4715
							#var_dump(__LINE__,$getMeetMultiConditionsString);
-
 
4716
							
-
 
4717
							#如果執行失敗
-
 
4718
							if($getMeetMultiConditionsString["status"]==="false"){
-
 
4719
							
-
 
4720
								#設置錯誤識別
-
 
4721
								$result["status"]="false";
-
 
4722
								
-
 
4723
								#設置錯誤訊息
-
 
4724
								$result["error"]=$getMeetMultiConditionsString;
-
 
4725
								
-
 
4726
								#回傳結果
-
 
4727
								return $result;
4647
						$keyWordLineIndex=0;
4728
							
4648
					
4729
								}#if end
-
 
4730
								
-
 
4731
							#如果有關鍵字存在
4649
						#針對檔案每行原始內容
4732
							if($getMeetMultiConditionsString["founded"]==="true"){
-
 
4733
							
-
 
4734
								#取得已經移開頭空格跟\t後的內容
-
 
4735
								$modifiedOriLineContent=$getMeetMultiConditionsString["content"];
4650
						for($oriLineContentIndex=0;$oriLineContentIndex<$getFileContent["lineCount"];$oriLineContentIndex++){
4736
							
-
 
4737
								#繼續檢查
-
 
4738
								continue;
-
 
4739
							
-
 
4740
								}#if end
-
 
4741
							
-
 
4742
							#到這表代表已經移除開頭的 空格 跟 \t
-
 
4743
							
-
 
4744
							#結束 while
-
 
4745
							break;
-
 
4746
						
-
 
4747
							}#while end
-
 
4748
						
4651
						
4749
						#針對每個關鍵字
4652
							#取得原始內容行
4750
						for(;$keyWordLineIndex<count($conf["replaceFrom"]);$keyWordLineIndex++){
4653
							$oriLineContent=$getFileContent["fileContent"][$oriLineContentIndex];
4751
						
4654
						
4752
							#取得關鍵字行的內容
4655
							#預設調整後的原始內容跟原本一樣
4753
							$keyWordLine=$conf["replaceFrom"][$keyWordLineIndex];
4656
							$modifiedOriLineContent=$oriLineContent;
4754
						
4657
						
4755
							#如果要log
4658
							#如果要log
4756
							if(isset($conf["log"])){
4659
							if(isset($conf["log"])){
4757
							
-
 
4758
								#提示期望的內容格式
-
 
4759
								$log="期望的第 ".($keyWordLineIndex+1)." 個行內容格式為:".PHP_EOL;
-
 
4760
								
4660
								
-
 
4661
								#提示正在比對哪個檔案的第幾行
-
 
4662
								$log="比對 檔案(".$path.$node["name"].") 的第 ".($oriLineContentIndex+1)." 行...".PHP_EOL;
-
 
4663
								
4761
								#提示期望的內容
4664
								#提示原始內容
-
 
4665
								$log=$log."原始內容為:".PHP_EOL;
-
 
4666
								
-
 
4667
								#印出原始內容
4762
								$log=$log.$keyWordLine.PHP_EOL;
4668
								$log=$log.$oriLineContent.PHP_EOL;
4763
							
4669
								
4764
								#log的路徑與名稱
4670
								#log的路徑與名稱
4765
								$path="/tmp/".basename($conf["log"]).":".$uuid.":".$node["name"].".log";
4671
								$logPath="/tmp/".basename($conf["log"]).":".$uuid.":".$node["name"].".log";
4766
							
4672
							
4767
								#函式說明:
4673
								#函式說明:
4768
								#撰寫log
4674
								#撰寫log
4769
								#回傳結果:
4675
								#回傳結果:
4770
								#$result["status"],狀態,"true"或"false".
4676
								#$result["status"],狀態,"true"或"false".
4771
								#$result["error"],錯誤訊息陣列.
4677
								#$result["error"],錯誤訊息陣列.
4772
								#$result["function"],當前函式的名稱.
4678
								#$result["function"],當前函式的名稱.
4773
								#$result["argu"],使用的參數.
4679
								#$result["argu"],使用的參數.
4774
								#必填參數:
4680
								#必填參數:
4775
								#$conf["path"],字串,log檔案的路徑與名稱.
4681
								#$conf["path"],字串,log檔案的路徑與名稱.
4776
								$conf["logs::record"]["path"]=$path;
4682
								$conf["logs::record"]["path"]=$logPath;
4777
								#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4683
								#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4778
								$conf["logs::record"]["content"]=$log;
4684
								$conf["logs::record"]["content"]=$log;
4779
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4685
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4780
								$conf["logs::record"]["fileArgu"]=__FILE__;
4686
								$conf["logs::record"]["fileArgu"]=__FILE__;
4781
								#可省略參數:
4687
								#可省略參數:
Line 4802... Line 4708...
4802
									
4708
									
4803
									}#if end
4709
									}#if end
4804
							
4710
							
4805
								}#if end
4711
								}#if end
4806
						
4712
						
4807
							#調整過的關鍵字內容行預設跟原始關鍵行內容一樣
-
 
4808
							$modifiedKeyWordLine=$keyWordLine;
-
 
4809
							
-
 
4810
							#初始化關鍵字前面的內容(可能有為多個空格或tab)
-
 
4811
							$keyWordContentOfHead="";
-
 
4812
							
-
 
4813
							#無窮迴圈
4713
							#無窮迴圈
4814
							while(true){
4714
							while(true){
4815
							
4715
							
4816
								#嘗試剔除開頭的 空格 跟 "\t"
4716
								#嘗試移除開頭的 空格 跟 \t
4817
							
4717
								
4818
								#函式說明:
4718
								#函式說明:
4819
								#取得符合多個特定字首與字尾的字串
4719
								#取得符合多個特定字首與字尾的字串
4820
								#回傳結果:
4720
								#回傳結果:
4821
								#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
4721
								#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
4822
								#$result["function"],當前執行的函數名稱.
4722
								#$result["function"],當前執行的函數名稱.
Line 4826... Line 4726...
4826
								#$result["returnString"],爲符合字首字、尾條件的字串內容.
4726
								#$result["returnString"],爲符合字首字、尾條件的字串內容.
4827
								#$result["meetConditions"],為符合的條件,會是$conf["keyWord"]中的其中一個元素.
4727
								#$result["meetConditions"],為符合的條件,會是$conf["keyWord"]中的其中一個元素.
4828
								#$result["argu"],使用的參數.
4728
								#$result["argu"],使用的參數.
4829
								#必填參數:
4729
								#必填參數:
4830
								#$conf["checkString"],字串,要檢查的字串.
4730
								#$conf["checkString"],字串,要檢查的字串.
4831
								$conf["search::getMeetMultiConditionsString"]["checkString"]=$modifiedKeyWordLine;
4731
								$conf["search::getMeetMultiConditionsString"]["checkString"]=$modifiedOriLineContent;
4832
								#$conf["keyWord"],字串陣列,用來檢查字首、字尾應該要有哪些字串之一,每個元素代表一個可能的條件,key為front者代表開頭的關鍵字,key為tail為代表結尾的官關鍵字.
4732
								#$conf["keyWord"],字串陣列,用來檢查字首、字尾應該要有哪些字串之一,每個元素代表一個可能的條件,key為front者代表開頭的關鍵字,key為tail為代表結尾的官關鍵字.
4833
								$conf["search::getMeetMultiConditionsString"]["keyWord"]=array(array("front"=>" "),array("front"=>"\t"));
4733
								$conf["search::getMeetMultiConditionsString"]["keyWord"]=array(array("front"=>" "),array("front"=>"\t"));
4834
								#可省略參數:
4734
								#可省略參數:
4835
								#無.
4735
								#無.
4836
								#參考資料:
4736
								#參考資料:
Line 4858... Line 4758...
4858
									}#if end
4758
									}#if end
4859
									
4759
									
4860
								#如果有關鍵字存在
4760
								#如果有關鍵字存在
4861
								if($getMeetMultiConditionsString["founded"]==="true"){
4761
								if($getMeetMultiConditionsString["founded"]==="true"){
4862
								
4762
								
4863
									#取得移除開頭 空格 跟 \t 後的內容
4763
									#取得已經移開頭空格跟\t後的內容
4864
									$modifiedKeyWordLine=$getMeetMultiConditionsString["content"];
4764
									$modifiedOriLineContent=$getMeetMultiConditionsString["content"];
4865
									
-
 
4866
									#取得關鍵字前面的內容
-
 
4867
									$keyWordContentOfHead=substr($keyWordLine,0,strlen($keyWordLine)-strlen($modifiedKeyWordLine));
-
 
4868
									
4765
								
4869
									#繼續檢查
4766
									#繼續檢查
4870
									continue;
4767
									continue;
4871
									
4768
								
4872
									}#if end
4769
									}#if end
4873
							
4770
								
4874
								#到這表代表已經移除開頭的 空格 跟 \t
4771
								#到這表代表已經移除開頭的 空格 跟 \t
4875
							
4772
								
4876
								#結束 while
4773
								#結束 while
4877
								break;
4774
								break;
4878
								
4775
							
4879
								}#while end
4776
								}#while end
4880
						
-
 
4881
							#debug
-
 
4882
							#var_dump(__LINE__,$modifiedOriLineContent,$modifiedKeyWordLine);
-
 
4883
						
-
 
4884
							#預設分段的關鍵字為空
-
 
4885
							$keyWordPart=array();
-
 
4886
							
4777
							
4887
							#預設該行的變數為空
4778
							#針對每個關鍵字
4888
							$varPart=array();
4779
							for(;$keyWordLineIndex<count($conf["replaceFrom"]);$keyWordLineIndex++){
4889
							
4780
							
4890
							#關鍵字行的結構順序
4781
								#取得關鍵字行的內容
4891
							$OderOfPartInLine=array();
4782
								$keyWordLine=$conf["replaceFrom"][$keyWordLineIndex];
4892
						
-
 
4893
							#無窮迴圈
-
 
4894
							while(true){
-
 
4895
							
4783
							
4896
								#判斷是否含有 "${"、"}" 關鍵字
-
 
4897
								#函式說明:
-
 
4898
								#檢查一個字串裡面是否有多個關鍵字
-
 
4899
								#回傳結果:
-
 
4900
								#$result["status"],"true"代表執行成功,"false"代表執行失敗.
-
 
4901
								#$result["error"],錯誤訊息.
-
 
4902
								#$result["function"],當前執行的函數名稱.
-
 
4903
								#$result["founded"],是否有找到的關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字.
-
 
4904
								#$result["foundedKeyWords"],找到的關鍵字.
-
 
4905
								#$result["foundedAll"],是否有找到全部的關鍵字,"true"代表有;"false"代表沒有.
-
 
4906
								#$result["argu"],使用的參數.
-
 
4907
								#必填參數:
-
 
4908
								#$conf["keyWords"],字串陣列,想要搜尋的關鍵字.
-
 
4909
								$conf["search::findManyKeyWords"]["keyWords"]=array("\${","}");
-
 
4910
								#$conf["string"],字串,要被搜尋的字串內容.
-
 
4911
								$conf["search::findManyKeyWords"]["string"]=$modifiedKeyWordLine;
-
 
4912
								#可省略參數:
-
 
4913
								#$conf["completeEqual"],字串,是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合.
-
 
4914
								#$conf["completeEqual"]="true";
-
 
4915
								#參考資料:
-
 
4916
								#無.
-
 
4917
								#備註:
-
 
4918
								#無.
-
 
4919
								$findManyKeyWords=search::findManyKeyWords($conf["search::findManyKeyWords"]);
-
 
4920
								unset($conf["search::findManyKeyWords"]);
-
 
4921
								
-
 
4922
								#如果執行失敗
4784
								#如果要log
4923
								if($findManyKeyWords["status"]==="false"){
-
 
4924
								
-
 
4925
									#設置錯誤識別
-
 
4926
									$result["status"]="false";
4785
								if(isset($conf["log"])){
4927
									
-
 
4928
									#設置錯誤訊息
-
 
4929
									$result["error"]=$findManyKeyWords;
-
 
4930
									
-
 
4931
									#回傳結果
-
 
4932
									return $result;
-
 
4933
								
4786
								
4934
									}#if end
4787
									#提示期望的內容格式
-
 
4788
									$log="期望的第 ".($keyWordLineIndex+1)." 個行內容格式為:".PHP_EOL;
4935
									
4789
									
4936
								#如果有 "${"、"}" 存在
4790
									#提示期望的內容
4937
								if($findManyKeyWords["foundedAll"]==="true"){
4791
									$log=$log.$keyWordLine.PHP_EOL;
4938
								
4792
								
4939
									#debug
4793
									#log的路徑與名稱
4940
									#var_dump(__LINE__,$findManyKeyWords);
4794
									$logPath="/tmp/".basename($conf["log"]).":".$uuid.":".$node["name"].".log";
4941
								
4795
								
4942
									#取得 ${... 前面的部分
-
 
4943
									#函式說明:
4796
									#函式說明:
4944
									#將字串特定關鍵字與其後面的內容剔除
4797
									#撰寫log
4945
									#回傳結果:
4798
									#回傳結果:
4946
									#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4799
									#$result["status"],狀態,"true"或"false".
4947
									#$result["error"],錯誤訊息陣列.
4800
									#$result["error"],錯誤訊息陣列.
4948
									#$result["warning"],警告訊息鎮列.
-
 
4949
									#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
4950
									#$result["function"],當前執行的函數名稱.
4801
									#$result["function"],當前函式的名稱.
4951
									#$result["oriStr"],要處理的原始字串內容.
-
 
4952
									#$result["content"],處理好的的字串內容.
-
 
4953
									#$result["argu"],使用的參數.
4802
									#$result["argu"],使用的參數.
4954
									#必填參數:
4803
									#必填參數:
4955
									#$conf["stringIn"],字串,要處理的字串.
4804
									#$conf["path"],字串,log檔案的路徑與名稱.
4956
									$conf["stringProcess::delStrAfterKeyWord"]["stringIn"]=$modifiedKeyWordLine;
4805
									$conf["logs::record"]["path"]=$logPath;
-
 
4806
									#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4957
									#$conf["keyWord"],字串,特定字串.
4807
									$conf["logs::record"]["content"]=$log;
-
 
4808
									#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4958
									$conf["stringProcess::delStrAfterKeyWord"]["keyWord"]="\${";
4809
									$conf["logs::record"]["fileArgu"]=__FILE__;
4959
									#可省略參數:
4810
									#可省略參數:
4960
									#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
4811
									#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4961
									#$conf["deleteLastRepeatedOne"]="";
4812
									#$conf["rewrite"]="false";
4962
									#參考資料:
4813
									#參考資料:
4963
									#無.
4814
									#無.
4964
									#備註:
4815
									#備註:
4965
									#無.
4816
									#無.
4966
									$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
4817
									$record=logs::record($conf["logs::record"]);
4967
									unset($conf["stringProcess::delStrAfterKeyWord"]);
4818
									unset($conf["logs::record"]);
4968
									
-
 
4969
									#debug
-
 
4970
									#var_dump(__LINE__,$delStrAfterKeyWord);
-
 
4971
									
4819
								
4972
									#如果執行失敗
4820
									#如果出錯
4973
									if($delStrAfterKeyWord["status"]==="false"){
4821
									if($record["status"]==="false"){
4974
									
4822
								
4975
										#設置錯誤識別
4823
										#設置錯誤識別
4976
										$result["status"]="false";
4824
										$result["status"]="false";
4977
										
4825
										
4978
										#設置錯誤訊息
4826
										#設置錯誤訊息
4979
										$result["error"]=$delStrAfterKeyWord;
4827
										$result["error"]=$getFileContent;
4980
										
4828
										
4981
										#回傳結果
4829
										#回傳結果
4982
										return $result;
4830
										return $result;
4983
									
-
 
4984
										}#if end
-
 
4985
										
-
 
4986
									#如果要有關鍵字找不到
-
 
4987
									if($delStrAfterKeyWord["founded"]==="false"){
-
 
4988
									
-
 
4989
										#設置錯誤識別
-
 
4990
										$result["status"]="false";
-
 
4991
										
4831
										
4992
										#設置錯誤訊息
-
 
4993
										$result["error"]=$delStrAfterKeyWord;
-
 
4994
										
-
 
4995
										#回傳結果
-
 
4996
										return $result;
-
 
4997
									
-
 
4998
										}#if end
4832
										}#if end
4999
									
4833
								
5000
									#如果前面有內容
4834
									}#if end
5001
									if($delStrAfterKeyWord["content"]!==""){
-
 
5002
									
4835
							
5003
										#儲存該行的關鍵字之一
4836
								#調整過的關鍵字內容行預設跟原始關鍵行內容一樣
5004
										$keyWordPart[]=$delStrAfterKeyWord["content"];
4837
								$modifiedKeyWordLine=$keyWordLine;
5005
									
4838
								
5006
										#暫存的關鍵字資訊
4839
								#初始化關鍵字前面的內容(可能有為多個空格或tab)
5007
										$tmp=array("name"=>"keyWordPart","index"=>count($keyWordPart)-1,"value"=>$keyWordPart[count($keyWordPart)-1]);
4840
								$keyWordContentOfHead="";
5008
			
4841
								
5009
										#設置順序資訊
4842
								#無窮迴圈
5010
										$OderOfPartInLine[]=$tmp;
4843
								while(true){
5011
									
4844
								
5012
										}#if end
4845
									#嘗試剔除開頭的 空格 跟 "\t"
5013
									
4846
								
5014
									#取得 }... 前面的部分
-
 
5015
									#函式說明:
4847
									#函式說明:
5016
									#將字串特定關鍵字與其後面的內容剔除
4848
									#取得符合多個特定字首與字尾的字串
5017
									#回傳結果:
4849
									#回傳結果:
5018
									#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4850
									#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
5019
									#$result["error"],錯誤訊息陣列.
-
 
5020
									#$result["warning"],警告訊息鎮列.
-
 
5021
									#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5022
									#$result["function"],當前執行的函數名稱.
4851
									#$result["function"],當前執行的函數名稱.
5023
									#$result["oriStr"],要處理的原始字串內容.
4852
									#$result["error"],錯誤訊息陣列.
-
 
4853
									#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
-
 
4854
									#$result["content"],符合條件的字串,去掉字首字尾後的結果.
5024
									#$result["content"],處理好的的字串內容.
4855
									#$result["returnString"],爲符合字首字、尾條件的字串內容.
-
 
4856
									#$result["meetConditions"],為符合的條件,會是$conf["keyWord"]中的其中一個元素.
5025
									#$result["argu"],使用的參數.
4857
									#$result["argu"],使用的參數.
5026
									#必填參數:
4858
									#必填參數:
5027
									#$conf["stringIn"],字串,要處理的字串.
4859
									#$conf["checkString"],字串,要檢查的字串.
5028
									$conf["stringProcess::delStrAfterKeyWord"]["stringIn"]=$delStrAfterKeyWord["deleted"];
4860
									$conf["search::getMeetMultiConditionsString"]["checkString"]=$modifiedKeyWordLine;
5029
									#$conf["keyWord"],字串,特定字串.
4861
									#$conf["keyWord"],字串陣列,用來檢查字首、字尾應該要有哪些字串之一,每個元素代表一個可能的條件,key為front者代表開頭的關鍵字,key為tail為代表結尾的官關鍵字.
5030
									$conf["stringProcess::delStrAfterKeyWord"]["keyWord"]="}";
4862
									$conf["search::getMeetMultiConditionsString"]["keyWord"]=array(array("front"=>" "),array("front"=>"\t"));
5031
									#可省略參數:
4863
									#可省略參數:
5032
									#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
-
 
5033
									#$conf["deleteLastRepeatedOne"]="";
4864
									#無.
5034
									#參考資料:
4865
									#參考資料:
5035
									#無.
4866
									#無.
5036
									#備註:
4867
									#備註:
5037
									#無.
4868
									#無.
5038
									$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
4869
									$getMeetMultiConditionsString=search::getMeetMultiConditionsString($conf["search::getMeetMultiConditionsString"]);
5039
									unset($conf["stringProcess::delStrAfterKeyWord"]);
4870
									unset($conf["search::getMeetMultiConditionsString"]);
5040
									
4871
									
5041
									#debug
4872
									#debug
5042
									#var_dump(__LINE__,$delStrAfterKeyWord);
4873
									#var_dump(__LINE__,$getMeetMultiConditionsString);
5043
									
4874
									
5044
									#如果執行失敗
4875
									#如果執行失敗
5045
									if($delStrAfterKeyWord["status"]==="false"){
4876
									if($getMeetMultiConditionsString["status"]==="false"){
5046
									
4877
									
5047
										#設置錯誤識別
4878
										#設置錯誤識別
5048
										$result["status"]="false";
4879
										$result["status"]="false";
5049
										
4880
										
5050
										#設置錯誤訊息
4881
										#設置錯誤訊息
5051
										$result["error"]=$delStrAfterKeyWord;
4882
										$result["error"]=$getMeetMultiConditionsString;
5052
										
4883
										
5053
										#回傳結果
4884
										#回傳結果
5054
										return $result;
4885
										return $result;
5055
									
4886
									
5056
										}#if end
4887
										}#if end
5057
										
4888
										
5058
									#如果要有關鍵字找不到
4889
									#如果有關鍵字存在
5059
									if($delStrAfterKeyWord["founded"]==="false"){
4890
									if($getMeetMultiConditionsString["founded"]==="true"){
5060
									
4891
									
5061
										#設置錯誤識別
4892
										#取得移除開頭 空格 跟 \t 後的內容
5062
										$result["status"]="false";
4893
										$modifiedKeyWordLine=$getMeetMultiConditionsString["content"];
5063
										
4894
										
-
 
4895
										#取得關鍵字前面的內容
-
 
4896
										$keyWordContentOfHead=substr($keyWordLine,0,strlen($keyWordLine)-strlen($modifiedKeyWordLine));
-
 
4897
										
5064
										#設置錯誤訊息
4898
										#繼續檢查
5065
										$result["error"]=$delStrAfterKeyWord;
4899
										continue;
5066
										
4900
										
5067
										#回傳結果
-
 
5068
										return $result;
-
 
5069
									
-
 
5070
										}#if end
4901
										}#if end
-
 
4902
								
-
 
4903
									#到這表代表已經移除開頭的 空格 跟 \t
-
 
4904
								
-
 
4905
									#結束 while
-
 
4906
									break;
5071
									
4907
									
-
 
4908
									}#while end
-
 
4909
							
-
 
4910
								#debug
-
 
4911
								#var_dump(__LINE__,$modifiedOriLineContent,$modifiedKeyWordLine);
-
 
4912
							
-
 
4913
								#預設分段的關鍵字為空
-
 
4914
								$keyWordPart=array();
-
 
4915
								
5072
									#儲存該行的變數名稱之一
4916
								#預設該行的變數為空
5073
									$varPart[]=$delStrAfterKeyWord["content"]."}";
4917
								$varPart=array();
5074
									
4918
								
5075
									#移除 "}" 其面的內容
4919
								#關鍵字行的結構順序
-
 
4920
								$OderOfPartInLine=array();
-
 
4921
							
-
 
4922
								#無窮迴圈
-
 
4923
								while(true){
-
 
4924
								
-
 
4925
									#判斷是否含有 "${"、"}" 關鍵字
5076
									#函式說明:
4926
									#函式說明:
5077
									#將字串特定關鍵字與其前面的內容剔除
4927
									#檢查一個字串裡面是否有多個關鍵字
5078
									#回傳結果:
4928
									#回傳結果:
5079
									#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4929
									#$result["status"],"true"代表執行成功,"false"代表執行失敗.
5080
									#$result["error"],錯誤訊息陣列.
4930
									#$result["error"],錯誤訊息.
5081
									#$result["warning"],警告訊息鎮列.
-
 
5082
									#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5083
									#$result["function"],當前執行的函數名稱.
4931
									#$result["function"],當前執行的函數名稱.
-
 
4932
									#$result["founded"],是否有找到的關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字.
-
 
4933
									#$result["foundedKeyWords"],找到的關鍵字.
-
 
4934
									#$result["foundedAll"],是否有找到全部的關鍵字,"true"代表有;"false"代表沒有.
5084
									#$result["argu"],使用的參數.
4935
									#$result["argu"],使用的參數.
5085
									#$result["oriStr"],要處理的原始字串內容.
-
 
5086
									#$result["content"],處理好的的字串內容.
-
 
5087
									#$result["deleted"],被移除的內容.
-
 
5088
									#必填參數:
4936
									#必填參數:
5089
									#$conf["stringIn"],字串,要處理的字串.
4937
									#$conf["keyWords"],字串陣列,想要搜尋的關鍵字.
5090
									$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedKeyWordLine;
4938
									$conf["search::findManyKeyWords"]["keyWords"]=array("\${","}");
5091
									#$conf["keyWord"],字串,特定字串.
4939
									#$conf["string"],字串,要被搜尋的字串內容.
5092
									$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="}";
4940
									$conf["search::findManyKeyWords"]["string"]=$modifiedKeyWordLine;
5093
									#可省略參數:
4941
									#可省略參數:
5094
									#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
4942
									#$conf["completeEqual"],字串,是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合.
5095
									#$conf["recursive"]="true";
4943
									#$conf["completeEqual"]="true";
5096
									#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
-
 
5097
									#$conf["lastResult"]=$delStrBeforeKeyWord;
-
 
5098
									#參考資料:
4944
									#參考資料:
5099
									#無.
4945
									#無.
5100
									#備註:
4946
									#備註:
5101
									#無.
4947
									#無.
5102
									$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
4948
									$findManyKeyWords=search::findManyKeyWords($conf["search::findManyKeyWords"]);
5103
									unset($conf["stringProcess::delStrBeforeKeyWord"]);
4949
									unset($conf["search::findManyKeyWords"]);
5104
									
4950
									
5105
									#如果執行失敗
4951
									#如果執行失敗
5106
									if($delStrBeforeKeyWord["status"]==="false"){
4952
									if($findManyKeyWords["status"]==="false"){
5107
									
4953
									
5108
										#設置錯誤識別
4954
										#設置錯誤識別
5109
										$result["status"]="false";
4955
										$result["status"]="false";
5110
										
4956
										
5111
										#設置錯誤訊息
4957
										#設置錯誤訊息
5112
										$result["error"]=$delStrBeforeKeyWord;
4958
										$result["error"]=$findManyKeyWords;
5113
										
4959
										
5114
										#回傳結果
4960
										#回傳結果
5115
										return $result;
4961
										return $result;
5116
									
4962
									
5117
										}#if end
4963
										}#if end
5118
										
4964
										
5119
									#如果要有關鍵字找不到
4965
									#如果有 "${"、"}" 存在
5120
									if($delStrBeforeKeyWord["founded"]==="false"){
4966
									if($findManyKeyWords["foundedAll"]==="true"){
5121
									
4967
									
-
 
4968
										#debug
-
 
4969
										#var_dump(__LINE__,$findManyKeyWords);
-
 
4970
									
-
 
4971
										#取得 ${... 前面的部分
5122
										#設置錯誤識別
4972
										#函式說明:
-
 
4973
										#將字串特定關鍵字與其後面的內容剔除
-
 
4974
										#回傳結果:
-
 
4975
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
4976
										#$result["error"],錯誤訊息陣列.
-
 
4977
										#$result["warning"],警告訊息鎮列.
-
 
4978
										#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
4979
										#$result["function"],當前執行的函數名稱.
-
 
4980
										#$result["oriStr"],要處理的原始字串內容.
-
 
4981
										#$result["content"],處理好的的字串內容.
5123
										$result["status"]="false";
4982
										#$result["argu"],使用的參數.
-
 
4983
										#必填參數:
-
 
4984
										#$conf["stringIn"],字串,要處理的字串.
-
 
4985
										$conf["stringProcess::delStrAfterKeyWord"]["stringIn"]=$modifiedKeyWordLine;
-
 
4986
										#$conf["keyWord"],字串,特定字串.
-
 
4987
										$conf["stringProcess::delStrAfterKeyWord"]["keyWord"]="\${";
-
 
4988
										#可省略參數:
-
 
4989
										#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
-
 
4990
										#$conf["deleteLastRepeatedOne"]="";
-
 
4991
										#參考資料:
-
 
4992
										#無.
-
 
4993
										#備註:
-
 
4994
										#無.
-
 
4995
										$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
-
 
4996
										unset($conf["stringProcess::delStrAfterKeyWord"]);
5124
										
4997
										
-
 
4998
										#debug
-
 
4999
										#var_dump(__LINE__,$delStrAfterKeyWord);
-
 
5000
										
-
 
5001
										#如果執行失敗
-
 
5002
										if($delStrAfterKeyWord["status"]==="false"){
-
 
5003
										
-
 
5004
											#設置錯誤識別
-
 
5005
											$result["status"]="false";
-
 
5006
											
-
 
5007
											#設置錯誤訊息
-
 
5008
											$result["error"]=$delStrAfterKeyWord;
-
 
5009
											
-
 
5010
											#回傳結果
-
 
5011
											return $result;
-
 
5012
										
-
 
5013
											}#if end
-
 
5014
											
-
 
5015
										#如果要有關鍵字找不到
-
 
5016
										if($delStrAfterKeyWord["founded"]==="false"){
-
 
5017
										
-
 
5018
											#設置錯誤識別
-
 
5019
											$result["status"]="false";
-
 
5020
											
-
 
5021
											#設置錯誤訊息
-
 
5022
											$result["error"]=$delStrAfterKeyWord;
-
 
5023
											
-
 
5024
											#回傳結果
-
 
5025
											return $result;
-
 
5026
										
-
 
5027
											}#if end
-
 
5028
										
-
 
5029
										#如果前面有內容
-
 
5030
										if($delStrAfterKeyWord["content"]!==""){
-
 
5031
										
-
 
5032
											#儲存該行的關鍵字之一
-
 
5033
											$keyWordPart[]=$delStrAfterKeyWord["content"];
-
 
5034
										
-
 
5035
											#暫存的關鍵字資訊
-
 
5036
											$tmp=array("name"=>"keyWordPart","index"=>count($keyWordPart)-1,"value"=>$keyWordPart[count($keyWordPart)-1]);
-
 
5037
				
-
 
5038
											#設置順序資訊
-
 
5039
											$OderOfPartInLine[]=$tmp;
-
 
5040
										
-
 
5041
											}#if end
-
 
5042
										
-
 
5043
										#取得 }... 前面的部分
-
 
5044
										#函式說明:
-
 
5045
										#將字串特定關鍵字與其後面的內容剔除
-
 
5046
										#回傳結果:
-
 
5047
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5048
										#$result["error"],錯誤訊息陣列.
-
 
5049
										#$result["warning"],警告訊息鎮列.
-
 
5050
										#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5051
										#$result["function"],當前執行的函數名稱.
-
 
5052
										#$result["oriStr"],要處理的原始字串內容.
-
 
5053
										#$result["content"],處理好的的字串內容.
-
 
5054
										#$result["argu"],使用的參數.
-
 
5055
										#必填參數:
-
 
5056
										#$conf["stringIn"],字串,要處理的字串.
-
 
5057
										$conf["stringProcess::delStrAfterKeyWord"]["stringIn"]=$delStrAfterKeyWord["deleted"];
-
 
5058
										#$conf["keyWord"],字串,特定字串.
-
 
5059
										$conf["stringProcess::delStrAfterKeyWord"]["keyWord"]="}";
-
 
5060
										#可省略參數:
-
 
5061
										#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
-
 
5062
										#$conf["deleteLastRepeatedOne"]="";
-
 
5063
										#參考資料:
-
 
5064
										#無.
-
 
5065
										#備註:
-
 
5066
										#無.
-
 
5067
										$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
-
 
5068
										unset($conf["stringProcess::delStrAfterKeyWord"]);
-
 
5069
										
-
 
5070
										#debug
-
 
5071
										#var_dump(__LINE__,$delStrAfterKeyWord);
-
 
5072
										
-
 
5073
										#如果執行失敗
-
 
5074
										if($delStrAfterKeyWord["status"]==="false"){
-
 
5075
										
-
 
5076
											#設置錯誤識別
-
 
5077
											$result["status"]="false";
-
 
5078
											
-
 
5079
											#設置錯誤訊息
-
 
5080
											$result["error"]=$delStrAfterKeyWord;
-
 
5081
											
-
 
5082
											#回傳結果
-
 
5083
											return $result;
-
 
5084
										
-
 
5085
											}#if end
-
 
5086
											
-
 
5087
										#如果要有關鍵字找不到
-
 
5088
										if($delStrAfterKeyWord["founded"]==="false"){
-
 
5089
										
-
 
5090
											#設置錯誤識別
-
 
5091
											$result["status"]="false";
-
 
5092
											
-
 
5093
											#設置錯誤訊息
-
 
5094
											$result["error"]=$delStrAfterKeyWord;
-
 
5095
											
-
 
5096
											#回傳結果
-
 
5097
											return $result;
-
 
5098
										
-
 
5099
											}#if end
-
 
5100
										
-
 
5101
										#儲存該行的變數名稱之一
-
 
5102
										$varPart[]=$delStrAfterKeyWord["content"]."}";
-
 
5103
										
-
 
5104
										#移除 "}" 其面的內容
-
 
5105
										#函式說明:
-
 
5106
										#將字串特定關鍵字與其前面的內容剔除
-
 
5107
										#回傳結果:
-
 
5108
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5109
										#$result["error"],錯誤訊息陣列.
-
 
5110
										#$result["warning"],警告訊息鎮列.
-
 
5111
										#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5112
										#$result["function"],當前執行的函數名稱.
-
 
5113
										#$result["argu"],使用的參數.
-
 
5114
										#$result["oriStr"],要處理的原始字串內容.
-
 
5115
										#$result["content"],處理好的的字串內容.
-
 
5116
										#$result["deleted"],被移除的內容.
-
 
5117
										#必填參數:
-
 
5118
										#$conf["stringIn"],字串,要處理的字串.
-
 
5119
										$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedKeyWordLine;
-
 
5120
										#$conf["keyWord"],字串,特定字串.
-
 
5121
										$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="}";
-
 
5122
										#可省略參數:
-
 
5123
										#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
-
 
5124
										#$conf["recursive"]="true";
-
 
5125
										#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
-
 
5126
										#$conf["lastResult"]=$delStrBeforeKeyWord;
-
 
5127
										#參考資料:
-
 
5128
										#無.
-
 
5129
										#備註:
-
 
5130
										#無.
-
 
5131
										$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5132
										unset($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5133
										
-
 
5134
										#如果執行失敗
-
 
5135
										if($delStrBeforeKeyWord["status"]==="false"){
-
 
5136
										
-
 
5137
											#設置錯誤識別
-
 
5138
											$result["status"]="false";
-
 
5139
											
5125
										#設置錯誤訊息
5140
											#設置錯誤訊息
5126
										$result["error"]=$delStrBeforeKeyWord;
5141
											$result["error"]=$delStrBeforeKeyWord;
-
 
5142
											
-
 
5143
											#回傳結果
-
 
5144
											return $result;
-
 
5145
										
-
 
5146
											}#if end
-
 
5147
											
-
 
5148
										#如果要有關鍵字找不到
-
 
5149
										if($delStrBeforeKeyWord["founded"]==="false"){
-
 
5150
										
-
 
5151
											#設置錯誤識別
-
 
5152
											$result["status"]="false";
-
 
5153
											
-
 
5154
											#設置錯誤訊息
-
 
5155
											$result["error"]=$delStrBeforeKeyWord;
-
 
5156
											
-
 
5157
											#回傳結果
-
 
5158
											return $result;
-
 
5159
										
-
 
5160
											}#if end
-
 
5161
										
-
 
5162
										#取得剩下的部分
-
 
5163
										$modifiedKeyWordLine=$delStrBeforeKeyWord["content"];
-
 
5164
										
-
 
5165
										#暫存的關鍵字資訊
-
 
5166
										$tmp=array("name"=>"varPart","index"=>count($varPart)-1,"value"=>$varPart[count($varPart)-1]);
-
 
5167
			
-
 
5168
										#設置順序資訊
-
 
5169
										$OderOfPartInLine[]=$tmp;
-
 
5170
										
-
 
5171
										#下一輪檢查有無變數關鍵字
-
 
5172
										continue;
5127
										
5173
										
5128
										#回傳結果
-
 
5129
										return $result;
-
 
5130
									
-
 
5131
										}#if end
5174
										}#if end
5132
									
5175
									
5133
									#取得剩下的部分
-
 
5134
									$modifiedKeyWordLine=$delStrBeforeKeyWord["content"];
-
 
5135
									
-
 
5136
									#暫存的關鍵字資訊
-
 
5137
									$tmp=array("name"=>"varPart","index"=>count($varPart)-1,"value"=>$varPart[count($varPart)-1]);
-
 
5138
		
-
 
5139
									#設置順序資訊
-
 
5140
									$OderOfPartInLine[]=$tmp;
-
 
5141
									
-
 
5142
									#下一輪檢查有無變數關鍵字
-
 
5143
									continue;
-
 
5144
									
-
 
5145
									}#if end
-
 
5146
								
-
 
5147
								#debug
-
 
5148
								#var_dump(__LINE__,$OderOfPartInLine);
-
 
5149
								
-
 
5150
								#如果有關鍵字片段與變數的順序存在
-
 
5151
								if( count($OderOfPartInLine)>0 ){
-
 
5152
									
-
 
5153
									#debug
5176
									#debug
5154
									#var_dump(__LINE__,$OderOfPartInLine);
5177
									#var_dump(__LINE__,$OderOfPartInLine);
5155
									
5178
									
5156
									#針對每個資訊
5179
									#如果有關鍵字片段與變數的順序存在
5157
									foreach($OderOfPartInLine as $index=>$condition){
5180
									if( count($OderOfPartInLine)>0 ){
5158
										
5181
										
5159
										#debug
5182
										#debug
5160
										#var_dump(__LINE__,$index,$condition);
5183
										#var_dump(__LINE__,$OderOfPartInLine);
5161
										
5184
										
5162
										#判斷資訊
5185
										#針對每個資訊
5163
										switch($condition["name"]){
5186
										foreach($OderOfPartInLine as $index=>$condition){
5164
										
-
 
5165
											#如果是 "keyWordPart"
-
 
5166
											case "keyWordPart":
-
 
5167
											
5187
											
5168
												#確認是否開頭有符合
-
 
5169
												
-
 
5170
												#函式說明:
-
 
5171
												#取得關鍵字在字串的哪個位置(字首,字尾,中間)
-
 
5172
												#回傳結果:
-
 
5173
												#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
-
 
5174
												#$result["error"],錯誤訊息陣列.
-
 
5175
												#$result["function"],當前執行的函數名稱.
-
 
5176
												#$result["found"],是否有關鍵字存在,若為"true",代表存在;反之為"false".
-
 
5177
												#$result["argu"],傳入的參數.
-
 
5178
												#$result["head"],關鍵字是否在字串的開頭,"true"代表是,"false"代表不是.
-
 
5179
												#$result["tail"],關鍵字是否在字串的尾端,"true"代表是,"false"代表不是.
-
 
5180
												#$result["center"],關鍵字是否在字串的中間,"true"代表是,"false"代表不是.
-
 
5181
												#$result["indexS"],關鍵字在被搜尋字串的哪個位置開始.
-
 
5182
												#$result["indexE"],關鍵字在被搜尋字串的哪個位置結束.
-
 
5183
												#必填參數:
-
 
5184
												#$conf["inputStr"],字串,被搜尋的字串.
-
 
5185
												$conf["search::findKeyWordPosition"]["inputStr"]=$modifiedOriLineContent;
-
 
5186
												#$conf["keyWord"],字串,關鍵字.
-
 
5187
												$conf["search::findKeyWordPosition"]["keyWord"]=$condition["value"];
-
 
5188
												#可省略參數:
-
 
5189
												#無.
5188
											#debug
5190
												#參考資料:
-
 
5191
												#http://php.net/manual/en/function.strpos.php
-
 
5192
												#備註:
-
 
5193
												#無.
-
 
5194
												$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
-
 
5195
												unset($conf["search::findKeyWordPosition"]);
5189
											#var_dump(__LINE__,$index,$condition);
5196
											
5190
											
-
 
5191
											#判斷資訊
-
 
5192
											switch($condition["name"]){
5197
												#debug
5193
											
5198
												#var_dump(__LINE__,$findKeyWordPosition);
5194
												#如果是 "keyWordPart"
-
 
5195
												case "keyWordPart":
5199
											
5196
												
-
 
5197
													#確認是否開頭有符合
-
 
5198
													
-
 
5199
													#函式說明:
-
 
5200
													#取得關鍵字在字串的哪個位置(字首,字尾,中間)
-
 
5201
													#回傳結果:
-
 
5202
													#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
-
 
5203
													#$result["error"],錯誤訊息陣列.
-
 
5204
													#$result["function"],當前執行的函數名稱.
-
 
5205
													#$result["found"],是否有關鍵字存在,若為"true",代表存在;反之為"false".
-
 
5206
													#$result["argu"],傳入的參數.
-
 
5207
													#$result["head"],關鍵字是否在字串的開頭,"true"代表是,"false"代表不是.
-
 
5208
													#$result["tail"],關鍵字是否在字串的尾端,"true"代表是,"false"代表不是.
-
 
5209
													#$result["center"],關鍵字是否在字串的中間,"true"代表是,"false"代表不是.
-
 
5210
													#$result["indexS"],關鍵字在被搜尋字串的哪個位置開始.
-
 
5211
													#$result["indexE"],關鍵字在被搜尋字串的哪個位置結束.
5200
												#如果執行失敗
5212
													#必填參數:
-
 
5213
													#$conf["inputStr"],字串,被搜尋的字串.
-
 
5214
													$conf["search::findKeyWordPosition"]["inputStr"]=$modifiedOriLineContent;
-
 
5215
													#$conf["keyWord"],字串,關鍵字.
5201
												if($findKeyWordPosition["status"]==="false"){
5216
													$conf["search::findKeyWordPosition"]["keyWord"]=$condition["value"];
-
 
5217
													#可省略參數:
-
 
5218
													#無.
-
 
5219
													#參考資料:
-
 
5220
													#http://php.net/manual/en/function.strpos.php
-
 
5221
													#備註:
-
 
5222
													#無.
-
 
5223
													$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
-
 
5224
													unset($conf["search::findKeyWordPosition"]);
5202
												
5225
												
5203
													#設置錯誤識別
-
 
5204
													$result["status"]="false";
-
 
5205
													
5226
													#debug
5206
													#設置錯誤訊息
-
 
5207
													$result["error"]=$findKeyWordPosition;
5227
													#var_dump(__LINE__,$findKeyWordPosition);
5208
													
-
 
5209
													#回傳結果
-
 
5210
													return $result;
-
 
5211
												
5228
												
5212
													}#if end
5229
													#如果執行失敗
-
 
5230
													if($findKeyWordPosition["status"]==="false"){
5213
													
5231
													
5214
												#如果沒有符合
5232
														#設置錯誤識別
5215
												if($findKeyWordPosition["found"]==="false"){
5233
														$result["status"]="false";
5216
												
5234
														
5217
													#初始化關鍵字行
5235
														#設置錯誤訊息
5218
													$keyWordLineIndex=0;
5236
														$result["error"]=$findKeyWordPosition;
5219
													
5237
														
5220
													#換下行原始內容
5238
														#回傳結果
5221
													continue 5;
5239
														return $result;
5222
												
-
 
5223
													}#if end
-
 
5224
													
5240
													
5225
												#如果關鍵字不在開頭
5241
														}#if end
5226
												if($findKeyWordPosition["head"]==="false"){
-
 
5227
												
5242
														
5228
													#初始化關鍵字行
5243
													#如果沒有符合
5229
													$keyWordLineIndex=0;
5244
													if($findKeyWordPosition["found"]==="false"){
5230
													
5245
													
5231
													#換下行原始內容
5246
														#初始化關鍵字行
5232
													continue 5;
5247
														$keyWordLineIndex=0;
5233
												
-
 
5234
													}#if end
-
 
5235
												
5248
														
5236
												#函式說明:
-
 
5237
												#將字串特定關鍵字與其前面的內容剔除
-
 
5238
												#回傳結果:
-
 
5239
												#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5240
												#$result["error"],錯誤訊息陣列.
-
 
5241
												#$result["warning"],警告訊息鎮列.
-
 
5242
												#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5243
												#$result["function"],當前執行的函數名稱.
-
 
5244
												#$result["argu"],使用的參數.
-
 
5245
												#$result["oriStr"],要處理的原始字串內容.
-
 
5246
												#$result["content"],處理好的的字串內容.
-
 
5247
												#$result["deleted"],被移除的內容.
-
 
5248
												#必填參數:
-
 
5249
												#$conf["stringIn"],字串,要處理的字串.
-
 
5250
												$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedOriLineContent;
-
 
5251
												#$conf["keyWord"],字串,特定字串.
-
 
5252
												$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$condition["value"];
-
 
5253
												#可省略參數:
5249
														#換下行原始內容
5254
												#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
-
 
5255
												#$conf["recursive"]="true";
-
 
5256
												#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
-
 
5257
												#$conf["lastResult"]=$delStrBeforeKeyWord;
-
 
5258
												#參考資料:
5250
														continue 5;
5259
												#無.
-
 
5260
												#備註:
-
 
5261
												#無.
-
 
5262
												$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5263
												unset($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5264
												
-
 
5265
												#debug
-
 
5266
												#var_dump(__LINE__,$delStrBeforeKeyWord);
-
 
5267
												
-
 
5268
												#如果執行失敗
-
 
5269
												if($delStrBeforeKeyWord["status"]==="false"){
-
 
5270
												
-
 
5271
													#設置錯誤識別
-
 
5272
													$result["status"]="false";
-
 
5273
													
5251
													
-
 
5252
														}#if end
-
 
5253
														
5274
													#設置錯誤訊息
5254
													#如果關鍵字不在開頭
5275
													$result["error"]=$delStrBeforeKeyWord;
5255
													if($findKeyWordPosition["head"]==="false"){
5276
													
5256
													
5277
													#回傳結果
5257
														#初始化關鍵字行
5278
													return $result;
5258
														$keyWordLineIndex=0;
5279
												
5259
														
-
 
5260
														#換下行原始內容
5280
													}#if end
5261
														continue 5;
5281
													
5262
													
5282
												#如果沒有符合
-
 
5283
												if($delStrBeforeKeyWord["founded"]==="false"){
-
 
5284
												
5263
														}#if end
5285
													#初始化關鍵字行
-
 
5286
													$keyWordLineIndex=0;
-
 
5287
													
5264
													
-
 
5265
													#函式說明:
-
 
5266
													#將字串特定關鍵字與其前面的內容剔除
-
 
5267
													#回傳結果:
-
 
5268
													#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5269
													#$result["error"],錯誤訊息陣列.
-
 
5270
													#$result["warning"],警告訊息鎮列.
-
 
5271
													#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5272
													#$result["function"],當前執行的函數名稱.
-
 
5273
													#$result["argu"],使用的參數.
-
 
5274
													#$result["oriStr"],要處理的原始字串內容.
-
 
5275
													#$result["content"],處理好的的字串內容.
-
 
5276
													#$result["deleted"],被移除的內容.
-
 
5277
													#必填參數:
-
 
5278
													#$conf["stringIn"],字串,要處理的字串.
-
 
5279
													$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedOriLineContent;
-
 
5280
													#$conf["keyWord"],字串,特定字串.
-
 
5281
													$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$condition["value"];
5288
													#換下行原始內容
5282
													#可省略參數:
-
 
5283
													#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
-
 
5284
													#$conf["recursive"]="true";
-
 
5285
													#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
-
 
5286
													#$conf["lastResult"]=$delStrBeforeKeyWord;
-
 
5287
													#參考資料:
-
 
5288
													#無.
5289
													continue 5;
5289
													#備註:
-
 
5290
													#無.
-
 
5291
													$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5292
													unset($conf["stringProcess::delStrBeforeKeyWord"]);
5290
													
5293
													
5291
													}#if end
5294
													#debug
-
 
5295
													#var_dump(__LINE__,$delStrBeforeKeyWord);
5292
													
5296
													
5293
												#執行到這邊代表有符合
-
 
5294
												
-
 
5295
												#取得剩下未判斷是否符合的項目
-
 
5296
												$modifiedOriLineContent=$delStrBeforeKeyWord["content"];
-
 
5297
												
-
 
5298
												#換找下個資訊有無符合
-
 
5299
												continue 2;
-
 
5300
												
-
 
5301
												#結束 switch
-
 
5302
												break;
-
 
5303
												
-
 
5304
											#如果是 "varPart"
5297
													#如果執行失敗
5305
											case "varPart":
-
 
5306
											
-
 
5307
												#判斷變數名稱
-
 
5308
												switch($OderOfPartInLine[($index)]["value"]){
5298
													if($delStrBeforeKeyWord["status"]==="false"){
5309
													
5299
													
-
 
5300
														#設置錯誤識別
-
 
5301
														$result["status"]="false";
-
 
5302
														
-
 
5303
														#設置錯誤訊息
-
 
5304
														$result["error"]=$delStrBeforeKeyWord;
-
 
5305
														
5310
													#如果為 起始年份
5306
														#回傳結果
5311
													case "\${yearFrom}":
5307
														return $result;
5312
													
5308
													
5313
													#或如果為 結束年份
5309
														}#if end
-
 
5310
														
5314
													case "\${yearTo}":
5311
													#如果沒有符合
-
 
5312
													if($delStrBeforeKeyWord["founded"]==="false"){
5315
													
5313
													
5316
														#取得變數名稱,亦即去掉開頭的 "${" 跟結尾的 "}"
5314
														#初始化關鍵字行
5317
														$varName=substr($OderOfPartInLine[($index)]["value"],2,strlen($OderOfPartInLine[($index)]["value"])-3);
5315
														$keyWordLineIndex=0;
5318
														
5316
														
5319
														#取得變數實際數值
5317
														#換下行原始內容
5320
														$varVal=$conf[$varName];
5318
														continue 5;
5321
														
5319
														
5322
														#轉換成 keyWordPart
5320
														}#if end
5323
														$OderOfPartInLine[($index)]["name"]="keyWordPart";
-
 
5324
														
5321
														
5325
														#轉換成期望的數值
5322
													#執行到這邊代表有符合
5326
														$OderOfPartInLine[($index)]["value"]=$varVal;
-
 
5327
													
5323
													
-
 
5324
													#取得剩下未判斷是否符合的項目
-
 
5325
													$modifiedOriLineContent=$delStrBeforeKeyWord["content"];
5328
														#跳出 switch
5326
													
-
 
5327
													#換找下個資訊有無符合
5329
														break;
5328
													continue 2;
5330
													
5329
													
5331
													#或如果為作者資訊
5330
													#結束 switch
5332
													case "\${Authors}":
5331
													break;
5333
													
5332
													
-
 
5333
												#如果是 "varPart"
-
 
5334
												case "varPart":
-
 
5335
												
5334
														#取得變數名稱,亦即去掉開頭的 "${" 跟結尾的 "}"
5336
													#判斷變數名稱
5335
														$varName=substr($OderOfPartInLine[($index)]["value"],2,strlen($OderOfPartInLine[($index)]["value"])-3);
5337
													switch($OderOfPartInLine[($index)]["value"]){
5336
														
5338
														
5337
														#取得變數實際數值
5339
														#如果為 起始年份
5338
														$varVal=$conf[$varName];
5340
														case "\${yearFrom}":
5339
														
5341
														
5340
														#轉換成 keyWordPart
5342
														#或如果為 結束年份
5341
														$OderOfPartInLine[($index)]["name"]="keyWordPart";
5343
														case "\${yearTo}":
5342
														
5344
														
-
 
5345
															#取得變數名稱,亦即去掉開頭的 "${" 跟結尾的 "}"
-
 
5346
															$varName=substr($OderOfPartInLine[($index)]["value"],2,strlen($OderOfPartInLine[($index)]["value"])-3);
-
 
5347
															
5343
														#初始化作者清單
5348
															#取得變數實際數值
5344
														$authorNameList="";
5349
															$varVal=$conf[$varName];
-
 
5350
															
-
 
5351
															#轉換成 keyWordPart
-
 
5352
															$OderOfPartInLine[($index)]["name"]="keyWordPart";
-
 
5353
															
-
 
5354
															#轉換成期望的數值
-
 
5355
															$OderOfPartInLine[($index)]["value"]=$varVal;
5345
														
5356
														
5346
														#針對每個作者
5357
															#跳出 switch
5347
														foreach($varVal as $authorNameIndex=>$authorName){
5358
															break;
5348
														
5359
														
5349
															#預設的間隔內容
5360
														#或如果為作者資訊
5350
															$comma=" | ";
5361
														case "\${Authors}":
5351
														
5362
														
-
 
5363
															#取得變數名稱,亦即去掉開頭的 "${" 跟結尾的 "}"
-
 
5364
															$varName=substr($OderOfPartInLine[($index)]["value"],2,strlen($OderOfPartInLine[($index)]["value"])-3);
-
 
5365
															
-
 
5366
															#取得變數實際數值
-
 
5367
															$varVal=$conf[$varName];
-
 
5368
															
-
 
5369
															#轉換成 keyWordPart
-
 
5370
															$OderOfPartInLine[($index)]["name"]="keyWordPart";
-
 
5371
															
5352
															#如果是第一個作者
5372
															#初始化作者清單
5353
															if($authorNameIndex===0){
5373
															$authorNameList="";
5354
															
5374
															
5355
																#不需要間隔內容
5375
															#針對每個作者
5356
																$comma="";
5376
															foreach($varVal as $authorNameIndex=>$authorName){
5357
															
5377
															
-
 
5378
																#預設的間隔內容
-
 
5379
																$comma=" | ";
-
 
5380
															
-
 
5381
																#如果是第一個作者
-
 
5382
																if($authorNameIndex===0){
-
 
5383
																
-
 
5384
																	#不需要間隔內容
-
 
5385
																	$comma="";
-
 
5386
																
5358
																}#if end
5387
																	}#if end
-
 
5388
															
-
 
5389
																#串接間隔與作者名字
-
 
5390
																$authorNameList=$authorNameList.$comma.$authorName;
-
 
5391
															
-
 
5392
																}#foreach end
-
 
5393
															
-
 
5394
															#轉換成期望的數值
-
 
5395
															$OderOfPartInLine[($index)]["value"]=$authorNameList;
-
 
5396
															
-
 
5397
															#跳出 switch
-
 
5398
															break;
5359
														
5399
														
5360
															#串接間隔與作者名字
5400
														#其他變數
5361
															$authorNameList=$authorNameList.$comma.$authorName;
5401
														default:
5362
														
5402
														
-
 
5403
															#請定義實際內容要如何產生
-
 
5404
															#...
-
 
5405
													
5363
															}#foreach end
5406
														}#switch end
-
 
5407
												
-
 
5408
													#如果後面沒有 $OderOfPartInLine 了
-
 
5409
													if(!isset($OderOfPartInLine[($index+1)])){
-
 
5410
													
-
 
5411
														#代表有符合所有條件
5364
														
5412
														
5365
														#轉換成期望的數值
5413
														#輪到下個關鍵字行
5366
														$OderOfPartInLine[($index)]["value"]=$authorNameList;
5414
														$keyWordLineIndex++;
5367
														
5415
														
5368
														#跳出 switch
5416
														#結束 switch
5369
														break;
5417
														break;
5370
													
5418
													
-
 
5419
														}#if end
-
 
5420
														
-
 
5421
													#debug
-
 
5422
													#var_dump(__LINE__,$OderOfPartInLine[($index+1)]);
-
 
5423
														
-
 
5424
													#執行到這邊代表後面還有 $OderOfPartInLine
-
 
5425
													
-
 
5426
													#如果後面的內容不是 keyWordPart
-
 
5427
													if($OderOfPartInLine[($index+1)]["name"]!=="keyWordPart"){
-
 
5428
													
-
 
5429
														#設置錯誤識別
-
 
5430
														$result["status"]="false";
-
 
5431
														
-
 
5432
														#設置錯誤訊息
-
 
5433
														$result["error"][]="multi continued varName not supported";
-
 
5434
														
5371
													#其他變數
5435
														#回傳結果
-
 
5436
														return $result;
-
 
5437
													
5372
													default:
5438
														}#if end
-
 
5439
														
-
 
5440
													#執行到這邊代表為 varPart
5373
													
5441
													
-
 
5442
													#函式說明:
-
 
5443
													#取得關鍵字在字串的哪個位置(字首,字尾,中間)
-
 
5444
													#回傳結果:
-
 
5445
													#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
-
 
5446
													#$result["error"],錯誤訊息陣列.
-
 
5447
													#$result["function"],當前執行的函數名稱.
-
 
5448
													#$result["found"],是否有關鍵字存在,若為"true",代表存在;反之為"false".
5374
														#請定義實際內容要如何產生
5449
													#$result["argu"],傳入的參數.
-
 
5450
													#$result["head"],關鍵字是否在字串的開頭,"true"代表是,"false"代表不是.
-
 
5451
													#$result["tail"],關鍵字是否在字串的尾端,"true"代表是,"false"代表不是.
-
 
5452
													#$result["center"],關鍵字是否在字串的中間,"true"代表是,"false"代表不是.
-
 
5453
													#$result["indexS"],關鍵字在被搜尋字串的哪個位置開始.
-
 
5454
													#$result["indexE"],關鍵字在被搜尋字串的哪個位置結束.
-
 
5455
													#必填參數:
-
 
5456
													#$conf["inputStr"],字串,被搜尋的字串.
-
 
5457
													$conf["search::findKeyWordPosition"]["inputStr"]=$modifiedOriLineContent;
-
 
5458
													#$conf["keyWord"],字串,關鍵字.
-
 
5459
													$conf["search::findKeyWordPosition"]["keyWord"]=$OderOfPartInLine[($index+1)]["value"];
-
 
5460
													#可省略參數:
-
 
5461
													#無.
-
 
5462
													#參考資料:
-
 
5463
													#http://php.net/manual/en/function.strpos.php
-
 
5464
													#備註:
5375
														#...
5465
													#無.
-
 
5466
													$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
-
 
5467
													unset($conf["search::findKeyWordPosition"]);
5376
												
5468
												
5377
													}#switch end
5469
													#debug
5378
											
-
 
5379
												#如果後面沒有 $OderOfPartInLine 了
-
 
5380
												if(!isset($OderOfPartInLine[($index+1)])){
5470
													#var_dump(__LINE__,$findKeyWordPosition);
5381
												
5471
												
5382
													#代表有符合所有條件
5472
													#如果執行失敗
-
 
5473
													if($findKeyWordPosition["status"]==="false"){
5383
													
5474
													
5384
													#輪到下個關鍵字行
5475
														#設置錯誤識別
-
 
5476
														$result["status"]="false";
-
 
5477
														
-
 
5478
														#設置錯誤訊息
-
 
5479
														$result["error"]=$findKeyWordPosition;
-
 
5480
														
-
 
5481
														#回傳結果
5385
													$keyWordLineIndex++;
5482
														return $result;
5386
													
5483
													
5387
													#結束 switch
5484
														}#if end
5388
													break;
5485
														
5389
												
5486
													#如果沒有符合
5390
													}#if end
5487
													if($findKeyWordPosition["found"]==="false"){
5391
													
5488
													
-
 
5489
														#初始化關鍵字行
-
 
5490
														$keyWordLineIndex=0;
5392
												#debug
5491
														
5393
												#var_dump(__LINE__,$OderOfPartInLine[($index+1)]);
5492
														#換下行原始內容
-
 
5493
														continue 5;
5394
													
5494
													
5395
												#執行到這邊代表後面還有 $OderOfPartInLine
-
 
5396
												
5495
														}#if end
5397
												#如果後面的內容不是 keyWordPart
-
 
5398
												if($OderOfPartInLine[($index+1)]["name"]!=="keyWordPart"){
-
 
5399
												
-
 
5400
													#設置錯誤識別
-
 
5401
													$result["status"]="false";
-
 
5402
													
5496
													
5403
													#設置錯誤訊息
5497
													#執行到這邊代表有符合
5404
													$result["error"][]="multi continued varName not supported";
-
 
5405
													
5498
													
-
 
5499
													#函式說明:
-
 
5500
													#將字串特定關鍵字與其前面的內容剔除
5406
													#回傳結果
5501
													#回傳結果:
-
 
5502
													#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5503
													#$result["error"],錯誤訊息陣列.
-
 
5504
													#$result["warning"],警告訊息鎮列.
-
 
5505
													#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5506
													#$result["function"],當前執行的函數名稱.
-
 
5507
													#$result["argu"],使用的參數.
-
 
5508
													#$result["oriStr"],要處理的原始字串內容.
-
 
5509
													#$result["content"],處理好的的字串內容.
-
 
5510
													#$result["deleted"],被移除的內容.
-
 
5511
													#必填參數:
-
 
5512
													#$conf["stringIn"],字串,要處理的字串.
-
 
5513
													$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedOriLineContent;
-
 
5514
													#$conf["keyWord"],字串,特定字串.
-
 
5515
													$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$OderOfPartInLine[($index+1)]["value"];
-
 
5516
													#可省略參數:
-
 
5517
													#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
-
 
5518
													#$conf["recursive"]="true";
-
 
5519
													#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
-
 
5520
													#$conf["lastResult"]=$delStrBeforeKeyWord;
5407
													return $result;
5521
													#參考資料:
5408
												
5522
													#無.
-
 
5523
													#備註:
5409
													}#if end
5524
													#無.
-
 
5525
													$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5526
													unset($conf["stringProcess::delStrBeforeKeyWord"]);
5410
													
5527
													
5411
												#執行到這邊代表為 varPart
-
 
5412
												
-
 
5413
												#函式說明:
-
 
5414
												#取得關鍵字在字串的哪個位置(字首,字尾,中間)
-
 
5415
												#回傳結果:
-
 
5416
												#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
-
 
5417
												#$result["error"],錯誤訊息陣列.
-
 
5418
												#$result["function"],當前執行的函數名稱.
-
 
5419
												#$result["found"],是否有關鍵字存在,若為"true",代表存在;反之為"false".
-
 
5420
												#$result["argu"],傳入的參數.
-
 
5421
												#$result["head"],關鍵字是否在字串的開頭,"true"代表是,"false"代表不是.
-
 
5422
												#$result["tail"],關鍵字是否在字串的尾端,"true"代表是,"false"代表不是.
-
 
5423
												#$result["center"],關鍵字是否在字串的中間,"true"代表是,"false"代表不是.
-
 
5424
												#$result["indexS"],關鍵字在被搜尋字串的哪個位置開始.
-
 
5425
												#$result["indexE"],關鍵字在被搜尋字串的哪個位置結束.
-
 
5426
												#必填參數:
-
 
5427
												#$conf["inputStr"],字串,被搜尋的字串.
-
 
5428
												$conf["search::findKeyWordPosition"]["inputStr"]=$modifiedOriLineContent;
-
 
5429
												#$conf["keyWord"],字串,關鍵字.
-
 
5430
												$conf["search::findKeyWordPosition"]["keyWord"]=$OderOfPartInLine[($index+1)]["value"];
-
 
5431
												#可省略參數:
-
 
5432
												#無.
-
 
5433
												#參考資料:
-
 
5434
												#http://php.net/manual/en/function.strpos.php
-
 
5435
												#備註:
-
 
5436
												#無.
-
 
5437
												$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
-
 
5438
												unset($conf["search::findKeyWordPosition"]);
-
 
5439
											
-
 
5440
												#debug
5528
													#debug
5441
												#var_dump(__LINE__,$findKeyWordPosition);
5529
													#var_dump(__LINE__,$delStrBeforeKeyWord);
5442
											
-
 
5443
												#如果執行失敗
-
 
5444
												if($findKeyWordPosition["status"]==="false"){
-
 
5445
												
-
 
5446
													#設置錯誤識別
-
 
5447
													$result["status"]="false";
-
 
5448
													
5530
													
5449
													#設置錯誤訊息
5531
													#如果執行失敗
5450
													$result["error"]=$findKeyWordPosition;
5532
													if($delStrBeforeKeyWord["status"]==="false"){
5451
													
5533
													
5452
													#回傳結果
5534
														#設置錯誤識別
5453
													return $result;
5535
														$result["status"]="false";
5454
												
5536
														
-
 
5537
														#設置錯誤訊息
-
 
5538
														$result["error"]=$delStrBeforeKeyWord;
5455
													}#if end
5539
														
-
 
5540
														#回傳結果
-
 
5541
														return $result;
5456
													
5542
													
5457
												#如果沒有符合
5543
														}#if end
5458
												if($findKeyWordPosition["found"]==="false"){
-
 
5459
												
5544
														
5460
													#初始化關鍵字行
5545
													#如果該存在的關鍵字不在
5461
													$keyWordLineIndex=0;
5546
													if($delStrBeforeKeyWord["founded"]==="false"){
5462
													
5547
													
5463
													#換下行原始內容
5548
														#初始化關鍵字行
5464
													continue 5;
5549
														$keyWordLineIndex=0;
5465
												
5550
														
5466
													}#if end
5551
														#換下行原始內容
5467
												
5552
														continue 5;
5468
												#執行到這邊代表有符合
-
 
5469
												
5553
														
5470
												#函式說明:
5554
														}#if end
5471
												#將字串特定關鍵字與其前面的內容剔除
-
 
5472
												#回傳結果:
5555
													
5473
												#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5474
												#$result["error"],錯誤訊息陣列.
-
 
5475
												#$result["warning"],警告訊息鎮列.
5556
													#取得剩下未判斷是否符合的項目
5476
												#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
5557
													$modifiedOriLineContent=$OderOfPartInLine[($index+1)]["value"].$delStrBeforeKeyWord["content"];
5477
												#$result["function"],當前執行的函數名稱.
-
 
5478
												#$result["argu"],使用的參數.
-
 
5479
												#$result["oriStr"],要處理的原始字串內容.
-
 
5480
												#$result["content"],處理好的的字串內容.
-
 
5481
												#$result["deleted"],被移除的內容.
-
 
5482
												#必填參數:
5558
													
5483
												#$conf["stringIn"],字串,要處理的字串.
-
 
5484
												$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedOriLineContent;
-
 
5485
												#$conf["keyWord"],字串,特定字串.
-
 
5486
												$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$OderOfPartInLine[($index+1)]["value"];
-
 
5487
												#可省略參數:
5559
													#debug
5488
												#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
-
 
5489
												#$conf["recursive"]="true";
-
 
5490
												#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
-
 
5491
												#$conf["lastResult"]=$delStrBeforeKeyWord;
5560
													#var_dump(__LINE__,$modifiedOriLineContent);
5492
												#參考資料:
-
 
5493
												#無.
5561
													
5494
												#備註:
5562
													#換找下個資訊有無符合
5495
												#無.
5563
													continue 2;
5496
												$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5497
												unset($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5498
												
5564
												
5499
												#debug
5565
													break;
5500
												#var_dump(__LINE__,$delStrBeforeKeyWord);
-
 
5501
												
5566
												
5502
												#如果執行失敗
5567
												#其他狀況
5503
												if($delStrBeforeKeyWord["status"]==="false"){
5568
												default:
5504
												
5569
												
5505
													#設置錯誤識別
5570
													#設置錯誤識別
5506
													$result["status"]="false";
5571
													$result["status"]="false";
5507
													
5572
													
5508
													#設置錯誤訊息
5573
													#設置錯誤訊息
-
 
5574
													$result["error"][]="unexpected name value";
-
 
5575
													
-
 
5576
													#設置錯誤訊息
5509
													$result["error"]=$delStrBeforeKeyWord;
5577
													$result["error"][]=$condition;
5510
													
5578
													
5511
													#回傳結果
5579
													#回傳結果
5512
													return $result;
5580
													return $result;
5513
												
-
 
5514
													}#if end
-
 
5515
													
-
 
5516
												#如果該存在的關鍵字不在
-
 
5517
												if($delStrBeforeKeyWord["founded"]==="false"){
-
 
5518
												
-
 
5519
													#初始化關鍵字行
-
 
5520
													$keyWordLineIndex=0;
-
 
5521
													
-
 
5522
													#換下行原始內容
-
 
5523
													continue 5;
-
 
5524
													
-
 
5525
													}#if end
-
 
5526
												
-
 
5527
												#取得剩下未判斷是否符合的項目
-
 
5528
												$modifiedOriLineContent=$OderOfPartInLine[($index+1)]["value"].$delStrBeforeKeyWord["content"];
-
 
5529
												
-
 
5530
												#debug
-
 
5531
												#var_dump(__LINE__,$modifiedOriLineContent);
-
 
5532
												
-
 
5533
												#換找下個資訊有無符合
-
 
5534
												continue 2;
-
 
5535
											
5581
											
5536
												break;
5582
												}#switch end
5537
											
5583
											
5538
											#其他狀況
-
 
5539
											default:
5584
											}#foreach end
5540
											
5585
											
5541
												#設置錯誤識別
-
 
5542
												$result["status"]="false";
-
 
5543
												
-
 
5544
												#設置錯誤訊息
-
 
5545
												$result["error"][]="unexpected name value";
5586
										#執行到這邊代表該行有符合關鍵字的結構
5546
												
-
 
5547
												#設置錯誤訊息
-
 
5548
												$result["error"][]=$condition;
-
 
5549
												
-
 
5550
												#回傳結果
-
 
5551
												return $result;
-
 
5552
										
5587
										
-
 
5588
										#初始化期望的關鍵字內容
5553
											}#switch end
5589
										$fixedKeyWordVal="";
5554
										
5590
										
5555
										}#foreach end
5591
										#debug
-
 
5592
										#var_dump(__LINE__,$OderOfPartInLine);
5556
										
5593
										
5557
									#執行到這邊代表該行有符合關鍵字的結構
5594
										#針對關鍵字的每個字串段落
-
 
5595
										foreach($OderOfPartInLine as $indexOfOderOfPartInLine => $keyWordStrPart){
5558
									
5596
										
-
 
5597
											#串接之
-
 
5598
											$fixedKeyWordVal=$fixedKeyWordVal.$OderOfPartInLine[$indexOfOderOfPartInLine]["value"];
-
 
5599
										
-
 
5600
											}#foreach end
-
 
5601
										
-
 
5602
										#debug
-
 
5603
										#var_dump(__LINE__,$oriLineContent,$fixedKeyWordVal);
-
 
5604
										
-
 
5605
										#補上關鍵字前面的tab或空格
-
 
5606
										$fixedKeyWordVal=$keyWordContentOfHead.$fixedKeyWordVal;
-
 
5607
										
-
 
5608
										#如果內容有差
-
 
5609
										if($oriLineContent!=$fixedKeyWordVal){
-
 
5610
										
-
 
5611
											#debug
-
 
5612
											#var_dump(__LINE__,$oriLineContent,$fixedKeyWordVal);
-
 
5613
										
5559
									#初始化期望的關鍵字內容
5614
											#設置要取代的暫存資訊
5560
									$fixedKeyWordVal="";
5615
											$detailRepaceddInfo=array();
-
 
5616
										
-
 
5617
											#設置暫存的取代詳細資訊,包含取代的行(從0開始算),原始內容,新內容.
-
 
5618
											$detailRepaceddInfo[$oriLineContentIndex]=array("from"=>$oriLineContent,"to"=>$fixedKeyWordVal);
5561
									
5619
										
5562
									#debug
5620
											#debug
5563
									#var_dump(__LINE__,$OderOfPartInLine);
5621
											#var_dump(__LINE__,$detailRepaceddInfo);
-
 
5622
										
-
 
5623
											#儲存要取代的資訊
-
 
5624
											$replacedInfo[]=$detailRepaceddInfo;
-
 
5625
										
-
 
5626
											}#if end
-
 
5627
										
-
 
5628
										#取代期望的關鍵字
-
 
5629
										$modifiedKeyWordLine=$fixedKeyWordVal;
-
 
5630
										
-
 
5631
										#換看下行內容有無符合關鍵字,會執行for迴圈的 $keyWordLineIndex++
-
 
5632
										continue 3;
-
 
5633
										
-
 
5634
										}#if end
5564
									
5635
									
5565
									#針對關鍵字的每個字串段落
5636
									#結束 while
5566
									foreach($OderOfPartInLine as $indexOfOderOfPartInLine => $keyWordStrPart){
5637
									break;
5567
									
5638
									
5568
										#串接之
5639
									}#while end
5569
										$fixedKeyWordVal=$fixedKeyWordVal.$OderOfPartInLine[$indexOfOderOfPartInLine]["value"];
-
 
5570
									
5640
									
5571
										}#foreach end
5641
								#若原始內容沒有符合關鍵字
-
 
5642
								if($modifiedOriLineContent!==$modifiedKeyWordLine){
5572
									
5643
									
5573
									#debug
5644
									#debug
5574
									#var_dump(__LINE__,$oriLineContent,$fixedKeyWordVal);
5645
									#var_dump(__LINE__,$modifiedOriLineContent,$modifiedKeyWordLine);
-
 
5646
									
-
 
5647
									#初始化關鍵字行
-
 
5648
									$keyWordLineIndex=0;
5575
									
5649
									
5576
									#補上關鍵字前面的tab或空格
5650
									#換下行原始內容
5577
									$fixedKeyWordVal=$keyWordContentOfHead.$fixedKeyWordVal;
5651
									continue 2;
-
 
5652
								
-
 
5653
									}#if end
5578
									
5654
									
-
 
5655
								#反之代表內容有符合
-
 
5656
								else{
-
 
5657
								
-
 
5658
									#debug
-
 
5659
									#var_dump(__LINE__,"第 ".($keyWordLineIndex+1)." 個關鍵字有符合,總關鍵行有 ".count($conf["replaceFrom"])." 個");
-
 
5660
								
5579
									#如果內容有差
5661
									#如果內容有差
5580
									if($oriLineContent!=$fixedKeyWordVal){
5662
									if($oriLineContent!=$conf["replaceFrom"][$keyWordLineIndex]){
5581
									
5663
									
5582
										#debug
5664
										#debug
5583
										#var_dump(__LINE__,$oriLineContent,$fixedKeyWordVal);
5665
										#var_dump(__LINE__,$oriLineContent,$conf["replaceFrom"][$keyWordLineIndex]);
5584
									
5666
									
5585
										#設置要取代的暫存資訊
5667
										#設置要取代的暫存資訊
5586
										$detailRepaceddInfo=array();
5668
										$detailRepaceddInfo=array();
5587
									
5669
									
5588
										#設置暫存的取代詳細資訊,包含取代的行(從0開始算),原始內容,新內容.
5670
										#設置暫存的取代詳細資訊,包含取代的行(從0開始算),原始內容,新內容.
5589
										$detailRepaceddInfo[$oriLineContentIndex]=array("from"=>$oriLineContent,"to"=>$fixedKeyWordVal);
5671
										$detailRepaceddInfo[$oriLineContentIndex]=array("from"=>$oriLineContent,"to"=>$conf["replaceFrom"][$keyWordLineIndex]);
5590
									
-
 
5591
										#debug
-
 
5592
										#var_dump(__LINE__,$detailRepaceddInfo);
-
 
5593
									
5672
									
5594
										#儲存要取代的資訊
5673
										#儲存要取代的資訊
5595
										$replacedInfo[]=$detailRepaceddInfo;
5674
										$replacedInfo[]=$detailRepaceddInfo;
5596
									
5675
									
5597
										}#if end
5676
										}#if end
5598
									
5677
									
5599
									#取代期望的關鍵字
-
 
5600
									$modifiedKeyWordLine=$fixedKeyWordVal;
-
 
5601
									
-
 
5602
									#換看下行內容有無符合關鍵字,會執行for迴圈的 $keyWordLineIndex++
-
 
5603
									continue 3;
-
 
5604
									
-
 
5605
									}#if end
-
 
5606
								
-
 
5607
								#結束 while
-
 
5608
								break;
-
 
5609
								
-
 
5610
								}#while end
-
 
5611
								
-
 
5612
							#若原始內容沒有符合關鍵字
-
 
5613
							if($modifiedOriLineContent!==$modifiedKeyWordLine){
-
 
5614
								
-
 
5615
								#debug
-
 
5616
								#var_dump(__LINE__,$modifiedOriLineContent,$modifiedKeyWordLine);
-
 
5617
								
-
 
5618
								#初始化關鍵字行
-
 
5619
								$keyWordLineIndex=0;
-
 
5620
								
-
 
5621
								#換下行原始內容
-
 
5622
								continue 2;
-
 
5623
							
-
 
5624
								}#if end
-
 
5625
								
-
 
5626
							#反之代表內容有符合
-
 
5627
							else{
-
 
5628
							
-
 
5629
								#debug
-
 
5630
								#var_dump(__LINE__,"第 ".($keyWordLineIndex+1)." 個關鍵字有符合,總關鍵行有 ".count($conf["replaceFrom"])." 個");
-
 
5631
							
-
 
5632
								#如果內容有差
-
 
5633
								if($oriLineContent!=$conf["replaceFrom"][$keyWordLineIndex]){
-
 
5634
								
-
 
5635
									#debug
-
 
5636
									#var_dump(__LINE__,$oriLineContent,$conf["replaceFrom"][$keyWordLineIndex]);
-
 
5637
								
-
 
5638
									#設置要取代的暫存資訊
-
 
5639
									$detailRepaceddInfo=array();
-
 
5640
								
-
 
5641
									#設置暫存的取代詳細資訊,包含取代的行(從0開始算),原始內容,新內容.
-
 
5642
									$detailRepaceddInfo[$oriLineContentIndex]=array("from"=>$oriLineContent,"to"=>$conf["replaceFrom"][$keyWordLineIndex]);
-
 
5643
								
-
 
5644
									#儲存要取代的資訊
-
 
5645
									$replacedInfo[]=$detailRepaceddInfo;
-
 
5646
								
-
 
5647
									}#if end
-
 
5648
								
-
 
5649
								#若為最後一個關鍵行.
5678
									#若為最後一個關鍵行.
5650
								if( count($conf["replaceFrom"])===($keyWordLineIndex+1) ){
5679
									if( count($conf["replaceFrom"])===($keyWordLineIndex+1) ){
5651
								
-
 
5652
									#代表符合要取代的條件
-
 
5653
									$shouldReplace="true";
-
 
5654
									
-
 
5655
									#debug
-
 
5656
									#var_dump(__LINE__,$result["content"]);
-
 
5657
									
-
 
5658
									#如果沒有既有的記錄
-
 
5659
									if(!isset($result["content"][$NodePathAndName])){
-
 
5660
									
-
 
5661
										#記錄有更新的檔案路徑與名稱與其次數為1
-
 
5662
										$result["content"][$NodePathAndName]["time"]=1;
-
 
5663
									
5680
									
-
 
5681
										#代表符合要取代的條件
-
 
5682
										$shouldReplace="true";
-
 
5683
										
-
 
5684
										#debug
-
 
5685
										#var_dump(__LINE__,$result["content"]);
-
 
5686
										
-
 
5687
										#如果沒有既有的記錄
-
 
5688
										if(!isset($result["content"][$NodePathAndName])){
-
 
5689
										
-
 
5690
											#記錄有更新的檔案路徑與名稱與其次數為1
-
 
5691
											$result["content"][$NodePathAndName]["time"]=1;
-
 
5692
										
-
 
5693
											}#if end
-
 
5694
										
-
 
5695
										#反之
-
 
5696
										else{
-
 
5697
										
-
 
5698
											#記錄有更新的檔案路徑與名稱與的次數+1
-
 
5699
											$result["content"][$NodePathAndName]["time"]++;
-
 
5700
										
-
 
5701
											}#else end
-
 
5702
										
-
 
5703
										#記錄要更新的相關資訊
-
 
5704
										$result["content"][$NodePathAndName]["replacedInfo"]=$replacedInfo;
-
 
5705
										
-
 
5706
										#debug
-
 
5707
										#var_dump(__LINE__,$result["content"]);
-
 
5708
										
-
 
5709
										#關鍵字行初始化
-
 
5710
										$keyWordLineIndex=0;
-
 
5711
										
5664
										}#if end
5712
										}#if end
5665
									
5713
									
5666
									#反之
5714
									#反之
5667
									else{
5715
									else{
5668
									
5716
									
5669
										#記錄有更新的檔案路徑與名稱與的次數+1
5717
										#輪到下個關鍵字行
5670
										$result["content"][$NodePathAndName]["time"]++;
5718
										$keyWordLineIndex++;
5671
									
5719
									
5672
										}#else end
5720
										}#else end
5673
									
5721
									
5674
									#記錄要更新的相關資訊
5722
									#換找下個行內容有無符合關鍵字
5675
									$result["content"][$NodePathAndName]["replacedInfo"]=$replacedInfo;
-
 
5676
									
-
 
5677
									#debug
5723
									continue 2;
5678
									#var_dump(__LINE__,$result["content"]);
-
 
5679
									
-
 
5680
									#關鍵字行初始化
-
 
5681
									$keyWordLineIndex=0;
-
 
5682
									
5724
										
5683
									}#if end
-
 
5684
								
-
 
5685
								#反之
-
 
5686
								else{
-
 
5687
								
-
 
5688
									#輪到下個關鍵字行
-
 
5689
									$keyWordLineIndex++;
-
 
5690
								
-
 
5691
									}#else end
5725
									}#else end
5692
								
5726
								
5693
								#換找下個行內容有無符合關鍵字
-
 
5694
								continue 2;
-
 
5695
									
-
 
5696
								}#else end
5727
								}#for end
5697
							
5728
						
5698
							}#for end
5729
							}#for end
-
 
5730
							
-
 
5731
						}#if end
-
 
5732
						
-
 
5733
					#如果有需要更新檔案內容的識別
-
 
5734
					if($shouldReplace==="true"){
-
 
5735
					
-
 
5736
						#更新檔案內容
-
 
5737
						#...
5699
					
5738
					
-
 
5739
						}#if end
-
 
5740
					
5700
						}#for end
5741
						}#if end
5701
						
5742
						
-
 
5743
					#反之為多執行序
5702
					}#if end
5744
					else{
5703
					
5745
					
5704
				#如果有需要更新檔案內容的識別
-
 
5705
				if($shouldReplace==="true"){
-
 
5706
				
5746
						#...
5707
					#更新檔案內容
-
 
5708
					#...
5747
						#待實作
5709
				
5748
					
5710
					}#if end
5749
						}#else end
5711
					
5750
					
5712
				}#foreach end
5751
				}#foreach end
5713
			
5752
			
5714
			}#foreach end
5753
			}#foreach end
5715
		
5754
		
Line 6675... Line 6714...
6675
			return $result;
6714
			return $result;
6676
		
6715
		
6677
			}#else end
6716
			}#else end
6678
		
6717
		
6679
		}#function updateCopyRightYear end
6718
		}#function updateCopyRightYear end
-
 
6719
		
-
 
6720
	/*
-
 
6721
	#函式說明:
-
 
6722
	#置換檔案內容中符合的內容.
-
 
6723
	#回傳結果:
-
 
6724
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
6725
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
6726
	#$result["function"],當前執行的函式名稱.
-
 
6727
	#$result["argu"],本函式使用的參數.
-
 
6728
	#$result["content"],更新後的檔案內容陣列.每個元素代表一行的內容.
-
 
6729
	#$result["found"],字串,是否有找到符合條件需要置換的內容.
-
 
6730
	#$result["relaceInfo"],陣列,記錄需要置換的行資訊,元素的key為需要置換的行號,第 $i 行用 $i+1 表示.
-
 
6731
	#$result["relaceInfo"][$i]["ori"],字串,第 $i+1 行原始的內容.
-
 
6732
	#$result["relaceInfo"][$i]["new"],字串,第 $i+1 行要置換成的內容.
-
 
6733
	#$result["content"],陣列,替換完後的每行內容.
-
 
6734
	#必填參數:
-
 
6735
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
6736
	$conf["fileArgu"]=__FILE__;
-
 
6737
	#$conf["file"],字串,要置換內容的檔案路徑與名稱.
-
 
6738
	$conf["file"]="";
-
 
6739
	#$conf["formats"],陣列,連續的關鍵字字串.
-
 
6740
	$conf["formats"]=array();
-
 
6741
	#$conf["replaceTo"],陣列,原始內容要如何置換,每個元素的索引對應到formats參數的每個元素,若其索引不存在則代表對應的行不異動.
-
 
6742
	$conf["replaceTo"]=array();
-
 
6743
	#可省略參數:
-
 
6744
	#無.
-
 
6745
	#參考資料:
-
 
6746
	#無.
-
 
6747
	#備註:
-
 
6748
	#參數設定 $conf["replaceTo"][$i]=$replaceStr; 代表符合格式的連續字串中的 $i+1 行內容要置換成 $replaceStr.
-
 
6749
	#參數設定 $conf["replaceTo"][$i]=array("varName1"=>$replaceStr1,"varName2"=>$replaceStr2); 代表符合格式的連續字串中的 $i+1 行內容中的變數 varName1 要置換成 $replaceStr1;變數 varName2 要置換成 $replaceStr2.
-
 
6750
	*/
-
 
6751
	public static function replaceMatchContent(&$conf){
-
 
6752
		
-
 
6753
		#初始化要回傳的結果
-
 
6754
		$result=array();
-
 
6755
 
-
 
6756
		#取得當前執行的函數名稱
-
 
6757
		$result["function"]=__FUNCTION__;
-
 
6758
 
-
 
6759
		#如果沒有參數
-
 
6760
		if(func_num_args()==0){
-
 
6761
 
-
 
6762
			#設置執行失敗
-
 
6763
			$result["status"]="false";
-
 
6764
 
-
 
6765
			#設置執行錯誤訊息
-
 
6766
			$result["error"]="函數".$result["function"]."需要參數";
-
 
6767
 
-
 
6768
			#回傳結果
-
 
6769
			return $result;
-
 
6770
 
-
 
6771
			}#if end
-
 
6772
 
-
 
6773
		#取得參數
-
 
6774
		$result["argu"]=$conf;
-
 
6775
		
-
 
6776
		#如果 $conf 不為陣列
-
 
6777
		if(gettype($conf)!=="array"){
-
 
6778
 
-
 
6779
			#設置執行失敗
-
 
6780
			$result["status"]="false";
-
 
6781
 
-
 
6782
			#設置執行錯誤訊息
-
 
6783
			$result["error"][]="\$conf變數須為陣列形態";
-
 
6784
 
-
 
6785
			#如果傳入的參數為 null
-
 
6786
			if(is_null($conf)){
-
 
6787
 
-
 
6788
				#設置執行錯誤訊息
-
 
6789
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
-
 
6790
 
-
 
6791
				}#if end
-
 
6792
 
-
 
6793
			#回傳結果
-
 
6794
			return $result;
-
 
6795
 
-
 
6796
			}#if end
-
 
6797
		
-
 
6798
		#參數檢查
-
 
6799
		#函式說明:
-
 
6800
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
-
 
6801
		#回傳結果:
-
 
6802
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
6803
		#$result["error"],執行不正常結束的錯訊息陣列.
-
 
6804
		#$result["simpleError"],簡單表示的錯誤訊息.
-
 
6805
		#$result["function"],當前執行的函式名稱.
-
 
6806
		#$result["argu"],設置給予的參數.
-
 
6807
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
-
 
6808
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
-
 
6809
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
-
 
6810
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
-
 
6811
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
-
 
6812
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
-
 
6813
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
-
 
6814
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
-
 
6815
		#必填參數:
-
 
6816
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
-
 
6817
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
-
 
6818
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
-
 
6819
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
-
 
6820
		#可省略參數:
-
 
6821
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
-
 
6822
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","file","formats","replaceTo");
-
 
6823
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".
-
 
6824
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","array","array");
-
 
6825
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
-
 
6826
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
-
 
6827
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
-
 
6828
		#$conf["canNotBeEmpty"]=array();
-
 
6829
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
-
 
6830
		#$conf["canBeEmpty"]=array();
-
 
6831
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
-
 
6832
		#$conf["skipableVariableCanNotBeEmpty"]=array();
-
 
6833
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
-
 
6834
		#$conf["skipableVariableName"]=array();
-
 
6835
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
-
 
6836
		#$conf["skipableVariableType"]=array();
-
 
6837
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
-
 
6838
		#$conf["skipableVarDefaultValue"]=array("");
-
 
6839
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
-
 
6840
		#$conf["disallowAllSkipableVarIsEmpty"]="";
-
 
6841
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
-
 
6842
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
-
 
6843
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
-
 
6844
		#$conf["disallowAllSkipableVarNotExist"]="";
-
 
6845
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
-
 
6846
		#$conf["arrayCountEqualCheck"][]=array();
-
 
6847
		#參考資料:
-
 
6848
		#array_keys=>http://php.net/manual/en/function.array-keys.php
-
 
6849
		#備註:
-
 
6850
		#無.
-
 
6851
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
-
 
6852
		unset($conf["variableCheck::checkArguments"]);
-
 
6853
		
-
 
6854
		#如果執行失敗
-
 
6855
		if($checkArguments["status"]==="false"){
-
 
6856
		
-
 
6857
			#設置錯誤識別
-
 
6858
			$result["status"]="false";
-
 
6859
			
-
 
6860
			#設置錯誤訊息
-
 
6861
			$result["error"]=$checkArguments;
-
 
6862
			
-
 
6863
			#回傳結果
-
 
6864
			return $result;
-
 
6865
		
-
 
6866
			}#if end
-
 
6867
			
-
 
6868
		#如果檢查參數不通過
-
 
6869
		if($checkArguments["passed"]==="false"){
-
 
6870
		
-
 
6871
			#設置錯誤識別
-
 
6872
			$result["status"]="false";
-
 
6873
			
-
 
6874
			#設置錯誤訊息
-
 
6875
			$result["error"]=$checkArguments;
-
 
6876
			
-
 
6877
			#回傳結果
-
 
6878
			return $result;
-
 
6879
		
-
 
6880
			}#if end
-
 
6881
		
-
 
6882
		#取得檔案的內容
-
 
6883
		#函式說明:
-
 
6884
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
-
 
6885
		#回傳的變數說明:
-
 
6886
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
-
 
6887
		#$result["error"],錯誤訊息提示.
-
 
6888
		#$result["warning"],警告訊息.
-
 
6889
		#$result["function"],當前執行的函數名稱.
-
 
6890
		#$result["fileContent"],爲檔案的內容陣列.
-
 
6891
		#$result["lineCount"],爲檔案內容總共的行數.
-
 
6892
		#$result["fullContent"],為檔案的完整內容.
-
 
6893
		#$result["base64data"],為檔案的base64內容.
-
 
6894
		#$result["mimeType"],為檔案的mime type.
-
 
6895
		#必填參數:
-
 
6896
		#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
-
 
6897
		$conf["fileAccess::getFileContent"]["filePositionAndName"]=$conf["file"];
-
 
6898
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
6899
		$conf["fileAccess::getFileContent"]["fileArgu"]=$conf["fileArgu"];
-
 
6900
		#可省略參數:
-
 
6901
		#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
-
 
6902
		#$conf["web"]="true";
-
 
6903
		#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
-
 
6904
		#$conf["createIfnotExist"]="false";
-
 
6905
		#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
-
 
6906
		#$conf["autoDeleteSpaceOnEachLineStart"]="false";
-
 
6907
		#參考資料:
-
 
6908
		#file(),取得檔案內容的行數.
-
 
6909
		#file=>http:#php.net/manual/en/function.file.php
-
 
6910
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
-
 
6911
		#filesize=>http://php.net/manual/en/function.filesize.php
-
 
6912
		#參考資料:
-
 
6913
		#無.
-
 
6914
		#備註:
-
 
6915
		#無.
-
 
6916
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
-
 
6917
		unset($conf["fileAccess::getFileContent"]);
-
 
6918
	
-
 
6919
		#如果執行失敗
-
 
6920
		if($getFileContent["status"]==="false"){
-
 
6921
		
-
 
6922
			#設置錯誤識別
-
 
6923
			$result["status"]="false";
-
 
6924
			
-
 
6925
			#設置錯誤訊息
-
 
6926
			$result["error"]=$getFileContent;
-
 
6927
			
-
 
6928
			#回傳結果
-
 
6929
			return $result;
-
 
6930
		
-
 
6931
			}#if end
-
 
6932
			
-
 
6933
		#尋找連續的多行字串是否依順含有符合格式的內容,且回傳解析好的變數數值.
-
 
6934
		#回傳結果:
-
 
6935
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
6936
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
6937
		#$result["function"],當前執行的函式名稱.
-
 
6938
		#$result["argu"],所使用的參數.
-
 
6939
		#$result["found"],是否有找到符合格式的連續字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
6940
		#$result["content"],陣列,每段符合格式的段落資訊.
-
 
6941
		#$result["content"][$i]["lineS"],字串,為第 $i+1 個符合格式的段落起始行數.
-
 
6942
		#$result["content"][$i]["ori"],字串,為第 $i+1 個符合格式的段落每行原始內容資訊.
-
 
6943
		#$result["content"][$i]["deletedHead"],字串,為第 $i+1 個符合格式的段落每行原始內容被剔除的開頭資訊.
-
 
6944
		#$result["content"][$i]["new"],字串,為第 $i+1 個符合格式的段落每行關鍵字內容.
-
 
6945
		#$result["content"][$i]["vars"],陣列,為第 $i+1 個符合格式的段落每行變數解析的結果.
-
 
6946
		#必填參數:
-
 
6947
		#$conf["input"],字串陣列,要檢查的每行字串.
-
 
6948
		$conf["search::findConMatchStrs"]["input"]=$getFileContent["fileContent"];
-
 
6949
		#$conf["format"],格式字串陣列,要尋找的每行格式字串集合.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
6950
		$conf["search::findConMatchStrs"]["formats"]=$conf["formats"];
-
 
6951
		#可省略參數:
-
 
6952
		#無.
-
 
6953
		#參考資料:
-
 
6954
		#無.
-
 
6955
		#備註:
-
 
6956
		#回傳結果 $result["content"][$i]["ori"][$j]=array("index"=>$oriLineIndex,"value"=>$oriLineContent) 代表第 $i+1 個符合格式的段落中第 $j+1 個原始內容對應的行數($oriLineIndex+1),其原始內容為 $oriLineContent.
-
 
6957
		$findConMatchStrs=search::findConMatchStrs($conf["search::findConMatchStrs"]);
-
 
6958
		unset($conf["search::findConMatchStrs"]);
-
 
6959
	
-
 
6960
		#如果執行失敗
-
 
6961
		if($findConMatchStrs["status"]==="false"){
-
 
6962
		
-
 
6963
			#設置錯誤識別
-
 
6964
			$result["status"]="false";
-
 
6965
			
-
 
6966
			#設置錯誤訊息
-
 
6967
			$result["error"]=$findConMatchStrs;
-
 
6968
			
-
 
6969
			#回傳結果
-
 
6970
			return $result;
-
 
6971
		
-
 
6972
			}#if end
-
 
6973
		
-
 
6974
		#如果沒有符合的連續字串格式
-
 
6975
		if($findConMatchStrs["found"]==="false"){
-
 
6976
		
-
 
6977
			#設置執行正常的識別
-
 
6978
			$result["status"]="true";
-
 
6979
			
-
 
6980
			#設置沒有找到符合格式內容
-
 
6981
			$result["found"]="false";
-
 
6982
			
-
 
6983
			#回傳結果
-
 
6984
			return $result;
-
 
6985
		
-
 
6986
			}#if end
-
 
6987
		
-
 
6988
		#初始化儲存內容置換資訊的變數
-
 
6989
		$result["relaceInfo"]=array();
-
 
6990
		
-
 
6991
		#debug
-
 
6992
		#var_dump(__LINE__,$findConMatchStrs["content"]);exit;
-
 
6993
		
-
 
6994
		#執行到這邊代表有遇到符合的連續字串格式
-
 
6995
		foreach($findConMatchStrs["content"] as $matchSectionIndex => $sInfo){
-
 
6996
		
-
 
6997
			#針對符合的每行內容
-
 
6998
			foreach($sInfo["ori"] as $index => $lInfo){
-
 
6999
			
-
 
7000
				#取得對應的原始行索引
-
 
7001
				$oriLineNo=$lInfo["index"];
-
 
7002
				
-
 
7003
				#取得對應的原始行內容
-
 
7004
				$oriLineContent=$lInfo["value"];
-
 
7005
				
-
 
7006
				#儲存被剔除的開頭部分
-
 
7007
				$deletedOriHead=$lInfo["deletedHead"];
-
 
7008
			
-
 
7009
				#如果沒有對應的要取代格式
-
 
7010
				if(!isset($conf["replaceTo"][$index])){
-
 
7011
				
-
 
7012
					#不處理
-
 
7013
					continue;
-
 
7014
				
-
 
7015
					}#if end
-
 
7016
			
-
 
7017
				#如果解析的結果有變數
-
 
7018
				if(empty($sInfo["vars"][$index])){
-
 
7019
					
-
 
7020
					#debug
-
 
7021
					#var_dump(__LINE__,$index,$sInfo["vars"][$index]);
-
 
7022
					
-
 
7023
					#執行到這邊代表有對應的要取代格式
-
 
7024
					
-
 
7025
					#debug
-
 
7026
					#var_dump(__LINE__,$index,gettype($conf["replaceTo"][$index]),$conf["replaceTo"]);
-
 
7027
					
-
 
7028
					#如果取代格式不為字串
-
 
7029
					if(gettype($conf["replaceTo"][$index])!=="string"){
-
 
7030
					
-
 
7031
						#設置執行不正常的識別
-
 
7032
						$result["status"]="false";
-
 
7033
						
-
 
7034
						#設置錯誤訊息
-
 
7035
						$result["error"]="參數 formats 跟 replaceTo 的對應有錯誤.";
-
 
7036
						
-
 
7037
						#回傳結果
-
 
7038
						return $result;
-
 
7039
					
-
 
7040
						}#if end
-
 
7041
					
-
 
7042
					#執行到這邊代表檢查通過
-
 
7043
					
-
 
7044
					#記錄取代的資訊
-
 
7045
					$result["relaceInfo"][$oriLineNo]=array("deletedOriHead"=>$deletedOriHead,"ori"=>$oriLineContent,"new"=>$conf["replaceTo"][$index]);
-
 
7046
				
-
 
7047
					}#if end
-
 
7048
					
-
 
7049
				#反之代表有解析出變數
-
 
7050
				else{
-
 
7051
				
-
 
7052
					#debug
-
 
7053
					#var_dump(__LINE__,gettype($conf["replaceTo"][$index]));
-
 
7054
				
-
 
7055
					#如果取代格式不為陣列
-
 
7056
					if(gettype($conf["replaceTo"][$index])!=="array"){
-
 
7057
					
-
 
7058
						#設置執行不正常的識別
-
 
7059
						$result["status"]="false";
-
 
7060
						
-
 
7061
						#設置錯誤訊息
-
 
7062
						$result["error"]="參數 formats 跟 replaceTo 的對應有錯誤.";
-
 
7063
						
-
 
7064
						#回傳結果
-
 
7065
						return $result;
-
 
7066
					
-
 
7067
						}#if end
-
 
7068
						
-
 
7069
					#執行到這邊代表檢查通過
-
 
7070
					
-
 
7071
					#初始化替換好的內容
-
 
7072
					$newLineContent=$oriLineContent;
-
 
7073
					
-
 
7074
					#針對每個解析出來的變數
-
 
7075
					foreach($conf["replaceTo"][$index] as $varName => $newVal){
-
 
7076
						
-
 
7077
						#取得原始解析出來的內容
-
 
7078
						$oriVal=$sInfo["vars"][$index][$varName][0];
-
 
7079
						
-
 
7080
						#將關鍵字取代
-
 
7081
						#函式說明:
-
 
7082
						#將字串中的特定內容取代.
-
 
7083
						#回傳結果:
-
 
7084
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
7085
						#$result["function"],當前執行的函數.
-
 
7086
						#$result["content"],爲處理好的字串.
-
 
7087
						#$result["error"],錯誤訊息陣列.
-
 
7088
						#$result["argu"],使用的參數. 
-
 
7089
						#必填參數:
-
 
7090
						#$conf["stringIn"],字串,爲要處理的字串
-
 
7091
						$conf["stringProcess::replaceOnce"]["stringIn"]=$newLineContent;
-
 
7092
						#$conf["selectedCharacter"],字串,爲被選擇要處理的字串/字元,\n」代表換行,「\t」代表tab鍵的間隔.
-
 
7093
						$conf["stringProcess::replaceOnce"]["selectedCharacter"]=$oriVal;
-
 
7094
						#$conf["changeTo"],字串,爲被選擇的字元要換成什麼字串/字元.
-
 
7095
						$conf["stringProcess::replaceOnce"]["changeTo"]=$newVal;
-
 
7096
						#參考資料:
-
 
7097
						#無.
-
 
7098
						#備註:
-
 
7099
						#無.
-
 
7100
						$replaceOnce=stringProcess::replaceOnce($conf["stringProcess::replaceOnce"]);
-
 
7101
						unset($conf["stringProcess::replaceOnce"]);
-
 
7102
					
-
 
7103
						#debug
-
 
7104
						#var_dump(__LINE__,$replaceOnce);
-
 
7105
					
-
 
7106
						#如果執行失敗
-
 
7107
						if($replaceOnce["status"]==="false"){
-
 
7108
						
-
 
7109
							#設置錯誤識別
-
 
7110
							$result["status"]="false";
-
 
7111
							
-
 
7112
							#設置錯誤訊息
-
 
7113
							$result["error"]=$replaceOnce;
-
 
7114
							
-
 
7115
							#回傳結果
-
 
7116
							return $result;
-
 
7117
						
-
 
7118
							}#if end
-
 
7119
						
-
 
7120
						#儲存該階段替換好的內容
-
 
7121
						$newLineContent=$replaceOnce["content"];
-
 
7122
						
-
 
7123
						}#foreach end
-
 
7124
					
-
 
7125
					#記錄取代的資訊
-
 
7126
					$result["relaceInfo"][$oriLineNo]=array("deletedOriHead"=>$deletedOriHead,"ori"=>$oriLineContent,"new"=>$newLineContent);
-
 
7127
					
-
 
7128
					}#else end
-
 
7129
				
-
 
7130
				}#foreach end
-
 
7131
				
-
 
7132
			}#foreach end
-
 
7133
		
-
 
7134
		#初始化替換好的內容為原始內容
-
 
7135
		$result["content"]=$getFileContent["fileContent"];
-
 
7136
		
-
 
7137
		#依照內容替代的資訊
-
 
7138
		foreach($result["relaceInfo"] as $lineIndex =>$info){
-
 
7139
		
-
 
7140
			#儲存新的行內容
-
 
7141
			$newLine=$info["new"];
-
 
7142
			
-
 
7143
			#儲存被剔除的開頭字串
-
 
7144
			$deletedOriHead=$info["deletedOriHead"];
-
 
7145
		
-
 
7146
			#儲存置換好的行
-
 
7147
			$result["content"][$lineIndex]=$deletedOriHead.$newLine;
-
 
7148
		
-
 
7149
			}#foreach end
-
 
7150
		
-
 
7151
		#設置執行正常
-
 
7152
		$result["status"]="true";
-
 
7153
		
-
 
7154
		#回傳結果
-
 
7155
		return $result;
-
 
7156
			
-
 
7157
		}#function replaceMatchContent end
6680
	
7158
	
6681
	}#class phpLib end
7159
	}#class phpLib end
6682
 
7160
 
6683
?>
7161
?>
6684
7162