Subversion Repositories php-qbpwcf

Rev

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

Rev 3 Rev 60
Line 500... Line 500...
500
	#$result["error"],錯誤訊息陣列.
500
	#$result["error"],錯誤訊息陣列.
501
	#$result["function"],當前執行的函數名稱.
501
	#$result["function"],當前執行的函數名稱.
502
	#$result["argu"],使用的參數.
502
	#$result["argu"],使用的參數.
503
	#$result["cmd"],執行的指令內容.
503
	#$result["cmd"],執行的指令內容.
504
	#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
504
	#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
505
	#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
505
	#$result["output"],爲執行完後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
-
 
506
	#$result["content"],為執行完後的輸出字串.
506
	#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
507
	#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
507
	#$result["running"],是否還在執行.
508
	#$result["running"],是否還在執行.
508
	#$result["pid"],pid.
509
	#$result["pid"],pid.
509
	#$result["statusCode"],執行結束後的代碼.
510
	#$result["statusCode"],執行結束後的代碼.
510
	#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
511
	#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
Line 1245... Line 1246...
1245
												}#if end
1246
												}#if end
1246
									
1247
									
1247
											}#if end
1248
											}#if end
1248
									
1249
									
1249
										}#if end
1250
										}#if end
1250
																									
1251
									
1251
									}#if end
1252
									}#if end
1252
							
1253
							
1253
								}#if end
1254
								}#if end
1254
						
1255
						
1255
							#串接指令
1256
							#串接指令
Line 1437... Line 1438...
1437
					#透過指定的使用者來執行指令
1438
					#透過指定的使用者來執行指令
1438
					$result["cmd"]="su ".$conf["username"]." -c '".$result["cmd"]."'";
1439
					$result["cmd"]="su ".$conf["username"]." -c '".$result["cmd"]."'";
1439
					
1440
					
1440
					}#else end
1441
					}#else end
1441
				
1442
				
1442
				}#if end			
1443
				}#if end
1443
			
1444
			
1444
			}#if end
1445
			}#if end
1445
		
1446
		
1446
		#如果 $conf["useScript"] 為 "true"
1447
		#如果 $conf["useScript"] 為 "true"
1447
		if($conf["useScript"]==="true"){
1448
		if($conf["useScript"]==="true"){
Line 1723... Line 1724...
1723
			else{
1724
			else{
1724
			
1725
			
1725
				#var_dump($result["cmd"]);
1726
				#var_dump($result["cmd"]);
1726
			
1727
			
1727
				#執行腳本程式,將輸出結果儲存在 $resultArray 陣列裏面
1728
				#執行腳本程式,將輸出結果儲存在 $resultArray 陣列裏面
1728
				exec($result["cmd"],$resultArray,$execStatus);			
1729
				exec($result["cmd"],$resultArray,$execStatus);
1729
				
1730
				
1730
				#取得執行結果狀態碼
1731
				#取得執行結果狀態碼
1731
				$result["statusCode"]=$execStatus;
1732
				$result["statusCode"]=$execStatus;
1732
			
1733
			
1733
				}#else end
1734
				}#else end
1734
			
1735
			
1735
			}#else end
1736
			}#else end
1736
		
1737
		
1737
		#如果 $conf["useScript"] 為 "true"
1738
		#如果 $conf["useScript"] 為 "true"
1738
		if($conf["useScript"]=="true"){				
1739
		if($conf["useScript"]=="true"){
1739
			
1740
			
1740
			#讀取暫存檔案的內容
1741
			#讀取暫存檔案的內容
1741
			#函式說明:
1742
			#函式說明:
1742
			#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
1743
			#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
1743
			#回傳的變數說明:
1744
			#回傳的變數說明:
Line 1868... Line 1869...
1868
			#回傳結果
1869
			#回傳結果
1869
			return $result;
1870
			return $result;
1870
			
1871
			
1871
			}#if end
1872
			}#if end
1872
		
1873
		
-
 
1874
		#初始化完整標準輸出
-
 
1875
		$result["content"]="";
-
 
1876
		
-
 
1877
		#如果有 output
-
 
1878
		if(!empty($result["output"])){
-
 
1879
		
-
 
1880
			#函式說明:
-
 
1881
			#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
-
 
1882
			#回傳的結果:
-
 
1883
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
1884
			#$result["function"],當前執行的function名稱
-
 
1885
			#$result["error"],錯誤訊息陣列.
-
 
1886
			#$result["content"],處理好的字串.
-
 
1887
			#$result["argu"],使用的參數.
-
 
1888
			#必填參數:
-
 
1889
			#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.
-
 
1890
			$conf["arrays::arrayToString"]["inputArray"]=$result["output"];
-
 
1891
			#可省略參數:
-
 
1892
			#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;
-
 
1893
			$conf["arrays::arrayToString"]["spiltSymbol"]=PHP_EOL;
-
 
1894
			#$conf["skipEnd"],字串,結尾是否不要加上符號,預設為"false",要加上符號,"true"代表不要加上符號。
-
 
1895
			$conf["arrays::arrayToString"]["skipEnd"]="true";
-
 
1896
			#$conf["spiltSymbolAtStart"],字串,是否要在開頭加上spiltSymbol,預設為"false",代表不要;反之為“true”.
-
 
1897
			#$conf["spiltSymbolAtStart"]="";
-
 
1898
			#參考資料:
-
 
1899
			#無.
-
 
1900
			#備註:
-
 
1901
			#無.
-
 
1902
			$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
-
 
1903
			unset($conf["arrays::arrayToString"]);
-
 
1904
		
-
 
1905
			#如果執行失敗
-
 
1906
			if($arrayToString["status"]=="false"){
-
 
1907
				
-
 
1908
				#設置執行不正常
-
 
1909
				$result["status"]="false";
-
 
1910
				
-
 
1911
				#設置執行錯誤
-
 
1912
				$result["error"]=$arrayToString;
-
 
1913
				
-
 
1914
				#回傳結果
-
 
1915
				return $result;
-
 
1916
				
-
 
1917
				}#if end
-
 
1918
				
-
 
1919
			#儲存完整標準輸出的內容
-
 
1920
			$result["content"]=$arrayToString["content"];
-
 
1921
		
-
 
1922
			}#if end
-
 
1923
		
1873
		#執行到這邊代表執行正常
1924
		#執行到這邊代表執行正常
1874
		$result["status"]="true";
1925
		$result["status"]="true";
1875
		
1926
		
1876
		#回傳結果
1927
		#回傳結果
1877
		return $result;
1928
		return $result;