Subversion Repositories php-qbpwcf

Rev

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

Rev 239 Rev 255
Line 507... Line 507...
507
	#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
507
	#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
508
	#$result["running"],是否還在執行.
508
	#$result["running"],是否還在執行.
509
	#$result["pid"],pid.
509
	#$result["pid"],pid.
510
	#$result["statusCode"],執行結束後的代碼.
510
	#$result["statusCode"],執行結束後的代碼.
511
	#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
511
	#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
512
	#$result["noEcaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
512
	#$result["noEscaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
513
	#必填參數:
513
	#必填參數:
514
	#$conf["command"],字串,要執行的指令.
514
	#$conf["command"],字串,要執行的指令.
515
	$conf["command"]="";
515
	$conf["command"]="";
516
	#$conf["fileArgu"],字串,變數__FILE__的內容.
516
	#$conf["fileArgu"],字串,變數__FILE__的內容.
517
	$conf["fileArgu"]=__FILE__;
517
	$conf["fileArgu"]=__FILE__;
Line 543... Line 543...
543
	#$conf["inBackGround"]="";
543
	#$conf["inBackGround"]="";
544
	#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
544
	#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
545
	#$conf["getErr"]="false";
545
	#$conf["getErr"]="false";
546
	#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
546
	#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
547
	#$conf["doNotRun"]="false";
547
	#$conf["doNotRun"]="false";
-
 
548
	#$conf["remoteIp"],字串,遠端ip或domainName,預設不使用,若存在則會透過ssh指令進行連線,然後執行指令.
-
 
549
	#$conf["remoteIp"]="";
-
 
550
	#$conf["remoteUser"],字串,遠端的使用者賬戶,預設不指定,亦即跟為運行該php程式的使用者.
-
 
551
	#$conf["remoteUser"]="";
548
	#參考資料:
552
	#參考資料:
549
	#exec=>http://php.net/manual/en/function.exec.php
553
	#exec=>http://php.net/manual/en/function.exec.php
550
	#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
554
	#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
551
	#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
555
	#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
552
	#備註:
556
	#備註:
553
	#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
557
	#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
Line 607... Line 611...
607
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
611
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
608
		#可以省略的參數:
612
		#可以省略的參數:
609
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
613
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
610
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
614
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
611
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
615
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
612
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("pre","enablePrintDescription","printDescription","argu","escapeshellarg","username","password","useScript","logFilePath","inBackGround","arguIsAddr","getErr","doNotRun","thereIsShellVar");
616
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("pre","enablePrintDescription","printDescription","argu","escapeshellarg","username","password","useScript","logFilePath","inBackGround","arguIsAddr","getErr","doNotRun","thereIsShellVar","remoteIp","remoteUser");
613
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
617
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
614
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string","array","string","string","string","string","string","string","array","string","string","array");
618
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string","array","string","string","string","string","string","string","array","string","string","array","string","string");
615
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
619
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
616
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"false",null,null,"false",null,null,"false",".qbpwcf_tmp/external/callShell/","false",null,"false","false",null);
620
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"false",null,null,"false",null,null,"false",".qbpwcf_tmp/external/callShell/","false",null,"false","false",null,null,null);
617
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
621
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
618
		$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("argu","arguIsAddr");
622
		$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("argu","arguIsAddr");
619
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
623
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
620
		unset($conf["variableCheck::checkArguments"]);
624
		unset($conf["variableCheck::checkArguments"]);
621
 
625
 
Line 672... Line 676...
672
			$newArgu=array();
676
			$newArgu=array();
673
 
677
 
674
			#初始化那些參數含有 shell 變數
678
			#初始化那些參數含有 shell 變數
675
			$thereIsShellVar=array();
679
			$thereIsShellVar=array();
676
 
680
 
677
			#debug
-
 
678
			#var_dump($conf["pre"]);
-
 
679
 
-
 
680
			#記錄原先的指令
681
			#記錄原先的指令
681
			$oriCmd=$conf["command"];
682
			$oriCmd=$conf["command"];
682
 
683
 
683
			#針對每個前置指令
684
			#針對每個前置指令
684
			foreach($conf["pre"] as $index=>$info){
685
			foreach($conf["pre"] as $index=>$info){
685
 
686
 
686
				#debug
-
 
687
				#var_dump($index);
-
 
688
 
-
 
689
				#如果是第一個要執行的 pre 指令
687
				#如果是第一個要執行的 pre 指令
690
				if($index===0){
688
				if($index===0){
691
 
689
 
692
					#更新 指令的名稱
690
					#更新 指令的名稱
693
					$conf["command"]=$info["cmd"];
691
					$conf["command"]=$info["cmd"];
Line 728... Line 726...
728
			$newArgu[]=$oriCmd;
726
			$newArgu[]=$oriCmd;
729
 
727
 
730
			#設置不含有 shell 變數
728
			#設置不含有 shell 變數
731
			$thereIsShellVar[]="false";
729
			$thereIsShellVar[]="false";
732
 
730
 
733
			#debug
-
 
734
			#var_dump($conf["argu"]);
-
 
735
 
-
 
736
			#針對本來要執行的參數
731
			#針對本來要執行的參數
737
			foreach($conf["argu"] as $index => $param){
732
			foreach($conf["argu"] as $index => $param){
738
 
733
 
739
				#增加參數
734
				#增加參數
740
				$newArgu[]=$param;
735
				$newArgu[]=$param;
Line 754... Line 749...
754
					$thereIsShellVar[]="false";
749
					$thereIsShellVar[]="false";
755
 
750
 
756
					}#else end
751
					}#else end
757
 
752
 
758
				}#foreach end
753
				}#foreach end
759
 
-
 
760
			#debug
754
				
761
			#var_dump($newArgu);
-
 
762
 
-
 
763
			#更新 argu 參數
755
			#更新 argu 參數
764
			$conf["argu"]=$newArgu;
756
			$conf["argu"]=$newArgu;
765
 
757
 
766
			#更新 thereIsShellVar 參數
758
			#更新 thereIsShellVar 參數
767
			$conf["thereIsShellVar"]=$thereIsShellVar;
759
			$conf["thereIsShellVar"]=$thereIsShellVar;
768
 
760
 
769
			#移除處理掉的 pre 參數
761
			#移除處理掉的 pre 參數
770
			unset($conf["pre"]);
762
			unset($conf["pre"]);
771
 
763
 
772
			#debug
-
 
773
			#var_dump($conf);
-
 
774
 
-
 
775
			#遞迴呼叫
764
			#遞迴呼叫
776
			return self::callShell($conf);
765
			return self::callShell($conf);
777
 
766
 
778
			}#if end
767
			}#if end
779
 
768
 
Line 895... Line 884...
895
			#初始化輸出
884
			#初始化輸出
896
			$output=array();
885
			$output=array();
897
 
886
 
898
			#執行指令
887
			#執行指令
899
			exec($cmd,$output,$status);
888
			exec($cmd,$output,$status);
900
 
-
 
901
			/*
889
			
902
			#debug
-
 
903
			$fh=fopen("/tmp/external::callShell.log","a");
-
 
904
			fwrite($fh,PHP_EOL."start".PHP_EOL);
-
 
905
			fwrite($fh,$result["cmd"].PHP_EOL);
-
 
906
			fwrite($fh,$cmd.PHP_EOL);
-
 
907
			fwrite($fh,print_r($ouput,true).PHP_EOL);
-
 
908
			fwrite($fh,$status.PHP_EOL);
-
 
909
			fwrite($fh,PHP_EOL."end".PHP_EOL);
-
 
910
			fclose($fh);
-
 
911
			*/
-
 
912
 
-
 
913
			#如果有找到
890
			#如果有找到
