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 249
Line 43... Line 43...
43
	#$arguments,陣列,為呼叫方法時所用的參數.
43
	#$arguments,陣列,為呼叫方法時所用的參數.
44
	#可省略參數:
44
	#可省略參數:
45
	#無.
45
	#無.
46
	#參考資料:
46
	#參考資料:
47
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
47
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
-
 
48
	#get namespace and class=>https://www.php.net/manual/en/function.get-called-class.php
48
	#備註:
49
	#備註:
49
	#無.
50
	#無.
50
	*/
51
	*/
51
	public function __call($method,$arguments){
52
	public function __call($method,$arguments){
52
 
53
 
Line 55... Line 56...
55
 
56
 
56
		#設置執行不正常
57
		#設置執行不正常
57
		$result["status"]="false";
58
		$result["status"]="false";
58
 
59
 
59
		#設置執行錯誤
60
		#設置執行錯誤
60
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
61
		$result["error"][]="欲呼叫的". get_called_class()."->".$method."() 不存在!";
61
 
62
 
62
		#設置所丟入的參數
63
		#設置所丟入的參數
63
		$result["error"][]=$arguments;
64
		$result["error"][]=$arguments;
64
 
65
 
65
		#回傳結果
66
		#回傳結果
Line 79... Line 80...
79
	#$arguments,陣列,為呼叫方法時所用的參數.
80
	#$arguments,陣列,為呼叫方法時所用的參數.
80
	#可省略參數:
81
	#可省略參數:
81
	#無.
82
	#無.
82
	#參考資料:
83
	#參考資料:
83
	#__callStatic=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
84
	#__callStatic=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
-
 
85
	#get namespace and class=>https://www.php.net/manual/en/function.get-called-class.php
84
	#備註:
86
	#備註:
85
	#無.
87
	#無.
86
	*/
88
	*/
87
	public static function __callStatic($method,$arguments){
89
	public static function __callStatic($method,$arguments){
88
 
90
 
Line 91... Line 93...
91
 
93
 
92
		#設置執行不正常
94
		#設置執行不正常
93
		$result["status"]="false";
95
		$result["status"]="false";
94
 
96
 
95
		#設置執行錯誤
97
		#設置執行錯誤
96
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
98
		$result["error"][]="欲呼叫的". get_called_class()."::".$method."() 不存在!";
97
 
99
 
98
		#設置所丟入的參數
100
		#設置所丟入的參數
99
		$result["error"][]=$arguments;
101
		$result["error"][]=$arguments;
100
 
102
 
101
		#回傳結果
103
		#回傳結果
Line 3070... Line 3072...
3070
 
3072
 
3071
		}#function delStrBeforeKeyWord end
3073
		}#function delStrBeforeKeyWord end
3072
 
3074
 
3073
	/*
3075
	/*
3074
	#函式說明:
3076
	#函式說明:
-
 
3077
	#將字串開頭的特定關鍵字移除.
-
 
3078
	#回傳結果:
-
 
3079
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3080
	#$result["error"],錯誤訊息陣列.
-
 
3081
	#$result["founded"],有無找到開頭要移除的特定字串"true"代表有,"false"代表沒有.
-
 
3082
	#$result["function"],當前執行的函數名稱.
-
 
3083
	#$result["argu"],使用的參數.
-
 
3084
	#$result["content"],處理好的的字串內容.
-
 
3085
	#$result["deleted"],被移除的內容.
-
 
3086
	#必填參數:
-
 
3087
	#$conf["stringIn"],字串,要處理的字串.
-
 
3088
	$conf["stringIn"]="";
-
 
3089
	#$conf["headStr"],字串陣列,開頭為哪些字串就要移除.
-
 
3090
	$conf["headStr"]=array("");
-
 
3091
	#可省略參數:
-
 
3092
	#無.
-
 
3093
	#參考資料:
-
 
3094
	#無.
-
 
3095
	#備註:
-
 
3096
	#無.
-
 
3097
	*/
-
 
3098
	public static function delHeadStr(&$conf){
-
 
3099
	
-
 
3100
		#初始化要回傳的結果
-
 
3101
		$result=array();
-
 
3102
 
-
 
3103
		#取得當前執行的函數名稱
-
 
3104
		$result["function"]=__FUNCTION__;
-
 
3105
 
-
 
3106
		#如果沒有參數
-
 
3107
		if(func_num_args()==0){
-
 
3108
 
-
 
3109
			#設置執行失敗
-
 
3110
			$result["status"]="false";
-
 
3111
 
-
 
3112
			#設置執行錯誤訊息
-
 
3113
			$result["error"]="函數".$result["function"]."需要參數";
-
 
3114
 
-
 
3115
			#回傳結果
-
 
3116
			return $result;
-
 
3117
 
-
 
3118
			}#if end
-
 
3119
 
-
 
3120
		/* 請依據實際狀況使用
-
 
3121
		#涵式說明:
-
 
3122
		#判斷當前環境為web還是cmd
-
 
3123
		#回傳結果:
-
 
3124
		#$result,"web"或"cmd"
-
 
3125
		if(csInformation::getEnv()==="web"){
-
 
3126
 
-
 
3127
			#設置執行失敗
-
 
3128
			$result["status"]="false";
-
 
3129
 
-
 
3130
			#設置執行錯誤訊息
-
 
3131
			$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";
-
 
3132
 
-
 
3133
			#回傳結果
-
 
3134
			return $result;
-
 
3135
 
-
 
3136
			}#if end
-
 
3137
		*/
-
 
3138
 
-
 
3139
		#取得參數
-
 
3140
		$result["argu"]=$conf;
-
 
3141
 
-
 
3142
		#如果 $conf 不為陣列
-
 
3143
		if(gettype($conf)!=="array"){
-
 
3144
 
-
 
3145
			#設置執行失敗
-
 
3146
			$result["status"]="false";
-
 
3147
 
-
 
3148
			#設置執行錯誤訊息
-
 
3149
			$result["error"][]="\$conf變數須為陣列形態";
-
 
3150
 
-
 
3151
			#如果傳入的參數為 null
-
 
3152
			if(is_null($conf)){
-
 
3153
 
-
 
3154
				#設置執行錯誤訊息
-
 
3155
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
-
 
3156
 
-
 
3157
				}#if end
-
 
3158
 
-
 
3159
			#回傳結果
-
 
3160
			return $result;
-
 
3161
 
-
 
3162
			}#if end
-
 
3163
	
-
 
3164
		#檢查參數
-
 
3165
		#函式說明:
-
 
3166
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
-
 
3167
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3168
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3169
		#$result["function"],當前執行的函式名稱.
-
 
3170
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
-
 
3171
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
-
 
3172
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
-
 
3173
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
-
 
3174
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
-
 
3175
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
-
 
3176
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
-
 
3177
		#必填寫的參數:
-
 
3178
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
-
 
3179
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
-
 
3180
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
-
 
3181
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("stringIn","headStr");
-
 
3182
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
-
 
3183
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");
-
 
3184
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
-
 
3185
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
-
 
3186
		#可以省略的參數:
-
 
3187
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
-
 
3188
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
-
 
3189
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
-
 
3190
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("recursive","lastResult");
-
 
3191
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
-
 
3192
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","array");
-
 
3193
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
-
 
3194
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false",null);
-
 
3195
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
-
 
3196
		#$conf["arrayCountEqualCheck"][]=array();
-
 
3197
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
-
 
3198
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
-
 
3199
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
-
 
3200
		#$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("stringIn");
-
 
3201
		#參考資料來源:
-
 
3202
		#array_keys=>http://php.net/manual/en/function.array-keys.php
-
 
3203
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
-
 
3204
		unset($conf["variableCheck::checkArguments"]);
-
 
3205
 
-
 
3206
		#如果檢查有誤
-
 
3207
		if($checkResult["status"]==="false"){
-
 
3208
 
-
 
3209
			#設置錯誤識別
-
 
3210
			$result["status"]="false";
-
 
3211
 
-
 
3212
			#設置錯誤訊息
-
 
3213
			$result["error"]=$checkResult;
-
 
3214
 
-
 
3215
			#回傳結果
-
 
3216
			return $result;
-
 
3217
 
-
 
3218
			}#if end
-
 
3219
 
-
 
3220
		#如果檢查不通過
-
 
3221
		if($checkResult["passed"]==="false"){
-
 
3222
 
-
 
3223
			#設置錯誤識別
-
 
3224
			$result["status"]="false";
-
 
3225
 
-
 
3226
			#設置錯誤訊息
-
 
3227
			$result["error"]=$checkResult;
-
 
3228
 
-
 
3229
			#回傳結果
-
 
3230
			return $result;
-
 
3231
 
-
 
3232
			}#if end
-
 
3233
	
-
 
3234
		#初始化沒有找到要移除的關鍵字
-
 
3235
		$result["founded"]="false";
-
 
3236
	
-
 
3237
		#初始化被移除的內容
-
 
3238
		$result["deleted"]="";
-
 
3239
	
-
 
3240
		#另存要處理的字串
-
 
3241
		$str2process=$conf["stringIn"];
-
 
3242
	
-
 
3243
		#無窮迴圈
-
 
3244
		while(true){
-
 
3245
		
-
 
3246
			#預設執行完關鍵字處理一輪後就結束
-
 
3247
			$continue="false";
-
 
3248
		
-
 
3249
			#針對每個要移除的開頭字串
-
 
3250
			foreach($conf["headStr"] as $index => $keyWord){
-
 
3251
			
-
 
3252
				#函式說明:
-
 
3253
				#尋找字串中是否含有符合格式的內容,且回傳解析好的變數數值.
-
 
3254
				#回傳結果:
-
 
3255
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
3256
				#$reuslt["error"],執行不正常結束的錯訊息陣列.
-
 
3257
				#$result["function"],當前執行的函式名稱.
-
 
3258
				#$result["argu"],所使用的參數.
-
 
3259
				#$result["found"],是否有找到符合格式的字串內容,"true"代表有找到,"false"代表沒有找到.
-
 
3260
				#$result["content"],陣列,若為n個${*},則當found為"true"時,就會回傳n個元素.
-
 
3261
				#$result["parsedVar"][varName],陣列,解析好的變數陣列,varName為${}中的內容,變數的key從0開始.
-
 
3262
				#必填參數:
-
 
3263
				#$conf["input"],字串,要檢查的字串.
-
 
3264
				$conf["search::findSpecifyStrFormat"]["input"]=$str2process;
-
 
3265
				#$conf["format"],格式字串,要尋找的格式字串.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
-
 
3266
				$conf["search::findSpecifyStrFormat"]["format"]=$keyWord."\${left}";
-
 
3267
				#可省略參數:
-
 
3268
				#$conf["varEqual"],陣列,變數對應的數值,null代表不指定,其他內容代表該變數解析出來必須要為該內容.
-
 
3269
				#$conf["varEqual"]=array(null,"found");
-
 
3270
				#$conf["varCon"],陣列,每個varEqual為null者,其是否有其他條件,預設為null代表無其他條件,條件的表示是用陣列的key與value來表達,例如:array("no_tail"=>" not"),就代表變數的結尾不能為" not",可以用的key有"head",代表開頭要有什麼;"no_head",代表不能為什麼開頭;"tail",代表要什麼結尾;"no_tail",代表不能什麼結尾.
-
 
3271
				#$conf["varCon"]=array("no_tail"=>" not");
-
 
3272
				#參考資料:
-
 
3273
				#無.
-
 
3274
				#備註:
-
 
3275
				#無.
-
 
3276
				$findSpecifyStrFormat=search::findSpecifyStrFormat($conf["search::findSpecifyStrFormat"]);
-
 
3277
				unset($conf["search::findSpecifyStrFormat"]);
-
 
3278
			
-
 
3279
				#如果執行異常
-
 
3280
				if($findSpecifyStrFormat["status"]==="false"){
-
 
3281
 
-
 
3282
					#設置錯誤識別
-
 
3283
					$result["status"]="false";
-
 
3284
 
-
 
3285
					#設置錯誤訊息
-
 
3286
					$result["error"]=$findSpecifyStrFormat;
-
 
3287
 
-
 
3288
					#回傳結果
-
 
3289
					return $result;
-
 
3290
 
-
 
3291
					}#if end
-
 
3292
					
-
 
3293
				#如果有找到要移除的關鍵字
-
 
3294
				if($findSpecifyStrFormat["found"]==="true"){
-
 
3295
 
-
 
3296
					#串接移除的字串內容 
-
 
3297
					$result["deleted"]=$result["deleted"].$keyWord;
-
 
3298
 
-
 
3299
					#儲存處理好的結果
-
 
3300
					$str2process=$findSpecifyStrFormat["parsedVar"]["left"][0];
-
 
3301
 
-
 
3302
					#設置要繼續執行
-
 
3303
					$continue="true";
-
 
3304
 
-
 
3305
					}#if end
-
 
3306
			
-
 
3307
				}#foreach end
-
 
3308
				
-
 
3309
			#如果沒有必須繼續處理開頭關鍵字了
-
 
3310
			if($continue==="false"){
-
 
3311
			
-
 
3312
				#跳出 while
-
 
3313
				break;
-
 
3314
			
-
 
3315
				}#if end
-
 
3316
			
-
 
3317
			#反之若尚未設置有找到要移除的關鍵字
-
 
3318
			else if($result["founded"]==="false"){
-
 
3319
			
-
 
3320
				#設置有找到要移除的關鍵字
-
 
3321
				$result["founded"]="true";
-
 
3322
			
-
 
3323
				}#else end
-
 
3324
		
-
 
3325
			}#while end
-
 
3326
	
-
 
3327
		#儲存處理好的字串
-
 
3328
		$result["content"]=$str2process;
-
 
3329
	
-
 
3330
		#設置執行正常
-
 
3331
		$result["status"]="true";
-
 
3332
		
-
 
3333
		#回傳結果
-
 
3334
		return $result;
-
 
3335
	
-
 
3336
		}#function delHeadStr end
-
 
3337
 
-
 
3338
	/*
-
 
3339
	#函式說明:
3075
	#將字串特定關鍵字與其後面的內容剔除
3340
	#將字串特定關鍵字與其後面的內容剔除
3076
	#回傳結果:
3341
	#回傳結果:
3077
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3342
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3078
	#$result["error"],錯誤訊息陣列.
3343
	#$result["error"],錯誤訊息陣列.
3079
	#$result["warning"],警告訊息鎮列.
3344
	#$result["warning"],警告訊息鎮列.
Line 4080... Line 4345...
4080
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
4345
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
4081
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4346
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4082
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
4347
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
4083
		#可以省略的參數:
4348
		#可以省略的參數:
4084
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
4349
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
4085
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
4350
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
4086
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
4351
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
4087
		#$conf["canNotBeEmpty"]=array();
4352
		#$conf["canNotBeEmpty"]=array();
4088
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
4353
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
4089
		#$conf["canBeEmpty"]=array();
4354
		#$conf["canBeEmpty"]=array();
4090
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
4355
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
Line 4134... Line 4399...
4134
			#回傳結果
4399
			#回傳結果
4135
			return $result;
4400
			return $result;
4136
 
4401
 
4137
			}#if end
4402
			}#if end
4138
 
4403
 
-
 
4404
		#如果輸入為空
-
 
4405
		if(empty($conf["input"])){
-
 
4406
		
-
 
4407
			#設置沒有參數
-
 
4408
			$result["content"]=array();
-
 
4409
			
-
 
4410
			#設置參數數量
-
 
4411
			$result["count"]=count($result["content"]);
-
 
4412
		
-
 
4413
			#設置執行正常
-
 
4414
			$result["status"]="true";
-
 
4415
			
-
 
4416
			#回傳結果
-
 
4417
			return $result;
-
 
4418
		
-
 
4419
			}#if end
-
 
4420
 
4139
		#預設存放 qbpwcf 可執行程式 parse 的位置
4421
		#預設存放 qbpwcf 可執行程式 parse 的位置
4140
		$defaultQbpwcfUsrBinParse="/usr/bin/parse";
4422
		$defaultQbpwcfUsrBinParse="/usr/bin/parse";
4141
 
4423
 
4142
		#預設存放 qbpwcf local 可執行程式 parse 的位置
4424
		#預設存放 qbpwcf local 可執行程式 parse 的位置
4143
		$defaultLocalQbpwcfUsrBinParse=pathinfo(__FILE__)["dirname"]."/../../bin/parse";
4425
		$defaultLocalQbpwcfUsrBinParse=pathinfo(__FILE__)["dirname"]."/../../bin/parse";
Line 4444... Line 4726...
4444
 
4726
 
4445
		#移除暫存檔案
4727
		#移除暫存檔案
4446
		unlink($scriptFile2test);
4728
		unlink($scriptFile2test);
4447
 
4729
 
4448
		#預設要運行的指令
4730
		#預設要運行的指令
4449
		$cmd=$defaultQbpwcfUsrBinParse.' '.$conf["input"];
4731
		#$cmd=$defaultQbpwcfUsrBinParse.' '.$conf["input"];
4450
 
4732
		
-
 
4733
		#函式說明:
-
 
4734
		#呼叫shell執行系統命令,並取得回傳的內容.
-
 
4735
		#回傳結果:
-
 
4736
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
-
 
4737
		#$result["error"],錯誤訊息陣列.
-
 
4738
		#$result["function"],當前執行的函數名稱.
-
 
4739
		#$result["argu"],使用的參數.
4451
		#執行印出參數的php程式
4740
		#$result["cmd"],執行的指令內容.
-
 
4741
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
4742
		#$result["output"],爲執行完後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
-
 
4743
		#$result["content"],為執行完後的輸出字串.
-
 
4744
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
-
 
4745
		#$result["running"],是否還在執行.
4452
		exec($cmd,$output,$status);
4746
		#$result["pid"],pid.
-
 
4747
		#$result["statusCode"],執行結束後的代碼.
-
 
4748
		#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
-
 
4749
		#$result["noEcaped"],陣列,儲存重新排序過未經過escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
4453
 
4750
		#必填參數:
-
 
4751
		#$conf["command"],字串,要執行的指令.
-
 
4752
		$conf["external::callShell"]["command"]=$defaultQbpwcfUsrBinParse;
-
 
4753
		#$conf["fileArgu"],字串,變數__FILE__的內容.
-
 
4754
		$conf["external::callShell"]["fileArgu"]=__FILE__;
4454
		#如果運行正常
4755
		#可省略參數:
-
 
4756
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
-
 
4757
		$conf["external::callShell"]["argu"]=array($conf["input"]);
-
 
4758
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
-
 
4759
		#$conf["arguIsAddr"]=array();
-
 
4760
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
-
 
4761
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
-
 
4762
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
-
 
4763
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
-
 
4764
		#$conf["enablePrintDescription"]="true";
-
 
4765
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
-
 
4766
		#$conf["printDescription"]="";
-
 
4767
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
-
 
4768
		#$conf["external::callShell"]["escapeshellarg"]="true";
-
 
4769
		#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
-
 
4770
		#$conf["thereIsShellVar"]=array();
-
 
4771
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
4455
		if($status===0){
4772
		#$conf["username"]="";
4456
 
-
 
-
 
4773
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
4457
			#設置執行正常
4774
		#$conf["password"]="";
-
 
4775
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
-
 
4776
		#$conf["useScript"]="";
-
 
4777
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
-
 
4778
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
-
 
4779
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
-
 
4780
		#$conf["inBackGround"]="";
-
 
4781
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
-
 
4782
		#$conf["getErr"]="false";
-
 
4783
		#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
4458
			$result["status"]="true";
4784
		#$conf["doNotRun"]="false";
4459
 
-
 
4460
			#如果輸出不是 json
4785
		#參考資料:
-
 
4786
		#exec=>http://php.net/manual/en/function.exec.php
-
 
4787
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
-
 
4788
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
-
 
4789
		#備註:
-
 
4790
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
-
 
4791
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
-
 
4792
		$callShell=external::callShell($conf["external::callShell"]);
4461
			if(json_validate($output[0])===false){
4793
		unset($conf["external::callShell"]);
4462
 
4794
 
4463
				#設置執行失敗
4795
		#如果執行異常
4464
				$result["status"]="false";
4796
		if($callShell["status"]==="false"){
4465
 
4797
		
4466
				#設置執行錯誤訊息
4798
			#設置執行失敗
4467
				$result["error"][]="not json output";
4799
			$result["status"]="false";
4468
 
4800
 
4469
				#設置執行錯誤訊息
4801
			#設置執行錯誤訊息
4470
				$result["error"][]=$output;
4802
			$result["error"]=$callShell;
4471
 
4803
 
4472
				#回傳結果
4804
			#回傳結果
4473
				return $result;
4805
			return $result;
-
 
4806
			
-
 
4807
			}#if end
4474
 
4808
 
4475
				}#if end
4809
		#設置執行正常
-
 
4810
		$result["status"]="true";
4476
 
4811
 
4477
			#解析json,並轉成array
4812
		#如果輸出不是 json
4478
			$output=(array)json_decode($output[0]);
4813
		if(json_validate($callShell["content"])===false){
4479
 
4814
 
4480
			#移除被執行的php檔案名稱
4815
			#設置執行失敗
4481
			unset($output[0]);
4816
			$result["status"]="false";
4482
 
4817
 
4483
			#初始化參數陣列
4818
			#設置執行錯誤訊息
4484
			$params=array();
4819
			$result["error"][]="not json output";
4485
 
4820
 
4486
			#針對每個參數
4821
			#設置執行錯誤訊息
4487
			foreach($output as $param){
4822
			$result["error"][]=$callShell["content"];
4488
 
4823
 
4489
				#取得參數
4824
			#回傳結果
4490
				$params[]=$param;
4825
			return $result;
4491
 
4826
 
4492
				}#foreach end
4827
			}#if end
4493
 
4828
 
4494
			#取得參數陣列
4829
		#解析json,並轉成array
4495
			$result["content"]=$params;
4830
		$output=(array)json_decode($callShell["content"]);
4496
 
4831
 
4497
			#取得參數數目
4832
		#移除被執行的php檔案名稱
4498
			$result["count"]=count($params);
4833
		unset($output[0]);
4499
 
4834
 
4500
			#回傳結果
4835
		#初始化參數陣列
4501
			return $result;
4836
		$params=array();
4502
 
4837
 
4503
			}#if end
4838
		#針對每個參數
-
 
4839
		foreach($output as $param){
4504
 
4840
 
4505
		#反之運行不正常
-
 
4506
		else{
-
 
4507
			#設置執行正常
4841
			#取得參數
4508
			$result["status"]="false";
4842
			$params[]=$param;
4509
 
4843
 
4510
			#設置錯誤訊息
4844
			}#foreach end
4511
			$result["error"][]="解析字串出錯";
-
 
4512
 
4845
 
4513
			#設置 escaped 過後的 input 資訊到錯誤訊息陣列裡面
4846
		#取得參數陣列
4514
			$result["error"][]="escaped input:".escapeshellarg($conf["input"]);
4847
		$result["content"]=$params;
4515
 
4848
 
4516
			#回傳結果
4849
		#取得參數數目
4517
			return $result;
4850
		$result["count"]=count($params);
4518
 
4851
 
4519
			}#else end
4852
		#回傳結果
-
 
4853
		return $result;
4520
 
4854
 
4521
		}#function parse end
4855
		}#function parse end
4522
 
4856
 
4523
	/*
4857
	/*
4524
	#函式說明:
4858
	#函式說明: