Subversion Repositories php-qbpwcf

Rev

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

Rev 220 Rev 221
Line 3844... Line 3844...
3844
 
3844
 
3845
		#儲存 lib folder
3845
		#儲存 lib folder
3846
		$folderOfUsrLib=$output[0];
3846
		$folderOfUsrLib=$output[0];
3847
		
3847
		
3848
		#儲存 lib path
3848
		#儲存 lib path
3849
		$libPath=$libRootPath."/usr/".$folderOfUsrLib;
3849
		#$libPath=$libRootPath."/usr/".$folderOfUsrLib;
3850
		
3850
		
3851
		#debug
3851
		#debug
3852
		#var_dump(__LINE__,$libPath);exit(1);
3852
		#var_dump(__LINE__,$libPath);exit(1);
3853
		
3853
		
3854
		#函式說明:
3854
		#函式說明:
Line 3920... Line 3920...
3920
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3920
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3921
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("replaceFrom","yearFrom","yearTo","Authors","searchPath","skipHiddenFolder","includeHiddenFolder","excludeDirName","excludeMineType","excludeSecondName","multiThread","threadType","socket","log","outputPath");
3921
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("replaceFrom","yearFrom","yearTo","Authors","searchPath","skipHiddenFolder","includeHiddenFolder","excludeDirName","excludeMineType","excludeSecondName","multiThread","threadType","socket","log","outputPath");
3922
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
3922
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
3923
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string","array","array","string","array","array","array","array","string","string","string","string","string");
3923
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string","array","array","string","array","array","array","array","string","string","string","string","string");
3924
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3924
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3925
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array($replaceFromArray,"2014",gmdate("Y"),array("MIN ZHI, CHEN"),array($libPath),"true",null,array("free-lib","no-free-lib","composer"),array("image/*","video/*","audio/*","media/*","application/*"),array("log","csv","sql","js","css","html"),"false","socket",qbpwcf_usock_path,null,$outputPath);
3925
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array($replaceFromArray,"2014",gmdate("Y"),array("MIN ZHI, CHEN"),array($libRootPath),"true",null,array("free-lib","no-free-lib","composer"),array("image/*","video/*","audio/*","media/*","application/*"),array("log","csv","sql","js","css","html"),"false","socket",qbpwcf_usock_path,null,$outputPath);
3926
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
3926
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
3927
		#$conf["disallowAllSkipableVarIsEmpty"]="";
3927
		#$conf["disallowAllSkipableVarIsEmpty"]="";
3928
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
3928
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
3929
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
3929
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
3930
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
3930
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
Line 4189... Line 4189...
4189
							
4189
							
4190
							#回傳結果
4190
							#回傳結果
4191
							return $result;
4191
							return $result;
4192
						
4192
						
4193
							}#if end
4193
							}#if end
4194
							
4194
						
4195
						#記錄有掃描的資料夾路徑與名稱 
4195
						#記錄有掃描的資料夾路徑與名稱 
4196
						$result["scannedFile"][]=$NodePathAndName;
4196
						$result["scannedFile"][]=$NodePathAndName;
4197
						
4197
						
4198
						#debug
4198
						#debug
4199
						#var_dump(__LINE__,"seartched node:".$NodePathAndName);
4199
						var_dump(__LINE__,"seartched node(folder):".$NodePathAndName);
4200
						
4200
						
4201
						#合併 content - start
4201
						#合併 content - start
4202
						
4202
						
4203
						#函式說明:
4203
						#函式說明:
4204
						#將多個一維陣列串聯起來,key從0開始排序.
4204
						#將多個一維陣列串聯起來,key從0開始排序.
Line 4775... Line 4775...
4775
							
4775
							
4776
							#回傳結果
4776
							#回傳結果
4777
							return $result;
4777
							return $result;
4778
						
4778
						
4779
							}#if end
4779
							}#if end
4780
					
-
 