914
			if($status===0){
891
			if($status===0){
915
 
892
 
916
				#設置有找到
893
				#設置有找到
917
				$cmdFound=true;
894
				$cmdFound=true;
Line 933... Line 910...
933
				$output=array();
910
				$output=array();
934
 
911
 
935
				#執行指令
912
				#執行指令
936
				exec($cmd,$output,$status);
913
				exec($cmd,$output,$status);
937
 
914
 
938
				/*
-
 
939
				#debug
-
 
940
				$fh=fopen("/tmp/external::callShell.log","a");
-
 
941
				fwrite($fh,PHP_EOL."start".PHP_EOL);
-
 
942
				fwrite($fh,$result["cmd"].PHP_EOL);
-
 
943
				fwrite($fh,$cmd.PHP_EOL);
-
 
944
				fwrite($fh,print_r($output,true).PHP_EOL);
-
 
945
				fwrite($fh,$status.PHP_EOL);
-
 
946
				fwrite($fh,PHP_EOL."end".PHP_EOL);
-
 
947
				fclose($fh);
-
 
948
				*/
-
 
949
 
-
 
950
				#debug
-
 
951
				#var_dump(__LINE__,$cmd,$output,$status);
-
 
952
 
-
 
953
				#如果執行正常
915
				#如果執行正常
954
				if($status===0){
916
				if($status===0){
955
 
917
 
956
					#代表有找到程式
918
					#代表有找到程式
957
					$cmdFound=true;
919
					$cmdFound=true;
Line 966... Line 928...
966
			}#else end
928
			}#else end
967
 
929
 
968
		#如果找不到要執行的程式
930
		#如果找不到要執行的程式
969
		if($cmdFound===false){
931
		if($cmdFound===false){
970
 
932
 
-
 
933
			#取得搜尋 "=" 的結果
971
			$equalPosition=strpos($result["cmd"],"=");
934
			$equalPosition=strpos($result["cmd"],"=");
972
 
935
 
973
			#若指令不為 shell 變數指派
936
			#若指令不為 shell 變數指派
974
			if( $equalPosition===false ){
937
			if( $equalPosition===false ){
975
 
938
 
Line 987... Line 950...
987
			#代表有找到程式
950
			#代表有找到程式
988
			$cmdFound=true;
951
			$cmdFound=true;
989
 
952
 
990
			}#if end
953
			}#if end
991
 
954
 
992
		#如果 $conf["escapeshellarg"] 為 "true"
955
		#初始化儲存未escaped後的指令與參數資訊
993
		if($conf["escapeshellarg"]==="true"){
956
		$result["noEscaped"]=array();
994
 
957
 
995
			#取得真正執行的指令
958
		#儲存執行的指令
996
			$result["escape"]["cmd"]=$result["cmd"];
959
		$result["noEscaped"]["cmd"]=$conf["command"];
997
 
960
 
-
 
961
		#初始化儲存執行的參數
-
 
962
		$result["noEscaped"]["argu"]=array();
-
 
963
		
-
 
964
		#初始化儲存escaped後的指令與參數資訊
-
 
965
		$result["escaped"]=array();
-
 
966
 
-
 
967
		#儲存執行的指令
-
 
968
		$result["escaped"]["cmd"]=escapeshellarg($conf["command"]);
-
 
969
 
-
 
970
		#初始化儲存執行的參數
-
 
971
		$result["escaped"]["argu"]=array();
-
 
972
		
998
			#如果有參數存在
973
		#如果有參數存在
999
			if(isset($conf["argu"])){
974
		if(isset($conf["argu"])){
-
 
975
 
-
 
976
			#有幾個參數就執行幾次
-
 
977
			for($i=0;$i<count($conf["argu"]);$i++){
-
 
978
 
-
 
979
				#如果有指定位置參數
-
 
980
				if(isset($conf["arguIsAddr"])){
-
 
981
 
-
 
982
					#如果是位置參數
-
 
983
					if($conf["arguIsAddr"][$i]==="true"){
-
 
984
 
-
 
985
						#如果相對路徑就要轉換路徑
-
 
986
						if(strpos($conf["argu"][$i],"/")!==0){
-
 
987
 
-
 
988
							#函數說明:
-
 
989
							#將多個路徑字串變成相對於當前路徑的相對路徑字串
-
 
990
							#回傳結果:
-
 
991
							#$result["status"],"true"爲建立成功,"false"爲建立失敗.
-
 
992
							#$result["error"],錯誤訊息陣列.
-
 
993
							#$result["function"],函數名稱.
-
 
994
							#$result["content"],字串陣列,多個轉換好的相對路徑字串.
-
 
995
							#必填參數:
-
 
996
							#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
-
 
997
							$conf["fileAccess::getRelativePath"]["path"]=array($conf["argu"][$i]);
-
 
998
							#$conf["fileArgu"],字串,當前路徑.
-
 
999
							$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
-
 
1000
							$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
-
 
1001
							unset($conf["fileAccess::getRelativePath"]);
-
 
1002
 
-
 
1003
							#var_dump($getRelativePath);
-
 
1004
 
-
 
1005
							#如果轉換路徑失敗
-
 
1006
							if($getRelativePath["status"]==="false"){
-
 
1007
 
-
 
1008
								#設置執行失敗的識別
-
 
1009
								$result["status"]="false";
-
 
1010
								
-
 
1011
								#設置執行失敗的訊息
-
 
1012
								$result["error"]=$getRelativePath;
1000
 
1013
 
1001
				#有幾個參數就執行幾次
1014
								#回傳結果
1002
				for($i=0;$i<count($conf["argu"]);$i++){
1015
								return $result;
1003
 
1016
 
1004
					#如果有指定位置參數
-
 
1005
					if(isset($conf["arguIsAddr"])){
1017
								}#if end
1006
 
1018
 
1007
						#如果是位置參數
1019
							#取得相對路徑
1008
						if($conf["arguIsAddr"][$i]==="true"){
1020
							$conf["argu"][$i]=$getRelativePath["content"][0];
1009
 
1021
 
1010
							#如果相對路徑就要轉換路徑
-
 
1011
							if(strpos($conf["argu"][$i],"/")!==0){
-
 
1012
 
-
 
1013
								#函數說明:
-
 
1014
								#將多個路徑字串變成相對於當前路徑的相對路徑字串
-
 
1015
								#回傳結果:
-
 
1016
								#$result["status"],"true"爲建立成功,"false"爲建立失敗.
-
 
1017
								#$result["error"],錯誤訊息陣列.
-
 
1018
								#$result["function"],函數名稱.
-
 
1019
								#$result["content"],字串陣列,多個轉換好的相對路徑字串.
-
 
1020
								#必填參數:
-
 
1021
								#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
-
 
1022
								$conf["fileAccess::getRelativePath"]["path"]=array($conf["argu"][$i]);
-
 
1023
								#$conf["fileArgu"],字串,當前路徑.
-
 
1024
								$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
-
 
1025
								$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
-
 
1026
								unset($conf["fileAccess::getRelativePath"]);
-
 
1027
 
-
 
1028
								#var_dump($getRelativePath);
-
 
1029
 
-
 
1030
								#如果轉換路徑失敗
1022
							#取得相對路徑
1031
								if($getRelativePath["status"]==="false"){
1023
							$relativePath=$getRelativePath["content"][0];
1032
 
1024
 
1033
									#設置執行失敗的識別
1025
							#保存其相對路徑
1034
									$result["status"]="false";
1026
							$conf["argu"][$i]=$relativePath;
1035
 
1027
 
1036
									#設置執行失敗的訊息
1028
							}#if end
1037
									$result["error"]=$getRelativePath;
-
 
1038
 
1029
 
1039
									#回傳結果
1030
						}#if end
-
 
1031
						
1040
									return $result;
1032
					}#if end
-
 
1033
					
-
 
1034
				#如果參數長度大於3
-
 
1035
				if(strlen($conf["argu"][$i])>3){
1041
 
1036
 
1042
									}#if end
1037
					#如果參數是 ${xxx}
-
 
1038
					if( strpos($conf["argu"][$i],"\${")===0 && strpos($conf["argu"][$i],"}")===(strlen($conf["argu"][$i])-1) ){
1043
 
1039
 
1044
								#取得相對路徑
1040
						#預設要空格
1045
								$conf["argu"][$i]=$getRelativePath["content"][0];
1041
						$space=" ";
1046
 
1042
 
1047
								#取得相對路徑
1043
						#如果前一個參數為 "=" 結尾
1048
								$relativePath=$getRelativePath["content"][0];
1044
						if($result["cmd"][strlen($result["cmd"])-1]==="="){
1049
 
1045
 
1050
								#保存其相對路徑
1046
							#不放空格
1051
								$conf["argu"][$i]=$relativePath;
1047
							$space="";
1052
 
1048
 
-
 
1049
							#如果是第一個參數
1053
								}#if end
1050
							if($i===0){
1054
 
1051
 
-
 
1052
								#更新真正執行的指令
-
 
1053
								$result["cmd"]=$result["cmd"].$space.$conf["argu"][$i];
1055
							}#if end
1054
								
-
 
1055
								#儲存escape的cmd
-
 
1056
								$result["escaped"]["cmd"]=escapeshellarg($result["cmd"]);
-
 
1057
								
-
 
1058
								#儲存未escape的cmd
-
 
1059
								$result["noEscaped"]["cmd"]=$result["cmd"];
1056
 
1060
 
1057
						}#if end
1061
								}#if end
1058
 
-
 
1059
					#如果參數長度大於3
-
 
1060
					if(strlen($conf["argu"][$i])>3){
-
 
1061
 
-
 
1062
						#如果參數是 ${xxx}
-
 
1063
						if( strpos($conf["argu"][$i],"\${")===0 && strpos($conf["argu"][$i],"}")===(strlen($conf["argu"][$i])-1) ){
-
 
1064
 
1062
 
1065
							#預設要空格
1063
							#反之真的為參數
1066
							$space=" ";
1064
							else{
1067
 
1065
 
1068
							#如果前一個參數為 "=" 結尾
1066
								#取得參數的索引
1069
							if($result["cmd"][strlen($result["cmd"])-1]==="="){
1067
								$arguIndex=count($conf["argu"])-1;
1070
 
1068
 
1071
								#不放空格
1069
								#儲存真正的參數
1072
								$space="";
1070
								$result["escaped"]["argu"][$arguIndex]=$conf["argu"][$arguIndex].$space.$conf["argu"][$i];
1073
 
1071
 
1074
								#如果是第一個參數
1072
								#儲存未escape的參數
1075
								if($i===0){
1073
								$result["unescape"]["argu"][$arguIndex]=$conf["argu"][$arguIndex].$space.$conf["argu"][$i];
1076
 
1074
 
1077
									#更新真正執行的指令
1075
								}#else end
1078
									$result["escape"]["cmd"]=$result["cmd"].$space.$conf["argu"][$i];
-
 
1079
 
1076
 
1080
									}#if end
1077
							}#if end
1081
 
1078
 
1082
								#反之真的為參數
1079
						#反之
1083
								else{
1080
						else{
1084
 
1081
 
1085
									#取得參數的索引
1082
							#儲存未escape的參數
1086
									$arguIndex=count($conf["argu"])-1;
1083
							$result["noescaped"]["argu"][]=$conf["argu"][$i];
-
 
1084
							
-
 
1085
							#儲存escape的參數
-
 
1086
							$result["escaped"]["argu"][]=escapeshellarg($conf["argu"][$i]);
1087
 
1087
 
1088
									#儲存真正的參數
1088
							}#else
1089
									$result["escape"]["argu"][$arguIndex]=$conf["argu"][$arguIndex].$space.$conf["argu"][$i];
-
 
1090
 
1089
 
1091
									}#else end
1090
						#組合執行的指令
-
 
1091
						$result["cmd"]=$result["cmd"].$space.$conf["argu"][$i];
1092
 
1092
 
-
 
1093
						#下一個參數
1093
								}#if end
1094
						continue;
1094
 
1095
 
1095
							#反之
1096
						}#if end
1096
							else{
-
 
1097
 
1097
 
1098
								#儲存真正的參數
1098
					}#if end
1099
								$result["escape"]["argu"][]=$conf["argu"][$i];
-
 
1100
 
1099
 
-
 
1100
				#如果參數是 < 、<< 、> 、>> 、| 、2>&1、;、`、~、&、$!
1101
								}#else
1101
				if($conf["argu"][$i]===">" || $conf["argu"][$i]==="<" || $conf["argu"][$i]===">>" || $conf["argu"][$i]==="<<" || $conf["argu"][$i]==="|" || $conf["argu"][$i]==="2>&1" || $conf["argu"][$i]===";" || $conf["argu"][$i]==="`" || $conf["argu"][$i]==="~" || $conf["argu"][$i]==="&" || $conf["argu"][$i]==="$!"){
1102
 
1102
 
1103
							#組合執行的指令
1103
					#預設要空格
1104
							$result["cmd"]=$result["cmd"].$space.$conf["argu"][$i];
1104
					$space=" ";
1105
 
1105
 
1106
							#下一個參數
1106
					#組合執行的指令
1107
							continue;
1107
					$result["cmd"]=$result["cmd"].$space.$conf["argu"][$i];
1108
 
1108
 
1109
							}#if end
1109
					#儲存真正的參數
-
 
1110
					$result["escaped"]["argu"][]=$conf["argu"][$i];
1110
 
1111
 
1111
						}#if end
1112
					}#if end
1112
 
1113
 
1113
					#如果參數是 < 、<< 、> 、>> 、| 、2>&1、;、`、~、&、$!
1114
				#反之
1114
					if($conf["argu"][$i]===">" || $conf["argu"][$i]==="<" || $conf["argu"][$i]===">>" || $conf["argu"][$i]==="<<" || $conf["argu"][$i]==="|" || $conf["argu"][$i]==="2>&1" || $conf["argu"][$i]===";" || $conf["argu"][$i]==="`" || $conf["argu"][$i]==="~" || $conf["argu"][$i]==="&" || $conf["argu"][$i]==="$!"){
1115
				else{
1115
 
1116
 
1116
						#預設要空格
1117
					#如果是第一個參數,且指令結尾為「=」結束
1117
						$space=" ";
1118
					if($i===0 && $result["cmd"][strlen($result["cmd"])-1]==="="){
1118
 
1119
 
1119
						#組合執行的指令
1120
						#處理參數後再串接指令
1120
						$result["cmd"]=$result["cmd"].$space.$conf["argu"][$i];
1121
						$result["cmd"]=$result["cmd"].escapeshellarg($conf["argu"][$i]);
1121
 
1122
 
-
 
1123
						#更新真正執行的指令
-
 
1124
						$result["escaped"]["cmd"]=$result["cmd"];
-
 
1125
						
1122
						#儲存真正的參數
1126
						#儲存unescape的指令
1123
						$result["escape"]["argu"][]=$conf["argu"][$i];
1127
						$result["noescaped"]["cmd"]=$result["cmd"];
1124
 
1128
 
1125
						}#if end
1129
						}#if end
1126
 
1130
 
1127
					#反之
1131
					#反之
1128
					else{
1132
					else{
1129
 
1133
 
1130
						#如果是第一個參數,且指令結尾為「=」結束
1134
						#儲存unescape的參數
1131
						if($i===0 && $result["cmd"][strlen($result["cmd"])-1]==="="){
1135
						$unescapeArgu=$conf["argu"][$i];
1132
 
1136
 
1133
							#處理參數後再串接指令
1137
						#儲存escape好的參數
1134
							$result["cmd"]=$result["cmd"].escapeshellarg($conf["argu"][$i]);
1138
						$escapeArgu=escapeshellarg($conf["argu"][$i]);
1135
 
1139
 
1136
							#更新真正執行的指令
1140
						#如果有設置 $conf["thereIsShellVar"]
1137
							$result["escape"]["cmd"]=$result["cmd"];
1141
						if(isset($conf["thereIsShellVar"])){
1138
 
1142
 
-
 
1143
							#如果有設置 $conf["thereIsShellVar"][$i]
-
 
1144
							if(isset($conf["thereIsShellVar"][$i])){
-
 
1145
 
-
 
1146
								#如果含有 shell 變數
-
 
1147
								if($conf["thereIsShellVar"][$i]==="true"){
-
 
1148
 
-
 
1149
									#檢查是否使用 shell 變數
-
 
1150
									#函式說明:
-
 
1151
									#尋找陣列中有無符合的key
-
 
1152
									#回傳結果:
-
 
1153
									#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1154
									#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1155
									#$result["function"],當前執行的函式名稱.
-
 
1156
									#$result["argu"],所使用的參數.
-
 
1157
									#$result["founded"],是否有找到shell變數,"true"代表有找到,"false"代表沒有找到..
-
 
1158
									#必填參數:
-
 
1159
									#$conf["input"],字串,要檢查的字串..
-
 
1160
									$conf["search::findShellVar"]["input"]=$escapeArgu;
-
 
1161
									#可省略參數:
1139
							}#if end
1162
									#無.
-
 
1163
									#參考資料:
-
 
1164
									#無.
-
 
1165
									#備註:
-
 
1166
									#無.
-
 
1167
									$findShellVar=search::findShellVar($conf["search::findShellVar"]);
-
 
1168
									unset($conf["search::findShellVar"]);
-
 
1169
 
-
 
1170
									#如果檢查失敗
-
 
1171
									if($findShellVar["status"]=="false"){
1140
 
1172
 
1141
						#反之
1173
										#設置錯誤識別
1142
						else{
1174
										$result["status"]="false";
1143
 
1175
 
1144
							#儲存escape好的參數
1176
										#設置錯誤訊息
1145
							$escapeArgu=escapeshellarg($conf["argu"][$i]);
1177
										$result["error"]=$findShellVar;
1146
 
1178
 
1147
							#如果有設置 $conf["thereIsShellVar"]
1179
										#回傳解果
1148
							if(isset($conf["thereIsShellVar"])){
1180
										return $result;
1149
 
1181
 
1150
								#如果有設置 $conf["thereIsShellVar"][$i]
-
 
1151
								if(isset($conf["thereIsShellVar"][$i])){
1182
										}#if end
1152
 
1183
 
1153
									#如果含有 shell 變數
1184
									#含有 shell 變數
1154
									if($conf["thereIsShellVar"][$i]==="true"){
1185
									if($findShellVar["founded"]=="true"){
1155
 
1186
 
1156
										#檢查是否使用 shell 變數
1187
										#確認該字串是否 開頭跟結尾為 「'」
1157
										#函式說明:
1188
										#函式說明:
1158
										#尋找陣列中有無符合的key
1189
										#取得符合特定字首與字尾的字串
1159
										#回傳結果:
1190
										#回傳結果:
1160
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1191
										#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
1161
										#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
1162
										#$result["function"],當前執行的函式名稱.
1192
										#$result["function"],當前執行的函數名稱.
1163
										#$result["argu"],所使用的參數.
1193
										#$result["error"],錯誤訊息陣列.
1164
										#$result["founded"],是否有找到shell變數,"true"代表有找到,"false"代表沒有找到..
1194
										#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
-
 
1195
										#$result["returnString"],爲符合字首條件的字串內容。
-
 
1196
										#$result["argu"],使用的參數.
1165
										#必填參數:
1197
										#必填參數:
1166
										#$conf["input"],字串,要檢查的字串..
1198
										#$conf["checkString"],字串,要檢查的字串.
1167
										$conf["search::findShellVar"]["input"]=$escapeArgu;
1199
										$conf["search::getMeetConditionsString"]["checkString"]=$escapeArgu;
1168
										#可省略參數:
1200
										#可省略參數:
-
 
1201
										#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
-
 
1202
										$conf["search::getMeetConditionsString"]["frontWord"]="'";
-
 
1203
										#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
1169
										#無.
1204
										$conf["search::getMeetConditionsString"]["tailWord"]="'";
1170
										#參考資料:
1205
										#參考資料:
1171
										#無.
1206
										#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
1172
										#備註:
1207
										#備註:
1173
										#無.
1208
										#無.
1174
										$findShellVar=search::findShellVar($conf["search::findShellVar"]);
1209
										$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
1175
										unset($conf["search::findShellVar"]);
1210
										unset($conf["search::getMeetConditionsString"]);
1176
 
1211
 
1177
										#如果檢查失敗
1212
										#如果檢查失敗
1178
										if($findShellVar["status"]=="false"){
1213
										if($getMeetConditionsString["status"]=="false"){
1179
 
1214
 
1180
											#設置錯誤識別
1215
											#設置錯誤識別
1181
											$result["status"]="false";
1216
											$result["status"]="false";
1182
 
1217
 
1183
											#設置錯誤訊息
1218
											#設置錯誤訊息
1184
											$result["error"]=$findShellVar;
1219
											$result["error"]=$getMeetConditionsString;
1185
 
1220
 
1186
											#回傳解果
1221
											#回傳解果
1187
											return $result;
1222
											return $result;
1188
 
1223
 
1189
											}#if end
1224
											}#if end
1190
 
1225
 
1191
										#含有 shell 變數
1226
										#含有 shell 變數
1192
										if($findShellVar["founded"]=="true"){
1227
										if($getMeetConditionsString["founded"]==="true"){
1193
 
1228
 
1194
											#確認該字串是否 開頭跟結尾為 「'」
1229
											#將含有 shell 變數的參數變成 '....'${hellVar}'....'
1195
											#函式說明:
1230
											#函式說明:
1196
											#取得符合特定字首與字尾的字串
1231
											#處理字串避免網頁出錯
1197
											#回傳結果:
1232
											#回傳結果:
1198
											#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
1233
											#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1199
											#$result["function"],當前執行的函數名稱.
1234
											#$result["function"],當前執行的函數.
-
 
1235
											#$result["content"],爲處理好的字串.
1200
											#$result["error"],錯誤訊息陣列.
1236
											#$result["error"],錯誤訊息陣列.
1201
											#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
-
 
1202
											#$result["returnString"],爲符合字首條件的字串內容。
-
 
1203
											#$result["argu"],使用的參數.
1237
											#$result["argu"],使用的參數.
1204
											#必填參數:
1238
											#必填參數:
1205
											#$conf["checkString"],字串,要檢查的字串.
1239
											#$conf["stringIn"],字串,爲要處理的字串
1206
											$conf["search::getMeetConditionsString"]["checkString"]=$escapeArgu;
1240
											$conf["stringProcess::correctCharacter"]["stringIn"]=$escapeArgu;
1207
											#可省略參數:
1241
											#可省略參數:
1208
											#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
1242
											#$conf["selectedCharacter"],字串陣列,爲被選擇要處理的字串/字元,須爲陣列值。若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
1209
											$conf["search::getMeetConditionsString"]["frontWord"]="'";
1243
											$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("\${","}");
1210
											#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
1244
											#$conf["changeTo"],字串陣列,爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
1211
											$conf["search::getMeetConditionsString"]["tailWord"]="'";
1245
											$conf["stringProcess::correctCharacter"]["changeTo"]=array("'\${","}'");
1212
											#參考資料:
1246
											#參考資料:
1213
											#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
1247
											#無.
1214
											#備註:
1248
											#備註:
1215
											#無.
1249
											#無.
1216
											$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
1250
											$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
1217
											unset($conf["search::getMeetConditionsString"]);
1251
											unset($conf["stringProcess::correctCharacter"]);
1218
 
1252
 
1219
											#如果檢查失敗
1253
											#如果執行失敗
1220
											if($getMeetConditionsString["status"]=="false"){
1254
											if($correctCharacter["status"]=="false"){
1221
 
1255
 
1222
												#設置錯誤識別
1256
												#設置錯誤識別
1223
												$result["status"]="false";
1257
												$result["status"]="false";
1224
 
1258
 
1225
												#設置錯誤訊息
1259
												#設置錯誤訊息
1226
												$result["error"]=$getMeetConditionsString;
1260
												$result["error"]=$correctCharacter;
1227
 
1261
 
1228
												#回傳解果
1262
												#回傳解果
1229
												return $result;
1263
												return $result;
1230
 
1264
 
1231
												}#if end
1265
												}#if end
1232
 
1266
 
1233
											#含有 shell 變數
-
 
1234
											if($getMeetConditionsString["founded"]==="true"){
-
 
1235
 
-
 
1236
												#將含有 shell 變數的參數變成 '....'${hellVar}'....'
-
 
1237
												#函式說明:
-
 
1238
												#處理字串避免網頁出錯
-
 
1239
												#回傳結果:
-
 
1240
												#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1241
												#$result["function"],當前執行的函數.
-
 
1242
												#$result["content"],爲處理好的字串.
-
 
1243
												#$result["error"],錯誤訊息陣列.
-
 
1244
												#$result["argu"],使用的參數.
-
 
1245
												#必填參數:
-
 
1246
												#$conf["stringIn"],字串,爲要處理的字串
-
 
1247
												$conf["stringProcess::correctCharacter"]["stringIn"]=$escapeArgu;
-
 
1248
												#可省略參數:
-
 
1249
												#$conf["selectedCharacter"],字串陣列,爲被選擇要處理的字串/字元,須爲陣列值。若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
-
 
1250
												$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("\${","}");
-
 
1251
												#$conf["changeTo"],字串陣列,爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
-
 
1252
												$conf["stringProcess::correctCharacter"]["changeTo"]=array("'\${","}'");
-
 
1253
												#參考資料:
-
 
1254
												#無.
-
 
1255
												#備註:
-
 
1256
												#無.
-
 
1257
												$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
-
 
1258
												unset($conf["stringProcess::correctCharacter"]);
-
 
1259
 
-
 
1260
												#如果執行失敗
-
 
1261
												if($correctCharacter["status"]=="false"){
-
 
1262
 
-
 
1263
													#設置錯誤識別
-
 
1264
													$result["status"]="false";
-
 
1265
 
-
 
1266
													#設置錯誤訊息
-
 
1267
													$result["error"]=$correctCharacter;
-
 
1268
 
-
 
1269
													#回傳解果
-
 
1270
													return $result;
-
 
1271
 
-
 
1272
													}#if end
-
 
1273
 
-
 
1274
												#更新成可以呈現 shell 變數的字串
1267
											#更新成可以呈現 shell 變數的字串
1275
												$escapeArgu=$correctCharacter["content"];
1268
											$escapeArgu=$correctCharacter["content"];
1276
 
-
 
1277
												}#if end
-
 
1278
 
1269
 
1279
											}#if end
1270
											}#if end
1280
 
1271
 
1281
										}#if end
1272
										}#if end
1282
 
1273
 
1283
									}#if end
1274
									}#if end
1284
 
1275
 
1285
								}#if end
1276
								}#if end
1286
 
1277
 
-
 
1278
							}#if end
-
 
1279
 
-
 
1280
						#如果是要執行 escpaed 後的指令
-
 
1281
						if($conf["escapeshellarg"]==="true"){
-
 
1282
						
1287
							#串接指令
1283
							#串接指令
1288
							$result["cmd"]=$result["cmd"]." ".$escapeArgu;
1284
							$result["cmd"]=$result["cmd"]." ".$escapeArgu;
-
 
1285
						
-
 
1286
							}#if end
-
 
1287
						
-
 
1288
						#反之
-
 
1289
						else{
-
 
1290
						
-
 
1291
							#串接指令
-
 
1292
							$result["cmd"]=$result["cmd"]." ".$unescapeArgu;
-
 
1293
							
-
 
1294
							}#else end
1289
 
1295
 
1290
							#儲存真正的參數
1296
						#儲存真正的參數
1291
							$result["escape"]["argu"][]=$escapeArgu;
1297
						$result["escaped"]["argu"][]=$escapeArgu;
1292
 
-
 
1293
							}#else
1298
							
-
 
1299
						#儲存未escape的參數
-
 
1300
						$result["noEscaped"]["argu"][]=$unescapeArgu;
1294
 
1301
 
1295
						}#else end
1302
						}#else end
1296
 
1303
 
1297
					}#for end
1304
					}#for end
1298
 
1305
 
1299
				}#if end
1306
				}#if end
1300
 
1307
 
1301
			}#if end
1308
			}#if end
1302
 
1309
 
1303
		#反之 $conf["escapeshellarg"] 為 "false"
-
 
1304
		else{
-
 
1305
 
-
 
1306
			#初始化儲存未escaped後的指令與參數資訊
-
 
1307
			$result["noEscaped"]=array();
-
 
1308
 
-
 
1309
			#儲存執行的指令
-
 
1310
			$result["noEscaped"]["cmd"]=$conf["command"];
-
 
1311
 
-
 
1312
			#初始化儲存執行的參數
-
 
1313
			$result["noEscaped"]["argu"]=array();
-
 
1314
 
-
 
1315
			#如果有參數存在
-
 
1316
			if(isset($conf["argu"])){
-
 
1317
 
-
 
1318
				#儲存執行的參數
-
 
1319
				$result["noEscaped"]["argu"]=$conf["argu"];
-
 
1320
 
-
 
1321
				#有幾個參數就執行幾次
-
 
1322
				for($i=0;$i<count($conf["argu"]);$i++){
-
 
1323
 
-
 
1324
					#如果有指定位置參數
-
 
1325
					if(isset($conf["arguIsAddr"])){
-
 
1326
 
-
 
1327
						#如果是位置參數
-
 
1328
						if($conf["arguIsAddr"][$i]==="true"){
-
 
1329
 
-
 
1330
							#如果是相對路徑就要轉換路徑
-
 
1331
							if(strpos($conf["argu"][$i],"/")!==0){
-
 
1332
 
-
 
1333
								#函數說明:
-
 
1334
								#將多個路徑字串變成相對於當前路徑的相對路徑字串
-
 
1335
								#回傳結果:
-
 
1336
								#$result["status"],"true"爲建立成功,"false"爲建立失敗.
-
 
1337
								#$result["error"],錯誤訊息陣列.
-
 
1338
								#$result["function"],函數名稱.
-
 
1339
								#$result["content"],字串陣列,多個轉換好的相對路徑字串.
-
 
1340
								#必填參數:
-
 
1341
								#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
-
 
1342
								$conf["fileAccess::getRelativePath"]["path"]=array($conf["argu"][$i]);
-
 
1343
								#$conf["fileArgu"],字串,當前路徑.
-
 
1344
								$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
-
 
1345
								$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
-
 
1346
								unset($conf["fileAccess::getRelativePath"]);
-
 
1347
 
-
 
1348
								#如果轉換路徑失敗
-
 
1349
								if($getRelativePath["status"]==="false"){
-
 
1350
 
-
 
1351
									#設置執行失敗的識別
-
 
1352
									$result["status"]="false";
-
 
1353
 
-
 
1354
									#設置執行失敗的訊息
-
 
1355
									$result["error"]=$getRelativePath;
-
 
1356
 
-
 
1357
									#回傳結果
-
 
1358
									return $result;
-
 
1359
 
-
 
1360
									}#if end
-
 
1361
 
-
 
1362
								#取得相對路徑
-
 
1363
								$relativePath=$getRelativePath["content"][0];
-
 
1364
 
-
 
1365
								#保存其相對路徑
-
 
1366
								$conf["argu"][$i]=$relativePath;
-
 
1367
 
-
 
1368
								}#if end
-
 
1369
 
-
 
1370
							}#if end
-
 
1371
 
-
 
1372
						}#if end
-
 
1373
 
-
 
1374
					#組合執行的指令
-
 
1375
					$result["cmd"]=$result["cmd"]." ".$conf["argu"][$i];
-
 
1376
 
-
 
1377
					}#for end
-
 
1378
 
-
 
1379
				}#if end
-
 
1380
 
-
 
1381
			}#else end
-
 
1382
 
-
 
1383
		#如果有設置使用者名稱
1310
		#如果有設置使用者名稱
1384
		if(isset($conf["username"])){
1311
		if(isset($conf["username"])){
1385
 
1312
 
1386
			#檢查環境為apache還是cmd
1313
			#檢查環境為apache還是cmd
1387
			#涵式說明:
1314
			#涵式說明:
Line 1513... Line 1440...
1513
			#在命令列執行,所得的路徑是錯誤的。
1440
			#在命令列執行,所得的路徑是錯誤的。
1514
			$getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
1441
			$getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
1515
			unset($conf["fileAccess::getInternetAddress"]);
1442
			unset($conf["fileAccess::getInternetAddress"]);
1516
 
1443
 
1517
			#如果轉換路徑失敗
1444
			#如果轉換路徑失敗
1518
			if($getInternetAddress["status"]=="false"){
1445
			if($getInternetAddress["status"]==="false"){
1519
 
1446
 
1520
				#設置執行失敗
1447
				#設置執行失敗
1521
				$result["status"]="false";
1448
				$result["status"]="false";
1522
 
1449
 
1523
				#設置執行錯誤
1450
				#設置執行錯誤
Line 1662... Line 1589...
1662
			#用script指令抓取輸出,並存到 $conf["logFilePath"]."/".$conf["logFileName"].
1589
			#用script指令抓取輸出,並存到 $conf["logFilePath"]."/".$conf["logFileName"].
1663
			$result["cmd"]="script -q -c \"".$result["cmd"]."\" \"".$conf["logFilePath"]."/".$conf["logFileName"]."\"";
1590
			$result["cmd"]="script -q -c \"".$result["cmd"]."\" \"".$conf["logFilePath"]."/".$conf["logFileName"]."\"";
1664
 
1591
 
1665
			}#if end
1592
			}#if end
1666
 
1593
 
-
 
1594
		#如果有指定遠端ip
-
 
1595
		if(isset($conf["remoteIp"])){
-
 
1596
		
-
 
1597
			#設定ssh指令	
-
 
1598
			$ssh="ssh ".$conf["remoteIp"];
-
 
1599
		
-
 
1600
			#如果有指定遠端使用者
-
 
1601
			if(isset($conf["remoteUser"])){
-
 
1602
			
-
 
1603
				#設定ssh指令
-
 
1604
				$ssh="ssh ".$conf["remoteUser"]."@".$conf["remoteIp"];
-
 
1605
			
-
 
1606
				}#if end
-
 
1607
		
-
 
1608
			#檢測能否成功遠端的指令
-
 
1609
			$testRemote="echo 'env | grep SSH_CONNECTION' | ".$ssh;
-
 
1610
			
-
 
1611
			#debug
-
 
1612
			#var_dump(__LINE__,$testRemote);
-
 
1613
			
-
 
1614
			#初始化輸出
-
 
1615
			$output=array();
-
 
1616
			
-
 
1617
			#執行檢測遠端是否成功
-
 
1618
			exec($testRemote,$output,$status);
-
 
1619
		
-
 
1620
			#如果異常
-
 
1621
			if($status!==0){
-
 
1622
			
-
 
1623
				#設置執行不正常
-
 
1624
				$result["status"]="false";
-
 
1625
 
-
 
1626
				#設置執行錯誤
-
 
1627
				$result["error"]="can not run cmd on remote shell(".$testRemote.")";
-
 
1628
 
-
 
1629
				#回傳結果
-
 
1630
				return $result;
-
 
1631
			
-
 
1632
				}#if end
-
 
1633
				
-
 
1634
			#如果異常
-
 
1635
			if(count($output)===0){
-
 
1636
			
-
 
1637
				#設置執行不正常
-
 
1638
				$result["status"]="false";
-
 
1639
 
-
 
1640
				#設置執行錯誤
-
 
1641
				$result["error"]="can not run cmd on remote shell(".$testRemote.")";
-
 
1642
 
-
 
1643
				#回傳結果
-
 
1644
				return $result;
-
 
1645
			
-
 
1646
				}#if end
-
 
1647
			
-
 
1648
			#繼承既有參數
-
 
1649
			$conf["external::callShell"]=$conf;
-
 
1650
			
-
 
1651
			#連線到遠端的ssh參數
-
 
1652
			$remote="";
-
 
1653
			
-
 
1654
			#如果有 remoteIp 參數
-
 
1655
			if(isset($conf["external::callShell"]["remoteIp"])){
-
 
1656
			
-
 
1657
				#設置 remote ip
-
 
1658
				$remote=$conf["external::callShell"]["remoteIp"];
-
 
1659
			
-
 
1660
				#移除之
-
 
1661
				unset($conf["external::callShell"]["remoteIp"]);
-
 
1662
			
-
 
1663
				#如果有 remoteUser 參數
-
 
1664
				if(isset($conf["external::callShell"]["remoteUser"])){
-
 
1665
				
-
 
1666
					#設置 remote user
-
 
1667
					$remote=$conf["external::callShell"]["remoteUser"]."@".$remote;
-
 
1668
				
-
 
1669
					#移除之
-
 
1670
					unset($conf["external::callShell"]["remoteUser"]);
-
 
1671
				
-
 
1672
					}#if end
-
 
1673
			
-
 
1674
				}#if end
-
 
1675
				
-
 
1676
			#設置不執行,只要印出指令內容
-
 
1677
			$conf["external::callShell"]["doNotRun"]="true";
-
 
1678
			
-
 
1679
			#設置不escape
-
 
1680
			#$conf["external::callShell"]["escapeshellarg"]="false";
-
 
1681
				
-
 
1682
			#函式說明:
-
 
1683
			#呼叫shell執行系統命令,並取得回傳的內容.
-
 
1684
			#回傳結果:
-
 
1685
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1686
			#$result["error"],錯誤訊息陣列.
-
 
1687
			#$result["function"],當前執行的函數名稱.
-
 
1688
			#$result["argu"],使用的參數.
-
 
1689
			#$result["cmd"],執行的指令內容.
-
 
1690
			#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
1691
			#$result["output"],爲執行完後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
-
 
1692
			#$result["content"],為執行完後的輸出字串.
-
 
1693
			#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
1694
			#$result["running"],是否還在執行.
-
 
1695
			#$result["pid"],pid.
-
 
1696
			#$result["statusCode"],執行結束後的代碼.
-
 
1697
			#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
-
 
1698
			#$result["noEcaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
-
 
1699
			#必填參數:
-
 
1700
			#$conf["command"],字串,要執行的指令.
-
 
1701
			#$conf["external::callShell"]["command"]="";
-
 
1702
			#$conf["fileArgu"],字串,變數__FILE__的內容.
-
 
1703
			#$conf["external::callShell"]["fileArgu"]=__FILE__;
-
 
1704
			#可省略參數:
-
 
1705
			#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
-
 
1706
			#$conf["argu"]=array("");
-
 
1707
			#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
-
 
1708
			#$conf["arguIsAddr"]=array();
-
 
1709
			#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
-
 
1710
			#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
-
 
1711
			#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
-
 
1712
			#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
-
 
1713
			#$conf["enablePrintDescription"]="true";
-
 
1714
			#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
-
 
1715
			#$conf["printDescription"]="";
-
 
1716
			#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
-
 
1717
			#$conf["escapeshellarg"]="false";
-
 
1718
			#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
-
 
1719
			#$conf["thereIsShellVar"]=array();
-
 
1720
			#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
-
 
1721
			#$conf["username"]="";
-
 
1722
			#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
-
 
1723
			#$conf["password"]="";
-
 
1724
			#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
-
 
1725
			#$conf["useScript"]="";
-
 
1726
			#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
-
 
1727
			#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
-
 
1728
			#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
-
 
1729
			#$conf["inBackGround"]="";
-
 
1730
			#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
-
 
1731
			#$conf["getErr"]="false";
-
 
1732
			#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
-
 
1733
			#$conf["doNotRun"]="false";
-
 
1734
			#$conf["remoteIp"],字串,遠端ip或domainName,預設不使用,若存在則會透過ssh指令進行連線,然後執行指令.
-
 
1735
			#$conf["remoteIp"]="";
-
 
1736
			#$conf["remoteUser"],字串,遠端的使用者賬戶,預設不指定,亦即跟為運行該php程式的使用者.
-
 
1737
			#$conf["remoteUser"]="";
-
 
1738
			#參考資料:
-
 
1739
			#exec=>http://php.net/manual/en/function.exec.php
-
 
1740
			#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
-
 
1741
			#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
-
 
1742
			#備註:
-
 
1743
			#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
-
 
1744
			#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
-
 
1745
			$callShell=external::callShell($conf["external::callShell"]);
-
 
1746
			unset($conf["external::callShell"]);
-
 
1747
		
-
 
1748
			#如果執行異常
-
 
1749
			if($callShell["status"]==="false"){
-
 
1750
			
-
 
1751
				#設置執行不正常
-
 
1752
				$result["status"]="false";
-
 
1753
 
-
 
1754
				#設置執行錯誤
-
 
1755
				$result["error"]=$callShell;
-
 
1756
 
-
 
1757
				#回傳結果
-
 
1758
				return $result;
-
 
1759
			
-
 
1760
				}#if end
-
 
1761
			
-
 
1762
			#指令與參數組成的陣列
-
 
1763
			#var_dump(__LINE__,$callShell);exit;
-
 
1764
		
-
 
1765
			#函式說明:
-
 
1766
			#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
-
 
1767
			#回傳的結果:
-
 
1768
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1769
			#$result["function"],當前執行的function名稱
-
 
1770
			#$result["error"],錯誤訊息陣列.
-
 
1771
			#$result["content"],處理好的字串.
-
 
1772
			#$result["argu"],使用的參數.
-
 
1773
			#必填參數:
-
 
1774
			#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.
-
 
1775
			$conf["arrays::arrayToString"]["inputArray"]=$callShell["noEscaped"]["array"];
-
 
1776
			#可省略參數:
-
 
1777
			#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;
-
 
1778
			$conf["arrays::arrayToString"]["spiltSymbol"]=" ";
-
 
1779
			#$conf["skipEnd"],字串,結尾是否不要加上符號,預設為"false",要加上符號,"true"代表不要加上符號。
-
 
1780
			$conf["arrays::arrayToString"]["skipEnd"]="true";
-
 
1781
			#$conf["spiltSymbolAtStart"],字串,是否要在開頭加上spiltSymbol,預設為"false",代表不要;反之為“true”.
-
 
1782
			#$conf["spiltSymbolAtStart"]="";
-
 
1783
			#參考資料:
-
 
1784
			#無.
-
 
1785
			#備註:
-
 
1786
			#無.
-
 
1787
			$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
-
 
1788
			unset($conf["arrays::arrayToString"]);
-
 
1789
		
-
 
1790
			#如果執行異常
-
 
1791
			if($arrayToString["status"]==="false"){
-
 
1792
			
-
 
1793
				#設置執行不正常
-
 
1794
				$result["status"]="false";
-
 
1795
 
-
 
1796
				#設置執行錯誤
-
 
1797
				$result["error"]=$arrayToString;
-
 
1798
 
-
 
1799
				#回傳結果
-
 
1800
				return $result;
-
 
1801
			
-
 
1802
				}#if end
-
 
1803
				
-
 
1804
			#初始化要執行的程式
-
 
1805
			$cmd="echo";
-
 
1806
			
-
 
1807
			#初始化要在遠端執行的參數
-
 
1808
			$argu=array($arrayToString["content"],"|","ssh",$remote);
-
 
1809
			
-
 
1810
			#函式說明:
-
 
1811
			#呼叫shell執行系統命令,並取得回傳的內容.
-
 
1812
			#回傳結果:
-
 
1813
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1814
			#$result["error"],錯誤訊息陣列.
-
 
1815
			#$result["function"],當前執行的函數名稱.
-
 
1816
			#$result["argu"],使用的參數.
-
 
1817
			#$result["cmd"],執行的指令內容.
-
 
1818
			#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
1819
			#$result["output"],爲執行完後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
-
 
1820
			#$result["content"],為執行完後的輸出字串.
-
 
1821
			#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
1822
			#$result["running"],是否還在執行.
-
 
1823
			#$result["pid"],pid.
-
 
1824
			#$result["statusCode"],執行結束後的代碼.
-
 
1825
			#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
-
 
1826
			#$result["noEcaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
-
 
1827
			#必填參數:
-
 
1828
			#$conf["command"],字串,要執行的指令.
-
 
1829
			$conf["external::callShell"]["command"]=$cmd;
-
 
1830
			#$conf["fileArgu"],字串,變數__FILE__的內容.
-
 
1831
			$conf["external::callShell"]["fileArgu"]=__FILE__;
-
 
1832
			#可省略參數:
-
 
1833
			#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
-
 
1834
			$conf["external::callShell"]["argu"]=$argu;
-
 
1835
			#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
-
 
1836
			#$conf["arguIsAddr"]=array();
-
 
1837
			#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
-
 
1838
			#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
-
 
1839
			#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
-
 
1840
			#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
-
 
1841
			#$conf["enablePrintDescription"]="true";
-
 
1842
			#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
-
 
1843
			#$conf["printDescription"]="";
-
 
1844
			#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
-
 
1845
			$conf["external::callShell"]["escapeshellarg"]="true";
-
 
1846
			#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
-
 
1847
			#$conf["thereIsShellVar"]=array();
-
 
1848
			#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
-
 
1849
			#$conf["username"]="";
-
 
1850
			#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
-
 
1851
			#$conf["password"]="";
-
 
1852
			#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
-
 
1853
			#$conf["useScript"]="";
-
 
1854
			#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
-
 
1855
			#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
-
 
1856
			#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
-
 
1857
			#$conf["inBackGround"]="";
-
 
1858
			#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
-
 
1859
			#$conf["getErr"]="false";
-
 
1860
			#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
-
 
1861
			#$conf["doNotRun"]="false";
-
 
1862
			#$conf["remoteIp"],字串,遠端ip或domainName,預設不使用,若存在則會透過ssh指令進行連線,然後執行指令.
-
 
1863
			#$conf["remoteIp"]="";
-
 
1864
			#$conf["remoteUser"],字串,遠端的使用者賬戶,預設不指定,亦即跟為運行該php程式的使用者.
-
 
1865
			#$conf["remoteUser"]="";
-
 
1866
			#參考資料:
-
 
1867
			#exec=>http://php.net/manual/en/function.exec.php
-
 
1868
			#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
-
 
1869
			#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
-
 
1870
			#備註:
-
 
1871
			#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
-
 
1872
			#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
-
 
1873
			return external::callShell($conf["external::callShell"]);
-
 
1874
			unset($conf["external::callShell"]);
-
 
1875
		
-
 
1876
			}#if end
-
 
1877
 
1667
		#如果 $conf["inBackGround"] 為 "true"
1878
		#如果 $conf["inBackGround"] 為 "true"
1668
		if($conf["inBackGround"]==="true"){
1879
		if($conf["inBackGround"]==="true"){
1669
 
1880
 
1670
			#函式說明:
1881
			#函式說明:
1671
			#呼叫shell執行系統命令,並取得回傳的內容與pid.
1882
			#呼叫shell執行系統命令,並取得回傳的內容與pid.
Line 1764... Line 1975...
1764
				}#if end
1975
				}#if end
1765
 
1976
 
1766
			#反之要執行指令
1977
			#反之要執行指令
1767
			else{
1978
			else{
1768
 
1979
 
-
 
1980
				#debug
1769
				#var_dump($result["cmd"]);
1981
				#var_dump(__LINE__,$result["cmd"]);
1770
 
1982
 
1771
				#執行腳本程式,將輸出結果儲存在 $resultArray 陣列裏面
1983
				#執行腳本程式,將輸出結果儲存在 $resultArray 陣列裏面
1772
				exec($result["cmd"],$resultArray,$execStatus);
1984
				exec($result["cmd"],$resultArray,$execStatus);
1773
 
1985
 
1774
				#取得執行結果狀態碼
1986
				#取得執行結果狀態碼
Line 1863... Line 2075...
1863
			#取得執行外部程式的輸出
2075
			#取得執行外部程式的輸出
1864
			$result["output"]=$resultArray;
2076
			$result["output"]=$resultArray;
1865
 
2077
 
1866
			}#else end
2078
			}#else end
1867
 
2079
 
1868
		#如果有escape後的結果
2080
		#初始化暫存 指令跟參數的陣列
1869
		if(isset($result["escape"])){
2081
		$cmdAndArguArray=array();
1870
 
2082
 
1871
			#初始化暫存 指令跟參數的陣列
2083
		#取得第一個元素
1872
			$cmdAndArguArray=array();
2084
		$cmdAndArguArray[]=&$result["escaped"]["cmd"];
1873
 
2085
 
1874
			#取得第一個元素
2086
		#如果有 argu
1875
			$cmdAndArguArray[]=&$result["escape"]["cmd"];
2087
		if(isset($result["escaped"]["argu"])){
1876
 
2088
 
1877
			#如果有 argu
2089
			#針對每個參數
1878
			if(isset($result["escape"]["argu"])){
2090
			foreach($result["escaped"]["argu"] as $arguKey=>$arguVal){
1879
 
2091
 
1880
				#針對每個參數
-
 
1881
				foreach($result["escape"]["argu"] as $arguKey=>$arguVal){
-
 
1882
 
-
 
1883
					#取得該參數
2092
				#取得該參數
1884
					$cmdAndArguArray[]=&$result["escape"]["argu"][$arguKey];
2093
				$cmdAndArguArray[]=&$result["escaped"]["argu"][$arguKey];
1885
 
-
 
1886
					}#foreach end
-
 
1887
 
2094
 
1888
				}#if end
2095
				}#foreach end
1889
 
-
 
1890
			#設置 cmd & argu 合併為一維陣列後的結果
-
 
1891
			$result["escape"]["array"]=&$cmdAndArguArray;
-
 
1892
 
2096
 
1893
			}#if end
2097
			}#if end
1894
 
2098
 
1895
		#如果有不 Escaped 的指令資訊結果
2099
		#設置 cmd & argu 合併為一維陣列後的結果
1896
		if(isset($result["noEscaped"])){
2100
		$result["escaped"]["array"]=&$cmdAndArguArray;
1897
 
2101
 
1898
			#從 $result["noEscaped"]["cmd"] 跟 $result["noEscaped"]["argu"] 產生 $result["noEscaped"]["array"]
2102
		#從 $result["noEscaped"]["cmd"] 跟 $result["noEscaped"]["argu"] 產生 $result["noEscaped"]["array"]
1899
			#函式說明:
2103
		#函式說明:
1900
			#將多個一維陣列串聯起來,key從0開始排序.
2104
		#將多個一維陣列串聯起來,key從0開始排序.
1901
			#回傳的結果:
2105
		#回傳的結果:
1902
			#$result["status"],"true"表執行正常,"false"代表執行不正常.
2106
		#$result["status"],"true"表執行正常,"false"代表執行不正常.
1903
			#$result["error"],錯誤訊息陣列.
2107
		#$result["error"],錯誤訊息陣列.
1904
			#$result["function"],當前執行的函數.
2108
		#$result["function"],當前執行的函數.
1905
			#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
2109
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
1906
			#$result["content"],合併好的一維陣列.
2110
		#$result["content"],合併好的一維陣列.
1907
			#必填參數
2111
		#必填參數
1908
			#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
2112
		#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
1909
			$conf["arrays::mergeArray"]["inputArray"]=array(array($result["noEscaped"]["cmd"]),$result["noEscaped"]["argu"]);
2113
		$conf["arrays::mergeArray"]["inputArray"]=array(array($result["noEscaped"]["cmd"]),$result["noEscaped"]["argu"]);
1910
			#可省略參數:
2114
		#可省略參數:
1911
			#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
2115
		#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
1912
			#$conf["allowRepeat"]="true";
2116
		#$conf["allowRepeat"]="true";
1913
			#$conf["looseDiff"],字串,預設為"false",代表要嚴謹判斷為有相異,例如陣列中元素的key順序不同(整數)就代表有相異;反之為"true",例如陣列中元素的key順序不同(非整數),但value有相同,則視為無相異.
2117
		#$conf["looseDiff"],字串,預設為"false",代表要嚴謹判斷為有相異,例如陣列中元素的key順序不同(整數)就代表有相異;反之為"true",例如陣列中元素的key順序不同(非整數),但value有相同,則視為無相異.
1914
			#$conf["looseDiff"]="false";
2118
		#$conf["looseDiff"]="false";
1915
			#參考資料:
2119
		#參考資料:
1916
			#無.
2120
		#無.
1917
			#備註:
2121
		#備註:
1918
			#無.
2122
		#無.
1919
			$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
2123
		$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
1920
			unset($conf["arrays::mergeArray"]);
2124
		unset($conf["arrays::mergeArray"]);
1921
 
-
 
1922
			#如果異常
-
 
1923
			if($mergeArray["status"]=="false"){
-
 
1924
 
-
 
1925
				#設置執行不正常
-
 
1926
				$result["status"]="false";
-
 
1927
 
2125
 
1928
				#設置執行錯誤
2126
		#如果異常
1929
				$result["error"]=$mergeArray;
2127
		if($mergeArray["status"]=="false"){
1930
 
2128
 
1931
				#回傳結果
2129
			#設置執行不正常
1932
				return $result;
2130
			$result["status"]="false";
1933
 
2131
 
1934
				}#if end
2132
			#設置執行錯誤
-
 
2133
			$result["error"]=$mergeArray;
1935
 
2134
 
1936
			#取得未escape的指令與參數陣列
2135
			#回傳結果
1937
			$result["noEscaped"]["array"]=$mergeArray["content"];
2136
			return $result;
1938
 
2137
 
1939
			}#if end
2138
			}#if end
1940
 
2139
 
-
 
2140
		#取得未escape的指令與參數陣列
-
 
2141
		$result["noEscaped"]["array"]=$mergeArray["content"];
-
 
2142
 
1941
		#若執行外部式回傳的狀態不為0
2143
		#若執行外部式回傳的狀態不為0
1942
		if($execStatus!==0){
2144
		if($execStatus!==0){
1943
 
2145
 
1944
			#代表執行外部程式不正常.
2146
			#代表執行外部程式不正常.
1945
 
2147