4781
						/*
-
 
4782
					
-
 
4783
						#取得檔案的內容
-
 
4784
						#函式說明:
-
 
4785
						#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
-
 
4786
						#回傳的變數說明:
-
 
4787
						#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
-
 
4788
						#$result["error"],錯誤訊息提示.
-
 
4789
						#$result["warning"],警告訊息.
-
 
4790
						#$result["function"],當前執行的函數名稱.
-
 
4791
						#$result["fileContent"],爲檔案的內容陣列.
-
 
4792
						#$result["lineCount"],爲檔案內容總共的行數.
-
 
4793
						#$result["fullContent"],為檔案的完整內容.
-
 
4794
						#$result["base64data"],為檔案的base64內容.
-
 
4795
						#$result["mimeType"],為檔案的mime type.
-
 
4796
						#必填參數:
-
 
4797
						#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
-
 
4798
						$conf["fileAccess::getFileContent"]["filePositionAndName"]=$NodePathAndName;
-
 
4799
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
4800
						$conf["fileAccess::getFileContent"]["fileArgu"]=$conf["fileArgu"];
-
 
4801
						#可省略參數:
-
 
4802
						#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
-
 
4803
						#$conf["web"]="true";
-
 
4804
						#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
-
 
4805
						#$conf["createIfnotExist"]="false";
-
 
4806
						#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
-
 
4807
						#$conf["autoDeleteSpaceOnEachLineStart"]="false";
-
 
4808
						#參考資料:
-
 
4809
						#file(),取得檔案內容的行數.
-
 
4810
						#file=>http:#php.net/manual/en/function.file.php
-
 
4811
						#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
-
 
4812
						#filesize=>http://php.net/manual/en/function.filesize.php
-
 
4813
						#參考資料:
-
 
4814
						#無.
-
 
4815
						#備註:
-
 
4816
						#無.
-
 
4817
						$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
-
 
4818
						unset($conf["fileAccess::getFileContent"]);
-
 
4819
					
-
 
4820
						#如果執行失敗
-
 
4821
						if($getFileContent["status"]==="false"){
-
 
4822
						
-
 
4823
							#設置錯誤識別
-
 
4824
							$result["status"]="false";
-
 
4825
							
-
 
4826
							#設置錯誤訊息
-
 
4827
							$result["error"]=$getFileContent;
-
 
4828
							
-
 
4829
							#回傳結果
-
 
4830
							return $result;
-
 
4831
						
-
 
4832
							}#if end
-
 
4833
					
-
 
4834
						#關鍵字行搜尋的索引預設數值為0
-
 
4835
						$keyWordLineIndex=0;
-
 
4836
					
-
 
4837
						#針對檔案每行原始內容
-
 
4838
						for($oriLineContentIndex=0;$oriLineContentIndex<$getFileContent["lineCount"];$oriLineContentIndex++){
-
 
4839
						
-
 
4840
							#取得原始內容行
-
 
4841
							$oriLineContent=$getFileContent["fileContent"][$oriLineContentIndex];
-
 
4842
						
-
 
4843
							#預設調整後的原始內容跟原本一樣
-
 
4844
							$modifiedOriLineContent=$oriLineContent;
-
 
4845
						
-
 
4846
							#如果要log
-
 
4847
							if(isset($conf["log"])){
-
 
4848
								
-
 
4849
								#提示正在比對哪個檔案的第幾行
-
 
4850
								$log="比對 檔案(".$path.$node["name"].") 的第 ".($oriLineContentIndex+1)." 行...".PHP_EOL;
-
 
4851
								
-
 
4852
								#提示原始內容
-
 
4853
								$log=$log."原始內容為:".PHP_EOL;
-
 
4854
								
-
 
4855
								#印出原始內容
-
 
4856
								$log=$log.$oriLineContent.PHP_EOL;
-
 
4857
								
-
 
4858
								#log的路徑與名稱
-
 
4859
								$logPath="/tmp/".basename($conf["log"]).":".$uuid.":".$node["name"].".log";
-
 
4860
							
-
 
4861
								#函式說明:
-
 
4862
								#撰寫log
-
 
4863
								#回傳結果:
-
 
4864
								#$result["status"],狀態,"true"或"false".
-
 
4865
								#$result["error"],錯誤訊息陣列.
-
 
4866
								#$result["function"],當前函式的名稱.
-
 
4867
								#$result["argu"],使用的參數.
-
 
4868
								#必填參數:
-
 
4869
								#$conf["path"],字串,log檔案的路徑與名稱.
-
 
4870
								$conf["logs::record"]["path"]=$logPath;
-
 
4871
								#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
4872
								$conf["logs::record"]["content"]=$log;
-
 
4873
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
4874
								$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
4875
								#可省略參數:
-
 
4876
								#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
4877
								#$conf["rewrite"]="false";
-
 
4878
								#參考資料:
-
 
4879
								#無.
-
 
4880
								#備註:
-
 
4881
								#無.
-
 
4882
								$record=logs::record($conf["logs::record"]);
-
 
4883
								unset($conf["logs::record"]);
-
 
4884
							
-
 
4885
								#如果出錯
-
 
4886
								if($record["status"]==="false"){
-
 
4887
							
-
 
4888
									#設置錯誤識別
-
 
4889
									$result["status"]="false";
-
 
4890
									
-
 
4891
									#設置錯誤訊息
-
 
4892
									$result["error"]=$getFileContent;
-
 
4893
									
-
 
4894
									#回傳結果
-
 
4895
									return $result;
-
 
4896
									
-
 
4897
									}#if end
-
 
4898
							
-
 
4899
								}#if end
-
 
4900
						
-
 
4901
							#無窮迴圈
-
 
4902
							while(true){
-
 
4903
							
-
 
4904
								#嘗試移除開頭的 空格 跟 \t
-
 
4905
								
-
 
4906
								#函式說明:
-
 
4907
								#取得符合多個特定字首與字尾的字串
-
 
4908
								#回傳結果:
-
 
4909
								#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
-
 
4910
								#$result["function"],當前執行的函數名稱.
-
 
4911
								#$result["error"],錯誤訊息陣列.
-
 
4912
								#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
-
 
4913
								#$result["content"],符合條件的字串,去掉字首字尾後的結果.
-
 
4914
								#$result["returnString"],爲符合字首字、尾條件的字串內容.
-
 
4915
								#$result["meetConditions"],為符合的條件,會是$conf["keyWord"]中的其中一個元素.
-
 
4916
								#$result["argu"],使用的參數.
-
 
4917
								#必填參數:
-
 
4918
								#$conf["checkString"],字串,要檢查的字串.
-
 
4919
								$conf["search::getMeetMultiConditionsString"]["checkString"]=$modifiedOriLineContent;
-
 
4920
								#$conf["keyWord"],字串陣列,用來檢查字首、字尾應該要有哪些字串之一,每個元素代表一個可能的條件,key為front者代表開頭的關鍵字,key為tail為代表結尾的官關鍵字.
-
 
4921
								$conf["search::getMeetMultiConditionsString"]["keyWord"]=array(array("front"=>" "),array("front"=>"\t"));
-
 
4922
								#可省略參數:
-
 
4923
								#無.
-
 
4924
								#參考資料:
-
 
4925
								#無.
-
 
4926
								#備註:
-
 
4927
								#無.
-
 
4928
								$getMeetMultiConditionsString=search::getMeetMultiConditionsString($conf["search::getMeetMultiConditionsString"]);
-
 
4929
								unset($conf["search::getMeetMultiConditionsString"]);
-
 
4930
								
-
 
4931
								#debug
-
 
4932
								#var_dump(__LINE__,$getMeetMultiConditionsString);
-
 
4933
								
-
 
4934
								#如果執行失敗
-
 
4935
								if($getMeetMultiConditionsString["status"]==="false"){
-
 
4936
								
-
 
4937
									#設置錯誤識別
-
 
4938
									$result["status"]="false";
-
 
4939
									
-
 
4940
									#設置錯誤訊息
-
 
4941
									$result["error"]=$getMeetMultiConditionsString;
-
 
4942
									
-
 
4943
									#回傳結果
-
 
4944
									return $result;
-
 
4945
								
-
 
4946
									}#if end
-
 
4947
									
-
 
4948
								#如果有關鍵字存在
-
 
4949
								if($getMeetMultiConditionsString["founded"]==="true"){
-
 
4950
								
-
 
4951
									#取得已經移開頭空格跟\t後的內容
-
 
4952
									$modifiedOriLineContent=$getMeetMultiConditionsString["content"];
-
 
4953
								
-
 
4954
									#繼續檢查
-
 
4955
									continue;
-
 
4956
								
-
 
4957
									}#if end
-
 
4958
								
-
 
4959
								#到這表代表已經移除開頭的 空格 跟 \t
-
 
4960
								
-
 
4961
								#結束 while
-
 
4962
								break;
-
 
4963
							
-
 
4964
								}#while end
-
 
4965
							
-
 
4966
							#針對每個關鍵字
-
 
4967
							for(;$keyWordLineIndex<count($conf["replaceFrom"]);$keyWordLineIndex++){
-
 
4968
							
-
 
4969
								#取得關鍵字行的內容
-
 
4970
								$keyWordLine=$conf["replaceFrom"][$keyWordLineIndex];
-
 
4971
							
-
 
4972
								#如果要log
-
 
4973
								if(isset($conf["log"])){
-
 
4974
								
-
 
4975
									#提示期望的內容格式
-
 
4976
									$log="期望的第 ".($keyWordLineIndex+1)." 個行內容格式為:".PHP_EOL;
-
 
4977
									
-
 
4978
									#提示期望的內容
-
 
4979
									$log=$log.$keyWordLine.PHP_EOL;
-
 
4980
								
-
 
4981
									#log的路徑與名稱
-
 
4982
									$logPath="/tmp/".basename($conf["log"]).":".$uuid.":".$node["name"].".log";
-
 
4983
								
-
 
4984
									#函式說明:
-
 
4985
									#撰寫log
-
 
4986
									#回傳結果:
-
 
4987
									#$result["status"],狀態,"true"或"false".
-
 
4988
									#$result["error"],錯誤訊息陣列.
-
 
4989
									#$result["function"],當前函式的名稱.
-
 
4990
									#$result["argu"],使用的參數.
-
 
4991
									#必填參數:
-
 
4992
									#$conf["path"],字串,log檔案的路徑與名稱.
-
 
4993
									$conf["logs::record"]["path"]=$logPath;
-
 
4994
									#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
-
 
4995
									$conf["logs::record"]["content"]=$log;
-
 
4996
									#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
-
 
4997
									$conf["logs::record"]["fileArgu"]=__FILE__;
-
 
4998
									#可省略參數:
-
 
4999
									#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
-
 
5000
									#$conf["rewrite"]="false";
-
 
5001
									#參考資料:
-
 
5002
									#無.
-
 
5003
									#備註:
-
 
5004
									#無.
-
 
5005
									$record=logs::record($conf["logs::record"]);
-
 
5006
									unset($conf["logs::record"]);
-
 
5007
								
-
 
5008
									#如果出錯
-
 
5009
									if($record["status"]==="false"){
-
 
5010
								
-
 
5011
										#設置錯誤識別
-
 
5012
										$result["status"]="false";
-
 
5013
										
-
 
5014
										#設置錯誤訊息
-
 
5015
										$result["error"]=$getFileContent;
-
 
5016
										
-
 
5017
										#回傳結果
-
 
5018
										return $result;
-
 
5019
										
-
 
5020
										}#if end
-
 
5021
								
-
 
5022
									}#if end
-
 
5023
							
-
 
5024
								#調整過的關鍵字內容行預設跟原始關鍵行內容一樣
-
 
5025
								$modifiedKeyWordLine=$keyWordLine;
-
 
5026
								
-
 
5027
								#初始化關鍵字前面的內容(可能有為多個空格或tab)
-
 
5028
								$keyWordContentOfHead="";
-
 
5029
								
-
 
5030
								#無窮迴圈
-
 
5031
								while(true){
-
 
5032
								
-
 
5033
									#嘗試剔除開頭的 空格 跟 "\t"
-
 
5034
								
-
 
5035
									#函式說明:
-
 
5036
									#取得符合多個特定字首與字尾的字串
-
 
5037
									#回傳結果:
-
 
5038
									#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
-
 
5039
									#$result["function"],當前執行的函數名稱.
-
 
5040
									#$result["error"],錯誤訊息陣列.
-
 
5041
									#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
-
 
5042
									#$result["content"],符合條件的字串,去掉字首字尾後的結果.
-
 
5043
									#$result["returnString"],爲符合字首字、尾條件的字串內容.
-
 
5044
									#$result["meetConditions"],為符合的條件,會是$conf["keyWord"]中的其中一個元素.
-
 
5045
									#$result["argu"],使用的參數.
-
 
5046
									#必填參數:
-
 
5047
									#$conf["checkString"],字串,要檢查的字串.
-
 
5048
									$conf["search::getMeetMultiConditionsString"]["checkString"]=$modifiedKeyWordLine;
-
 
5049
									#$conf["keyWord"],字串陣列,用來檢查字首、字尾應該要有哪些字串之一,每個元素代表一個可能的條件,key為front者代表開頭的關鍵字,key為tail為代表結尾的官關鍵字.
-
 
5050
									$conf["search::getMeetMultiConditionsString"]["keyWord"]=array(array("front"=>" "),array("front"=>"\t"));
-
 
5051
									#可省略參數:
-
 
5052
									#無.
-
 
5053
									#參考資料:
-
 
5054
									#無.
-
 
5055
									#備註:
-
 
5056
									#無.
-
 
5057
									$getMeetMultiConditionsString=search::getMeetMultiConditionsString($conf["search::getMeetMultiConditionsString"]);
-
 
5058
									unset($conf["search::getMeetMultiConditionsString"]);
-
 
5059
									
-
 
5060
									#debug
-
 
5061
									#var_dump(__LINE__,$getMeetMultiConditionsString);
-
 
5062
									
-
 
5063
									#如果執行失敗
-
 
5064
									if($getMeetMultiConditionsString["status"]==="false"){
-
 
5065
									
-
 
5066
										#設置錯誤識別
-
 
5067
										$result["status"]="false";
-
 
5068
										
-
 
5069
										#設置錯誤訊息
-
 
5070
										$result["error"]=$getMeetMultiConditionsString;
-
 
5071
										
-
 
5072
										#回傳結果
-
 
5073
										return $result;
-
 
5074
									
-
 
5075
										}#if end
-
 
5076
										
-
 
5077
									#如果有關鍵字存在
-
 
5078
									if($getMeetMultiConditionsString["founded"]==="true"){
-
 
5079
									
-
 
5080
										#取得移除開頭 空格 跟 \t 後的內容
-
 
5081
										$modifiedKeyWordLine=$getMeetMultiConditionsString["content"];
-
 
5082
										
-
 
5083
										#取得關鍵字前面的內容
-
 
5084
										$keyWordContentOfHead=substr($keyWordLine,0,strlen($keyWordLine)-strlen($modifiedKeyWordLine));
-
 
5085
										
-
 
5086
										#繼續檢查
-
 
5087
										continue;
-
 
5088
										
-
 
5089
										}#if end
-
 
5090
								
-
 
5091
									#到這表代表已經移除開頭的 空格 跟 \t
-
 
5092
								
-
 
5093
									#結束 while
-
 
5094
									break;
-
 
5095
									
-
 
5096
									}#while end
-
 
5097
							
-
 
5098
								#debug
-
 
5099
								#var_dump(__LINE__,$modifiedOriLineContent,$modifiedKeyWordLine);
-
 
5100
							
-
 
5101
								#預設分段的關鍵字為空
-
 
5102
								$keyWordPart=array();
-
 
5103
								
-
 
5104
								#預設該行的變數為空
-
 
5105
								$varPart=array();
-
 
5106
								
-
 
5107
								#關鍵字行的結構順序
-
 
5108
								$OderOfPartInLine=array();
-
 
5109
							
-
 
5110
								#無窮迴圈
-
 
5111
								while(true){
-
 
5112
								
-
 
5113
									#判斷是否含有 "${"、"}" 關鍵字
-
 
5114
									#函式說明:
-
 
5115
									#檢查一個字串裡面是否有多個關鍵字
-
 
5116
									#回傳結果:
-
 
5117
									#$result["status"],"true"代表執行成功,"false"代表執行失敗.
-
 
5118
									#$result["error"],錯誤訊息.
-
 
5119
									#$result["function"],當前執行的函數名稱.
-
 
5120
									#$result["founded"],是否有找到的關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字.
-
 
5121
									#$result["foundedKeyWords"],找到的關鍵字.
-
 
5122
									#$result["foundedAll"],是否有找到全部的關鍵字,"true"代表有;"false"代表沒有.
-
 
5123
									#$result["argu"],使用的參數.
-
 
5124
									#必填參數:
-
 
5125
									#$conf["keyWords"],字串陣列,想要搜尋的關鍵字.
-
 
5126
									$conf["search::findManyKeyWords"]["keyWords"]=array("\${","}");
-
 
5127
									#$conf["string"],字串,要被搜尋的字串內容.
-
 
5128
									$conf["search::findManyKeyWords"]["string"]=$modifiedKeyWordLine;
-
 
5129
									#可省略參數:
-
 
5130
									#$conf["completeEqual"],字串,是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合.
-
 
5131
									#$conf["completeEqual"]="true";
-
 
5132
									#參考資料:
-
 
5133
									#無.
-
 
5134
									#備註:
-
 
5135
									#無.
-
 
5136
									$findManyKeyWords=search::findManyKeyWords($conf["search::findManyKeyWords"]);
-
 
5137
									unset($conf["search::findManyKeyWords"]);
-
 
5138
									
-
 
5139
									#如果執行失敗
-
 
5140
									if($findManyKeyWords["status"]==="false"){
-
 
5141
									
-
 
5142
										#設置錯誤識別
-
 
5143
										$result["status"]="false";
-
 
5144
										
-
 
5145
										#設置錯誤訊息
-
 
5146
										$result["error"]=$findManyKeyWords;
-
 
5147
										
-
 
5148
										#回傳結果
-
 
5149
										return $result;
-
 
5150
									
-
 
5151
										}#if end
-
 
5152
										
-
 
5153
									#如果有 "${"、"}" 存在
-
 
5154
									if($findManyKeyWords["foundedAll"]==="true"){
-
 
5155
									
-
 
5156
										#debug
-
 
5157
										#var_dump(__LINE__,$findManyKeyWords);
-
 
5158
									
-
 
5159
										#取得 ${... 前面的部分
-
 
5160
										#函式說明:
-
 
5161
										#將字串特定關鍵字與其後面的內容剔除
-
 
5162
										#回傳結果:
-
 
5163
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5164
										#$result["error"],錯誤訊息陣列.
-
 
5165
										#$result["warning"],警告訊息鎮列.
-
 
5166
										#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5167
										#$result["function"],當前執行的函數名稱.
-
 
5168
										#$result["oriStr"],要處理的原始字串內容.
-
 
5169
										#$result["content"],處理好的的字串內容.
-
 
5170
										#$result["argu"],使用的參數.
-
 
5171
										#必填參數:
-
 
5172
										#$conf["stringIn"],字串,要處理的字串.
-
 
5173
										$conf["stringProcess::delStrAfterKeyWord"]["stringIn"]=$modifiedKeyWordLine;
-
 
5174
										#$conf["keyWord"],字串,特定字串.
-
 
5175
										$conf["stringProcess::delStrAfterKeyWord"]["keyWord"]="\${";
-
 
5176
										#可省略參數:
-
 
5177
										#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
-
 
5178
										#$conf["deleteLastRepeatedOne"]="";
-
 
5179
										#參考資料:
-
 
5180
										#無.
-
 
5181
										#備註:
-
 
5182
										#無.
-
 
5183
										$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
-
 
5184
										unset($conf["stringProcess::delStrAfterKeyWord"]);
-
 
5185
										
-
 
5186
										#debug
-
 
5187
										#var_dump(__LINE__,$delStrAfterKeyWord);
-
 
5188
										
-
 
5189
										#如果執行失敗
-
 
5190
										if($delStrAfterKeyWord["status"]==="false"){
-
 
5191
										
-
 
5192
											#設置錯誤識別
-
 
5193
											$result["status"]="false";
-
 
5194
											
-
 
5195
											#設置錯誤訊息
-
 
5196
											$result["error"]=$delStrAfterKeyWord;
-
 
5197
											
-
 
5198
											#回傳結果
-
 
5199
											return $result;
-
 
5200
										
-
 
5201
											}#if end
-
 
5202
											
-
 
5203
										#如果要有關鍵字找不到
-
 
5204
										if($delStrAfterKeyWord["founded"]==="false"){
-
 
5205
										
-
 
5206
											#設置錯誤識別
-
 
5207
											$result["status"]="false";
-
 
5208
											
-
 
5209
											#設置錯誤訊息
-
 
5210
											$result["error"]=$delStrAfterKeyWord;
-
 
5211
											
-
 
5212
											#回傳結果
-
 
5213
											return $result;
-
 
5214
										
-
 
5215
											}#if end
-
 
5216
										
-
 
5217
										#如果前面有內容
-
 
5218
										if($delStrAfterKeyWord["content"]!==""){
-
 
5219
										
-
 
5220
											#儲存該行的關鍵字之一
-
 
5221
											$keyWordPart[]=$delStrAfterKeyWord["content"];
-
 
5222
										
-
 
5223
											#暫存的關鍵字資訊
-
 
5224
											$tmp=array("name"=>"keyWordPart","index"=>count($keyWordPart)-1,"value"=>$keyWordPart[count($keyWordPart)-1]);
-
 
5225
				
-
 
5226
											#設置順序資訊
-
 
5227
											$OderOfPartInLine[]=$tmp;
-
 
5228
										
-
 
5229
											}#if end
-
 
5230
										
-
 
5231
										#取得 }... 前面的部分
-
 
5232
										#函式說明:
-
 
5233
										#將字串特定關鍵字與其後面的內容剔除
-
 
5234
										#回傳結果:
-
 
5235
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5236
										#$result["error"],錯誤訊息陣列.
-
 
5237
										#$result["warning"],警告訊息鎮列.
-
 
5238
										#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5239
										#$result["function"],當前執行的函數名稱.
-
 
5240
										#$result["oriStr"],要處理的原始字串內容.
-
 
5241
										#$result["content"],處理好的的字串內容.
-
 
5242
										#$result["argu"],使用的參數.
-
 
5243
										#必填參數:
-
 
5244
										#$conf["stringIn"],字串,要處理的字串.
-
 
5245
										$conf["stringProcess::delStrAfterKeyWord"]["stringIn"]=$delStrAfterKeyWord["deleted"];
-
 
5246
										#$conf["keyWord"],字串,特定字串.
-
 
5247
										$conf["stringProcess::delStrAfterKeyWord"]["keyWord"]="}";
-
 
5248
										#可省略參數:
-
 
5249
										#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
-
 
5250
										#$conf["deleteLastRepeatedOne"]="";
-
 
5251
										#參考資料:
-
 
5252
										#無.
-
 
5253
										#備註:
-
 
5254
										#無.
-
 
5255
										$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
-
 
5256
										unset($conf["stringProcess::delStrAfterKeyWord"]);
-
 
5257
										
-
 
5258
										#debug
-
 
5259
										#var_dump(__LINE__,$delStrAfterKeyWord);
-
 
5260
										
-
 
5261
										#如果執行失敗
-
 
5262
										if($delStrAfterKeyWord["status"]==="false"){
-
 
5263
										
-
 
5264
											#設置錯誤識別
-
 
5265
											$result["status"]="false";
-
 
5266
											
-
 
5267
											#設置錯誤訊息
-
 
5268
											$result["error"]=$delStrAfterKeyWord;
-
 
5269
											
-
 
5270
											#回傳結果
-
 
5271
											return $result;
-
 
5272
										
-
 
5273
											}#if end
-
 
5274
											
-
 
5275
										#如果要有關鍵字找不到
-
 
5276
										if($delStrAfterKeyWord["founded"]==="false"){
-
 
5277
										
-
 
5278
											#設置錯誤識別
-
 
5279
											$result["status"]="false";
-
 
5280
											
-
 
5281
											#設置錯誤訊息
-
 
5282
											$result["error"]=$delStrAfterKeyWord;
-
 
5283
											
-
 
5284
											#回傳結果
-
 
5285
											return $result;
-
 
5286
										
-
 
5287
											}#if end
-
 
5288
										
-
 
5289
										#儲存該行的變數名稱之一
-
 
5290
										$varPart[]=$delStrAfterKeyWord["content"]."}";
-
 
5291
										
-
 
5292
										#移除 "}" 其面的內容
-
 
5293
										#函式說明:
-
 
5294
										#將字串特定關鍵字與其前面的內容剔除
-
 
5295
										#回傳結果:
-
 
5296
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5297
										#$result["error"],錯誤訊息陣列.
-
 
5298
										#$result["warning"],警告訊息鎮列.
-
 
5299
										#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5300
										#$result["function"],當前執行的函數名稱.
-
 
5301
										#$result["argu"],使用的參數.
-
 
5302
										#$result["oriStr"],要處理的原始字串內容.
-
 
5303
										#$result["content"],處理好的的字串內容.
-
 
5304
										#$result["deleted"],被移除的內容.
-
 
5305
										#必填參數:
-
 
5306
										#$conf["stringIn"],字串,要處理的字串.
-
 
5307
										$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedKeyWordLine;
-
 
5308
										#$conf["keyWord"],字串,特定字串.
-
 
5309
										$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="}";
-
 
5310
										#可省略參數:
-
 
5311
										#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
-
 
5312
										#$conf["recursive"]="true";
-
 
5313
										#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
-
 
5314
										#$conf["lastResult"]=$delStrBeforeKeyWord;
-
 
5315
										#參考資料:
-
 
5316
										#無.
-
 
5317
										#備註:
-
 
5318
										#無.
-
 
5319
										$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5320
										unset($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5321
										
-
 
5322
										#如果執行失敗
-
 
5323
										if($delStrBeforeKeyWord["status"]==="false"){
-
 
5324
										
-
 
5325
											#設置錯誤識別
-
 
5326
											$result["status"]="false";
-
 
5327
											
-
 
5328
											#設置錯誤訊息
-
 
5329
											$result["error"]=$delStrBeforeKeyWord;
-
 
5330
											
-
 
5331
											#回傳結果
-
 
5332
											return $result;
-
 
5333
										
-
 
5334
											}#if end
-
 
5335
											
-
 
5336
										#如果要有關鍵字找不到
-
 
5337
										if($delStrBeforeKeyWord["founded"]==="false"){
-
 
5338
										
-
 
5339
											#設置錯誤識別
-
 
5340
											$result["status"]="false";
-
 
5341
											
-
 
5342
											#設置錯誤訊息
-
 
5343
											$result["error"]=$delStrBeforeKeyWord;
-
 
5344
											
-
 
5345
											#回傳結果
-
 
5346
											return $result;
-
 
5347
										
-
 
5348
											}#if end
-
 
5349
										
-
 
5350
										#取得剩下的部分
-
 
5351
										$modifiedKeyWordLine=$delStrBeforeKeyWord["content"];
-
 
5352
										
-
 
5353
										#暫存的關鍵字資訊
-
 
5354
										$tmp=array("name"=>"varPart","index"=>count($varPart)-1,"value"=>$varPart[count($varPart)-1]);
-
 
5355
			
-
 
5356
										#設置順序資訊
-
 
5357
										$OderOfPartInLine[]=$tmp;
-
 
5358
										
-
 
5359
										#下一輪檢查有無變數關鍵字
-
 
5360
										continue;
-
 
5361
										
-
 
5362
										}#if end
-
 
5363
									
-
 
5364
									#debug
-
 
5365
									#var_dump(__LINE__,$OderOfPartInLine);
-
 
5366
									
-
 
5367
									#如果有關鍵字片段與變數的順序存在
-
 
5368
									if( count($OderOfPartInLine)>0 ){
-
 
5369
										
-
 
5370
										#debug
-
 
5371
										#var_dump(__LINE__,$OderOfPartInLine);
-
 
5372
										
-
 
5373
										#針對每個資訊
-
 
5374
										foreach($OderOfPartInLine as $index=>$condition){
-
 
5375
											
-
 
5376
											#debug
-
 
5377
											#var_dump(__LINE__,$index,$condition);
-
 
5378
											
-
 
5379
											#判斷資訊
-
 
5380
											switch($condition["name"]){
-
 
5381
											
-
 
5382
												#如果是 "keyWordPart"
-
 
5383
												case "keyWordPart":
-
 
5384
												
-
 
5385
													#確認是否開頭有符合
-
 
5386
													
-
 
5387
													#函式說明:
-
 
5388
													#取得關鍵字在字串的哪個位置(字首,字尾,中間)
-
 
5389
													#回傳結果:
-
 
5390
													#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
-
 
5391
													#$result["error"],錯誤訊息陣列.
-
 
5392
													#$result["function"],當前執行的函數名稱.
-
 
5393
													#$result["found"],是否有關鍵字存在,若為"true",代表存在;反之為"false".
-
 
5394
													#$result["argu"],傳入的參數.
-
 
5395
													#$result["head"],關鍵字是否在字串的開頭,"true"代表是,"false"代表不是.
-
 
5396
													#$result["tail"],關鍵字是否在字串的尾端,"true"代表是,"false"代表不是.
-
 
5397
													#$result["center"],關鍵字是否在字串的中間,"true"代表是,"false"代表不是.
-
 
5398
													#$result["indexS"],關鍵字在被搜尋字串的哪個位置開始.
-
 
5399
													#$result["indexE"],關鍵字在被搜尋字串的哪個位置結束.
-
 
5400
													#必填參數:
-
 
5401
													#$conf["inputStr"],字串,被搜尋的字串.
-
 
5402
													$conf["search::findKeyWordPosition"]["inputStr"]=$modifiedOriLineContent;
-
 
5403
													#$conf["keyWord"],字串,關鍵字.
-
 
5404
													$conf["search::findKeyWordPosition"]["keyWord"]=$condition["value"];
-
 
5405
													#可省略參數:
-
 
5406
													#無.
-
 
5407
													#參考資料:
-
 
5408
													#http://php.net/manual/en/function.strpos.php
-
 
5409
													#備註:
-
 
5410
													#無.
-
 
5411
													$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
-
 
5412
													unset($conf["search::findKeyWordPosition"]);
-
 
5413
												
-
 
5414
													#debug
-
 
5415
													#var_dump(__LINE__,$findKeyWordPosition);
-
 
5416
												
-
 
5417
													#如果執行失敗
-
 
5418
													if($findKeyWordPosition["status"]==="false"){
-
 
5419
													
-
 
5420
														#設置錯誤識別
-
 
5421
														$result["status"]="false";
-
 
5422
														
-
 
5423
														#設置錯誤訊息
-
 
5424
														$result["error"]=$findKeyWordPosition;
-
 
5425
														
-
 
5426
														#回傳結果
-
 
5427
														return $result;
-
 
5428
													
-
 
5429
														}#if end
-
 
5430
														
-
 
5431
													#如果沒有符合
-
 
5432
													if($findKeyWordPosition["found"]==="false"){
-
 
5433
													
-
 
5434
														#初始化關鍵字行
-
 
5435
														$keyWordLineIndex=0;
-
 
5436
														
-
 
5437
														#換下行原始內容
-
 
5438
														continue 5;
-
 
5439
													
-
 
5440
														}#if end
-
 
5441
														
-
 
5442
													#如果關鍵字不在開頭
-
 
5443
													if($findKeyWordPosition["head"]==="false"){
-
 
5444
													
-
 
5445
														#初始化關鍵字行
-
 
5446
														$keyWordLineIndex=0;
-
 
5447
														
-
 
5448
														#換下行原始內容
-
 
5449
														continue 5;
-
 
5450
													
-
 
5451
														}#if end
-
 
5452
													
-
 
5453
													#函式說明:
-
 
5454
													#將字串特定關鍵字與其前面的內容剔除
-
 
5455
													#回傳結果:
-
 
5456
													#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5457
													#$result["error"],錯誤訊息陣列.
-
 
5458
													#$result["warning"],警告訊息鎮列.
-
 
5459
													#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5460
													#$result["function"],當前執行的函數名稱.
-
 
5461
													#$result["argu"],使用的參數.
-
 
5462
													#$result["oriStr"],要處理的原始字串內容.
-
 
5463
													#$result["content"],處理好的的字串內容.
-
 
5464
													#$result["deleted"],被移除的內容.
-
 
5465
													#必填參數:
-
 
5466
													#$conf["stringIn"],字串,要處理的字串.
-
 
5467
													$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedOriLineContent;
-
 
5468
													#$conf["keyWord"],字串,特定字串.
-
 
5469
													$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$condition["value"];
-
 
5470
													#可省略參數:
-
 
5471
													#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
-
 
5472
													#$conf["recursive"]="true";
-
 
5473
													#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
-
 
5474
													#$conf["lastResult"]=$delStrBeforeKeyWord;
-
 
5475
													#參考資料:
-
 
5476
													#無.
-
 
5477
													#備註:
-
 
5478
													#無.
-
 
5479
													$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5480
													unset($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5481
													
-
 
5482
													#debug
-
 
5483
													#var_dump(__LINE__,$delStrBeforeKeyWord);
-
 
5484
													
-
 
5485
													#如果執行失敗
-
 
5486
													if($delStrBeforeKeyWord["status"]==="false"){
-
 
5487
													
-
 
5488
														#設置錯誤識別
-
 
5489
														$result["status"]="false";
-
 
5490
														
-
 
5491
														#設置錯誤訊息
-
 
5492
														$result["error"]=$delStrBeforeKeyWord;
-
 
5493
														
-
 
5494
														#回傳結果
-
 
5495
														return $result;
-
 
5496
													
-
 
5497
														}#if end
-
 
5498
														
-
 
5499
													#如果沒有符合
-
 
5500
													if($delStrBeforeKeyWord["founded"]==="false"){
-
 
5501
													
-
 
5502
														#初始化關鍵字行
-
 
5503
														$keyWordLineIndex=0;
-
 
5504
														
-
 
5505
														#換下行原始內容
-
 
5506
														continue 5;
-
 
5507
														
-
 
5508
														}#if end
-
 
5509
														
-
 
5510
													#執行到這邊代表有符合
-
 
5511
													
-
 
5512
													#取得剩下未判斷是否符合的項目
-
 
5513
													$modifiedOriLineContent=$delStrBeforeKeyWord["content"];
-
 
5514
													
-
 
5515
													#換找下個資訊有無符合
-
 
5516
													continue 2;
-
 
5517
													
-
 
5518
													#結束 switch
-
 
5519
													break;
-
 
5520
													
-
 
5521
												#如果是 "varPart"
-
 
5522
												case "varPart":
-
 
5523
												
-
 
5524
													#判斷變數名稱
-
 
5525
													switch($OderOfPartInLine[($index)]["value"]){
-
 
5526
														
-
 
5527
														#如果為 起始年份
-
 
5528
														case "\${yearFrom}":
-
 
5529
														
-
 
5530
														#或如果為 結束年份
-
 
5531
														case "\${yearTo}":
-
 
5532
														
-
 
5533
															#取得變數名稱,亦即去掉開頭的 "${" 跟結尾的 "}"
-
 
5534
															$varName=substr($OderOfPartInLine[($index)]["value"],2,strlen($OderOfPartInLine[($index)]["value"])-3);
-
 
5535
															
-
 
5536
															#取得變數實際數值
-
 
5537
															$varVal=$conf[$varName];
-
 
5538
															
-
 
5539
															#轉換成 keyWordPart
-
 
5540
															$OderOfPartInLine[($index)]["name"]="keyWordPart";
-
 
5541
															
-
 
5542
															#轉換成期望的數值
-
 
5543
															$OderOfPartInLine[($index)]["value"]=$varVal;
-
 
5544
														
-
 
5545
															#跳出 switch
-
 
5546
															break;
-
 
5547
														
-
 
5548
														#或如果為作者資訊
-
 
5549
														case "\${Authors}":
-
 
5550
														
-
 
5551
															#取得變數名稱,亦即去掉開頭的 "${" 跟結尾的 "}"
-
 
5552
															$varName=substr($OderOfPartInLine[($index)]["value"],2,strlen($OderOfPartInLine[($index)]["value"])-3);
-
 
5553
															
-
 
5554
															#取得變數實際數值
-
 
5555
															$varVal=$conf[$varName];
-
 
5556
															
-
 
5557
															#轉換成 keyWordPart
-
 
5558
															$OderOfPartInLine[($index)]["name"]="keyWordPart";
-
 
5559
															
-
 
5560
															#初始化作者清單
-
 
5561
															$authorNameList="";
-
 
5562
															
-
 
5563
															#針對每個作者
-
 
5564
															foreach($varVal as $authorNameIndex=>$authorName){
-
 
5565
															
-
 
5566
																#預設的間隔內容
-
 
5567
																$comma=" | ";
-
 
5568
															
-
 
5569
																#如果是第一個作者
-
 
5570
																if($authorNameIndex===0){
-
 
5571
																
-
 
5572
																	#不需要間隔內容
-
 
5573
																	$comma="";
-
 
5574
																
-
 
5575
																	}#if end
-
 
5576
															
-
 
5577
																#串接間隔與作者名字
-
 
5578
																$authorNameList=$authorNameList.$comma.$authorName;
-
 
5579
															
-
 
5580
																}#foreach end
-
 
5581
															
-
 
5582
															#轉換成期望的數值
-
 
5583
															$OderOfPartInLine[($index)]["value"]=$authorNameList;
-
 
5584
															
-
 
5585
															#跳出 switch
-
 
5586
															break;
-
 
5587
														
-
 
5588
														#其他變數
-
 
5589
														default:
-
 
5590
														
-
 
5591
															#請定義實際內容要如何產生
-
 
5592
															#...
-
 
5593
													
-
 
5594
														}#switch end
-
 
5595
												
-
 
5596
													#如果後面沒有 $OderOfPartInLine 了
-
 
5597
													if(!isset($OderOfPartInLine[($index+1)])){
-
 
5598
													
-
 
5599
														#代表有符合所有條件
-
 
5600
														
-
 
5601
														#輪到下個關鍵字行
-
 
5602
														$keyWordLineIndex++;
-
 
5603
														
-
 
5604
														#結束 switch
-
 
5605
														break;
-
 
5606
													
-
 
5607
														}#if end
-
 
5608
														
-
 
5609
													#debug
-
 
5610
													#var_dump(__LINE__,$OderOfPartInLine[($index+1)]);
-
 
5611
														
-
 
5612
													#執行到這邊代表後面還有 $OderOfPartInLine
-
 
5613
													
-
 
5614
													#如果後面的內容不是 keyWordPart
-
 
5615
													if($OderOfPartInLine[($index+1)]["name"]!=="keyWordPart"){
-
 
5616
													
-
 
5617
														#設置錯誤識別
-
 
5618
														$result["status"]="false";
-
 
5619
														
-
 
5620
														#設置錯誤訊息
-
 
5621
														$result["error"][]="multi continued varName not supported";
-
 
5622
														
-
 
5623
														#回傳結果
-
 
5624
														return $result;
-
 
5625
													
-
 
5626
														}#if end
-
 
5627
														
-
 
5628
													#執行到這邊代表為 varPart
-
 
5629
													
-
 
5630
													#函式說明:
-
 
5631
													#取得關鍵字在字串的哪個位置(字首,字尾,中間)
-
 
5632
													#回傳結果:
-
 
5633
													#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
-
 
5634
													#$result["error"],錯誤訊息陣列.
-
 
5635
													#$result["function"],當前執行的函數名稱.
-
 
5636
													#$result["found"],是否有關鍵字存在,若為"true",代表存在;反之為"false".
-
 
5637
													#$result["argu"],傳入的參數.
-
 
5638
													#$result["head"],關鍵字是否在字串的開頭,"true"代表是,"false"代表不是.
-
 
5639
													#$result["tail"],關鍵字是否在字串的尾端,"true"代表是,"false"代表不是.
-
 
5640
													#$result["center"],關鍵字是否在字串的中間,"true"代表是,"false"代表不是.
-
 
5641
													#$result["indexS"],關鍵字在被搜尋字串的哪個位置開始.
-
 
5642
													#$result["indexE"],關鍵字在被搜尋字串的哪個位置結束.
-
 
5643
													#必填參數:
-
 
5644
													#$conf["inputStr"],字串,被搜尋的字串.
-
 
5645
													$conf["search::findKeyWordPosition"]["inputStr"]=$modifiedOriLineContent;
-
 
5646
													#$conf["keyWord"],字串,關鍵字.
-
 
5647
													$conf["search::findKeyWordPosition"]["keyWord"]=$OderOfPartInLine[($index+1)]["value"];
-
 
5648
													#可省略參數:
-
 
5649
													#無.
-
 
5650
													#參考資料:
-
 
5651
													#http://php.net/manual/en/function.strpos.php
-
 
5652
													#備註:
-
 
5653
													#無.
-
 
5654
													$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
-
 
5655
													unset($conf["search::findKeyWordPosition"]);
-
 
5656
												
-
 
5657
													#debug
-
 
5658
													#var_dump(__LINE__,$findKeyWordPosition);
-
 
5659
												
-
 
5660
													#如果執行失敗
-
 
5661
													if($findKeyWordPosition["status"]==="false"){
-
 
5662
													
-
 
5663
														#設置錯誤識別
-
 
5664
														$result["status"]="false";
-
 
5665
														
-
 
5666
														#設置錯誤訊息
-
 
5667
														$result["error"]=$findKeyWordPosition;
-
 
5668
														
-
 
5669
														#回傳結果
-
 
5670
														return $result;
-
 
5671
													
-
 
5672
														}#if end
-
 
5673
														
-
 
5674
													#如果沒有符合
-
 
5675
													if($findKeyWordPosition["found"]==="false"){
-
 
5676
													
-
 
5677
														#初始化關鍵字行
-
 
5678
														$keyWordLineIndex=0;
-
 
5679
														
-
 
5680
														#換下行原始內容
-
 
5681
														continue 5;
-
 
5682
													
-
 
5683
														}#if end
-
 
5684
													
-
 
5685
													#執行到這邊代表有符合
-
 
5686
													
-
 
5687
													#函式說明:
-
 
5688
													#將字串特定關鍵字與其前面的內容剔除
-
 
5689
													#回傳結果:
-
 
5690
													#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
5691
													#$result["error"],錯誤訊息陣列.
-
 
5692
													#$result["warning"],警告訊息鎮列.
-
 
5693
													#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
-
 
5694
													#$result["function"],當前執行的函數名稱.
-
 
5695
													#$result["argu"],使用的參數.
-
 
5696
													#$result["oriStr"],要處理的原始字串內容.
-
 
5697
													#$result["content"],處理好的的字串內容.
-
 
5698
													#$result["deleted"],被移除的內容.
-
 
5699
													#必填參數:
-
 
5700
													#$conf["stringIn"],字串,要處理的字串.
-
 
5701
													$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedOriLineContent;
-
 
5702
													#$conf["keyWord"],字串,特定字串.
-
 
5703
													$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$OderOfPartInLine[($index+1)]["value"];
-
 
5704
													#可省略參數:
-
 
5705
													#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
-
 
5706
													#$conf["recursive"]="true";
-
 
5707
													#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
-
 
5708
													#$conf["lastResult"]=$delStrBeforeKeyWord;
-
 
5709
													#參考資料:
-
 
5710
													#無.
-
 
5711
													#備註:
-
 
5712
													#無.
-
 
5713
													$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5714
													unset($conf["stringProcess::delStrBeforeKeyWord"]);
-
 
5715
													
-
 
5716
													#debug
-
 
5717
													#var_dump(__LINE__,$delStrBeforeKeyWord);
-
 
5718
													
-
 
5719
													#如果執行失敗
-
 
5720
													if($delStrBeforeKeyWord["status"]==="false"){
-
 
5721
													
-
 
5722
														#設置錯誤識別
-
 
5723
														$result["status"]="false";
-
 
5724
														
-
 
5725
														#設置錯誤訊息
-
 
5726
														$result["error"]=$delStrBeforeKeyWord;
-
 
5727
														
-
 
5728
														#回傳結果
-
 
5729
														return $result;
-
 
5730
													
-
 
5731
														}#if end
-
 
5732
														
-
 
5733
													#如果該存在的關鍵字不在
-
 
5734
													if($delStrBeforeKeyWord["founded"]==="false"){
-
 
5735
													
-
 
5736
														#初始化關鍵字行
-
 
5737
														$keyWordLineIndex=0;
-
 
5738
														
-
 
5739
														#換下行原始內容
-
 
5740
														continue 5;
-
 
5741
														
-
 
5742
														}#if end
-
 
5743
													
-
 
5744
													#取得剩下未判斷是否符合的項目
-
 
5745
													$modifiedOriLineContent=$OderOfPartInLine[($index+1)]["value"].$delStrBeforeKeyWord["content"];
-
 
5746
													
-
 
5747
													#debug
-
 
5748
													#var_dump(__LINE__,$modifiedOriLineContent);
-
 
5749
													
-
 
5750
													#換找下個資訊有無符合
-
 
5751
													continue 2;
-
 
5752
												
-
 
5753
													break;
-
 
5754
												
-
 
5755
												#其他狀況
-
 
5756
												default:
-
 
5757
												
-
 
5758
													#設置錯誤識別
-
 
5759
													$result["status"]="false";
-
 
5760
													
-
 
5761
													#設置錯誤訊息
-
 
5762
													$result["error"][]="unexpected name value";
-
 
5763
													
-
 
5764
													#設置錯誤訊息
-
 
5765
													$result["error"][]=$condition;
-
 
5766
													
-
 
5767
													#回傳結果
-
 
5768
													return $result;
-
 
5769
											
-
 
5770
												}#switch end
-
 
5771
											
-
 
5772
											}#foreach end
-
 
5773
											
-
 
5774
										#執行到這邊代表該行有符合關鍵字的結構
-
 
5775
										
-
 
5776
										#初始化期望的關鍵字內容
-
 
5777
										$fixedKeyWordVal="";
-
 
5778
										
-
 
5779
										#debug
-
 
5780
										#var_dump(__LINE__,$OderOfPartInLine);
-
 
5781
										
-
 
5782
										#針對關鍵字的每個字串段落
-
 
5783
										foreach($OderOfPartInLine as $indexOfOderOfPartInLine => $keyWordStrPart){
-
 
5784
										
-
 
5785
											#串接之
-
 
5786
											$fixedKeyWordVal=$fixedKeyWordVal.$OderOfPartInLine[$indexOfOderOfPartInLine]["value"];
-
 
5787
										
-
 
5788
											}#foreach end
-
 
5789
										
-
 
5790
										#debug
-
 
5791
										#var_dump(__LINE__,$oriLineContent,$fixedKeyWordVal);
-
 
5792
										
-
 
5793
										#補上關鍵字前面的tab或空格
-
 
5794
										$fixedKeyWordVal=$keyWordContentOfHead.$fixedKeyWordVal;
-
 
5795
										
-
 
5796
										#如果內容有差
-
 
5797
										if($oriLineContent!=$fixedKeyWordVal){
-
 
5798
										
-
 
5799
											#debug
-
 
5800
											#var_dump(__LINE__,$oriLineContent,$fixedKeyWordVal);
-
 
5801
										
-
 
5802
											#設置要取代的暫存資訊
-
 
5803
											$detailRepaceddInfo=array();
-
 
5804
										
-
 
5805
											#設置暫存的取代詳細資訊,包含取代的行(從0開始算),原始內容,新內容.
-
 
5806
											$detailRepaceddInfo[$oriLineContentIndex]=array("from"=>$oriLineContent,"to"=>$fixedKeyWordVal);
-
 
5807
										
-
 
5808
											#debug
-
 
5809
											#var_dump(__LINE__,$detailRepaceddInfo);
-
 
5810
										
-
 
5811
											#儲存要取代的資訊
-
 
5812
											$replacedInfo[]=$detailRepaceddInfo;
-
 
5813
										
-
 
5814
											}#if end
-
 
5815
										
-
 
5816
										#取代期望的關鍵字
-
 
5817
										$modifiedKeyWordLine=$fixedKeyWordVal;
-
 
5818
										
-
 
5819
										#換看下行內容有無符合關鍵字,會執行for迴圈的 $keyWordLineIndex++
-
 
5820
										continue 3;
-
 
5821
										
-
 
5822
										}#if end
-
 
5823
									
-
 
5824
									#結束 while
-
 
5825
									break;
-
 
5826
									
-
 
5827
									}#while end
-
 
5828
									
-
 
5829
								#若原始內容沒有符合關鍵字
-
 
5830
								if($modifiedOriLineContent!==$modifiedKeyWordLine){
-
 
5831
									
-
 
5832
									#debug
-
 
5833
									#var_dump(__LINE__,$modifiedOriLineContent,$modifiedKeyWordLine);
-
 
5834
									
-
 
5835
									#初始化關鍵字行
-
 
5836
									$keyWordLineIndex=0;
-
 
5837
									
-
 
5838
									#換下行原始內容
-
 
5839
									continue 2;
-
 
5840
								
-
 
5841
									}#if end
-
 
5842
									
-
 
5843
								#反之代表內容有符合
-
 
5844
								else{
-
 
5845
								
-
 
5846
									#debug
-
 
5847
									#var_dump(__LINE__,"第 ".($keyWordLineIndex+1)." 個關鍵字有符合,總關鍵行有 ".count($conf["replaceFrom"])." 個");
-
 
5848
								
-
 
5849
									#如果內容有差
-
 
5850
									if($oriLineContent!=$conf["replaceFrom"][$keyWordLineIndex]){
-
 
5851
									
-
 
5852
										#debug
-
 
5853
										#var_dump(__LINE__,$oriLineContent,$conf["replaceFrom"][$keyWordLineIndex]);
-
 
5854
									
-
 
5855
										#設置要取代的暫存資訊
-
 
5856
										$detailRepaceddInfo=array();
-
 
5857
									
-
 
5858
										#設置暫存的取代詳細資訊,包含取代的行(從0開始算),原始內容,新內容.
-
 
5859
										$detailRepaceddInfo[$oriLineContentIndex]=array("from"=>$oriLineContent,"to"=>$conf["replaceFrom"][$keyWordLineIndex]);
-
 
5860
									
-
 
5861
										#儲存要取代的資訊
-
 
5862
										$replacedInfo[]=$detailRepaceddInfo;
-
 
5863
									
-
 
5864
										}#if end
-
 
5865
									
-
 
5866
									#若為最後一個關鍵行.
-
 
5867
									if( count($conf["replaceFrom"])===($keyWordLineIndex+1) ){
-
 
5868
									
-
 
5869
										#代表符合要取代的條件
-
 
5870
										$shouldReplace="true";
-
 
5871
										
-
 
5872
										#debug
-
 
5873
										#var_dump(__LINE__,$result["content"]);
-
 
5874
										
-
 
5875
										#如果沒有既有的記錄
-
 
5876
										if(!isset($result["content"][$NodePathAndName])){
-
 
5877
										
-
 
5878
											#記錄有更新的檔案路徑與名稱與其次數為1
-
 
5879
											$result["content"][$NodePathAndName]["time"]=1;
-
 
5880
										
-
 
5881
											}#if end
-
 
5882
										
-
 
5883
										#反之
-
 
5884
										else{
-
 
5885
										
-
 
5886
											#記錄有更新的檔案路徑與名稱與的次數+1
-
 
5887
											$result["content"][$NodePathAndName]["time"]++;
-
 
5888
										
-
 
5889
											}#else end
-
 
5890
										
-
 
5891
										#記錄要更新的相關資訊
-
 
5892
										$result["content"][$NodePathAndName]["replacedInfo"]=$replacedInfo;
-
 
5893
										
-
 
5894
										#debug
-
 
5895
										#var_dump(__LINE__,$result["content"]);
-
 
5896
										
-
 
5897
										#關鍵字行初始化
-
 
5898
										$keyWordLineIndex=0;
-
 
5899
										
-
 
5900
										}#if end
-
 
5901
									
-
 
5902
									#反之
-
 
5903
									else{
-
 
5904
									
-
 
5905
										#輪到下個關鍵字行
-
 
5906
										$keyWordLineIndex++;
-
 
5907
									
-
 
5908
										}#else end
-
 
5909
									
-
 
5910
									#換找下個行內容有無符合關鍵字
-
 
5911
									continue 2;
-
 
5912
									
-
 
5913
									}#else end
-
 
5914
								
-
 
5915
								}#for end
-
 
5916
						
-
 
5917
							}#for end
-
 
5918
						
-
 
5919
						*/
-
 
5920
						
4780
						
5921
						#如果有需要更新檔案內容的識別
4781
						#如果有需要更新檔案內容的識別
5922
						if($replaceMatchContent["found"]==="true"){
4782
						if($replaceMatchContent["found"]==="true"){
5923
						
4783
						
5924
							#$replaceMatchContent["relaceInfo"][$i]["new"],第 $i+1 行的新內容.
4784
							#$replaceMatchContent["relaceInfo"][$i]["new"],第 $i+1 行的新內容.
Line 5959... Line 4819...
5959
							#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
4819
							#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
5960
							#$conf["addToTailBeforeThat"]="?\>";
4820
							#$conf["addToTailBeforeThat"]="?\>";
5961
							#$conf["replaceSpecifyLine"],字串陣列,將指定的行取代成指定的內容,元素的key為原始檔案的行索引,若key為$i+1,則代表第$i行;元素的數值就為該行的新內容.
4821
							#$conf["replaceSpecifyLine"],字串陣列,將指定的行取代成指定的內容,元素的key為原始檔案的行索引,若key為$i+1,則代表第$i行;元素的數值就為該行的新內容.
5962
							#$conf["fileAccess::updateFile"]["replaceSpecifyLine"]=$replaceSpecifyLine;
4822
							#$conf["fileAccess::updateFile"]["replaceSpecifyLine"]=$replaceSpecifyLine;
5963
							#$conf["outputPath"],字串,檔案要輸出到哪個位置,預設不指定,直接取代原始檔案的內容.
4823
							#$conf["outputPath"],字串,檔案要輸出到哪個位置,預設不指定,直接取代原始檔案的內容.
5964
							$conf["fileAccess::updateFile"]["outputPath"]=$outputPath;
4824
							$conf["fileAccess::updateFile"]["outputPath"]=$conf["outputPath"];
5965
							#參考資料:
4825
							#參考資料:
5966
							#無.
4826
							#無.
5967
							#備註:
4827
							#備註:
5968
							#無.
4828
							#無.
5969
							$updateFile=fileAccess::updateFile($conf["fileAccess::updateFile"]);
4829
							$updateFile=fileAccess::updateFile($conf["fileAccess::updateFile"]);