Subversion Repositories php-qbpwcf

Rev

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

Rev 220 Rev 226
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2014~2025 Min-Jhin,Chen
6
    Copyright (C) 2014~2025 MIN ZHI, CHEN
7
 
7
 
8
    This file is part of QBPWCF.
8
    This file is part of QBPWCF.
9
 
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
10
    QBPWCF is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
11
    it under the terms of the GNU General Public License as published by
Line 43... Line 43...
43
	#$arguments,陣列,為呼叫方法時所用的參數.
43
	#$arguments,陣列,為呼叫方法時所用的參數.
44
	#參考資料:
44
	#參考資料:
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
46
	*/
46
	*/
47
	public function __call($method,$arguments){
47
	public function __call($method,$arguments){
48
		
48
 
49
		#取得當前執行的函式
49
		#取得當前執行的函式
50
		$result["function"]=__FUNCTION__;
50
		$result["function"]=__FUNCTION__;
51
		
51
 
52
		#設置執行不正常
52
		#設置執行不正常
53
		$result["status"]="false";
53
		$result["status"]="false";
54
		
54
 
55
		#設置執行錯誤
55
		#設置執行錯誤
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
57
		
57
 
58
		#設置所丟入的參數
58
		#設置所丟入的參數
59
		$result["error"][]=$arguments;
59
		$result["error"][]=$arguments;
60
		
60
 
61
		#回傳結果
61
		#回傳結果
62
		return $result;
62
		return $result;
63
		
63
 
64
		}#function __call end
64
		}#function __call end
65
		
65
 
66
	/*
66
	/*
67
	#函式說明:
67
	#函式說明:
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
69
	#回傳結果:
69
	#回傳結果:
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 75... Line 75...
75
	#$arguments,陣列,為呼叫方法時所用的參數.
75
	#$arguments,陣列,為呼叫方法時所用的參數.
76
	#參考資料:
76
	#參考資料:
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
78
	*/
78
	*/
79
	public static function __callStatic($method,$arguments){
79
	public static function __callStatic($method,$arguments){
80
		
80
 
81
		#取得當前執行的函式
81
		#取得當前執行的函式
82
		$result["function"]=__FUNCTION__;
82
		$result["function"]=__FUNCTION__;
83
		
83
 
84
		#設置執行不正常
84
		#設置執行不正常
85
		$result["status"]="false";
85
		$result["status"]="false";
86
		
86
 
87
		#設置執行錯誤
87
		#設置執行錯誤
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
89
		
89
 
90
		#設置所丟入的參數
90
		#設置所丟入的參數
91
		$result["error"][]=$arguments;
91
		$result["error"][]=$arguments;
92
		
92
 
93
		#回傳結果
93
		#回傳結果
94
		return $result;
94
		return $result;
95
		
95
 
96
		}#function __callStatic end
96
		}#function __callStatic end
97
 
97
 
98
	/*
98
	/*
99
	#函式說明:
99
	#函式說明:
100
	#將字串寫入到檔案
100
	#將字串寫入到檔案
Line 138... Line 138...
138
		#初始化當前執行的函數名稱
138
		#初始化當前執行的函數名稱
139
		$result["function"]=__FUNCTION__;
139
		$result["function"]=__FUNCTION__;
140
 
140
 
141
		#如果 $conf 不為陣列
141
		#如果 $conf 不為陣列
142
		if(gettype($conf)!="array"){
142
		if(gettype($conf)!="array"){
143
			
143
 
144
			#設置執行失敗
144
			#設置執行失敗
145
			$result["status"]="false";
145
			$result["status"]="false";
146
			
146
 
147
			#設置執行錯誤訊息
147
			#設置執行錯誤訊息
148
			$result["error"][]="\$conf變數須為陣列形態";
148
			$result["error"][]="\$conf變數須為陣列形態";
149
 
149
 
150
			#如果傳入的參數為 null
150
			#如果傳入的參數為 null
151
			if($conf==null){
151
			if($conf==null){
152
				
152
 
153
				#設置執行錯誤訊息
153
				#設置執行錯誤訊息
154
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
154
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
155
				
155
 
156
				}#if end
156
				}#if end
157
 
157
 
158
			#回傳結果
158
			#回傳結果
159
			return $result;
159
			return $result;
160
			
160
 
161
			}#if end
161
			}#if end
162
	
162
 
163
		#取得使用的參數
163
		#取得使用的參數
164
		$result["argu"]=$conf;
164
		$result["argu"]=$conf;
165
 
165
 
166
		#檢查參數
166
		#檢查參數
167
		#函式說明:
167
		#函式說明:
Line 179... Line 179...
179
		#必填寫的參數:
179
		#必填寫的參數:
180
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
180
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
181
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
181
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
182
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
182
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
183
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
183
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
184
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
184
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
185
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
185
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
186
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
186
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
187
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
187
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
188
		#可以省略的參數:
188
		#可以省略的參數:
189
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
189
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
190
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
190
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
191
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
191
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
192
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileName","inputString","writeMethod","checkRepeat","filenameExtensionStartPoint","repeatNameRule","web");
192
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileName","inputString","writeMethod","checkRepeat","filenameExtensionStartPoint","repeatNameRule","web");
193
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
193
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
194
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string");
194
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string");
195
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
195
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
196
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"","w","false",null,null,"true");
196
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"","w","false",null,null,"true");
197
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
197
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
198
		#$conf["arrayCountEqualCheck"][]=array();
198
		#$conf["arrayCountEqualCheck"][]=array();
Line 201... Line 201...
201
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
201
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
202
		unset($conf["variableCheck::checkArguments"]);
202
		unset($conf["variableCheck::checkArguments"]);
203
 
203
 
204
		#如果 $checkArguments["status"] 等於 "false"
204
		#如果 $checkArguments["status"] 等於 "false"
205
		if($checkArguments["status"]=="false"){
205
		if($checkArguments["status"]=="false"){
206
			
206
 
207
			#設置錯誤識別
207
			#設置錯誤識別
208
			$result["status"]="false";
208
			$result["status"]="false";
209
			
209
 
210
			#設置錯誤訊息
210
			#設置錯誤訊息
211
			$result["error"]=$checkArguments;
211
			$result["error"]=$checkArguments;
212
			
212
 
213
			#回傳結果
213
			#回傳結果
214
			return $result;
214
			return $result;
215
			
215
 
216
			}#if end
216
			}#if end
217
			
217
 
218
		#如果 $checkArguments["passed"] 等於 "false"
218
		#如果 $checkArguments["passed"] 等於 "false"
219
		if($checkArguments["passed"]=="false"){
219
		if($checkArguments["passed"]=="false"){
220
			
220
 
221
			#設置錯誤識別
221
			#設置錯誤識別
222
			$result["status"]="false";
222
			$result["status"]="false";
223
			
223
 
224
			#設置錯誤訊息
224
			#設置錯誤訊息
225
			$result["error"]=$checkArguments;
225
			$result["error"]=$checkArguments;
226
			
226
 
227
			#回傳結果
227
			#回傳結果
228
			return $result;
228
			return $result;
229
			
229
 
230
			}#if end
230
			}#if end
231
 
231
 
232
		#如果沒有設置 $conf["fileName"]
232
		#如果沒有設置 $conf["fileName"]
233
		if(!isset($conf["fileName"])){
233
		if(!isset($conf["fileName"])){
234
			
234
 
235
			#設定要檢查是否有重複的檔案名稱
235
			#設定要檢查是否有重複的檔案名稱
236
			$conf["checkRepeat"]="true";
236
			$conf["checkRepeat"]="true";
237
			
237
 
238
			#亂數產生檔案名稱
238
			#亂數產生檔案名稱
239
			#函式說明:
239
			#函式說明:
240
			#建立以圖片(PNG格式)呈現的驗證碼.
240
			#建立以圖片(PNG格式)呈現的驗證碼.
241
			#回傳的解果:
241
			#回傳的解果:
242
			#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
242
			#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
Line 256... Line 256...
256
			$conf["authenticate::validationCode"]["disableImg"]="true";
256
			$conf["authenticate::validationCode"]["disableImg"]="true";
257
			#$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
257
			#$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
258
			#$conf["imgToData"]="true";
258
			#$conf["imgToData"]="true";
259
			$validationCode=authenticate::validationCode($conf["authenticate::validationCode"]);
259
			$validationCode=authenticate::validationCode($conf["authenticate::validationCode"]);
260
			unset($conf["authenticate::validationCode"]);
260
			unset($conf["authenticate::validationCode"]);
261
			
261
 
262
			#如果亂數產生錯誤
262
			#如果亂數產生錯誤
263
			if($validationCode["status"]=="false"){
263
			if($validationCode["status"]=="false"){
264
				
264
 
265
				#設置錯誤識別
265
				#設置錯誤識別
266
				$result["status"]="false";
266
				$result["status"]="false";
267
				
267
 
268
				#設置錯誤訊息
268
				#設置錯誤訊息
269
				$result["error"]=$validationCode;
269
				$result["error"]=$validationCode;
270
				
270
 
271
				#回傳結果
271
				#回傳結果
272
				return $result;	
272
				return $result;
273
				
273
 
274
				}#if end
274
				}#if end
275
			
275
 
276
			#取得產生的檔案名稱
276
			#取得產生的檔案名稱
277
			$conf["fileName"]=$validationCode["randNumberWord"];
277
			$conf["fileName"]=$validationCode["randNumberWord"];
278
			
278
 
279
			}#if end
279
			}#if end
280
 
280
 
281
		#剃除 $conf["fileName"] 開頭的 "./"
281
		#剃除 $conf["fileName"] 開頭的 "./"
282
		#函式說明:
282
		#函式說明:
283
		#移除字串開頭的特定內容
283
		#移除字串開頭的特定內容
Line 288... Line 288...
288
		#$result["content"],處理好的字串.
288
		#$result["content"],處理好的字串.
289
		#必填參數:
289
		#必填參數:
290
		#$conf["inputStr"],字串,要檢查並移除開頭有 $conf["keyWords"] 的字串.
290
		#$conf["inputStr"],字串,要檢查並移除開頭有 $conf["keyWords"] 的字串.
291
		$conf["stringProcess::delKeyWordsInStrHead"]["inputStr"]=$conf["fileName"];
291
		$conf["stringProcess::delKeyWordsInStrHead"]["inputStr"]=$conf["fileName"];
292
		#$conf["keyWord"],字串,要移除的字串開頭關鍵字.
292
		#$conf["keyWord"],字串,要移除的字串開頭關鍵字.
293
		$conf["stringProcess::delKeyWordsInStrHead"]["keyWord"]="./"; 
293
		$conf["stringProcess::delKeyWordsInStrHead"]["keyWord"]="./";
294
		#可省略參數:
294
		#可省略參數:
295
		#無.
295
		#無.
296
		$delKeyWordsInStrHead=stringProcess::delKeyWordsInStrHead($conf["stringProcess::delKeyWordsInStrHead"]);
296
		$delKeyWordsInStrHead=stringProcess::delKeyWordsInStrHead($conf["stringProcess::delKeyWordsInStrHead"]);
297
		unset($conf["stringProcess::delKeyWordsInStrHead"]);
297
		unset($conf["stringProcess::delKeyWordsInStrHead"]);
298
 
298
 
299
		#如果處理失敗
299
		#如果處理失敗
300
		if($delKeyWordsInStrHead["status"]=="false"){
300
		if($delKeyWordsInStrHead["status"]=="false"){
301
			
301
 
302
			#設置錯誤識別
302
			#設置錯誤識別
303
			$result["status"]="false";
303
			$result["status"]="false";
304
			
304
 
305
			#設置錯誤訊息
305
			#設置錯誤訊息
306
			$result["error"]=$delKeyWordsInStrHead;
306
			$result["error"]=$delKeyWordsInStrHead;
307
			
307
 
308
			#回傳結果
308
			#回傳結果
309
			return $result;	
309
			return $result;
310
			
310
 
311
			}#if end
311
			}#if end
312
			
312
 
313
		#取得處理好的檔案名稱
313
		#取得處理好的檔案名稱
314
		$conf["fileName"]=$delKeyWordsInStrHead["content"];
314
		$conf["fileName"]=$delKeyWordsInStrHead["content"];
315
 
315
 
316
		#函式說明:
316
		#函式說明:
317
		#確保路徑存在.
317
		#確保路徑存在.
Line 330... Line 330...
330
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
330
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
331
		#$conf["dirPermission"]="";
331
		#$conf["dirPermission"]="";
332
		$conf["fileAccess::validatePath"]["web"]=$conf["web"];
332
		$conf["fileAccess::validatePath"]["web"]=$conf["web"];
333
		$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
333
		$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
334
		unset($conf["fileAccess::validatePath"]);
334
		unset($conf["fileAccess::validatePath"]);
335
		
335
 
336
		#debug
336
		#debug
337
		#var_dump($validatePath);exit;
337
		#var_dump($validatePath);exit;
338
		
338
 
339
		#如果確保路徑失敗
339
		#如果確保路徑失敗
340
		if($validatePath["status"]=="false"){
340
		if($validatePath["status"]=="false"){
341
			
341
 
342
			#設置錯誤識別
342
			#設置錯誤識別
343
			$result["status"]="false";
343
			$result["status"]="false";
344
			
344
 
345
			#設置錯誤訊息
345
			#設置錯誤訊息
346
			$result["error"]=$validatePath;
346
			$result["error"]=$validatePath;
347
			
347
 
348
			#回傳結果
348
			#回傳結果
349
			return $result;	
349
			return $result;
350
			
350
 
351
			}#if end
351
			}#if end
352
		
352
 
353
		#如果要檢查是否有同名的檔案
353
		#如果要檢查是否有同名的檔案
354
		if($conf["checkRepeat"]=="true"){
354
		if($conf["checkRepeat"]=="true"){
355
		 
355
 
356
			#函式說明:
356
			#函式說明:
357
			#檢查要建立的檔案路徑是否存在,若不存在則建立新檔案,若檔案已存在則會在原檔名後面加上從(1)開始的編號,再度嘗試建立檔案,以避免資料異常.
357
			#檢查要建立的檔案路徑是否存在,若不存在則建立新檔案,若檔案已存在則會在原檔名後面加上從(1)開始的編號,再度嘗試建立檔案,以避免資料異常.
358
			#回傳的結果:
358
			#回傳的結果:
359
			#$result["status"],執行狀態,"true"代表執行正常,"false"代表執行失敗.
359
			#$result["status"],執行狀態,"true"代表執行正常,"false"代表執行失敗.
360
			#$result["error"],錯誤訊息陣列.
360
			#$result["error"],錯誤訊息陣列.
Line 366... Line 366...
366
			#$conf["checkedFileAndPath"],字串陣列,要建立的檔案路徑
366
			#$conf["checkedFileAndPath"],字串陣列,要建立的檔案路徑
367
			$conf["fileAccess::createFileAfterCheck"]["checkedFileAndPath"]=$conf["fileName"];
367
			$conf["fileAccess::createFileAfterCheck"]["checkedFileAndPath"]=$conf["fileName"];
368
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
368
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
369
			$conf["fileAccess::createFileAfterCheck"]["fileArgu"]=$conf["fileArgu"];
369
			$conf["fileAccess::createFileAfterCheck"]["fileArgu"]=$conf["fileArgu"];
370
			#可省略參數:
370
			#可省略參數:
371
			
371
 
372
			#如果有設定 $conf["filenameExtensionStartPoint"]
372
			#如果有設定 $conf["filenameExtensionStartPoint"]
373
			if(isset($conf["filenameExtensionStartPoint"])){
373
			if(isset($conf["filenameExtensionStartPoint"])){
374
				
374
 
375
				#$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點.
375
				#$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點.
376
				$conf["fileAccess::createFileAfterCheck"]["filenameExtensionStartPoint"]=$conf["filenameExtensionStartPoint"];
376
				$conf["fileAccess::createFileAfterCheck"]["filenameExtensionStartPoint"]=$conf["filenameExtensionStartPoint"];
377
				
377
 
378
				}#if end
378
				}#if end
379
			
379
 
380
			#如果有設定 $conf["repeatNameRule"]
380
			#如果有設定 $conf["repeatNameRule"]
381
			if(isset($conf["repeatNameRule"])){
381
			if(isset($conf["repeatNameRule"])){
382
				
382
 
383
				#$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)".
383
				#$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)".
384
				$conf["fileAccess::createFileAfterCheck"]["repeatNameRule"]=$conf["repeatNameRule"];
384
				$conf["fileAccess::createFileAfterCheck"]["repeatNameRule"]=$conf["repeatNameRule"];
385
				
385
 
386
				}#if end
386
				}#if end
387
			
387
 
388
			#如果有設定 $conf["web"] 參數
388
			#如果有設定 $conf["web"] 參數
389
			if(isset($conf["web"])){
389
			if(isset($conf["web"])){
390
				
390
 
391
				$conf["fileAccess::createFileAfterCheck"]["web"]=$conf["web"];
391
				$conf["fileAccess::createFileAfterCheck"]["web"]=$conf["web"];
392
				
392
 
393
				}#if end
393
				}#if end
394
			
394
 
395
			$createFileAfterCheck=fileAccess::createFileAfterCheck($conf["fileAccess::createFileAfterCheck"]);
395
			$createFileAfterCheck=fileAccess::createFileAfterCheck($conf["fileAccess::createFileAfterCheck"]);
396
			unset($conf["fileAccess::createFileAfterCheck"]);
396
			unset($conf["fileAccess::createFileAfterCheck"]);
397
			
397
 
398
			#debug
398
			#debug
399
			#var_dump($createFileAfterCheck);
399
			#var_dump($createFileAfterCheck);
400
			#exit;
400
			#exit;
401
			
401
 
402
			#如果嘗試建立檔案失敗
402
			#如果嘗試建立檔案失敗
403
			if($createFileAfterCheck["status"]=="false"){
403
			if($createFileAfterCheck["status"]=="false"){
404
				
404
 
405
				#設置執行不正常
405
				#設置執行不正常
406
				$result["status"]="false";
406
				$result["status"]="false";
407
				
407
 
408
				#設置錯誤訊息
408
				#設置錯誤訊息
409
				$result["error"]=$createFileAfterCheck;
409
				$result["error"]=$createFileAfterCheck;
410
				
410
 
411
				#回傳結果
411
				#回傳結果
412
				return $result;
412
				return $result;
413
				
413
 
414
				}#if end
414
				}#if end
415
				
415
 
416
			#取得建立的檔案資訊
416
			#取得建立的檔案資訊
417
			$result["fileInfo"]["createdFilePathAndName"]=$createFileAfterCheck["createdFilePathAndName"];
417
			$result["fileInfo"]["createdFilePathAndName"]=$createFileAfterCheck["createdFilePathAndName"];
418
			$result["fileInfo"]["createdFilePath"]=$createFileAfterCheck["createdFilePath"];
418
			$result["fileInfo"]["createdFilePath"]=$createFileAfterCheck["createdFilePath"];
419
			$result["fileInfo"]["createdFileName"]=$createFileAfterCheck["createdFileName"];	
419
			$result["fileInfo"]["createdFileName"]=$createFileAfterCheck["createdFileName"];
420
			
420
 
421
			#取得建立好的檔案路徑與名稱
421
			#取得建立好的檔案路徑與名稱
422
			$conf["fileName"]=$createFileAfterCheck["createdFilePathAndName"];
422
			$conf["fileName"]=$createFileAfterCheck["createdFilePathAndName"];
423
			
423
 
424
			}#if end
424
			}#if end
425
 
425
 
426
		#反之沒有要檢查檔案是否存在
426
		#反之沒有要檢查檔案是否存在
427
		else{
427
		else{
428
			
428
 
429
			#取得建立的檔案資訊
429
			#取得建立的檔案資訊
430
			$result["fileInfo"]["createdFilePathAndName"]=$conf["fileName"];
430
			$result["fileInfo"]["createdFilePathAndName"]=$conf["fileName"];
431
			$result["fileInfo"]["createdFilePath"]=$validatePath["path"];
431
			$result["fileInfo"]["createdFilePath"]=$validatePath["path"];
432
			$result["fileInfo"]["createdFileName"]=$validatePath["fileName"];
432
			$result["fileInfo"]["createdFileName"]=$validatePath["fileName"];
433
			
433
 
434
			}#else end
434
			}#else end
435
 
435
 
436
		#設定要寫入或複寫的檔案
436
		#設定要寫入或複寫的檔案
437
		$fileopenResult=fopen($conf["fileName"],$conf["writeMethod"]);
437
		$fileopenResult=fopen($conf["fileName"],$conf["writeMethod"]);
438
	
438
 
439
		#如果 $fileopenResult 等於 FALSE
439
		#如果 $fileopenResult 等於 FALSE
440
		if($fileopenResult==FALSE){
440
		if($fileopenResult==FALSE){
441
			
441
 
442
			#設置錯誤識別
442
			#設置錯誤識別
443
			$result["status"]="false";
443
			$result["status"]="false";
444
			
444
 
445
			#代表打開檔案失敗
445
			#代表打開檔案失敗
446
			$result["error"][]="檔案".$conf["fileName"]."開啟失敗";
446
			$result["error"][]="檔案".$conf["fileName"]."開啟失敗";
447
			
447
 
448
			#回傳結果
448
			#回傳結果
449
			return $result;
449
			return $result;
450
			
450
 
451
			}#if end
451
			}#if end
452
	
452
 
453
		#將資料寫入到檔案裡面
453
		#將資料寫入到檔案裡面
454
		$fwriteResult=fwrite($fileopenResult,$conf["inputString"]);
454
		$fwriteResult=fwrite($fileopenResult,$conf["inputString"]);
455
 
455
 
456
		#如果 $fwriteResult 等於 FALSE
456
		#如果 $fwriteResult 等於 FALSE
457
		if($fwriteResult!=0 && $fwriteResult==FALSE){
457
		if($fwriteResult!=0 && $fwriteResult==FALSE){
458
			
458
 
459
			#設置錯誤識別
459
			#設置錯誤識別
460
			$result["status"]="false";
460
			$result["status"]="false";
461
			
461
 
462
			#代表檔案寫入失敗
462
			#代表檔案寫入失敗
463
			$result["error"][]="檔案".$conf["fileName"]."寫入失敗";
463
			$result["error"][]="檔案".$conf["fileName"]."寫入失敗";
464
			
464
 
465
			#回傳結果
465
			#回傳結果
466
			return $result;
466
			return $result;
467
			
467
 
468
			}#if end
468
			}#if end
469
 
469
 
470
		#存檔並關閉檔案
470
		#存檔並關閉檔案
471
		$fcloseResult=fclose($fileopenResult);
471
		$fcloseResult=fclose($fileopenResult);
472
 
472
 
473
		#如果 $fcloseResult 等於 FALSE
473
		#如果 $fcloseResult 等於 FALSE
474
		if($fcloseResult==FALSE){
474
		if($fcloseResult==FALSE){
475
			
475
 
476
			#設置錯誤識別
476
			#設置錯誤識別
477
			$result["status"]="false";
477
			$result["status"]="false";
478
			
478
 
479
			#代表檔案寫入失敗
479
			#代表檔案寫入失敗
480
			$result["error"][]="檔案".$conf["fileName"]."儲存失敗";
480
			$result["error"][]="檔案".$conf["fileName"]."儲存失敗";
481
			
481
 
482
			#回傳結果
482
			#回傳結果
483
			return $result;
483
			return $result;
484
			
484
 
485
			}#if end
485
			}#if end
486
 
486
 
487
		#檢查用來寫入的檔案是否存在
487
		#檢查用來寫入的檔案是否存在
488
		#函式說明:檢查多個檔案與資料夾是否存在
488
		#函式說明:檢查多個檔案與資料夾是否存在
489
		#回傳的結果:
489
		#回傳的結果:
Line 501... Line 501...
501
		$fileAccess["checkMutiFileExist"]=fileAccess::checkMultiFileExist($conf["fileAccess::checkMutiFileExist"]);
501
		$fileAccess["checkMutiFileExist"]=fileAccess::checkMultiFileExist($conf["fileAccess::checkMutiFileExist"]);
502
		unset($conf["fileAccess::checkMutiFileExist"]);
502
		unset($conf["fileAccess::checkMutiFileExist"]);
503
 
503
 
504
		#如果檢查檔案是否存在失敗
504
		#如果檢查檔案是否存在失敗
505
		if($fileAccess["checkMutiFileExist"]["status"]==="false"){
505
		if($fileAccess["checkMutiFileExist"]["status"]==="false"){
506
			
506
 
507
			#設置錯誤識別
507
			#設置錯誤識別
508
			$result["status"]="false";
508
			$result["status"]="false";
509
			
509
 
510
			#設置錯誤訊息陣列
510
			#設置錯誤訊息陣列
511
			$result["error"]=$fileAccess["checkMutiFileExist"];
511
			$result["error"]=$fileAccess["checkMutiFileExist"];
512
			
512
 
513
			#回傳結果
513
			#回傳結果
514
			return $result;
514
			return $result;
515
			
515
 
516
			}#if end
516
			}#if end
517
 
517
 
518
		#如果$fileAccess["checkMutiFileExist"]["varExist"][0] 等於 "false" 
518
		#如果$fileAccess["checkMutiFileExist"]["varExist"][0] 等於 "false"
519
		if($fileAccess["checkMutiFileExist"]["varExist"][0]==="false"){
519
		if($fileAccess["checkMutiFileExist"]["varExist"][0]==="false"){
520
			
520
 
521
			#設置錯誤識別
521
			#設置錯誤識別
522
			$result["status"]="false";
522
			$result["status"]="false";
523
			
523
 
524
			#設置錯誤訊息
524
			#設置錯誤訊息
525
			$result["error"]=$fileAccess["checkMutiFileExist"];
525
			$result["error"]=$fileAccess["checkMutiFileExist"];
526
			
526
 
527
			#設置錯誤訊息陣列
527
			#設置錯誤訊息陣列
528
			$result["error"][]="愈建立的檔案不存在";
528
			$result["error"][]="愈建立的檔案不存在";
529
			
529
 
530
			#回傳結果
530
			#回傳結果
531
			return $result;
531
			return $result;
532
			
532
 
533
			}#if end
533
			}#if end
534
		
534
 
535
		#函式說明:
535
		#函式說明:
536
		#依據取得檔案的擁有着資訊
536
		#依據取得檔案的擁有着資訊
537
		#回傳結果:
537
		#回傳結果:
538
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
538
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
539
		#$result["error"],錯誤訊息陣列.
539
		#$result["error"],錯誤訊息陣列.
540
		#$result["function"],函數名稱. 
540
		#$result["function"],函數名稱.
541
		#$result["content"],檔案擁有着資訊.
541
		#$result["content"],檔案擁有着資訊.
542
		#$result["content"],檔案資訊陣列.
542
		#$result["content"],檔案資訊陣列.
543
		#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
543
		#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.
544
		#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
544
		#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
545
		#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
545
		#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
546
		#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
546
		#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
547
		#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
547
		#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
548
		#$result["content"]["ownerName"],檔案擁有着資訊.
548
		#$result["content"]["ownerName"],檔案擁有着資訊.
Line 559... Line 559...
559
		$conf["fileAccess::fileInfo"]["file"]=$conf["fileName"];
559
		$conf["fileAccess::fileInfo"]["file"]=$conf["fileName"];
560
		#可省略參數:
560
		#可省略參數:
561
		#$conf["fileToRead"],字串,要讀取的檔案名稱為何?預設為"help".
561
		#$conf["fileToRead"],字串,要讀取的檔案名稱為何?預設為"help".
562
		#$conf["fileToRead"]="help";
562
		#$conf["fileToRead"]="help";
563
		#$conf["output"],字串,輸出的網頁檔案位置與名稱,副檔名html會自動補上,預設為"help".
563
		#$conf["output"],字串,輸出的網頁檔案位置與名稱,副檔名html會自動補上,預設為"help".
564
		#$conf["output"]="help.html"; 
564
		#$conf["output"]="help.html";
565
		#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false".
565
		#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false".
566
		$conf["fileAccess::fileInfo"]["web"]=$conf["web"];
566
		$conf["fileAccess::fileInfo"]["web"]=$conf["web"];
567
		#參考資料:
567
		#參考資料:
568
		#fileowner=>http://php.net/manual/en/function.fileowner.php
568
		#fileowner=>http://php.net/manual/en/function.fileowner.php
569
		#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
569
		#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
570
		$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
570
		$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
571
		unset($conf["fileAccess::fileInfo"]);
571
		unset($conf["fileAccess::fileInfo"]);
572
			
572
 
573
		#如果取得檔案資訊失敗
573
		#如果取得檔案資訊失敗
574
		if($fileInfo["status"]==="false"){
574
		if($fileInfo["status"]==="false"){
575
			
575
 
576
			#設置執行失敗
576
			#設置執行失敗
577
			$result["status"]="false";
577
			$result["status"]="false";
578
			
578
 
579
			#設置錯誤訊息
579
			#設置錯誤訊息
580
			$result["error"]=$fileInfo;
580
			$result["error"]=$fileInfo;
581
			
581
 
582
			#回傳結果
582
			#回傳結果
583
			return $result;
583
			return $result;
584
			
584
 
585
			}#if end
585
			}#if end
586
			
586
 
587
		#取得檔案的擁有者名稱
587
		#取得檔案的擁有者名稱
588
		$fileOwner=$fileInfo["content"]["ownerName"];
588
		$fileOwner=$fileInfo["content"]["ownerName"];
589
			
589
 
590
		#執行php的帳戶
590
		#執行php的帳戶
591
		$runner=csInformation::runner();
591
		$runner=csInformation::runner();
592
			
592
 
593
		#如果執行php的使用者等於檔案的擁有者名稱或為root
593
		#如果執行php的使用者等於檔案的擁有者名稱或為root
594
		if($runner===$fileOwner || $runner==="root"){
594
		if($runner===$fileOwner || $runner==="root"){
595
			
595
 
596
			#改變檔案的權限為0770
596
			#改變檔案的權限為0770
597
			chmod($conf["fileName"],0770);
597
			chmod($conf["fileName"],0770);
598
			
598
 
599
			}#if end
599
			}#if end
600
			
600
 
601
		#執行到這邊代表執行正常
601
		#執行到這邊代表執行正常
602
		$result["status"]="true";
602
		$result["status"]="true";
603
		
603
 
604
		#回傳結果
604
		#回傳結果
605
		return $result;
605
		return $result;
606
			
606
 
607
		}#function writeTextIntoFile end
607
		}#function writeTextIntoFile end
608
 
608
 
609
	/*
609
	/*
610
	#函式說明:
610
	#函式說明:
611
	#一次建立多個檔案,並寫入內容.
611
	#一次建立多個檔案,並寫入內容.
Line 630... Line 630...
630
	#無.
630
	#無.
631
	#備註:
631
	#備註:
632
	#無.
632
	#無.
633
	*/
633
	*/
634
	public static function writeMultiFile(&$conf){
634
	public static function writeMultiFile(&$conf){
635
	
635
 
636
		#初始化要回傳的變數
636
		#初始化要回傳的變數
637
		$result=array();
637
		$result=array();
638
 
638
 
639
		#初始化當前執行的函數名稱
639
		#初始化當前執行的函數名稱
640
		$result["function"]=__FUNCTION__;
640
		$result["function"]=__FUNCTION__;
641
 
641
 
642
		#如果 $conf 不為陣列
642
		#如果 $conf 不為陣列
643
		if(gettype($conf)!="array"){
643
		if(gettype($conf)!="array"){
644
			
644
 
645
			#設置執行失敗
645
			#設置執行失敗
646
			$result["status"]="false";
646
			$result["status"]="false";
647
			
647
 
648
			#設置執行錯誤訊息
648
			#設置執行錯誤訊息
649
			$result["error"][]="\$conf變數須為陣列形態";
649
			$result["error"][]="\$conf變數須為陣列形態";
650
 
650
 
651
			#如果傳入的參數為 null
651
			#如果傳入的參數為 null
652
			if($conf==null){
652
			if($conf==null){
653
				
653
 
654
				#設置執行錯誤訊息
654
				#設置執行錯誤訊息
655
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
655
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
656
				
656
 
657
				}#if end
657
				}#if end
658
 
658
 
659
			#回傳結果
659
			#回傳結果
660
			return $result;
660
			return $result;
661
			
661
 
662
			}#if end
662
			}#if end
663
	
663
 
664
		#取得使用的參數
664
		#取得使用的參數
665
		$result["argu"]=$conf;
665
		$result["argu"]=$conf;
666
 
666
 
667
		#檢查參數
667
		#檢查參數
668
		#函式說明:
668
		#函式說明:
Line 680... Line 680...
680
		#必填寫的參數:
680
		#必填寫的參數:
681
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
681
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
682
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
682
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
683
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
683
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
684
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileName");
684
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileName");
685
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
685
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
686
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");
686
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");
687
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
687
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
688
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
688
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
689
		#可以省略的參數:
689
		#可以省略的參數:
690
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
690
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
691
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
691
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
692
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
692
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
693
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("inputString");
693
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("inputString");
694
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
694
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
695
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
695
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
696
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
696
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
697
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
697
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
698
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
698
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
699
		$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("fileName","inputString");
699
		$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("fileName","inputString");
Line 702... Line 702...
702
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
702
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
703
		unset($conf["variableCheck::checkArguments"]);
703
		unset($conf["variableCheck::checkArguments"]);
704
 
704
 
705
		#如果 $checkArguments["status"] 等於 "false"
705
		#如果 $checkArguments["status"] 等於 "false"
706
		if($checkArguments["status"]=="false"){
706
		if($checkArguments["status"]=="false"){
707
			
707
 
708
			#設置錯誤識別
708
			#設置錯誤識別
709
			$result["status"]="false";
709
			$result["status"]="false";
710
			
710
 
711
			#設置錯誤訊息
711
			#設置錯誤訊息
712
			$result["error"]=$checkArguments;
712
			$result["error"]=$checkArguments;
713
			
713
 
714
			#回傳結果
714
			#回傳結果
715
			return $result;
715
			return $result;
716
			
716
 
717
			}#if end
717
			}#if end
718
			
718
 
719
		#如果 $checkArguments["passed"] 等於 "false"
719
		#如果 $checkArguments["passed"] 等於 "false"
720
		if($checkArguments["passed"]=="false"){
720
		if($checkArguments["passed"]=="false"){
721
			
721
 
722
			#設置錯誤識別
722
			#設置錯誤識別
723
			$result["status"]="false";
723
			$result["status"]="false";
724
			
724
 
725
			#設置錯誤訊息
725
			#設置錯誤訊息
726
			$result["error"]=$checkArguments;
726
			$result["error"]=$checkArguments;
727
			
727
 
728
			#回傳結果
728
			#回傳結果
729
			return $result;
729
			return $result;
730
			
730
 
731
			}#if end
731
			}#if end
732
	
732
 
733
		#如果沒有設定要個別寫入的內容
733
		#如果沒有設定要個別寫入的內容
734
		if(!isset($conf["inputString"])){
734
		if(!isset($conf["inputString"])){
735
		
735
 
736
			#針對每個檔案名稱
736
			#針對每個檔案名稱
737
			for($i=0;$i<count($conf["fileName"]);$i++){
737
			for($i=0;$i<count($conf["fileName"]);$i++){
738
			
738
 
739
				#建立空的 $conf["inputString"]
739
				#建立空的 $conf["inputString"]
740
				$conf["inputString"][$i]="";
740
				$conf["inputString"][$i]="";
741
			
741
 
742
				}#for end
742
				}#for end
743
		
743
 
744
			}#if end
744
			}#if end
745
	
745
 
746
		#針對每個要寫入的檔案
746
		#針對每個要寫入的檔案
747
		foreach($conf["fileName"] as $index => $file2writre){
747
		foreach($conf["fileName"] as $index => $file2writre){
748
		
748
 
749
			#取得要寫入的內容
749
			#取得要寫入的內容
750
			$content2writre=$conf["inputString"][$index];
750
			$content2writre=$conf["inputString"][$index];
751
		
751
 
752
			#函式說明:
752
			#函式說明:
753
			#將字串寫入到檔案
753
			#將字串寫入到檔案
754
			#回傳結果:
754
			#回傳結果:
755
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
755
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
756
			#$result["error"],錯誤訊息陣列.
756
			#$result["error"],錯誤訊息陣列.
Line 780... Line 780...
780
			$conf["fileAccess::writeTextIntoFile"]["web"]="false";
780
			$conf["fileAccess::writeTextIntoFile"]["web"]="false";
781
			#備註:
781
			#備註:
782
			#無.
782
			#無.
783
			$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
783
			$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
784
			unset($conf["fileAccess::writeTextIntoFile"]);
784
			unset($conf["fileAccess::writeTextIntoFile"]);
785
			
785
 
786
			#如果建立檔案失敗
786
			#如果建立檔案失敗
787
			if($writeTextIntoFile["status"]==="false"){
787
			if($writeTextIntoFile["status"]==="false"){
788
			
788
 
789
				#設置錯誤識別
789
				#設置錯誤識別
790
				$result["status"]="false";
790
				$result["status"]="false";
791
				
791
 
792
				#設置錯誤訊息
792
				#設置錯誤訊息
793
				$result["error"]=$writeTextIntoFile;
793
				$result["error"]=$writeTextIntoFile;
794
				
794
 
795
				#回傳結果
795
				#回傳結果
796
				return $result;
796
				return $result;
797
			
797
 
798
				}#if end
798
				}#if end
799
			
799
 
800
			#設置建立好的檔案資訊
800
			#設置建立好的檔案資訊
801
			$result["content"][]=$writeTextIntoFile["fileInfo"];
801
			$result["content"][]=$writeTextIntoFile["fileInfo"];
802
				
802
 
803
			}#foreach end
803
			}#foreach end
804
			
804
 
805
			#設置執行正常
805
			#設置執行正常
806
			$result["status"]="true";
806
			$result["status"]="true";
807
			
807
 
808
			#回傳結果
808
			#回傳結果
809
			return $result;	
809
			return $result;
810
	
810
 
811
		}#function writeMultiFile end
811
		}#function writeMultiFile end
812
 
812
 
813
	/*
813
	/*
814
	#函式說明:
814
	#函式說明:
815
	#將多行字串寫入到檔案
815
	#將多行字串寫入到檔案
Line 833... Line 833...
833
	#無.
833
	#無.
834
	#備註:
834
	#備註:
835
	#無.
835
	#無.
836
	*/
836
	*/
837
	public static function writeMultiLine(&$conf){
837
	public static function writeMultiLine(&$conf){
838
	
838
 
839
		#初始化要回傳的結果
839
		#初始化要回傳的結果
840
		$result=array();
840
		$result=array();
841
		
841
 
842
		#取得當前執行的函數
842
		#取得當前執行的函數
843
		$result["function"]=__FUNCTION__;
843
		$result["function"]=__FUNCTION__;
844
 
844
 
845
		#如果 $conf 不為陣列
845
		#如果 $conf 不為陣列
846
		if(gettype($conf)!="array"){
846
		if(gettype($conf)!="array"){
847
			
847
 
848
			#設置執行失敗
848
			#設置執行失敗
849
			$result["status"]="false";
849
			$result["status"]="false";
850
			
850
 
851
			#設置執行錯誤訊息
851
			#設置執行錯誤訊息
852
			$result["error"][]="\$conf變數須為陣列形態";
852
			$result["error"][]="\$conf變數須為陣列形態";
853
 
853
 
854
			#如果傳入的參數為 null
854
			#如果傳入的參數為 null
855
			if($conf==null){
855
			if($conf==null){
856
				
856
 
857
				#設置執行錯誤訊息
857
				#設置執行錯誤訊息
858
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
858
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
859
				
859
 
860
				}#if end
860
				}#if end
861
 
861
 
862
			#回傳結果
862
			#回傳結果
863
			return $result;
863
			return $result;
864
			
864
 
865
			}#if end
865
			}#if end
866
	
866
 
867
		#檢查必填參數
867
		#檢查必填參數
868
		#函式說明:
868
		#函式說明:
869
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
869
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
870
		#回傳的結果:
870
		#回傳的結果:
871
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
871
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 877... Line 877...
877
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
877
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
878
		#必填寫的參數:
878
		#必填寫的參數:
879
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
879
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
880
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("fileName","inputString","fileArgu");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
880
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("fileName","inputString","fileArgu");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
881
		#可以省略的參數:
881
		#可以省略的參數:
882
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string","array","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
882
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string","array","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double");
883
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
883
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
884
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
884
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
885
		unset($conf["variableCheck.isexistMulti"]);
885
		unset($conf["variableCheck.isexistMulti"]);
886
		
886
 
887
		#如果檢查失敗
887
		#如果檢查失敗
888
		if($checkResult["status"]=="false"){
888
		if($checkResult["status"]=="false"){
889
			
889
 
890
			#設置執行錯誤
890
			#設置執行錯誤
891
			$result["status"]="false";
891
			$result["status"]="false";
892
			
892
 
893
			#設置執行錯誤訊息
893
			#設置執行錯誤訊息
894
			$result["error"]=$checkResult;
894
			$result["error"]=$checkResult;
895
			
895
 
896
			#回傳結果
896
			#回傳結果
897
			return $result;
897
			return $result;
898
			
898
 
899
			}#if end
899
			}#if end
900
			
900
 
901
		#如果檢查不通過
901
		#如果檢查不通過
902
		if($checkResult["passed"]=="false"){
902
		if($checkResult["passed"]=="false"){
903
			
903
 
904
			#設置執行錯誤
904
			#設置執行錯誤
905
			$result["status"]="false";
905
			$result["status"]="false";
906
			
906
 
907
			#設置執行錯誤訊息
907
			#設置執行錯誤訊息
908
			$result["error"]=$checkResult;
908
			$result["error"]=$checkResult;
909
			
909
 
910
			#回傳結果
910
			#回傳結果
911
			return $result;
911
			return $result;
912
			
912
 
913
			}#if end
913
			}#if end
914
		
914
 
915
		#檢查可省略參數 
915
		#檢查可省略參數
916
		#函式說明:
916
		#函式說明:
917
		#檢查一包含數個可省略變數的陣列變數,其型態是否正確,省略掉的陣列變數可以直接給定預設值。
917
		#檢查一包含數個可省略變數的陣列變數,其型態是否正確,省略掉的陣列變數可以直接給定預設值。
918
		#回傳結果:
918
		#回傳結果:
919
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
919
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
920
		#$result["error"],錯誤訊息陣列.
920
		#$result["error"],錯誤訊息陣列.
Line 933... Line 933...
933
		#$conf["variableCheck.checkSkipableVarType"]["skipableVarDefaultValue"],字串陣列,每個不存的變數要初始化為什麼,"null"代表不指定.
933
		#$conf["variableCheck.checkSkipableVarType"]["skipableVarDefaultValue"],字串陣列,每個不存的變數要初始化為什麼,"null"代表不指定.
934
		$conf["variableCheck.checkSkipableVarType"]["skipableVarDefaultValue"]=array("w","false");
934
		$conf["variableCheck.checkSkipableVarType"]["skipableVarDefaultValue"]=array("w","false");
935
		#無
935
		#無
936
		$checkResult=variableCheck::checkSkipableVarType($conf["variableCheck.checkSkipableVarType"],$argu);
936
		$checkResult=variableCheck::checkSkipableVarType($conf["variableCheck.checkSkipableVarType"],$argu);
937
		unset($conf["variableCheck.checkSkipableVarType"]);
937
		unset($conf["variableCheck.checkSkipableVarType"]);
938
		
938
 
939
		#如果檢查不通過
939
		#如果檢查不通過
940
		if($checkResult["status"]=="false"){
940
		if($checkResult["status"]=="false"){
941
			
941
 
942
			#設置執行錯誤
942
			#設置執行錯誤
943
			$result["status"]="false";
943
			$result["status"]="false";
944
			
944
 
945
			#設置執行錯誤訊息
945
			#設置執行錯誤訊息
946
			$result["error"]=$checkResult;
946
			$result["error"]=$checkResult;
947
			
947
 
948
			#回傳結果
948
			#回傳結果
949
			return $result;
949
			return $result;
950
			
950
 
951
			}#if end
951
			}#if end
952
			
952
 
953
		#如果檢查不通過
953
		#如果檢查不通過
954
		if($checkResult["passed"]=="false"){
954
		if($checkResult["passed"]=="false"){
955
			
955
 
956
			#設置執行錯誤
956
			#設置執行錯誤
957
			$result["status"]="false";
957
			$result["status"]="false";
958
			
958
 
959
			#設置執行錯誤訊息
959
			#設置執行錯誤訊息
960
			$result["error"]=$checkResult;
960
			$result["error"]=$checkResult;
961
			
961
 
962
			#回傳結果
962
			#回傳結果
963
			return $result;
963
			return $result;
964
			
964
 
965
			}#if end
965
			}#if end
966
 
966
 
967
		#如果有設置快速寫入
967
		#如果有設置快速寫入
968
		if($conf["fastWrite"]==="true"){
968
		if($conf["fastWrite"]==="true"){
969
		
969
 
970
			#初始化要寫入的字串
970
			#初始化要寫入的字串
971
			$inputStrAll="";
971
			$inputStrAll="";
972
		
972
 
973
			#有幾行字要寫就執行幾次
973
			#有幾行字要寫就執行幾次
974
			foreach($conf["inputString"] as $inputStr){
974
			foreach($conf["inputString"] as $inputStr){
975
 
975
 
976
				#附加 "\r\n"
976
				#附加 "\r\n"
977
				$inputStrAll=$inputStrAll.$inputStr.PHP_EOL;
977
				$inputStrAll=$inputStrAll.$inputStr.PHP_EOL;
978
 
978
 
979
				}#foreach end
979
				}#foreach end
980
		
980
 
981
			#函式說明:
981
			#函式說明:
982
			#將字串寫入到檔案
982
			#將字串寫入到檔案
983
			#回傳結果:
983
			#回傳結果:
984
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
984
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
985
			#$result["error"],錯誤訊息陣列.
985
			#$result["error"],錯誤訊息陣列.
Line 992... Line 992...
992
			$conf["fileAccess.writeTextIntoFile"]["writeMethod"]=$conf["writeMethod"];#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
992
			$conf["fileAccess.writeTextIntoFile"]["writeMethod"]=$conf["writeMethod"];#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
993
			#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
993
			#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
994
			$conf["fileAccess.writeTextIntoFile"]["web"]="false";
994
			$conf["fileAccess.writeTextIntoFile"]["web"]="false";
995
			$writeStatus=fileAccess::writeTextIntoFile($conf["fileAccess.writeTextIntoFile"]);
995
			$writeStatus=fileAccess::writeTextIntoFile($conf["fileAccess.writeTextIntoFile"]);
996
			unset($conf["fileAccess.writeTextIntoFile"]);
996
			unset($conf["fileAccess.writeTextIntoFile"]);
997
			
997
 
998
			#如果寫入失敗
998
			#如果寫入失敗
999
			if($writeStatus["status"]=="false"){
999
			if($writeStatus["status"]=="false"){
1000
				
1000
 
1001
				#設置執行錯誤
1001
				#設置執行錯誤
1002
				$result["status"]="false";
1002
				$result["status"]="false";
1003
				
1003
 
1004
				#設置執行錯誤訊息
1004
				#設置執行錯誤訊息
1005
				$result["error"]=$writeStatus;
1005
				$result["error"]=$writeStatus;
1006
				
1006
 
1007
				#回傳結果
1007
				#回傳結果
1008
				return $result;
1008
				return $result;
1009
				
1009
 
1010
				}#if end
1010
				}#if end
1011
				
1011
 
1012
			#設置執行正常
1012
			#設置執行正常
1013
			$result["status"]="true";
1013
			$result["status"]="true";
1014
			
1014
 
1015
			#回傳結果
1015
			#回傳結果
1016
			return $result;
1016
			return $result;
1017
		
1017
 
1018
			}#if end
1018
			}#if end
1019
 
1019
 
1020
		#初始化第一次寫入識別變數
1020
		#初始化第一次寫入識別變數
1021
		$firstTimeToWrite="true";
1021
		$firstTimeToWrite="true";
1022
		
1022
 
1023
		#有幾行字要寫就執行幾次
1023
		#有幾行字要寫就執行幾次
1024
		foreach($conf["inputString"] as $inputStr){
1024
		foreach($conf["inputString"] as $inputStr){
1025
 
1025
 
1026
			#附加 "\r\n"
1026
			#附加 "\r\n"
1027
			$inputStr=$inputStr.PHP_EOL;
1027
			$inputStr=$inputStr.PHP_EOL;
1028
 
1028
 
1029
			#如果是第一次寫入
1029
			#如果是第一次寫入
1030
			if($firstTimeToWrite=="true"){
1030
			if($firstTimeToWrite=="true"){
1031
				
1031
 
1032
				#如果是要重新寫入
1032
				#如果是要重新寫入
1033
				if($conf["writeMethod"]==="w"){
1033
				if($conf["writeMethod"]==="w"){
1034
					
1034
 
1035
					#函式說明:
1035
					#函式說明:
1036
					#將字串寫入到檔案
1036
					#將字串寫入到檔案
1037
					#回傳結果:
1037
					#回傳結果:
1038
					#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1038
					#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1039
					#$result["error"],錯誤訊息陣列.
1039
					#$result["error"],錯誤訊息陣列.
Line 1046... Line 1046...
1046
					$conf["fileAccess.writeTextIntoFile"]["writeMethod"]="w";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1046
					$conf["fileAccess.writeTextIntoFile"]["writeMethod"]="w";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1047
					#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1047
					#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1048
					$conf["fileAccess.writeTextIntoFile"]["web"]="false";
1048
					$conf["fileAccess.writeTextIntoFile"]["web"]="false";
1049
					$writeStatus=fileAccess::writeTextIntoFile($conf["fileAccess.writeTextIntoFile"]);
1049
					$writeStatus=fileAccess::writeTextIntoFile($conf["fileAccess.writeTextIntoFile"]);
1050
					unset($conf["fileAccess.writeTextIntoFile"]);
1050
					unset($conf["fileAccess.writeTextIntoFile"]);
1051
					
1051
 
1052
					#如果寫入失敗
1052
					#如果寫入失敗
1053
					if($writeStatus["status"]=="false"){
1053
					if($writeStatus["status"]=="false"){
1054
						
1054
 
1055
						#設置執行錯誤
1055
						#設置執行錯誤
1056
						$result["status"]="false";
1056
						$result["status"]="false";
1057
						
1057
 
1058
						#設置執行錯誤訊息
1058
						#設置執行錯誤訊息
1059
						$result["error"]=$writeStatus;
1059
						$result["error"]=$writeStatus;
1060
						
1060
 
1061
						#回傳結果
1061
						#回傳結果
1062
						return $result;
1062
						return $result;
1063
						
1063
 
1064
						}#if end
1064
						}#if end
1065
					
1065
 
1066
					}#if end
1066
					}#if end
1067
					
1067
 
1068
				#反之不是重新寫入,而是附加寫入。
1068
				#反之不是重新寫入,而是附加寫入。
1069
				else{
1069
				else{
1070
					
1070
 
1071
					#函式說明:
1071
					#函式說明:
1072
					#將字串寫入到檔案
1072
					#將字串寫入到檔案
1073
					#回傳結果:
1073
					#回傳結果:
1074
					#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1074
					#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1075
					#$result["error"],錯誤訊息陣列.
1075
					#$result["error"],錯誤訊息陣列.
Line 1082... Line 1082...
1082
					$conf["fileAccess.writeTextIntoFile"]["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1082
					$conf["fileAccess.writeTextIntoFile"]["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1083
					#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1083
					#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1084
					$conf["fileAccess.writeTextIntoFile"]["web"]="false";
1084
					$conf["fileAccess.writeTextIntoFile"]["web"]="false";
1085
					$writeStatus=fileAccess::writeTextIntoFile($conf["fileAccess.writeTextIntoFile"]);
1085
					$writeStatus=fileAccess::writeTextIntoFile($conf["fileAccess.writeTextIntoFile"]);
1086
					unset($conf["fileAccess.writeTextIntoFile"]);
1086
					unset($conf["fileAccess.writeTextIntoFile"]);
1087
					
1087
 
1088
					#如果寫入失敗
1088
					#如果寫入失敗
1089
					if($writeStatus["status"]=="false"){
1089
					if($writeStatus["status"]=="false"){
1090
						
1090
 
1091
						#設置執行錯誤
1091
						#設置執行錯誤
1092
						$result["status"]="false";
1092
						$result["status"]="false";
1093
						
1093
 
1094
						#設置執行錯誤訊息
1094
						#設置執行錯誤訊息
1095
						$result["error"]=$writeStatus;
1095
						$result["error"]=$writeStatus;
1096
						
1096
 
1097
						#回傳結果
1097
						#回傳結果
1098
						return $result;
1098
						return $result;
1099
						
1099
 
1100
						}#if end
1100
						}#if end
1101
					
1101
 
1102
					}#else end
1102
					}#else end
1103
				
1103
 
1104
				#將之設為不是第一次寫入
1104
				#將之設為不是第一次寫入
1105
				$firstTimeToWrite="false";
1105
				$firstTimeToWrite="false";
1106
				
1106
 
1107
				}#if end
1107
				}#if end
1108
				
1108
 
1109
			#反之不是第一次寫入
1109
			#反之不是第一次寫入
1110
			else{
1110
			else{
1111
				
1111
 
1112
				#函式說明:
1112
				#函式說明:
1113
				#將字串寫入到檔案
1113
				#將字串寫入到檔案
1114
				#回傳結果:
1114
				#回傳結果:
1115
				#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1115
				#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1116
				#$result["error"],錯誤訊息陣列.
1116
				#$result["error"],錯誤訊息陣列.
Line 1123... Line 1123...
1123
				$conf["fileAccess.writeTextIntoFile"]["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1123
				$conf["fileAccess.writeTextIntoFile"]["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1124
				#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1124
				#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1125
				$conf["fileAccess.writeTextIntoFile"]["web"]="false";
1125
				$conf["fileAccess.writeTextIntoFile"]["web"]="false";
1126
				$writeStatus=fileAccess::writeTextIntoFile($conf["fileAccess.writeTextIntoFile"]);
1126
				$writeStatus=fileAccess::writeTextIntoFile($conf["fileAccess.writeTextIntoFile"]);
1127
				unset($conf["fileAccess.writeTextIntoFile"]);
1127
				unset($conf["fileAccess.writeTextIntoFile"]);
1128
				
1128
 
1129
				#如果寫入失敗
1129
				#如果寫入失敗
1130
				if($writeStatus["status"]=="false"){
1130
				if($writeStatus["status"]=="false"){
1131
					
1131
 
1132
					#設置執行錯誤
1132
					#設置執行錯誤
1133
					$result["status"]="false";
1133
					$result["status"]="false";
1134
					
1134
 
1135
					#設置執行錯誤訊息
1135
					#設置執行錯誤訊息
1136
					$result["error"]=$writeStatus;
1136
					$result["error"]=$writeStatus;
1137
					
1137
 
1138
					#回傳結果
1138
					#回傳結果
1139
					return $result;
1139
					return $result;
1140
					
1140
 
1141
					}#if end
1141
					}#if end
1142
				
1142
 
1143
				}#else end
1143
				}#else end
1144
			
1144
 
1145
			}#foreach end
1145
			}#foreach end
1146
			
1146
 
1147
		#執行到這邊代表一切正常
1147
		#執行到這邊代表一切正常
1148
		$result["status"]="true";
1148
		$result["status"]="true";
1149
		
1149
 
1150
		#回傳結果
1150
		#回傳結果
1151
		return $result;
1151
		return $result;
1152
		
1152
 
1153
		}#function writeMultiLine end
1153
		}#function writeMultiLine end
1154
	
1154
 
1155
	/*
1155
	/*
1156
	#函式說明:
1156
	#函式說明:
1157
	#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
1157
	#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
1158
	#回傳的變數說明:
1158
	#回傳的變數說明:
1159
	#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
1159
	#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
Line 1190... Line 1190...
1190
	*/
1190
	*/
1191
	public static function getFileContent($conf){
1191
	public static function getFileContent($conf){
1192
 
1192
 
1193
		#初始化要回傳的內容
1193
		#初始化要回傳的內容
1194
		$result=array();
1194
		$result=array();
1195
		
1195
 
1196
		#取得當前執行函數名稱
1196
		#取得當前執行函數名稱
1197
		$result["function"]=__FUNCTION__;
1197
		$result["function"]=__FUNCTION__;
1198
 
1198
 
1199
		#如果 $conf 不為陣列
1199
		#如果 $conf 不為陣列
1200
		if(gettype($conf)!="array"){
1200
		if(gettype($conf)!="array"){
1201
			
1201
 
1202
			#設置執行失敗
1202
			#設置執行失敗
1203
			$result["status"]="false";
1203
			$result["status"]="false";
1204
			
1204
 
1205
			#設置執行錯誤訊息
1205
			#設置執行錯誤訊息
1206
			$result["error"][]="\$conf變數須為陣列形態";
1206
			$result["error"][]="\$conf變數須為陣列形態";
1207
 
1207
 
1208
			#如果傳入的參數為 null
1208
			#如果傳入的參數為 null
1209
			if($conf==null){
1209
			if($conf==null){
1210
				
1210
 
1211
				#設置執行錯誤訊息
1211
				#設置執行錯誤訊息
1212
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1212
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1213
				
1213
 
1214
				}#if end
1214
				}#if end
1215
 
1215
 
1216
			#回傳結果
1216
			#回傳結果
1217
			return $result;
1217
			return $result;
1218
			
1218
 
1219
			}#if end
1219
			}#if end
1220
 
1220
 
1221
		#檢查參數
1221
		#檢查參數
1222
		#函式說明:
1222
		#函式說明:
1223
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
1223
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
Line 1271... Line 1271...
1271
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1271
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1272
		#備註:
1272
		#備註:
1273
		#無.
1273
		#無.
1274
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1274
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1275
		unset($conf["variableCheck::checkArguments"]);
1275
		unset($conf["variableCheck::checkArguments"]);
1276
		
1276
 
1277
		#如果檢查出錯
1277
		#如果檢查出錯
1278
		if($checkArguments["status"]==="false"){
1278
		if($checkArguments["status"]==="false"){
1279
			
1279
 
1280
			#設置執行錯誤識別
1280
			#設置執行錯誤識別
1281
			$result["status"]="false";
1281
			$result["status"]="false";
1282
			
1282
 
1283
			#設置執行錯誤訊息
1283
			#設置執行錯誤訊息
1284
			$result["error"]=$checkArguments;
1284
			$result["error"]=$checkArguments;
1285
			
1285
 
1286
			#回傳結果
1286
			#回傳結果
1287
			return $result;
1287
			return $result;
1288
			
1288
 
1289
			}#if end
1289
			}#if end
1290
			
1290
 
1291
		#如果檢查參數不通過
1291
		#如果檢查參數不通過
1292
		if($checkArguments["passed"]==="false"){
1292
		if($checkArguments["passed"]==="false"){
1293
			
1293
 
1294
			#設置執行錯誤識別
1294
			#設置執行錯誤識別
1295
			$result["status"]="false";
1295
			$result["status"]="false";
1296
			
1296
 
1297
			#設置執行錯誤訊息
1297
			#設置執行錯誤訊息
1298
			$result["error"]=$checkArguments;
1298
			$result["error"]=$checkArguments;
1299
			
1299
 
1300
			#回傳結果
1300
			#回傳結果
1301
			return $result;
1301
			return $result;
1302
			
1302
 
1303
			}#if end
1303
			}#if end
1304
		
1304
 
1305
		#檢查檔案是否存在
1305
		#檢查檔案是否存在
1306
		#函式說明:檢查多個檔案與資料夾是否存在
1306
		#函式說明:檢查多個檔案與資料夾是否存在
1307
		#回傳的結果:
1307
		#回傳的結果:
1308
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
1308
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
1309
		#$result["error"],錯誤訊息陣列.
1309
		#$result["error"],錯誤訊息陣列.
Line 1316... Line 1316...
1316
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1316
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1317
		$conf["fileAccess"]["checkMutiFileExist"]["fileArgu"]=$conf["fileArgu"];
1317
		$conf["fileAccess"]["checkMutiFileExist"]["fileArgu"]=$conf["fileArgu"];
1318
		#可省略參數:
1318
		#可省略參數:
1319
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
1319
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
1320
		$conf["fileAccess"]["checkMutiFileExist"]["disableWebSearch"]="true";
1320
		$conf["fileAccess"]["checkMutiFileExist"]["disableWebSearch"]="true";
1321
		
1321
 
1322
		#如果有設置 $conf["web"]
1322
		#如果有設置 $conf["web"]
1323
		if(isset($conf["web"])){
1323
		if(isset($conf["web"])){
1324
		
1324
 
1325
			#設置 web 參數.
1325
			#設置 web 參數.
1326
			$conf["fileAccess"]["checkMutiFileExist"]["web"]=$conf["web"];
1326
			$conf["fileAccess"]["checkMutiFileExist"]["web"]=$conf["web"];
1327
	
1327
 
1328
			}#if end
1328
			}#if end
1329
		
1329
 
1330
		#參考資料來源:
1330
		#參考資料來源:
1331
		#http:#php.net/manual/en/function.file-exists.php
1331
		#http:#php.net/manual/en/function.file-exists.php
1332
		#http:#php.net/manual/en/control-structures.foreach.php
1332
		#http:#php.net/manual/en/control-structures.foreach.php
1333
		$fileCheckResult=fileAccess::checkMultiFileExist($conf["fileAccess"]["checkMutiFileExist"]);
1333
		$fileCheckResult=fileAccess::checkMultiFileExist($conf["fileAccess"]["checkMutiFileExist"]);
1334
		unset($conf["fileAccess"]["checkMutiFileExist"]);
1334
		unset($conf["fileAccess"]["checkMutiFileExist"]);
1335
 
1335
 
1336
		#如果檢查檔案是否存在出錯
1336
		#如果檢查檔案是否存在出錯
1337
		if($fileCheckResult["status"]=="false"){
1337
		if($fileCheckResult["status"]=="false"){
1338
			
1338
 
1339
			#設置執行錯誤識別
1339
			#設置執行錯誤識別
1340
			$result["status"]="false";
1340
			$result["status"]="false";
1341
			
1341
 
1342
			#設置執行錯誤訊息
1342
			#設置執行錯誤訊息
1343
			$result["error"]=$fileCheckResult;
1343
			$result["error"]=$fileCheckResult;
1344
			
1344
 
1345
			#回傳結果
1345
			#回傳結果
1346
			return $result;
1346
			return $result;
1347
			
1347
 
1348
			}#if end
1348
			}#if end
1349
 
1349
 
1350
		#如果該檔案不存在
1350
		#如果該檔案不存在
1351
		if($fileCheckResult["varExist"][0]=="false"){
1351
		if($fileCheckResult["varExist"][0]=="false"){
1352
			
1352
 
1353
			#如果也不要自動建立檔案
1353
			#如果也不要自動建立檔案
1354
			if($conf["createIfnotExist"]==="false"){
1354
			if($conf["createIfnotExist"]==="false"){
1355
			
1355
 
1356
				#設置執行錯誤識別
1356
				#設置執行錯誤識別
1357
				$result["status"]="false";
1357
				$result["status"]="false";
1358
				
1358
 
1359
				#設置執行錯誤訊息
1359
				#設置執行錯誤訊息
1360
				$result["error"]=$fileCheckResult;
1360
				$result["error"]=$fileCheckResult;
1361
				
1361
 
1362
				#設置易讀的錯誤訊息
1362
				#設置易讀的錯誤訊息
1363
				$result["error"][]="名為".$fileCheckResult["varName"][0]."的檔案不存在";
1363
				$result["error"][]="名為".$fileCheckResult["varName"][0]."的檔案不存在";
1364
				
1364
 
1365
				#回傳結果
1365
				#回傳結果
1366
				return $result;
1366
				return $result;
1367
			
1367
 
1368
				}#if end
1368
				}#if end
1369
			
1369
 
1370
			#執行到這邊代表需要建立該檔案
1370
			#執行到這邊代表需要建立該檔案
1371
			#函式說明:
1371
			#函式說明:
1372
			#將字串寫入到檔案
1372
			#將字串寫入到檔案
1373
			#回傳結果:
1373
			#回傳結果:
1374
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1374
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
Line 1391... Line 1391...
1391
			#$conf["checkRepeat"]="";
1391
			#$conf["checkRepeat"]="";
1392
			#$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點,必須與$conf["checkRepeat"]搭配才會生效.
1392
			#$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點,必須與$conf["checkRepeat"]搭配才會生效.
1393
			#$conf["filenameExtensionStartPoint"]="";
1393
			#$conf["filenameExtensionStartPoint"]="";
1394
			#$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)",必須與$conf["checkRepeat"]搭配才會生效.
1394
			#$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)",必須與$conf["checkRepeat"]搭配才會生效.
1395
			#$conf["repeatNameRule"]="";
1395
			#$conf["repeatNameRule"]="";
1396
			
1396
 
1397
			#如果有設置 $conf["web"]
1397
			#如果有設置 $conf["web"]
1398
			if(isset($conf["web"])){
1398
			if(isset($conf["web"])){
1399
			
1399
 
1400
				#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1400
				#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1401
				$conf["fileAccess::writeTextIntoFile"]["web"]=$conf["web"];
1401
				$conf["fileAccess::writeTextIntoFile"]["web"]=$conf["web"];
1402
		
1402
 
1403
				}#if end
1403
				}#if end
1404
			
1404
 
1405
			#參考資料:
1405
			#參考資料:
1406
			#無.
1406
			#無.
1407
			#備註:
1407
			#備註:
1408
			#無.
1408
			#無.
1409
			$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
1409
			$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
1410
			unset($conf["fileAccess::writeTextIntoFile"]);
1410
			unset($conf["fileAccess::writeTextIntoFile"]);
1411
			
1411
 
1412
			#如果建立檔案失敗
1412
			#如果建立檔案失敗
1413
			if($writeTextIntoFile["status"]=="false"){
1413
			if($writeTextIntoFile["status"]=="false"){
1414
				
1414
 
1415
				#設置執行錯誤識別
1415
				#設置執行錯誤識別
1416
				$result["status"]="false";
1416
				$result["status"]="false";
1417
				
1417
 
1418
				#設置執行錯誤訊息
1418
				#設置執行錯誤訊息
1419
				$result["error"]=$writeTextIntoFile;
1419
				$result["error"]=$writeTextIntoFile;
1420
				
1420
 
1421
				#回傳結果
1421
				#回傳結果
1422
				return $result;
1422
				return $result;
1423
				
1423
 
1424
				}#if end
1424
				}#if end
1425
			
1425
 
1426
			}#if end
1426
			}#if end
1427
 
1427
 
1428
		#file absolute addr
1428
		#file absolute addr
1429
		$fileAbAddr=$fileCheckResult["varNameFullPath"][0];
1429
		$fileAbAddr=$fileCheckResult["varNameFullPath"][0];
1430
		
1430
 
1431
		#將檔案的內容放進變數裡面(會得到陣列)
1431
		#將檔案的內容放進變數裡面(會得到陣列)
1432
		$fileContent=file($fileAbAddr);
1432
		$fileContent=file($fileAbAddr);
1433
 
1433
 
1434
		#如果 $fileContent 等於
1434
		#如果 $fileContent 等於
1435
		if($fileContent==FALSE){
1435
		if($fileContent==FALSE){
1436
 
1436
 
1437
			#如果檔案大小為0bytes
1437
			#如果檔案大小為0bytes
1438
			if(filesize($fileAbAddr)==0){
1438
			if(filesize($fileAbAddr)==0){
1439
			
1439
 
1440
				#設置錯誤識別
1440
				#設置錯誤識別
1441
				$result["warning"][]="執行結果沒有輸出內容";
1441
				$result["warning"][]="執行結果沒有輸出內容";
1442
 
1442
 
1443
				}#if end
1443
				}#if end
1444
				
1444
 
1445
			#反之檔案有內容
1445
			#反之檔案有內容
1446
			else{
1446
			else{
1447
 
1447
 
1448
				#設置錯誤識別
1448
				#設置錯誤識別
1449
				$result["status"]="false";
1449
				$result["status"]="false";
Line 1451... Line 1451...
1451
				#設置錯誤訊息
1451
				#設置錯誤訊息
1452
				$result["error"][]="讀取檔案失敗";
1452
				$result["error"][]="讀取檔案失敗";
1453
 
1453
 
1454
				#取得詳細的錯誤訊息
1454
				#取得詳細的錯誤訊息
1455
				$result["error"][]=$fileCheckResult;
1455
				$result["error"][]=$fileCheckResult;
1456
				
1456
 
1457
				#回傳結果
1457
				#回傳結果
1458
				return $result;
1458
				return $result;
1459
				
1459
 
1460
				}#else end
1460
				}#else end
1461
 
1461
 
1462
			}#if end
1462
			}#if end
1463
 
1463
 
1464
		#針對每行內容
1464
		#針對每行內容
1465
		for($i=0;$i<count($fileContent);$i++){
1465
		for($i=0;$i<count($fileContent);$i++){
1466
			
1466
 
1467
			#剔除字串尾的換行符號
1467
			#剔除字串尾的換行符號
1468
			$fileContent[$i]=rtrim($fileContent[$i]);
1468
			$fileContent[$i]=rtrim($fileContent[$i]);
1469
			
1469
 
1470
			#如果要移除開頭的空白
1470
			#如果要移除開頭的空白
1471
			if($conf["autoDeleteSpaceOnEachLineStart"]==="true"){
1471
			if($conf["autoDeleteSpaceOnEachLineStart"]==="true"){
1472
			
1472
 
1473
				#如果開頭是空格
1473
				#如果開頭是空格
1474
				while(strpos($fileContent[$i]," ")===0){
1474
				while(strpos($fileContent[$i]," ")===0){
1475
				
1475
 
1476
					#函式說明:
1476
					#函式說明:
1477
					#將字串特定關鍵字與其前面的內容剔除
1477
					#將字串特定關鍵字與其前面的內容剔除
1478
					#回傳結果:
1478
					#回傳結果:
1479
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1479
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1480
					#$result["error"],錯誤訊息陣列.
1480
					#$result["error"],錯誤訊息陣列.
1481
					#$result["warning"],警告訊息鎮列.
1481
					#$result["warning"],警告訊息鎮列.
1482
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
1482
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
1483
					#$result["function"],當前執行的函數名稱.
1483
					#$result["function"],當前執行的函數名稱.
1484
					#$result["argu"],使用的參數.
1484
					#$result["argu"],使用的參數.
1485
					#$result["oriStr"],要處理的原始字串內容.
1485
					#$result["oriStr"],要處理的原始字串內容.
1486
					#$result["content"],處理好的的字串內容.	
1486
					#$result["content"],處理好的的字串內容.
1487
					#必填參數:
1487
					#必填參數:
1488
					#$conf["stringIn"],字串,要處理的字串.
1488
					#$conf["stringIn"],字串,要處理的字串.
1489
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$fileContent[$i];
1489
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$fileContent[$i];
1490
					#$conf["keyWord"],字串,特定字串.
1490
					#$conf["keyWord"],字串,特定字串.
1491
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
1491
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
Line 1498... Line 1498...
1498
					#無.
1498
					#無.
1499
					#備註:
1499
					#備註:
1500
					#無.
1500
					#無.
1501
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
1501
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
1502
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
1502
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
1503
				
1503
 
1504
					#如果建立檔案失敗
1504
					#如果建立檔案失敗
1505
					if($delStrBeforeKeyWord["status"]=="false"){
1505
					if($delStrBeforeKeyWord["status"]=="false"){
1506
						
1506
 
1507
						#設置執行錯誤識別
1507
						#設置執行錯誤識別
1508
						$result["status"]="false";
1508
						$result["status"]="false";
1509
						
1509
 
1510
						#設置執行錯誤訊息
1510
						#設置執行錯誤訊息
1511
						$result["error"]=$delStrBeforeKeyWord;
1511
						$result["error"]=$delStrBeforeKeyWord;
1512
						
1512
 
1513
						#回傳結果
1513
						#回傳結果
1514
						return $result;
1514
						return $result;
1515
						
1515
 
1516
						}#if end
1516
						}#if end
1517
						
1517
 
1518
					#取得剔除開頭空格後的內容
1518
					#取得剔除開頭空格後的內容
1519
					$fileContent[$i]=$delStrBeforeKeyWord["content"];
1519
					$fileContent[$i]=$delStrBeforeKeyWord["content"];
1520
				
1520
 
1521
					}#while end
1521
					}#while end
1522
			
1522
 
1523
				}#if end
1523
				}#if end
1524
			
1524
 
1525
			}#for end
1525
			}#for end
1526
 
1526
 
1527
		#取得總共有幾行
1527
		#取得總共有幾行
1528
		$lineCount=count($fileContent);
1528
		$lineCount=count($fileContent);
1529
 
1529
 
1530
		#將檔案內容的陣列放進 $result 陣列變數裏面
1530
		#將檔案內容的陣列放進 $result 陣列變數裏面
1531
		$result["fileContent"]=$fileContent;
1531
		$result["fileContent"]=$fileContent;
1532
		
1532
 
1533
		#建立暫存檔案
1533
		#建立暫存檔案
1534
		$tmpFile=tempnam("/tmp", "qbpwcf");
1534
		$tmpFile=tempnam("/tmp", "qbpwcf");
1535
		
1535
 
1536
		#讀取要取得的檔案內容
1536
		#讀取要取得的檔案內容
1537
		$content=file_get_contents($fileAbAddr);
1537
		$content=file_get_contents($fileAbAddr);
1538
		
1538
 
1539
		#開啟暫存檔案(寫入模式)
1539
		#開啟暫存檔案(寫入模式)
1540
		$file=fopen($tmpFile,'w');
1540
		$file=fopen($tmpFile,'w');
1541
		
1541
 
1542
		#寫入讀取到的內容
1542
		#寫入讀取到的內容
1543
		fwrite($file,$content);
1543
		fwrite($file,$content);
1544
		
1544
 
1545
		#關閉暫存檔案
1545
		#關閉暫存檔案
1546
		fclose($file);
1546
		fclose($file);
1547
		
1547
 
1548
		#取得檔案的 mime 類型
1548
		#取得檔案的 mime 類型
1549
		$mimeType=mime_content_type($tmpFile);
1549
		$mimeType=mime_content_type($tmpFile);
1550
		
1550
 
1551
		#設置檔案的mime類型
1551
		#設置檔案的mime類型
1552
		$result["mimeType"]=$mimeType;
1552
		$result["mimeType"]=$mimeType;
1553
		
1553
 
1554
		#取得檔案的內容為字串
1554
		#取得檔案的內容為字串
1555
		$result["fullContent"]=file_get_contents($tmpFile);
1555
		$result["fullContent"]=file_get_contents($tmpFile);
1556
		
1556
 
1557
		#取得檔案的base64data
1557
		#取得檔案的base64data
1558
		$result["base64dataOnly"]=base64_encode($result["fullContent"]);
1558
		$result["base64dataOnly"]=base64_encode($result["fullContent"]);
1559
		
1559
 
1560
		#取得檔案用 data:mimeType;base64,base64data 表示的字串
1560
		#取得檔案用 data:mimeType;base64,base64data 表示的字串
1561
		$result["base64data"]="data:".$result["mimeType"].";base64,".$result["base64dataOnly"];
1561
		$result["base64data"]="data:".$result["mimeType"].";base64,".$result["base64dataOnly"];
1562
		
1562
 
1563
		#移除暫存檔案
1563
		#移除暫存檔案
1564
		unlink($tmpFile);
1564
		unlink($tmpFile);
1565
		
1565
 
1566
		#將檔案內容的行數放進 $result 陣列變數裏面
1566
		#將檔案內容的行數放進 $result 陣列變數裏面
1567
		$result["lineCount"]=$lineCount;
1567
		$result["lineCount"]=$lineCount;
1568
 
1568
 
1569
		#執行到這邊代表執行成功
1569
		#執行到這邊代表執行成功
1570
		$result["status"]="true";
1570
		$result["status"]="true";
Line 1575... Line 1575...
1575
		}#function getFileContent end
1575
		}#function getFileContent end
1576
 
1576
 
1577
	/*
1577
	/*
1578
	#函式說明:
1578
	#函式說明:
1579
	#依據逗號分隔抓取檔案的內容,結果會回傳一個陣列
1579
	#依據逗號分隔抓取檔案的內容,結果會回傳一個陣列
1580
	#回傳結果:	
1580
	#回傳結果:
1581
	#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
1581
	#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
1582
	#$result["error"],錯誤訊息提示.
1582
	#$result["error"],錯誤訊息提示.
1583
	#$result["function"],函數名稱.
1583
	#$result["function"],函數名稱.
1584
	#$result["lineCount"]爲總共有幾行
1584
	#$result["lineCount"]爲總共有幾行
1585
	#$result["lineContent"][i]["dataCounts"],爲第 i+1 行總共有幾個字串
1585
	#$result["lineContent"][i]["dataCounts"],爲第 i+1 行總共有幾個字串
Line 1598... Line 1598...
1598
	*/
1598
	*/
1599
	public static function getFileContentSpiltBySomething($conf){
1599
	public static function getFileContentSpiltBySomething($conf){
1600
 
1600
 
1601
		#初始化要回傳的內容
1601
		#初始化要回傳的內容
1602
		$result=array();
1602
		$result=array();
1603
		
1603
 
1604
		#取得當前執行函數名稱
1604
		#取得當前執行函數名稱
1605
		$result["function"]=__FUNCTION__;
1605
		$result["function"]=__FUNCTION__;
1606
 
1606
 
1607
		#如果 $conf 不為陣列
1607
		#如果 $conf 不為陣列
1608
		if(gettype($conf)!="array"){
1608
		if(gettype($conf)!="array"){
1609
			
1609
 
1610
			#設置執行失敗
1610
			#設置執行失敗
1611
			$result["status"]="false";
1611
			$result["status"]="false";
1612
			
1612
 
1613
			#設置執行錯誤訊息
1613
			#設置執行錯誤訊息
1614
			$result["error"][]="\$conf變數須為陣列形態";
1614
			$result["error"][]="\$conf變數須為陣列形態";
1615
 
1615
 
1616
			#如果傳入的參數為 null
1616
			#如果傳入的參數為 null
1617
			if($conf==null){
1617
			if($conf==null){
1618
				
1618
 
1619
				#設置執行錯誤訊息
1619
				#設置執行錯誤訊息
1620
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1620
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1621
				
1621
 
1622
				}#if end
1622
				}#if end
1623
 
1623
 
1624
			#回傳結果
1624
			#回傳結果
1625
			return $result;
1625
			return $result;
1626
			
1626
 
1627
			}#if end
1627
			}#if end
1628
 
1628
 
1629
		#如果 $conf["spiltSign"] 爲空,則預設爲","。
1629
		#如果 $conf["spiltSign"] 爲空,則預設爲","。
1630
		if(!isset($conf["spiltSign"])){
1630
		if(!isset($conf["spiltSign"])){
1631
 
1631
 
Line 1647... Line 1647...
1647
		$fileContent=fileAccess::getFileContent($conf["fileAccess"]["getFileContent"]);
1647
		$fileContent=fileAccess::getFileContent($conf["fileAccess"]["getFileContent"]);
1648
		unset($conf["fileAccess"]["getFileContent"]);
1648
		unset($conf["fileAccess"]["getFileContent"]);
1649
 
1649
 
1650
		#如果取得檔案內容失敗
1650
		#如果取得檔案內容失敗
1651
		if($fileContent["status"]=="false"){
1651
		if($fileContent["status"]=="false"){
1652
			
1652
 
1653
			#設置執行失敗
1653
			#設置執行失敗
1654
			$result["status"]="false";
1654
			$result["status"]="false";
1655
			
1655
 
1656
			#設置執行錯誤訊息
1656
			#設置執行錯誤訊息
1657
			$result["error"]=$fileContent;
1657
			$result["error"]=$fileContent;
1658
 
1658
 
1659
			#回傳結果
1659
			#回傳結果
1660
			return $result;
1660
			return $result;
1661
			
1661
 
1662
			}#if end
1662
			}#if end
1663
 
1663
 
1664
		#迴圈,有幾行資料就執行幾次
1664
		#迴圈,有幾行資料就執行幾次
1665
		for($i=0;$i<$fileContent["lineCount"];$i++){
1665
		for($i=0;$i<$fileContent["lineCount"];$i++){
1666
 
1666
 
1667
			#將該行內容用逗號分隔
1667
			#將該行內容用逗號分隔
1668
			$conf["stringProcess"]["spiltString"]["stringIn"]=$fileContent["fileContent"][$i];#要處理的字串。
1668
			$conf["stringProcess"]["spiltString"]["stringIn"]=$fileContent["fileContent"][$i];#要處理的字串。
1669
			$conf["stringProcess"]["spiltString"]["spiltSymbol"]=$conf["spiltSign"];#爲以哪個符號作爲分割
1669
			$conf["stringProcess"]["spiltString"]["spiltSymbol"]=$conf["spiltSign"];#爲以哪個符號作爲分割
1670
			$lineSpiltResult[$i]=stringProcess::spiltString($conf["stringProcess"]["spiltString"]);
1670
			$lineSpiltResult[$i]=stringProcess::spiltString($conf["stringProcess"]["spiltString"]);
1671
			unset($conf["stringProcess"]["spiltString"]);	
1671
			unset($conf["stringProcess"]["spiltString"]);
1672
 
1672
 
1673
			#如果分割字串失敗
1673
			#如果分割字串失敗
1674
			if($lineSpiltResult[$i]["status"]=="false"){
1674
			if($lineSpiltResult[$i]["status"]=="false"){
1675
				
1675
 
1676
				#設置執行失敗
1676
				#設置執行失敗
1677
				$result["status"]="false";
1677
				$result["status"]="false";
1678
				
1678
 
1679
				#設置執行錯誤訊息
1679
				#設置執行錯誤訊息
1680
				$result["error"]=$lineSpiltResult[$i];
1680
				$result["error"]=$lineSpiltResult[$i];
1681
 
1681
 
1682
				#回傳結果
1682
				#回傳結果
1683
				return $result;
1683
				return $result;
1684
				
1684
 
1685
				}#if end
1685
				}#if end
1686
 
1686
 
1687
			}#for end
1687
			}#for end
1688
 
1688
 
1689
		#取得
1689
		#取得
Line 1692... Line 1692...
1692
		#取得資料的行數
1692
		#取得資料的行數
1693
		$result["lineCount"]=$fileContent["lineCount"];
1693
		$result["lineCount"]=$fileContent["lineCount"];
1694
 
1694
 
1695
		#回傳結果
1695
		#回傳結果
1696
		return $result;
1696
		return $result;
1697
	
1697
 
1698
		}#function getFileContentSpiltBySomething end
1698
		}#function getFileContentSpiltBySomething end
1699
 
1699
 
1700
	/*
1700
	/*
1701
	#函式說明:
1701
	#函式說明:
1702
	#檢查多個檔案與資料夾是否存在.
1702
	#檢查多個檔案與資料夾是否存在.
Line 1728... Line 1728...
1728
	#備註:
1728
	#備註:
1729
	#函數file_exists檢查的路徑為檔案系統的路徑
1729
	#函數file_exists檢查的路徑為檔案系統的路徑
1730
	#$result["varName"][$i]結果未實作
1730
	#$result["varName"][$i]結果未實作
1731
	*/
1731
	*/
1732
	public static function checkMultiFileExist(&$conf){
1732
	public static function checkMultiFileExist(&$conf){
1733
		
1733
 
1734
		#初始化要回傳的變數
1734
		#初始化要回傳的變數
1735
		$result=array();
1735
		$result=array();
1736
		
1736
 
1737
		#設置當前執行的涵式
1737
		#設置當前執行的涵式
1738
		$result["function"]=__FUNCTION__;
1738
		$result["function"]=__FUNCTION__;
1739
		
1739
 
1740
		#如果 $conf 不為陣列
1740
		#如果 $conf 不為陣列
1741
		if(gettype($conf)!="array"){
1741
		if(gettype($conf)!="array"){
1742
			
1742
 
1743
			#設置執行失敗
1743
			#設置執行失敗
1744
			$result["status"]="false";
1744
			$result["status"]="false";
1745
			
1745
 
1746
			#設置執行錯誤訊息
1746
			#設置執行錯誤訊息
1747
			$result["error"][]="\$conf變數須為陣列形態";
1747
			$result["error"][]="\$conf變數須為陣列形態";
1748
 
1748
 
1749
			#如果傳入的參數為 null
1749
			#如果傳入的參數為 null
1750
			if($conf==null){
1750
			if($conf==null){
1751
				
1751
 
1752
				#設置執行錯誤訊息
1752
				#設置執行錯誤訊息
1753
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1753
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1754
				
1754
 
1755
				}#if end
1755
				}#if end
1756
 
1756
 
1757
			#回傳結果
1757
			#回傳結果
1758
			return $result;
1758
			return $result;
1759
			
1759
 
1760
			}#if end
1760
			}#if end
1761
			
1761
 
1762
		#取得使用的參數
1762
		#取得使用的參數
1763
		$result["argu"]=$conf;
1763
		$result["argu"]=$conf;
1764
		
1764
 
1765
		#檢查參數
1765
		#檢查參數
1766
		#函式說明:
1766
		#函式說明:
1767
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
1767
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
1768
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1768
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1769
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
1769
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 1778... Line 1778...
1778
		#必填寫的參數:
1778
		#必填寫的參數:
1779
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
1779
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
1780
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
1780
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
1781
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
1781
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
1782
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArray","fileArgu");
1782
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArray","fileArgu");
1783
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
1783
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
1784
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");
1784
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");
1785
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
1785
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
1786
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
1786
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
1787
		#可以省略的參數:
1787
		#可以省略的參數:
1788
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
1788
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
1789
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1789
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1790
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1790
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1791
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("disableWebSearch","userDir","web");
1791
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("disableWebSearch","userDir","web");
1792
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
1792
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
1793
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
1793
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
1794
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1794
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1795
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true","true","true");
1795
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true","true","true");
1796
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1796
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1797
		#$conf["arrayCountEqualCheck"][]=array();
1797
		#$conf["arrayCountEqualCheck"][]=array();
Line 1800... Line 1800...
1800
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1800
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1801
		unset($conf["variableCheck::checkArguments"]);
1801
		unset($conf["variableCheck::checkArguments"]);
1802
 
1802
 
1803
		#如果 $checkArguments["status"] 等於 "false"
1803
		#如果 $checkArguments["status"] 等於 "false"
1804
		if($checkArguments["status"]=="false"){
1804
		if($checkArguments["status"]=="false"){
1805
			
1805
 
1806
			#設置錯誤識別
1806
			#設置錯誤識別
1807
			$result["status"]="false";
1807
			$result["status"]="false";
1808
			
1808
 
1809
			#設置錯誤訊息
1809
			#設置錯誤訊息
1810
			$result["error"]=$checkArguments;
1810
			$result["error"]=$checkArguments;
1811
			
1811
 
1812
			#回傳結果
1812
			#回傳結果
1813
			return $result;
1813
			return $result;
1814
			
1814
 
1815
			}#if end
1815
			}#if end
1816
			
1816
 
1817
		#如果 $checkArguments["passed"] 等於 "false"
1817
		#如果 $checkArguments["passed"] 等於 "false"
1818
		if($checkArguments["passed"]=="false"){
1818
		if($checkArguments["passed"]=="false"){
1819
			
1819
 
1820
			#設置錯誤識別
1820
			#設置錯誤識別
1821
			$result["status"]="false";
1821
			$result["status"]="false";
1822
			
1822
 
1823
			#設置錯誤訊息
1823
			#設置錯誤訊息
1824
			$result["error"]=$checkArguments;
1824
			$result["error"]=$checkArguments;
1825
			
1825
 
1826
			#回傳結果
1826
			#回傳結果
1827
			return $result;
1827
			return $result;
1828
			
1828
 
1829
			}#if end
1829
			}#if end
1830
		
1830
 
1831
		#初始化儲存每個檔案是否存在的陣列變數
1831
		#初始化儲存每個檔案是否存在的陣列變數
1832
		$result["varName"]=array();
1832
		$result["varName"]=array();
1833
		$result["varExist"]=array();
1833
		$result["varExist"]=array();
1834
 
1834
 
1835
		#針對每個要檢查的檔案
1835
		#針對每個要檢查的檔案
1836
		foreach($conf["fileArray"] as $i=>$varName){
1836
		foreach($conf["fileArray"] as $i=>$varName){
1837
		
1837
 
1838
			#儲存要判斷是否存在的物件
1838
			#儲存要判斷是否存在的物件
1839
			$result["varName"][]=$varName;
1839
			$result["varName"][]=$varName;
1840
			
1840
 
1841
			#函式說明:
1841
			#函式說明:
1842
			#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
1842
			#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
1843
			#回傳結果:
1843
			#回傳結果:
1844
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1844
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1845
			#$result["error"],錯誤訊息陣列.
1845
			#$result["error"],錯誤訊息陣列.
1846
			#$result["function"],函數名稱. 
1846
			#$result["function"],函數名稱.
1847
			#$result["argu"],使用的參數.
1847
			#$result["argu"],使用的參數.
1848
			#$result["content"],網址,若是在命令列執行,則為"null".
1848
			#$result["content"],網址,若是在命令列執行,則為"null".
1849
			#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
1849
			#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
1850
			#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
1850
			#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
1851
			#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
1851
			#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
Line 1858... Line 1858...
1858
			$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
1858
			$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
1859
			#備註:
1859
			#備註:
1860
			#建構中,fileSystemRelativePosition尚未實作.
1860
			#建構中,fileSystemRelativePosition尚未實作.
1861
			$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
1861
			$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
1862
			unset($conf["fileAccess::getInternetAddressV2"]);
1862
			unset($conf["fileAccess::getInternetAddressV2"]);
1863
			
1863
 
1864
			#如果轉換成絕對路徑失敗
1864
			#如果轉換成絕對路徑失敗
1865
			if($getInternetAddressV2["status"]=="false"){
1865
			if($getInternetAddressV2["status"]=="false"){
1866
				
1866
 
1867
				#設置錯誤識別
1867
				#設置錯誤識別
1868
				$result["status"]="false";
1868
				$result["status"]="false";
1869
				
1869
 
1870
				#設置錯誤訊息
1870
				#設置錯誤訊息
1871
				$result["error"]=$getInternetAddressV2;
1871
				$result["error"]=$getInternetAddressV2;
1872
				
1872
 
1873
				#回傳結果
1873
				#回傳結果
1874
				return $result;
1874
				return $result;
1875
				
1875
 
1876
				}#if end
1876
				}#if end
1877
			
1877
 
1878
			#傳參考
1878
			#傳參考
1879
			$getInternetAddress=&$getInternetAddressV2;
1879
			$getInternetAddress=&$getInternetAddressV2;
1880
		
1880
 
1881
			#如果沒有檔案的絕對路徑位置
1881
			#如果沒有檔案的絕對路徑位置
1882
			if(!isset($getInternetAddress["fileSystemAbsoulutePosition"])){
1882
			if(!isset($getInternetAddress["fileSystemAbsoulutePosition"])){
1883
				
1883
 
1884
				#置換成給予的參數網址
1884
				#置換成給予的參數網址
1885
				$conf["fileArray"][$i]=$getInternetAddress["content"];
1885
				$conf["fileArray"][$i]=$getInternetAddress["content"];
1886
				
1886
 
1887
				#設置無法從檔案系統找到
1887
				#設置無法從檔案系統找到
1888
				$exist=FALSE;
1888
				$exist=FALSE;
1889
				
1889
 
1890
				}#if end
1890
				}#if end
1891
			
1891
 
1892
			#反之取得
1892
			#反之取得
1893
			else{
1893
			else{
1894
				
1894
 
1895
				#轉換好的絕對路徑
1895
				#轉換好的絕對路徑
1896
				$conf["fileArray"][$i]=$getInternetAddress["fileSystemAbsoulutePosition"];
1896
				$conf["fileArray"][$i]=$getInternetAddress["fileSystemAbsoulutePosition"];
1897
				
1897
 
1898
				#無窮迴圈
1898
				#無窮迴圈
1899
				while(true){
1899
				while(true){
1900
				
1900
 
1901
					#判斷該檔案是否存在
1901
					#判斷該檔案是否存在
1902
					$exist=file_exists($conf["fileArray"][$i]);
1902
					$exist=file_exists($conf["fileArray"][$i]);
1903
				
1903
 
1904
					#如果不存在
1904
					#如果不存在
1905
					if($exist===false){
1905
					if($exist===false){
1906
					
1906
 
1907
						#無窮迴圈
1907
						#無窮迴圈
1908
						while(true){
1908
						while(true){
1909
						
1909
 
1910
							#當要檢查的目標是 link 時
1910
							#當要檢查的目標是 link 時
1911
							if(is_link($conf["fileArray"][$i])){
1911
							if(is_link($conf["fileArray"][$i])){
1912
							
1912
 
1913
								#取得link的路徑
1913
								#取得link的路徑
1914
								$conf["fileArray"][$i]=readlink($conf["fileArray"][$i]);
1914
								$conf["fileArray"][$i]=readlink($conf["fileArray"][$i]);
1915
								
1915
 
1916
								#結束連結的判斷,回到判斷目標是否存在的地方.
1916
								#結束連結的判斷,回到判斷目標是否存在的地方.
1917
								continue 2;
1917
								continue 2;
1918
								
1918
 
1919
								}#if end
1919
								}#if end
1920
							
1920
 
1921
							#結束連結的判斷
1921
							#結束連結的判斷
1922
							break;
1922
							break;
1923
							
1923
 
1924
							}#while end
1924
							}#while end
1925
						
1925
 
1926
						}#if end
1926
						}#if end
1927
						
1927
 
1928
					#結束到判斷目標是否存在
1928
					#結束到判斷目標是否存在
1929
					break;
1929
					break;
1930
				
1930
 
1931
					}#while end
1931
					}#while end
1932
				
1932
 
1933
				}#else end
1933
				}#else end
1934
			
1934
 
1935
			#如果 $exist 等於 false (檔案不存在) 且 沒有停用網路搜尋功能
1935
			#如果 $exist 等於 false (檔案不存在) 且 沒有停用網路搜尋功能
1936
			if($exist===FALSE && $conf["disableWebSearch"]==="false"){
1936
			if($exist===FALSE && $conf["disableWebSearch"]==="false"){
1937
 
1937
 
1938
				#將目標轉換成網址
1938
				#將目標轉換成網址
1939
				#函式說明:
1939
				#函式說明:
1940
				#將檔案的位置名稱變成網址
1940
				#將檔案的位置名稱變成網址
1941
				#回傳結果:
1941
				#回傳結果:
1942
				#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1942
				#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1943
				#$result["error"],錯誤訊息陣列.
1943
				#$result["error"],錯誤訊息陣列.
1944
				#$result["function"],函數名稱. 
1944
				#$result["function"],函數名稱.
1945
				#$result["content"],網址.
1945
				#$result["content"],網址.
1946
				#必填參數:
1946
				#必填參數:
1947
				#$conf["address"],字串,檔案的相對位置.
1947
				#$conf["address"],字串,檔案的相對位置.
1948
				$conf["fileAccess::getInternetAddress"]["address"]=$conf["fileArray"][$i];
1948
				$conf["fileAccess::getInternetAddress"]["address"]=$conf["fileArray"][$i];
1949
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
1949
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
Line 1951... Line 1951...
1951
				$getInternetAddress=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddress"]);
1951
				$getInternetAddress=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddress"]);
1952
				unset($conf["fileAccess::getInternetAddress"]);
1952
				unset($conf["fileAccess::getInternetAddress"]);
1953
 
1953
 
1954
				#如果轉換失敗
1954
				#如果轉換失敗
1955
				if($getInternetAddress["status"]=="false"){
1955
				if($getInternetAddress["status"]=="false"){
1956
					
1956
 
1957
					#設置錯誤識別
1957
					#設置錯誤識別
1958
					$result["status"]="false";
1958
					$result["status"]="false";
1959
					
1959
 
1960
					#設置錯誤訊息
1960
					#設置錯誤訊息
1961
					$result["error"]=$getInternetAddress;
1961
					$result["error"]=$getInternetAddress;
1962
					
1962
 
1963
					#回傳結果
1963
					#回傳結果
1964
					return $result;	
1964
					return $result;
1965
					
1965
 
1966
					}#if end
1966
					}#if end
1967
				
1967
 
1968
				#函式說明:
1968
				#函式說明:
1969
				#運行curl cmd
1969
				#運行curl cmd
1970
				#回傳結果:
1970
				#回傳結果:
1971
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1971
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1972
				#$result["error"],錯誤訊息陣列.
1972
				#$result["error"],錯誤訊息陣列.
Line 1997... Line 1997...
1997
				#$conf["cookie"]="";
1997
				#$conf["cookie"]="";
1998
				#$conf["forceNewCookie"],字串,是否要重置cookie,"true"代表要,"false"代表不要,預設為"false".
1998
				#$conf["forceNewCookie"],字串,是否要重置cookie,"true"代表要,"false"代表不要,預設為"false".
1999
				#$conf["forceNewCookie"]="";
1999
				#$conf["forceNewCookie"]="";
2000
				$curlCmd=catchWebContent::curlCmd($conf["catchWebContent::curlCmd"]);
2000
				$curlCmd=catchWebContent::curlCmd($conf["catchWebContent::curlCmd"]);
2001
				unset($conf["catchWebContent::curlCmd"]);
2001
				unset($conf["catchWebContent::curlCmd"]);
2002
				
2002
 
2003
				#如果抓取資料失敗
2003
				#如果抓取資料失敗
2004
				if($curlCmd["status"]==="false"){
2004
				if($curlCmd["status"]==="false"){
2005
				
2005
 
2006
					#設置錯誤識別
2006
					#設置錯誤識別
2007
					$result["status"]="false";
2007
					$result["status"]="false";
2008
					
2008
 
2009
					#設置錯誤訊息
2009
					#設置錯誤訊息
2010
					$result["error"]=$curlCmd;
2010
					$result["error"]=$curlCmd;
2011
					
2011
 
2012
					#回傳結果
2012
					#回傳結果
2013
					return $result;
2013
					return $result;
2014
				
2014
 
2015
					}#if end
2015
					}#if end
2016
				
2016
 
2017
				#反之檔案存在網路上
2017
				#反之檔案存在網路上
2018
				else{
2018
				else{
2019
					
2019
 
2020
					#將該檔案的路徑名稱與是否存在的訊息儲存到 $result 陣列變數裏面
2020
					#將該檔案的路徑名稱與是否存在的訊息儲存到 $result 陣列變數裏面
2021
					$result["varName"][$i]=$getInternetAddress["content"];
2021
					$result["varName"][$i]=$getInternetAddress["content"];
2022
					
2022
 
2023
					#如果存在檔案路徑的絕對位置
2023
					#如果存在檔案路徑的絕對位置
2024
					if(isset($getInternetAddress["fileSystemAbsoulutePosition"])){
2024
					if(isset($getInternetAddress["fileSystemAbsoulutePosition"])){
2025
						
2025
 
2026
						#設置該檔案的絕對路徑位置
2026
						#設置該檔案的絕對路徑位置
2027
						$result["varNameFullPath"][$i]=$getInternetAddress["fileSystemAbsoulutePosition"];
2027
						$result["varNameFullPath"][$i]=$getInternetAddress["fileSystemAbsoulutePosition"];
2028
						
2028
 
2029
						}#if end
2029
						}#if end
2030
					
2030
 
2031
					#反之代表輸入參數是網址	
2031
					#反之代表輸入參數是網址
2032
					else{
2032
					else{
2033
						
2033
 
2034
						#設置該檔案的網址
2034
						#設置該檔案的網址
2035
						$result["varNameWebPath"][$i]=$getInternetAddress["content"];
2035
						$result["varNameWebPath"][$i]=$getInternetAddress["content"];
2036
						
2036
 
2037
						}#else end
2037
						}#else end
2038
					
2038
 
2039
					#設置有無找到的識別
2039
					#設置有無找到的識別
2040
					$result["varExist"][$i]=$curlCmd["founded"];
2040
					$result["varExist"][$i]=$curlCmd["founded"];
2041
					
2041
 
2042
					}#else end
2042
					}#else end
2043
			
2043
 
2044
				}#if end
2044
				}#if end
2045
 
2045
 
2046
			#反之檔案不存在,且停用網路搜尋.
2046
			#反之檔案不存在,且停用網路搜尋.
2047
			else if($exist===FALSE){
2047
			else if($exist===FALSE){
2048
				
2048
 
2049
				#將該檔案的路徑名稱與是否存在的訊息儲存到 $result 陣列變數裏面
2049
				#將該檔案的路徑名稱與是否存在的訊息儲存到 $result 陣列變數裏面
2050
				$result["varName"][$i]=$conf["fileArray"][$i];
2050
				$result["varName"][$i]=$conf["fileArray"][$i];
2051
				$result["varNameFullPath"][$i]=$conf["fileArray"][$i];
2051
				$result["varNameFullPath"][$i]=$conf["fileArray"][$i];
2052
				$result["varExist"][$i]="false";
2052
				$result["varExist"][$i]="false";
2053
 
2053
 
2054
				#設置全部檔案都存在的識別變數為 "false"
2054
				#設置全部檔案都存在的識別變數為 "false"
2055
				$result["allExist"]="false";
2055
				$result["allExist"]="false";
2056
				
2056
 
2057
				}#if end
2057
				}#if end
2058
 
2058
 
2059
			#反之代表檔案存在
2059
			#反之代表檔案存在
2060
			else{
2060
			else{
2061
				
2061
 
2062
				#將該檔案的路徑名稱與是否存在的訊息儲存到 $result 陣列變數裏面
2062
				#將該檔案的路徑名稱與是否存在的訊息儲存到 $result 陣列變數裏面
2063
				$result["varNameFullPath"][$i]=$conf["fileArray"][$i];
2063
				$result["varNameFullPath"][$i]=$conf["fileArray"][$i];
2064
				
2064
 
2065
				#如果 web 參數為 "true"
2065
				#如果 web 參數為 "true"
2066
				if($conf["web"]==="true"){
2066
				if($conf["web"]==="true"){
2067
				
2067
 
2068
					#設置網路上的位置
2068
					#設置網路上的位置
2069
					$result["varNameWebPath"][$i]=$getInternetAddress["content"];
2069
					$result["varNameWebPath"][$i]=$getInternetAddress["content"];
2070
				
2070
 
2071
					}#if end
2071
					}#if end
2072
				
2072
 
2073
				$result["varExist"][$i]="true";
2073
				$result["varExist"][$i]="true";
2074
 
2074
 
2075
				}#else end
2075
				}#else end
2076
		
2076
 
2077
			}#foreach end
2077
			}#foreach end
2078
		
2078
 
2079
		#如果所有檔案與資料夾都找到的識別變數不存在
2079
		#如果所有檔案與資料夾都找到的識別變數不存在
2080
		if(!isset($result["allExist"])){
2080
		if(!isset($result["allExist"])){
2081
			
2081
 
2082
			#設置全部檔案與資料夾都有找到
2082
			#設置全部檔案與資料夾都有找到
2083
			$result["allExist"]="true";
2083
			$result["allExist"]="true";
2084
			
2084
 
2085
			}#if end
2085
			}#if end
2086
 
2086
 
2087
		#執行到這邊代表執行正常
2087
		#執行到這邊代表執行正常
2088
		$result["status"]="true";
2088
		$result["status"]="true";
2089
 
2089
 
Line 2119... Line 2119...
2119
	#無.
2119
	#無.
2120
	#備註:
2120
	#備註:
2121
	#如果要在/tmp底下建立檔案,若在apache環境下則會被作業系統特殊處理,即不等於實際上的路徑.
2121
	#如果要在/tmp底下建立檔案,若在apache環境下則會被作業系統特殊處理,即不等於實際上的路徑.
2122
	*/
2122
	*/
2123
	public static function createFileAfterCheck(&$conf){
2123
	public static function createFileAfterCheck(&$conf){
2124
		
2124
 
2125
		#初始化要回傳的結果
2125
		#初始化要回傳的結果
2126
		$result=array();
2126
		$result=array();
2127
		
2127
 
2128
		#設置當前執行的涵式
2128
		#設置當前執行的涵式
2129
		$result["function"]=__FUNCTION__;
2129
		$result["function"]=__FUNCTION__;
2130
		
2130
 
2131
		#如果 $conf 不為陣列
2131
		#如果 $conf 不為陣列
2132
		if(gettype($conf)!="array"){
2132
		if(gettype($conf)!="array"){
2133
			
2133
 
2134
			#設置執行失敗
2134
			#設置執行失敗
2135
			$result["status"]="false";
2135
			$result["status"]="false";
2136
			
2136
 
2137
			#設置執行錯誤訊息
2137
			#設置執行錯誤訊息
2138
			$result["error"][]="\$conf變數須為陣列形態";
2138
			$result["error"][]="\$conf變數須為陣列形態";
2139
 
2139
 
2140
			#如果傳入的參數為 null
2140
			#如果傳入的參數為 null
2141
			if($conf==null){
2141
			if($conf==null){
2142
				
2142
 
2143
				#設置執行錯誤訊息
2143
				#設置執行錯誤訊息
2144
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
2144
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
2145
				
2145
 
2146
				}#if end
2146
				}#if end
2147
 
2147
 
2148
			#回傳結果
2148
			#回傳結果
2149
			return $result;
2149
			return $result;
2150
			
2150
 
2151
			}#if end
2151
			}#if end
2152
		
2152
 
2153
		#取得參數
2153
		#取得參數
2154
		$result["argu"]=$conf;
2154
		$result["argu"]=$conf;
2155
		
2155
 
2156
		#檢查參數
2156
		#檢查參數
2157
		#函式說明:
2157
		#函式說明:
2158
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
2158
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
2159
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2159
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2160
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
2160
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 2169... Line 2169...
2169
		#必填寫的參數:
2169
		#必填寫的參數:
2170
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
2170
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
2171
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
2171
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
2172
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
2172
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
2173
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","checkedFileAndPath");
2173
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","checkedFileAndPath");
2174
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
2174
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
2175
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
2175
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
2176
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
2176
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
2177
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
2177
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
2178
		#可以省略的參數:
2178
		#可以省略的參數:
2179
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
2179
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
2180
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
2180
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
2181
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
2181
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
2182
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("filenameExtensionStartPoint","repeatNameRule","web");
2182
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("filenameExtensionStartPoint","repeatNameRule","web");
2183
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
2183
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
2184
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
2184
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
2185
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
2185
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
2186
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("1","(\$i)","false");
2186
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("1","(\$i)","false");
2187
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
2187
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
2188
		#$conf["arrayCountEqualCheck"][]=array();
2188
		#$conf["arrayCountEqualCheck"][]=array();
Line 2191... Line 2191...
2191
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2191
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2192
		unset($conf["variableCheck::checkArguments"]);
2192
		unset($conf["variableCheck::checkArguments"]);
2193
 
2193
 
2194
		#如果 $checkArguments["status"] 等於 "false"
2194
		#如果 $checkArguments["status"] 等於 "false"
2195
		if($checkArguments["status"]=="false"){
2195
		if($checkArguments["status"]=="false"){
2196
			
2196
 
2197
			#設置錯誤識別
2197
			#設置錯誤識別
2198
			$result["status"]="false";
2198
			$result["status"]="false";
2199
			
2199
 
2200
			#設置錯誤訊息
2200
			#設置錯誤訊息
2201
			$result["error"]=$checkArguments;
2201
			$result["error"]=$checkArguments;
2202
			
2202
 
2203
			#回傳結果
2203
			#回傳結果
2204
			return $result;				
2204
			return $result;
2205
			
2205
 
2206
			}#if end
2206
			}#if end
2207
			
2207
 
2208
		#如果 $checkArguments["passed"] 等於 "false"
2208
		#如果 $checkArguments["passed"] 等於 "false"
2209
		if($checkArguments["passed"]=="false"){
2209
		if($checkArguments["passed"]=="false"){
2210
			
2210
 
2211
			#設置錯誤識別
2211
			#設置錯誤識別
2212
			$result["status"]="false";
2212
			$result["status"]="false";
2213
			
2213
 
2214
			#設置錯誤訊息
2214
			#設置錯誤訊息
2215
			$result["error"]=$checkArguments;
2215
			$result["error"]=$checkArguments;
2216
			
2216
 
2217
			#回傳結果
2217
			#回傳結果
2218
			return $result;				
2218
			return $result;
2219
			
2219
 
2220
			}#if end	
2220
			}#if end
2221
				
2221
 
2222
		#確保要建立檔案的路徑
2222
		#確保要建立檔案的路徑
2223
		#函式說明:
2223
		#函式說明:
2224
		#確保路徑存在.
2224
		#確保路徑存在.
2225
		#回傳結果:
2225
		#回傳結果:
2226
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
2226
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 2228... Line 2228...
2228
		#$resutl["function"],當前執行的涵式名稱.
2228
		#$resutl["function"],當前執行的涵式名稱.
2229
		#$result["path"],建立好的路徑字串.
2229
		#$result["path"],建立好的路徑字串.
2230
		#$result["fileName"],檔案名稱,若 $conf["haveFileName"] 為 "true" 則會回傳.
2230
		#$result["fileName"],檔案名稱,若 $conf["haveFileName"] 為 "true" 則會回傳.
2231
		#必填參數:
2231
		#必填參數:
2232
		#$conf["path"],要檢查的路徑
2232
		#$conf["path"],要檢查的路徑
2233
		$conf["fileAccess::validatePath"]["path"]=$conf["checkedFileAndPath"];		
2233
		$conf["fileAccess::validatePath"]["path"]=$conf["checkedFileAndPath"];
2234
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2234
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2235
		$conf["fileAccess::validatePath"]["fileArgu"]=$conf["fileArgu"];
2235
		$conf["fileAccess::validatePath"]["fileArgu"]=$conf["fileArgu"];
2236
		#可省略參數:
2236
		#可省略參數:
2237
		#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
2237
		#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
2238
		$conf["fileAccess::validatePath"]["haveFileName"]="true";
2238
		$conf["fileAccess::validatePath"]["haveFileName"]="true";
2239
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
2239
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
2240
		#$conf["dirPermission"]="";
2240
		#$conf["dirPermission"]="";
2241
		$conf["fileAccess::validatePath"]["web"]=$conf["web"];
2241
		$conf["fileAccess::validatePath"]["web"]=$conf["web"];
2242
		$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
2242
		$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
2243
		unset($conf["fileAccess::validatePath"]);	
2243
		unset($conf["fileAccess::validatePath"]);
2244
			
2244
 
2245
		#debug
2245
		#debug
2246
		#var_dump($validatePath);
2246
		#var_dump($validatePath);
2247
		#exit;	
2247
		#exit;
2248
			
2248
 
2249
		#如果確保路徑失敗
2249
		#如果確保路徑失敗
2250
		if($validatePath["status"]==="false"){
2250
		if($validatePath["status"]==="false"){
2251
			
2251
 
2252
			#設置錯誤識別
2252
			#設置錯誤識別
2253
			$result["status"]="false";
2253
			$result["status"]="false";
2254
			
2254
 
2255
			#設置錯誤訊息
2255
			#設置錯誤訊息
2256
			$result["error"]=$validatePath;
2256
			$result["error"]=$validatePath;
2257
			
2257
 
2258
			#回傳結果
2258
			#回傳結果
2259
			return $result;
2259
			return $result;
2260
			
2260
 
2261
			}#if end
2261
			}#if end
2262
			
2262
 
2263
		#取得要建立的檔案名稱
2263
		#取得要建立的檔案名稱
2264
		$createdFileName=$validatePath["fileName"];
2264
		$createdFileName=$validatePath["fileName"];
2265
		
2265
 
2266
		#取得要建立的路徑			
2266
		#取得要建立的路徑
2267
		$createdFilePath=$validatePath["path"];
2267
		$createdFilePath=$validatePath["path"];
2268
							
2268
 
2269
		#透過無窮迴圈嘗試建立不同編號的檔案
2269
		#透過無窮迴圈嘗試建立不同編號的檔案
2270
		for($i=0;$i>-1;$i++){
2270
		for($i=0;$i>-1;$i++){
2271
			
2271
 
2272
			#如果 $i 為 0
2272
			#如果 $i 為 0
2273
			if($i==0){
2273
			if($i==0){
2274
				
2274
 
2275
				#檢查該檔案是否存在
2275
				#檢查該檔案是否存在
2276
				#函式說明:
2276
				#函式說明:
2277
				#檢查多個檔案與資料夾是否存在.
2277
				#檢查多個檔案與資料夾是否存在.
2278
				#回傳的結果:
2278
				#回傳的結果:
2279
				#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
2279
				#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
Line 2286... Line 2286...
2286
				#http://php.net/manual/en/function.file-exists.php
2286
				#http://php.net/manual/en/function.file-exists.php
2287
				#http://php.net/manual/en/control-structures.foreach.php
2287
				#http://php.net/manual/en/control-structures.foreach.php
2288
				$conf["fileAccess"]["checkMutiFileExist"]["web"]=$conf["web"];
2288
				$conf["fileAccess"]["checkMutiFileExist"]["web"]=$conf["web"];
2289
				$checkResult=fileAccess::checkMultiFileExist($conf["fileAccess"]["checkMutiFileExist"]);
2289
				$checkResult=fileAccess::checkMultiFileExist($conf["fileAccess"]["checkMutiFileExist"]);
2290
				unset($conf["fileAccess"]["checkMutiFileExist"]);
2290
				unset($conf["fileAccess"]["checkMutiFileExist"]);
2291
				
2291
 
2292
				#debug
2292
				#debug
2293
				#var_dump($checkResult);
2293
				#var_dump($checkResult);
2294
				#exit;
2294
				#exit;
2295
				
2295
 
2296
				#如果檢查檔案是否存在失敗
2296
				#如果檢查檔案是否存在失敗
2297
				if($checkResult["status"]=="false"){
2297
				if($checkResult["status"]=="false"){
2298
					
2298
 
2299
					#設置執行失敗
2299
					#設置執行失敗
2300
					$result["status"]="false";
2300
					$result["status"]="false";
2301
					
2301
 
2302
					#設置錯誤訊息
2302
					#設置錯誤訊息
2303
					$result["error"]=$checkResult;
2303
					$result["error"]=$checkResult;
2304
					
2304
 
2305
					#回傳結果
2305
					#回傳結果
2306
					return $result;
2306
					return $result;
2307
					
2307
 
2308
					}#if end
2308
					}#if end
2309
				
2309
 
2310
				#如果 $createFilePath.$createdFileName 檔案存在
2310
				#如果 $createFilePath.$createdFileName 檔案存在
2311
				if($checkResult["varExist"][0]=="true"){
2311
				if($checkResult["varExist"][0]=="true"){
2312
					
2312
 
2313
					#跳過這次迴圈
2313
					#跳過這次迴圈
2314
					continue;
2314
					continue;
2315
					
2315
 
2316
					}#if end
2316
					}#if end
2317
					
2317
 
2318
				#反之代表 $createFilePath.$createdFileName 檔案不存在
2318
				#反之代表 $createFilePath.$createdFileName 檔案不存在
2319
				else{
2319
				else{
2320
					
2320
 
2321
					#嘗試建立該檔案
2321
					#嘗試建立該檔案
2322
					#函式說明:
2322
					#函式說明:
2323
					#將字串寫入到檔案
2323
					#將字串寫入到檔案
2324
					#回傳結果:
2324
					#回傳結果:
2325
					#$result["status"],true表示檔案寫入成功,false表示檔案寫入失敗.
2325
					#$result["status"],true表示檔案寫入成功,false表示檔案寫入失敗.
Line 2331... Line 2331...
2331
					#可省略參數:
2331
					#可省略參數:
2332
					$conf["fileAccess"]["writeTextIntoFile"]["writeMethod"]="w";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
2332
					$conf["fileAccess"]["writeTextIntoFile"]["writeMethod"]="w";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
2333
					$conf["fileAccess"]["writeTextIntoFile"]["web"]=$conf["web"];
2333
					$conf["fileAccess"]["writeTextIntoFile"]["web"]=$conf["web"];
2334
					$fileCreateResult=fileAccess::writeTextIntoFile($conf["fileAccess"]["writeTextIntoFile"]);
2334
					$fileCreateResult=fileAccess::writeTextIntoFile($conf["fileAccess"]["writeTextIntoFile"]);
2335
					unset($conf["fileAccess"]["writeTextIntoFile"]);
2335
					unset($conf["fileAccess"]["writeTextIntoFile"]);
2336
						
2336
 
2337
					#如果 $fileCreateResult["status"] 等於 "true"
2337
					#如果 $fileCreateResult["status"] 等於 "true"
2338
					if($fileCreateResult["status"]=="true"){
2338
					if($fileCreateResult["status"]=="true"){
2339
						
2339
 
2340
						#代表檔案建立成功
2340
						#代表檔案建立成功
2341
						
2341
 
2342
						#更新建立的檔案名稱
2342
						#更新建立的檔案名稱
2343
						$result["createdFileName"]=$createdFileName;
2343
						$result["createdFileName"]=$createdFileName;
2344
						
2344
 
2345
						#設置新建立的檔案名稱與路徑
2345
						#設置新建立的檔案名稱與路徑
2346
						$result["createdFilePathAndName"]=$createdFilePath."/".$result["createdFileName"];
2346
						$result["createdFilePathAndName"]=$createdFilePath."/".$result["createdFileName"];
2347
		
2347
 
2348
						#設置新建立的檔與路徑
2348
						#設置新建立的檔與路徑
2349
						$result["createdFilePath"]=$createdFilePath;
2349
						$result["createdFilePath"]=$createdFilePath;
2350
							
2350
 
2351
						#跳出迴圈
2351
						#跳出迴圈
2352
						break;
2352
						break;
2353
							
2353
 
2354
						}#if end
2354
						}#if end
2355
						
2355
 
2356
					#反之代表檔案建立失敗
2356
					#反之代表檔案建立失敗
2357
					else{
2357
					else{
2358
						
2358
 
2359
						#設置錯誤識別
2359
						#設置錯誤識別
2360
						$result["status"]="false";
2360
						$result["status"]="false";
2361
						
2361
 
2362
						#設置錯誤訊息
2362
						#設置錯誤訊息
2363
						$result["error"]=$fileCreateResult;
2363
						$result["error"]=$fileCreateResult;
2364
						
2364
 
2365
						#回傳結果
2365
						#回傳結果
2366
						return $result;
2366
						return $result;
2367
						
2367
 
2368
						}#else end
2368
						}#else end
2369
					
2369
 
2370
					}#else end	
2370
					}#else end
2371
					
2371
 
2372
				}#if end
2372
				}#if end
2373
					
2373
 
2374
			#反之代表有相同檔名存在
2374
			#反之代表有相同檔名存在
2375
			else{					
2375
			else{
2376
				
2376
 
2377
				#用「.」分割檔案名稱
2377
				#用「.」分割檔案名稱
2378
				#函式說明:
2378
				#函式說明:
2379
				#將固定格式的字串分開,並回傳分開的結果。
2379
				#將固定格式的字串分開,並回傳分開的結果。
2380
				#回傳結果:
2380
				#回傳結果:
2381
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2381
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 2390... Line 2390...
2390
				$conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
2390
				$conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
2391
				#可省略參數:
2391
				#可省略參數:
2392
				#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
2392
				#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
2393
				$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
2393
				$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
2394
				$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
2394
				$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
2395
				unset($conf["stringProcess::spiltString"]);					
2395
				unset($conf["stringProcess::spiltString"]);
2396
				
2396
 
2397
				#如果分割檔案名稱失敗
2397
				#如果分割檔案名稱失敗
2398
				if($spiltString["status"]=="false"){
2398
				if($spiltString["status"]=="false"){
2399
					
2399
 
2400
					#設置執行失敗
2400
					#設置執行失敗
2401
					$result["status"]="false";
2401
					$result["status"]="false";
2402
					
2402
 
2403
					#設置錯誤訊息
2403
					#設置錯誤訊息
2404
					$result["error"]=$spiltString;
2404
					$result["error"]=$spiltString;
2405
					
2405
 
2406
					#回傳結果
2406
					#回傳結果
2407
					return $result;
2407
					return $result;
2408
					
2408
 
2409
					}#if end
2409
					}#if end
2410
				
2410
 
2411
				#初始化儲存建立的檔案名稱
2411
				#初始化儲存建立的檔案名稱
2412
				$createdFileName="";
2412
				$createdFileName="";
2413
				
2413
 
2414
				#初始化儲存編號的變數
2414
				#初始化儲存編號的變數
2415
				$no="";
2415
				$no="";
2416
				
2416
 
2417
				#如果沒有dot存在
2417
				#如果沒有dot存在
2418
				if($spiltString["found"]=="false"){
2418
				if($spiltString["found"]=="false"){
2419
					
2419
 
2420
					#解析 $conf["repeatNameRule"],用 \$i 分割.
2420
					#解析 $conf["repeatNameRule"],用 \$i 分割.
2421
					#函式說明:
2421
					#函式說明:
2422
					#將固定格式的字串分開,並回傳分開的結果。
2422
					#將固定格式的字串分開,並回傳分開的結果。
2423
					#回傳結果:
2423
					#回傳結果:
2424
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2424
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 2432... Line 2432...
2432
					$conf["stringProcess::spiltString"]["spiltSymbol"]="\$i";#爲以哪個符號作爲分割
2432
					$conf["stringProcess::spiltString"]["spiltSymbol"]="\$i";#爲以哪個符號作爲分割
2433
					#可省略參數:
2433
					#可省略參數:
2434
					#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
2434
					#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
2435
					$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
2435
					$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
2436
					$noString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
2436
					$noString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
2437
					unset($conf["stringProcess::spiltString"]);					
2437
					unset($conf["stringProcess::spiltString"]);
2438
					
2438
 
2439
					#如果分割檔案名稱失敗
2439
					#如果分割檔案名稱失敗
2440
					if($noString["status"]=="false"){
2440
					if($noString["status"]=="false"){
2441
						
2441
 
2442
						#設置執行失敗
2442
						#設置執行失敗
2443
						$result["status"]="false";
2443
						$result["status"]="false";
2444
						
2444
 
2445
						#設置錯誤訊息
2445
						#設置錯誤訊息
2446
						$result["error"]=$noString;
2446
						$result["error"]=$noString;
2447
						
2447
 
2448
						#回傳結果
2448
						#回傳結果
2449
						return $result;
2449
						return $result;
2450
						
2450
 
2451
						}#if end
2451
						}#if end
2452
						
2452
 
2453
					#如果 編號規則字串 分割出來的段數為2
2453
					#如果 編號規則字串 分割出來的段數為2
2454
					if($noString["dataCounts"]==2){
2454
					if($noString["dataCounts"]==2){
2455
						
2455
 
2456
						#組合編號
2456
						#組合編號
2457
						$no=$noString["dataArray"][0].$i.$noString["dataArray"][1];
2457
						$no=$noString["dataArray"][0].$i.$noString["dataArray"][1];
2458
						
2458
 
2459
						}#if end
2459
						}#if end
2460
					
2460
 
2461
					#反之 號規則字串 分割出來的段數為1
2461
					#反之 號規則字串 分割出來的段數為1
2462
					else if($noString["dataCounts"]==1){
2462
					else if($noString["dataCounts"]==1){
2463
						
2463
 
2464
						#判斷 "\$i" 在開頭或結尾
2464
						#判斷 "\$i" 在開頭或結尾
2465
						#函式說明:
2465
						#函式說明:
2466
						#取得關鍵字在字串的哪個位置
2466
						#取得關鍵字在字串的哪個位置
2467
						#回傳結果:
2467
						#回傳結果:
2468
						#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
2468
						#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
Line 2479... Line 2479...
2479
						$conf["search::findKeyWordPosition"]["keyWord"]="\$i";
2479
						$conf["search::findKeyWordPosition"]["keyWord"]="\$i";
2480
						#參考資料:
2480
						#參考資料:
2481
						#http://php.net/manual/en/function.strpos.php
2481
						#http://php.net/manual/en/function.strpos.php
2482
						$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
2482
						$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
2483
						unset($conf["search::findKeyWordPosition"]);
2483
						unset($conf["search::findKeyWordPosition"]);
2484
						
2484
 
2485
						#如果取得關鍵字位置失敗
2485
						#如果取得關鍵字位置失敗
2486
						if($findKeyWordPosition["status"]=="false"){
2486
						if($findKeyWordPosition["status"]=="false"){
2487
							
2487
 
2488
							#設置執行失敗
2488
							#設置執行失敗
2489
							$result["status"]="false";
2489
							$result["status"]="false";
2490
							
2490
 
2491
							#設置錯誤訊息
2491
							#設置錯誤訊息
2492
							$result["error"]=$findKeyWordPosition;
2492
							$result["error"]=$findKeyWordPosition;
2493
							
2493
 
2494
							#回傳結果
2494
							#回傳結果
2495
							return $result;
2495
							return $result;
2496
							
2496
 
2497
							}#if end
2497
							}#if end
2498
							
2498
 
2499
						#如果關鍵字在開頭
2499
						#如果關鍵字在開頭
2500
						if($findKeyWordPosition["head"]=="true"){
2500
						if($findKeyWordPosition["head"]=="true"){
2501
							
2501
 
2502
							#組合編號
2502
							#組合編號
2503
							$no=$i.$noString["dataArray"][0];
2503
							$no=$i.$noString["dataArray"][0];
2504
							
2504
 
2505
							}#if end
2505
							}#if end
2506
							
2506
 
2507
						#反之如果關鍵字在結尾
2507
						#反之如果關鍵字在結尾
2508
						else if($findKeyWordPosition["tail"]=="true"){
2508
						else if($findKeyWordPosition["tail"]=="true"){
2509
							
2509
 
2510
							#組合編號
2510
							#組合編號
2511
							$no=$noString["dataArray"][0].$i;
2511
							$no=$noString["dataArray"][0].$i;
2512
							
2512
 
2513
							}#if end
2513
							}#if end
2514
							
2514
 
2515
						#其他情況
2515
						#其他情況
2516
						else{
2516
						else{
2517
							
2517
 
2518
							#設置執行失敗
2518
							#設置執行失敗
2519
							$result["status"]="false";
2519
							$result["status"]="false";
2520
							
2520
 
2521
							#設置錯誤訊息
2521
							#設置錯誤訊息
2522
							$result["error"]=$findKeyWordPosition;
2522
							$result["error"]=$findKeyWordPosition;
2523
							
2523
 
2524
							#設置額外的錯誤訊息
2524
							#設置額外的錯誤訊息
2525
							$result["error"][]="非預期的結果";
2525
							$result["error"][]="非預期的結果";
2526
							
2526
 
2527
							#回傳結果
2527
							#回傳結果
2528
							return $result;
2528
							return $result;
2529
							
2529
 
2530
							}#else end
2530
							}#else end
2531
						
2531
 
2532
						}#if end
2532
						}#if end
2533
					
2533
 
2534
					#反之 編號規則字串 分割出來的段數為0
2534
					#反之 編號規則字串 分割出來的段數為0
2535
					else if($noString["dataCounts"]==0){
2535
					else if($noString["dataCounts"]==0){
2536
						
2536
 
2537
						#組合編號
2537
						#組合編號
2538
						$no=$j;
2538
						$no=$j;
2539
						
2539
 
2540
						}#if end
2540
						}#if end
2541
						
2541
 
2542
					#其他結果
2542
					#其他結果
2543
					else{
2543
					else{
2544
														
2544
 
2545
						#設置執行失敗
2545
						#設置執行失敗
2546
						$result["status"]="false";
2546
						$result["status"]="false";
2547
						
2547
 
2548
						#設置錯誤訊息
2548
						#設置錯誤訊息
2549
						$result["error"]=$noString;
2549
						$result["error"]=$noString;
2550
						
2550
 
2551
						#設置額外的錯誤訊息
2551
						#設置額外的錯誤訊息
2552
						$result["error"][]="非預期的結果";
2552
						$result["error"][]="非預期的結果";
2553
						
2553
 
2554
						#回傳結果
2554
						#回傳結果
2555
						return $result;
2555
						return $result;
2556
						
2556
 
2557
						}#else end	
2557
						}#else end
2558
					
2558
 
2559
					#串接編號到檔案名稱上
2559
					#串接編號到檔案名稱上
2560
					$createdFileName=$validatePath["fileName"].$no;
2560
					$createdFileName=$validatePath["fileName"].$no;
2561
					
2561
 
2562
					}#if end
2562
					}#if end
2563
				
2563
 
2564
				#反之有dot存在	
2564
				#反之有dot存在
2565
				else{
2565
				else{
2566
					
2566
 
2567
					#依據 $spiltString["dataCounts"] 值來組裝新的檔案名稱
2567
					#依據 $spiltString["dataCounts"] 值來組裝新的檔案名稱
2568
					for($j=0;$j<$spiltString["dataCounts"];$j++){
2568
					for($j=0;$j<$spiltString["dataCounts"];$j++){
2569
						
2569
 
2570
						#如果是副檔名的前一段內容
2570
						#如果是副檔名的前一段內容
2571
						if(($conf["filenameExtensionStartPoint"]+1)==($spiltString["dataCounts"]-$j)){
2571
						if(($conf["filenameExtensionStartPoint"]+1)==($spiltString["dataCounts"]-$j)){
2572
							
2572
 
2573
							#解析 $conf["repeatNameRule"],用 \$i 分割.
2573
							#解析 $conf["repeatNameRule"],用 \$i 分割.
2574
							#函式說明:
2574
							#函式說明:
2575
							#將固定格式的字串分開,並回傳分開的結果。
2575
							#將固定格式的字串分開,並回傳分開的結果。
2576
							#回傳結果:
2576
							#回傳結果:
2577
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2577
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 2585... Line 2585...
2585
							$conf["stringProcess::spiltString"]["spiltSymbol"]="\$i";#爲以哪個符號作爲分割
2585
							$conf["stringProcess::spiltString"]["spiltSymbol"]="\$i";#爲以哪個符號作爲分割
2586
							#可省略參數:
2586
							#可省略參數:
2587
							#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
2587
							#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
2588
							$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
2588
							$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
2589
							$noString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
2589
							$noString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
2590
							unset($conf["stringProcess::spiltString"]);					
2590
							unset($conf["stringProcess::spiltString"]);
2591
							
2591
 
2592
							#如果分割檔案名稱失敗
2592
							#如果分割檔案名稱失敗
2593
							if($noString["status"]=="false"){
2593
							if($noString["status"]=="false"){
2594
								
2594
 
2595
								#設置執行失敗
2595
								#設置執行失敗
2596
								$result["status"]="false";
2596
								$result["status"]="false";
2597
								
2597
 
2598
								#設置錯誤訊息
2598
								#設置錯誤訊息
2599
								$result["error"]=$noString;
2599
								$result["error"]=$noString;
2600
								
2600
 
2601
								#回傳結果
2601
								#回傳結果
2602
								return $result;
2602
								return $result;
2603
								
2603
 
2604
								}#if end
2604
								}#if end
2605
								
2605
 
2606
							#如果 編號規則字串 分割出來的段數為2
2606
							#如果 編號規則字串 分割出來的段數為2
2607
							if($noString["dataCounts"]==2){
2607
							if($noString["dataCounts"]==2){
2608
								
2608
 
2609
								#組合編號
2609
								#組合編號
2610
								$no=$noString["dataArray"][0].$i.$noString["dataArray"][1];
2610
								$no=$noString["dataArray"][0].$i.$noString["dataArray"][1];
2611
								
2611
 
2612
								}#if end
2612
								}#if end
2613
							
2613
 
2614
							#反之 號規則字串 分割出來的段數為1
2614
							#反之 號規則字串 分割出來的段數為1
2615
							else if($noString["dataCounts"]==1){
2615
							else if($noString["dataCounts"]==1){
2616
								
2616
 
2617
								#判斷 "\$i" 在開頭或結尾
2617
								#判斷 "\$i" 在開頭或結尾
2618
								#函式說明:
2618
								#函式說明:
2619
								#取得關鍵字在字串的哪個位置
2619
								#取得關鍵字在字串的哪個位置
2620
								#回傳結果:
2620
								#回傳結果:
2621
								#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
2621
								#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
Line 2632... Line 2632...
2632
								$conf["search::findKeyWordPosition"]["keyWord"]="\$i";
2632
								$conf["search::findKeyWordPosition"]["keyWord"]="\$i";
2633
								#參考資料:
2633
								#參考資料:
2634
								#http://php.net/manual/en/function.strpos.php
2634
								#http://php.net/manual/en/function.strpos.php
2635
								$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
2635
								$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
2636
								unset($conf["search::findKeyWordPosition"]);
2636
								unset($conf["search::findKeyWordPosition"]);
2637
								
2637
 
2638
								#如果取得關鍵字位置失敗
2638
								#如果取得關鍵字位置失敗
2639
								if($findKeyWordPosition["status"]=="false"){
2639
								if($findKeyWordPosition["status"]=="false"){
2640
									
2640
 
2641
									#設置執行失敗
2641
									#設置執行失敗
2642
									$result["status"]="false";
2642
									$result["status"]="false";
2643
									
2643
 
2644
									#設置錯誤訊息
2644
									#設置錯誤訊息
2645
									$result["error"]=$findKeyWordPosition;
2645
									$result["error"]=$findKeyWordPosition;
2646
									
2646
 
2647
									#回傳結果
2647
									#回傳結果
2648
									return $result;
2648
									return $result;
2649
									
2649
 
2650
									}#if end
2650
									}#if end
2651
									
2651
 
2652
								#如果關鍵字在開頭
2652
								#如果關鍵字在開頭
2653
								if($findKeyWordPosition["head"]=="true"){
2653
								if($findKeyWordPosition["head"]=="true"){
2654
									
2654
 
2655
									#組合編號
2655
									#組合編號
2656
									$no=$i.$noString["dataArray"][0];
2656
									$no=$i.$noString["dataArray"][0];
2657
									
2657
 
2658
									}#if end
2658
									}#if end
2659
									
2659
 
2660
								#反之如果關鍵字在結尾
2660
								#反之如果關鍵字在結尾
2661
								else if($findKeyWordPosition["tail"]=="true"){
2661
								else if($findKeyWordPosition["tail"]=="true"){
2662
									
2662
 
2663
									#組合編號
2663
									#組合編號
2664
									$no=$noString["dataArray"][0].$i;
2664
									$no=$noString["dataArray"][0].$i;
2665
									
2665
 
2666
									}#if end
2666
									}#if end
2667
									
2667
 
2668
								#其他情況
2668
								#其他情況
2669
								else{
2669
								else{
2670
									
2670
 
2671
									#設置執行失敗
2671
									#設置執行失敗
2672
									$result["status"]="false";
2672
									$result["status"]="false";
2673
									
2673
 
2674
									#設置錯誤訊息
2674
									#設置錯誤訊息
2675
									$result["error"]=$findKeyWordPosition;
2675
									$result["error"]=$findKeyWordPosition;
2676
									
2676
 
2677
									#設置額外的錯誤訊息
2677
									#設置額外的錯誤訊息
2678
									$result["error"][]="非預期的結果";
2678
									$result["error"][]="非預期的結果";
2679
									
2679
 
2680
									#回傳結果
2680
									#回傳結果
2681
									return $result;
2681
									return $result;
2682
									
2682
 
2683
									}#else end
2683
									}#else end
2684
								
2684
 
2685
								}#if end
2685
								}#if end
2686
							
2686
 
2687
							#反之 編號規則字串 分割出來的段數為0
2687
							#反之 編號規則字串 分割出來的段數為0
2688
							else if($noString["dataCounts"]==0){
2688
							else if($noString["dataCounts"]==0){
2689
								
2689
 
2690
								#組合編號
2690
								#組合編號
2691
								$no=$j;
2691
								$no=$j;
2692
								
2692
 
2693
								}#if end
2693
								}#if end
2694
								
2694
 
2695
							#其他結果
2695
							#其他結果
2696
							else{
2696
							else{
2697
																
-
 
-
 
2697
 
2698
								#設置執行失敗
2698
								#設置執行失敗
2699
								$result["status"]="false";
2699
								$result["status"]="false";
2700
								
2700
 
2701
								#設置錯誤訊息
2701
								#設置錯誤訊息
2702
								$result["error"]=$noString;
2702
								$result["error"]=$noString;
2703
								
2703
 
2704
								#設置額外的錯誤訊息
2704
								#設置額外的錯誤訊息
2705
								$result["error"][]="非預期的結果";
2705
								$result["error"][]="非預期的結果";
2706
								
2706
 
2707
								#回傳結果
2707
								#回傳結果
2708
								return $result;
2708
								return $result;
2709
								
2709
 
2710
								}#else end	
2710
								}#else end
2711
							
2711
 
2712
							#串接編號到檔案名稱上
2712
							#串接編號到檔案名稱上
2713
							$createdFileName=$createdFileName.$spiltString["dataArray"][$j].$no;
2713
							$createdFileName=$createdFileName.$spiltString["dataArray"][$j].$no;
2714
							
2714
 
2715
							#如果不是最後一段
2715
							#如果不是最後一段
2716
							if($j!=$spiltString["dataCounts"]-1){
2716
							if($j!=$spiltString["dataCounts"]-1){
2717
							
2717
 
2718
								#串接並加上 dot
2718
								#串接並加上 dot
2719
								$createdFileName=$createdFileName.".";
2719
								$createdFileName=$createdFileName.".";
2720
							
2720
 
2721
								}#if end
2721
								}#if end
2722
							
2722
 
2723
							}#if end
2723
							}#if end
2724
						
2724
 
2725
						#反之如果不是最後一段
2725
						#反之如果不是最後一段
2726
						else if($j!=$spiltString["dataCounts"]-1){
2726
						else if($j!=$spiltString["dataCounts"]-1){
2727
							
2727
 
2728
							#串接並加上 dot
2728
							#串接並加上 dot
2729
							$createdFileName=$createdFileName.$spiltString["dataArray"][$j].".";
2729
							$createdFileName=$createdFileName.$spiltString["dataArray"][$j].".";
2730
							
2730
 
2731
							}#if end
2731
							}#if end
2732
						
2732
 
2733
						#反之是最後一段	
2733
						#反之是最後一段
2734
						else{
2734
						else{
2735
							
2735
 
2736
							#串接並加上 dot
2736
							#串接並加上 dot
2737
							$createdFileName=$createdFileName.$spiltString["dataArray"][$j];
2737
							$createdFileName=$createdFileName.$spiltString["dataArray"][$j];
2738
							
2738
 
2739
							}#else end
2739
							}#else end
2740
						
2740
 
2741
						}#for end
2741
						}#for end
2742
					
2742
 
2743
					}#else end
2743
					}#else end
2744
				
2744
 
2745
				#檢查加上編號的檔案是否存在
2745
				#檢查加上編號的檔案是否存在
2746
				#函式說明:
2746
				#函式說明:
2747
				#檢查多個檔案與資料夾是否存在.
2747
				#檢查多個檔案與資料夾是否存在.
2748
				#回傳的結果:
2748
				#回傳的結果:
2749
				#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
2749
				#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
Line 2755... Line 2755...
2755
				#http://php.net/manual/en/function.file-exists.php
2755
				#http://php.net/manual/en/function.file-exists.php
2756
				#http://php.net/manual/en/control-structures.foreach.php
2756
				#http://php.net/manual/en/control-structures.foreach.php
2757
				$conf["fileAccess"]["checkMutiFileExist"]["web"]=$conf["web"];
2757
				$conf["fileAccess"]["checkMutiFileExist"]["web"]=$conf["web"];
2758
				$checkResult=fileAccess::checkMultiFileExist($conf["fileAccess"]["checkMutiFileExist"]);
2758
				$checkResult=fileAccess::checkMultiFileExist($conf["fileAccess"]["checkMutiFileExist"]);
2759
				unset($conf["fileAccess"]["checkMutiFileExist"]);
2759
				unset($conf["fileAccess"]["checkMutiFileExist"]);
2760
				
2760
 
2761
				#如果檢查檔案是否存在失敗
2761
				#如果檢查檔案是否存在失敗
2762
				if($checkResult["status"]=="false"){
2762
				if($checkResult["status"]=="false"){
2763
					
2763
 
2764
					#設置執行失敗
2764
					#設置執行失敗
2765
					$result["status"]="false";
2765
					$result["status"]="false";
2766
					
2766
 
2767
					#設置錯誤訊息
2767
					#設置錯誤訊息
2768
					$result["error"]=$checkResult;
2768
					$result["error"]=$checkResult;
2769
					
2769
 
2770
					#回傳結果
2770
					#回傳結果
2771
					return $result;
2771
					return $result;
2772
					
2772
 
2773
					}#if end						
2773
					}#if end
2774
				
2774
 
2775
				#如果 $checkResult["varExist"][0] 等於 "true"
2775
				#如果 $checkResult["varExist"][0] 等於 "true"
2776
				if($checkResult["varExist"][0]=="true"){						
2776
				if($checkResult["varExist"][0]=="true"){
2777
					
2777
 
2778
					#取得要建立的檔案名稱
2778
					#取得要建立的檔案名稱
2779
					$createdFileName=$validatePath["fileName"];
2779
					$createdFileName=$validatePath["fileName"];
2780
					
2780
 
2781
					#跳到下個迴圈
2781
					#跳到下個迴圈
2782
					continue;
2782
					continue;
2783
					
2783
 
2784
					}#if end
2784
					}#if end
2785
					
2785
 
2786
				#反之代表 $createFilePath.$createdFileName."(".$i.")" 檔檔案不存在
2786
				#反之代表 $createFilePath.$createdFileName."(".$i.")" 檔檔案不存在
2787
				else{
2787
				else{
2788
				
2788
 
2789
					#嘗試建立該檔案
2789
					#嘗試建立該檔案
2790
					#函式說明:
2790
					#函式說明:
2791
					#將字串寫入到檔案
2791
					#將字串寫入到檔案
2792
					#回傳結果:
2792
					#回傳結果:
2793
					#$result["status"],true表示檔案寫入成功,false表示檔案寫入失敗.
2793
					#$result["status"],true表示檔案寫入成功,false表示檔案寫入失敗.
Line 2799... Line 2799...
2799
					#可省略參數:
2799
					#可省略參數:
2800
					$conf["fileAccess"]["writeTextIntoFile"]["writeMethod"]="w";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
2800
					$conf["fileAccess"]["writeTextIntoFile"]["writeMethod"]="w";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
2801
					$conf["fileAccess"]["writeTextIntoFile"]["web"]=$conf["web"];
2801
					$conf["fileAccess"]["writeTextIntoFile"]["web"]=$conf["web"];
2802
					$fileCreateResult=fileAccess::writeTextIntoFile($conf["fileAccess"]["writeTextIntoFile"]);
2802
					$fileCreateResult=fileAccess::writeTextIntoFile($conf["fileAccess"]["writeTextIntoFile"]);
2803
					unset($conf["fileAccess"]["writeTextIntoFile"]);
2803
					unset($conf["fileAccess"]["writeTextIntoFile"]);
2804
						
2804
 
2805
					#如果 $fileCreateResult["status"] 等於 "true"
2805
					#如果 $fileCreateResult["status"] 等於 "true"
2806
					if($fileCreateResult["status"]=="true"){
2806
					if($fileCreateResult["status"]=="true"){
2807
							
2807
 
2808
						#代表檔案建立成功
2808
						#代表檔案建立成功
2809
								
2809
 
2810
						#更新建立的檔案名稱
2810
						#更新建立的檔案名稱
2811
						$result["createdFileName"]=$createdFileName;
2811
						$result["createdFileName"]=$createdFileName;
2812
							
2812
 
2813
						#跳出迴圈
2813
						#跳出迴圈
2814
						break;
2814
						break;
2815
							
2815
 
2816
						}#if end
2816
						}#if end
2817
							
2817
 
2818
					#反之代表檔案建立失敗
2818
					#反之代表檔案建立失敗
2819
					else{
2819
					else{
2820
							
2820
 
2821
						#設置錯誤識別
2821
						#設置錯誤識別
2822
						$result["status"]="false";
2822
						$result["status"]="false";
2823
						
2823
 
2824
						#設置錯誤訊息
2824
						#設置錯誤訊息
2825
						$result["error"]=$fileCreateResult;
2825
						$result["error"]=$fileCreateResult;
2826
							
2826
 
2827
						#回傳結果
2827
						#回傳結果
2828
						return $result;
2828
						return $result;
2829
							
2829
 
2830
						}#else end
2830
						}#else end
2831
						
2831
 
2832
					}#else end
2832
					}#else end
2833
					
2833
 
2834
				}#else end
2834
				}#else end
2835
			
2835
 
2836
			}#for end
2836
			}#for end
2837
			
2837
 
2838
		#如果不存在建立的檔案名稱
2838
		#如果不存在建立的檔案名稱
2839
		if(!isset($result["createdFileName"])){
2839
		if(!isset($result["createdFileName"])){
2840
			
2840
 
2841
			#設置錯誤識別
2841
			#設置錯誤識別
2842
			$result["status"]="false";
2842
			$result["status"]="false";
2843
			
2843
 
2844
			#設置錯誤訊息
2844
			#設置錯誤訊息
2845
			$result["error"][]="建立的檔案名稱不存在";
2845
			$result["error"][]="建立的檔案名稱不存在";
2846
				
2846
 
2847
			#回傳結果
2847
			#回傳結果
2848
			return $result;
2848
			return $result;
2849
			
2849
 
2850
			}#if end	
2850
			}#if end
2851
			
2851
 
2852
		#執行到這邊代表執行成功
2852
		#執行到這邊代表執行成功
2853
		$result["status"]="true";
2853
		$result["status"]="true";
2854
		
2854
 
2855
		#設置新建立的檔案名稱與路徑
2855
		#設置新建立的檔案名稱與路徑
2856
		$result["createdFilePathAndName"]=$createdFilePath."/".$result["createdFileName"];
2856
		$result["createdFilePathAndName"]=$createdFilePath."/".$result["createdFileName"];
2857
		
2857
 
2858
		#設置新建立的檔與路徑
2858
		#設置新建立的檔與路徑
2859
		$result["createdFilePath"]=$createdFilePath;
2859
		$result["createdFilePath"]=$createdFilePath;
2860
		
2860
 
2861
		#回傳結果
2861
		#回傳結果
2862
		return $result;
2862
		return $result;
2863
		
2863
 
2864
		}#fucntion createFileAfterCheck end
2864
		}#fucntion createFileAfterCheck end
2865
 
2865
 
2866
	/*
2866
	/*
2867
	#函式說明:
2867
	#函式說明:
2868
	#將檔案內容清空
2868
	#將檔案內容清空
Line 2881... Line 2881...
2881
	#無.
2881
	#無.
2882
	#備註:
2882
	#備註:
2883
	#無.
2883
	#無.
2884
	*/
2884
	*/
2885
	public static function emptyFile(&$conf){
2885
	public static function emptyFile(&$conf){
2886
	
2886
 
2887
		#初始化要回傳的結果
2887
		#初始化要回傳的結果
2888
		$result=array();
2888
		$result=array();
2889
		
2889
 
2890
		#設置當前執行的涵式
2890
		#設置當前執行的涵式
2891
		$result["function"]=__FUNCTION__;
2891
		$result["function"]=__FUNCTION__;
2892
		
2892
 
2893
		#如果 $conf 不為陣列
2893
		#如果 $conf 不為陣列
2894
		if(gettype($conf)!="array"){
2894
		if(gettype($conf)!="array"){
2895
			
2895
 
2896
			#設置執行失敗
2896
			#設置執行失敗
2897
			$result["status"]="false";
2897
			$result["status"]="false";
2898
			
2898
 
2899
			#設置執行錯誤訊息
2899
			#設置執行錯誤訊息
2900
			$result["error"][]="\$conf變數須為陣列形態";
2900
			$result["error"][]="\$conf變數須為陣列形態";
2901
 
2901
 
2902
			#如果傳入的參數為 null
2902
			#如果傳入的參數為 null
2903
			if($conf==null){
2903
			if($conf==null){
2904
				
2904
 
2905
				#設置執行錯誤訊息
2905
				#設置執行錯誤訊息
2906
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
2906
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
2907
				
2907
 
2908
				}#if end
2908
				}#if end
2909
 
2909
 
2910
			#回傳結果
2910
			#回傳結果
2911
			return $result;
2911
			return $result;
2912
			
2912
 
2913
			}#if end
2913
			}#if end
2914
		
2914
 
2915
		#取得參數
2915
		#取得參數
2916
		$result["argu"]=$conf;
2916
		$result["argu"]=$conf;
2917
		
2917
 
2918
		#檢查參數
2918
		#檢查參數
2919
		#函式說明:
2919
		#函式說明:
2920
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
2920
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
2921
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2921
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2922
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
2922
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 2931... Line 2931...
2931
		#必填寫的參數:
2931
		#必填寫的參數:
2932
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
2932
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
2933
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
2933
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
2934
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
2934
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
2935
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileAddr");
2935
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileAddr");
2936
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
2936
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
2937
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
2937
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
2938
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
2938
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
2939
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
2939
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
2940
		#可以省略的參數:
2940
		#可以省略的參數:
2941
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
2941
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
2942
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
2942
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
2943
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
2943
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
2944
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
2944
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
2945
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
2945
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
2946
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
2946
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
2947
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
2947
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
2948
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
2948
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
2949
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
2949
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
2950
		#$conf["arrayCountEqualCheck"][]=array();
2950
		#$conf["arrayCountEqualCheck"][]=array();
Line 2953... Line 2953...
2953
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2953
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2954
		unset($conf["variableCheck::checkArguments"]);
2954
		unset($conf["variableCheck::checkArguments"]);
2955
 
2955
 
2956
		#如果 $checkArguments["status"] 等於 "false"
2956
		#如果 $checkArguments["status"] 等於 "false"
2957
		if($checkArguments["status"]=="false"){
2957
		if($checkArguments["status"]=="false"){
2958
			
2958
 
2959
			#設置錯誤識別
2959
			#設置錯誤識別
2960
			$result["status"]="false";
2960
			$result["status"]="false";
2961
			
2961
 
2962
			#設置錯誤訊息
2962
			#設置錯誤訊息
2963
			$result["error"]=$checkArguments;
2963
			$result["error"]=$checkArguments;
2964
			
2964
 
2965
			#回傳結果
2965
			#回傳結果
2966
			return $result;				
2966
			return $result;
2967
			
2967
 
2968
			}#if end
2968
			}#if end
2969
			
2969
 
2970
		#如果 $checkArguments["passed"] 等於 "false"
2970
		#如果 $checkArguments["passed"] 等於 "false"
2971
		if($checkArguments["passed"]=="false"){
2971
		if($checkArguments["passed"]=="false"){
2972
			
2972
 
2973
			#設置錯誤識別
2973
			#設置錯誤識別
2974
			$result["status"]="false";
2974
			$result["status"]="false";
2975
			
2975
 
2976
			#設置錯誤訊息
2976
			#設置錯誤訊息
2977
			$result["error"]=$checkArguments;
2977
			$result["error"]=$checkArguments;
2978
			
2978
 
2979
			#回傳結果
2979
			#回傳結果
2980
			return $result;				
2980
			return $result;
2981
			
2981
 
2982
			}#if end	
2982
			}#if end
2983
			
2983
 
2984
		#函式說明:
2984
		#函式說明:
2985
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
2985
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
2986
		#回傳結果:
2986
		#回傳結果:
2987
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
2987
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
2988
		#$result["error"],錯誤訊息陣列.
2988
		#$result["error"],錯誤訊息陣列.
2989
		#$result["function"],函數名稱. 
2989
		#$result["function"],函數名稱.
2990
		#$result["argu"],使用的參數.
2990
		#$result["argu"],使用的參數.
2991
		#$result["content"],網址,若是在命令列執行,則為"null".
2991
		#$result["content"],網址,若是在命令列執行,則為"null".
2992
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
2992
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
2993
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
2993
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
2994
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
2994
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
Line 3002... Line 3002...
3002
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
3002
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
3003
		#備註:
3003
		#備註:
3004
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
3004
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
3005
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
3005
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
3006
		unset($conf["fileAccess::getInternetAddressV2"]);
3006
		unset($conf["fileAccess::getInternetAddressV2"]);
3007
			
3007
 
3008
		#如果確保路徑失敗
3008
		#如果確保路徑失敗
3009
		if($getInternetAddressV2["status"]==="false"){
3009
		if($getInternetAddressV2["status"]==="false"){
3010
			
3010
 
3011
			#設置錯誤識別
3011
			#設置錯誤識別
3012
			$result["status"]="false";
3012
			$result["status"]="false";
3013
			
3013
 
3014
			#設置錯誤訊息
3014
			#設置錯誤訊息
3015
			$result["error"]=$getInternetAddressV2;
3015
			$result["error"]=$getInternetAddressV2;
3016
			
3016
 
3017
			#回傳結果
3017
			#回傳結果
3018
			return $result;
3018
			return $result;
3019
			
3019
 
3020
			}#if end
3020
			}#if end
3021
		
3021
 
3022
		#更新檔案路徑
3022
		#更新檔案路徑
3023
		$conf["fileAddr"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
3023
		$conf["fileAddr"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
3024
		
3024
 
3025
		#確保要建立檔案的路徑
3025
		#確保要建立檔案的路徑
3026
		#函式說明:
3026
		#函式說明:
3027
		#確保路徑存在.
3027
		#確保路徑存在.
3028
		#回傳結果:
3028
		#回傳結果:
3029
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
3029
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 3031... Line 3031...
3031
		#$resutl["function"],當前執行的涵式名稱.
3031
		#$resutl["function"],當前執行的涵式名稱.
3032
		#$result["path"],建立好的路徑字串.
3032
		#$result["path"],建立好的路徑字串.
3033
		#$result["fileName"],檔案名稱,若 $conf["haveFileName"] 為 "true" 則會回傳.
3033
		#$result["fileName"],檔案名稱,若 $conf["haveFileName"] 為 "true" 則會回傳.
3034
		#必填參數:
3034
		#必填參數:
3035
		#$conf["path"],要檢查的路徑
3035
		#$conf["path"],要檢查的路徑
3036
		$conf["fileAccess::validatePath"]["path"]=$conf["fileAddr"];		
3036
		$conf["fileAccess::validatePath"]["path"]=$conf["fileAddr"];
3037
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3037
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3038
		$conf["fileAccess::validatePath"]["fileArgu"]=$conf["fileArgu"];
3038
		$conf["fileAccess::validatePath"]["fileArgu"]=$conf["fileArgu"];
3039
		#可省略參數:
3039
		#可省略參數:
3040
		#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
3040
		#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
3041
		$conf["fileAccess::validatePath"]["haveFileName"]="true";
3041
		$conf["fileAccess::validatePath"]["haveFileName"]="true";
3042
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
3042
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
3043
		#$conf["dirPermission"]="";
3043
		#$conf["dirPermission"]="";
3044
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
3044
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
3045
		$conf["fileAccess::validatePath"]["web"]="false";
3045
		$conf["fileAccess::validatePath"]["web"]="false";
3046
		$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
3046
		$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
3047
		unset($conf["fileAccess::validatePath"]);	
3047
		unset($conf["fileAccess::validatePath"]);
3048
			
3048
 
3049
		#如果確保路徑失敗
3049
		#如果確保路徑失敗
3050
		if($validatePath["status"]==="false"){
3050
		if($validatePath["status"]==="false"){
3051
			
3051
 
3052
			#設置錯誤識別
3052
			#設置錯誤識別
3053
			$result["status"]="false";
3053
			$result["status"]="false";
3054
			
3054
 
3055
			#設置錯誤訊息
3055
			#設置錯誤訊息
3056
			$result["error"]=$validatePath;
3056
			$result["error"]=$validatePath;
3057
			
3057
 
3058
			#回傳結果
3058
			#回傳結果
3059
			return $result;
3059
			return $result;
3060
			
3060
 
3061
			}#if end
3061
			}#if end
3062
	
3062
 
3063
		#清空檔案
3063
		#清空檔案
3064
		#函式說明:
3064
		#函式說明:
3065
		#將字串寫入到檔案
3065
		#將字串寫入到檔案
3066
		#回傳結果:
3066
		#回傳結果:
3067
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
3067
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
Line 3091... Line 3091...
3091
		#$conf["repeatNameRule"]="";
3091
		#$conf["repeatNameRule"]="";
3092
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
3092
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
3093
		$conf["fileAccess::writeTextIntoFile"]["web"]="false";
3093
		$conf["fileAccess::writeTextIntoFile"]["web"]="false";
3094
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
3094
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
3095
		unset($conf["fileAccess::writeTextIntoFile"]);
3095
		unset($conf["fileAccess::writeTextIntoFile"]);
3096
					
3096
 
3097
		#如果確保路徑失敗
3097
		#如果確保路徑失敗
3098
		if($writeTextIntoFile["status"]==="false"){
3098
		if($writeTextIntoFile["status"]==="false"){
3099
			
3099
 
3100
			#設置錯誤識別
3100
			#設置錯誤識別
3101
			$result["status"]="false";
3101
			$result["status"]="false";
3102
			
3102
 
3103
			#設置錯誤訊息
3103
			#設置錯誤訊息
3104
			$result["error"]=$writeTextIntoFile;
3104
			$result["error"]=$writeTextIntoFile;
3105
			
3105
 
3106
			#回傳結果
3106
			#回傳結果
3107
			return $result;
3107
			return $result;
3108
			
3108
 
3109
			}#if end
3109
			}#if end
3110
			
3110
 
3111
		#設置執行正常
3111
		#設置執行正常
3112
		$result["status"]="true";
3112
		$result["status"]="true";
3113
		
3113
 
3114
		#儲存建立的結果
3114
		#儲存建立的結果
3115
		$result["content"]=$writeTextIntoFile;
3115
		$result["content"]=$writeTextIntoFile;
3116
		
3116
 
3117
		#回傳結果
3117
		#回傳結果
3118
		return $result;
3118
		return $result;
3119
		
3119
 
3120
		}#function emptyFile end
3120
		}#function emptyFile end
3121
 
3121
 
3122
	/*
3122
	/*
3123
	#函式說明:
3123
	#函式說明:
3124
	#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
3124
	#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
Line 3162... Line 3162...
3162
		*/
3162
		*/
3163
		return fileAccess::createFolderAfterCheck($conf);
3163
		return fileAccess::createFolderAfterCheck($conf);
3164
		unset($conf);
3164
		unset($conf);
3165
 
3165
 
3166
		}#function createNewFolder end
3166
		}#function createNewFolder end
3167
		
3167
 
3168
	/*
3168
	/*
3169
	#函式說明:
3169
	#函式說明:
3170
	#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
3170
	#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
3171
	#回傳結果:
3171
	#回傳結果:
3172
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
3172
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
Line 3189... Line 3189...
3189
	#chmod=>http://php.net/manual/en/function.chmod.php
3189
	#chmod=>http://php.net/manual/en/function.chmod.php
3190
	#備註:
3190
	#備註:
3191
	#無.
3191
	#無.
3192
	*/
3192
	*/
3193
	public static function createFolderAfterCheck(&$conf){
3193
	public static function createFolderAfterCheck(&$conf){
3194
		
3194
 
3195
		#初始化要回傳的結果
3195
		#初始化要回傳的結果
3196
		$result=array();
3196
		$result=array();
3197
		
3197
 
3198
		#初始化警告訊息陣列
3198
		#初始化警告訊息陣列
3199
		$result["warning"]=array();
3199
		$result["warning"]=array();
3200
		
3200
 
3201
		#記錄當前執行的函數名稱
3201
		#記錄當前執行的函數名稱
3202
		$result["function"]=__FUNCTION__;
3202
		$result["function"]=__FUNCTION__;
3203
		
3203
 
3204
		#如果 $conf 不為陣列
3204
		#如果 $conf 不為陣列
3205
		if(gettype($conf)!="array"){
3205
		if(gettype($conf)!="array"){
3206
			
3206
 
3207
			#設置執行失敗
3207
			#設置執行失敗
3208
			$result["status"]="false";
3208
			$result["status"]="false";
3209
			
3209
 
3210
			#設置執行錯誤訊息
3210
			#設置執行錯誤訊息
3211
			$result["error"][]="\$conf變數須為陣列形態";
3211
			$result["error"][]="\$conf變數須為陣列形態";
3212
 
3212
 
3213
			#如果傳入的參數為 null
3213
			#如果傳入的參數為 null
3214
			if($conf==null){
3214
			if($conf==null){
3215
				
3215
 
3216
				#設置執行錯誤訊息
3216
				#設置執行錯誤訊息
3217
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3217
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3218
				
3218
 
3219
				}#if end
3219
				}#if end
3220
 
3220
 
3221
			#回傳結果
3221
			#回傳結果
3222
			return $result;
3222
			return $result;
3223
			
3223
 
3224
			}#if end
3224
			}#if end
3225
		
3225
 
3226
		#取得參數
3226
		#取得參數
3227
		$result["argu"]=$conf;
3227
		$result["argu"]=$conf;
3228
		
3228
 
3229
		#檢查參數
3229
		#檢查參數
3230
		#函式說明:
3230
		#函式說明:
3231
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
3231
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
3232
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3232
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3233
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
3233
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 3242... Line 3242...
3242
		#必填寫的參數:
3242
		#必填寫的參數:
3243
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
3243
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
3244
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
3244
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
3245
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
3245
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
3246
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","dirPositionAndName");
3246
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","dirPositionAndName");
3247
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
3247
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
3248
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
3248
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
3249
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
3249
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
3250
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
3250
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
3251
		#可以省略的參數:
3251
		#可以省略的參數:
3252
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
3252
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
3253
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
3253
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
3254
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3254
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3255
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("dirPermission","web");
3255
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("dirPermission","web");
3256
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
3256
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
3257
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
3257
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
3258
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3258
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3259
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("0770","false");
3259
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("0770","false");
3260
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3260
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3261
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
3261
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
3262
		#參考資料來源:
3262
		#參考資料來源:
3263
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3263
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3264
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3264
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3265
		unset($conf["variableCheck::checkArguments"]);
3265
		unset($conf["variableCheck::checkArguments"]);
3266
							
3266
 
3267
		#如果 $checkArguments["status"] 等於 "false"
3267
		#如果 $checkArguments["status"] 等於 "false"
3268
		if($checkArguments["status"]==="false"){
3268
		if($checkArguments["status"]==="false"){
3269
			
3269
 
3270
			#設置 $result["status"] 為 "false"
3270
			#設置 $result["status"] 為 "false"
3271
			$result["status"]="false";
3271
			$result["status"]="false";
3272
			
3272
 
3273
			#設置 $result["error"]
3273
			#設置 $result["error"]
3274
			$result["error"]=$checkArguments;
3274
			$result["error"]=$checkArguments;
3275
			
3275
 
3276
			#回傳結果
3276
			#回傳結果
3277
			return $result;
3277
			return $result;
3278
			
3278
 
3279
			}#if end
3279
			}#if end
3280
			
3280
 
3281
		#如果 $checkArguments["passed"] 等於 "false"
3281
		#如果 $checkArguments["passed"] 等於 "false"
3282
		if($checkArguments["passed"]==="false"){
3282
		if($checkArguments["passed"]==="false"){
3283
			
3283
 
3284
			#設置 $result["status"] 為 "false"
3284
			#設置 $result["status"] 為 "false"
3285
			$result["status"]="false";
3285
			$result["status"]="false";
3286
			
3286
 
3287
			#設置 $result["error"]
3287
			#設置 $result["error"]
3288
			$result["error"]=$checkArguments;
3288
			$result["error"]=$checkArguments;
3289
			
3289
 
3290
			#回傳結果
3290
			#回傳結果
3291
			return $result;
3291
			return $result;
3292
			
3292
 
3293
			}#if end			
3293
			}#if end
3294
				
3294
 
3295
		#函式說明:
3295
		#函式說明:
3296
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
3296
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
3297
		#回傳結果:
3297
		#回傳結果:
3298
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
3298
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
3299
		#$result["error"],錯誤訊息陣列.
3299
		#$result["error"],錯誤訊息陣列.
3300
		#$result["function"],函數名稱. 
3300
		#$result["function"],函數名稱.
3301
		#$result["argu"],使用的參數.
3301
		#$result["argu"],使用的參數.
3302
		#$result["content"],網址,若是在命令列執行,則為"null".
3302
		#$result["content"],網址,若是在命令列執行,則為"null".
3303
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
3303
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
3304
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
3304
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
3305
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
3305
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
Line 3313... Line 3313...
3313
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
3313
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
3314
		#備註:
3314
		#備註:
3315
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
3315
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
3316
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
3316
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
3317
		unset($conf["fileAccess::getInternetAddressV2"]);
3317
		unset($conf["fileAccess::getInternetAddressV2"]);
3318
		
3318
 
3319
		#如果 $getInternetAddressV2["status"] 等於 "false"
3319
		#如果 $getInternetAddressV2["status"] 等於 "false"
3320
		if($getInternetAddressV2["status"]==="false"){
3320
		if($getInternetAddressV2["status"]==="false"){
3321
			
3321
 
3322
			#設置 $result["status"] 為 "false"
3322
			#設置 $result["status"] 為 "false"
3323
			$result["status"]="false";
3323
			$result["status"]="false";
3324
			
3324
 
3325
			#設置 $result["error"]
3325
			#設置 $result["error"]
3326
			$result["error"]=$getInternetAddressV2;
3326
			$result["error"]=$getInternetAddressV2;
3327
			
3327
 
3328
			#回傳結果
3328
			#回傳結果
3329
			return $result;
3329
			return $result;
3330
			
3330
 
3331
			}#if end
3331
			}#if end
3332
		
3332
 
3333
		#取得絕對位置
3333
		#取得絕對位置
3334
		$conf["dirPositionAndName"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
3334
		$conf["dirPositionAndName"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
3335
		
3335
 
3336
		#用「/」分割要建立的路徑
3336
		#用「/」分割要建立的路徑
3337
		#函式說明:
3337
		#函式說明:
3338
		#將固定格式的字串分開,並回傳分開的結果。
3338
		#將固定格式的字串分開,並回傳分開的結果。
3339
		#回傳結果:
3339
		#回傳結果:
3340
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3340
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 3345... Line 3345...
3345
		#$result["dataCounts"],爲總共分成幾段
3345
		#$result["dataCounts"],爲總共分成幾段
3346
		#必填參數:
3346
		#必填參數:
3347
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["dirPositionAndName"];
3347
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["dirPositionAndName"];
3348
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
3348
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
3349
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
3349
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
3350
		unset($conf["stringProcess::spiltString"]);	
3350
		unset($conf["stringProcess::spiltString"]);
3351
		
3351
 
3352
		#如果分割失敗
3352
		#如果分割失敗
3353
		if($spiltString["status"]=="false"){
3353
		if($spiltString["status"]=="false"){
3354
			
3354
 
3355
			#設置 $result["status"] 為 "false"
3355
			#設置 $result["status"] 為 "false"
3356
			$result["status"]="false";
3356
			$result["status"]="false";
3357
			
3357
 
3358
			#設置 $result["error"]
3358
			#設置 $result["error"]
3359
			$result["error"]=$spiltString;
3359
			$result["error"]=$spiltString;
3360
			
3360
 
3361
			#回傳結果
3361
			#回傳結果
3362
			return $result;
3362
			return $result;
3363
			
3363
 
3364
			}#if end
3364
			}#if end
3365
		
3365
 
3366
		$checkedPath="";
3366
		$checkedPath="";
3367
			
3367
 
3368
		#依據切割成的路徑片段數目
3368
		#依據切割成的路徑片段數目
3369
		for($i=0;$i<$spiltString["dataCounts"];$i++){
3369
		for($i=0;$i<$spiltString["dataCounts"];$i++){
3370
			
3370
 
3371
			$checkedPath=$checkedPath."/".$spiltString["dataArray"][$i];
3371
			$checkedPath=$checkedPath."/".$spiltString["dataArray"][$i];
3372
			
3372
 
3373
			#檢查路徑是否存在
3373
			#檢查路徑是否存在
3374
			#函式說明:
3374
			#函式說明:
3375
			#檢查多個檔案與資料夾是否存在.
3375
			#檢查多個檔案與資料夾是否存在.
3376
			#回傳的結果:
3376
			#回傳的結果:
3377
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
3377
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 3396... Line 3396...
3396
			#http://php.net/manual/en/function.file-exists.php
3396
			#http://php.net/manual/en/function.file-exists.php
3397
			#http://php.net/manual/en/control-structures.foreach.php
3397
			#http://php.net/manual/en/control-structures.foreach.php
3398
			#備註:
3398
			#備註:
3399
			#函數file_exists檢查的路徑為檔案系統的路徑
3399
			#函數file_exists檢查的路徑為檔案系統的路徑
3400
			$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
3400
			$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
3401
			
3401
 
3402
			#如果檢查資料夾路徑失敗
3402
			#如果檢查資料夾路徑失敗
3403
			if($checkMultiFileExist["status"]=="false"){
3403
			if($checkMultiFileExist["status"]=="false"){
3404
				
3404
 
3405
				#設置 $result["status"] 為 "false"
3405
				#設置 $result["status"] 為 "false"
3406
				$result["status"]="false";
3406
				$result["status"]="false";
3407
				
3407
 
3408
				#設置 $result["error"]
3408
				#設置 $result["error"]
3409
				$result["error"]=$spiltString;
3409
				$result["error"]=$spiltString;
3410
				
3410
 
3411
				#回傳結果
3411
				#回傳結果
3412
				return $result;
3412
				return $result;
3413
				
3413
 
3414
				}#if end
3414
				}#if end
3415
				
3415
 
3416
			#如果目錄不存在
3416
			#如果目錄不存在
3417
			if($checkMultiFileExist["allExist"]=="false"){
3417
			if($checkMultiFileExist["allExist"]=="false"){
3418
				
3418
 
3419
				#如果有這個名稱的東西存在
3419
				#如果有這個名稱的東西存在
3420
				if(file_exists($checkedPath)){
3420
				if(file_exists($checkedPath)){
3421
					
3421
 
3422
					#如果目錄存在
3422
					#如果目錄存在
3423
					if(is_dir($checkedPath)){
3423
					if(is_dir($checkedPath)){
3424
						
3424
 
3425
						#目錄已經存在換下一層
3425
						#目錄已經存在換下一層
3426
						continue;
3426
						continue;
3427
						
3427
 
3428
						}#if end
3428
						}#if end
3429
					
3429
 
3430
					}#if end
3430
					}#if end
3431
				
3431
 
3432
				#建立目錄
3432
				#建立目錄
3433
				$mkdir=@mkdir($checkedPath,0770);
3433
				$mkdir=@mkdir($checkedPath,0770);
3434
				
3434
 
3435
				#如果建立目錄失敗
3435
				#如果建立目錄失敗
3436
				#參考資料:
3436
				#參考資料:
3437
				#http://php.net/manual/en/function.mkdir.php
3437
				#http://php.net/manual/en/function.mkdir.php
3438
				if($mkdir===false){
3438
				if($mkdir===false){
3439
					
3439
 
3440
					#設置 $result["status"] 為 "false"
3440
					#設置 $result["status"] 為 "false"
3441
					$result["status"]="false";
3441
					$result["status"]="false";
3442
					
3442
 
3443
					#設置 $result["error"]
3443
					#設置 $result["error"]
3444
					$result["error"][]="建立目錄「".$checkedPath."」失敗";
3444
					$result["error"][]="建立目錄「".$checkedPath."」失敗";
3445
					
3445
 
3446
					#回傳結果
3446
					#回傳結果
3447
					return $result;
3447
					return $result;
3448
					
3448
 
3449
					}#if end
3449
					}#if end
3450
					
3450
 
3451
				#更改目錄的權限為 0770
3451
				#更改目錄的權限為 0770
3452
				chmod($checkedPath,0770);
3452
				chmod($checkedPath,0770);
3453
				
3453
 
3454
				}#if end
3454
				}#if end
3455
			
3455
 
3456
			}#for end
3456
			}#for end
3457
			
3457
 
3458
		#取得建立好的目錄
3458
		#取得建立好的目錄
3459
		$result["content"]=$checkedPath;	
3459
		$result["content"]=$checkedPath;
3460
					
3460
 
3461
		#執行到這邊代表執行成功
3461
		#執行到這邊代表執行成功
3462
		$result["status"]="true";
3462
		$result["status"]="true";
3463
		
3463
 
3464
		#回傳結果
3464
		#回傳結果
3465
		return $result;
3465
		return $result;
3466
		
3466
 
3467
		}#function createFolderAfterCheck end
3467
		}#function createFolderAfterCheck end
3468
 
3468
 
3469
	/*
3469
	/*
3470
	#函式說明:
3470
	#函式說明:
3471
	#移除檔案
3471
	#移除檔案
Line 3494... Line 3494...
3494
	*/
3494
	*/
3495
	public static function delFile(&$conf){
3495
	public static function delFile(&$conf){
3496
 
3496
 
3497
		#初始化要回傳的結果
3497
		#初始化要回傳的結果
3498
		$result=array();
3498
		$result=array();
3499
		
3499
 
3500
		#設置當其函數名稱
3500
		#設置當其函數名稱
3501
		$result["function"]=__FUNCTION__;
3501
		$result["function"]=__FUNCTION__;
3502
		
3502
 
3503
		#如果 $conf 不為陣列
3503
		#如果 $conf 不為陣列
3504
		if(gettype($conf)!="array"){
3504
		if(gettype($conf)!="array"){
3505
			
3505
 
3506
			#設置執行失敗
3506
			#設置執行失敗
3507
			$result["status"]="false";
3507
			$result["status"]="false";
3508
			
3508
 
3509
			#設置執行錯誤訊息
3509
			#設置執行錯誤訊息
3510
			$result["error"][]="\$conf變數須為陣列形態";
3510
			$result["error"][]="\$conf變數須為陣列形態";
3511
 
3511
 
3512
			#如果傳入的參數為 null
3512
			#如果傳入的參數為 null
3513
			if($conf==null){
3513
			if($conf==null){
3514
				
3514
 
3515
				#設置執行錯誤訊息
3515
				#設置執行錯誤訊息
3516
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3516
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3517
				
3517
 
3518
				}#if end
3518
				}#if end
3519
 
3519
 
3520
			#回傳結果
3520
			#回傳結果
3521
			return $result;
3521
			return $result;
3522
			
3522
 
3523
			}#if end
3523
			}#if end
3524
		
3524
 
3525
		#取得參數
3525
		#取得參數
3526
		$result["argu"]=$conf;
3526
		$result["argu"]=$conf;
3527
		
3527
 
3528
		#檢查參數
3528
		#檢查參數
3529
		#函式說明:
3529
		#函式說明:
3530
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
3530
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
3531
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3531
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3532
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
3532
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 3541... Line 3541...
3541
		#必填寫的參數:
3541
		#必填寫的參數:
3542
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
3542
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
3543
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
3543
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
3544
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
3544
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
3545
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileAddress");
3545
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileAddress");
3546
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
3546
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
3547
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
3547
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
3548
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
3548
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
3549
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
3549
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
3550
		#可以省略的參數:
3550
		#可以省略的參數:
3551
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
3551
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
3552
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
3552
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
3553
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3553
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3554
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray","allowDelSymlink","allowDelFolder");
3554
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray","allowDelSymlink","allowDelFolder");
3555
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
3555
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
3556
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string");
3556
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string");
3557
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3557
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3558
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"false","false");
3558
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"false","false");
3559
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3559
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3560
		#$conf["arrayCountEqualCheck"][]=array();
3560
		#$conf["arrayCountEqualCheck"][]=array();
3561
		#參考資料來源:
3561
		#參考資料來源:
3562
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3562
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3563
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3563
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3564
		unset($conf["variableCheck::checkArguments"]);
3564
		unset($conf["variableCheck::checkArguments"]);
3565
					
3565
 
3566
		#如果檢查失敗
3566
		#如果檢查失敗
3567
		if($checkResult["status"]=="false"){
3567
		if($checkResult["status"]=="false"){
3568
			
3568
 
3569
			#設置錯誤識別
3569
			#設置錯誤識別
3570
			$result["status"]="false";
3570
			$result["status"]="false";
3571
			
3571
 
3572
			#設置錯誤訊息
3572
			#設置錯誤訊息
3573
			$result["error"]=$checkResult;
3573
			$result["error"]=$checkResult;
3574
			
3574
 
3575
			#回傳結果
3575
			#回傳結果
3576
			return $result;
3576
			return $result;
3577
			
3577
 
3578
			}#if end
3578
			}#if end
3579
			
3579
 
3580
		#如果檢查不通過
3580
		#如果檢查不通過
3581
		if($checkResult["passed"]=="false"){
3581
		if($checkResult["passed"]=="false"){
3582
			
3582
 
3583
			#設置錯誤識別
3583
			#設置錯誤識別
3584
			$result["status"]="false";
3584
			$result["status"]="false";
3585
			
3585
 
3586
			#設置錯誤訊息
3586
			#設置錯誤訊息
3587
			$result["error"]=$checkResult;
3587
			$result["error"]=$checkResult;
3588
			
3588
 
3589
			#回傳結果
3589
			#回傳結果
3590
			return $result;
3590
			return $result;
3591
			
3591
 
3592
			}#if end
3592
			}#if end
3593
 
3593
 
3594
		#如果 $conf["commentsArray"] 有設定
3594
		#如果 $conf["commentsArray"] 有設定
3595
		if(isset($conf["commentsArray"])){
3595
		if(isset($conf["commentsArray"])){
3596
			
3596
 
3597
			#印出提示文字
3597
			#印出提示文字
3598
			#函式說明:
3598
			#函式說明:
3599
			#印出多行文字,結尾自動換行.
3599
			#印出多行文字,結尾自動換行.
3600
			#回傳的結果:
3600
			#回傳的結果:
3601
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
3601
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
Line 3604... Line 3604...
3604
			#必填參數:
3604
			#必填參數:
3605
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
3605
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
3606
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
3606
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
3607
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
3607
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
3608
			unset($conf["cmd::echoMultiLine"]);
3608
			unset($conf["cmd::echoMultiLine"]);
3609
			
3609
 
3610
			#如果印出提示文字失敗
3610
			#如果印出提示文字失敗
3611
			if($echoMultiLine["status"]=="false"){
3611
			if($echoMultiLine["status"]=="false"){
3612
				
3612
 
3613
				#設置執行失敗
3613
				#設置執行失敗
3614
				$result["status"]="false";
3614
				$result["status"]="false";
3615
				
3615
 
3616
				#設置執行錯誤訊息
3616
				#設置執行錯誤訊息
3617
				$result["error"]=$echoMultiLine;
3617
				$result["error"]=$echoMultiLine;
3618
				
3618
 
3619
				#回傳結果
3619
				#回傳結果
3620
				return $result;
3620
				return $result;
3621
				
3621
 
3622
				}#if end
3622
				}#if end
3623
			
3623
 
3624
			}#if end
3624
			}#if end
3625
 
3625
 
3626
		#檢查要移除的檔案是否存在
3626
		#檢查要移除的檔案是否存在
3627
		#函式說明:
3627
		#函式說明:
3628
		#檢查多個檔案與資料夾是否存在.
3628
		#檢查多個檔案與資料夾是否存在.
Line 3652... Line 3652...
3652
 
3652
 
3653
		#var_dump($checkResult);
3653
		#var_dump($checkResult);
3654
 
3654
 
3655
		#如果檢查檔案是否存在失敗
3655
		#如果檢查檔案是否存在失敗
3656
		if($checkResult["status"]==="false"){
3656
		if($checkResult["status"]==="false"){
3657
			
3657
 
3658
			#設置執行失敗
3658
			#設置執行失敗
3659
			$result["status"]="false";
3659
			$result["status"]="false";
3660
 
3660
 
3661
			#回傳錯誤訊息
3661
			#回傳錯誤訊息
3662
			$result["error"]=$checkResult;
3662
			$result["error"]=$checkResult;
3663
 
3663
 
3664
			#回傳結果
3664
			#回傳結果
3665
			return $result;
3665
			return $result;
3666
			
3666
 
3667
			}#if end
3667
			}#if end
3668
 
3668
 
3669
		#如果目標檔案不存在
3669
		#如果目標檔案不存在
3670
		if($checkResult["varExist"][0]==="false"){
3670
		if($checkResult["varExist"][0]==="false"){
3671
			
3671
 
3672
			#設置錯誤識別
3672
			#設置錯誤識別
3673
			$result["status"]="true";
3673
			$result["status"]="true";
3674
 
3674
 
3675
			#回傳錯誤訊息
3675
			#回傳錯誤訊息
3676
			$result["warning"][]="要移除的檔案不存在";
3676
			$result["warning"][]="要移除的檔案不存在";
3677
 
3677
 
3678
			#回傳結果
3678
			#回傳結果
3679
			return $result;
3679
			return $result;
3680
			
3680
 
3681
			}#if end
3681
			}#if end
3682
 
3682
 
3683
		#如果要移除的目標是檔案
3683
		#如果要移除的目標是檔案
3684
		if(is_file($conf["fileAddress"])){
3684
		if(is_file($conf["fileAddress"])){
3685
		
3685
 
3686
			#移除檔案,並回傳移除的結果
3686
			#移除檔案,並回傳移除的結果
3687
			$eraseResult=(@unlink($conf["fileAddress"]));
3687
			$eraseResult=(@unlink($conf["fileAddress"]));
3688
 
3688
 
3689
			#如果 $eraseResult 等於 false
3689
			#如果 $eraseResult 等於 false
3690
			if($eraseResult===false){
3690
			if($eraseResult===false){
3691
				
3691
 
3692
				#設置錯誤識別
3692
				#設置錯誤識別
3693
				$result["status"]="false";
3693
				$result["status"]="false";
3694
 
3694
 
3695
				#回傳錯誤訊息
3695
				#回傳錯誤訊息
3696
				$result["error"][]="檔案移除失敗";
3696
				$result["error"][]="檔案移除失敗";
3697
 
3697
 
3698
				#回傳結果
3698
				#回傳結果
3699
				return $result;
3699
				return $result;
3700
				
3700
 
3701
				}#if end
3701
				}#if end
3702
		
3702
 
3703
			}#if end
3703
			}#if end
3704
 
3704
 
3705
		#反之要移除的目標是目錄
3705
		#反之要移除的目標是目錄
3706
		else if(is_dir($conf["fileAddress"])){
3706
		else if(is_dir($conf["fileAddress"])){
3707
		
3707
 
3708
			#如果允許移除目錄
3708
			#如果允許移除目錄
3709
			if($conf["allowDelFolder"]==="true"){
3709
			if($conf["allowDelFolder"]==="true"){
3710
			
3710
 
3711
				#移除目錄跟底下的內容
3711
				#移除目錄跟底下的內容
3712
				w函式說明:
3712
				w函式說明:
3713
				#呼叫shell執行系統命令,並取得回傳的內容.
3713
				#呼叫shell執行系統命令,並取得回傳的內容.
3714
				#回傳結果:
3714
				#回傳結果:
3715
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3715
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 3769... Line 3769...
3769
				#備註:
3769
				#備註:
3770
				#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
3770
				#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
3771
				#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
3771
				#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
3772
				$callShell=external::callShell($conf["external::callShell"]);
3772
				$callShell=external::callShell($conf["external::callShell"]);
3773
				unset($conf["external::callShell"]);
3773
				unset($conf["external::callShell"]);
3774
			
3774
 
3775
				#如果執行失敗
3775
				#如果執行失敗
3776
				if($callShell["status"]==="false"){
3776
				if($callShell["status"]==="false"){
3777
					
3777
 
3778
					#設置錯誤識別
3778
					#設置錯誤識別
3779
					$result["status"]="false";
3779
					$result["status"]="false";
3780
 
3780
 
3781
					#回傳錯誤訊息
3781
					#回傳錯誤訊息
3782
					$result["error"]=$callShell;
3782
					$result["error"]=$callShell;
3783
 
3783
 
3784
					#回傳結果
3784
					#回傳結果
3785
					return $result;
3785
					return $result;
3786
					
3786
 
3787
					}#if end
3787
					}#if end
3788
			
3788
 
3789
				}#if end	
3789
				}#if end
3790
		
3790
 
3791
			#反之不允許
3791
			#反之不允許
3792
			else{
3792
			else{
3793
		
3793
 
3794
				#設置錯誤識別
3794
				#設置錯誤識別
3795
				$result["status"]="false";
3795
				$result["status"]="false";
3796
 
3796
 
3797
				#回傳錯誤訊息
3797
				#回傳錯誤訊息
3798
				$result["error"][]="不允許移除目錄";
3798
				$result["error"][]="不允許移除目錄";
3799
				
3799
 
3800
				#回傳結果
3800
				#回傳結果
3801
				return $result;
3801
				return $result;
3802
				
3802
 
3803
				}#else end
3803
				}#else end
3804
		
3804
 
3805
			}#if end
3805
			}#if end
3806
			
3806
 
3807
		#反之
3807
		#反之
3808
		else{
3808
		else{
3809
		
3809
 
3810
			#可能為 軟連結
3810
			#可能為 軟連結
3811
			
3811
 
3812
			#如果允許移除
3812
			#如果允許移除
3813
			if($conf["allowDelSymlink"]==="true"){
3813
			if($conf["allowDelSymlink"]==="true"){
3814
			
3814
 
3815
				#移除檔案,並回傳移除的結果
3815
				#移除檔案,並回傳移除的結果
3816
				$eraseResult=(@unlink($conf["fileAddress"]));
3816
				$eraseResult=(@unlink($conf["fileAddress"]));
3817
 
3817
 
3818
				#如果 $eraseResult 等於 false
3818
				#如果 $eraseResult 等於 false
3819
				if($eraseResult===false){
3819
				if($eraseResult===false){
3820
					
3820
 
3821
					#設置錯誤識別
3821
					#設置錯誤識別
3822
					$result["status"]="false";
3822
					$result["status"]="false";
3823
 
3823
 
3824
					#回傳錯誤訊息
3824
					#回傳錯誤訊息
3825
					$result["error"][]="檔案移除失敗";
3825
					$result["error"][]="檔案移除失敗";
3826
 
3826
 
3827
					#回傳結果
3827
					#回傳結果
3828
					return $result;
3828
					return $result;
3829
					
3829
 
3830
					}#if end
3830
					}#if end
3831
				
3831
 
3832
				}#if end
3832
				}#if end
3833
			
3833
 
3834
			#反之
3834
			#反之
3835
			else{
3835
			else{
3836
			
3836
 
3837
				#設置錯誤識別
3837
				#設置錯誤識別
3838
				$result["status"]="false";
3838
				$result["status"]="false";
3839
				
3839
 
3840
				#設置錯誤訊息
3840
				#設置錯誤訊息
3841
				$result["error"][]="不允許移除 檔案、目錄 以外類型的目標";
3841
				$result["error"][]="不允許移除 檔案、目錄 以外類型的目標";
3842
 
3842
 
3843
				#回傳結果
3843
				#回傳結果
3844
				return $result;
3844
				return $result;
3845
			
3845
 
3846
				}#else end
3846
				}#else end
3847
		
3847
 
3848
			}#else end
3848
			}#else end
3849
		
3849
 
3850
		#執行到這邊代表執行正常.
3850
		#執行到這邊代表執行正常.
3851
		$result["status"]="true";
3851
		$result["status"]="true";
3852
		
3852
 
3853
		#回傳結果
3853
		#回傳結果
3854
		return $result;
3854
		return $result;
3855
 
3855
 
3856
		}#function delFile end
3856
		}#function delFile end
3857
	
3857
 
3858
	/*
3858
	/*
3859
	#函式說明:
3859
	#函式說明:
3860
	#移除多個檔案
3860
	#移除多個檔案
3861
	#回傳結果:
3861
	#回傳結果:
3862
	#$result["status"],"true"代表移除成功,"false"代表移除失敗.
3862
	#$result["status"],"true"代表移除成功,"false"代表移除失敗.
Line 3875... Line 3875...
3875
	#無.
3875
	#無.
3876
	#備註:
3876
	#備註:
3877
	#無.
3877
	#無.
3878
	*/
3878
	*/
3879
	public static function delMultiFile(&$conf){
3879
	public static function delMultiFile(&$conf){
3880
	
3880
 
3881
		#初始化要回傳的結果
3881
		#初始化要回傳的結果
3882
		$result=array();
3882
		$result=array();
3883
		
3883
 
3884
		#設置當其函數名稱
3884
		#設置當其函數名稱
3885
		$result["function"]=__FUNCTION__;
3885
		$result["function"]=__FUNCTION__;
3886
		
3886
 
3887
		#如果 $conf 不為陣列
3887
		#如果 $conf 不為陣列
3888
		if(gettype($conf)!="array"){
3888
		if(gettype($conf)!="array"){
3889
			
3889
 
3890
			#設置執行失敗
3890
			#設置執行失敗
3891
			$result["status"]="false";
3891
			$result["status"]="false";
3892
			
3892
 
3893
			#設置執行錯誤訊息
3893
			#設置執行錯誤訊息
3894
			$result["error"][]="\$conf變數須為陣列形態";
3894
			$result["error"][]="\$conf變數須為陣列形態";
3895
 
3895
 
3896
			#如果傳入的參數為 null
3896
			#如果傳入的參數為 null
3897
			if($conf==null){
3897
			if($conf==null){
3898
				
3898
 
3899
				#設置執行錯誤訊息
3899
				#設置執行錯誤訊息
3900
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3900
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3901
				
3901
 
3902
				}#if end
3902
				}#if end
3903
 
3903
 
3904
			#回傳結果
3904
			#回傳結果
3905
			return $result;
3905
			return $result;
3906
			
3906
 
3907
			}#if end
3907
			}#if end
3908
		
3908
 
3909
		#取得使用的參數.
3909
		#取得使用的參數.
3910
		$result["argu"]=$conf;
3910
		$result["argu"]=$conf;
3911
		
3911
 
3912
		#檢查參數
3912
		#檢查參數
3913
		#函式說明:
3913
		#函式說明:
3914
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
3914
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
3915
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3915
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3916
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
3916
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 3925... Line 3925...
3925
		#必填寫的參數:
3925
		#必填寫的參數:
3926
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
3926
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
3927
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
3927
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
3928
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
3928
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
3929
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileAddress");
3929
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileAddress");
3930
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
3930
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
3931
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");
3931
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");
3932
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
3932
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
3933
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
3933
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
3934
		#可以省略的參數:
3934
		#可以省略的參數:
3935
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
3935
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
3936
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
3936
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
3937
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3937
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3938
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray");
3938
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray");
3939
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
3939
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
3940
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
3940
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
3941
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3941
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3942
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
3942
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
3943
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3943
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3944
		#$conf["arrayCountEqualCheck"][]=array();
3944
		#$conf["arrayCountEqualCheck"][]=array();
3945
		#參考資料來源:
3945
		#參考資料來源:
3946
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3946
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3947
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3947
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3948
		unset($conf["variableCheck::checkArguments"]);
3948
		unset($conf["variableCheck::checkArguments"]);
3949
					
3949
 
3950
		#如果檢查失敗
3950
		#如果檢查失敗
3951
		if($checkResult["status"]=="false"){
3951
		if($checkResult["status"]=="false"){
3952
			
3952
 
3953
			#設置錯誤識別
3953
			#設置錯誤識別
3954
			$result["status"]="false";
3954
			$result["status"]="false";
3955
			
3955
 
3956
			#設置錯誤訊息
3956
			#設置錯誤訊息
3957
			$result["error"]=$checkResult;
3957
			$result["error"]=$checkResult;
3958
			
3958
 
3959
			#回傳結果
3959
			#回傳結果
3960
			return $result;
3960
			return $result;
3961
			
3961
 
3962
			}#if end
3962
			}#if end
3963
			
3963
 
3964
		#如果檢查不通過
3964
		#如果檢查不通過
3965
		if($checkResult["passed"]=="false"){
3965
		if($checkResult["passed"]=="false"){
3966
			
3966
 
3967
			#設置錯誤識別
3967
			#設置錯誤識別
3968
			$result["status"]="false";
3968
			$result["status"]="false";
3969
			
3969
 
3970
			#設置錯誤訊息
3970
			#設置錯誤訊息
3971
			$result["error"]=$checkResult;
3971
			$result["error"]=$checkResult;
3972
			
3972
 
3973
			#回傳結果
3973
			#回傳結果
3974
			return $result;
3974
			return $result;
3975
			
3975
 
3976
			}#if end
3976
			}#if end
3977
	
3977
 
3978
		#針對每個要移除的檔案
3978
		#針對每個要移除的檔案
3979
		foreach($conf["fileAddress"] as $fileAddr){
3979
		foreach($conf["fileAddress"] as $fileAddr){
3980
		
3980
 
3981
			#函式說明:
3981
			#函式說明:
3982
			#移除檔案
3982
			#移除檔案
3983
			#回傳結果:
3983
			#回傳結果:
3984
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
3984
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
3985
			#$result["error"],錯誤訊息陣列
3985
			#$result["error"],錯誤訊息陣列
Line 3995... Line 3995...
3995
			#$conf["commentsArray"]=array("");
3995
			#$conf["commentsArray"]=array("");
3996
			#備註:
3996
			#備註:
3997
			#無.
3997
			#無.
3998
			$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
3998
			$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
3999
			unset($conf["fileAccess::delFile"]);
3999
			unset($conf["fileAccess::delFile"]);
4000
		
4000
 
4001
			#如果檢查失敗
4001
			#如果檢查失敗
4002
			if($delFile["status"]==="false"){
4002
			if($delFile["status"]==="false"){
4003
				
4003
 
4004
				#設置錯誤識別
4004
				#設置錯誤識別
4005
				$result["status"]="false";
4005
				$result["status"]="false";
4006
				
4006
 
4007
				#設置錯誤訊息
4007
				#設置錯誤訊息
4008
				$result["error"]=$delFile;
4008
				$result["error"]=$delFile;
4009
				
4009
 
4010
				#回傳結果
4010
				#回傳結果
4011
				return $result;
4011
				return $result;
4012
				
4012
 
4013
				}#if end
4013
				}#if end
4014
		
4014
 
4015
			#取得移除檔案的結果
4015
			#取得移除檔案的結果
4016
			$result["content"][]=$delFile;
4016
			$result["content"][]=$delFile;
4017
		
4017
 
4018
			}#foreach end
4018
			}#foreach end
4019
			
4019
 
4020
		#設置執行正常
4020
		#設置執行正常
4021
		$result["status"]="true";
4021
		$result["status"]="true";
4022
		
4022
 
4023
		#回傳結果
4023
		#回傳結果
4024
		return $result;
4024
		return $result;
4025
	
4025
 
4026
		}#function delMultiFile end
4026
		}#function delMultiFile end
4027
	
4027
 
4028
	/*
4028
	/*
4029
	#函式說明:
4029
	#函式說明:
4030
	#確保路徑存在.
4030
	#確保路徑存在.
4031
	#回傳結果:
4031
	#回傳結果:
4032
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
4032
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 4035... Line 4035...
4035
	#$result["path"],建立好的路徑字串.
4035
	#$result["path"],建立好的路徑字串.
4036
	#$result["fileName"],檔案名稱,若 $conf["haveFileName"] 為 "true" 則會回傳.
4036
	#$result["fileName"],檔案名稱,若 $conf["haveFileName"] 為 "true" 則會回傳.
4037
	#$result["argu"],使用的參數.
4037
	#$result["argu"],使用的參數.
4038
	#必填參數:
4038
	#必填參數:
4039
	#$conf["path"],要檢查的路徑
4039
	#$conf["path"],要檢查的路徑
4040
	$conf["path"]="";		
4040
	$conf["path"]="";
4041
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4041
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4042
	$conf["fileArgu"]=__FILE__;
4042
	$conf["fileArgu"]=__FILE__;
4043
	#可省略參數:
4043
	#可省略參數:
4044
	#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
4044
	#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
4045
	#$conf["haveFileName"]="false";
4045
	#$conf["haveFileName"]="false";
Line 4049... Line 4049...
4049
	#$conf["web"]="";
4049
	#$conf["web"]="";
4050
	#參考資料:
4050
	#參考資料:
4051
	#無.
4051
	#無.
4052
	#備註:
4052
	#備註:
4053
	#無.
4053
	#無.
4054
	*/ 
4054
	*/
4055
	public static function validatePath(&$conf){
4055
	public static function validatePath(&$conf){
4056
		
4056
 
4057
		#初始化要回傳的結果
4057
		#初始化要回傳的結果
4058
		$result=array();
4058
		$result=array();
4059
		
4059
 
4060
		#設置當其函數名稱
4060
		#設置當其函數名稱
4061
		$result["function"]=__FUNCTION__;
4061
		$result["function"]=__FUNCTION__;
4062
		
4062
 
4063
		#如果 $conf 不為陣列
4063
		#如果 $conf 不為陣列
4064
		if(gettype($conf)!="array"){
4064
		if(gettype($conf)!="array"){
4065
			
4065
 
4066
			#設置執行失敗
4066
			#設置執行失敗
4067
			$result["status"]="false";
4067
			$result["status"]="false";
4068
			
4068
 
4069
			#設置執行錯誤訊息
4069
			#設置執行錯誤訊息
4070
			$result["error"][]="\$conf變數須為陣列形態";
4070
			$result["error"][]="\$conf變數須為陣列形態";
4071
 
4071
 
4072
			#如果傳入的參數為 null
4072
			#如果傳入的參數為 null
4073
			if($conf==null){
4073
			if($conf==null){
4074
				
4074
 
4075
				#設置執行錯誤訊息
4075
				#設置執行錯誤訊息
4076
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
4076
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
4077
				
4077
 
4078
				}#if end
4078
				}#if end
4079
			
4079
 
4080
			#回傳結果
4080
			#回傳結果
4081
			return $result;
4081
			return $result;
4082
			
4082
 
4083
			}#if end
4083
			}#if end
4084
			
4084
 
4085
		#取得使用的參數
4085
		#取得使用的參數
4086
		$result["argu"]=$conf;	
4086
		$result["argu"]=$conf;
4087
			
4087
 
4088
		#檢查參數
4088
		#檢查參數
4089
		#函式說明:
4089
		#函式說明:
4090
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
4090
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
4091
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4091
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4092
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
4092
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 4113... Line 4113...
4113
		$conf["variableCheck::checkArgument"]["canBeEmptyString"]="false";
4113
		$conf["variableCheck::checkArgument"]["canBeEmptyString"]="false";
4114
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
4114
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
4115
		$conf["variableCheck::checkArgument"]["skipableVariableCanNotBeEmpty"]=array("haveFileName","dirPermission","web");
4115
		$conf["variableCheck::checkArgument"]["skipableVariableCanNotBeEmpty"]=array("haveFileName","dirPermission","web");
4116
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4116
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4117
		$conf["variableCheck::checkArgument"]["skipableVariableName"]=array("haveFileName","dirPermission","web");
4117
		$conf["variableCheck::checkArgument"]["skipableVariableName"]=array("haveFileName","dirPermission","web");
4118
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
4118
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
4119
		$conf["variableCheck::checkArgument"]["skipableVariableType"]=array("string","string","string");
4119
		$conf["variableCheck::checkArgument"]["skipableVariableType"]=array("string","string","string");
4120
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4120
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4121
		$conf["variableCheck::checkArgument"]["skipableVarDefaultValue"]=array("false","0770","false");
4121
		$conf["variableCheck::checkArgument"]["skipableVarDefaultValue"]=array("false","0770","false");
4122
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4122
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4123
		#$conf["arrayCountEqualCheck"][]=array();
4123
		#$conf["arrayCountEqualCheck"][]=array();
4124
		#參考資料來源:
4124
		#參考資料來源:
4125
		#array_keys=>http://php.net/manual/en/function.array-keys.php
4125
		#array_keys=>http://php.net/manual/en/function.array-keys.php
4126
		$checkArgument=variableCheck::checkArguments($conf["variableCheck::checkArgument"]);
4126
		$checkArgument=variableCheck::checkArguments($conf["variableCheck::checkArgument"]);
4127
		unset($conf["variableCheck::checkArgument"]);
4127
		unset($conf["variableCheck::checkArgument"]);
4128
		
4128
 
4129
		#如果檢查過程出錯
4129
		#如果檢查過程出錯
4130
		if($checkArgument["status"]==="false"){
4130
		if($checkArgument["status"]==="false"){
4131
			
4131
 
4132
			#設置執行失敗
4132
			#設置執行失敗
4133
			$result["status"]="false";
4133
			$result["status"]="false";
4134
			
4134
 
4135
			#設置執行錯誤訊息
4135
			#設置執行錯誤訊息
4136
			$result["error"]=$checkArgument;
4136
			$result["error"]=$checkArgument;
4137
 
4137
 
4138
			#回傳結果
4138
			#回傳結果
4139
			return $result;
4139
			return $result;
4140
			
4140
 
4141
			}#if end
4141
			}#if end
4142
		
4142
 
4143
		#如果檢查不通過
4143
		#如果檢查不通過
4144
		if($checkArgument["passed"]==="false"){
4144
		if($checkArgument["passed"]==="false"){
4145
			
4145
 
4146
			#設置執行失敗
4146
			#設置執行失敗
4147
			$result["status"]="false";
4147
			$result["status"]="false";
4148
			
4148
 
4149
			#設置執行錯誤訊息
4149
			#設置執行錯誤訊息
4150
			$result["error"]=$checkArgument;
4150
			$result["error"]=$checkArgument;
4151
 
4151
 
4152
			#回傳結果
4152
			#回傳結果
4153
			return $result;
4153
			return $result;
4154
			
4154
 
4155
			}#if end
4155
			}#if end
4156
		
4156
 
4157
		#函式說明:
4157
		#函式說明:
4158
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
4158
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
4159
		#回傳結果:
4159
		#回傳結果:
4160
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
4160
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
4161
		#$result["error"],錯誤訊息陣列.
4161
		#$result["error"],錯誤訊息陣列.
4162
		#$result["function"],函數名稱. 
4162
		#$result["function"],函數名稱.
4163
		#$result["argu"],使用的參數.
4163
		#$result["argu"],使用的參數.
4164
		#$result["content"],網址,若是在命令列執行,則為"null".
4164
		#$result["content"],網址,若是在命令列執行,則為"null".
4165
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
4165
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
4166
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
4166
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
4167
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
4167
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
Line 4174... Line 4174...
4174
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
4174
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
4175
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
4175
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
4176
		#備註:
4176
		#備註:
4177
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
4177
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
4178
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
4178
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
4179
		unset($conf["fileAccess::getInternetAddressV2"]);	
4179
		unset($conf["fileAccess::getInternetAddressV2"]);
4180
			
4180
 
4181
		#如果檢查過程出錯
4181
		#如果檢查過程出錯
4182
		if($getInternetAddressV2["status"]=="false"){
4182
		if($getInternetAddressV2["status"]=="false"){
4183
			
4183
 
4184
			#設置執行失敗
4184
			#設置執行失敗
4185
			$result["status"]="false";
4185
			$result["status"]="false";
4186
			
4186
 
4187
			#設置執行錯誤訊息
4187
			#設置執行錯誤訊息
4188
			$result["error"]=$getInternetAddressV2;
4188
			$result["error"]=$getInternetAddressV2;
4189
 
4189
 
4190
			#回傳結果
4190
			#回傳結果
4191
			return $result;
4191
			return $result;
4192
			
4192
 
4193
			}#if end		
4193
			}#if end
4194
				
4194
 
4195
		#取得轉換好的絕對路徑
4195
		#取得轉換好的絕對路徑
4196
		$result["path"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
4196
		$result["path"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
4197
			
4197
 
4198
		#debug
4198
		#debug
4199
		#var_dump($getInternetAddressV2);exit;
4199
		#var_dump($getInternetAddressV2);exit;
4200
			
4200
 
4201
		#如果 路徑 含有檔案名稱
4201
		#如果 路徑 含有檔案名稱
4202
		if($conf["haveFileName"]==="true"){
4202
		if($conf["haveFileName"]==="true"){
4203
		
4203
 
4204
			#預設要加回去的結束字串為空字串
4204
			#預設要加回去的結束字串為空字串
4205
			$endStr="";
4205
			$endStr="";
4206
		
4206
 
4207
			#如果開頭跟結尾都是 "'"
4207
			#如果開頭跟結尾都是 "'"
4208
			if( strpos($result["path"],"'")===0 && strpos($result["path"],"'")===(strlen($result["path"])-1) ){
4208
			if( strpos($result["path"],"'")===0 && strpos($result["path"],"'")===(strlen($result["path"])-1) ){
4209
			
4209
 
4210
				#設置要加回去的結束字串
4210
				#設置要加回去的結束字串
4211
				$endStr="'";
4211
				$endStr="'";
4212
			
4212
 
4213
				}#if end
4213
				}#if end
4214
			
4214
 
4215
			#函式說明:
4215
			#函式說明:
4216
			#將固定格式的字串分開,並回傳分開的結果。
4216
			#將固定格式的字串分開,並回傳分開的結果。
4217
			#回傳結果:
4217
			#回傳結果:
4218
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4218
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4219
			#$result["error"],錯誤訊息陣列
4219
			#$result["error"],錯誤訊息陣列
Line 4231... Line 4231...
4231
			#可省略參數:
4231
			#可省略參數:
4232
			#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
4232
			#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
4233
			$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
4233
			$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
4234
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
4234
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
4235
			unset($conf["stringProcess::spiltString"]);
4235
			unset($conf["stringProcess::spiltString"]);
4236
		
4236
 
4237
			#如果檢查過程出錯
4237
			#如果檢查過程出錯
4238
			if($spiltString["status"]==="false"){
4238
			if($spiltString["status"]==="false"){
4239
				
4239
 
4240
				#設置執行失敗
4240
				#設置執行失敗
4241
				$result["status"]="false";
4241
				$result["status"]="false";
4242
				
4242
 
4243
				#設置執行錯誤訊息
4243
				#設置執行錯誤訊息
4244
				$result["error"]=$spiltString;
4244
				$result["error"]=$spiltString;
4245
 
4245
 
4246
				#回傳結果
4246
				#回傳結果
4247
				return $result;
4247
				return $result;
4248
				
4248
 
4249
				}#if end
4249
				}#if end
4250
			
4250
 
4251
			#初始化儲存 path
4251
			#初始化儲存 path
4252
			$path="";
4252
			$path="";
4253
			
4253
 
4254
			#針對n-1段的內容
4254
			#針對n-1段的內容
4255
			for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
4255
			for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
4256
				
4256
 
4257
				#串接路徑
4257
				#串接路徑
4258
				$path=$path."/".$spiltString["dataArray"][$i];
4258
				$path=$path."/".$spiltString["dataArray"][$i];
4259
			
4259
 
4260
				}#for end
4260
				}#for end
4261
				
4261
 
4262
			#如果路徑為空
4262
			#如果路徑為空
4263
			if($path===""){
4263
			if($path===""){
4264
			
4264
 
4265
				#則與設為根目錄
4265
				#則與設為根目錄
4266
				$path="/";
4266
				$path="/";
4267
			
4267
 
4268
				}#if end
4268
				}#if end
4269
				
4269
 
4270
			#設置檔案名稱
4270
			#設置檔案名稱
4271
			$result["fileName"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
4271
			$result["fileName"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
4272
			
4272
 
4273
			#取得不含檔案名稱的路徑
4273
			#取得不含檔案名稱的路徑
4274
			$conf["path"]=$path.$endStr;
4274
			$conf["path"]=$path.$endStr;
4275
			
4275
 
4276
			#取得不含檔案名稱的路徑
4276
			#取得不含檔案名稱的路徑
4277
			$result["path"]=$path.$endStr;
4277
			$result["path"]=$path.$endStr;
4278
		
4278
 
4279
			}#if end
4279
			}#if end
4280
		
4280
 
4281
		#函式說明:
4281
		#函式說明:
4282
		#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
4282
		#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
4283
		#回傳結果:
4283
		#回傳結果:
4284
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
4284
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
4285
		#$result["error"],錯誤訊息陣列
4285
		#$result["error"],錯誤訊息陣列
Line 4294... Line 4294...
4294
		#參考資料:
4294
		#參考資料:
4295
		#mkdir=>http://php.net/manual/en/function.mkdir.php
4295
		#mkdir=>http://php.net/manual/en/function.mkdir.php
4296
		#chmod=>http://php.net/manual/en/function.chmod.php
4296
		#chmod=>http://php.net/manual/en/function.chmod.php
4297
		$createFolderAfterCheck=fileAccess::createFolderAfterCheck($conf["fileAccess::createFolderAfterCheck"]);
4297
		$createFolderAfterCheck=fileAccess::createFolderAfterCheck($conf["fileAccess::createFolderAfterCheck"]);
4298
		unset($conf["fileAccess::createFolderAfterCheck"]);
4298
		unset($conf["fileAccess::createFolderAfterCheck"]);
4299
		
4299
 
4300
		#如果建立路徑過程出錯
4300
		#如果建立路徑過程出錯
4301
		if($createFolderAfterCheck["status"]==="false"){
4301
		if($createFolderAfterCheck["status"]==="false"){
4302
			
4302
 
4303
			#設置執行失敗
4303
			#設置執行失敗
4304
			$result["status"]="false";
4304
			$result["status"]="false";
4305
			
4305
 
4306
			#設置執行錯誤訊息
4306
			#設置執行錯誤訊息
4307
			$result["error"]=$createFolderAfterCheck;
4307
			$result["error"]=$createFolderAfterCheck;
4308
 
4308
 
4309
			#回傳結果
4309
			#回傳結果
4310
			return $result;
4310
			return $result;
4311
			
4311
 
4312
			}#if end
4312
			}#if end
4313
		
4313
 
4314
		#如果有警告訊息
4314
		#如果有警告訊息
4315
		if(count($createFolderAfterCheck["warning"])>0){
4315
		if(count($createFolderAfterCheck["warning"])>0){
4316
			
4316
 
4317
			#取得警告訊息
4317
			#取得警告訊息
4318
			$result["error"]=$createFolderAfterCheck["warning"];
4318
			$result["error"]=$createFolderAfterCheck["warning"];
4319
			
4319
 
4320
			#設置執行失敗
4320
			#設置執行失敗
4321
			$result["status"]="false";
4321
			$result["status"]="false";
4322
			
4322
 
4323
			#回傳結果
4323
			#回傳結果
4324
			return $result;
4324
			return $result;
4325
			
4325
 
4326
			}#if end
4326
			}#if end
4327
			
4327
 
4328
		#執行到這邊代表成功
4328
		#執行到這邊代表成功
4329
		$result["status"]="true";
4329
		$result["status"]="true";
4330
		
4330
 
4331
		#回傳結果
4331
		#回傳結果
4332
		return $result;
4332
		return $result;
4333
				
4333
 
4334
		}#function validatePath end
4334
		}#function validatePath end
4335
	
4335
 
4336
	/*
4336
	/*
4337
	#函式說明:
4337
	#函式說明:
4338
	#解析路徑的每個層級.
4338
	#解析路徑的每個層級.
4339
	#回傳結果:
4339
	#回傳結果:
4340
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
4340
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 4352... Line 4352...
4352
	#無.
4352
	#無.
4353
	#備註:
4353
	#備註:
4354
	#無.
4354
	#無.
4355
	*/
4355
	*/
4356
	public static function parsePath(&$conf){
4356
	public static function parsePath(&$conf){
4357
	
4357
 
4358
		#初始化要回傳的內容
4358
		#初始化要回傳的內容
4359
		$result=array();
4359
		$result=array();
4360
 
4360
 
4361
		#取得當前執行的函數名稱
4361
		#取得當前執行的函數名稱
4362
		$result["function"]=__FUNCTION__;
4362
		$result["function"]=__FUNCTION__;
4363
 
4363
 
4364
		#如果 $conf 不為陣列
4364
		#如果 $conf 不為陣列
4365
		if(gettype($conf)!="array"){
4365
		if(gettype($conf)!="array"){
4366
			
4366
 
4367
			#設置執行失敗
4367
			#設置執行失敗
4368
			$result["status"]="false";
4368
			$result["status"]="false";
4369
			
4369
 
4370
			#設置執行錯誤訊息
4370
			#設置執行錯誤訊息
4371
			$result["error"][]="\$conf變數須為陣列形態";
4371
			$result["error"][]="\$conf變數須為陣列形態";
4372
 
4372
 
4373
			#如果傳入的參數為 null
4373
			#如果傳入的參數為 null
4374
			if($conf==null){
4374
			if($conf==null){
4375
				
4375
 
4376
				#設置執行錯誤訊息
4376
				#設置執行錯誤訊息
4377
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
4377
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
4378
				
4378
 
4379
				}#if end
4379
				}#if end
4380
 
4380
 
4381
			#回傳結果
4381
			#回傳結果
4382
			return $result;
4382
			return $result;
4383
			
4383
 
4384
			}#if end
4384
			}#if end
4385
 
4385
 
4386
		#記錄使用的參數
4386
		#記錄使用的參數
4387
		$result["argu"]=$conf;
4387
		$result["argu"]=$conf;
4388
 
4388
 
Line 4402... Line 4402...
4402
		#必填寫的參數:
4402
		#必填寫的參數:
4403
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
4403
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
4404
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
4404
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
4405
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
4405
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
4406
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path");
4406
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path");
4407
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
4407
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
4408
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
4408
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
4409
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4409
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4410
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
4410
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
4411
		#可以省略的參數:
4411
		#可以省略的參數:
4412
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
4412
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
4413
		#$conf["canBeEmptyString"]="false";
4413
		#$conf["canBeEmptyString"]="false";
4414
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4414
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4415
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("haveFileName");
4415
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("haveFileName");
4416
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
4416
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
4417
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
4417
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
4418
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4418
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4419
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
4419
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
4420
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4420
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4421
		#$conf["arrayCountEqualCheck"][]=array();
4421
		#$conf["arrayCountEqualCheck"][]=array();
Line 4424... Line 4424...
4424
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
4424
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
4425
		unset($conf["variableCheck::checkArguments"]);
4425
		unset($conf["variableCheck::checkArguments"]);
4426
 
4426
 
4427
		#如果檢查有誤
4427
		#如果檢查有誤
4428
		if($checkResult["status"]=="false"){
4428
		if($checkResult["status"]=="false"){
4429
			
4429
 
4430
			#設置錯誤識別
4430
			#設置錯誤識別
4431
			$result["status"]="false";
4431
			$result["status"]="false";
4432
			
4432
 
4433
			#設置錯誤訊息
4433
			#設置錯誤訊息
4434
			$result["error"]=$checkResult;
4434
			$result["error"]=$checkResult;
4435
			
4435
 
4436
			#回傳結果
4436
			#回傳結果
4437
			return $result;
4437
			return $result;
4438
			
4438
 
4439
			}#if end
4439
			}#if end
4440
		
4440
 
4441
		#如果檢查不通過
4441
		#如果檢查不通過
4442
		if($checkResult["passed"]=="false"){
4442
		if($checkResult["passed"]=="false"){
4443
			
4443
 
4444
			#設置錯誤識別
4444
			#設置錯誤識別
4445
			$result["status"]="false";
4445
			$result["status"]="false";
4446
			
4446
 
4447
			#設置錯誤訊息
4447
			#設置錯誤訊息
4448
			$result["error"]=$checkResult;
4448
			$result["error"]=$checkResult;
4449
			
4449
 
4450
			#回傳結果
4450
			#回傳結果
4451
			return $result;
4451
			return $result;
4452
			
4452
 
4453
			}#if end
4453
			}#if end
4454
		
4454
 
4455
		#函式說明:
4455
		#函式說明:
4456
		#將固定格式的字串分開,並回傳分開的結果.
4456
		#將固定格式的字串分開,並回傳分開的結果.
4457
		#回傳結果:
4457
		#回傳結果:
4458
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4458
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4459
		#$result["error"],錯誤訊息陣列
4459
		#$result["error"],錯誤訊息陣列
Line 4475... Line 4475...
4475
		#無.
4475
		#無.
4476
		#備註:
4476
		#備註:
4477
		#無.
4477
		#無.
4478
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
4478
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
4479
		unset($conf["stringProcess::spiltString"]);
4479
		unset($conf["stringProcess::spiltString"]);
4480
	
4480
 
4481
		#如果檢查有誤
4481
		#如果檢查有誤
4482
		if($spiltString["status"]==="false"){
4482
		if($spiltString["status"]==="false"){
4483
			
4483
 
4484
			#設置錯誤識別
4484
			#設置錯誤識別
4485
			$result["status"]="false";
4485
			$result["status"]="false";
4486
			
4486
 
4487
			#設置錯誤訊息
4487
			#設置錯誤訊息
4488
			$result["error"]=$spiltString;
4488
			$result["error"]=$spiltString;
4489
			
4489
 
4490
			#回傳結果
4490
			#回傳結果
4491
			return $result;
4491
			return $result;
4492
			
4492
 
4493
			}#if end
4493
			}#if end
4494
		
4494
 
4495
		#確認是否為絕對路徑
4495
		#確認是否為絕對路徑
4496
		#函式說明:
4496
		#函式說明:
4497
		#取得符合特定字首與字尾的字串
4497
		#取得符合特定字首與字尾的字串
4498
		#回傳結果:
4498
		#回傳結果:
4499
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
4499
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 4515... Line 4515...
4515
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
4515
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
4516
		#備註:
4516
		#備註:
4517
		#無.
4517
		#無.
4518
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
4518
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
4519
		unset($conf["search::getMeetConditionsString"]);
4519
		unset($conf["search::getMeetConditionsString"]);
4520
		
4520
 
4521
		#如果檢查有誤
4521
		#如果檢查有誤
4522
		if($getMeetConditionsString["status"]==="false"){
4522
		if($getMeetConditionsString["status"]==="false"){
4523
			
4523
 
4524
			#設置錯誤識別
4524
			#設置錯誤識別
4525
			$result["status"]="false";
4525
			$result["status"]="false";
4526
			
4526
 
4527
			#設置錯誤訊息
4527
			#設置錯誤訊息
4528
			$result["error"]=$getMeetConditionsString;
4528
			$result["error"]=$getMeetConditionsString;
4529
			
4529
 
4530
			#回傳結果
4530
			#回傳結果
4531
			return $result;
4531
			return $result;
4532
			
4532
 
4533
			}#if end
4533
			}#if end
4534
		
4534
 
4535
		#如果是絕對路徑
4535
		#如果是絕對路徑
4536
		if($getMeetConditionsString["founded"]==="true"){
4536
		if($getMeetConditionsString["founded"]==="true"){
4537
		
4537
 
4538
			#初始化路徑為 "/"
4538
			#初始化路徑為 "/"
4539
			$result["content"][]="/";
4539
			$result["content"][]="/";
4540
		
4540
 
4541
			}#if end
4541
			}#if end
4542
		
4542
 
4543
		#針對每個切割出來的路徑階層
4543
		#針對每個切割出來的路徑階層
4544
		foreach($spiltString["dataArray"] as $index => $dir){
4544
		foreach($spiltString["dataArray"] as $index => $dir){
4545
		
4545
 
4546
			#如果路徑結尾含有檔案名稱
4546
			#如果路徑結尾含有檔案名稱
4547
			if($conf["haveFileName"]==="true"){
4547
			if($conf["haveFileName"]==="true"){
4548
			
4548
 
4549
				#如果是最後一段
4549
				#如果是最後一段
4550
				if($index===$spiltString["dataCounts"]-1){
4550
				if($index===$spiltString["dataCounts"]-1){
4551
				
4551
 
4552
					#忽略
4552
					#忽略
4553
					continue;
4553
					continue;
4554
				
4554
 
4555
					}#if end
4555
					}#if end
4556
			
4556
 
4557
				}#if end
4557
				}#if end
4558
			
4558
 
4559
			#後面加上 資料夾名稱 跟 "/"
4559
			#後面加上 資料夾名稱 跟 "/"
4560
			$newPath=$dir."/";
4560
			$newPath=$dir."/";
4561
			
4561
 
4562
			#如果有 content
4562
			#如果有 content
4563
			if(isset($result["content"])){
4563
			if(isset($result["content"])){
4564
			
4564
 
4565
				#如果有上個資料夾
4565
				#如果有上個資料夾
4566
				if(isset($result["content"][count($result["content"])-1])){
4566
				if(isset($result["content"][count($result["content"])-1])){
4567
			
4567
 
4568
					#後面加上 上個資料夾名稱 加上資料夾名稱 跟 "/"
4568
					#後面加上 上個資料夾名稱 加上資料夾名稱 跟 "/"
4569
					$newPath=$result["content"][count($result["content"])-1].$dir."/";
4569
					$newPath=$result["content"][count($result["content"])-1].$dir."/";
4570
				
4570
 
4571
					}#if end
4571
					}#if end
4572
			
4572
 
4573
				}#if end
4573
				}#if end
4574
			
4574
 
4575
			#並新增置結果
4575
			#並新增置結果
4576
			$result["content"][]=$newPath;
4576
			$result["content"][]=$newPath;
4577
		
4577
 
4578
			}#foreach end
4578
			}#foreach end
4579
			
4579
 
4580
		#var_dump($result["content"]);
4580
		#var_dump($result["content"]);
4581
			
4581
 
4582
		#設置執行正常
4582
		#設置執行正常
4583
		$result["status"]="true";
4583
		$result["status"]="true";
4584
		
4584
 
4585
		#回傳結果
4585
		#回傳結果
4586
		return $result;
4586
		return $result;
4587
	
4587
 
4588
		}#function parsePath end
4588
		}#function parsePath end
4589
	
4589
 
4590
	/*
4590
	/*
4591
	#函式說明:
4591
	#函式說明:
4592
	#檢查路徑是否存在.
4592
	#檢查路徑是否存在.
4593
	#回傳結果:
4593
	#回傳結果:
4594
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
4594
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 4609... Line 4609...
4609
	#無.
4609
	#無.
4610
	#備註:
4610
	#備註:
4611
	#無.
4611
	#無.
4612
	*/
4612
	*/
4613
	public static function checkPathExist(&$conf){
4613
	public static function checkPathExist(&$conf){
4614
	
4614
 
4615
		#初始化要回傳的內容
4615
		#初始化要回傳的內容
4616
		$result=array();
4616
		$result=array();
4617
 
4617
 
4618
		#取得當前執行的函數名稱
4618
		#取得當前執行的函數名稱
4619
		$result["function"]=__FUNCTION__;
4619
		$result["function"]=__FUNCTION__;
4620
 
4620
 
4621
		#如果 $conf 不為陣列
4621
		#如果 $conf 不為陣列
4622
		if(gettype($conf)!="array"){
4622
		if(gettype($conf)!="array"){
4623
			
4623
 
4624
			#設置執行失敗
4624
			#設置執行失敗
4625
			$result["status"]="false";
4625
			$result["status"]="false";
4626
			
4626
 
4627
			#設置執行錯誤訊息
4627
			#設置執行錯誤訊息
4628
			$result["error"][]="\$conf變數須為陣列形態";
4628
			$result["error"][]="\$conf變數須為陣列形態";
4629
 
4629
 
4630
			#如果傳入的參數為 null
4630
			#如果傳入的參數為 null
4631
			if($conf==null){
4631
			if($conf==null){
4632
				
4632
 
4633
				#設置執行錯誤訊息
4633
				#設置執行錯誤訊息
4634
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
4634
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
4635
				
4635
 
4636
				}#if end
4636
				}#if end
4637
 
4637
 
4638
			#回傳結果
4638
			#回傳結果
4639
			return $result;
4639
			return $result;
4640
			
4640
 
4641
			}#if end
4641
			}#if end
4642
 
4642
 
4643
		#記錄使用的參數
4643
		#記錄使用的參數
4644
		$result["argu"]=$conf;
4644
		$result["argu"]=$conf;
4645
 
4645
 
Line 4659... Line 4659...
4659
		#必填寫的參數:
4659
		#必填寫的參數:
4660
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
4660
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
4661
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
4661
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
4662
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
4662
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
4663
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
4663
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
4664
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
4664
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
4665
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
4665
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
4666
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4666
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4667
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
4667
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
4668
		#可以省略的參數:
4668
		#可以省略的參數:
4669
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
4669
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
4670
		#$conf["canBeEmptyString"]="false";
4670
		#$conf["canBeEmptyString"]="false";
4671
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4671
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4672
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("haveFileName");
4672
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("haveFileName");
4673
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
4673
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
4674
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
4674
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
4675
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4675
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4676
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
4676
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
4677
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4677
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4678
		#$conf["arrayCountEqualCheck"][]=array();
4678
		#$conf["arrayCountEqualCheck"][]=array();
Line 4681... Line 4681...
4681
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
4681
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
4682
		unset($conf["variableCheck::checkArguments"]);
4682
		unset($conf["variableCheck::checkArguments"]);
4683
 
4683
 
4684
		#如果檢查有誤
4684
		#如果檢查有誤
4685
		if($checkResult["status"]=="false"){
4685
		if($checkResult["status"]=="false"){
4686
			
4686
 
4687
			#設置錯誤識別
4687
			#設置錯誤識別
4688
			$result["status"]="false";
4688
			$result["status"]="false";
4689
			
4689
 
4690
			#設置錯誤訊息
4690
			#設置錯誤訊息
4691
			$result["error"]=$checkResult;
4691
			$result["error"]=$checkResult;
4692
			
4692
 
4693
			#回傳結果
4693
			#回傳結果
4694
			return $result;
4694
			return $result;
4695
			
4695
 
4696
			}#if end
4696
			}#if end
4697
		
4697
 
4698
		#如果檢查不通過
4698
		#如果檢查不通過
4699
		if($checkResult["passed"]=="false"){
4699
		if($checkResult["passed"]=="false"){
4700
			
4700
 
4701
			#設置錯誤識別
4701
			#設置錯誤識別
4702
			$result["status"]="false";
4702
			$result["status"]="false";
4703
			
4703
 
4704
			#設置錯誤訊息
4704
			#設置錯誤訊息
4705
			$result["error"]=$checkResult;
4705
			$result["error"]=$checkResult;
4706
			
4706
 
4707
			#回傳結果
4707
			#回傳結果
4708
			return $result;
4708
			return $result;
4709
			
4709
 
4710
			}#if end
4710
			}#if end
4711
	
4711
 
4712
		#函式說明:
4712
		#函式說明:
4713
		#解析路徑的每個層級.
4713
		#解析路徑的每個層級.
4714
		#回傳結果:
4714
		#回傳結果:
4715
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
4715
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
4716
		#$result["error"],錯誤訊息陣列.
4716
		#$result["error"],錯誤訊息陣列.
Line 4727... Line 4727...
4727
		#無.
4727
		#無.
4728
		#備註:
4728
		#備註:
4729
		#無.
4729
		#無.
4730
		$parsePath=fileAccess::parsePath($conf["fileAccess::parsePath"]);
4730
		$parsePath=fileAccess::parsePath($conf["fileAccess::parsePath"]);
4731
		unset($conf["fileAccess::parsePath"]);
4731
		unset($conf["fileAccess::parsePath"]);
4732
	
4732
 
4733
		#如果檢查有誤
4733
		#如果檢查有誤
4734
		if($parsePath["status"]==="false"){
4734
		if($parsePath["status"]==="false"){
4735
			
4735
 
4736
			#設置錯誤識別
4736
			#設置錯誤識別
4737
			$result["status"]="false";
4737
			$result["status"]="false";
4738
			
4738
 
4739
			#設置錯誤訊息
4739
			#設置錯誤訊息
4740
			$result["error"]=$parsePath;
4740
			$result["error"]=$parsePath;
4741
			
4741
 
4742
			#回傳結果
4742
			#回傳結果
4743
			return $result;
4743
			return $result;
4744
			
4744
 
4745
			}#if end
4745
			}#if end
4746
	
4746
 
4747
		#函式說明:
4747
		#函式說明:
4748
		#檢查多個檔案與資料夾是否存在.
4748
		#檢查多個檔案與資料夾是否存在.
4749
		#回傳的結果:
4749
		#回傳的結果:
4750
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
4750
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
4751
		#$result["error"],錯誤訊息陣列.
4751
		#$result["error"],錯誤訊息陣列.
Line 4774... Line 4774...
4774
		#備註:
4774
		#備註:
4775
		#函數file_exists檢查的路徑為檔案系統的路徑
4775
		#函數file_exists檢查的路徑為檔案系統的路徑
4776
		#$result["varName"][$i]結果未實作
4776
		#$result["varName"][$i]結果未實作
4777
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
4777
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
4778
		unset($conf["fileAccess::checkMultiFileExist"]);
4778
		unset($conf["fileAccess::checkMultiFileExist"]);
4779
		
4779
 
4780
		#如果執行異常
4780
		#如果執行異常
4781
		if($checkMultiFileExist["status"]==="false"){
4781
		if($checkMultiFileExist["status"]==="false"){
4782
			
4782
 
4783
			#設置錯誤識別
4783
			#設置錯誤識別
4784
			$result["status"]="false";
4784
			$result["status"]="false";
4785
			
4785
 
4786
			#設置錯誤訊息
4786
			#設置錯誤訊息
4787
			$result["error"]=$checkMultiFileExist;
4787
			$result["error"]=$checkMultiFileExist;
4788
			
4788
 
4789
			#回傳結果
4789
			#回傳結果
4790
			return $result;
4790
			return $result;
4791
			
4791
 
4792
			}#if end
4792
			}#if end
4793
	
4793
 
4794
		#如果有路徑無法存取
4794
		#如果有路徑無法存取
4795
		if($checkMultiFileExist["allExist"]==="false"){
4795
		if($checkMultiFileExist["allExist"]==="false"){
4796
			
4796
 
4797
			#設置執行正常識別
4797
			#設置執行正常識別
4798
			$result["status"]="true";
4798
			$result["status"]="true";
4799
			
4799
 
4800
			#設置路徑找不到
4800
			#設置路徑找不到
4801
			$result["found"]="false";
4801
			$result["found"]="false";
4802
			
4802
 
4803
			#針對每個路徑的搜尋結果
4803
			#針對每個路徑的搜尋結果
4804
			foreach($checkMultiFileExist["varExist"] as $index => $found){
4804
			foreach($checkMultiFileExist["varExist"] as $index => $found){
4805
			
4805
 
4806
				#設置路徑尋找結果
4806
				#設置路徑尋找結果
4807
				$result["content"][]=array("found"=>$found,"path"=>$checkMultiFileExist["varNameFullPath"][$index]);
4807
				$result["content"][]=array("found"=>$found,"path"=>$checkMultiFileExist["varNameFullPath"][$index]);
4808
			
4808
 
4809
				}#foreach end
4809
				}#foreach end
4810
			
4810
 
4811
			#回傳結果
4811
			#回傳結果
4812
			return $result;
4812
			return $result;
4813
			
4813
 
4814
			}#if end
4814
			}#if end
4815
		
4815
 
4816
		#設置路徑有找到
4816
		#設置路徑有找到
4817
		$result["found"]="true";
4817
		$result["found"]="true";
4818
		
4818
 
4819
		#設置執行正常識別
4819
		#設置執行正常識別
4820
		$result["status"]="true";
4820
		$result["status"]="true";
4821
			
4821
 
4822
		#回傳結果
4822
		#回傳結果
4823
		return $result;
4823
		return $result;
4824
		
4824
 
4825
		}#function checkPathExist end
4825
		}#function checkPathExist end
4826
	
4826
 
4827
	/*	
4827
	/*
4828
	#函式說明:
4828
	#函式說明:
4829
	#demo建立pdf檔
4829
	#demo建立pdf檔
4830
	#必填參數:
4830
	#必填參數:
4831
	#無
4831
	#無
4832
	#可省略參數:
4832
	#可省略參數:
Line 4835... Line 4835...
4835
	#tcpdf=>http://www.tcpdf.org/examples.php
4835
	#tcpdf=>http://www.tcpdf.org/examples.php
4836
	#備註:
4836
	#備註:
4837
	#開發中,需要安裝 php-tcpdf 套件.
4837
	#開發中,需要安裝 php-tcpdf 套件.
4838
	*/
4838
	*/
4839
	public static function demoCreateTcPdfFile(){
4839
	public static function demoCreateTcPdfFile(){
4840
		
4840
 
4841
		#避免 TCPDF ERROR: Some data has already been output, can't send PDF file 錯誤產生
4841
		#避免 TCPDF ERROR: Some data has already been output, can't send PDF file 錯誤產生
4842
		ob_end_clean();
4842
		ob_end_clean();
4843
		
4843
 
4844
		#create new PDF document
4844
		#create new PDF document
4845
		$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
4845
		$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
4846
		
4846
 
4847
		#set document information
4847
		#set document information
4848
		$pdf->SetCreator(PDF_CREATOR);
4848
		$pdf->SetCreator(PDF_CREATOR);
4849
		$pdf->SetAuthor('qbpwc');
4849
		$pdf->SetAuthor('qbpwc');
4850
		$pdf->SetTitle('pdf sample title');
4850
		$pdf->SetTitle('pdf sample title');
4851
		$pdf->SetSubject('pdf sample subject');
4851
		$pdf->SetSubject('pdf sample subject');
4852
		$pdf->SetKeywords('pdf, sample, tcpdf, qbpwc');
4852
		$pdf->SetKeywords('pdf, sample, tcpdf, qbpwc');
4853
					
4853
 
4854
		#set default header data
4854
		#set default header data
4855
		$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
4855
		$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
4856
		$pdf->setFooterData(array(0,64,0), array(0,64,128));
4856
		$pdf->setFooterData(array(0,64,0), array(0,64,128));
4857
		
4857
 
4858
		#set header and footer fonts
4858
		#set header and footer fonts
4859
		$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
4859
		$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
4860
		$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
4860
		$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
4861
		
4861
 
4862
		#set default monospaced font
4862
		#set default monospaced font
4863
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
4863
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
4864
		
4864
 
4865
		#set margins
4865
		#set margins
4866
		$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
4866
		$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
4867
		$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
4867
		$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
4868
		$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
4868
		$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
4869
 
4869
 
Line 4873... Line 4873...
4873
		#set image scale factor
4873
		#set image scale factor
4874
		$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
4874
		$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
4875
 
4875
 
4876
		#set some language-dependent strings (optional)
4876
		#set some language-dependent strings (optional)
4877
		if (@file_exists(dirname(__FILE__).'/lang/eng.php')){
4877
		if (@file_exists(dirname(__FILE__).'/lang/eng.php')){
4878
			
4878
 
4879
			require_once(dirname(__FILE__).'/lang/eng.php');
4879
			require_once(dirname(__FILE__).'/lang/eng.php');
4880
			
4880
 
4881
			$pdf->setLanguageArray($l);
4881
			$pdf->setLanguageArray($l);
4882
		
4882
 
4883
			}#if end
4883
			}#if end
4884
			
4884
 
4885
		#set default font subsetting mode
4885
		#set default font subsetting mode
4886
		$pdf->setFontSubsetting(true);
4886
		$pdf->setFontSubsetting(true);
4887
		
4887
 
4888
		#Set font
4888
		#Set font
4889
		#dejavusans is a UTF-8 Unicode font, if you only need to
4889
		#dejavusans is a UTF-8 Unicode font, if you only need to
4890
		#print standard ASCII chars, you can use core fonts like
4890
		#print standard ASCII chars, you can use core fonts like
4891
		#helvetica or times to reduce file size.
4891
		#helvetica or times to reduce file size.
4892
		$pdf->SetFont('dejavusans', '', 14, '', true);
4892
		$pdf->SetFont('dejavusans', '', 14, '', true);
4893
		
4893
 
4894
		#Add a page
4894
		#Add a page
4895
		#This method has several options, check the source code documentation for more information.
4895
		#This method has several options, check the source code documentation for more information.
4896
		$pdf->AddPage();
4896
		$pdf->AddPage();
4897
		
4897
 
4898
		#set text shadow effect
4898
		#set text shadow effect
4899
		$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
4899
		$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
4900
		
4900
 
4901
		#Set some content to print
4901
		#Set some content to print
4902
		$html="<h5>Hello World!</h5>";
4902
		$html="<h5>Hello World!</h5>";
4903
		
4903
 
4904
		// Print text using writeHTMLCell()
4904
		// Print text using writeHTMLCell()
4905
		$pdf->writeHTMLCell(0,0,'','',$html,0,1,0,true,'',true);
4905
		$pdf->writeHTMLCell(0,0,'','',$html,0,1,0,true,'',true);
4906
 
4906
 
4907
		// Close and output PDF document
4907
		// Close and output PDF document
4908
		// This method has several options, check the source code documentation for more information.
4908
		// This method has several options, check the source code documentation for more information.
4909
		$pdf->Output('fileAccessT/example_001.pdf','I');
4909
		$pdf->Output('fileAccessT/example_001.pdf','I');
4910
		
4910
 
4911
		}#function demoCreateTcPdfFile end
4911
		}#function demoCreateTcPdfFile end
4912
		
4912
 
4913
	/*
4913
	/*
4914
	#函式說明:
4914
	#函式說明:
4915
	#取得檔案路徑字串的路徑與檔案的名稱與檔案副檔名
4915
	#取得檔案路徑字串的路徑與檔案的名稱與檔案副檔名
4916
	#回傳的結果:
4916
	#回傳的結果:
4917
	#$result["status"],執行是否正常,"true"正常,"false"代表不正常.
4917
	#$result["status"],執行是否正常,"true"正常,"false"代表不正常.
Line 4931... Line 4931...
4931
	#無.
4931
	#無.
4932
	#備註:
4932
	#備註:
4933
	#無.
4933
	#無.
4934
	*/
4934
	*/
4935
	public static function getFileAddressAndNameAndFileExtention(&$conf){
4935
	public static function getFileAddressAndNameAndFileExtention(&$conf){
4936
		
4936
 
4937
		#初始化要回傳的參數
4937
		#初始化要回傳的參數
4938
		$result=array();
4938
		$result=array();
4939
		
4939
 
4940
		#取得當前執行函數名稱
4940
		#取得當前執行函數名稱
4941
		$result["function"]=__FUNCTION__;
4941
		$result["function"]=__FUNCTION__;
4942
 
4942
 
4943
		#如果 $conf 不為陣列
4943
		#如果 $conf 不為陣列
4944
		if(gettype($conf)!="array"){
4944
		if(gettype($conf)!="array"){
4945
			
4945
 
4946
			#設置執行失敗
4946
			#設置執行失敗
4947
			$result["status"]="false";
4947
			$result["status"]="false";
4948
			
4948
 
4949
			#設置執行錯誤訊息
4949
			#設置執行錯誤訊息
4950
			$result["error"][]="\$conf變數須為陣列形態";
4950
			$result["error"][]="\$conf變數須為陣列形態";
4951
 
4951
 
4952
			#如果傳入的參數為 null
4952
			#如果傳入的參數為 null
4953
			if($conf==null){
4953
			if($conf==null){
4954
				
4954
 
4955
				#設置執行錯誤訊息
4955
				#設置執行錯誤訊息
4956
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
4956
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
4957
				
4957
 
4958
				}#if end
4958
				}#if end
4959
 
4959
 
4960
			#回傳結果
4960
			#回傳結果
4961
			return $result;
4961
			return $result;
4962
			
4962
 
4963
			}#if end
4963
			}#if end
4964
 
4964
 
4965
		#檢查參數
4965
		#檢查參數
4966
		#函式說明:
4966
		#函式說明:
4967
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
4967
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
Line 4978... Line 4978...
4978
		#必填寫的參數:
4978
		#必填寫的參數:
4979
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
4979
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
4980
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
4980
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
4981
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
4981
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
4982
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileAddressAndName");
4982
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileAddressAndName");
4983
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
4983
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
4984
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
4984
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
4985
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4985
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4986
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
4986
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
4987
		#可以省略的參數:
4987
		#可以省略的參數:
4988
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
4988
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
4989
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
4989
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
4990
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4990
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4991
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("outputAddress","noDownload");
4991
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("outputAddress","noDownload");
4992
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
4992
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
4993
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
4993
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
4994
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4994
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4995
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(".bin/".$conf["cppAddress"].".bin","true");
4995
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(".bin/".$conf["cppAddress"].".bin","true");
4996
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4996
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4997
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
4997
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
4998
		#參考資料來源:
4998
		#參考資料來源:
4999
		#array_keys=>http://php.net/manual/en/function.array-keys.php
4999
		#array_keys=>http://php.net/manual/en/function.array-keys.php
5000
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
5000
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
5001
		unset($conf["variableCheck::checkArguments"]);
5001
		unset($conf["variableCheck::checkArguments"]);
5002
							
5002
 
5003
		#如果 $checkArguments["status"] 等於 "false"
5003
		#如果 $checkArguments["status"] 等於 "false"
5004
		if($checkArguments["status"]=="false"){
5004
		if($checkArguments["status"]=="false"){
5005
			
5005
 
5006
			#設置 $result["status"] 為 "false"
5006
			#設置 $result["status"] 為 "false"
5007
			$result["status"]="false";
5007
			$result["status"]="false";
5008
			
5008
 
5009
			#設置 $result["error"]
5009
			#設置 $result["error"]
5010
			$result["error"]=$checkArguments;
5010
			$result["error"]=$checkArguments;
5011
			
5011
 
5012
			#回傳結果
5012
			#回傳結果
5013
			return $result;
5013
			return $result;
5014
			
5014
 
5015
			}#if end
5015
			}#if end
5016
			
5016
 
5017
		#如果 $checkArguments["passed"] 等於 "false"
5017
		#如果 $checkArguments["passed"] 等於 "false"
5018
		if($checkArguments["passed"]=="false"){
5018
		if($checkArguments["passed"]=="false"){
5019
			
5019
 
5020
			#設置 $result["status"] 為 "false"
5020
			#設置 $result["status"] 為 "false"
5021
			$result["status"]="false";
5021
			$result["status"]="false";
5022
			
5022
 
5023
			#設置 $result["error"]
5023
			#設置 $result["error"]
5024
			$result["error"]=$checkArguments;
5024
			$result["error"]=$checkArguments;
5025
			
5025
 
5026
			#回傳結果
5026
			#回傳結果
5027
			return $result;
5027
			return $result;
5028
			
5028
 
5029
			}#if end
5029
			}#if end
5030
		
5030
 
5031
		#確認路徑是否為絕對路徑
5031
		#確認路徑是否為絕對路徑
5032
		#函式說明:
5032
		#函式說明:
5033
		#取得符合特定字首與字尾的字串
5033
		#取得符合特定字首與字尾的字串
5034
		#回傳結果:
5034
		#回傳結果:
5035
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
5035
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 5051... Line 5051...
5051
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
5051
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
5052
		#備註:
5052
		#備註:
5053
		#無.
5053
		#無.
5054
		$getMeetConditionsString=search::getMeetConditionsString($conf["fileAccess::getMeetConditionsString"]);
5054
		$getMeetConditionsString=search::getMeetConditionsString($conf["fileAccess::getMeetConditionsString"]);
5055
		unset($conf["fileAccess::getMeetConditionsString"]);
5055
		unset($conf["fileAccess::getMeetConditionsString"]);
5056
		
5056
 
5057
		#如果執行出錯
5057
		#如果執行出錯
5058
		if($getMeetConditionsString["status"]==="false"){
5058
		if($getMeetConditionsString["status"]==="false"){
5059
			
5059
 
5060
			#設置錯誤識別
5060
			#設置錯誤識別
5061
			$result["status"]="false";
5061
			$result["status"]="false";
5062
			
5062
 
5063
			#設置錯誤訊息
5063
			#設置錯誤訊息
5064
			$result["error"]=$getMeetConditionsString;
5064
			$result["error"]=$getMeetConditionsString;
5065
			
5065
 
5066
			#回傳結果
5066
			#回傳結果
5067
			return $result;
5067
			return $result;
5068
			
5068
 
5069
			}#if end
5069
			}#if end
5070
		
5070
 
5071
		#預設參數 $conf["fileAddressAndName"] 不為 "/" 開始
5071
		#預設參數 $conf["fileAddressAndName"] 不為 "/" 開始
5072
		$fileAddressAndNameStarFromRoot="true";
5072
		$fileAddressAndNameStarFromRoot="true";
5073
		
5073
 
5074
		#如果是 "/" 開頭
5074
		#如果是 "/" 開頭
5075
		if($getMeetConditionsString["founded"]==="false"){
5075
		if($getMeetConditionsString["founded"]==="false"){
5076
			
5076
 
5077
			#設置參數 $conf["fileAddressAndName"] 為 "/" 開始
5077
			#設置參數 $conf["fileAddressAndName"] 為 "/" 開始
5078
			$fileAddressAndNameStarFromRoot="true";
5078
			$fileAddressAndNameStarFromRoot="true";
5079
			
5079
 
5080
			}#if end
5080
			}#if end
5081
		
5081
 
5082
		#檢查是否有路徑資訊 
5082
		#檢查是否有路徑資訊
5083
		#函式說明:
5083
		#函式說明:
5084
		#將固定格式的字串分開,並回傳分開的結果。
5084
		#將固定格式的字串分開,並回傳分開的結果。
5085
		#回傳的參數:
5085
		#回傳的參數:
5086
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5086
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5087
		#$result["error"],錯誤訊息陣列
5087
		#$result["error"],錯誤訊息陣列
Line 5091... Line 5091...
5091
		#必填參數:
5091
		#必填參數:
5092
		$conf["stringProcess"]["spiltString"]["stringIn"]=$conf["fileAddressAndName"];#要處理的字串。
5092
		$conf["stringProcess"]["spiltString"]["stringIn"]=$conf["fileAddressAndName"];#要處理的字串。
5093
		$conf["stringProcess"]["spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
5093
		$conf["stringProcess"]["spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
5094
		$spiledResult=stringProcess::spiltString($conf["stringProcess"]["spiltString"]);
5094
		$spiledResult=stringProcess::spiltString($conf["stringProcess"]["spiltString"]);
5095
		unset($conf["stringProcess"]["spiltString"]);
5095
		unset($conf["stringProcess"]["spiltString"]);
5096
		
5096
 
5097
		#如果 $spiledResult["status"] 等於 "false"
5097
		#如果 $spiledResult["status"] 等於 "false"
5098
		if($spiledResult["status"]==="false"){
5098
		if($spiledResult["status"]==="false"){
5099
			
5099
 
5100
			#設置錯誤識別
5100
			#設置錯誤識別
5101
			$result["status"]="false";
5101
			$result["status"]="false";
5102
			
5102
 
5103
			#設置錯誤訊息
5103
			#設置錯誤訊息
5104
			$result["error"]=$spiledResult;
5104
			$result["error"]=$spiledResult;
5105
			
5105
 
5106
			#回傳結果
5106
			#回傳結果
5107
			return $result;
5107
			return $result;
5108
			
5108
 
5109
			}#if end
5109
			}#if end
5110
			
5110
 
5111
		#如果 $spiledResult["dataCounts"] 大於 1
5111
		#如果 $spiledResult["dataCounts"] 大於 1
5112
		if($spiledResult["dataCounts"]>1){
5112
		if($spiledResult["dataCounts"]>1){
5113
			
5113
 
5114
			#代表有路徑字串
5114
			#代表有路徑字串
5115
			
5115
 
5116
			#初始化路徑字串暫存變數
5116
			#初始化路徑字串暫存變數
5117
			$tempPathStr="";
5117
			$tempPathStr="";
5118
			
5118
 
5119
			#如果是絕對路徑
5119
			#如果是絕對路徑
5120
			if($fileAddressAndNameStarFromRoot==="true"){
5120
			if($fileAddressAndNameStarFromRoot==="true"){
5121
			
5121
 
5122
				#加上根目錄
5122
				#加上根目錄
5123
				$tempPathStr=$tempPathStr."/";
5123
				$tempPathStr=$tempPathStr."/";
5124
			
5124
 
5125
				}#if end
5125
				}#if end
5126
			
5126
 
5127
			#取得路徑字串
5127
			#取得路徑字串
5128
			for($i=0;$i<$spiledResult["dataCounts"]-1;$i++){
5128
			for($i=0;$i<$spiledResult["dataCounts"]-1;$i++){
5129
				
5129
 
5130
				#串連片段路徑字串
5130
				#串連片段路徑字串
5131
				$tempPathStr=$tempPathStr.$spiledResult["dataArray"][$i]."/";
5131
				$tempPathStr=$tempPathStr.$spiledResult["dataArray"][$i]."/";
5132
				
5132
 
5133
				}#for end
5133
				}#for end
5134
				
5134
 
5135
			#取得檔案的路徑
5135
			#取得檔案的路徑
5136
			$result["filePath"]=$tempPathStr;
5136
			$result["filePath"]=$tempPathStr;
5137
			
5137
 
5138
			}#if end
5138
			}#if end
5139
			
5139
 
5140
		#反之 $spiledResult["dataCounts"] 等於 1
5140
		#反之 $spiledResult["dataCounts"] 等於 1
5141
		else{
5141
		else{
5142
			
5142
 
5143
			#檔案的路徑設為""
5143
			#檔案的路徑設為""
5144
			$result["filePath"]="";
5144
			$result["filePath"]="";
5145
			
5145
 
5146
			}#else end
5146
			}#else end
5147
			
5147
 
5148
		#取得檔案名稱(含副檔名)
5148
		#取得檔案名稱(含副檔名)
5149
		$result["fullFileName"]=$spiledResult["dataArray"][$spiledResult["dataCounts"]-1];
5149
		$result["fullFileName"]=$spiledResult["dataArray"][$spiledResult["dataCounts"]-1];
5150
			
5150
 
5151
		#取得副檔名
5151
		#取得副檔名
5152
		#函式說明:
5152
		#函式說明:
5153
		#將固定格式的字串分開,並回傳分開的結果。
5153
		#將固定格式的字串分開,並回傳分開的結果。
5154
		#回傳的參數:
5154
		#回傳的參數:
5155
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5155
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 5160... Line 5160...
5160
		#必填參數:
5160
		#必填參數:
5161
		$conf["stringProcess"]["spiltString"]["stringIn"]=$result["fullFileName"];#要處理的字串。
5161
		$conf["stringProcess"]["spiltString"]["stringIn"]=$result["fullFileName"];#要處理的字串。
5162
		$conf["stringProcess"]["spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
5162
		$conf["stringProcess"]["spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
5163
		$spiledResult=stringProcess::spiltString($conf["stringProcess"]["spiltString"]);
5163
		$spiledResult=stringProcess::spiltString($conf["stringProcess"]["spiltString"]);
5164
		unset($conf["stringProcess"]["spiltString"]);
5164
		unset($conf["stringProcess"]["spiltString"]);
5165
		
5165
 
5166
		#如果 $spiledResult["status"] 等於 "false"
5166
		#如果 $spiledResult["status"] 等於 "false"
5167
		if($spiledResult["status"]=="false"){
5167
		if($spiledResult["status"]=="false"){
5168
			
5168
 
5169
			#設置錯誤識別
5169
			#設置錯誤識別
5170
			$result["status"]="false";
5170
			$result["status"]="false";
5171
			
5171
 
5172
			#設置錯誤訊息
5172
			#設置錯誤訊息
5173
			$result["error"]=$spiledResult;
5173
			$result["error"]=$spiledResult;
5174
			
5174
 
5175
			#回傳結果
5175
			#回傳結果
5176
			return $result;
5176
			return $result;
5177
			
5177
 
5178
			}#if end
5178
			}#if end
5179
			
5179
 
5180
		#如果 $spiledResult["dataCounts"] 大於 1
5180
		#如果 $spiledResult["dataCounts"] 大於 1
5181
		if($spiledResult["dataCounts"]>1){
5181
		if($spiledResult["dataCounts"]>1){
5182
			
5182
 
5183
			#代表有副檔名
5183
			#代表有副檔名
5184
			
5184
 
5185
			#初始化檔名字串暫存變數
5185
			#初始化檔名字串暫存變數
5186
			$tempFileNameStr="";
5186
			$tempFileNameStr="";
5187
			
5187
 
5188
			#取得路徑字串
5188
			#取得路徑字串
5189
			for($i=0;$i<$spiledResult["dataCounts"]-1;$i++){
5189
			for($i=0;$i<$spiledResult["dataCounts"]-1;$i++){
5190
				
5190
 
5191
				#如果是最後一個小黑點前面的字串片段
5191
				#如果是最後一個小黑點前面的字串片段
5192
				if($i==$spiledResult["dataCounts"]-2){
5192
				if($i==$spiledResult["dataCounts"]-2){
5193
					
5193
 
5194
					#串連片段路徑字串
5194
					#串連片段路徑字串
5195
					$tempFileNameStr=$tempFileNameStr.$spiledResult["dataArray"][$i];
5195
					$tempFileNameStr=$tempFileNameStr.$spiledResult["dataArray"][$i];
5196
					
5196
 
5197
					}#if end
5197
					}#if end
5198
				
5198
 
5199
				#反之不是最後一個小黑點前面的字串片段
5199
				#反之不是最後一個小黑點前面的字串片段
5200
				else{
5200
				else{
5201
				
5201
 
5202
					#串連片段路徑字串(含小黑點)
5202
					#串連片段路徑字串(含小黑點)
5203
					$tempFileNameStr=$tempFileNameStr.$spiledResult["dataArray"][$i].".";
5203
					$tempFileNameStr=$tempFileNameStr.$spiledResult["dataArray"][$i].".";
5204
				
5204
 
5205
					}#else end
5205
					}#else end
5206
				
5206
 
5207
				}#for end
5207
				}#for end
5208
				
5208
 
5209
			#取得檔名
5209
			#取得檔名
5210
			$result["fileName"]=$tempFileNameStr;
5210
			$result["fileName"]=$tempFileNameStr;
5211
				
5211
 
5212
			#取得副檔名
5212
			#取得副檔名
5213
			$result["fileExtention"]=$spiledResult["dataArray"][$spiledResult["dataCounts"]-1];
5213
			$result["fileExtention"]=$spiledResult["dataArray"][$spiledResult["dataCounts"]-1];
5214
			
5214
 
5215
			}#if end
5215
			}#if end
5216
			
5216
 
5217
		#反之 $spiledResult["dataCounts"] 等於 1
5217
		#反之 $spiledResult["dataCounts"] 等於 1
5218
		else{
5218
		else{
5219
			
5219
 
5220
			#檔案的副檔名設為""
5220
			#檔案的副檔名設為""
5221
			$result["fileExtention"]="";
5221
			$result["fileExtention"]="";
5222
			
5222
 
5223
			#取得檔案的名稱
5223
			#取得檔案的名稱
5224
			$result["fileName"]=$spiledResult["dataArray"][0];
5224
			$result["fileName"]=$spiledResult["dataArray"][0];
5225
			
5225
 
5226
			}#else end
5226
			}#else end
5227
			
5227
 
5228
		#如果 $result["fileExtention"] 不等於 ""
5228
		#如果 $result["fileExtention"] 不等於 ""
5229
		if($result["fileExtention"]!=""){
5229
		if($result["fileExtention"]!=""){
5230
			
5230
 
5231
			#將副檔名用小黑點跟檔案名稱連在一塊
5231
			#將副檔名用小黑點跟檔案名稱連在一塊
5232
			$result["fullFileName"]=$result["fileName"].".".$result["fileExtention"];
5232
			$result["fullFileName"]=$result["fileName"].".".$result["fileExtention"];
5233
			
5233
 
5234
			}#if end
5234
			}#if end
5235
			
5235
 
5236
		#反之代表沒有副檔名
5236
		#反之代表沒有副檔名
5237
		else{
5237
		else{
5238
			
5238
 
5239
			#取得含副檔名的檔案名稱
5239
			#取得含副檔名的檔案名稱
5240
			$result["fullFileName"]=$result["fileName"].$result["fileExtention"];
5240
			$result["fullFileName"]=$result["fileName"].$result["fileExtention"];
5241
		
5241
 
5242
			}#else end
5242
			}#else end
5243
		
5243
 
5244
		#完整的檔案路徑(含副檔名).
5244
		#完整的檔案路徑(含副檔名).
5245
		$result["fullFilePathAndName"]=$result["filePath"].$result["fullFileName"];
5245
		$result["fullFilePathAndName"]=$result["filePath"].$result["fullFileName"];
5246
		
5246
 
5247
		#設置執行正常的識別
5247
		#設置執行正常的識別
5248
		$result["status"]="true";
5248
		$result["status"]="true";
5249
		
5249
 
5250
		#回傳結果
5250
		#回傳結果
5251
		return $result;
5251
		return $result;
5252
		
5252
 
5253
		}#funciton getFileAddressAndNameAndFileExtention end
5253
		}#funciton getFileAddressAndNameAndFileExtention end
5254
 
5254
 
5255
	/*
5255
	/*
5256
	#函式說明:
5256
	#函式說明:
5257
	#將資料夾或檔案打包成tar檔案
5257
	#將資料夾或檔案打包成tar檔案
Line 5273... Line 5273...
5273
	#無.
5273
	#無.
5274
	#備註:
5274
	#備註:
5275
	#無.
5275
	#無.
5276
	*/
5276
	*/
5277
	public static function makeTarFile(&$conf){
5277
	public static function makeTarFile(&$conf){
5278
		
5278
 
5279
		#初始化要回傳的內容
5279
		#初始化要回傳的內容
5280
		$result=array();
5280
		$result=array();
5281
		
5281
 
5282
		#記錄當前執行的函數名稱
5282
		#記錄當前執行的函數名稱
5283
		$result["function"]=__FUNCTION__;
5283
		$result["function"]=__FUNCTION__;
5284
		
5284
 
5285
		#如果 $conf 不為陣列
5285
		#如果 $conf 不為陣列
5286
		if(gettype($conf)!="array"){
5286
		if(gettype($conf)!="array"){
5287
			
5287
 
5288
			#設置執行失敗
5288
			#設置執行失敗
5289
			$result["status"]="false";
5289
			$result["status"]="false";
5290
			
5290
 
5291
			#設置執行錯誤訊息
5291
			#設置執行錯誤訊息
5292
			$result["error"][]="\$conf變數須為陣列形態";
5292
			$result["error"][]="\$conf變數須為陣列形態";
5293
 
5293
 
5294
			#如果傳入的參數為 null
5294
			#如果傳入的參數為 null
5295
			if($conf==null){
5295
			if($conf==null){
5296
				
5296
 
5297
				#設置執行錯誤訊息
5297
				#設置執行錯誤訊息
5298
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
5298
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
5299
				
5299
 
5300
				}#if end
5300
				}#if end
5301
 
5301
 
5302
			#回傳結果
5302
			#回傳結果
5303
			return $result;
5303
			return $result;
5304
			
5304
 
5305
			}#if end
5305
			}#if end
5306
		
5306
 
5307
		#檢查參數
5307
		#檢查參數
5308
		#函式說明:
5308
		#函式說明:
5309
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
5309
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
5310
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5310
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5311
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
5311
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 5317... Line 5317...
5317
		#必填寫的參數:
5317
		#必填寫的參數:
5318
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
5318
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
5319
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
5319
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
5320
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
5320
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
5321
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","packetTarget","createdTarFile");
5321
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","packetTarget","createdTarFile");
5322
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
5322
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
5323
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array","string");
5323
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array","string");
5324
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
5324
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
5325
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
5325
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
5326
		#可以省略的參數:
5326
		#可以省略的參數:
5327
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
5327
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
5328
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
5328
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
5329
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
5329
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
5330
		#$conf["skipableVariableName"]=array();
5330
		#$conf["skipableVariableName"]=array();
5331
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
5331
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
5332
		#$conf["skipableVariableType"]=array();
5332
		#$conf["skipableVariableType"]=array();
5333
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
5333
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
5334
		#$conf["skipableVarDefaultValue"]=array("");
5334
		#$conf["skipableVarDefaultValue"]=array("");
5335
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
5335
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
5336
		#$conf["arrayCountEqualCheck"][]=array();
5336
		#$conf["arrayCountEqualCheck"][]=array();
5337
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
5337
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
5338
		unset($conf["variableCheck::checkArguments"]);
5338
		unset($conf["variableCheck::checkArguments"]);
5339
		
5339
 
5340
		#若檢查失敗
5340
		#若檢查失敗
5341
		if($checkResult["status"]=="false"){
5341
		if($checkResult["status"]=="false"){
5342
			
5342
 
5343
			#設置執行失敗
5343
			#設置執行失敗
5344
			$result["status"]="false";
5344
			$result["status"]="false";
5345
			
5345
 
5346
			#設置執行錯誤訊息
5346
			#設置執行錯誤訊息
5347
			$result["error"]=$checkResult;
5347
			$result["error"]=$checkResult;
5348
			
5348
 
5349
			#回傳結果
5349
			#回傳結果
5350
			return $result;
5350
			return $result;
5351
			
5351
 
5352
			}#if end
5352
			}#if end
5353
			
5353
 
5354
		#若檢查不通過
5354
		#若檢查不通過
5355
		if($checkResult["passed"]=="false"){
5355
		if($checkResult["passed"]=="false"){
5356
			
5356
 
5357
			#設置執行失敗
5357
			#設置執行失敗
5358
			$result["status"]="false";
5358
			$result["status"]="false";
5359
			
5359
 
5360
			#設置執行錯誤訊息
5360
			#設置執行錯誤訊息
5361
			$result["error"]=$checkResult;
5361
			$result["error"]=$checkResult;
5362
			
5362
 
5363
			#回傳結果
5363
			#回傳結果
5364
			return $result;
5364
			return $result;
5365
			
5365
 
5366
			}#if end
5366
			}#if end
5367
		
5367
 
5368
		#初始化打包要用的tar指令參數
5368
		#初始化打包要用的tar指令參數
5369
		$paramsArray=array("-cvf",$conf["createdTarFile"].".tar");
5369
		$paramsArray=array("-cvf",$conf["createdTarFile"].".tar");
5370
		
5370
 
5371
		#檢查要打包的檔案是否存在
5371
		#檢查要打包的檔案是否存在
5372
		#函式說明:
5372
		#函式說明:
5373
		#檢查多個檔案與資料夾是否存在.
5373
		#檢查多個檔案與資料夾是否存在.
5374
		#回傳的結果:
5374
		#回傳的結果:
5375
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
5375
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 5394... Line 5394...
5394
		#http://php.net/manual/en/control-structures.foreach.php
5394
		#http://php.net/manual/en/control-structures.foreach.php
5395
		#備註:
5395
		#備註:
5396
		#函數file_exists檢查的路徑為檔案系統的路徑
5396
		#函數file_exists檢查的路徑為檔案系統的路徑
5397
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
5397
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
5398
		unset($conf["fileAccess::checkMultiFileExist"]);
5398
		unset($conf["fileAccess::checkMultiFileExist"]);
5399
		
5399
 
5400
		#如果檢查要打包的檔案失敗
5400
		#如果檢查要打包的檔案失敗
5401
		if($checkMultiFileExist["status"]=="false"){
5401
		if($checkMultiFileExist["status"]=="false"){
5402
			
5402
 
5403
			#設置執行失敗
5403
			#設置執行失敗
5404
			$result["status"]="false";
5404
			$result["status"]="false";
5405
			
5405
 
5406
			#設置執行錯誤訊息
5406
			#設置執行錯誤訊息
5407
			$result["error"]=$checkMultiFileExist;
5407
			$result["error"]=$checkMultiFileExist;
5408
			
5408
 
5409
			#回傳結果
5409
			#回傳結果
5410
			return $result;
5410
			return $result;
5411
			
5411
 
5412
			}#if end
5412
			}#if end
5413
			
5413
 
5414
		#如果要打包的檔案有缺
5414
		#如果要打包的檔案有缺
5415
		if($checkMultiFileExist["allExist"]=="false"){
5415
		if($checkMultiFileExist["allExist"]=="false"){
5416
			
5416
 
5417
			#設置執行失敗
5417
			#設置執行失敗
5418
			$result["status"]="false";
5418
			$result["status"]="false";
5419
			
5419
 
5420
			#設置執行錯誤訊息
5420
			#設置執行錯誤訊息
5421
			$result["error"]=$checkMultiFileExist;
5421
			$result["error"]=$checkMultiFileExist;
5422
			
5422
 
5423
			#回傳結果
5423
			#回傳結果
5424
			return $result;
5424
			return $result;
5425
			
5425
 
5426
			}#if end
5426
			}#if end
5427
		
5427
 
5428
		#有幾個要打包的目標就執行幾次
5428
		#有幾個要打包的目標就執行幾次
5429
		for($i=0;$i<count($conf["packetTarget"]);$i++){
5429
		for($i=0;$i<count($conf["packetTarget"]);$i++){
5430
			
5430
 
5431
			#串接上要打包的檔案或資料夾
5431
			#串接上要打包的檔案或資料夾
5432
			$paramsArray[]=$conf["packetTarget"][$i];
5432
			$paramsArray[]=$conf["packetTarget"][$i];
5433
			
5433
 
5434
			}#for end
5434
			}#for end
5435
		
5435
 
5436
		#函式說明:
5436
		#函式說明:
5437
		#呼叫shell執行系統命令,並取得回傳的內容.
5437
		#呼叫shell執行系統命令,並取得回傳的內容.
5438
		#回傳結果:
5438
		#回傳結果:
5439
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5439
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5440
		#$result["error"],錯誤訊息陣列.
5440
		#$result["error"],錯誤訊息陣列.
Line 5490... Line 5490...
5490
		#備註:
5490
		#備註:
5491
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
5491
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
5492
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
5492
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
5493
		$conf["external::callShell"]=external::callShell($conf["external::callShell"]);
5493
		$conf["external::callShell"]=external::callShell($conf["external::callShell"]);
5494
		unset($conf["external::callShell"]);
5494
		unset($conf["external::callShell"]);
5495
		
5495
 
5496
		#如果執行shell失敗
5496
		#如果執行shell失敗
5497
		if($callShell["status"]=="false"){
5497
		if($callShell["status"]=="false"){
5498
			
5498
 
5499
			#設置執行失敗
5499
			#設置執行失敗
5500
			$result["status"]="false";
5500
			$result["status"]="false";
5501
			
5501
 
5502
			#設置執行錯誤訊息
5502
			#設置執行錯誤訊息
5503
			$result["error"]=$callShell;
5503
			$result["error"]=$callShell;
5504
			
5504
 
5505
			#回傳結果
5505
			#回傳結果
5506
			return $result;
5506
			return $result;
5507
			
5507
 
5508
			}#if end
5508
			}#if end
5509
		
5509
 
5510
		#打包好的檔案位置與名稱
5510
		#打包好的檔案位置與名稱
5511
		$result["content"]=$conf["createdTarFile"].".tar";
5511
		$result["content"]=$conf["createdTarFile"].".tar";
5512
		
5512
 
5513
		#執行到這邊代表執行正常
5513
		#執行到這邊代表執行正常
5514
		$result["status"]="true";
5514
		$result["status"]="true";
5515
		
5515
 
5516
		#回傳結果
5516
		#回傳結果
5517
		return $result;
5517
		return $result;
5518
		
5518
 
5519
		}#function makeTarFile end
5519
		}#function makeTarFile end
5520
		
5520
 
5521
	/*
5521
	/*
5522
	#函式說明:
5522
	#函式說明:
5523
	#將一個檔案壓縮成xz檔案
5523
	#將一個檔案壓縮成xz檔案
5524
	#回傳結果:
5524
	#回傳結果:
5525
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5525
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 5542... Line 5542...
5542
	*/
5542
	*/
5543
	public static function makeXzFile(&$conf){
5543
	public static function makeXzFile(&$conf){
5544
 
5544
 
5545
		#初始化要回傳的內容
5545
		#初始化要回傳的內容
5546
		$result=array();
5546
		$result=array();
5547
		
5547
 
5548
		#記錄當前執行的函數名稱
5548
		#記錄當前執行的函數名稱
5549
		$result["function"]=__FUNCTION__;
5549
		$result["function"]=__FUNCTION__;
5550
		
5550
 
5551
		#如果 $conf 不為陣列
5551
		#如果 $conf 不為陣列
5552
		if(gettype($conf)!="array"){
5552
		if(gettype($conf)!="array"){
5553
			
5553
 
5554
			#設置執行失敗
5554
			#設置執行失敗
5555
			$result["status"]="false";
5555
			$result["status"]="false";
5556
			
5556
 
5557
			#設置執行錯誤訊息
5557
			#設置執行錯誤訊息
5558
			$result["error"][]="\$conf變數須為陣列形態";
5558
			$result["error"][]="\$conf變數須為陣列形態";
5559
 
5559
 
5560
			#如果傳入的參數為 null
5560
			#如果傳入的參數為 null
5561
			if($conf==null){
5561
			if($conf==null){
5562
				
5562
 
5563
				#設置執行錯誤訊息
5563
				#設置執行錯誤訊息
5564
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
5564
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
5565
				
5565
 
5566
				}#if end
5566
				}#if end
5567
 
5567
 
5568
			#回傳結果
5568
			#回傳結果
5569
			return $result;
5569
			return $result;
5570
			
5570
 
5571
			}#if end
5571
			}#if end
5572
		
5572
 
5573
		#檢查參數
5573
		#檢查參數
5574
		#函式說明:
5574
		#函式說明:
5575
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
5575
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
5576
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5576
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5577
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
5577
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 5583... Line 5583...
5583
		#必填寫的參數:
5583
		#必填寫的參數:
5584
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
5584
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
5585
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
5585
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
5586
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
5586
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
5587
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","compressTarget","createdXzFile");
5587
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","compressTarget","createdXzFile");
5588
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
5588
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
5589
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
5589
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
5590
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
5590
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
5591
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
5591
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
5592
		#可以省略的參數:
5592
		#可以省略的參數:
5593
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
5593
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
5594
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
5594
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
5595
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
5595
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
5596
		#$conf["skipableVariableName"]=array();
5596
		#$conf["skipableVariableName"]=array();
5597
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
5597
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
5598
		#$conf["skipableVariableType"]=array();
5598
		#$conf["skipableVariableType"]=array();
5599
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
5599
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
5600
		#$conf["skipableVarDefaultValue"]=array("");
5600
		#$conf["skipableVarDefaultValue"]=array("");
5601
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
5601
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
5602
		#$conf["arrayCountEqualCheck"][]=array();
5602
		#$conf["arrayCountEqualCheck"][]=array();
5603
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
5603
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
5604
		unset($conf["variableCheck::checkArguments"]);
5604
		unset($conf["variableCheck::checkArguments"]);
5605
		
5605
 
5606
		#若檢查失敗
5606
		#若檢查失敗
5607
		if($checkResult["status"]=="false"){
5607
		if($checkResult["status"]=="false"){
5608
			
5608
 
5609
			#設置執行失敗
5609
			#設置執行失敗
5610
			$result["status"]="false";
5610
			$result["status"]="false";
5611
			
5611
 
5612
			#設置執行錯誤訊息
5612
			#設置執行錯誤訊息
5613
			$result["error"]=$checkResult;
5613
			$result["error"]=$checkResult;
5614
			
5614
 
5615
			#回傳結果
5615
			#回傳結果
5616
			return $result;
5616
			return $result;
5617
			
5617
 
5618
			}#if end
5618
			}#if end
5619
			
5619
 
5620
		#若檢查不通過
5620
		#若檢查不通過
5621
		if($checkResult["passed"]=="false"){
5621
		if($checkResult["passed"]=="false"){
5622
			
5622
 
5623
			#設置執行失敗
5623
			#設置執行失敗
5624
			$result["status"]="false";
5624
			$result["status"]="false";
5625
			
5625
 
5626
			#設置執行錯誤訊息
5626
			#設置執行錯誤訊息
5627
			$result["error"]=$checkResult;
5627
			$result["error"]=$checkResult;
5628
			
5628
 
5629
			#回傳結果
5629
			#回傳結果
5630
			return $result;
5630
			return $result;
5631
			
5631
 
5632
			}#if end
5632
			}#if end
5633
		
5633
 
5634
		#檢查要用xz壓縮的檔案是否存在
5634
		#檢查要用xz壓縮的檔案是否存在
5635
		#函式說明:
5635
		#函式說明:
5636
		#檢查多個檔案與資料夾是否存在.
5636
		#檢查多個檔案與資料夾是否存在.
5637
		#回傳的結果:
5637
		#回傳的結果:
5638
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
5638
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 5657... Line 5657...
5657
		#http://php.net/manual/en/control-structures.foreach.php
5657
		#http://php.net/manual/en/control-structures.foreach.php
5658
		#備註:
5658
		#備註:
5659
		#函數file_exists檢查的路徑為檔案系統的路徑
5659
		#函數file_exists檢查的路徑為檔案系統的路徑
5660
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
5660
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
5661
		unset($conf["fileAccess::checkMultiFileExist"]);
5661
		unset($conf["fileAccess::checkMultiFileExist"]);
5662
		
5662
 
5663
		#如果檢查要用xz壓縮的檔案失敗
5663
		#如果檢查要用xz壓縮的檔案失敗
5664
		if($checkMultiFileExist["status"]=="false"){
5664
		if($checkMultiFileExist["status"]=="false"){
5665
			
5665
 
5666
			#設置執行失敗
5666
			#設置執行失敗
5667
			$result["status"]="false";
5667
			$result["status"]="false";
5668
			
5668
 
5669
			#設置執行錯誤訊息
5669
			#設置執行錯誤訊息
5670
			$result["error"]=$checkMultiFileExist;
5670
			$result["error"]=$checkMultiFileExist;
5671
			
5671
 
5672
			#回傳結果
5672
			#回傳結果
5673
			return $result;
5673
			return $result;
5674
			
5674
 
5675
			}#if end
5675
			}#if end
5676
			
5676
 
5677
		#如果要用xz壓縮的檔案有缺
5677
		#如果要用xz壓縮的檔案有缺
5678
		if($checkMultiFileExist["allExist"]=="false"){
5678
		if($checkMultiFileExist["allExist"]=="false"){
5679
			
5679
 
5680
			#設置執行失敗
5680
			#設置執行失敗
5681
			$result["status"]="false";
5681
			$result["status"]="false";
5682
			
5682
 
5683
			#設置執行錯誤訊息
5683
			#設置執行錯誤訊息
5684
			$result["error"]=$checkMultiFileExist;
5684
			$result["error"]=$checkMultiFileExist;
5685
			
5685
 
5686
			#回傳結果
5686
			#回傳結果
5687
			return $result;
5687
			return $result;
5688
			
5688
 
5689
			}#if end
5689
			}#if end
5690
		
5690
 
5691
		#壓縮要用的xz語法
5691
		#壓縮要用的xz語法
5692
		#函式說明:
5692
		#函式說明:
5693
		#呼叫shell執行系統命令,並取得回傳的內容.
5693
		#呼叫shell執行系統命令,並取得回傳的內容.
5694
		#回傳的結果:
5694
		#回傳的結果:
5695
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5695
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 5710... Line 5710...
5710
		$conf["external::callShell"]["escapeshellarg"]="true";
5710
		$conf["external::callShell"]["escapeshellarg"]="true";
5711
		#參考資料:
5711
		#參考資料:
5712
		#http://php.net/manual/en/function.exec.php
5712
		#http://php.net/manual/en/function.exec.php
5713
		$callShell=external::callShell($conf["external::callShell"]);
5713
		$callShell=external::callShell($conf["external::callShell"]);
5714
		unset($conf["external::callShell"]);
5714
		unset($conf["external::callShell"]);
5715
		
5715
 
5716
		#如果執行shell失敗
5716
		#如果執行shell失敗
5717
		if($callShell["status"]=="false"){
5717
		if($callShell["status"]=="false"){
5718
			
5718
 
5719
			#設置執行失敗
5719
			#設置執行失敗
5720
			$result["status"]="false";
5720
			$result["status"]="false";
5721
			
5721
 
5722
			#設置執行錯誤訊息
5722
			#設置執行錯誤訊息
5723
			$result["error"]=$callShell;
5723
			$result["error"]=$callShell;
5724
			
5724
 
5725
			#回傳結果
5725
			#回傳結果
5726
			return $result;
5726
			return $result;
5727
			
5727
 
5728
			}#if end
5728
			}#if end
5729
		
5729
 
5730
		#壓縮好的檔案位置與名稱
5730
		#壓縮好的檔案位置與名稱
5731
		$result["content"]=$conf["createdXzFile"].".xz";
5731
		$result["content"]=$conf["createdXzFile"].".xz";
5732
		
5732
 
5733
		#執行到這邊代表執行正常
5733
		#執行到這邊代表執行正常
5734
		$result["status"]="status";
5734
		$result["status"]="status";
5735
		
5735
 
5736
		#回傳結果
5736
		#回傳結果
5737
		return $result;
5737
		return $result;
5738
 
5738
 
5739
		}#function makeXzFile end
5739
		}#function makeXzFile end
5740
		
5740
 
5741
	/*
5741
	/*
5742
	#函式說明:
5742
	#函式說明:
5743
	#將資料夾或檔案打包壓縮成tar.xz檔案
5743
	#將資料夾或檔案打包壓縮成tar.xz檔案
5744
	#回傳結果:
5744
	#回傳結果:
5745
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5745
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 5761... Line 5761...
5761
	#$conf["includeWaveEnd"],字串,當參數$conf["commentsArray"]含有星號時是否要包含「~」結尾的檔案.預設為"false",不包含,"true"為要包含.
5761
	#$conf["includeWaveEnd"],字串,當參數$conf["commentsArray"]含有星號時是否要包含「~」結尾的檔案.預設為"false",不包含,"true"為要包含.
5762
	#$conf["includeWaveEnd"]="false";
5762
	#$conf["includeWaveEnd"]="false";
5763
	#參考資料:
5763
	#參考資料:
5764
	#無.
5764
	#無.
5765
	#備註:
5765
	#備註:
5766
	#建議加上 --exclude-backups, --exclude-caches-all 
5766
	#建議加上 --exclude-backups, --exclude-caches-all
5767
	*/
5767
	*/
5768
	public static function makeTarXzFile(&$conf){
5768
	public static function makeTarXzFile(&$conf){
5769
		
5769
 
5770
		#初始化要回傳的內容
5770
		#初始化要回傳的內容
5771
		$result=array();
5771
		$result=array();
5772
		
5772
 
5773
		#記錄當前執行的函數名稱
5773
		#記錄當前執行的函數名稱
5774
		$result["function"]=__FUNCTION__;
5774
		$result["function"]=__FUNCTION__;
5775
		
5775
 
5776
		#如果 $conf 不為陣列
5776
		#如果 $conf 不為陣列
5777
		if(gettype($conf)!="array"){
5777
		if(gettype($conf)!="array"){
5778
			
5778
 
5779
			#設置執行失敗
5779
			#設置執行失敗
5780
			$result["status"]="false";
5780
			$result["status"]="false";
5781
			
5781
 
5782
			#設置執行錯誤訊息
5782
			#設置執行錯誤訊息
5783
			$result["error"][]="\$conf變數須為陣列形態";
5783
			$result["error"][]="\$conf變數須為陣列形態";
5784
 
5784
 
5785
			#如果傳入的參數為 null
5785
			#如果傳入的參數為 null
5786
			if($conf==null){
5786
			if($conf==null){
5787
				
5787
 
5788
				#設置執行錯誤訊息
5788
				#設置執行錯誤訊息
5789
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
5789
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
5790
				
5790
 
5791
				}#if end
5791
				}#if end
5792
 
5792
 
5793
			#回傳結果
5793
			#回傳結果
5794
			return $result;
5794
			return $result;
5795
			
5795
 
5796
			}#if end
5796
			}#if end
5797
		
5797
 
5798
		#檢查參數
5798
		#檢查參數
5799
		#函式說明:
5799
		#函式說明:
5800
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
5800
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
5801
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5801
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5802
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
5802
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 5808... Line 5808...
5808
		#必填寫的參數:
5808
		#必填寫的參數:
5809
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
5809
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
5810
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
5810
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
5811
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
5811
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
5812
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","compressTarget","createdTarXzFile");
5812
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","compressTarget","createdTarXzFile");
5813
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
5813
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
5814
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array","string");
5814
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array","string");
5815
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
5815
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
5816
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
5816
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
5817
		#可以省略的參數:
5817
		#可以省略的參數:
5818
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
5818
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
5819
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
5819
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
5820
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
5820
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
5821
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray","includeDotStart","includeWaveEnd");
5821
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray","includeDotStart","includeWaveEnd");
5822
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
5822
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
5823
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string");
5823
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string");
5824
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
5824
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
5825
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"false","false");
5825
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"false","false");
5826
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
5826
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
5827
		#$conf["arrayCountEqualCheck"][]=array();
5827
		#$conf["arrayCountEqualCheck"][]=array();
5828
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
5828
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
5829
		unset($conf["variableCheck::checkArguments"]);
5829
		unset($conf["variableCheck::checkArguments"]);
5830
		
5830
 
5831
		#若檢查失敗
5831
		#若檢查失敗
5832
		if($checkResult["status"]=="false"){
5832
		if($checkResult["status"]=="false"){
5833
			
5833
 
5834
			#設置執行失敗
5834
			#設置執行失敗
5835
			$result["status"]="false";
5835
			$result["status"]="false";
5836
			
5836
 
5837
			#設置執行錯誤訊息
5837
			#設置執行錯誤訊息
5838
			$result["error"]=$checkResult;
5838
			$result["error"]=$checkResult;
5839
			
5839
 
5840
			#回傳結果
5840
			#回傳結果
5841
			return $result;
5841
			return $result;
5842
			
5842
 
5843
			}#if end
5843
			}#if end
5844
			
5844
 
5845
		#若檢查不通過
5845
		#若檢查不通過
5846
		if($checkResult["passed"]=="false"){
5846
		if($checkResult["passed"]=="false"){
5847
			
5847
 
5848
			#設置執行失敗
5848
			#設置執行失敗
5849
			$result["status"]="false";
5849
			$result["status"]="false";
5850
			
5850
 
5851
			#設置執行錯誤訊息
5851
			#設置執行錯誤訊息
5852
			$result["error"]=$checkResult;
5852
			$result["error"]=$checkResult;
5853
			
5853
 
5854
			#回傳結果
5854
			#回傳結果
5855
			return $result;
5855
			return $result;
5856
			
5856
 
5857
			}#if end
5857
			}#if end
5858
			
5858
 
5859
		#如果 $conf["commentsArray"] 有設定
5859
		#如果 $conf["commentsArray"] 有設定
5860
		if(isset($conf["commentsArray"])){
5860
		if(isset($conf["commentsArray"])){
5861
			
5861
 
5862
			#印出提示文字
5862
			#印出提示文字
5863
			#函式說明:
5863
			#函式說明:
5864
			#印出多行文字,結尾自動換行.
5864
			#印出多行文字,結尾自動換行.
5865
			#回傳的結果:
5865
			#回傳的結果:
5866
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
5866
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
Line 5869... Line 5869...
5869
			#必填參數:
5869
			#必填參數:
5870
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
5870
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
5871
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
5871
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
5872
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
5872
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
5873
			unset($conf["cmd::echoMultiLine"]);
5873
			unset($conf["cmd::echoMultiLine"]);
5874
			
5874
 
5875
			#如果印出提示文字失敗
5875
			#如果印出提示文字失敗
5876
			if($echoMultiLine["status"]=="false"){
5876
			if($echoMultiLine["status"]=="false"){
5877
				
5877
 
5878
				#設置執行失敗
5878
				#設置執行失敗
5879
				$result["status"]="false";
5879
				$result["status"]="false";
5880
				
5880
 
5881
				#設置執行錯誤訊息
5881
				#設置執行錯誤訊息
5882
				$result["error"]=$echoMultiLine;
5882
				$result["error"]=$echoMultiLine;
5883
				
5883
 
5884
				#回傳結果
5884
				#回傳結果
5885
				return $result;
5885
				return $result;
5886
				
5886
 
5887
				}#if end
5887
				}#if end
5888
			
5888
 
5889
			}#if end	
5889
			}#if end
5890
			
5890
 
5891
		#解析要處理的檔案路徑
5891
		#解析要處理的檔案路徑
5892
		#函式說明:
5892
		#函式說明:
5893
		#將含有「*」的多個檔案路徑名稱,變成多個符合條件的路徑檔案.
5893
		#將含有「*」的多個檔案路徑名稱,變成多個符合條件的路徑檔案.
5894
		#回傳結果:
5894
		#回傳結果:
5895
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
5895
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
5896
		#$result["error"],錯誤訊息陣列.
5896
		#$result["error"],錯誤訊息陣列.
5897
		#$result["function"],函數名稱. 
5897
		#$result["function"],函數名稱.
5898
		#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
5898
		#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
5899
		#$result["pathCount"],整數,有幾個路徑.
5899
		#$result["pathCount"],整數,有幾個路徑.
5900
		#必填參數:
5900
		#必填參數:
5901
		#$conf["path"],字串陣列,要解析含有「*」的檔案路徑字串.
5901
		#$conf["path"],字串陣列,要解析含有「*」的檔案路徑字串.
5902
		$conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]["path"]=$conf["compressTarget"];
5902
		$conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]["path"]=$conf["compressTarget"];
Line 5907... Line 5907...
5907
		$conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]["noDotStart"]=$conf["includeDotStart"]==="true"?"false":"true";
5907
		$conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]["noDotStart"]=$conf["includeDotStart"]==="true"?"false":"true";
5908
		#$conf["noWaveEnd"],字串,預設為"true"代表不包含「~」結尾的名稱,"false"代表包含結尾為「~」的名稱.
5908
		#$conf["noWaveEnd"],字串,預設為"true"代表不包含「~」結尾的名稱,"false"代表包含結尾為「~」的名稱.
5909
		$conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]["noWaveEnd"]=$conf["includeWaveEnd"]==="true"?"false":"true";
5909
		$conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]["noWaveEnd"]=$conf["includeWaveEnd"]==="true"?"false":"true";
5910
		$realPathArray=fileAccess::resolveMultiPostionStringWhichContainStarSymbol($conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]);
5910
		$realPathArray=fileAccess::resolveMultiPostionStringWhichContainStarSymbol($conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]);
5911
		unset($conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]);
5911
		unset($conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]);
5912
			
5912
 
5913
		#如果解析路徑失敗
5913
		#如果解析路徑失敗
5914
		if($realPathArray["status"]=="false"){
5914
		if($realPathArray["status"]=="false"){
5915
			
5915
 
5916
			#設置執行失敗
5916
			#設置執行失敗
5917
			$result["status"]="false";
5917
			$result["status"]="false";
5918
			
5918
 
5919
			#設置執行錯誤訊息
5919
			#設置執行錯誤訊息
5920
			$result["error"]=$realPathArray;
5920
			$result["error"]=$realPathArray;
5921
			
5921
 
5922
			#回傳結果
5922
			#回傳結果
5923
			return $result;
5923
			return $result;
5924
			
5924
 
5925
			}#if end
5925
			}#if end
5926
		
5926
 
5927
		#取得解析好的檔案路徑陣列
5927
		#取得解析好的檔案路徑陣列
5928
		$conf["compressTarget"]=$realPathArray["content"];	
5928
		$conf["compressTarget"]=$realPathArray["content"];
5929
		
5929
 
5930
		#將路徑轉換成相對路徑
5930
		#將路徑轉換成相對路徑
5931
		#函式說明:
5931
		#函式說明:
5932
		#將多個路徑字串變成相對於當前路徑的相對路徑字串
5932
		#將多個路徑字串變成相對於當前路徑的相對路徑字串
5933
		#回傳結果:
5933
		#回傳結果:
5934
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
5934
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
5935
		#$result["error"],錯誤訊息陣列.
5935
		#$result["error"],錯誤訊息陣列.
5936
		#$result["function"],函數名稱. 
5936
		#$result["function"],函數名稱.
5937
		#$result["content"],字串陣列,多個轉換好的相對路徑字串.
5937
		#$result["content"],字串陣列,多個轉換好的相對路徑字串.
5938
		#必填參數:
5938
		#必填參數:
5939
		#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
5939
		#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
5940
		$conf["fileAccess::getRelativePath"]["path"]=$conf["compressTarget"];
5940
		$conf["fileAccess::getRelativePath"]["path"]=$conf["compressTarget"];
5941
		#$conf["fileArgu"],字串,當前路徑.
5941
		#$conf["fileArgu"],字串,當前路徑.
5942
		$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
5942
		$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
5943
		$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
5943
		$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
5944
		unset($conf["fileAccess::getRelativePath"]);
5944
		unset($conf["fileAccess::getRelativePath"]);
5945
		
5945
 
5946
		#如果轉換失敗
5946
		#如果轉換失敗
5947
		if($getRelativePath["status"]=="false"){
5947
		if($getRelativePath["status"]=="false"){
5948
			
5948
 
5949
			#設置執行失敗
5949
			#設置執行失敗
5950
			$result["status"]="false";
5950
			$result["status"]="false";
5951
			
5951
 
5952
			#設置執行錯誤訊息
5952
			#設置執行錯誤訊息
5953
			$result["error"]=$getRelativePat;
5953
			$result["error"]=$getRelativePat;
5954
			
5954
 
5955
			#回傳結果
5955
			#回傳結果
5956
			return $result;
5956
			return $result;
5957
			
5957
 
5958
			}#if end	
5958
			}#if end
5959
				
5959
 
5960
		#打包成tar檔
5960
		#打包成tar檔
5961
		#函式說明:
5961
		#函式說明:
5962
		#將資料夾或檔案打包成tar檔案
5962
		#將資料夾或檔案打包成tar檔案
5963
		#回傳的結果:
5963
		#回傳的結果:
5964
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5964
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 5972... Line 5972...
5972
		$conf["fileAccess::makeTarFile"]["createdTarFile"]=$conf["createdTarXzFile"];
5972
		$conf["fileAccess::makeTarFile"]["createdTarFile"]=$conf["createdTarXzFile"];
5973
		#$conf["fileAccess::makeTarFile"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5973
		#$conf["fileAccess::makeTarFile"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5974
		$conf["fileAccess::makeTarFile"]["fileArgu"]=$conf["fileArgu"];
5974
		$conf["fileAccess::makeTarFile"]["fileArgu"]=$conf["fileArgu"];
5975
		$makeTarFile=fileAccess::makeTarFile($conf["fileAccess::makeTarFile"]);
5975
		$makeTarFile=fileAccess::makeTarFile($conf["fileAccess::makeTarFile"]);
5976
		unset($conf["fileAccess::makeTarFile"]);
5976
		unset($conf["fileAccess::makeTarFile"]);
5977
		
5977
 
5978
		#如果打包失敗
5978
		#如果打包失敗
5979
		if($makeTarFile["status"]=="false"){
5979
		if($makeTarFile["status"]=="false"){
5980
			
5980
 
5981
			#設置執行不正常
5981
			#設置執行不正常
5982
			$result["status"]="false";
5982
			$result["status"]="false";
5983
			
5983
 
5984
			#設置錯誤訊息
5984
			#設置錯誤訊息
5985
			$result["error"]=$makeTarFile;
5985
			$result["error"]=$makeTarFile;
5986
			
5986
 
5987
			#回傳結果
5987
			#回傳結果
5988
			return $result;
5988
			return $result;
5989
			
5989
 
5990
			}#if end
5990
			}#if end
5991
		
5991
 
5992
		#壓縮成xz檔
5992
		#壓縮成xz檔
5993
		#函式說明:
5993
		#函式說明:
5994
		#將一個檔案壓縮成xz檔案
5994
		#將一個檔案壓縮成xz檔案
5995
		#回傳的結果:
5995
		#回傳的結果:
5996
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5996
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 6004... Line 6004...
6004
		$conf["fileAccess::makeXzFile"]["createdXzFile"]=$makeTarFile["content"];
6004
		$conf["fileAccess::makeXzFile"]["createdXzFile"]=$makeTarFile["content"];
6005
		#$conf["fileAccess::makeXzFile"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6005
		#$conf["fileAccess::makeXzFile"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6006
		$conf["fileAccess::makeXzFile"]["fileArgu"]=$conf["fileArgu"];
6006
		$conf["fileAccess::makeXzFile"]["fileArgu"]=$conf["fileArgu"];
6007
		$makeXzFile=fileAccess::makeXzFile($conf["fileAccess::makeXzFile"]);
6007
		$makeXzFile=fileAccess::makeXzFile($conf["fileAccess::makeXzFile"]);
6008
		unset($conf["fileAccess::makeXzFile"]);
6008
		unset($conf["fileAccess::makeXzFile"]);
6009
		
6009
 
6010
		#如果壓縮失敗
6010
		#如果壓縮失敗
6011
		if($makeXzFile["status"]=="false"){
6011
		if($makeXzFile["status"]=="false"){
6012
			
6012
 
6013
			#設置執行不正常
6013
			#設置執行不正常
6014
			$result["status"]="false";
6014
			$result["status"]="false";
6015
			
6015
 
6016
			#設置錯誤訊息
6016
			#設置錯誤訊息
6017
			$result["error"]=$makeXzFile;
6017
			$result["error"]=$makeXzFile;
6018
			
6018
 
6019
			#回傳結果
6019
			#回傳結果
6020
			return $result;
6020
			return $result;
6021
			
6021
 
6022
			}#if end
6022
			}#if end
6023
		
6023
 
6024
		#移除tar檔案
6024
		#移除tar檔案
6025
		#函式說明:
6025
		#函式說明:
6026
		#移除檔案
6026
		#移除檔案
6027
		#回傳結果:
6027
		#回傳結果:
6028
		#$result["status"],"true"代表移除成功,"false"代表移除失敗.
6028
		#$result["status"],"true"代表移除成功,"false"代表移除失敗.
Line 6033... Line 6033...
6033
		$conf["fileAccess::delFile"]["fileAddress"]=$makeTarFile["content"];#要移除檔案的位置
6033
		$conf["fileAccess::delFile"]["fileAddress"]=$makeTarFile["content"];#要移除檔案的位置
6034
		#$conf["fileAccess::delFile"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
6034
		#$conf["fileAccess::delFile"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
6035
		$conf["fileAccess::delFile"]["fileArgu"]=$conf["fileArgu"];
6035
		$conf["fileAccess::delFile"]["fileArgu"]=$conf["fileArgu"];
6036
		$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
6036
		$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
6037
		unset($conf["fileAccess::delFile"]);
6037
		unset($conf["fileAccess::delFile"]);
6038
		
6038
 
6039
		#如果移除tar檔案失敗
6039
		#如果移除tar檔案失敗
6040
		if($delFile["status"]=="false"){
6040
		if($delFile["status"]=="false"){
6041
			
6041
 
6042
			#設置執行不正常
6042
			#設置執行不正常
6043
			$result["status"]="false";
6043
			$result["status"]="false";
6044
			
6044
 
6045
			#設置錯誤訊息
6045
			#設置錯誤訊息
6046
			$result["error"]=$delFile;
6046
			$result["error"]=$delFile;
6047
			
6047
 
6048
			#回傳結果
6048
			#回傳結果
6049
			return $result;
6049
			return $result;
6050
			
6050
 
6051
			}#if end
6051
			}#if end
6052
			
6052
 
6053
		#取得壓縮好的檔案位置與名稱
6053
		#取得壓縮好的檔案位置與名稱
6054
		$result["content"]=$makeXzFile["content"];
6054
		$result["content"]=$makeXzFile["content"];
6055
		
6055
 
6056
		#執行到這邊代表執行正常
6056
		#執行到這邊代表執行正常
6057
		$result["status"]="true";
6057
		$result["status"]="true";
6058
		
6058
 
6059
		#回傳結果
6059
		#回傳結果
6060
		return $result;
6060
		return $result;
6061
		
6061
 
6062
		}#function makeTarXzFile end
6062
		}#function makeTarXzFile end
6063
		
6063
 
6064
	/*
6064
	/*
6065
	#函式說明:
6065
	#函式說明:
6066
	#移動檔案
6066
	#移動檔案
6067
	#回傳結果:
6067
	#回傳結果:
6068
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6068
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 6083... Line 6083...
6083
	#無.
6083
	#無.
6084
	#備註:
6084
	#備註:
6085
	#無.
6085
	#無.
6086
	*/
6086
	*/
6087
	public static function mv(&$conf){
6087
	public static function mv(&$conf){
6088
		
6088
 
6089
		#初始化要回傳的結果
6089
		#初始化要回傳的結果
6090
		$result=array();
6090
		$result=array();
6091
		
6091
 
6092
		#取得當前執行的函數名稱
6092
		#取得當前執行的函數名稱
6093
		$result["function"]=__FUNCTION__;
6093
		$result["function"]=__FUNCTION__;
6094
		
6094
 
6095
		#如果 $conf 不為陣列
6095
		#如果 $conf 不為陣列
6096
		if(gettype($conf)!="array"){
6096
		if(gettype($conf)!="array"){
6097
			
6097
 
6098
			#設置執行失敗
6098
			#設置執行失敗
6099
			$result["status"]="false";
6099
			$result["status"]="false";
6100
			
6100
 
6101
			#設置執行錯誤訊息
6101
			#設置執行錯誤訊息
6102
			$result["error"][]="\$conf變數須為陣列形態";
6102
			$result["error"][]="\$conf變數須為陣列形態";
6103
 
6103
 
6104
			#如果傳入的參數為 null
6104
			#如果傳入的參數為 null
6105
			if($conf==null){
6105
			if($conf==null){
6106
				
6106
 
6107
				#設置執行錯誤訊息
6107
				#設置執行錯誤訊息
6108
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6108
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6109
				
6109
 
6110
				}#if end
6110
				}#if end
6111
 
6111
 
6112
			#回傳結果
6112
			#回傳結果
6113
			return $result;
6113
			return $result;
6114
			
6114
 
6115
			}#if end
6115
			}#if end
6116
		
6116
 
6117
		#檢查參數
6117
		#檢查參數
6118
		#函式說明:
6118
		#函式說明:
6119
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
6119
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
6120
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6120
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6121
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
6121
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 6127... Line 6127...
6127
		#必填寫的參數:
6127
		#必填寫的參數:
6128
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
6128
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
6129
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
6129
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
6130
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
6130
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
6131
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("from","to","fileArgu");
6131
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("from","to","fileArgu");
6132
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
6132
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
6133
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
6133
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
6134
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
6134
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
6135
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
6135
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
6136
		#可以省略的參數:
6136
		#可以省略的參數:
6137
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
6137
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
6138
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
6138
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
6139
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
6139
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
6140
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray");
6140
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray");
6141
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
6141
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
6142
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
6142
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
6143
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
6143
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
6144
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
6144
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
6145
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
6145
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
6146
		#$conf["arrayCountEqualCheck"][]=array();
6146
		#$conf["arrayCountEqualCheck"][]=array();
6147
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
6147
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
6148
		unset($conf["variableCheck::checkArguments"]);
6148
		unset($conf["variableCheck::checkArguments"]);
6149
		
6149
 
6150
		#若檢查失敗
6150
		#若檢查失敗
6151
		if($checkResult["status"]=="false"){
6151
		if($checkResult["status"]=="false"){
6152
			
6152
 
6153
			#設置執行失敗
6153
			#設置執行失敗
6154
			$result["status"]="false";
6154
			$result["status"]="false";
6155
			
6155
 
6156
			#設置執行錯誤訊息
6156
			#設置執行錯誤訊息
6157
			$result["error"]=$checkResult;
6157
			$result["error"]=$checkResult;
6158
			
6158
 
6159
			#回傳結果
6159
			#回傳結果
6160
			return $result;
6160
			return $result;
6161
			
6161
 
6162
			}#if end
6162
			}#if end
6163
			
6163
 
6164
		#若檢查不通過
6164
		#若檢查不通過
6165
		if($checkResult["passed"]=="false"){
6165
		if($checkResult["passed"]=="false"){
6166
			
6166
 
6167
			#設置執行失敗
6167
			#設置執行失敗
6168
			$result["status"]="false";
6168
			$result["status"]="false";
6169
			
6169
 
6170
			#設置執行錯誤訊息
6170
			#設置執行錯誤訊息
6171
			$result["error"]=$checkResult;
6171
			$result["error"]=$checkResult;
6172
			
6172
 
6173
			#回傳結果
6173
			#回傳結果
6174
			return $result;
6174
			return $result;
6175
			
6175
 
6176
			}#if end
6176
			}#if end
6177
			
6177
 
6178
		#如果 $conf["commentsArray"] 有設定
6178
		#如果 $conf["commentsArray"] 有設定
6179
		if(isset($conf["commentsArray"])){
6179
		if(isset($conf["commentsArray"])){
6180
			
6180
 
6181
			#印出提示文字
6181
			#印出提示文字
6182
			#函式說明:
6182
			#函式說明:
6183
			#印出多行文字,結尾自動換行.
6183
			#印出多行文字,結尾自動換行.
6184
			#回傳的結果:
6184
			#回傳的結果:
6185
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
6185
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
Line 6188... Line 6188...
6188
			#必填參數:
6188
			#必填參數:
6189
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
6189
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
6190
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
6190
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
6191
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
6191
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
6192
			unset($conf["cmd::echoMultiLine"]);
6192
			unset($conf["cmd::echoMultiLine"]);
6193
			
6193
 
6194
			#如果印出提示文字失敗
6194
			#如果印出提示文字失敗
6195
			if($echoMultiLine["status"]=="false"){
6195
			if($echoMultiLine["status"]=="false"){
6196
				
6196
 
6197
				#設置執行失敗
6197
				#設置執行失敗
6198
				$result["status"]="false";
6198
				$result["status"]="false";
6199
				
6199
 
6200
				#設置執行錯誤訊息
6200
				#設置執行錯誤訊息
6201
				$result["error"]=$echoMultiLine;
6201
				$result["error"]=$echoMultiLine;
6202
				
6202
 
6203
				#回傳結果
6203
				#回傳結果
6204
				return $result;
6204
				return $result;
6205
				
6205
 
6206
				}#if end
6206
				}#if end
6207
			
6207
 
6208
			}#if end	
6208
			}#if end
6209
		
6209
 
6210
		#檢查要移動的檔案是否存在
6210
		#檢查要移動的檔案是否存在
6211
		#函式說明:
6211
		#函式說明:
6212
		#檢查多個檔案與資料夾是否存在.
6212
		#檢查多個檔案與資料夾是否存在.
6213
		#回傳的結果:
6213
		#回傳的結果:
6214
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
6214
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 6223... Line 6223...
6223
		#參考資料來源:
6223
		#參考資料來源:
6224
		#http://php.net/manual/en/function.file-exists.php
6224
		#http://php.net/manual/en/function.file-exists.php
6225
		#http://php.net/manual/en/control-structures.foreach.php
6225
		#http://php.net/manual/en/control-structures.foreach.php
6226
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
6226
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
6227
		unset($conf["fileAccess::checkMultiFileExist"]);
6227
		unset($conf["fileAccess::checkMultiFileExist"]);
6228
			
6228
 
6229
		#如果檢查失敗
6229
		#如果檢查失敗
6230
		if($checkMultiFileExist["status"]=="false"){
6230
		if($checkMultiFileExist["status"]=="false"){
6231
			
6231
 
6232
			#設置執行失敗
6232
			#設置執行失敗
6233
			$result["status"]="false";
6233
			$result["status"]="false";
6234
			
6234
 
6235
			#設置執行錯誤訊息
6235
			#設置執行錯誤訊息
6236
			$result["error"]=$checkMultiFileExist;
6236
			$result["error"]=$checkMultiFileExist;
6237
			
6237
 
6238
			#回傳結果
6238
			#回傳結果
6239
			return $result;
6239
			return $result;
6240
			
6240
 
6241
			}#if end	
6241
			}#if end
6242
			
6242
 
6243
		#如果來源檔案不存在
6243
		#如果來源檔案不存在
6244
		if($checkMultiFileExist["allExist"]=="false"){
6244
		if($checkMultiFileExist["allExist"]=="false"){
6245
			
6245
 
6246
			#設置執行失敗
6246
			#設置執行失敗
6247
			$result["status"]="false";
6247
			$result["status"]="false";
6248
			
6248
 
6249
			#設置執行錯誤訊息
6249
			#設置執行錯誤訊息
6250
			$result["error"][]="檔案「".$conf["from"]."」不存在";
6250
			$result["error"][]="檔案「".$conf["from"]."」不存在";
6251
			
6251
 
6252
			#回傳結果
6252
			#回傳結果
6253
			return $result;
6253
			return $result;
6254
			
6254
 
6255
			}#if end
6255
			}#if end
6256
			
6256
 
6257
		#函式說明:
6257
		#函式說明:
6258
		#呼叫shell執行系統命令,並取得回傳的內容.
6258
		#呼叫shell執行系統命令,並取得回傳的內容.
6259
		#回傳的結果:
6259
		#回傳的結果:
6260
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6260
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6261
		#$result["error"],錯誤訊息陣列
6261
		#$result["error"],錯誤訊息陣列
Line 6274... Line 6274...
6274
		$conf["external::callShell"]["escapeshellarg"]="true";
6274
		$conf["external::callShell"]["escapeshellarg"]="true";
6275
		#參考資料:
6275
		#參考資料:
6276
		#http://php.net/manual/en/function.exec.php
6276
		#http://php.net/manual/en/function.exec.php
6277
		$callShell=external::callShell($conf["external::callShell"]);
6277
		$callShell=external::callShell($conf["external::callShell"]);
6278
		unset($conf["external::callShell"]);
6278
		unset($conf["external::callShell"]);
6279
		
6279
 
6280
		#如果移動檔案失敗
6280
		#如果移動檔案失敗
6281
		if($callShell["status"]=="false"){
6281
		if($callShell["status"]=="false"){
6282
			
6282
 
6283
			#設置執行失敗
6283
			#設置執行失敗
6284
			$result["status"]="false";
6284
			$result["status"]="false";
6285
			
6285
 
6286
			#設置執行錯誤訊息
6286
			#設置執行錯誤訊息
6287
			$result["error"]=$callShell;
6287
			$result["error"]=$callShell;
6288
			
6288
 
6289
			#回傳結果
6289
			#回傳結果
6290
			return $result;
6290
			return $result;
6291
			
6291
 
6292
			}#if end
6292
			}#if end
6293
			
6293
 
6294
		#執行到這邊代表正常
6294
		#執行到這邊代表正常
6295
		$result["status"]="true";
6295
		$result["status"]="true";
6296
		
6296
 
6297
		#儲存移動後的位置與名稱
6297
		#儲存移動後的位置與名稱
6298
		$result["content"]=$conf["to"];
6298
		$result["content"]=$conf["to"];
6299
		
6299
 
6300
		#回傳結果
6300
		#回傳結果
6301
		return $result;
6301
		return $result;
6302
		
6302
 
6303
		}#function mv end
6303
		}#function mv end
6304
		
6304
 
6305
	/*
6305
	/*
6306
	#函式說明:
6306
	#函式說明:
6307
	#取得目錄底下所有目錄與檔案的樹狀結構.
6307
	#取得目錄底下所有目錄與檔案的樹狀結構.
6308
	#回傳結果:
6308
	#回傳結果:
6309
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6309
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
Line 6325... Line 6325...
6325
	#$result["content"][$i]["next"][$j]["ownerPerm"],第$i+1個為目錄的名稱的目錄底下第$j+1個使用者的權限.
6325
	#$result["content"][$i]["next"][$j]["ownerPerm"],第$i+1個為目錄的名稱的目錄底下第$j+1個使用者的權限.
6326
	#$result["content"][$i]["next"][$j]["groupPerm"],第$i+1個為目錄的名稱的目錄底下第$j+1個群組使用者的權限.
6326
	#$result["content"][$i]["next"][$j]["groupPerm"],第$i+1個為目錄的名稱的目錄底下第$j+1個群組使用者的權限.
6327
	#$result["content"][$i]["next"][$j]["otherPerm"],第$i+1個為目錄的名稱的目錄底下第$j+1個其他使用者的權限.
6327
	#$result["content"][$i]["next"][$j]["otherPerm"],第$i+1個為目錄的名稱的目錄底下第$j+1個其他使用者的權限.
6328
	#$result["content"][$i]["next"][$j]["ownerName"],第$i+1個為目錄的名稱的目錄底下第$j+1個擁有者賬戶.
6328
	#$result["content"][$i]["next"][$j]["ownerName"],第$i+1個為目錄的名稱的目錄底下第$j+1個擁有者賬戶.
6329
	#$result["content"][$i]["next"][$j]["groupName"],第$i+1個為目錄的名稱的目錄底下第$j+1個群組擁有者賬戶.
6329
	#$result["content"][$i]["next"][$j]["groupName"],第$i+1個為目錄的名稱的目錄底下第$j+1個群組擁有者賬戶.
6330
	#以此類推...		
6330
	#以此類推...
6331
	#必填參數:
6331
	#必填參數:
6332
	#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
6332
	#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
6333
	$conf["position"]="";
6333
	$conf["position"]="";
6334
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6334
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6335
	$conf["fileArgu"]=__FILE__;
6335
	$conf["fileArgu"]=__FILE__;
Line 6339... Line 6339...
6339
	#無.
6339
	#無.
6340
	#備註:
6340
	#備註:
6341
	#無.
6341
	#無.
6342
	*/
6342
	*/
6343
	public static function getListTree(&$conf){
6343
	public static function getListTree(&$conf){
6344
		
6344
 
6345
		#初始化要回傳的結果
6345
		#初始化要回傳的結果
6346
		$result=array();
6346
		$result=array();
6347
		
6347
 
6348
		#設置當其函數名稱
6348
		#設置當其函數名稱
6349
		$result["function"]=__FUNCTION__;
6349
		$result["function"]=__FUNCTION__;
6350
		
6350
 
6351
		#如果 $conf 不為陣列
6351
		#如果 $conf 不為陣列
6352
		if(gettype($conf)!="array"){
6352
		if(gettype($conf)!="array"){
6353
			
6353
 
6354
			#設置執行失敗
6354
			#設置執行失敗
6355
			$result["status"]="false";
6355
			$result["status"]="false";
6356
			
6356
 
6357
			#設置執行錯誤訊息
6357
			#設置執行錯誤訊息
6358
			$result["error"][]="\$conf變數須為陣列形態";
6358
			$result["error"][]="\$conf變數須為陣列形態";
6359
 
6359
 
6360
			#如果傳入的參數為 null
6360
			#如果傳入的參數為 null
6361
			if($conf==null){
6361
			if($conf==null){
6362
				
6362
 
6363
				#設置執行錯誤訊息
6363
				#設置執行錯誤訊息
6364
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6364
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6365
				
6365
 
6366
				}#if end
6366
				}#if end
6367
 
6367
 
6368
			#回傳結果
6368
			#回傳結果
6369
			return $result;
6369
			return $result;
6370
			
6370
 
6371
			}#if end
6371
			}#if end
6372
			
6372
 
6373
		#檢查必填參數
6373
		#檢查必填參數
6374
		#函式說明:
6374
		#函式說明:
6375
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
6375
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
6376
		#回傳的結果:
6376
		#回傳的結果:
6377
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6377
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 6383... Line 6383...
6383
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
6383
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
6384
		#必填寫的參數:
6384
		#必填寫的參數:
6385
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
6385
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
6386
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("fileArgu","position");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
6386
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("fileArgu","position");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
6387
		#可以省略的參數:
6387
		#可以省略的參數:
6388
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
6388
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double");
6389
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
6389
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
6390
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
6390
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
6391
		unset($conf["variableCheck.isexistMulti"]);
6391
		unset($conf["variableCheck.isexistMulti"]);
6392
					
6392
 
6393
		#如果檢查失敗
6393
		#如果檢查失敗
6394
		if($checkResult["status"]=="false"){
6394
		if($checkResult["status"]=="false"){
6395
			
6395
 
6396
			#設置錯誤識別
6396
			#設置錯誤識別
6397
			$result["status"]="false";
6397
			$result["status"]="false";
6398
			
6398
 
6399
			#設置錯誤訊息
6399
			#設置錯誤訊息
6400
			$result["error"]=$checkResult;
6400
			$result["error"]=$checkResult;
6401
			
6401
 
6402
			#回傳結果
6402
			#回傳結果
6403
			return $result;
6403
			return $result;
6404
			
6404
 
6405
			}#if end
6405
			}#if end
6406
			
6406
 
6407
		#如果檢查不通過
6407
		#如果檢查不通過
6408
		if($checkResult["passed"]=="false"){
6408
		if($checkResult["passed"]=="false"){
6409
			
6409
 
6410
			#設置錯誤識別
6410
			#設置錯誤識別
6411
			$result["status"]="false";
6411
			$result["status"]="false";
6412
			
6412
 
6413
			#設置錯誤訊息
6413
			#設置錯誤訊息
6414
			$result["error"]=$checkResult;
6414
			$result["error"]=$checkResult;
6415
			
6415
 
6416
			#回傳結果
6416
			#回傳結果
6417
			return $result;
6417
			return $result;
6418
			
6418
 
6419
			}#if end
6419
			}#if end
6420
		
6420
 
6421
		#如果目錄不為 . 與 ..
6421
		#如果目錄不為 . 與 ..
6422
		if(basename($conf["position"])!="." && basename($conf["position"])!=".."){
6422
		if(basename($conf["position"])!="." && basename($conf["position"])!=".."){
6423
			
6423
 
6424
			#檢查目錄是否存在
6424
			#檢查目錄是否存在
6425
			#函式說明:
6425
			#函式說明:
6426
			#檢查多個檔案與資料夾是否存在.
6426
			#檢查多個檔案與資料夾是否存在.
6427
			#回傳的結果:
6427
			#回傳的結果:
6428
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
6428
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 6438... Line 6438...
6438
			#參考資料來源:
6438
			#參考資料來源:
6439
			#http://php.net/manual/en/function.file-exists.php
6439
			#http://php.net/manual/en/function.file-exists.php
6440
			#http://php.net/manual/en/control-structures.foreach.php
6440
			#http://php.net/manual/en/control-structures.foreach.php
6441
			$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
6441
			$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
6442
			unset($conf["fileAccess::checkMultiFileExist"]);
6442
			unset($conf["fileAccess::checkMultiFileExist"]);
6443
				
6443
 
6444
			#如果檢查目錄失敗
6444
			#如果檢查目錄失敗
6445
			if($checkMultiFileExist["status"]=="false"){
6445
			if($checkMultiFileExist["status"]=="false"){
6446
				
6446
 
6447
				#設置錯誤識別
6447
				#設置錯誤識別
6448
				$result["status"]="false";
6448
				$result["status"]="false";
6449
				
6449
 
6450
				#設置錯誤訊息
6450
				#設置錯誤訊息
6451
				$result["error"]=$checkMultiFileExist;
6451
				$result["error"]=$checkMultiFileExist;
6452
				
6452
 
6453
				#回傳結果
6453
				#回傳結果
6454
				return $result;
6454
				return $result;
6455
				
6455
 
6456
				}#if end	
6456
				}#if end
6457
				
6457
 
6458
			#如果目錄不存在
6458
			#如果目錄不存在
6459
			if($checkMultiFileExist["varExist"][0]=="false"){
6459
			if($checkMultiFileExist["varExist"][0]=="false"){
6460
				
6460
 
6461
				#設置錯誤識別
6461
				#設置錯誤識別
6462
				$result["status"]="false";
6462
				$result["status"]="false";
6463
				
6463
 
6464
				#設置錯誤訊息
6464
				#設置錯誤訊息
6465
				$result["error"]=$checkMultiFileExist;
6465
				$result["error"]=$checkMultiFileExist;
6466
				
6466
 
6467
				#回傳結果
6467
				#回傳結果
6468
				return $result;
6468
				return $result;
6469
				
6469
 
6470
				}#if end	
6470
				}#if end
6471
			
6471
 
6472
			}#if end
6472
			}#if end
6473
		
6473
 
6474
		#取得根目錄的樹狀結構
6474
		#取得根目錄的樹狀結構
6475
		#函式說明:
6475
		#函式說明:
6476
		#取得目錄底下所有目錄與檔案清單.
6476
		#取得目錄底下所有目錄與檔案清單.
6477
		#回傳結果:
6477
		#回傳結果:
6478
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6478
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
Line 6492... Line 6492...
6492
		#無
6492
		#無
6493
		#參考資料來源:
6493
		#參考資料來源:
6494
		#opendir=>http://php.net/manual/en/function.opendir.php
6494
		#opendir=>http://php.net/manual/en/function.opendir.php
6495
		#is_dir=>http://php.net/manual/en/function.is-dir.php
6495
		#is_dir=>http://php.net/manual/en/function.is-dir.php
6496
		$rootList=fileAccess::getList($conf["fileAccess::getList"]);
6496
		$rootList=fileAccess::getList($conf["fileAccess::getList"]);
6497
		unset($conf["fileAccess::getList"]);	
6497
		unset($conf["fileAccess::getList"]);
6498
									
6498
 
6499
		#如果取得根目錄底下的資料失敗
6499
		#如果取得根目錄底下的資料失敗
6500
		if($rootList["status"]=="false"){
6500
		if($rootList["status"]=="false"){
6501
			
6501
 
6502
			#設置錯誤識別
6502
			#設置錯誤識別
6503
			$result["status"]="false";
6503
			$result["status"]="false";
6504
			
6504
 
6505
			#設置錯誤訊息
6505
			#設置錯誤訊息
6506
			$result["error"]=$rootList;
6506
			$result["error"]=$rootList;
6507
			
6507
 
6508
			#回傳結果
6508
			#回傳結果
6509
			return $result;
6509
			return $result;
6510
			
6510
 
6511
			}#if end
6511
			}#if end
6512
		
6512
 
6513
		#取得當前目錄	
6513
		#取得當前目錄
6514
		$result["position"]=$rootList["position"];	
6514
		$result["position"]=$rootList["position"];
6515
								
6515
 
6516
		#取得根目錄層級可以看到的檔案與目錄
6516
		#取得根目錄層級可以看到的檔案與目錄
6517
		$result["content"]=$rootList["content"];
6517
		$result["content"]=$rootList["content"];
6518
					
6518
 
6519
		#如果當前目錄有檔案與子目錄
6519
		#如果當前目錄有檔案與子目錄
6520
		if(isset($result["content"])){
6520
		if(isset($result["content"])){
6521
		
6521
 
6522
			#當前層級有幾個檔案目錄就執行幾次
6522
			#當前層級有幾個檔案目錄就執行幾次
6523
			for($i=0;$i<count($result["content"]);$i++){
6523
			for($i=0;$i<count($result["content"]);$i++){
6524
				
6524
 
6525
				#如果該單位是目錄
6525
				#如果該單位是目錄
6526
				if($result["content"][$i]["folder"]=="true"){
6526
				if($result["content"][$i]["folder"]=="true"){
6527
					
6527
 
6528
					#呼叫當前函數,取得 $conf["position"]."/".$result["content"][$i]["name"] 目錄底下的檔案目錄資訊
6528
					#呼叫當前函數,取得 $conf["position"]."/".$result["content"][$i]["name"] 目錄底下的檔案目錄資訊
6529
					#函式說明:
6529
					#函式說明:
6530
					#取得目錄底下所有目錄與檔案的樹狀結構.
6530
					#取得目錄底下所有目錄與檔案的樹狀結構.
6531
					#回傳結果:
6531
					#回傳結果:
6532
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6532
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
Line 6541... Line 6541...
6541
					$conf["fileAccess::getListTree"]["fileArgu"]=$conf["fileArgu"];
6541
					$conf["fileAccess::getListTree"]["fileArgu"]=$conf["fileArgu"];
6542
					#可省略參數:
6542
					#可省略參數:
6543
					#無
6543
					#無
6544
					$getListTree=fileAccess::getListTree($conf["fileAccess::getListTree"]);
6544
					$getListTree=fileAccess::getListTree($conf["fileAccess::getListTree"]);
6545
					unset($conf["fileAccess::getListTree"]);
6545
					unset($conf["fileAccess::getListTree"]);
6546
					
6546
 
6547
					#如果取得 $conf["position"]."/".$result["content"][$i]["name"] 目錄底下的檔案目錄資訊失敗
6547
					#如果取得 $conf["position"]."/".$result["content"][$i]["name"] 目錄底下的檔案目錄資訊失敗
6548
					if($getListTree["status"]=="false"){
6548
					if($getListTree["status"]=="false"){
6549
						
6549
 
6550
						#設置錯誤識別
6550
						#設置錯誤識別
6551
						$result["status"]="false";
6551
						$result["status"]="false";
6552
						
6552
 
6553
						#設置錯誤訊息
6553
						#設置錯誤訊息
6554
						$result["error"]=$getListTree;
6554
						$result["error"]=$getListTree;
6555
						
6555
 
6556
						#回傳結果
6556
						#回傳結果
6557
						return $result;
6557
						return $result;
6558
						
6558
 
6559
						}#if end
6559
						}#if end
6560
						
6560
 
6561
					#如果 $conf["position"]."/".$result["content"][$i]["name"] 目錄有檔案與子目錄
6561
					#如果 $conf["position"]."/".$result["content"][$i]["name"] 目錄有檔案與子目錄
6562
					if(isset($getListTree["content"])){	
6562
					if(isset($getListTree["content"])){
6563
						
6563
 
6564
						#取得 $conf["position"]."/".$result["content"][$i]["name"] 目錄底下的檔案目錄資訊
6564
						#取得 $conf["position"]."/".$result["content"][$i]["name"] 目錄底下的檔案目錄資訊
6565
						$result["content"][$i]["next"]=$getListTree["content"];
6565
						$result["content"][$i]["next"]=$getListTree["content"];
6566
					
6566
 
6567
						}#if end
6567
						}#if end
6568
						
6568
 
6569
					#取得當前目錄	
6569
					#取得當前目錄
6570
					$result["content"][$i]["position"]=$rootList["position"];	
6570
					$result["content"][$i]["position"]=$rootList["position"];
6571
					
6571
 
6572
					}#if end
6572
					}#if end
6573
				
6573
 
6574
				}#for end
6574
				}#for end
6575
				
6575
 
6576
			}#if end
6576
			}#if end
6577
					
6577
 
6578
		#執行到這邊代表執行正常
6578
		#執行到這邊代表執行正常
6579
		$result["status"]="true";
6579
		$result["status"]="true";
6580
		
6580
 
6581
		#回傳結果
6581
		#回傳結果
6582
		return $result;
6582
		return $result;
6583
		
6583
 
6584
		}#function getListTree end
6584
		}#function getListTree end
6585
		
6585
 
6586
	/*
6586
	/*
6587
	#函式說明:
6587
	#函式說明:
6588
	#取得目錄底下所有目錄與檔案清單.
6588
	#取得目錄底下所有目錄與檔案清單.
6589
	#回傳結果:
6589
	#回傳結果:
6590
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6590
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
Line 6615... Line 6615...
6615
	*/
6615
	*/
6616
	public static function getList(&$conf){
6616
	public static function getList(&$conf){
6617
 
6617
 
6618
		#初始化要回傳的結果
6618
		#初始化要回傳的結果
6619
		$result=array();
6619
		$result=array();
6620
		
6620
 
6621
		#設置當其函數名稱
6621
		#設置當其函數名稱
6622
		$result["function"]=__FUNCTION__;
6622
		$result["function"]=__FUNCTION__;
6623
		
6623
 
6624
		#初始化記載檔案目錄名單的陣列
6624
		#初始化記載檔案目錄名單的陣列
6625
		$result["content"]=array();
6625
		$result["content"]=array();
6626
		
6626
 
6627
		#如果 $conf 不為陣列
6627
		#如果 $conf 不為陣列
6628
		if(gettype($conf)!="array"){
6628
		if(gettype($conf)!="array"){
6629
			
6629
 
6630
			#設置執行失敗
6630
			#設置執行失敗
6631
			$result["status"]="false";
6631
			$result["status"]="false";
6632
			
6632
 
6633
			#設置執行錯誤訊息
6633
			#設置執行錯誤訊息
6634
			$result["error"][]="\$conf變數須為陣列形態";
6634
			$result["error"][]="\$conf變數須為陣列形態";
6635
 
6635
 
6636
			#如果傳入的參數為 null
6636
			#如果傳入的參數為 null
6637
			if($conf==null){
6637
			if($conf==null){
6638
				
6638
 
6639
				#設置執行錯誤訊息
6639
				#設置執行錯誤訊息
6640
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6640
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6641
				
6641
 
6642
				}#if end
6642
				}#if end
6643
 
6643
 
6644
			#回傳結果
6644
			#回傳結果
6645
			return $result;
6645
			return $result;
6646
			
6646
 
6647
			}#if end
6647
			}#if end
6648
			
6648
 
6649
		#檢查必填參數
6649
		#檢查必填參數
6650
		#函式說明:
6650
		#函式說明:
6651
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
6651
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
6652
		#回傳的結果:
6652
		#回傳的結果:
6653
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6653
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 6659... Line 6659...
6659
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
6659
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
6660
		#必填寫的參數:
6660
		#必填寫的參數:
6661
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
6661
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
6662
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("fileArgu","position");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
6662
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("fileArgu","position");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
6663
		#可以省略的參數:
6663
		#可以省略的參數:
6664
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
6664
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double");
6665
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
6665
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
6666
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
6666
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
6667
		unset($conf["variableCheck.isexistMulti"]);
6667
		unset($conf["variableCheck.isexistMulti"]);
6668
					
6668
 
6669
		#如果檢查失敗
6669
		#如果檢查失敗
6670
		if($checkResult["status"]=="false"){
6670
		if($checkResult["status"]=="false"){
6671
			
6671
 
6672
			#設置錯誤識別
6672
			#設置錯誤識別
6673
			$result["status"]="false";
6673
			$result["status"]="false";
6674
			
6674
 
6675
			#設置錯誤訊息
6675
			#設置錯誤訊息
6676
			$result["error"]=$checkResult;
6676
			$result["error"]=$checkResult;
6677
			
6677
 
6678
			#回傳結果
6678
			#回傳結果
6679
			return $result;
6679
			return $result;
6680
			
6680
 
6681
			}#if end
6681
			}#if end
6682
			
6682
 
6683
		#如果檢查不通過
6683
		#如果檢查不通過
6684
		if($checkResult["passed"]==="false"){
6684
		if($checkResult["passed"]==="false"){
6685
			
6685
 
6686
			#設置錯誤識別
6686
			#設置錯誤識別
6687
			$result["status"]="false";
6687
			$result["status"]="false";
6688
			
6688
 
6689
			#設置錯誤訊息
6689
			#設置錯誤訊息
6690
			$result["error"]=$checkResult;
6690
			$result["error"]=$checkResult;
6691
			
6691
 
6692
			#回傳結果
6692
			#回傳結果
6693
			return $result;
6693
			return $result;
6694
			
6694
 
6695
			}#if end
6695
			}#if end
6696
			
6696
 
6697
		#檢查目標路徑是否為「/」開頭的路徑
6697
		#檢查目標路徑是否為「/」開頭的路徑
6698
		#函式說明:
6698
		#函式說明:
6699
		#取得符合特定字首與字尾的字串
6699
		#取得符合特定字首與字尾的字串
6700
		#回傳結果:
6700
		#回傳結果:
6701
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
6701
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 6713... Line 6713...
6713
		#$conf["tailWord"]="";
6713
		#$conf["tailWord"]="";
6714
		#參考資料:
6714
		#參考資料:
6715
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
6715
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
6716
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
6716
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
6717
		unset($conf["search::getMeetConditionsString"]);
6717
		unset($conf["search::getMeetConditionsString"]);
6718
			
6718
 
6719
		#如果檢查關鍵字失敗
6719
		#如果檢查關鍵字失敗
6720
		if($getMeetConditionsString["status"]=="false"){
6720
		if($getMeetConditionsString["status"]=="false"){
6721
			
6721
 
6722
			#設置錯誤識別
6722
			#設置錯誤識別
6723
			$result["status"]="false";
6723
			$result["status"]="false";
6724
			
6724
 
6725
			#設置錯誤訊息
6725
			#設置錯誤訊息
6726
			$result["error"]=$getMeetConditionsString;
6726
			$result["error"]=$getMeetConditionsString;
6727
			
6727
 
6728
			#回傳結果
6728
			#回傳結果
6729
			return $result;
6729
			return $result;
6730
			
6730
 
6731
			}#if end					
6731
			}#if end
6732
			
6732
 
6733
		#如果目標路徑不為「/」開頭的路徑,則為相對路徑
6733
		#如果目標路徑不為「/」開頭的路徑,則為相對路徑
6734
		if($getMeetConditionsString["founded"]=="false"){
6734
		if($getMeetConditionsString["founded"]=="false"){
6735
			
6735
 
6736
			#取得目標位置的路徑
6736
			#取得目標位置的路徑
6737
			#函式說明:
6737
			#函式說明:
6738
			#將檔案的位置名稱變成網址
6738
			#將檔案的位置名稱變成網址
6739
			#回傳結果:
6739
			#回傳結果:
6740
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6740
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6741
			#$result["error"],錯誤訊息陣列.
6741
			#$result["error"],錯誤訊息陣列.
6742
			#$result["function"],函數名稱. 
6742
			#$result["function"],函數名稱.
6743
			#$result["content"],網址.
6743
			#$result["content"],網址.
6744
			#$result["localAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
6744
			#$result["localAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
6745
			#$result["fileSystemAbsoulutePosition"],針對伺服器檔案系統的絕對位置.
6745
			#$result["fileSystemAbsoulutePosition"],針對伺服器檔案系統的絕對位置.
6746
			#必填參數:
6746
			#必填參數:
6747
			#$conf["address"],字串,檔案的相對位置.
6747
			#$conf["address"],字串,檔案的相對位置.
Line 6749... Line 6749...
6749
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
6749
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
6750
			$conf["fileAccess::getInternetAddress"]["fileArgu"]=$conf["fileArgu"];
6750
			$conf["fileAccess::getInternetAddress"]["fileArgu"]=$conf["fileArgu"];
6751
			#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是.
6751
			#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是.
6752
			#$conf["fileAccess::getInternetAddress"]["userDir"]="true";
6752
			#$conf["fileAccess::getInternetAddress"]["userDir"]="true";
6753
			$getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
6753
			$getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
6754
			unset($conf["fileAccess::getInternetAddress"]);	
6754
			unset($conf["fileAccess::getInternetAddress"]);
6755
				
6755
 
6756
			#如果將檔案的位置名稱變成網址失敗
6756
			#如果將檔案的位置名稱變成網址失敗
6757
			if($getInternetAddress["status"]=="false"){
6757
			if($getInternetAddress["status"]=="false"){
6758
				
6758
 
6759
				#設置錯誤識別
6759
				#設置錯誤識別
6760
				$result["status"]="false";
6760
				$result["status"]="false";
6761
				
6761
 
6762
				#設置錯誤訊息
6762
				#設置錯誤訊息
6763
				$result["error"]=$getInternetAddress;
6763
				$result["error"]=$getInternetAddress;
6764
				
6764
 
6765
				#回傳結果
6765
				#回傳結果
6766
				return $result;
6766
				return $result;
6767
				
6767
 
6768
				}#if end	
6768
				}#if end
6769
				
6769
 
6770
			#置換目標位置為檔案系統路徑的絕對位置
6770
			#置換目標位置為檔案系統路徑的絕對位置
6771
			$conf["position"]=$getInternetAddress["fileSystemAbsoulutePosition"];
6771
			$conf["position"]=$getInternetAddress["fileSystemAbsoulutePosition"];
6772
							
6772
 
6773
			}#if end						
6773
			}#if end
6774
			
6774
 
6775
		#如果目標是資料夾	
6775
		#如果目標是資料夾
6776
		if(is_dir($conf["position"])) {
6776
		if(is_dir($conf["position"])) {
6777
			
6777
 
6778
			#設置為資料夾
6778
			#設置為資料夾
6779
			$result["folder"]="true";
6779
			$result["folder"]="true";
6780
			
6780
 
6781
			#如果開啟資料夾成功
6781
			#如果開啟資料夾成功
6782
			if($dh=opendir($conf["position"])){
6782
			if($dh=opendir($conf["position"])){
6783
			
6783
 
6784
				#初始化計數變數
6784
				#初始化計數變數
6785
				$count=0;
6785
				$count=0;
6786
			
6786
 
6787
				#如果資料夾裡面有檔案
6787
				#如果資料夾裡面有檔案
6788
				while(($fileName=readdir($dh))!==false){
6788
				while(($fileName=readdir($dh))!==false){
6789
			
6789
 
6790
					#debug
6790
					#debug
6791
					#echo "有檔案";
6791
					#echo "有檔案";
6792
				
6792
 
6793
					#如果名稱是「.」或「..」
6793
					#如果名稱是「.」或「..」
6794
					if($fileName=="." || $fileName==".."){
6794
					if($fileName=="." || $fileName==".."){
6795
						
6795
 
6796
						#則跳過
6796
						#則跳過
6797
						continue;
6797
						continue;
6798
						
6798
 
6799
						}#if end
6799
						}#if end
6800
							
6800
 
6801
					#取得檔案或子目錄名稱
6801
					#取得檔案或子目錄名稱
6802
					$result["content"][$count]["name"]=$fileName;					
6802
					$result["content"][$count]["name"]=$fileName;
6803
				
6803
 
6804
					#取得詳細資訊
6804
					#取得詳細資訊
6805
					#函式說明:
6805
					#函式說明:
6806
					#取得節點的資訊.
6806
					#取得節點的資訊.
6807
					#回傳結果:
6807
					#回傳結果:
6808
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6808
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6809
					#$result["error"],錯誤訊息陣列.
6809
					#$result["error"],錯誤訊息陣列.
6810
					#$result["function"],函數名稱. 
6810
					#$result["function"],函數名稱.
6811
					#$result["content"],檔案資訊陣列.
6811
					#$result["content"],檔案資訊陣列.
6812
					#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
6812
					#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.
6813
					#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
6813
					#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
6814
					#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
6814
					#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
6815
					#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
6815
					#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
6816
					#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
6816
					#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
6817
					#$result["content"]["ownerName"],檔案擁有着資訊.
6817
					#$result["content"]["ownerName"],檔案擁有着資訊.
Line 6834... Line 6834...
6834
					#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
6834
					#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
6835
					#備註:
6835
					#備註:
6836
					#無.
6836
					#無.
6837
					$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
6837
					$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
6838
					unset($conf["fileAccess::fileInfo"]);
6838
					unset($conf["fileAccess::fileInfo"]);
6839
				
6839
 
6840
					#如果執行失敗
6840
					#如果執行失敗
6841
					if($fileInfo["status"]=="false"){
6841
					if($fileInfo["status"]=="false"){
6842
						
6842
 
6843
						#設置錯誤識別
6843
						#設置錯誤識別
6844
						$result["status"]="false";
6844
						$result["status"]="false";
6845
						
6845
 
6846
						#設置錯誤訊息
6846
						#設置錯誤訊息
6847
						$result["error"]=$fileInfo;
6847
						$result["error"]=$fileInfo;
6848
						
6848
 
6849
						#回傳結果
6849
						#回傳結果
6850
						return $result;
6850
						return $result;
6851
						
6851
 
6852
						}#if end
6852
						}#if end
6853
						
6853
 
6854
					#設置是否為資料夾
6854
					#設置是否為資料夾
6855
					$result["content"][$count]["folder"]=$fileInfo["content"]["is_folder"];
6855
					$result["content"][$count]["folder"]=$fileInfo["content"]["is_folder"];
6856
				
6856
 
6857
					#設置使用者的權限
6857
					#設置使用者的權限
6858
					$result["content"][$count]["ownerPerm"]=$fileInfo["content"]["ownerPerm"];
6858
					$result["content"][$count]["ownerPerm"]=$fileInfo["content"]["ownerPerm"];
6859
						
6859
 
6860
					#設置群組的權限
6860
					#設置群組的權限
6861
					$result["content"][$count]["groupPerm"]=$fileInfo["content"]["groupPerm"];
6861
					$result["content"][$count]["groupPerm"]=$fileInfo["content"]["groupPerm"];
6862
					
6862
 
6863
					#設置其他使用者的權限
6863
					#設置其他使用者的權限
6864
					$result["content"][$count]["otherPerm"]=$fileInfo["content"]["otherPerm"];
6864
					$result["content"][$count]["otherPerm"]=$fileInfo["content"]["otherPerm"];
6865
					
6865
 
6866
					#設置其擁有者賬戶
6866
					#設置其擁有者賬戶
6867
					$result["content"][$count]["ownerName"]=$fileInfo["content"]["ownerName"];
6867
					$result["content"][$count]["ownerName"]=$fileInfo["content"]["ownerName"];
6868
					
6868
 
6869
					#設置其群組擁有者賬戶
6869
					#設置其群組擁有者賬戶
6870
					$result["content"][$count]["groupName"]=$fileInfo["content"]["groupName"];
6870
					$result["content"][$count]["groupName"]=$fileInfo["content"]["groupName"];
6871
					
6871
 
6872
					#計數加1
6872
					#計數加1
6873
					$count++;
6873
					$count++;
6874
				
6874
 
6875
					}#while
6875
					}#while
6876
				
6876
 
6877
				#關閉資料夾
6877
				#關閉資料夾
6878
				closedir($dh);
6878
				closedir($dh);
6879
				
6879
 
6880
				}#if end
6880
				}#if end
6881
			
6881
 
6882
			#開啟資料夾失敗	
6882
			#開啟資料夾失敗
6883
			else{
6883
			else{
6884
				
6884
 
6885
				#設置執行失敗
6885
				#設置執行失敗
6886
				$result["status"]="false";
6886
				$result["status"]="false";
6887
				
6887
 
6888
				#設置執行錯誤訊息
6888
				#設置執行錯誤訊息
6889
				$result["error"][]="開啟資料夾「".$conf["position"]."」失敗";
6889
				$result["error"][]="開啟資料夾「".$conf["position"]."」失敗";
6890
 
6890
 
6891
				#回傳結果
6891
				#回傳結果
6892
				return $result;
6892
				return $result;
6893
				
6893
 
6894
				}#else end
6894
				}#else end
6895
				
6895
 
6896
			}#if end
6896
			}#if end
6897
			
6897
 
6898
		#反之是檔案
6898
		#反之是檔案
6899
		else{
6899
		else{
6900
			
6900
 
6901
			#設置不為目錄
6901
			#設置不為目錄
6902
			$result["folder"]="false";
6902
			$result["folder"]="false";
6903
			
6903
 
6904
			}#else end
6904
			}#else end
6905
			
6905
 
6906
		#取得目前位置
6906
		#取得目前位置
6907
		$result["position"]=$conf["position"];	
6907
		$result["position"]=$conf["position"];
6908
			
6908
 
6909
		#執行到這邊代表執行正常
6909
		#執行到這邊代表執行正常
6910
		$result["status"]="true";
6910
		$result["status"]="true";
6911
		
6911
 
6912
		#回傳結果
6912
		#回傳結果
6913
		return $result;	
6913
		return $result;
6914
 
6914
 
6915
		}#function getList end
6915
		}#function getList end
6916
		
6916
 
6917
	/*
6917
	/*
6918
	#函式說明:
6918
	#函式說明:
6919
	#取得目錄底下所有目錄與檔案的樹狀結構.
6919
	#取得目錄底下所有目錄與檔案的樹狀結構.
6920
	#回傳結果:
6920
	#回傳結果:
6921
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6921
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
Line 6931... Line 6931...
6931
	#無.
6931
	#無.
6932
	#備註:
6932
	#備註:
6933
	#無.
6933
	#無.
6934
	*/
6934
	*/
6935
	public static function exportListTree(&$conf){
6935
	public static function exportListTree(&$conf){
6936
		
6936
 
6937
		#初始化要回傳的結果
6937
		#初始化要回傳的結果
6938
		$result=array();
6938
		$result=array();
6939
		
6939
 
6940
		#設置當其函數名稱
6940
		#設置當其函數名稱
6941
		$result["function"]=__FUNCTION__;
6941
		$result["function"]=__FUNCTION__;
6942
		
6942
 
6943
		#如果 $conf 不為陣列
6943
		#如果 $conf 不為陣列
6944
		if(gettype($conf)!="array"){
6944
		if(gettype($conf)!="array"){
6945
			
6945
 
6946
			#設置執行失敗
6946
			#設置執行失敗
6947
			$result["status"]="false";
6947
			$result["status"]="false";
6948
			
6948
 
6949
			#設置執行錯誤訊息
6949
			#設置執行錯誤訊息
6950
			$result["error"][]="\$conf變數須為陣列形態";
6950
			$result["error"][]="\$conf變數須為陣列形態";
6951
 
6951
 
6952
			#如果傳入的參數為 null
6952
			#如果傳入的參數為 null
6953
			if($conf==null){
6953
			if($conf==null){
6954
				
6954
 
6955
				#設置執行錯誤訊息
6955
				#設置執行錯誤訊息
6956
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6956
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6957
				
6957
 
6958
				}#if end
6958
				}#if end
6959
 
6959
 
6960
			#回傳結果
6960
			#回傳結果
6961
			return $result;
6961
			return $result;
6962
			
6962
 
6963
			}#if end
6963
			}#if end
6964
			
6964
 
6965
		#檢查必填參數
6965
		#檢查必填參數
6966
		#函式說明:
6966
		#函式說明:
6967
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
6967
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
6968
		#回傳的結果:
6968
		#回傳的結果:
6969
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6969
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 6975... Line 6975...
6975
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
6975
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
6976
		#必填寫的參數:
6976
		#必填寫的參數:
6977
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
6977
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
6978
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("position");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
6978
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("position");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
6979
		#可以省略的參數:
6979
		#可以省略的參數:
6980
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
6980
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double");
6981
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
6981
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
6982
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
6982
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
6983
		unset($conf["variableCheck.isexistMulti"]);
6983
		unset($conf["variableCheck.isexistMulti"]);
6984
					
6984
 
6985
		#如果檢查失敗
6985
		#如果檢查失敗
6986
		if($checkResult["status"]=="false"){
6986
		if($checkResult["status"]=="false"){
6987
			
6987
 
6988
			#設置錯誤識別
6988
			#設置錯誤識別
6989
			$result["status"]="false";
6989
			$result["status"]="false";
6990
			
6990
 
6991
			#設置錯誤訊息
6991
			#設置錯誤訊息
6992
			$result["error"]=$checkResult;
6992
			$result["error"]=$checkResult;
6993
			
6993
 
6994
			#回傳結果
6994
			#回傳結果
6995
			return $result;
6995
			return $result;
6996
			
6996
 
6997
			}#if end
6997
			}#if end
6998
			
6998
 
6999
		#如果檢查不通過
6999
		#如果檢查不通過
7000
		if($checkResult["passed"]=="false"){
7000
		if($checkResult["passed"]=="false"){
7001
			
7001
 
7002
			#設置錯誤識別
7002
			#設置錯誤識別
7003
			$result["status"]="false";
7003
			$result["status"]="false";
7004
			
7004
 
7005
			#設置錯誤訊息
7005
			#設置錯誤訊息
7006
			$result["error"]=$checkResult;
7006
			$result["error"]=$checkResult;
7007
			
7007
 
7008
			#回傳結果
7008
			#回傳結果
7009
			return $result;
7009
			return $result;
7010
			
7010
 
7011
			}#if end
7011
			}#if end
7012
			
7012
 
7013
		#函式說明:
7013
		#函式說明:
7014
		#取得目錄底下所有目錄與檔案的樹狀結構.
7014
		#取得目錄底下所有目錄與檔案的樹狀結構.
7015
		#回傳結果:
7015
		#回傳結果:
7016
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
7016
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
7017
		#$result["error"],錯誤訊息陣列.
7017
		#$result["error"],錯誤訊息陣列.
Line 7021... Line 7021...
7021
		#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
7021
		#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
7022
		$conf["fileAccess::getListTree"]["position"]=$conf["position"];
7022
		$conf["fileAccess::getListTree"]["position"]=$conf["position"];
7023
		#可省略參數:
7023
		#可省略參數:
7024
		#無
7024
		#無
7025
		#備註:
7025
		#備註:
7026
		#若檔案與目錄的名稱含有「[」與「]」與「(」與「)」將會無法取得其目錄底下的內容	
7026
		#若檔案與目錄的名稱含有「[」與「]」與「(」與「)」將會無法取得其目錄底下的內容
7027
		#若檔案與目錄的名稱含有「 」將會無法檢查檔案是否存在
7027
		#若檔案與目錄的名稱含有「 」將會無法檢查檔案是否存在
7028
		#改用opendir()函數應該可以解決大部分的bug.
7028
		#改用opendir()函數應該可以解決大部分的bug.
7029
		$getListTree=fileAccess::getListTree($conf["fileAccess::getListTree"]);
7029
		$getListTree=fileAccess::getListTree($conf["fileAccess::getListTree"]);
7030
		unset($conf["fileAccess::getListTree"]);
7030
		unset($conf["fileAccess::getListTree"]);
7031
		
7031
 
7032
		#如果取得 目標目錄底下所有目錄與檔案的樹狀結構 失敗
7032
		#如果取得 目標目錄底下所有目錄與檔案的樹狀結構 失敗
7033
		if($getListTree["status"]==="false"){
7033
		if($getListTree["status"]==="false"){
7034
			
7034
 
7035
			#設置錯誤識別
7035
			#設置錯誤識別
7036
			$result["status"]="false";
7036
			$result["status"]="false";
7037
			
7037
 
7038
			#設置錯誤訊息
7038
			#設置錯誤訊息
7039
			$result["error"]=$getListTree;
7039
			$result["error"]=$getListTree;
7040
			
7040
 
7041
			#回傳結果
7041
			#回傳結果
7042
			return $result;
7042
			return $result;
7043
			
7043
 
7044
			}#if end
7044
			}#if end
7045
			
7045
 
7046
		#目標目錄底下有幾個
7046
		#目標目錄底下有幾個
7047
		
7047
 
7048
		}#function exportListTree end
7048
		}#function exportListTree end
7049
 
7049
 
7050
	/*
7050
	/*
7051
	#函式說明:
7051
	#函式說明:
7052
	#解壓縮tar.xz檔案,解壓縮完畢後,tar.xz檔案會被移除.
7052
	#解壓縮tar.xz檔案,解壓縮完畢後,tar.xz檔案會被移除.
7053
	#回傳結果:
7053
	#回傳結果:
7054
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
7054
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
7055
	#$result["error"],錯誤訊息陣列.
7055
	#$result["error"],錯誤訊息陣列.
7056
	#$result["function"],函數名稱. 
7056
	#$result["function"],函數名稱.
7057
	#必填參數:
7057
	#必填參數:
7058
	#$conf["tarXzFile"],字串變數,壓縮檔的位置與名稱,副檔名".tar.xz"會自動補上.
7058
	#$conf["tarXzFile"],字串變數,壓縮檔的位置與名稱,副檔名".tar.xz"會自動補上.
7059
	$conf["tarXzFile"]="";
7059
	$conf["tarXzFile"]="";
7060
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
7060
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
7061
	$conf["fileArgu"]=__FILE__;
7061
	$conf["fileArgu"]=__FILE__;
Line 7068... Line 7068...
7068
	#無.
7068
	#無.
7069
	#備註:
7069
	#備註:
7070
	#無.
7070
	#無.
7071
	*/
7071
	*/
7072
	public static function unpackTarXzFile(&$conf){
7072
	public static function unpackTarXzFile(&$conf){
7073
		
7073
 
7074
		#初始化要回傳的內容
7074
		#初始化要回傳的內容
7075
		$result=array();
7075
		$result=array();
7076
		
7076
 
7077
		#記錄當前執行的函數名稱
7077
		#記錄當前執行的函數名稱
7078
		$result["function"]=__FUNCTION__;
7078
		$result["function"]=__FUNCTION__;
7079
		
7079
 
7080
		#如果 $conf 不為陣列
7080
		#如果 $conf 不為陣列
7081
		if(gettype($conf)!="array"){
7081
		if(gettype($conf)!="array"){
7082
			
7082
 
7083
			#設置執行失敗
7083
			#設置執行失敗
7084
			$result["status"]="false";
7084
			$result["status"]="false";
7085
			
7085
 
7086
			#設置執行錯誤訊息
7086
			#設置執行錯誤訊息
7087
			$result["error"][]="\$conf變數須為陣列形態";
7087
			$result["error"][]="\$conf變數須為陣列形態";
7088
 
7088
 
7089
			#如果傳入的參數為 null
7089
			#如果傳入的參數為 null
7090
			if($conf==null){
7090
			if($conf==null){
7091
				
7091
 
7092
				#設置執行錯誤訊息
7092
				#設置執行錯誤訊息
7093
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
7093
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
7094
				
7094
 
7095
				}#if end
7095
				}#if end
7096
 
7096
 
7097
			#回傳結果
7097
			#回傳結果
7098
			return $result;
7098
			return $result;
7099
			
7099
 
7100
			}#if end
7100
			}#if end
7101
		
7101
 
7102
		#檢查參數
7102
		#檢查參數
7103
		#函式說明:
7103
		#函式說明:
7104
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
7104
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
7105
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7105
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7106
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
7106
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 7112... Line 7112...
7112
		#必填寫的參數:
7112
		#必填寫的參數:
7113
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
7113
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
7114
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
7114
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
7115
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
7115
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
7116
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","tarXzFile");
7116
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","tarXzFile");
7117
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
7117
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
7118
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
7118
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
7119
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
7119
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
7120
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
7120
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
7121
		#可以省略的參數:
7121
		#可以省略的參數:
7122
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
7122
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
7123
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
7123
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
7124
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
7124
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
7125
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray","extractTo");
7125
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray","extractTo");
7126
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
7126
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
7127
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string");
7127
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string");
7128
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
7128
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
7129
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,".");
7129
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,".");
7130
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
7130
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
7131
		#$conf["arrayCountEqualCheck"][]=array();
7131
		#$conf["arrayCountEqualCheck"][]=array();
7132
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
7132
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
7133
		unset($conf["variableCheck::checkArguments"]);
7133
		unset($conf["variableCheck::checkArguments"]);
7134
		
7134
 
7135
		#若檢查失敗
7135
		#若檢查失敗
7136
		if($checkResult["status"]=="false"){
7136
		if($checkResult["status"]=="false"){
7137
			
7137
 
7138
			#設置執行失敗
7138
			#設置執行失敗
7139
			$result["status"]="false";
7139
			$result["status"]="false";
7140
			
7140
 
7141
			#設置執行錯誤訊息
7141
			#設置執行錯誤訊息
7142
			$result["error"]=$checkResult;
7142
			$result["error"]=$checkResult;
7143
			
7143
 
7144
			#回傳結果
7144
			#回傳結果
7145
			return $result;
7145
			return $result;
7146
			
7146
 
7147
			}#if end
7147
			}#if end
7148
			
7148
 
7149
		#若檢查不通過
7149
		#若檢查不通過
7150
		if($checkResult["passed"]=="false"){
7150
		if($checkResult["passed"]=="false"){
7151
			
7151
 
7152
			#設置執行失敗
7152
			#設置執行失敗
7153
			$result["status"]="false";
7153
			$result["status"]="false";
7154
			
7154
 
7155
			#設置執行錯誤訊息
7155
			#設置執行錯誤訊息
7156
			$result["error"]=$checkResult;
7156
			$result["error"]=$checkResult;
7157
			
7157
 
7158
			#回傳結果
7158
			#回傳結果
7159
			return $result;
7159
			return $result;
7160
			
7160
 
7161
			}#if end
7161
			}#if end
7162
			
7162
 
7163
		#如果 $conf["commentsArray"] 有設定
7163
		#如果 $conf["commentsArray"] 有設定
7164
		if(isset($conf["commentsArray"])){
7164
		if(isset($conf["commentsArray"])){
7165
			
7165
 
7166
			#印出提示文字
7166
			#印出提示文字
7167
			#函式說明:
7167
			#函式說明:
7168
			#印出多行文字,結尾自動換行.
7168
			#印出多行文字,結尾自動換行.
7169
			#回傳的結果:
7169
			#回傳的結果:
7170
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
7170
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
Line 7173... Line 7173...
7173
			#必填參數:
7173
			#必填參數:
7174
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
7174
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
7175
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
7175
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
7176
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
7176
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
7177
			unset($conf["cmd::echoMultiLine"]);
7177
			unset($conf["cmd::echoMultiLine"]);
7178
			
7178
 
7179
			#如果印出提示文字失敗
7179
			#如果印出提示文字失敗
7180
			if($echoMultiLine["status"]=="false"){
7180
			if($echoMultiLine["status"]=="false"){
7181
				
7181
 
7182
				#設置執行失敗
7182
				#設置執行失敗
7183
				$result["status"]="false";
7183
				$result["status"]="false";
7184
				
7184
 
7185
				#設置執行錯誤訊息
7185
				#設置執行錯誤訊息
7186
				$result["error"]=$echoMultiLine;
7186
				$result["error"]=$echoMultiLine;
7187
				
7187
 
7188
				#回傳結果
7188
				#回傳結果
7189
				return $result;
7189
				return $result;
7190
				
7190
 
7191
				}#if end
7191
				}#if end
7192
			
7192
 
7193
			}#if end
7193
			}#if end
7194
		
7194
 
7195
		#檢查要移動的檔案是否存在
7195
		#檢查要移動的檔案是否存在
7196
		#函式說明:
7196
		#函式說明:
7197
		#檢查多個檔案與資料夾是否存在.
7197
		#檢查多個檔案與資料夾是否存在.
7198
		#回傳的結果:
7198
		#回傳的結果:
7199
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
7199
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 7209... Line 7209...
7209
		#參考資料來源:
7209
		#參考資料來源:
7210
		#http://php.net/manual/en/function.file-exists.php
7210
		#http://php.net/manual/en/function.file-exists.php
7211
		#http://php.net/manual/en/control-structures.foreach.php
7211
		#http://php.net/manual/en/control-structures.foreach.php
7212
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
7212
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
7213
		unset($conf["fileAccess::checkMultiFileExist"]);
7213
		unset($conf["fileAccess::checkMultiFileExist"]);
7214
			
7214
 
7215
		#如果檢查失敗
7215
		#如果檢查失敗
7216
		if($checkMultiFileExist["status"]=="false"){
7216
		if($checkMultiFileExist["status"]=="false"){
7217
			
7217
 
7218
			#設置執行失敗
7218
			#設置執行失敗
7219
			$result["status"]="false";
7219
			$result["status"]="false";
7220
			
7220
 
7221
			#設置執行錯誤訊息
7221
			#設置執行錯誤訊息
7222
			$result["error"]=$checkMultiFileExist;
7222
			$result["error"]=$checkMultiFileExist;
7223
			
7223
 
7224
			#回傳結果
7224
			#回傳結果
7225
			return $result;
7225
			return $result;
7226
			
7226
 
7227
			}#if end	
7227
			}#if end
7228
			
7228
 
7229
		#如果來源檔案不存在
7229
		#如果來源檔案不存在
7230
		if($checkMultiFileExist["allExist"]=="false"){
7230
		if($checkMultiFileExist["allExist"]=="false"){
7231
			
7231
 
7232
			#設置執行失敗
7232
			#設置執行失敗
7233
			$result["status"]="false";
7233
			$result["status"]="false";
7234
			
7234
 
7235
			#設置執行錯誤訊息
7235
			#設置執行錯誤訊息
7236
			$result["error"][]="檔案「".$conf["tarXzFile"].".tar.xz」不存在";
7236
			$result["error"][]="檔案「".$conf["tarXzFile"].".tar.xz」不存在";
7237
			
7237
 
7238
			#回傳結果
7238
			#回傳結果
7239
			return $result;
7239
			return $result;
7240
			
7240
 
7241
			}#if end
7241
			}#if end
7242
									
7242
 
7243
		#進行解壓縮xz檔
7243
		#進行解壓縮xz檔
7244
		#函式說明:
7244
		#函式說明:
7245
		#呼叫shell執行系統命令,並取得回傳的內容.
7245
		#呼叫shell執行系統命令,並取得回傳的內容.
7246
		#回傳的結果:
7246
		#回傳的結果:
7247
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7247
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 7267... Line 7267...
7267
		#exec=>http://php.net/manual/en/function.exec.php
7267
		#exec=>http://php.net/manual/en/function.exec.php
7268
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
7268
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
7269
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
7269
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
7270
		$callShell=external::callShell($conf["fileAccess::callShell"]);
7270
		$callShell=external::callShell($conf["fileAccess::callShell"]);
7271
		unset($conf["fileAccess::callShell"]);
7271
		unset($conf["fileAccess::callShell"]);
7272
		
7272
 
7273
		#如果解壓縮xz檔案失敗
7273
		#如果解壓縮xz檔案失敗
7274
		if($callShell["status"]=="false"){
7274
		if($callShell["status"]=="false"){
7275
			
7275
 
7276
			#設置執行失敗
7276
			#設置執行失敗
7277
			$result["status"]="false";
7277
			$result["status"]="false";
7278
			
7278
 
7279
			#設置執行錯誤訊息
7279
			#設置執行錯誤訊息
7280
			$result["error"]=$callShell;
7280
			$result["error"]=$callShell;
7281
			
7281
 
7282
			#回傳結果
7282
			#回傳結果
7283
			return $result;
7283
			return $result;
7284
			
7284
 
7285
			}#if end
7285
			}#if end
7286
			
7286
 
7287
		#解壓縮tar檔
7287
		#解壓縮tar檔
7288
		#函式說明:
7288
		#函式說明:
7289
		#呼叫shell執行系統命令,並取得回傳的內容.
7289
		#呼叫shell執行系統命令,並取得回傳的內容.
7290
		#回傳的結果:
7290
		#回傳的結果:
7291
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7291
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 7311... Line 7311...
7311
		#exec=>http://php.net/manual/en/function.exec.php
7311
		#exec=>http://php.net/manual/en/function.exec.php
7312
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
7312
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
7313
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
7313
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
7314
		$callShell=external::callShell($conf["fileAccess::callShell"]);
7314
		$callShell=external::callShell($conf["fileAccess::callShell"]);
7315
		unset($conf["fileAccess::callShell"]);
7315
		unset($conf["fileAccess::callShell"]);
7316
		
7316
 
7317
		#如果解壓縮xz檔案失敗
7317
		#如果解壓縮xz檔案失敗
7318
		if($callShell["status"]=="false"){
7318
		if($callShell["status"]=="false"){
7319
			
7319
 
7320
			#設置執行失敗
7320
			#設置執行失敗
7321
			$result["status"]="false";
7321
			$result["status"]="false";
7322
			
7322
 
7323
			#設置執行錯誤訊息
7323
			#設置執行錯誤訊息
7324
			$result["error"]=$callShell;
7324
			$result["error"]=$callShell;
7325
			
7325
 
7326
			#回傳結果
7326
			#回傳結果
7327
			return $result;
7327
			return $result;
7328
			
7328
 
7329
			}#if end
7329
			}#if end
7330
			
7330
 
7331
		#移除tar檔
7331
		#移除tar檔
7332
		#函式說明:
7332
		#函式說明:
7333
		#移除檔案
7333
		#移除檔案
7334
		#回傳結果:
7334
		#回傳結果:
7335
		#$result["status"],"true"代表移除成功,"false"代表移除失敗.
7335
		#$result["status"],"true"代表移除成功,"false"代表移除失敗.
Line 7342... Line 7342...
7342
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
7342
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
7343
		$conf["fileAccess::delFile"]["fileArgu"]=$conf["fileArgu"];
7343
		$conf["fileAccess::delFile"]["fileArgu"]=$conf["fileArgu"];
7344
		#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
7344
		#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
7345
		#$conf["commentsArray"]=array("");
7345
		#$conf["commentsArray"]=array("");
7346
		$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
7346
		$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
7347
		unset($conf["fileAccess::delFile"]);	
7347
		unset($conf["fileAccess::delFile"]);
7348
			
7348
 
7349
		#如果移除檔案失敗
7349
		#如果移除檔案失敗
7350
		if($delFile["status"]=="false"){
7350
		if($delFile["status"]=="false"){
7351
			
7351
 
7352
			#設置執行失敗
7352
			#設置執行失敗
7353
			$result["status"]="false";
7353
			$result["status"]="false";
7354
			
7354
 
7355
			#設置執行錯誤訊息
7355
			#設置執行錯誤訊息
7356
			$result["error"]=$delFile;
7356
			$result["error"]=$delFile;
7357
			
7357
 
7358
			#回傳結果
7358
			#回傳結果
7359
			return $result;
7359
			return $result;
7360
			
7360
 
7361
			}#if end	
7361
			}#if end
7362
			
7362
 
7363
		#執行到這邊代表執行正常
7363
		#執行到這邊代表執行正常
7364
		$result["status"]="true";
7364
		$result["status"]="true";
7365
		
7365
 
7366
		#回傳結果
7366
		#回傳結果
7367
		return $result;
7367
		return $result;
7368
		
7368
 
7369
		}#function unpackTarXzFile end
7369
		}#function unpackTarXzFile end
7370
 
7370
 
7371
	/*
7371
	/*
7372
	#函式說明:
7372
	#函式說明:
7373
	#用data:mimeType;base64,fileVar的形式來提供檔案的連結,亦即檔案儲存在變數裡面.
7373
	#用data:mimeType;base64,fileVar的形式來提供檔案的連結,亦即檔案儲存在變數裡面.
7374
	#回傳結果:
7374
	#回傳結果:
7375
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7375
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7376
	#$result["error"],錯誤訊息
7376
	#$result["error"],錯誤訊息
7377
	#$result["content"],檔案變數的內容
7377
	#$result["content"],檔案變數的內容
7378
	#$result["fileTypeName"],副檔名,ex:「.tar.xz」.
7378
	#$result["fileTypeName"],副檔名,ex:「.tar.xz」.
7379
	#$result["function"],當前執行的函數名稱 
7379
	#$result["function"],當前執行的函數名稱
7380
	#必填參數:
7380
	#必填參數:
7381
	#$conf["filePosition"],要轉存成2元碼的檔案位置與名稱
7381
	#$conf["filePosition"],要轉存成2元碼的檔案位置與名稱
7382
	$conf["filePosition"]="";
7382
	$conf["filePosition"]="";
7383
	#$conf["mimeType"],2元碼的內容是什麼
7383
	#$conf["mimeType"],2元碼的內容是什麼
7384
	$conf["mimeType"]="";
7384
	$conf["mimeType"]="";
Line 7392... Line 7392...
7392
	#壓縮2元碼=>http://php.net/manual/en/function.base64-encode.php
7392
	#壓縮2元碼=>http://php.net/manual/en/function.base64-encode.php
7393
	#備註:
7393
	#備註:
7394
	#無.
7394
	#無.
7395
	*/
7395
	*/
7396
	public static function data(&$conf){
7396
	public static function data(&$conf){
7397
		
7397
 
7398
		#初始化要回傳的內容
7398
		#初始化要回傳的內容
7399
		$result=array();
7399
		$result=array();
7400
		
7400
 
7401
		#取得當前執行的函數名稱
7401
		#取得當前執行的函數名稱
7402
		$result["function"]=__FUNCTION__;
7402
		$result["function"]=__FUNCTION__;
7403
		
7403
 
7404
		#如果 $conf 不為陣列
7404
		#如果 $conf 不為陣列
7405
		if(gettype($conf)!="array"){
7405
		if(gettype($conf)!="array"){
7406
			
7406
 
7407
			#設置執行失敗
7407
			#設置執行失敗
7408
			$result["status"]="false";
7408
			$result["status"]="false";
7409
			
7409
 
7410
			#設置執行錯誤訊息
7410
			#設置執行錯誤訊息
7411
			$result["error"][]="\$conf變數須為陣列形態";
7411
			$result["error"][]="\$conf變數須為陣列形態";
7412
 
7412
 
7413
			#如果傳入的參數為 null
7413
			#如果傳入的參數為 null
7414
			if($conf==null){
7414
			if($conf==null){
7415
				
7415
 
7416
				#設置執行錯誤訊息
7416
				#設置執行錯誤訊息
7417
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
7417
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
7418
				
7418
 
7419
				}#if end
7419
				}#if end
7420
 
7420
 
7421
			#回傳結果
7421
			#回傳結果
7422
			return $result;
7422
			return $result;
7423
			
7423
 
7424
			}#if end
7424
			}#if end
7425
		
7425
 
7426
		#檢查參數
7426
		#檢查參數
7427
		#函式說明:
7427
		#函式說明:
7428
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
7428
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
7429
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7429
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7430
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
7430
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 7436... Line 7436...
7436
		#必填寫的參數:
7436
		#必填寫的參數:
7437
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
7437
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
7438
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
7438
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
7439
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
7439
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
7440
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("filePosition");
7440
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("filePosition");
7441
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
7441
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
7442
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
7442
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
7443
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
7443
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
7444
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
7444
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
7445
		#可以省略的參數:
7445
		#可以省略的參數:
7446
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
7446
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
7447
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
7447
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
7448
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
7448
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
7449
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("mimeType","compressType","delFile");
7449
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("mimeType","compressType","delFile");
7450
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
7450
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
7451
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
7451
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
7452
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
7452
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
7453
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("null","base64","false");
7453
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("null","base64","false");
7454
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
7454
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
7455
		#$conf["arrayCountEqualCheck"][]=array();
7455
		#$conf["arrayCountEqualCheck"][]=array();
7456
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
7456
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
7457
		unset($conf["variableCheck::checkArguments"]);
7457
		unset($conf["variableCheck::checkArguments"]);
7458
		
7458
 
7459
		#如果檢查參數失敗
7459
		#如果檢查參數失敗
7460
		if($checkResult["status"]=="false"){
7460
		if($checkResult["status"]=="false"){
7461
			
7461
 
7462
			#設置執行失敗
7462
			#設置執行失敗
7463
			$result["status"]="false";
7463
			$result["status"]="false";
7464
			
7464
 
7465
			#設置錯誤訊息
7465
			#設置錯誤訊息
7466
			$result["error"]=$checkResult;
7466
			$result["error"]=$checkResult;
7467
			
7467
 
7468
			#回傳結果
7468
			#回傳結果
7469
			return $result;
7469
			return $result;
7470
			
7470
 
7471
			}#if end
7471
			}#if end
7472
			
7472
 
7473
		#如果檢查參數不通過
7473
		#如果檢查參數不通過
7474
		if($checkResult["passed"]=="false"){
7474
		if($checkResult["passed"]=="false"){
7475
			
7475
 
7476
			#設置執行失敗
7476
			#設置執行失敗
7477
			$result["status"]="false";
7477
			$result["status"]="false";
7478
			
7478
 
7479
			#設置錯誤訊息
7479
			#設置錯誤訊息
7480
			$result["error"]=$checkResult;
7480
			$result["error"]=$checkResult;
7481
			
7481
 
7482
			#回傳結果
7482
			#回傳結果
7483
			return $result;
7483
			return $result;
7484
			
7484
 
7485
			}#if end
7485
			}#if end
7486
		
7486
 
7487
		#依據檔案名稱取得副檔名 $result["fileTypeName"]
7487
		#依據檔案名稱取得副檔名 $result["fileTypeName"]
7488
		#函式說明:
7488
		#函式說明:
7489
		#將固定格式的字串分開,並回傳分開的結果。
7489
		#將固定格式的字串分開,並回傳分開的結果。
7490
		#回傳的參數:
7490
		#回傳的參數:
7491
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7491
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 7499... Line 7499...
7499
		$conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
7499
		$conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
7500
		#備註:
7500
		#備註:
7501
		#建議新增如果透過" "分割後的內容含有""的元素,將其移除,並將後面有內容的元素補上,key也重新排序。
7501
		#建議新增如果透過" "分割後的內容含有""的元素,將其移除,並將後面有內容的元素補上,key也重新排序。
7502
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7502
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7503
		unset($conf["stringProcess::spiltString"]);
7503
		unset($conf["stringProcess::spiltString"]);
7504
		
7504
 
7505
		#如果分割字串失敗
7505
		#如果分割字串失敗
7506
		if($spiltString["status"]=="false"){
7506
		if($spiltString["status"]=="false"){
7507
			
7507
 
7508
			#設置執行失敗
7508
			#設置執行失敗
7509
			$result["status"]="false";
7509
			$result["status"]="false";
7510
			
7510
 
7511
			#設置錯誤訊息
7511
			#設置錯誤訊息
7512
			$result["error"]=$spiltString;
7512
			$result["error"]=$spiltString;
7513
			
7513
 
7514
			#回傳結果
7514
			#回傳結果
7515
			return $result;
7515
			return $result;
7516
			
7516
 
7517
			}#if end
7517
			}#if end
7518
			
7518
 
7519
		#初始化副檔名
7519
		#初始化副檔名
7520
		$result["fileTypeName"]="";	
7520
		$result["fileTypeName"]="";
7521
			
7521
 
7522
		#如果只有一段代表沒有副檔名
7522
		#如果只有一段代表沒有副檔名
7523
		if($spiltString["dataCounts"]==1){
7523
		if($spiltString["dataCounts"]==1){
7524
			
7524
 
7525
			#副檔名設置為 "unknow"
7525
			#副檔名設置為 "unknow"
7526
			$result["fileTypeName"]="unknow";
7526
			$result["fileTypeName"]="unknow";
7527
			
7527
 
7528
			}#if end
7528
			}#if end
7529
			
7529
 
7530
		#不符合以上條件,但至少有兩段
7530
		#不符合以上條件,但至少有兩段
7531
		else if($spiltString["dataCounts"]>=2){
7531
		else if($spiltString["dataCounts"]>=2){
7532
			
7532
 
7533
			#執行 $spiltString["dataCounts"] 減一次的迴圈
7533
			#執行 $spiltString["dataCounts"] 減一次的迴圈
7534
			for($i=1;$i<$spiltString["dataCounts"];$i++){
7534
			for($i=1;$i<$spiltString["dataCounts"];$i++){
7535
				
7535
 
7536
				#串接副檔名
7536
				#串接副檔名
7537
				$result["fileTypeName"]=$result["fileTypeName"].".".$spiltString["dataArray"][$i];
7537
				$result["fileTypeName"]=$result["fileTypeName"].".".$spiltString["dataArray"][$i];
7538
				
7538
 
7539
				}#for end
7539
				}#for end
7540
			
7540
 
7541
			}#if end
7541
			}#if end
7542
		
7542
 
7543
		#讀取檔案內容
7543
		#讀取檔案內容
7544
		$fileBin=file_get_contents($conf["filePosition"],"rb");
7544
		$fileBin=file_get_contents($conf["filePosition"],"rb");
7545
					
7545
 
7546
		#編碼檔案
7546
		#編碼檔案
7547
		$base64fileBin=base64_encode($fileBin);
7547
		$base64fileBin=base64_encode($fileBin);
7548
		
7548
 
7549
		#如果 $conf["delFile"] 等於 "true"
7549
		#如果 $conf["delFile"] 等於 "true"
7550
		if($conf["delFile"]=="true"){
7550
		if($conf["delFile"]=="true"){
7551
			
7551
 
7552
			#移除檔案
7552
			#移除檔案
7553
			#函式說明:
7553
			#函式說明:
7554
			#移除檔案
7554
			#移除檔案
7555
			#回傳結果:
7555
			#回傳結果:
7556
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
7556
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
Line 7559... Line 7559...
7559
			#$result["function"],當前執行的函數名稱
7559
			#$result["function"],當前執行的函數名稱
7560
			#必填參數:
7560
			#必填參數:
7561
			$conf["fileAccess::delFile"]["fileAddress"]=$conf["filePosition"];#要移除檔案的位置
7561
			$conf["fileAccess::delFile"]["fileAddress"]=$conf["filePosition"];#要移除檔案的位置
7562
			$del=fileAccess::delFile($conf["fileAccess::delFile"]);
7562
			$del=fileAccess::delFile($conf["fileAccess::delFile"]);
7563
			unset($conf["fileAccess::delFile"]);
7563
			unset($conf["fileAccess::delFile"]);
7564
			
7564
 
7565
			#如果移除圖片失敗
7565
			#如果移除圖片失敗
7566
			if($del["status"]=="false"){
7566
			if($del["status"]=="false"){
7567
				
7567
 
7568
				#設置執行失敗
7568
				#設置執行失敗
7569
				$result["status"]="false";
7569
				$result["status"]="false";
7570
				
7570
 
7571
				#設置錯誤訊息
7571
				#設置錯誤訊息
7572
				$result["error"]=$del;
7572
				$result["error"]=$del;
7573
				
7573
 
7574
				#回傳結果
7574
				#回傳結果
7575
				return $result;
7575
				return $result;
7576
				
7576
 
7577
				}#if end
7577
				}#if end
7578
			
7578
 
7579
			}#if end
7579
			}#if end
7580
		
7580
 
7581
		#放置檔案的語法
7581
		#放置檔案的語法
7582
		$result["content"]="data:".$conf["mimeType"].";".$conf["compressType"].",".$base64fileBin;
7582
		$result["content"]="data:".$conf["mimeType"].";".$conf["compressType"].",".$base64fileBin;
7583
		
7583
 
7584
		#執行到這邊代表執行正常
7584
		#執行到這邊代表執行正常
7585
		$result["status"]="true";
7585
		$result["status"]="true";
7586
		
7586
 
7587
		#回傳結果
7587
		#回傳結果
7588
		return $result;
7588
		return $result;
7589
		
7589
 
7590
		}#function data end
7590
		}#function data end
7591
 
7591
 
7592
	/*
7592
	/*
7593
	#函式說明:
7593
	#函式說明:
7594
	#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
7594
	#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
7595
	#回傳結果:
7595
	#回傳結果:
7596
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
7596
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
7597
	#$result["error"],錯誤訊息陣列.
7597
	#$result["error"],錯誤訊息陣列.
7598
	#$result["function"],函數名稱. 
7598
	#$result["function"],函數名稱.
7599
	#$result["argu"],使用的參數.
7599
	#$result["argu"],使用的參數.
7600
	#$result["content"],網址,若是在命令列執行,則為"null".
7600
	#$result["content"],網址,若是在命令列執行,則為"null".
7601
	#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
7601
	#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
7602
	#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
7602
	#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
7603
	#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
7603
	#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
Line 7613... Line 7613...
7613
	#無.
7613
	#無.
7614
	#備註:
7614
	#備註:
7615
	#無.
7615
	#無.
7616
	*/
7616
	*/
7617
	public static function getInternetAddress(&$conf){
7617
	public static function getInternetAddress(&$conf){
7618
		
7618
 
7619
		#初始化要回傳的變數
7619
		#初始化要回傳的變數
7620
		$result=array();
7620
		$result=array();
7621
		
7621
 
7622
		#記錄當前執行的函數名稱
7622
		#記錄當前執行的函數名稱
7623
		$result["function"]=__FUNCTION__;
7623
		$result["function"]=__FUNCTION__;
7624
		
7624
 
7625
		#如果 $conf 不為陣列
7625
		#如果 $conf 不為陣列
7626
		if(gettype($conf)!="array"){
7626
		if(gettype($conf)!="array"){
7627
			
7627
 
7628
			#設置執行失敗
7628
			#設置執行失敗
7629
			$result["status"]="false";
7629
			$result["status"]="false";
7630
			
7630
 
7631
			#設置執行錯誤訊息
7631
			#設置執行錯誤訊息
7632
			$result["error"][]="\$conf變數須為陣列形態";
7632
			$result["error"][]="\$conf變數須為陣列形態";
7633
 
7633
 
7634
			#如果傳入的參數為 null
7634
			#如果傳入的參數為 null
7635
			if($conf==null){
7635
			if($conf==null){
7636
				
7636
 
7637
				#設置執行錯誤訊息
7637
				#設置執行錯誤訊息
7638
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
7638
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
7639
				
7639
 
7640
				}#if end
7640
				}#if end
7641
 
7641
 
7642
			#回傳結果
7642
			#回傳結果
7643
			return $result;
7643
			return $result;
7644
			
7644
 
7645
			}#if end
7645
			}#if end
7646
 
7646
 
7647
		#取得使用的參數
7647
		#取得使用的參數
7648
		$result["argu"]=$conf;
7648
		$result["argu"]=$conf;
7649
	
7649
 
7650
		#檢查參數
7650
		#檢查參數
7651
		#函式說明:
7651
		#函式說明:
7652
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
7652
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
7653
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7653
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7654
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
7654
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 7663... Line 7663...
7663
		#必填寫的參數:
7663
		#必填寫的參數:
7664
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
7664
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
7665
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
7665
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
7666
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
7666
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
7667
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("address","fileArgu");
7667
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("address","fileArgu");
7668
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
7668
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
7669
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
7669
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
7670
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
7670
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
7671
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
7671
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
7672
		#可以省略的參數:
7672
		#可以省略的參數:
7673
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
7673
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
7674
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
7674
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
7675
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
7675
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
7676
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("userDir");
7676
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("userDir");
7677
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
7677
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
7678
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
7678
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
7679
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
7679
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
7680
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
7680
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
7681
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
7681
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
7682
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
7682
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
Line 7685... Line 7685...
7685
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
7685
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
7686
		unset($conf["variableCheck::checkArguments"]);
7686
		unset($conf["variableCheck::checkArguments"]);
7687
 
7687
 
7688
		#如果檢查失敗
7688
		#如果檢查失敗
7689
		if($checkResult["status"]==="false"){
7689
		if($checkResult["status"]==="false"){
7690
			
7690
 
7691
			#設置錯誤狀態
7691
			#設置錯誤狀態
7692
			$result["status"]="false";
7692
			$result["status"]="false";
7693
			
7693
 
7694
			#設置錯誤提示
7694
			#設置錯誤提示
7695
			$result["error"]=$checkResult;
7695
			$result["error"]=$checkResult;
7696
			
7696
 
7697
			#回傳結果
7697
			#回傳結果
7698
			return $result;
7698
			return $result;
7699
			
7699
 
7700
			}#if end
7700
			}#if end
7701
 
7701
 
7702
		#如果檢查不通過
7702
		#如果檢查不通過
7703
		if($checkResult["passed"]==="false"){
7703
		if($checkResult["passed"]==="false"){
7704
			
7704
 
7705
			#設置錯誤狀態
7705
			#設置錯誤狀態
7706
			$result["status"]="false";
7706
			$result["status"]="false";
7707
			
7707
 
7708
			#設置錯誤提示
7708
			#設置錯誤提示
7709
			$result["error"]=$checkResult;
7709
			$result["error"]=$checkResult;
7710
			
7710
 
7711
			#回傳結果
7711
			#回傳結果
7712
			return $result;
7712
			return $result;
7713
			
7713
 
7714
			}#if end
7714
			}#if end
7715
			
7715
 
7716
		#如果是本來就是網址了
7716
		#如果是本來就是網址了
7717
		if(strpos($conf["address"],'https://')===0 || strpos($conf["address"],'http://')===0){
7717
		if(strpos($conf["address"],'https://')===0 || strpos($conf["address"],'http://')===0){
7718
			
7718
 
7719
			#設置執行正常
7719
			#設置執行正常
7720
			$result["status"]="true";
7720
			$result["status"]="true";
7721
			
7721
 
7722
			#取得網址
7722
			#取得網址
7723
			$result["content"]=$conf["address"];
7723
			$result["content"]=$conf["address"];
7724
			
7724
 
7725
			#回傳結果
7725
			#回傳結果
7726
			return $result;			
7726
			return $result;
7727
			
7727
 
7728
			}#if end	
7728
			}#if end
7729
				
7729
 
7730
		#解析 $conf["fileArgu"]
7730
		#解析 $conf["fileArgu"]
7731
		#函式說明:
7731
		#函式說明:
7732
		#將固定格式的字串分開,並回傳分開的結果。
7732
		#將固定格式的字串分開,並回傳分開的結果。
7733
		#回傳的參數:
7733
		#回傳的參數:
7734
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7734
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 7739... Line 7739...
7739
		#$result["dataCounts"],爲總共分成幾段
7739
		#$result["dataCounts"],爲總共分成幾段
7740
		#必填參數:
7740
		#必填參數:
7741
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["fileArgu"];#要處理的字串。
7741
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["fileArgu"];#要處理的字串。
7742
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
7742
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
7743
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7743
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7744
		unset($conf["stringProcess::spiltString"]); 
7744
		unset($conf["stringProcess::spiltString"]);
7745
		
7745
 
7746
		#如果分割字串失敗
7746
		#如果分割字串失敗
7747
		if($spiltString["status"]==="false"){
7747
		if($spiltString["status"]==="false"){
7748
			
7748
 
7749
			#設置錯誤狀態
7749
			#設置錯誤狀態
7750
			$result["status"]="false";
7750
			$result["status"]="false";
7751
			
7751
 
7752
			#設置錯誤提示
7752
			#設置錯誤提示
7753
			$result["error"]=$spiltString;
7753
			$result["error"]=$spiltString;
7754
			
7754
 
7755
			#回傳結果
7755
			#回傳結果
7756
			return $result;
7756
			return $result;
7757
			
7757
 
7758
			}#if end
7758
			}#if end
7759
		
7759
 
7760
		#函式說明:
7760
		#函式說明:
7761
		#將多個路徑字串變成相對於當前路徑的相對路徑字串
7761
		#將多個路徑字串變成相對於當前路徑的相對路徑字串
7762
		#回傳結果:
7762
		#回傳結果:
7763
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
7763
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
7764
		#$result["error"],錯誤訊息陣列.
7764
		#$result["error"],錯誤訊息陣列.
7765
		#$result["function"],函數名稱. 
7765
		#$result["function"],函數名稱.
7766
		#$result["content"],字串陣列,多個轉換好的相對路徑字串.
7766
		#$result["content"],字串陣列,多個轉換好的相對路徑字串.
7767
		#必填參數:
7767
		#必填參數:
7768
		#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
7768
		#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
7769
		$conf["fileAccess::getRelativePath"]["path"]=array($conf["address"]);
7769
		$conf["fileAccess::getRelativePath"]["path"]=array($conf["address"]);
7770
		#$conf["fileArgu"],字串,當前路徑.
7770
		#$conf["fileArgu"],字串,當前路徑.
7771
		$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
7771
		$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
7772
		$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
7772
		$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
7773
		unset($conf["fileAccess::getRelativePath"]);
7773
		unset($conf["fileAccess::getRelativePath"]);
7774
			
7774
 
7775
		#如果取得相對位置失敗
7775
		#如果取得相對位置失敗
7776
		if($getRelativePath["status"]==="false"){
7776
		if($getRelativePath["status"]==="false"){
7777
			
7777
 
7778
			#設置錯誤狀態
7778
			#設置錯誤狀態
7779
			$result["status"]="false";
7779
			$result["status"]="false";
7780
			
7780
 
7781
			#設置錯誤提示
7781
			#設置錯誤提示
7782
			$result["error"]=$getRelativePath;
7782
			$result["error"]=$getRelativePath;
7783
			
7783
 
7784
			#回傳結果
7784
			#回傳結果
7785
			return $result;
7785
			return $result;
7786
			
7786
 
7787
			}#if end			
7787
			}#if end
7788
		
7788
 
7789
		#取得轉換成相對路徑的位置
7789
		#取得轉換成相對路徑的位置
7790
		$result["fileSystemRelativePosition"]=$getRelativePath["content"][0];
7790
		$result["fileSystemRelativePosition"]=$getRelativePath["content"][0];
7791
		
7791
 
7792
		#解析 $conf["fileArgu"]
7792
		#解析 $conf["fileArgu"]
7793
		#函式說明:
7793
		#函式說明:
7794
		#將固定格式的字串分開,並回傳分開的結果。
7794
		#將固定格式的字串分開,並回傳分開的結果。
7795
		#回傳的參數:
7795
		#回傳的參數:
7796
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7796
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 7801... Line 7801...
7801
		#$result["dataCounts"],爲總共分成幾段
7801
		#$result["dataCounts"],爲總共分成幾段
7802
		#必填參數:
7802
		#必填參數:
7803
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["fileArgu"];#要處理的字串。
7803
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["fileArgu"];#要處理的字串。
7804
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
7804
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
7805
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7805
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7806
		unset($conf["stringProcess::spiltString"]); 
7806
		unset($conf["stringProcess::spiltString"]);
7807
		
7807
 
7808
		#如果分割字串失敗
7808
		#如果分割字串失敗
7809
		if($spiltString["status"]==="false"){
7809
		if($spiltString["status"]==="false"){
7810
			
7810
 
7811
			#設置錯誤狀態
7811
			#設置錯誤狀態
7812
			$result["status"]="false";
7812
			$result["status"]="false";
7813
			
7813
 
7814
			#設置錯誤提示
7814
			#設置錯誤提示
7815
			$result["error"]=$spiltString;
7815
			$result["error"]=$spiltString;
7816
			
7816
 
7817
			#回傳結果
7817
			#回傳結果
7818
			return $result;
7818
			return $result;
7819
			
7819
 
7820
			}#if end
7820
			}#if end
7821
		
7821
 
7822
		#debug
7822
		#debug
7823
		#var_dump($spiltString);
7823
		#var_dump($spiltString);
7824
		#var_dump($_SERVER);
7824
		#var_dump($_SERVER);
7825
 
7825
 
7826
		#初始化檔案在伺服器上的檔案系統位置
7826
		#初始化檔案在伺服器上的檔案系統位置
7827
		$result["fileSystemAbsoulutePosition"]="/";
7827
		$result["fileSystemAbsoulutePosition"]="/";
7828
		
7828
 
7829
		#將最後一段捨棄
7829
		#將最後一段捨棄
7830
		for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
7830
		for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
7831
			
7831
 
7832
			$result["fileSystemAbsoulutePosition"]=$result["fileSystemAbsoulutePosition"].$spiltString["dataArray"][$i]."/";
7832
			$result["fileSystemAbsoulutePosition"]=$result["fileSystemAbsoulutePosition"].$spiltString["dataArray"][$i]."/";
7833
			
7833
 
7834
			}#for end				
7834
			}#for end
7835
			
7835
 
7836
		#取得非直觀的絕對位置
7836
		#取得非直觀的絕對位置
7837
		$result["fileSystemAbsoulutePosition"]=$result["fileSystemAbsoulutePosition"].$result["fileSystemRelativePosition"];
7837
		$result["fileSystemAbsoulutePosition"]=$result["fileSystemAbsoulutePosition"].$result["fileSystemRelativePosition"];
7838
					
7838
 
7839
		#將檔案的相對路徑進行整理,變成可以直接讀的路徑.
7839
		#將檔案的相對路徑進行整理,變成可以直接讀的路徑.
7840
		#函式說明:
7840
		#函式說明:
7841
		#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
7841
		#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
7842
		#回傳的結果:
7842
		#回傳的結果:
7843
		#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
7843
		#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
Line 7848... Line 7848...
7848
		#必填參數:
7848
		#必填參數:
7849
		#$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"],字串,要處理的檔案目錄字串.
7849
		#$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"],字串,要處理的檔案目錄字串.
7850
		$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"]=$result["fileSystemAbsoulutePosition"];
7850
		$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"]=$result["fileSystemAbsoulutePosition"];
7851
		$changeDirByDotDotSolidus=stringProcess::changeDirByDotDotSolidus($conf["stringProcess::changeDirByDotDotSolidus"]);
7851
		$changeDirByDotDotSolidus=stringProcess::changeDirByDotDotSolidus($conf["stringProcess::changeDirByDotDotSolidus"]);
7852
		unset($conf["stringProcess::changeDirByDotDotSolidus"]);
7852
		unset($conf["stringProcess::changeDirByDotDotSolidus"]);
7853
				
7853
 
7854
		#如果處理失敗
7854
		#如果處理失敗
7855
		if($changeDirByDotDotSolidus["status"]==="false"){
7855
		if($changeDirByDotDotSolidus["status"]==="false"){
7856
			
7856
 
7857
			#設置錯誤狀態
7857
			#設置錯誤狀態
7858
			$result["status"]="false";
7858
			$result["status"]="false";
7859
			
7859
 
7860
			#設置錯誤提示
7860
			#設置錯誤提示
7861
			$result["error"]=$changeDirByDotDotSolidus;
7861
			$result["error"]=$changeDirByDotDotSolidus;
7862
			
7862
 
7863
			#回傳結果
7863
			#回傳結果
7864
			return $result;
7864
			return $result;
7865
			
7865
 
7866
			}#if end
7866
			}#if end
7867
				
7867
 
7868
		#改變為易讀的絕對路徑
7868
		#改變為易讀的絕對路徑
7869
		$result["fileSystemAbsoulutePosition"]=$changeDirByDotDotSolidus["changedPath"];	
7869
		$result["fileSystemAbsoulutePosition"]=$changeDirByDotDotSolidus["changedPath"];
7870
																					
-
 
-
 
7870
 
7871
		#如果 $conf["userDir"] 為 "true"
7871
		#如果 $conf["userDir"] 為 "true"
7872
		if($conf["userDir"]==="true"){
7872
		if($conf["userDir"]==="true"){
7873
		
7873
 
7874
			#重設為 絕對路徑 [/~家目錄名稱」
7874
			#重設為 絕對路徑 [/~家目錄名稱」
7875
			$result["webPathFromRoot"]="/~".$spiltString["dataArray"][1];
7875
			$result["webPathFromRoot"]="/~".$spiltString["dataArray"][1];
7876
			
7876
 
7877
			#從第四段到倒數第二段,將其內容合併
7877
			#從第四段到倒數第二段,將其內容合併
7878
			for($i=3;$i<$spiltString["dataCounts"]-1;$i++){
7878
			for($i=3;$i<$spiltString["dataCounts"]-1;$i++){
7879
				
7879
 
7880
				$result["webPathFromRoot"]=$result["webPathFromRoot"]."/".$spiltString["dataArray"][$i];
7880
				$result["webPathFromRoot"]=$result["webPathFromRoot"]."/".$spiltString["dataArray"][$i];
7881
				
7881
 
7882
				}#for end
7882
				}#for end
7883
			
7883
 
7884
			}#if end
7884
			}#if end
7885
		
7885
 
7886
		#反之 $conf["userDir"] 為 "false",
7886
		#反之 $conf["userDir"] 為 "false",
7887
		else{
7887
		else{
7888
			
7888
 
7889
			#重設為 ""
7889
			#重設為 ""
7890
			$result["webPathFromRoot"]="";
7890
			$result["webPathFromRoot"]="";
7891
			
7891
 
7892
			#可能的根目錄層級 - start 
7892
			#可能的根目錄層級 - start
7893
 
7893
 
7894
			#解析 $conf["fileArgu"]
7894
			#解析 $conf["fileArgu"]
7895
			#函式說明:
7895
			#函式說明:
7896
			#將固定格式的字串分開,並回傳分開的結果。
7896
			#將固定格式的字串分開,並回傳分開的結果。
7897
			#回傳的參數:
7897
			#回傳的參數:
Line 7903... Line 7903...
7903
			#$result["dataCounts"],爲總共分成幾段
7903
			#$result["dataCounts"],爲總共分成幾段
7904
			#必填參數:
7904
			#必填參數:
7905
			$conf["stringProcess::spiltString"]["stringIn"]=$_SERVER["PHP_SELF"];#要處理的字串。
7905
			$conf["stringProcess::spiltString"]["stringIn"]=$_SERVER["PHP_SELF"];#要處理的字串。
7906
			$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
7906
			$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
7907
			$keyWord=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7907
			$keyWord=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7908
			unset($conf["stringProcess::spiltString"]); 
7908
			unset($conf["stringProcess::spiltString"]);
7909
 
7909
 
7910
			#如果處理失敗
7910
			#如果處理失敗
7911
			if($keyWord["status"]==="false"){
7911
			if($keyWord["status"]==="false"){
7912
				
7912
 
7913
				#設置錯誤狀態
7913
				#設置錯誤狀態
7914
				$result["status"]="false";
7914
				$result["status"]="false";
7915
				
7915
 
7916
				#設置錯誤提示
7916
				#設置錯誤提示
7917
				$result["error"]=$keyWord;
7917
				$result["error"]=$keyWord;
7918
				
7918
 
7919
				#回傳結果
7919
				#回傳結果
7920
				return $result;
7920
				return $result;
7921
				
7921
 
7922
				}#if end
7922
				}#if end
7923
	
7923
 
7924
			#取得關鍵字
7924
			#取得關鍵字
7925
			$keyWord=$keyWord["dataArray"][0];
7925
			$keyWord=$keyWord["dataArray"][0];
7926
 
7926
 
7927
			#預設層級為4層
7927
			#預設層級為4層
7928
			$layer=4;
7928
			$layer=4;
7929
 
7929
 
7930
			#檢查每個絕對路徑片段
7930
			#檢查每個絕對路徑片段
7931
			for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
7931
			for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
7932
				
7932
 
7933
				#如果路徑片段等於 $keyWord
7933
				#如果路徑片段等於 $keyWord
7934
				if($spiltString["dataArray"][$i]===$keyWord){
7934
				if($spiltString["dataArray"][$i]===$keyWord){
7935
					
7935
 
7936
					#取得層級
7936
					#取得層級
7937
					$layer=$i;
7937
					$layer=$i;
7938
					
7938
 
7939
					#跳出迴圈
7939
					#跳出迴圈
7940
					break;
7940
					break;
7941
 
7941
 
7942
					}#if end
7942
					}#if end
7943
				
7943
 
7944
				}#for end
7944
				}#for end
7945
 
7945
 
7946
			#可能的根目錄層級 - end
7946
			#可能的根目錄層級 - end
7947
 
7947
 
7948
			#網頁於檔案系統中的存放路徑可能為「/var/www/html」,從第四段到倒數第二段,將其內容合併
7948
			#網頁於檔案系統中的存放路徑可能為「/var/www/html」,從第四段到倒數第二段,將其內容合併
7949
			for($i=$layer;$i<$spiltString["dataCounts"]-1;$i++){
7949
			for($i=$layer;$i<$spiltString["dataCounts"]-1;$i++){
7950
				
7950
 
7951
				$result["webPathFromRoot"]=$result["webPathFromRoot"]."/".$spiltString["dataArray"][$i];
7951
				$result["webPathFromRoot"]=$result["webPathFromRoot"]."/".$spiltString["dataArray"][$i];
7952
				
7952
 
7953
				}#for end
7953
				}#for end
7954
				
7954
 
7955
			}#else end
7955
			}#else end
7956
			
7956
 
7957
		#加上檔案的路徑
7957
		#加上檔案的路徑
7958
		$result["webPathFromRoot"]=$result["webPathFromRoot"]."/".$conf["address"];			
7958
		$result["webPathFromRoot"]=$result["webPathFromRoot"]."/".$conf["address"];
7959
		
7959
 
7960
		#取得檔案位於網頁伺服器的絕對位置
7960
		#取得檔案位於網頁伺服器的絕對位置
7961
		#函式說明:
7961
		#函式說明:
7962
		#取得用戶端的資訊,並依據需要寫入到資料表裡面
7962
		#取得用戶端的資訊,並依據需要寫入到資料表裡面
7963
		#回傳結果:
7963
		#回傳結果:
7964
		#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
7964
		#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
Line 7985... Line 7985...
7985
			#例如:$conf["columnName"]=array("columnName1","columnName2","columnName3",...);
7985
			#例如:$conf["columnName"]=array("columnName1","columnName2","columnName3",...);
7986
			#寫入的資料依序為,使用者帳戶、瀏覽器資訊、使用者IP、觀看的網址、當時的時間
7986
			#寫入的資料依序為,使用者帳戶、瀏覽器資訊、使用者IP、觀看的網址、當時的時間
7987
			#$conf["saveToDb"]設為"true",則該參數為必填。
7987
			#$conf["saveToDb"]設為"true",則該參數為必填。
7988
		#$conf["dbPassword"]=$dbPassword;#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
7988
		#$conf["dbPassword"]=$dbPassword;#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
7989
		$getConnectionInfo=csInformation::getConnectionInfo($conf["csInformation::getConnectionInfo"]);
7989
		$getConnectionInfo=csInformation::getConnectionInfo($conf["csInformation::getConnectionInfo"]);
7990
		unset($conf["csInformation::getConnectionInfo"]);	
7990
		unset($conf["csInformation::getConnectionInfo"]);
7991
					
7991
 
7992
		#如果取得連線資訊失敗
7992
		#如果取得連線資訊失敗
7993
		if($getConnectionInfo["status"]==="false"){
7993
		if($getConnectionInfo["status"]==="false"){
7994
			
7994
 
7995
			#設置錯誤狀態
7995
			#設置錯誤狀態
7996
			$result["status"]="false";
7996
			$result["status"]="false";
7997
			
7997
 
7998
			#設置錯誤提示
7998
			#設置錯誤提示
7999
			$result["error"]=$getConnectionInfo;
7999
			$result["error"]=$getConnectionInfo;
8000
			
8000
 
8001
			#回傳結果
8001
			#回傳結果
8002
			return $result;
8002
			return $result;
8003
			
8003
 
8004
			}#if end
8004
			}#if end
8005
			
8005
 
8006
		#如果運行環境為 "web"
8006
		#如果運行環境為 "web"
8007
		if($getConnectionInfo["mode"]=="web"){
8007
		if($getConnectionInfo["mode"]=="web"){
8008
			
8008
 
8009
			#為絕對路徑加上通訊協定與ip與port
8009
			#為絕對路徑加上通訊協定與ip與port
8010
			#$result["content"]=$getConnectionInfo["scheme"]."://".$getConnectionInfo["serverIp"].":".$getConnectionInfo["serverPort"].$result["webPathFromRoot"];	
8010
			#$result["content"]=$getConnectionInfo["scheme"]."://".$getConnectionInfo["serverIp"].":".$getConnectionInfo["serverPort"].$result["webPathFromRoot"];
8011
				
8011
 
8012
			#為絕對路徑加上用戶端通訊協定與ip與port	
8012
			#為絕對路徑加上用戶端通訊協定與ip與port
8013
			$result["content"]=$getConnectionInfo["scheme"]."://".$getConnectionInfo["clientRequestIP"].$result["webPathFromRoot"];
8013
			$result["content"]=$getConnectionInfo["scheme"]."://".$getConnectionInfo["clientRequestIP"].$result["webPathFromRoot"];
8014
			
8014
 
8015
			}#if end
8015
			}#if end
8016
			
8016
 
8017
		#反之如果為 "cmd" 環境
8017
		#反之如果為 "cmd" 環境
8018
		else{
8018
		else{
8019
			
8019
 
8020
			$result["content"]="null";
8020
			$result["content"]="null";
8021
			
8021
 
8022
			}#else end
8022
			}#else end
8023
			
8023
 
8024
		#設置執行正常
8024
		#設置執行正常
8025
		$result["status"]="true";
8025
		$result["status"]="true";
8026
		
8026
 
8027
		#回傳結果
8027
		#回傳結果
8028
		return $result;
8028
		return $result;
8029
		
8029
 
8030
		}#function getInternetAddress end
8030
		}#function getInternetAddress end
8031
 
8031
 
8032
	/*
8032
	/*
8033
	#函式說明:
8033
	#函式說明:
8034
	#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
8034
	#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
8035
	#回傳結果:
8035
	#回傳結果:
8036
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
8036
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
8037
	#$result["error"],錯誤訊息陣列.
8037
	#$result["error"],錯誤訊息陣列.
8038
	#$result["function"],函數名稱. 
8038
	#$result["function"],函數名稱.
8039
	#$result["argu"],使用的參數.
8039
	#$result["argu"],使用的參數.
8040
	#$result["content"],網址,若是在命令列執行,則為"null".
8040
	#$result["content"],網址,若是在命令列執行,則為"null".
8041
	#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
8041
	#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
8042
	#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
8042
	#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
8043
	#必填參數:
8043
	#必填參數:
Line 8052... Line 8052...
8052
	#無.
8052
	#無.
8053
	#備註:
8053
	#備註:
8054
	#無.
8054
	#無.
8055
	*/
8055
	*/
8056
	public static function getInternetAddressV2(&$conf){
8056
	public static function getInternetAddressV2(&$conf){
8057
	
8057
 
8058
		#初始化要回傳的變數
8058
		#初始化要回傳的變數
8059
		$result=array();
8059
		$result=array();
8060
		
8060
 
8061
		#記錄當前執行的函數名稱
8061
		#記錄當前執行的函數名稱
8062
		$result["function"]=__FUNCTION__;
8062
		$result["function"]=__FUNCTION__;
8063
	
8063
 
8064
		#取得參數
8064
		#取得參數
8065
		$result["argu"]=$conf;
8065
		$result["argu"]=$conf;
8066
		
8066
 
8067
		#檢查參數
8067
		#檢查參數
8068
		#函式說明:
8068
		#函式說明:
8069
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
8069
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
8070
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8070
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8071
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
8071
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 8111... Line 8111...
8111
		#$conf["arrayCountEqualCheck"][]=array();
8111
		#$conf["arrayCountEqualCheck"][]=array();
8112
		#參考資料來源:
8112
		#參考資料來源:
8113
		#array_keys=>http://php.net/manual/en/function.array-keys.php
8113
		#array_keys=>http://php.net/manual/en/function.array-keys.php
8114
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
8114
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
8115
		unset($conf["variableCheck::checkArguments"]);
8115
		unset($conf["variableCheck::checkArguments"]);
8116
	
8116
 
8117
		#如果檢查失敗
8117
		#如果檢查失敗
8118
		if($checkArguments["status"]==="false"){
8118
		if($checkArguments["status"]==="false"){
8119
		
8119
 
8120
			#設置錯誤狀態
8120
			#設置錯誤狀態
8121
			$result["status"]="false";
8121
			$result["status"]="false";
8122
			
8122
 
8123
			#設置錯誤提示
8123
			#設置錯誤提示
8124
			$result["error"]=$checkArguments;
8124
			$result["error"]=$checkArguments;
8125
			
8125
 
8126
			#回傳結果
8126
			#回傳結果
8127
			return $result;
8127
			return $result;
8128
		
8128
 
8129
			}#if end
8129
			}#if end
8130
			
8130
 
8131
		#如果檢查不通過
8131
		#如果檢查不通過
8132
		if($checkArguments["passed"]==="false"){
8132
		if($checkArguments["passed"]==="false"){
8133
		
8133
 
8134
			#設置錯誤狀態
8134
			#設置錯誤狀態
8135
			$result["status"]="false";
8135
			$result["status"]="false";
8136
			
8136
 
8137
			#設置錯誤提示
8137
			#設置錯誤提示
8138
			$result["error"]=$checkArguments;
8138
			$result["error"]=$checkArguments;
8139
			
8139
 
8140
			#回傳結果
8140
			#回傳結果
8141
			return $result;
8141
			return $result;
8142
		
8142
 
8143
			}#if end
8143
			}#if end
8144
	
8144
 
8145
		#如果是本來就是網址了
8145
		#如果是本來就是網址了
8146
		if(strpos($conf["address"],'https://')===0 || strpos($conf["address"],'http://')===0){
8146
		if(strpos($conf["address"],'https://')===0 || strpos($conf["address"],'http://')===0){
8147
		
8147
 
8148
			#取得網址
8148
			#取得網址
8149
			$result["content"]=$conf["address"];
8149
			$result["content"]=$conf["address"];
8150
				
8150
 
8151
			}#if end
8151
			}#if end
8152
	
8152
 
8153
		#反之是絕對或相對路徑
8153
		#反之是絕對或相對路徑
8154
		else{
8154
		else{
8155
		
8155
 
8156
			#確認 $conf["address"] 是否為 escaped 後的內容
8156
			#確認 $conf["address"] 是否為 escaped 後的內容
8157
			#函式說明:
8157
			#函式說明:
8158
			#判斷字串是否一定需要經過escapeshellarg才能為單一shell參數,並回傳可以成為單一shell參數的結果.
8158
			#判斷字串是否一定需要經過escapeshellarg才能為單一shell參數,並回傳可以成為單一shell參數的結果.
8159
			#回傳結果:
8159
			#回傳結果:
8160
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8160
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 8173... Line 8173...
8173
			#無.
8173
			#無.
8174
			#備註:
8174
			#備註:
8175
			#無.
8175
			#無.
8176
			$toSingleShellArg=stringProcess::toSingleShellArg($conf["stringProcess::toSingleShellArg"]);
8176
			$toSingleShellArg=stringProcess::toSingleShellArg($conf["stringProcess::toSingleShellArg"]);
8177
			unset($conf["stringProcess::toSingleShellArg"]);
8177
			unset($conf["stringProcess::toSingleShellArg"]);
8178
		
8178
 
8179
			#如果執行失敗
8179
			#如果執行失敗
8180
			if($toSingleShellArg["status"]==="false"){
8180
			if($toSingleShellArg["status"]==="false"){
8181
			
8181
 
8182
				#設置錯誤狀態
8182
				#設置錯誤狀態
8183
				$result["status"]="false";
8183
				$result["status"]="false";
8184
				
8184
 
8185
				#設置錯誤提示
8185
				#設置錯誤提示
8186
				$result["error"]=$toSingleShellArg;
8186
				$result["error"]=$toSingleShellArg;
8187
				
8187
 
8188
				#回傳結果
8188
				#回傳結果
8189
				return $result;
8189
				return $result;
8190
				
8190
 
8191
				}#if end
8191
				}#if end
8192
			
8192
 
8193
			#取得不含escape字元的address參數
8193
			#取得不含escape字元的address參數
8194
			$conf["address"]=urldecode($toSingleShellArg["urlEncodeStr"]);
8194
			$conf["address"]=urldecode($toSingleShellArg["urlEncodeStr"]);
8195
			
8195
 
8196
			#不是絕對位置
8196
			#不是絕對位置
8197
			if(strpos($conf["address"],"/")!==0){
8197
			if(strpos($conf["address"],"/")!==0){
8198
			
8198
 
8199
				#如果有這些參數
8199
				#如果有這些參數
8200
				if( isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) ){
8200
				if( isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) ){
8201
			
8201
 
8202
					#網址
8202
					#網址
8203
					$result["content"]=$_SERVER['REQUEST_SCHEME']."://".$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT']."/".$conf["address"];
8203
					$result["content"]=$_SERVER['REQUEST_SCHEME']."://".$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT']."/".$conf["address"];
8204
			
8204
 
8205
					}#if end
8205
					}#if end
8206
					
8206
 
8207
				#反之
8207
				#反之
8208
				else{
8208
				else{
8209
				
8209
 
8210
					#網址設置為 null
8210
					#網址設置為 null
8211
					$result["content"]=null;
8211
					$result["content"]=null;
8212
				
8212
 
8213
					}#else
8213
					}#else
8214
			
8214
 
8215
				}#if end
8215
				}#if end
8216
			
8216
 
8217
			#反之是絕對位置
8217
			#反之是絕對位置
8218
			else{
8218
			else{
8219
			
8219
 
8220
				#移除開頭的 "/"
8220
				#移除開頭的 "/"
8221
				$conf["address"]=substr($conf["address"],1);
8221
				$conf["address"]=substr($conf["address"],1);
8222
			
8222
 
8223
				#如果有這些參數
8223
				#如果有這些參數
8224
				if( isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) ){
8224
				if( isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) ){
8225
			
8225
 
8226
					#網址
8226
					#網址
8227
					$result["content"]=$_SERVER['REQUEST_SCHEME']."://".$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT']."/".$conf["address"];
8227
					$result["content"]=$_SERVER['REQUEST_SCHEME']."://".$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT']."/".$conf["address"];
8228
				
8228
 
8229
					}#if end
8229
					}#if end
8230
					
8230
 
8231
				#反之
8231
				#反之
8232
				else{
8232
				else{
8233
				
8233
 
8234
					#網址設置為 null
8234
					#網址設置為 null
8235
					$result["content"]=null;
8235
					$result["content"]=null;
8236
				
8236
 
8237
					}#else
8237
					}#else
8238
				
8238
 
8239
				}#else end
8239
				}#else end
8240
			
8240
 
8241
			#取得 doc root;
8241
			#取得 doc root;
8242
			$docRoot=$_SERVER['DOCUMENT_ROOT'];
8242
			$docRoot=$_SERVER['DOCUMENT_ROOT'];
8243
			
8243
 
8244
			#如果不是網路環境
8244
			#如果不是網路環境
8245
			if($conf["web"]==="false"){
8245
			if($conf["web"]==="false"){
8246
				
8246
 
8247
				#不採用 docRoot
8247
				#不採用 docRoot
8248
				$docRoot="";
8248
				$docRoot="";
8249
				
8249
 
8250
				}#if end
8250
				}#if end
8251
							
8251
 
8252
			#如果不存在 DOCUMENT_ROOT 變數或 web 參數為 "false" 且為相對位置.
8252
			#如果不存在 DOCUMENT_ROOT 變數或 web 參數為 "false" 且為相對位置.
8253
			if( ($_SERVER['DOCUMENT_ROOT']==="" || $conf["web"]==="false") && (strpos($result["argu"]["address"],"/")!==0) ){
8253
			if( ($_SERVER['DOCUMENT_ROOT']==="" || $conf["web"]==="false") && (strpos($result["argu"]["address"],"/")!==0) ){
8254
				
8254
 
8255
				#執行 "pwd" 取得當前位置
8255
				#執行 "pwd" 取得當前位置
8256
				exec("pwd",$output,$status);
8256
				exec("pwd",$output,$status);
8257
				
8257
 
8258
				#預設為`pwd`的結果加"/"
8258
				#預設為`pwd`的結果加"/"
8259
				$docRoot=$output[0]."/";
8259
				$docRoot=$output[0]."/";
8260
				
8260
 
8261
				}#if end	
8261
				}#if end
8262
			
8262
 
8263
			#如果是絕對位置
8263
			#如果是絕對位置
8264
			else if(strpos($result["argu"]["address"],"/")===0){
8264
			else if(strpos($result["argu"]["address"],"/")===0){
8265
				
8265
 
8266
				#補回 "/" 
8266
				#補回 "/"
8267
				$conf["address"]="/".$conf["address"];
8267
				$conf["address"]="/".$conf["address"];
8268
				
8268
 
8269
				}#if end
8269
				}#if end
8270
			
8270
 
8271
			#針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
8271
			#針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
8272
			$result["fileSystemAbsoulutePosition"]=$docRoot.$conf["address"];
8272
			$result["fileSystemAbsoulutePosition"]=$docRoot.$conf["address"];
8273
				
8273
 
8274
			}#else end
8274
			}#else end
8275
		
8275
 
8276
		#設置執行正常
8276
		#設置執行正常
8277
		$result["status"]="true";	
8277
		$result["status"]="true";
8278
			
8278
 
8279
		#回傳結果
8279
		#回傳結果
8280
		return $result;
8280
		return $result;
8281
	
8281
 
8282
		}#function getInternetAddressV2 end
8282
		}#function getInternetAddressV2 end
8283
 
8283
 
8284
	/*
8284
	/*
8285
	#函式說明:
8285
	#函式說明:
8286
	#將含有「*」的檔案路徑名稱,變成多個符合條件的路徑檔案.
8286
	#將含有「*」的檔案路徑名稱,變成多個符合條件的路徑檔案.
8287
	#回傳結果:
8287
	#回傳結果:
8288
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
8288
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
8289
	#$result["error"],錯誤訊息陣列.
8289
	#$result["error"],錯誤訊息陣列.
8290
	#$result["function"],函數名稱. 
8290
	#$result["function"],函數名稱.
8291
	#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
8291
	#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
8292
	#必填參數:
8292
	#必填參數:
8293
	#$conf["path"],字串,要解析含有「*」的檔案路徑字串.
8293
	#$conf["path"],字串,要解析含有「*」的檔案路徑字串.
8294
	$conf["path"]="";
8294
	$conf["path"]="";
8295
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
8295
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
Line 8303... Line 8303...
8303
	#無.
8303
	#無.
8304
	#備註:
8304
	#備註:
8305
	#無.
8305
	#無.
8306
	*/
8306
	*/
8307
	public static function resolvePostionStringWhichContainStarSymbol(&$conf){
8307
	public static function resolvePostionStringWhichContainStarSymbol(&$conf){
8308
		
8308
 
8309
		#初始化要回傳的結果
8309
		#初始化要回傳的結果
8310
		$result=array();
8310
		$result=array();
8311
		
8311
 
8312
		#設置當其函數名稱
8312
		#設置當其函數名稱
8313
		$result["function"]=__FUNCTION__;
8313
		$result["function"]=__FUNCTION__;
8314
		
8314
 
8315
		#如果 $conf 不為陣列
8315
		#如果 $conf 不為陣列
8316
		if(gettype($conf)!="array"){
8316
		if(gettype($conf)!="array"){
8317
			
8317
 
8318
			#設置執行失敗
8318
			#設置執行失敗
8319
			$result["status"]="false";
8319
			$result["status"]="false";
8320
			
8320
 
8321
			#設置執行錯誤訊息
8321
			#設置執行錯誤訊息
8322
			$result["error"][]="\$conf變數須為陣列形態";
8322
			$result["error"][]="\$conf變數須為陣列形態";
8323
 
8323
 
8324
			#如果傳入的參數為 null
8324
			#如果傳入的參數為 null
8325
			if($conf==null){
8325
			if($conf==null){
8326
				
8326
 
8327
				#設置執行錯誤訊息
8327
				#設置執行錯誤訊息
8328
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
8328
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
8329
				
8329
 
8330
				}#if end
8330
				}#if end
8331
 
8331
 
8332
			#回傳結果
8332
			#回傳結果
8333
			return $result;
8333
			return $result;
8334
			
8334
 
8335
			}#if end
8335
			}#if end
8336
			
8336
 
8337
		#檢查參數
8337
		#檢查參數
8338
		#函式說明:
8338
		#函式說明:
8339
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
8339
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
8340
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8340
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8341
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
8341
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 8350... Line 8350...
8350
		#必填寫的參數:
8350
		#必填寫的參數:
8351
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
8351
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
8352
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
8352
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
8353
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
8353
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
8354
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
8354
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
8355
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
8355
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
8356
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
8356
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
8357
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
8357
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
8358
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
8358
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
8359
		#可以省略的參數:
8359
		#可以省略的參數:
8360
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
8360
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
8361
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
8361
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
8362
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
8362
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
8363
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("noDotStart","noWaveEnd");
8363
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("noDotStart","noWaveEnd");
8364
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
8364
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
8365
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
8365
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
8366
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
8366
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
8367
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","true");
8367
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","true");
8368
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
8368
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
8369
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
8369
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
8370
		#參考資料來源:
8370
		#參考資料來源:
8371
		#array_keys=>http://php.net/manual/en/function.array-keys.php
8371
		#array_keys=>http://php.net/manual/en/function.array-keys.php
8372
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
8372
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
8373
		unset($conf["variableCheck::checkArguments"]);
8373
		unset($conf["variableCheck::checkArguments"]);
8374
		
8374
 
8375
		#如果 $checkResult["status"] 等於 "fasle"
8375
		#如果 $checkResult["status"] 等於 "fasle"
8376
		if($checkResult["status"]==="false"){
8376
		if($checkResult["status"]==="false"){
8377
			
8377
 
8378
			#設置錯誤識別
8378
			#設置錯誤識別
8379
			$result["status"]="false";
8379
			$result["status"]="false";
8380
			
8380
 
8381
			#設置錯誤訊息
8381
			#設置錯誤訊息
8382
			$result["error"]=$checkResult;
8382
			$result["error"]=$checkResult;
8383
			
8383
 
8384
			#回傳結果
8384
			#回傳結果
8385
			return $result;
8385
			return $result;
8386
			
8386
 
8387
			}#if end
8387
			}#if end
8388
			
8388
 
8389
		#如果 $checkResult["passed"] 等於 "fasle"
8389
		#如果 $checkResult["passed"] 等於 "fasle"
8390
		if($checkResult["passed"]==="false"){
8390
		if($checkResult["passed"]==="false"){
8391
			
8391
 
8392
			#設置錯誤識別
8392
			#設置錯誤識別
8393
			$result["status"]="false";
8393
			$result["status"]="false";
8394
			
8394
 
8395
			#設置錯誤訊息
8395
			#設置錯誤訊息
8396
			$result["error"]=$checkResult;
8396
			$result["error"]=$checkResult;
8397
			
8397
 
8398
			#回傳結果
8398
			#回傳結果
8399
			return $result;
8399
			return $result;
8400
			
8400
 
8401
			}#if end
8401
			}#if end
8402
		
8402
 
8403
		#轉換檔案路徑為相對於伺服器檔案系統的絕對路徑
8403
		#轉換檔案路徑為相對於伺服器檔案系統的絕對路徑
8404
		#函式說明:
8404
		#函式說明:
8405
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
8405
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
8406
		#回傳結果:
8406
		#回傳結果:
8407
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
8407
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
8408
		#$result["error"],錯誤訊息陣列.
8408
		#$result["error"],錯誤訊息陣列.
8409
		#$result["function"],函數名稱. 
8409
		#$result["function"],函數名稱.
8410
		#$result["content"],網址.
8410
		#$result["content"],網址.
8411
		#$result["localAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
8411
		#$result["localAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
8412
		#$result["fileSystemAbsoulutePosition"],針對伺服器檔案系統的絕對位置.
8412
		#$result["fileSystemAbsoulutePosition"],針對伺服器檔案系統的絕對位置.
8413
		#必填參數:
8413
		#必填參數:
8414
		#$conf["address"],字串,檔案的相對位置.
8414
		#$conf["address"],字串,檔案的相對位置.
Line 8417... Line 8417...
8417
		$conf["fileAccess::getInternetAddress"]["fileArgu"]=$conf["fileArgu"];
8417
		$conf["fileAccess::getInternetAddress"]["fileArgu"]=$conf["fileArgu"];
8418
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是.
8418
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是.
8419
		$conf["fileAccess::getInternetAddress"]["userDir"]="true";
8419
		$conf["fileAccess::getInternetAddress"]["userDir"]="true";
8420
		$getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
8420
		$getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
8421
		unset($conf["fileAccess::getInternetAddress"]);
8421
		unset($conf["fileAccess::getInternetAddress"]);
8422
					
8422
 
8423
		#如果轉換路徑失敗
8423
		#如果轉換路徑失敗
8424
		if($getInternetAddress["status"]=="false"){
8424
		if($getInternetAddress["status"]=="false"){
8425
			
8425
 
8426
			#設置錯誤識別
8426
			#設置錯誤識別
8427
			$result["status"]="false";
8427
			$result["status"]="false";
8428
			
8428
 
8429
			#設置錯誤訊息
8429
			#設置錯誤訊息
8430
			$result["error"]=$checkResult;
8430
			$result["error"]=$checkResult;
8431
			
8431
 
8432
			#回傳結果
8432
			#回傳結果
8433
			return $result;
8433
			return $result;
8434
			
8434
 
8435
			}#if end
8435
			}#if end
8436
			
8436
 
8437
		#取得轉換好的路徑
8437
		#取得轉換好的路徑
8438
		$conf["path"]=$getInternetAddress["fileSystemAbsoulutePosition"];
8438
		$conf["path"]=$getInternetAddress["fileSystemAbsoulutePosition"];
8439
		
8439
 
8440
		#檢查檔案路徑字串是否含有「*」
8440
		#檢查檔案路徑字串是否含有「*」
8441
		#函式說明:
8441
		#函式說明:
8442
		#檢查字串裡面有無指定的關鍵字
8442
		#檢查字串裡面有無指定的關鍵字
8443
		#回傳結果:
8443
		#回傳結果:
8444
		#$result["status"],"true"代表執行成功,"false"代表執行失敗。
8444
		#$result["status"],"true"代表執行成功,"false"代表執行失敗。
Line 8451... Line 8451...
8451
		$conf["search::findKeyWord"]["string"]=$conf["path"];#要被搜尋的字串內容
8451
		$conf["search::findKeyWord"]["string"]=$conf["path"];#要被搜尋的字串內容
8452
		#可省略參數:
8452
		#可省略參數:
8453
		#$conf["fileAccess::findKeyWord"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
8453
		#$conf["fileAccess::findKeyWord"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
8454
		$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
8454
		$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
8455
		unset($conf["search::findKeyWord"]);
8455
		unset($conf["search::findKeyWord"]);
8456
		
8456
 
8457
		#如果尋找關鍵字出錯
8457
		#如果尋找關鍵字出錯
8458
		if($findKeyWord["status"]=="false"){
8458
		if($findKeyWord["status"]=="false"){
8459
			
8459
 
8460
			#設置錯誤識別
8460
			#設置錯誤識別
8461
			$result["status"]="false";
8461
			$result["status"]="false";
8462
			
8462
 
8463
			#設置錯誤訊息
8463
			#設置錯誤訊息
8464
			$result["error"]=$findKeyWord;
8464
			$result["error"]=$findKeyWord;
8465
			
8465
 
8466
			#回傳結果
8466
			#回傳結果
8467
			return $result;
8467
			return $result;
8468
			
8468
 
8469
			}#if end
8469
			}#if end
8470
		
8470
 
8471
		#如果含有「*」
8471
		#如果含有「*」
8472
		if($findKeyWord["founded"]=="true"){
8472
		if($findKeyWord["founded"]=="true"){
8473
			
8473
 
8474
			#透過「/」分割路徑字串
8474
			#透過「/」分割路徑字串
8475
			#函式說明:
8475
			#函式說明:
8476
			#將固定格式的字串分開,並回傳分開的結果。
8476
			#將固定格式的字串分開,並回傳分開的結果。
8477
			#回傳的參數:
8477
			#回傳的參數:
8478
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8478
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 8484... Line 8484...
8484
			#必填參數:
8484
			#必填參數:
8485
			$conf["stringProcess::spiltString"]["stringIn"]=$conf["path"];#要處理的字串。
8485
			$conf["stringProcess::spiltString"]["stringIn"]=$conf["path"];#要處理的字串。
8486
			$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
8486
			$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
8487
			$spiltPathStr=stringProcess::spiltString($conf["stringProcess::spiltString"]);
8487
			$spiltPathStr=stringProcess::spiltString($conf["stringProcess::spiltString"]);
8488
			unset($conf["stringProcess::spiltString"]);
8488
			unset($conf["stringProcess::spiltString"]);
8489
			
8489
 
8490
			#如果分割字串失敗
8490
			#如果分割字串失敗
8491
			if($spiltPathStr["status"]=="false"){
8491
			if($spiltPathStr["status"]=="false"){
8492
				
8492
 
8493
				#設置錯誤識別
8493
				#設置錯誤識別
8494
				$result["status"]="false";
8494
				$result["status"]="false";
8495
				
8495
 
8496
				#設置錯誤訊息
8496
				#設置錯誤訊息
8497
				$result["error"]=$spiltPathStr;
8497
				$result["error"]=$spiltPathStr;
8498
				
8498
 
8499
				#回傳結果
8499
				#回傳結果
8500
				return $result;
8500
				return $result;
8501
				
8501
 
8502
				}#if end
8502
				}#if end
8503
			
8503
 
8504
			#初始化暫存展開後的檔案路徑字串
8504
			#初始化暫存展開後的檔案路徑字串
8505
			$extendPath=array("");			
8505
			$extendPath=array("");
8506
												
8506
 
8507
			#要解析的路徑分成幾段就執行幾次
8507
			#要解析的路徑分成幾段就執行幾次
8508
			foreach($spiltPathStr["dataArray"] as $pathPart){
8508
			foreach($spiltPathStr["dataArray"] as $pathPart){
8509
				
8509
 
8510
				#檢查該段名稱是否有「*」
8510
				#檢查該段名稱是否有「*」
8511
				#函式說明:
8511
				#函式說明:
8512
				#檢查字串裡面有無指定的關鍵字
8512
				#檢查字串裡面有無指定的關鍵字
8513
				#回傳結果:
8513
				#回傳結果:
8514
				#$result["status"],"true"代表執行成功,"false"代表執行失敗。
8514
				#$result["status"],"true"代表執行成功,"false"代表執行失敗。
Line 8521... Line 8521...
8521
				$conf["search::findKeyWord"]["string"]=$pathPart;#要被搜尋的字串內容
8521
				$conf["search::findKeyWord"]["string"]=$pathPart;#要被搜尋的字串內容
8522
				#可省略參數:
8522
				#可省略參數:
8523
				#$conf["fileAccess::findKeyWord"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
8523
				#$conf["fileAccess::findKeyWord"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
8524
				$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
8524
				$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
8525
				unset($conf["search::findKeyWord"]);
8525
				unset($conf["search::findKeyWord"]);
8526
				
8526
 
8527
				#如果尋找關鍵字出錯
8527
				#如果尋找關鍵字出錯
8528
				if($findKeyWord["status"]=="false"){
8528
				if($findKeyWord["status"]=="false"){
8529
					
8529
 
8530
					#設置錯誤識別
8530
					#設置錯誤識別
8531
					$result["status"]="false";
8531
					$result["status"]="false";
8532
					
8532
 
8533
					#設置錯誤訊息
8533
					#設置錯誤訊息
8534
					$result["error"]=$findKeyWord;
8534
					$result["error"]=$findKeyWord;
8535
					
8535
 
8536
					#回傳結果
8536
					#回傳結果
8537
					return $result;
8537
					return $result;
8538
					
8538
 
8539
					}#if end									
8539
					}#if end
8540
					
8540
 
8541
				#如果不含「*」
8541
				#如果不含「*」
8542
				if($findKeyWord["founded"]=="false"){
8542
				if($findKeyWord["founded"]=="false"){
8543
					
8543
 
8544
					#針對每個既有的路徑
8544
					#針對每個既有的路徑
8545
					for($i=0;$i<count($extendPath);$i++){
8545
					for($i=0;$i<count($extendPath);$i++){
8546
								
8546
 
8547
						#加上切割好的路徑
8547
						#加上切割好的路徑
8548
						$extendPath[$i]=$extendPath[$i]."/".$pathPart;
8548
						$extendPath[$i]=$extendPath[$i]."/".$pathPart;
8549
																				
-
 
-
 
8549
 
8550
						}#for end
8550
						}#for end
8551
					
8551
 
8552
					}#if end
8552
					}#if end
8553
				
8553
 
8554
				#反之該段含有「*」	
8554
				#反之該段含有「*」
8555
				else{
8555
				else{
8556
					
8556
 
8557
					#用「*」分割該段
8557
					#用「*」分割該段
8558
					#函式說明:
8558
					#函式說明:
8559
					#將固定格式的字串分開,並回傳分開的結果。
8559
					#將固定格式的字串分開,並回傳分開的結果。
8560
					#回傳的參數:
8560
					#回傳的參數:
8561
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8561
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 8567... Line 8567...
8567
					#必填參數:
8567
					#必填參數:
8568
					$conf["stringProcess::spiltString"]["stringIn"]=$pathPart;#要處理的字串。
8568
					$conf["stringProcess::spiltString"]["stringIn"]=$pathPart;#要處理的字串。
8569
					$conf["stringProcess::spiltString"]["spiltSymbol"]="*";#爲以哪個符號作爲分割
8569
					$conf["stringProcess::spiltString"]["spiltSymbol"]="*";#爲以哪個符號作爲分割
8570
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
8570
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
8571
					unset($conf["stringProcess::spiltString"]);
8571
					unset($conf["stringProcess::spiltString"]);
8572
					
8572
 
8573
					#如果分字串失敗
8573
					#如果分字串失敗
8574
					if($spiltString["status"]=="false"){
8574
					if($spiltString["status"]=="false"){
8575
						
8575
 
8576
						#設置錯誤識別
8576
						#設置錯誤識別
8577
						$result["status"]="false";
8577
						$result["status"]="false";
8578
						
8578
 
8579
						#設置錯誤訊息
8579
						#設置錯誤訊息
8580
						$result["error"]=$spiltStringByStar;
8580
						$result["error"]=$spiltStringByStar;
8581
						
8581
 
8582
						#回傳結果
8582
						#回傳結果
8583
						return $result;
8583
						return $result;
8584
						
8584
 
8585
						}#if end
8585
						}#if end
8586
						
8586
 
8587
					#如果用「*」分割後的段數為0
8587
					#如果用「*」分割後的段數為0
8588
					if($spiltString["dataCounts"]==0){
8588
					if($spiltString["dataCounts"]==0){
8589
						
8589
 
8590
						#初始化儲存符合條件的路徑
8590
						#初始化儲存符合條件的路徑
8591
						$newExtendPath=array();
8591
						$newExtendPath=array();
8592
						
8592
 
8593
						#代表沒有塞選條件
8593
						#代表沒有塞選條件
8594
						#當前有幾個符合條件的路徑就執行幾次
8594
						#當前有幾個符合條件的路徑就執行幾次
8595
						for($i=0;$i<count($extendPath);$i++){
8595
						for($i=0;$i<count($extendPath);$i++){
8596
							
8596
 
8597
							#取得該目錄下所有的東西
8597
							#取得該目錄下所有的東西
8598
							#取得該目錄底下的檔案目錄清單
8598
							#取得該目錄底下的檔案目錄清單
8599
							#函式說明:
8599
							#函式說明:
8600
							#取得目錄底下所有目錄與檔案清單.
8600
							#取得目錄底下所有目錄與檔案清單.
8601
							#回傳結果:
8601
							#回傳結果:
Line 8616... Line 8616...
8616
							#無
8616
							#無
8617
							#參考資料來源:
8617
							#參考資料來源:
8618
							#opendir=>http://php.net/manual/en/function.opendir.php
8618
							#opendir=>http://php.net/manual/en/function.opendir.php
8619
							#is_dir=>http://php.net/manual/en/function.is-dir.php
8619
							#is_dir=>http://php.net/manual/en/function.is-dir.php
8620
							$getList=fileAccess::getList($conf["fileAccess::getList"]);
8620
							$getList=fileAccess::getList($conf["fileAccess::getList"]);
8621
							unset($conf["fileAccess::getList"]);										
8621
							unset($conf["fileAccess::getList"]);
8622
							
8622
 
8623
							#如果取得目標目錄底下的檔案目錄清單失敗
8623
							#如果取得目標目錄底下的檔案目錄清單失敗
8624
							if($getList["status"]=="false"){
8624
							if($getList["status"]=="false"){
8625
								
8625
 
8626
								#設置錯誤識別
8626
								#設置錯誤識別
8627
								$result["status"]="false";
8627
								$result["status"]="false";
8628
								
8628
 
8629
								#設置錯誤訊息
8629
								#設置錯誤訊息
8630
								$result["error"]=$getList;																				
8630
								$result["error"]=$getList;
8631
								
8631
 
8632
								#回傳結果
8632
								#回傳結果
8633
								return $result;
8633
								return $result;
8634
								
8634
 
8635
								}#if end
8635
								}#if end
8636
							
8636
 
8637
							#如果底下有東西
8637
							#如果底下有東西
8638
							if(count($getList["content"])>0){
8638
							if(count($getList["content"])>0){
8639
								
8639
 
8640
								#初始化儲存要檢查的檔案或資料夾名稱陣列
8640
								#初始化儲存要檢查的檔案或資料夾名稱陣列
8641
								$list=array();
8641
								$list=array();
8642
								
8642
 
8643
								#針對每個檔案或資料夾
8643
								#針對每個檔案或資料夾
8644
								foreach($getList["content"] as $num=>$array){
8644
								foreach($getList["content"] as $num=>$array){
8645
									
8645
 
8646
									#儲存該名稱
8646
									#儲存該名稱
8647
									$list[]=$array["name"];
8647
									$list[]=$array["name"];
8648
									
8648
 
8649
									}#foreach end
8649
									}#foreach end
8650
									
8650
 
8651
								#初始化儲存符合新條件字串的陣列
8651
								#初始化儲存符合新條件字串的陣列
8652
								$tempExtendPath=array();
8652
								$tempExtendPath=array();
8653
																
-
 
-
 
8653
 
8654
								#針對每個現有的路徑字串
8654
								#針對每個現有的路徑字串
8655
								for($j=0;$j<count($extendPath);$j++){
8655
								for($j=0;$j<count($extendPath);$j++){
8656
									
8656
 
8657
									#附加每個符合條件的名稱到路徑字串裡面
8657
									#附加每個符合條件的名稱到路徑字串裡面
8658
									for($k=0;$k<count($list);$k++){
8658
									for($k=0;$k<count($list);$k++){
8659
										
8659
 
8660
										#如果 $conf["noDotStart"] 為 "true"
8660
										#如果 $conf["noDotStart"] 為 "true"
8661
										if($conf["noDotStart"]==="true"){
8661
										if($conf["noDotStart"]==="true"){
8662
											
8662
 
8663
											#將 $list[$k] 用 "/" 分割
8663
											#將 $list[$k] 用 "/" 分割
8664
											#函式說明:
8664
											#函式說明:
8665
											#將固定格式的字串分開,並回傳分開的結果。
8665
											#將固定格式的字串分開,並回傳分開的結果。
8666
											#回傳結果:
8666
											#回傳結果:
8667
											#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8667
											#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 8677... Line 8677...
8677
											#可省略參數:
8677
											#可省略參數:
8678
											#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
8678
											#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
8679
											$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
8679
											$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
8680
											$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
8680
											$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
8681
											unset($conf["stringProcess::spiltString"]);
8681
											unset($conf["stringProcess::spiltString"]);
8682
											
8682
 
8683
											#如果分割路徑失敗
8683
											#如果分割路徑失敗
8684
											if($spiltString["status"]==="false"){
8684
											if($spiltString["status"]==="false"){
8685
												
8685
 
8686
												#設置執行錯誤識別
8686
												#設置執行錯誤識別
8687
												$result["status"]="false";
8687
												$result["status"]="false";
8688
												
8688
 
8689
												#取得錯誤訊息
8689
												#取得錯誤訊息
8690
												$result["error"]=$spiltString;
8690
												$result["error"]=$spiltString;
8691
												
8691
 
8692
												#回傳結果
8692
												#回傳結果
8693
												return $result;
8693
												return $result;
8694
												
8694
 
8695
												}#if end
8695
												}#if end
8696
												
8696
 
8697
											#如果有關鍵字「/」存在
8697
											#如果有關鍵字「/」存在
8698
											if($spiltString["found"]==="true"){
8698
											if($spiltString["found"]==="true"){
8699
												
8699
 
8700
												#針對每個段落
8700
												#針對每個段落
8701
												foreach($spiltString["dataArray"] as $pp){
8701
												foreach($spiltString["dataArray"] as $pp){
8702
													
8702
 
8703
													#看該符合的名稱開頭是否包含「.」
8703
													#看該符合的名稱開頭是否包含「.」
8704
													#函式說明:
8704
													#函式說明:
8705
													#取得符合特定字首與字尾的字串
8705
													#取得符合特定字首與字尾的字串
8706
													#回傳結果:
8706
													#回傳結果:
8707
													#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
8707
													#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 8719... Line 8719...
8719
													#$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
8719
													#$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
8720
													#參考資料:
8720
													#參考資料:
8721
													#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
8721
													#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
8722
													$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
8722
													$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
8723
													unset($conf["search::getMeetConditionsString"]);
8723
													unset($conf["search::getMeetConditionsString"]);
8724
													
8724
 
8725
													#如果 取得符合特定字首的字串 出錯
8725
													#如果 取得符合特定字首的字串 出錯
8726
													if($getMeetConditionsString["status"]=="false"){
8726
													if($getMeetConditionsString["status"]=="false"){
8727
														
8727
 
8728
														#設置執行錯誤識別
8728
														#設置執行錯誤識別
8729
														$result["status"]="false";
8729
														$result["status"]="false";
8730
														
8730
 
8731
														#設置錯誤訊息
8731
														#設置錯誤訊息
8732
														$result["error"]=$getMeetConditionsString;
8732
														$result["error"]=$getMeetConditionsString;
8733
														
8733
 
8734
														#回傳結果
8734
														#回傳結果
8735
														return $result;
8735
														return $result;
8736
														
8736
 
8737
														}#if end
8737
														}#if end
8738
														
8738
 
8739
													#如果有「.」在開頭
8739
													#如果有「.」在開頭
8740
													if($getMeetConditionsString["founded"]=="true"){
8740
													if($getMeetConditionsString["founded"]=="true"){
8741
														
8741
 
8742
														#忽略這個名稱 
8742
														#忽略這個名稱
8743
														continue 2;
8743
														continue 2;
8744
														
8744
 
8745
														}#if end
8745
														}#if end
8746
													
8746
 
8747
													}#foreach end
8747
													}#foreach end
8748
												
8748
 
8749
												}#if end
8749
												}#if end
8750
											
8750
 
8751
											#反之沒有關鍵字「/」存在
8751
											#反之沒有關鍵字「/」存在
8752
											else{
8752
											else{
8753
												
8753
 
8754
												#看該符合的名稱開頭是否包含「.」
8754
												#看該符合的名稱開頭是否包含「.」
8755
												#函式說明:
8755
												#函式說明:
8756
												#取得符合特定字首與字尾的字串
8756
												#取得符合特定字首與字尾的字串
8757
												#回傳結果:
8757
												#回傳結果:
8758
												#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
8758
												#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 8770... Line 8770...
8770
												#$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
8770
												#$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
8771
												#參考資料:
8771
												#參考資料:
8772
												#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
8772
												#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
8773
												$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
8773
												$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
8774
												unset($conf["search::getMeetConditionsString"]);
8774
												unset($conf["search::getMeetConditionsString"]);
8775
												
8775
 
8776
												#如果 取得符合特定字首的字串 出錯
8776
												#如果 取得符合特定字首的字串 出錯
8777
												if($getMeetConditionsString["status"]=="false"){
8777
												if($getMeetConditionsString["status"]=="false"){
8778
													
8778
 
8779
													#設置執行錯誤識別
8779
													#設置執行錯誤識別
8780
													$result["status"]="false";
8780
													$result["status"]="false";
8781
													
8781
 
8782
													#設置錯誤訊息
8782
													#設置錯誤訊息
8783
													$result["error"]=$getMeetConditionsString;
8783
													$result["error"]=$getMeetConditionsString;
8784
													
8784
 
8785
													#回傳結果
8785
													#回傳結果
8786
													return $result;
8786
													return $result;
8787
													
8787
 
8788
													}#if end
8788
													}#if end
8789
													
8789
 
8790
												#如果有「.」在開頭
8790
												#如果有「.」在開頭
8791
												if($getMeetConditionsString["founded"]=="true"){
8791
												if($getMeetConditionsString["founded"]=="true"){
8792
													
8792
 
8793
													#忽略這個名稱 
8793
													#忽略這個名稱
8794
													continue;
8794
													continue;
8795
													
8795
 
8796
													}#if end
8796
													}#if end
8797
												
8797
 
8798
												}#else end
8798
												}#else end
8799
											
8799
 
8800
											}#if end
8800
											}#if end
8801
											
8801
 
8802
										#如果 $conf["noWaveEnd"] 為 "true"
8802
										#如果 $conf["noWaveEnd"] 為 "true"
8803
										if($conf["noWaveEnd"]==="true"){
8803
										if($conf["noWaveEnd"]==="true"){
8804
											
8804
 
8805
											#看該符合的名稱結尾是否包含「~」
8805
											#看該符合的名稱結尾是否包含「~」
8806
											#函式說明:
8806
											#函式說明:
8807
											#取得符合特定字首與字尾的字串
8807
											#取得符合特定字首與字尾的字串
8808
											#回傳結果:
8808
											#回傳結果:
8809
											#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
8809
											#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 8821... Line 8821...
8821
											$conf["search::getMeetConditionsString"]["tailWord"]="~";
8821
											$conf["search::getMeetConditionsString"]["tailWord"]="~";
8822
											#參考資料:
8822
											#參考資料:
8823
											#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
8823
											#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
8824
											$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
8824
											$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
8825
											unset($conf["search::getMeetConditionsString"]);
8825
											unset($conf["search::getMeetConditionsString"]);
8826
											
8826
 
8827
											#如果 取得符合特定字首的字串 出錯
8827
											#如果 取得符合特定字首的字串 出錯
8828
											if($getMeetConditionsString["status"]=="false"){
8828
											if($getMeetConditionsString["status"]=="false"){
8829
												
8829
 
8830
												#設置執行錯誤識別
8830
												#設置執行錯誤識別
8831
												$result["status"]="false";
8831
												$result["status"]="false";
8832
												
8832
 
8833
												#設置錯誤訊息
8833
												#設置錯誤訊息
8834
												$result["error"]=$getMeetConditionsString;
8834
												$result["error"]=$getMeetConditionsString;
8835
												
8835
 
8836
												#回傳結果
8836
												#回傳結果
8837
												return $result;
8837
												return $result;
8838
												
8838
 
8839
												}#if end
8839
												}#if end
8840
												
8840
 
8841
											#如果有「~」在結尾
8841
											#如果有「~」在結尾
8842
											if($getMeetConditionsString["founded"]=="true"){
8842
											if($getMeetConditionsString["founded"]=="true"){
8843
												
8843
 
8844
												#忽略這個名稱
8844
												#忽略這個名稱
8845
												continue;
8845
												continue;
8846
												
8846
 
8847
												}#if end
8847
												}#if end
8848
											
8848
 
8849
											}#if end
8849
											}#if end
8850
										
8850
 
8851
										#暫存該符合的路徑
8851
										#暫存該符合的路徑
8852
										$tempExtendPath[]=$extendPath[$j]."/".$list[$k];
8852
										$tempExtendPath[]=$extendPath[$j]."/".$list[$k];
8853
										
8853
 
8854
										}#for end
8854
										}#for end
8855
									
8855
 
8856
									}#for end	
8856
									}#for end
8857
									
8857
 
8858
								#該次有幾個符合的路徑就執行幾次
8858
								#該次有幾個符合的路徑就執行幾次
8859
								foreach($tempExtendPath as $path){
8859
								foreach($tempExtendPath as $path){
8860
									
8860
 
8861
									#暫存符合的路徑
8861
									#暫存符合的路徑
8862
									$newExtendPath[]=$path;
8862
									$newExtendPath[]=$path;
8863
									
8863
 
8864
									}#for end	
8864
									}#for end
8865
								
8865
 
8866
								}#if end
8866
								}#if end
8867
								
8867
 
8868
							#反之該目錄底下沒有東西
8868
							#反之該目錄底下沒有東西
8869
							else{
8869
							else{
8870
								
8870
 
8871
								#移除該 $extendPath[$i]
8871
								#移除該 $extendPath[$i]
8872
								unset($extendPath[$i]);
8872
								unset($extendPath[$i]);
8873
								
8873
 
8874
								}#else end					
8874
								}#else end
8875
							
8875
 
8876
							}#for end
8876
							}#for end
8877
						
8877
 
8878
						#置換原始符合條件字串的路徑字串陣列
8878
						#置換原始符合條件字串的路徑字串陣列
8879
						$extendPath=$newExtendPath;
8879
						$extendPath=$newExtendPath;
8880
						
8880
 
8881
						}#if end
8881
						}#if end
8882
						
8882
 
8883
						#反之用「*」分割後有分段
8883
						#反之用「*」分割後有分段
8884
						else{
8884
						else{
8885
							
8885
 
8886
							#初始化暫存符合條件的新路徑陣列變數
8886
							#初始化暫存符合條件的新路徑陣列變數
8887
							$newExtendPath=array();
8887
							$newExtendPath=array();
8888
							
8888
 
8889
							#當前有幾個符合條件的路徑就執行幾次
8889
							#當前有幾個符合條件的路徑就執行幾次
8890
							for($i=0;$i<count($extendPath);$i++){
8890
							for($i=0;$i<count($extendPath);$i++){
8891
								
8891
 
8892
								#取得該目錄下所有的東西
8892
								#取得該目錄下所有的東西
8893
								#函式說明:
8893
								#函式說明:
8894
								#取得目錄底下所有目錄與檔案清單.
8894
								#取得目錄底下所有目錄與檔案清單.
8895
								#回傳結果:
8895
								#回傳結果:
8896
								#$result["status"],"true"爲建立成功,"false"爲建立失敗.
8896
								#$result["status"],"true"爲建立成功,"false"爲建立失敗.
Line 8910... Line 8910...
8910
								#無
8910
								#無
8911
								#參考資料來源:
8911
								#參考資料來源:
8912
								#opendir=>http://php.net/manual/en/function.opendir.php
8912
								#opendir=>http://php.net/manual/en/function.opendir.php
8913
								#is_dir=>http://php.net/manual/en/function.is-dir.php
8913
								#is_dir=>http://php.net/manual/en/function.is-dir.php
8914
								$getList=fileAccess::getList($conf["fileAccess::getList"]);
8914
								$getList=fileAccess::getList($conf["fileAccess::getList"]);
8915
								unset($conf["fileAccess::getList"]);										
8915
								unset($conf["fileAccess::getList"]);
8916
								
8916
 
8917
								#如果取得目標目錄底下的檔案目錄清單失敗
8917
								#如果取得目標目錄底下的檔案目錄清單失敗
8918
								if($getList["status"]=="false"){
8918
								if($getList["status"]=="false"){
8919
									
8919
 
8920
									#設置錯誤識別
8920
									#設置錯誤識別
8921
									$result["status"]="false";
8921
									$result["status"]="false";
8922
									
8922
 
8923
									#設置錯誤訊息
8923
									#設置錯誤訊息
8924
									$result["error"]=$getList;																				
8924
									$result["error"]=$getList;
8925
									
8925
 
8926
									#回傳結果
8926
									#回傳結果
8927
									return $result;
8927
									return $result;
8928
									
8928
 
8929
									}#if end
8929
									}#if end
8930
								
8930
 
8931
								#如果底下有東西
8931
								#如果底下有東西
8932
								if(count($getList["content"])>0){
8932
								if(count($getList["content"])>0){
8933
									
8933
 
8934
									#初始化儲存要檢查的檔案或資料夾名稱陣列
8934
									#初始化儲存要檢查的檔案或資料夾名稱陣列
8935
									$list=array();
8935
									$list=array();
8936
									
8936
 
8937
									#針對每個檔案或資料夾
8937
									#針對每個檔案或資料夾
8938
									foreach($getList["content"] as $num=>$array){
8938
									foreach($getList["content"] as $num=>$array){
8939
										
8939
 
8940
										#儲存該名稱
8940
										#儲存該名稱
8941
										$list[]=$array["name"];
8941
										$list[]=$array["name"];
8942
										
8942
 
8943
										}#foreach end
8943
										}#foreach end
8944
									
8944
 
8945
									#初始化儲存符合的名稱
8945
									#初始化儲存符合的名稱
8946
									$passedName=array();
8946
									$passedName=array();
8947
									
8947
 
8948
									#依據每個檔案目錄名稱,檢查有無符合篩選條件
8948
									#依據每個檔案目錄名稱,檢查有無符合篩選條件
8949
									foreach($list as $filteredName){
8949
									foreach($list as $filteredName){
8950
										
8950
 
8951
										#初始化儲存被檢查的片段檔案資料夾名稱
8951
										#初始化儲存被檢查的片段檔案資料夾名稱
8952
										$partName=$filteredName;
8952
										$partName=$filteredName;
8953
										
8953
 
8954
										#依據 $pathPart 分割成幾段(關鍵字數量)就執行幾次
8954
										#依據 $pathPart 分割成幾段(關鍵字數量)就執行幾次
8955
										for($i=0;$i<$spiltString["dataCounts"];$i++){
8955
										for($i=0;$i<$spiltString["dataCounts"];$i++){
8956
											
8956
 
8957
											#尋找關鍵字 $spiltString["dataArray"][$i]
8957
											#尋找關鍵字 $spiltString["dataArray"][$i]
8958
											#函式說明:
8958
											#函式說明:
8959
											#檢查字串裡面有無指定的關鍵字
8959
											#檢查字串裡面有無指定的關鍵字
8960
											#回傳結果:
8960
											#回傳結果:
8961
											#$result["status"],"true"代表執行成功,"false"代表執行失敗。
8961
											#$result["status"],"true"代表執行成功,"false"代表執行失敗。
Line 8968... Line 8968...
8968
											$conf["search::findKeyWord"]["string"]=$partName;#要被搜尋的字串內容
8968
											$conf["search::findKeyWord"]["string"]=$partName;#要被搜尋的字串內容
8969
											#可省略參數:
8969
											#可省略參數:
8970
											#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
8970
											#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
8971
											$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
8971
											$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
8972
											unset($conf["search::findKeyWord"]);
8972
											unset($conf["search::findKeyWord"]);
8973
											
8973
 
8974
											#如果尋找關鍵字失敗
8974
											#如果尋找關鍵字失敗
8975
											if($findKeyWord["status"]=="false"){
8975
											if($findKeyWord["status"]=="false"){
8976
												
8976
 
8977
												#設置執行錯誤識別
8977
												#設置執行錯誤識別
8978
												$result["status"]="false";
8978
												$result["status"]="false";
8979
												
8979
 
8980
												#設置錯誤訊息
8980
												#設置錯誤訊息
8981
												$result["error"]=$findKeyWord;
8981
												$result["error"]=$findKeyWord;
8982
												
8982
 
8983
												#回傳結果
8983
												#回傳結果
8984
												return $result;
8984
												return $result;
8985
												
8985
 
8986
												}#if end
8986
												}#if end
8987
												
8987
 
8988
											#如果有找到關鍵字
8988
											#如果有找到關鍵字
8989
											if($findKeyWord["founded"]=="true"){
8989
											if($findKeyWord["founded"]=="true"){
8990
												
8990
 
8991
												#如果是最後一段要檢查的關鍵字
8991
												#如果是最後一段要檢查的關鍵字
8992
												if($i==$spiltString["dataCounts"]-1){
8992
												if($i==$spiltString["dataCounts"]-1){
8993
													
8993
 
8994
													#判斷該關鍵字是否在該未分割的 $pathPart(含有*字號的關鍵字字串) 的開頭
8994
													#判斷該關鍵字是否在該未分割的 $pathPart(含有*字號的關鍵字字串) 的開頭
8995
													#函式說明:
8995
													#函式說明:
8996
													#取得符合特定字首與字尾的字串
8996
													#取得符合特定字首與字尾的字串
8997
													#回傳結果:
8997
													#回傳結果:
8998
													#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
8998
													#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 9010... Line 9010...
9010
													#$conf["tailWord"]="";
9010
													#$conf["tailWord"]="";
9011
													#參考資料:
9011
													#參考資料:
9012
													#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9012
													#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9013
													$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9013
													$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9014
													unset($conf["search::getMeetConditionsString"]);
9014
													unset($conf["search::getMeetConditionsString"]);
9015
													
9015
 
9016
													#如果 取得符合特定字首的字串 出錯
9016
													#如果 取得符合特定字首的字串 出錯
9017
													if($getMeetConditionsString["status"]=="false"){
9017
													if($getMeetConditionsString["status"]=="false"){
9018
														
9018
 
9019
														#設置執行錯誤識別
9019
														#設置執行錯誤識別
9020
														$result["status"]="false";
9020
														$result["status"]="false";
9021
														
9021
 
9022
														#設置錯誤訊息
9022
														#設置錯誤訊息
9023
														$result["error"]=$getMeetConditionsString;
9023
														$result["error"]=$getMeetConditionsString;
9024
														
9024
 
9025
														#回傳結果
9025
														#回傳結果
9026
														return $result;
9026
														return $result;
9027
														
9027
 
9028
														}#if end
9028
														}#if end
9029
														
9029
 
9030
													#如果關鍵字是在開頭
9030
													#如果關鍵字是在開頭
9031
													if($getMeetConditionsString["founded"]=="true"){
9031
													if($getMeetConditionsString["founded"]=="true"){
9032
														
9032
 
9033
														#判斷關鍵字是否在該檔案目錄名稱的開頭
9033
														#判斷關鍵字是否在該檔案目錄名稱的開頭
9034
														#函式說明:
9034
														#函式說明:
9035
														#取得符合特定字首與字尾的字串
9035
														#取得符合特定字首與字尾的字串
9036
														#回傳結果:
9036
														#回傳結果:
9037
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
9037
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 9049... Line 9049...
9049
														#$conf["tailWord"]="";
9049
														#$conf["tailWord"]="";
9050
														#參考資料:
9050
														#參考資料:
9051
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9051
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9052
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9052
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9053
														unset($conf["search::getMeetConditionsString"]);
9053
														unset($conf["search::getMeetConditionsString"]);
9054
														
9054
 
9055
														#如果 取得符合特定字首的字串 出錯
9055
														#如果 取得符合特定字首的字串 出錯
9056
														if($getMeetConditionsString["status"]=="false"){
9056
														if($getMeetConditionsString["status"]=="false"){
9057
															
9057
 
9058
															#設置執行錯誤識別
9058
															#設置執行錯誤識別
9059
															$result["status"]="false";
9059
															$result["status"]="false";
9060
															
9060
 
9061
															#設置錯誤訊息
9061
															#設置錯誤訊息
9062
															$result["error"]=$getMeetConditionsString;
9062
															$result["error"]=$getMeetConditionsString;
9063
															
9063
 
9064
															#回傳結果
9064
															#回傳結果
9065
															return $result;
9065
															return $result;
9066
															
9066
 
9067
															}#if end
9067
															}#if end
9068
														
9068
 
9069
														#如果關鍵字不在開頭
9069
														#如果關鍵字不在開頭
9070
														if($getMeetConditionsString["founded"]=="false"){
9070
														if($getMeetConditionsString["founded"]=="false"){
9071
															
9071
 
9072
															#不符合條件,跳過該檔案目錄名稱
9072
															#不符合條件,跳過該檔案目錄名稱
9073
															break;
9073
															break;
9074
															
9074
 
9075
															}#if end
9075
															}#if end
9076
														
9076
 
9077
														}#if end
9077
														}#if end
9078
													
9078
 
9079
													#判斷最後一個關鍵字是否在該未分割的 $pathPart(含有*字號的關鍵字字串) 的結尾
9079
													#判斷最後一個關鍵字是否在該未分割的 $pathPart(含有*字號的關鍵字字串) 的結尾
9080
													#函式說明:
9080
													#函式說明:
9081
													#取得符合特定字首與字尾的字串
9081
													#取得符合特定字首與字尾的字串
9082
													#回傳結果:
9082
													#回傳結果:
9083
													#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
9083
													#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 9095... Line 9095...
9095
													$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
9095
													$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
9096
													#參考資料:
9096
													#參考資料:
9097
													#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9097
													#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9098
													$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9098
													$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9099
													unset($conf["search::getMeetConditionsString"]);
9099
													unset($conf["search::getMeetConditionsString"]);
9100
													
9100
 
9101
													#如果 取得符合特定字尾的字串 出錯
9101
													#如果 取得符合特定字尾的字串 出錯
9102
													if($getMeetConditionsString["status"]=="false"){
9102
													if($getMeetConditionsString["status"]=="false"){
9103
														
9103
 
9104
														#設置執行錯誤識別
9104
														#設置執行錯誤識別
9105
														$result["status"]="false";
9105
														$result["status"]="false";
9106
														
9106
 
9107
														#設置錯誤訊息
9107
														#設置錯誤訊息
9108
														$result["error"]=$getMeetConditionsString;
9108
														$result["error"]=$getMeetConditionsString;
9109
														
9109
 
9110
														#回傳結果
9110
														#回傳結果
9111
														return $result;
9111
														return $result;
9112
														
9112
 
9113
														}#if end
9113
														}#if end
9114
														
9114
 
9115
													#如果關鍵字是在字尾
9115
													#如果關鍵字是在字尾
9116
													if($getMeetConditionsString["founded"]=="true"){
9116
													if($getMeetConditionsString["founded"]=="true"){
9117
														
9117
 
9118
														#判斷關鍵字是否在該片段的開頭
9118
														#判斷關鍵字是否在該片段的開頭
9119
														#函式說明:
9119
														#函式說明:
9120
														#取得符合特定字首與字尾的字串
9120
														#取得符合特定字首與字尾的字串
9121
														#回傳結果:
9121
														#回傳結果:
9122
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
9122
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 9134... Line 9134...
9134
														$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
9134
														$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
9135
														#參考資料:
9135
														#參考資料:
9136
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9136
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9137
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9137
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9138
														unset($conf["search::getMeetConditionsString"]);
9138
														unset($conf["search::getMeetConditionsString"]);
9139
														
9139
 
9140
														#如果 取得符合特定字首的字串 出錯
9140
														#如果 取得符合特定字首的字串 出錯
9141
														if($getMeetConditionsString["status"]=="false"){
9141
														if($getMeetConditionsString["status"]=="false"){
9142
															
9142
 
9143
															#設置執行錯誤識別
9143
															#設置執行錯誤識別
9144
															$result["status"]="false";
9144
															$result["status"]="false";
9145
															
9145
 
9146
															#設置錯誤訊息
9146
															#設置錯誤訊息
9147
															$result["error"]=$getMeetConditionsString;
9147
															$result["error"]=$getMeetConditionsString;
9148
															
9148
 
9149
															#回傳結果
9149
															#回傳結果
9150
															return $result;
9150
															return $result;
9151
															
9151
 
9152
															}#if end
9152
															}#if end
9153
														
9153
 
9154
														#如果關鍵字不在結尾
9154
														#如果關鍵字不在結尾
9155
														if($getMeetConditionsString["founded"]=="false"){
9155
														if($getMeetConditionsString["founded"]=="false"){
9156
															
9156
 
9157
															#不符合條件,跳過該檔案目錄名稱
9157
															#不符合條件,跳過該檔案目錄名稱
9158
															break;
9158
															break;
9159
															
9159
 
9160
															}#if end
9160
															}#if end
9161
														
9161
 
9162
														}#if end
9162
														}#if end
9163
													
9163
 
9164
													#如果 $conf["noDotStart"] 為 "true"
9164
													#如果 $conf["noDotStart"] 為 "true"
9165
													if($conf["noDotStart"]==="true"){
9165
													if($conf["noDotStart"]==="true"){
9166
														
9166
 
9167
														#看該符合的名稱開頭是否包含「.」
9167
														#看該符合的名稱開頭是否包含「.」
9168
														#函式說明:
9168
														#函式說明:
9169
														#取得符合特定字首與字尾的字串
9169
														#取得符合特定字首與字尾的字串
9170
														#回傳結果:
9170
														#回傳結果:
9171
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
9171
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 9183... Line 9183...
9183
														#$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
9183
														#$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
9184
														#參考資料:
9184
														#參考資料:
9185
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9185
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9186
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9186
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9187
														unset($conf["search::getMeetConditionsString"]);
9187
														unset($conf["search::getMeetConditionsString"]);
9188
														
9188
 
9189
														#如果 取得符合特定字首的字串 出錯
9189
														#如果 取得符合特定字首的字串 出錯
9190
														if($getMeetConditionsString["status"]=="false"){
9190
														if($getMeetConditionsString["status"]=="false"){
9191
															
9191
 
9192
															#設置執行錯誤識別
9192
															#設置執行錯誤識別
9193
															$result["status"]="false";
9193
															$result["status"]="false";
9194
															
9194
 
9195
															#設置錯誤訊息
9195
															#設置錯誤訊息
9196
															$result["error"]=$getMeetConditionsString;
9196
															$result["error"]=$getMeetConditionsString;
9197
															
9197
 
9198
															#回傳結果
9198
															#回傳結果
9199
															return $result;
9199
															return $result;
9200
															
9200
 
9201
															}#if end
9201
															}#if end
9202
															
9202
 
9203
														#如果有「.」在開頭
9203
														#如果有「.」在開頭
9204
														if($getMeetConditionsString["founded"]=="true"){
9204
														if($getMeetConditionsString["founded"]=="true"){
9205
															
9205
 
9206
															#中斷迴圈
9206
															#中斷迴圈
9207
															break;
9207
															break;
9208
															
9208
 
9209
															}#if end
9209
															}#if end
9210
														
9210
 
9211
														}#if end
9211
														}#if end
9212
														
9212
 
9213
													#如果 $conf["noWaveEnd"] 為 "true"
9213
													#如果 $conf["noWaveEnd"] 為 "true"
9214
													if($conf["noWaveEnd"]==="true"){
9214
													if($conf["noWaveEnd"]==="true"){
9215
														
9215
 
9216
														#看該符合的名稱結尾是否包含「~」
9216
														#看該符合的名稱結尾是否包含「~」
9217
														#函式說明:
9217
														#函式說明:
9218
														#取得符合特定字首與字尾的字串
9218
														#取得符合特定字首與字尾的字串
9219
														#回傳結果:
9219
														#回傳結果:
9220
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
9220
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 9232... Line 9232...
9232
														$conf["search::getMeetConditionsString"]["tailWord"]="~";
9232
														$conf["search::getMeetConditionsString"]["tailWord"]="~";
9233
														#參考資料:
9233
														#參考資料:
9234
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9234
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9235
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9235
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9236
														unset($conf["search::getMeetConditionsString"]);
9236
														unset($conf["search::getMeetConditionsString"]);
9237
														
9237
 
9238
														#如果 取得符合特定字首的字串 出錯
9238
														#如果 取得符合特定字首的字串 出錯
9239
														if($getMeetConditionsString["status"]=="false"){
9239
														if($getMeetConditionsString["status"]=="false"){
9240
															
9240
 
9241
															#設置執行錯誤識別
9241
															#設置執行錯誤識別
9242
															$result["status"]="false";
9242
															$result["status"]="false";
9243
															
9243
 
9244
															#設置錯誤訊息
9244
															#設置錯誤訊息
9245
															$result["error"]=$getMeetConditionsString;
9245
															$result["error"]=$getMeetConditionsString;
9246
															
9246
 
9247
															#回傳結果
9247
															#回傳結果
9248
															return $result;
9248
															return $result;
9249
															
9249
 
9250
															}#if end
9250
															}#if end
9251
															
9251
 
9252
														#如果有「~」在結尾
9252
														#如果有「~」在結尾
9253
														if($getMeetConditionsString["founded"]=="true"){
9253
														if($getMeetConditionsString["founded"]=="true"){
9254
															
9254
 
9255
															#中斷迴圈
9255
															#中斷迴圈
9256
															break;
9256
															break;
9257
															
9257
 
9258
															}#if end
9258
															}#if end
9259
														
9259
 
9260
														}#if end
9260
														}#if end
9261
													
9261
 
9262
													#取得該符合的名稱
9262
													#取得該符合的名稱
9263
													$passedName[]=$filteredName;
9263
													$passedName[]=$filteredName;
9264
													
9264
 
9265
													#中斷迴圈
9265
													#中斷迴圈
9266
													break;
9266
													break;
9267
													
9267
 
9268
													}#if end
9268
													}#if end
9269
												
9269
 
9270
												#將 $partName 從左到關鍵字結束的部份剔除
9270
												#將 $partName 從左到關鍵字結束的部份剔除
9271
												#函式說明:
9271
												#函式說明:
9272
												#將特定字串前面的內容剔除
9272
												#將特定字串前面的內容剔除
9273
												#回傳結果:
9273
												#回傳結果:
9274
												#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9274
												#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 9280... Line 9280...
9280
												#必填參數:
9280
												#必填參數:
9281
												$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$partName;#要處理的字串.
9281
												$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$partName;#要處理的字串.
9282
												$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$spiltString["dataArray"][$i];#特定字串.
9282
												$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$spiltString["dataArray"][$i];#特定字串.
9283
												$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
9283
												$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
9284
												unset($conf["stringProcess::delStrBeforeKeyWord"]);
9284
												unset($conf["stringProcess::delStrBeforeKeyWord"]);
9285
												
9285
 
9286
												#如果將 $partName 從左到關鍵字結束的部份剔除失敗
9286
												#如果將 $partName 從左到關鍵字結束的部份剔除失敗
9287
												if($delStrBeforeKeyWord["status"]=="false"){
9287
												if($delStrBeforeKeyWord["status"]=="false"){
9288
													
9288
 
9289
													#設置執行錯誤識別
9289
													#設置執行錯誤識別
9290
													$result["status"]="false";
9290
													$result["status"]="false";
9291
													
9291
 
9292
													#設置錯誤訊息
9292
													#設置錯誤訊息
9293
													$result["error"]=$delStrBeforeKeyWord;
9293
													$result["error"]=$delStrBeforeKeyWord;
9294
													
9294
 
9295
													#回傳結果
9295
													#回傳結果
9296
													return $result;
9296
													return $result;
9297
													
9297
 
9298
													}#if end
9298
													}#if end
9299
													
9299
 
9300
												#如果沒有找到特定關鍵字字串
9300
												#如果沒有找到特定關鍵字字串
9301
												if($delStrBeforeKeyWord["founded"]=="false"){
9301
												if($delStrBeforeKeyWord["founded"]=="false"){
9302
													
9302
 
9303
													#設置執行錯誤識別
9303
													#設置執行錯誤識別
9304
													$result["status"]="false";
9304
													$result["status"]="false";
9305
													
9305
 
9306
													#設置錯誤訊息
9306
													#設置錯誤訊息
9307
													$result["error"]=$delStrBeforeKeyWord;
9307
													$result["error"]=$delStrBeforeKeyWord;
9308
													
9308
 
9309
													#回傳結果
9309
													#回傳結果
9310
													return $result;
9310
													return $result;
9311
													
9311
 
9312
													}#if end
9312
													}#if end
9313
													
9313
 
9314
												#取得剔除過關鍵字前字串的字串	
9314
												#取得剔除過關鍵字前字串的字串
9315
												$partName=$delStrBeforeKeyWord["content"];
9315
												$partName=$delStrBeforeKeyWord["content"];
9316
												
9316
 
9317
												}#if end
9317
												}#if end
9318
											
9318
 
9319
											#反之關鍵字不存在	
9319
											#反之關鍵字不存在
9320
											else{
9320
											else{
9321
												
9321
 
9322
												#儲存被拋棄的片段
9322
												#儲存被拋棄的片段
9323
												#$result["dismissLog"][]="片段「".$partName."」沒有關鍵字「".$spiltString["dataArray"][$i]."」";
9323
												#$result["dismissLog"][]="片段「".$partName."」沒有關鍵字「".$spiltString["dataArray"][$i]."」";
9324
												
9324
 
9325
												#該名稱不符合條件
9325
												#該名稱不符合條件
9326
												break;
9326
												break;
9327
												
9327
 
9328
												}#else end
9328
												}#else end
9329
											
9329
 
9330
											}#for end
9330
											}#for end
9331
										
9331
 
9332
										}#foreach end
9332
										}#foreach end
9333
									
9333
 
9334
									#初始化儲存符合的暫存路徑
9334
									#初始化儲存符合的暫存路徑
9335
									$tempExtendPath=array();
9335
									$tempExtendPath=array();
9336
																			
-
 
-
 
9336
 
9337
									#針對每個現有的路徑字串
9337
									#針對每個現有的路徑字串
9338
									for($j=0;$j<count($extendPath);$j++){
9338
									for($j=0;$j<count($extendPath);$j++){
9339
										
9339
 
9340
										#附加每個符合條件的名稱到路徑字串裡面
9340
										#附加每個符合條件的名稱到路徑字串裡面
9341
										for($k=0;$k<count($passedName);$k++){
9341
										for($k=0;$k<count($passedName);$k++){
9342
											
9342
 
9343
											#暫存該符合的路徑
9343
											#暫存該符合的路徑
9344
											$tempExtendPath[]=$extendPath[$j]."/".$passedName[$k];
9344
											$tempExtendPath[]=$extendPath[$j]."/".$passedName[$k];
9345
											
9345
 
9346
											}#for end
9346
											}#for end
9347
										
9347
 
9348
										}#for end	
9348
										}#for end
9349
										
9349
 
9350
									#該次有幾個符合的路徑就執行幾次
9350
									#該次有幾個符合的路徑就執行幾次
9351
									foreach($tempExtendPath as $path){
9351
									foreach($tempExtendPath as $path){
9352
										
9352
 
9353
										#暫存符合的路徑
9353
										#暫存符合的路徑
9354
										$newExtendPath[]=$path;
9354
										$newExtendPath[]=$path;
9355
										
9355
 
9356
										}#foreach end	
9356
										}#foreach end
9357
									
9357
 
9358
									}#if end
9358
									}#if end
9359
									
9359
 
9360
								#反之該目錄底下沒有東西
9360
								#反之該目錄底下沒有東西
9361
								else{
9361
								else{
9362
									
9362
 
9363
									#移除該 $extendPath[$i]
9363
									#移除該 $extendPath[$i]
9364
									unset($extendPath[$i]);
9364
									unset($extendPath[$i]);
9365
									
9365
 
9366
									}#else end					
9366
									}#else end
9367
								
9367
 
9368
								}#for end
9368
								}#for end
9369
															
9369
 
9370
							#如果有新的路徑產生
9370
							#如果有新的路徑產生
9371
							if(count($newExtendPath)>0){
9371
							if(count($newExtendPath)>0){
9372
								
9372
 
9373
								#置換原始符合條件字串的路徑字串陣列
9373
								#置換原始符合條件字串的路徑字串陣列
9374
								$extendPath=$newExtendPath;
9374
								$extendPath=$newExtendPath;
9375
								
9375
 
9376
								}#if end
9376
								}#if end
9377
								
9377
 
9378
							#反之找不到後續符合的路徑
9378
							#反之找不到後續符合的路徑
9379
							else{
9379
							else{
9380
								
9380
 
9381
								$extendPath=array();
9381
								$extendPath=array();
9382
								
9382
 
9383
								}#else end
9383
								}#else end
9384
													
9384
 
9385
							}#else end
9385
							}#else end
9386
												
9386
 
9387
					}#else end
9387
					}#else end
9388
				
9388
 
9389
				}#foreach end
9389
				}#foreach end
9390
			
9390
 
9391
			}#if end
9391
			}#if end
9392
		
9392
 
9393
		#反之沒有含有「*」
9393
		#反之沒有含有「*」
9394
		else{
9394
		else{
9395
			
9395
 
9396
			#判斷 $conf["path"] 是否存在
9396
			#判斷 $conf["path"] 是否存在
9397
			#函式說明:
9397
			#函式說明:
9398
			#檢查多個檔案與資料夾是否存在.
9398
			#檢查多個檔案與資料夾是否存在.
9399
			#回傳的結果:
9399
			#回傳的結果:
9400
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
9400
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 9419... Line 9419...
9419
			#http://php.net/manual/en/control-structures.foreach.php
9419
			#http://php.net/manual/en/control-structures.foreach.php
9420
			#備註:
9420
			#備註:
9421
			#函數file_exists檢查的路徑為檔案系統的路徑
9421
			#函數file_exists檢查的路徑為檔案系統的路徑
9422
			$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
9422
			$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
9423
			unset($conf["fileAccess::checkMultiFileExist"]);
9423
			unset($conf["fileAccess::checkMultiFileExist"]);
9424
			
9424
 
9425
			#如果檢查失敗
9425
			#如果檢查失敗
9426
			if($checkMultiFileExist["status"]=="false"){
9426
			if($checkMultiFileExist["status"]=="false"){
9427
				
9427
 
9428
				#設置錯誤識別
9428
				#設置錯誤識別
9429
				$result["status"]="false";
9429
				$result["status"]="false";
9430
				
9430
 
9431
				#設置錯誤訊息
9431
				#設置錯誤訊息
9432
				$result["error"]=$checkMultiFileExist;
9432
				$result["error"]=$checkMultiFileExist;
9433
				
9433
 
9434
				#回傳結果
9434
				#回傳結果
9435
				return $result;
9435
				return $result;
9436
				
9436
 
9437
				}#if end
9437
				}#if end
9438
			
9438
 
9439
			#如果存在
9439
			#如果存在
9440
			if($checkMultiFileExist["varExist"][0]=="true"){
9440
			if($checkMultiFileExist["varExist"][0]=="true"){
9441
				
9441
 
9442
				#初始化暫存展開後的檔案路徑字串
9442
				#初始化暫存展開後的檔案路徑字串
9443
				$extendPath=array($conf["path"]);
9443
				$extendPath=array($conf["path"]);
9444
				
9444
 
9445
				}#if end
9445
				}#if end
9446
			
9446
 
9447
			#反之不存在
9447
			#反之不存在
9448
			else{
9448
			else{
9449
				
9449
 
9450
				#置換符合的路徑為空字串
9450
				#置換符合的路徑為空字串
9451
				$extendPath=array();
9451
				$extendPath=array();
9452
				
9452
 
9453
				}#else end
9453
				}#else end
9454
			
9454
 
9455
			#初始化暫存展開後的檔案路徑字串
9455
			#初始化暫存展開後的檔案路徑字串
9456
			$extendPath=array($conf["path"]);
9456
			$extendPath=array($conf["path"]);
9457
							
9457
 
9458
			}#else end
9458
			}#else end
9459
			
9459
 
9460
		#取得解析完「*」的檔案路徑字串
9460
		#取得解析完「*」的檔案路徑字串
9461
		$result["content"]=$extendPath;
9461
		$result["content"]=$extendPath;
9462
									
9462
 
9463
		#取得有幾個檔案路徑
9463
		#取得有幾個檔案路徑
9464
		$result["pathCount"]=count($result["content"]);
9464
		$result["pathCount"]=count($result["content"]);
9465
							
9465
 
9466
		#設置執行正常
9466
		#設置執行正常
9467
		$result["status"]="true";
9467
		$result["status"]="true";
9468
		
9468
 
9469
		#回傳結果
9469
		#回傳結果
9470
		return $result;
9470
		return $result;
9471
		
9471
 
9472
		}#function resolvePostionStringWhichContainStarSymbol end
9472
		}#function resolvePostionStringWhichContainStarSymbol end
9473
 
9473
 
9474
	/*
9474
	/*
9475
	#函式說明:
9475
	#函式說明:
9476
	#將含有「*」的多個檔案路徑名稱,變成多個符合條件的路徑檔案.
9476
	#將含有「*」的多個檔案路徑名稱,變成多個符合條件的路徑檔案.
9477
	#回傳結果:
9477
	#回傳結果:
9478
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
9478
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
9479
	#$result["error"],錯誤訊息陣列.
9479
	#$result["error"],錯誤訊息陣列.
9480
	#$result["function"],函數名稱. 
9480
	#$result["function"],函數名稱.
9481
	#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
9481
	#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
9482
	#$result["pathCount"],整數,有幾個路徑.
9482
	#$result["pathCount"],整數,有幾個路徑.
9483
	#必填參數:
9483
	#必填參數:
9484
	#$conf["path"],字串陣列,要解析含有「*」的檔案路徑字串.
9484
	#$conf["path"],字串陣列,要解析含有「*」的檔案路徑字串.
9485
	$conf["path"]=array();
9485
	$conf["path"]=array();
Line 9494... Line 9494...
9494
	#無.
9494
	#無.
9495
	#備註:
9495
	#備註:
9496
	#無.
9496
	#無.
9497
	*/
9497
	*/
9498
	public static function resolveMultiPostionStringWhichContainStarSymbol(&$conf){
9498
	public static function resolveMultiPostionStringWhichContainStarSymbol(&$conf){
9499
		
9499
 
9500
		#初始化要回傳的結果
9500
		#初始化要回傳的結果
9501
		$result=array();
9501
		$result=array();
9502
		
9502
 
9503
		#設置當其函數名稱
9503
		#設置當其函數名稱
9504
		$result["function"]=__FUNCTION__;
9504
		$result["function"]=__FUNCTION__;
9505
		
9505
 
9506
		#如果 $conf 不為陣列
9506
		#如果 $conf 不為陣列
9507
		if(gettype($conf)!="array"){
9507
		if(gettype($conf)!="array"){
9508
			
9508
 
9509
			#設置執行失敗
9509
			#設置執行失敗
9510
			$result["status"]="false";
9510
			$result["status"]="false";
9511
			
9511
 
9512
			#設置執行錯誤訊息
9512
			#設置執行錯誤訊息
9513
			$result["error"][]="\$conf變數須為陣列形態";
9513
			$result["error"][]="\$conf變數須為陣列形態";
9514
 
9514
 
9515
			#如果傳入的參數為 null
9515
			#如果傳入的參數為 null
9516
			if($conf==null){
9516
			if($conf==null){
9517
				
9517
 
9518
				#設置執行錯誤訊息
9518
				#設置執行錯誤訊息
9519
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
9519
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
9520
				
9520
 
9521
				}#if end
9521
				}#if end
9522
 
9522
 
9523
			#回傳結果
9523
			#回傳結果
9524
			return $result;
9524
			return $result;
9525
			
9525
 
9526
			}#if end
9526
			}#if end
9527
			
9527
 
9528
		#檢查參數
9528
		#檢查參數
9529
		#函式說明:
9529
		#函式說明:
9530
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
9530
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
9531
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9531
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9532
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
9532
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 9541... Line 9541...
9541
		#必填寫的參數:
9541
		#必填寫的參數:
9542
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
9542
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
9543
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
9543
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
9544
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
9544
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
9545
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
9545
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
9546
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
9546
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
9547
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");
9547
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");
9548
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
9548
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
9549
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
9549
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
9550
		#可以省略的參數:
9550
		#可以省略的參數:
9551
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
9551
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
9552
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
9552
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
9553
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
9553
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
9554
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("noDotStart","noWaveEnd");
9554
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("noDotStart","noWaveEnd");
9555
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
9555
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
9556
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
9556
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
9557
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
9557
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
9558
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","true");
9558
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","true");
9559
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
9559
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
9560
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
9560
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
9561
		#參考資料來源:
9561
		#參考資料來源:
9562
		#array_keys=>http://php.net/manual/en/function.array-keys.php
9562
		#array_keys=>http://php.net/manual/en/function.array-keys.php
9563
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
9563
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
9564
		unset($conf["variableCheck::checkArguments"]);
9564
		unset($conf["variableCheck::checkArguments"]);
9565
		
9565
 
9566
		#如果 $checkResult["status"] 等於 "fasle"
9566
		#如果 $checkResult["status"] 等於 "fasle"
9567
		if($checkResult["status"]=="false"){
9567
		if($checkResult["status"]=="false"){
9568
			
9568
 
9569
			#設置錯誤識別
9569
			#設置錯誤識別
9570
			$result["status"]="false";
9570
			$result["status"]="false";
9571
			
9571
 
9572
			#設置錯誤訊息
9572
			#設置錯誤訊息
9573
			$result["error"]=$checkResult;
9573
			$result["error"]=$checkResult;
9574
			
9574
 
9575
			#回傳結果
9575
			#回傳結果
9576
			return $result;
9576
			return $result;
9577
			
9577
 
9578
			}#if end
9578
			}#if end
9579
			
9579
 
9580
		#如果 $checkResult["passed"] 等於 "fasle"
9580
		#如果 $checkResult["passed"] 等於 "fasle"
9581
		if($checkResult["passed"]=="false"){
9581
		if($checkResult["passed"]=="false"){
9582
			
9582
 
9583
			#設置錯誤識別
9583
			#設置錯誤識別
9584
			$result["status"]="false";
9584
			$result["status"]="false";
9585
			
9585
 
9586
			#設置錯誤訊息
9586
			#設置錯誤訊息
9587
			$result["error"]=$checkResult;
9587
			$result["error"]=$checkResult;
9588
			
9588
 
9589
			#回傳結果
9589
			#回傳結果
9590
			return $result;
9590
			return $result;
9591
			
9591
 
9592
			}#if end
9592
			}#if end
9593
			
9593
 
9594
		#針對每個要解析的路徑字串
9594
		#針對每個要解析的路徑字串
9595
		foreach($conf["path"] as $path){
9595
		foreach($conf["path"] as $path){
9596
			
9596
 
9597
			#函式說明:
9597
			#函式說明:
9598
			#將含有「*」的檔案路徑名稱,變成多個符合條件的路徑檔案.
9598
			#將含有「*」的檔案路徑名稱,變成多個符合條件的路徑檔案.
9599
			#回傳結果:
9599
			#回傳結果:
9600
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
9600
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
9601
			#$result["error"],錯誤訊息陣列.
9601
			#$result["error"],錯誤訊息陣列.
9602
			#$result["function"],函數名稱. 
9602
			#$result["function"],函數名稱.
9603
			#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
9603
			#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
9604
			#必填參數:
9604
			#必填參數:
9605
			#$conf["path"],字串,要解析含有「*」的檔案路徑字串.
9605
			#$conf["path"],字串,要解析含有「*」的檔案路徑字串.
9606
			$conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]["path"]=$path;
9606
			$conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]["path"]=$path;
9607
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
9607
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
Line 9611... Line 9611...
9611
			$conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]["noDotStart"]=$conf["noDotStart"];
9611
			$conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]["noDotStart"]=$conf["noDotStart"];
9612
			#$conf["noWaveEnd"],字串,預設為"true"代表不包含「~」結尾的名稱,"false"代表包含結尾為「~」的名稱.
9612
			#$conf["noWaveEnd"],字串,預設為"true"代表不包含「~」結尾的名稱,"false"代表包含結尾為「~」的名稱.
9613
			$conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]["noWaveEnd"]=$conf["noWaveEnd"];
9613
			$conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]["noWaveEnd"]=$conf["noWaveEnd"];
9614
			$resolvePostionStringWhichContainStarSymbol=fileAccess::resolvePostionStringWhichContainStarSymbol($conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]);
9614
			$resolvePostionStringWhichContainStarSymbol=fileAccess::resolvePostionStringWhichContainStarSymbol($conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]);
9615
			unset($conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]);
9615
			unset($conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]);
9616
			
9616
 
9617
			#如果解析失敗
9617
			#如果解析失敗
9618
			if($resolvePostionStringWhichContainStarSymbol["status"]=="false"){
9618
			if($resolvePostionStringWhichContainStarSymbol["status"]=="false"){
9619
				
9619
 
9620
				#設置錯誤識別
9620
				#設置錯誤識別
9621
				$result["status"]="false";
9621
				$result["status"]="false";
9622
				
9622
 
9623
				#設置錯誤訊息
9623
				#設置錯誤訊息
9624
				$result["error"]=$resolvePostionStringWhichContainStarSymbol;
9624
				$result["error"]=$resolvePostionStringWhichContainStarSymbol;
9625
				
9625
 
9626
				#回傳結果
9626
				#回傳結果
9627
				return $result;
9627
				return $result;
9628
				
9628
 
9629
				}#if end
9629
				}#if end
9630
				
9630
 
9631
			#針對每個解析出來的路徑
9631
			#針對每個解析出來的路徑
9632
			foreach($resolvePostionStringWhichContainStarSymbol["content"] as $filteredPath){
9632
			foreach($resolvePostionStringWhichContainStarSymbol["content"] as $filteredPath){
9633
				
9633
 
9634
				#儲存符合條件的路徑
9634
				#儲存符合條件的路徑
9635
				$result["content"][]=$filteredPath;
9635
				$result["content"][]=$filteredPath;
9636
				
9636
 
9637
				}#foreach end
9637
				}#foreach end
9638
			
9638
 
9639
			}#foreach end
9639
			}#foreach end
9640
			
9640
 
9641
		#如果有路徑存在
9641
		#如果有路徑存在
9642
		if(isset($result["content"])){
9642
		if(isset($result["content"])){
9643
			
9643
 
9644
			#取得有幾個路徑
9644
			#取得有幾個路徑
9645
			$result["pathCount"]=count($result["content"]);
9645
			$result["pathCount"]=count($result["content"]);
9646
			
9646
 
9647
			}#if end
9647
			}#if end
9648
			
9648
 
9649
		#反之 
9649
		#反之
9650
		else{
9650
		else{
9651
			
9651
 
9652
			#設置空的路徑結果
9652
			#設置空的路徑結果
9653
			$result["content"]=array();
9653
			$result["content"]=array();
9654
			
9654
 
9655
			#取得有幾個路徑
9655
			#取得有幾個路徑
9656
			$result["pathCount"]=count($result["content"]);
9656
			$result["pathCount"]=count($result["content"]);
9657
			
9657
 
9658
			}#else end
9658
			}#else end
9659
			
9659
 
9660
		#設置執行正常
9660
		#設置執行正常
9661
		$result["status"]="true";
9661
		$result["status"]="true";
9662
		
9662
 
9663
		#回傳結果
9663
		#回傳結果
9664
		return $result;
9664
		return $result;
9665
		
9665
 
9666
		}#function resolveMultiPostionStringWhichContainStarSymbol end
9666
		}#function resolveMultiPostionStringWhichContainStarSymbol end
9667
 
9667
 
9668
	/*
9668
	/*
9669
	#函式說明:
9669
	#函式說明:
9670
	#將多個路徑字串變成相對於當前路徑的相對路徑字串
9670
	#將多個路徑字串變成相對於當前路徑的相對路徑字串
9671
	#回傳結果:
9671
	#回傳結果:
9672
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
9672
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
9673
	#$result["error"],錯誤訊息陣列.
9673
	#$result["error"],錯誤訊息陣列.
9674
	#$result["function"],函數名稱. 
9674
	#$result["function"],函數名稱.
9675
	#$result["argu"],使用的參數.
9675
	#$result["argu"],使用的參數.
9676
	#$result["content"],字串陣列,多個轉換好的相對路徑字串.
9676
	#$result["content"],字串陣列,多個轉換好的相對路徑字串.
9677
	#$result["cmd"],使用的指令.
9677
	#$result["cmd"],使用的指令.
9678
	#必填參數:
9678
	#必填參數:
9679
	#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
9679
	#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
Line 9687... Line 9687...
9687
	#無.
9687
	#無.
9688
	#備註:
9688
	#備註:
9689
	#無.
9689
	#無.
9690
	*/
9690
	*/
9691
	public static function getRelativePath(&$conf){
9691
	public static function getRelativePath(&$conf){
9692
		
9692
 
9693
		#初始化要回傳的結果
9693
		#初始化要回傳的結果
9694
		$result=array();
9694
		$result=array();
9695
		
9695
 
9696
		#設置當其函數名稱
9696
		#設置當其函數名稱
9697
		$result["function"]=__FUNCTION__;
9697
		$result["function"]=__FUNCTION__;
9698
		
9698
 
9699
		#如果 $conf 不為陣列
9699
		#如果 $conf 不為陣列
9700
		if(gettype($conf)!="array"){
9700
		if(gettype($conf)!="array"){
9701
			
9701
 
9702
			#設置執行失敗
9702
			#設置執行失敗
9703
			$result["status"]="false";
9703
			$result["status"]="false";
9704
			
9704
 
9705
			#設置執行錯誤訊息
9705
			#設置執行錯誤訊息
9706
			$result["error"][]="\$conf變數須為陣列形態";
9706
			$result["error"][]="\$conf變數須為陣列形態";
9707
 
9707
 
9708
			#如果傳入的參數為 null
9708
			#如果傳入的參數為 null
9709
			if($conf==null){
9709
			if($conf==null){
9710
				
9710
 
9711
				#設置執行錯誤訊息
9711
				#設置執行錯誤訊息
9712
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
9712
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
9713
				
9713
 
9714
				}#if end
9714
				}#if end
9715
 
9715
 
9716
			#回傳結果
9716
			#回傳結果
9717
			return $result;
9717
			return $result;
9718
			
9718
 
9719
			}#if end
9719
			}#if end
9720
			
9720
 
9721
		#檢查參數
9721
		#檢查參數
9722
		#函式說明:
9722
		#函式說明:
9723
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
9723
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
9724
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9724
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9725
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
9725
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 9734... Line 9734...
9734
		#必填寫的參數:
9734
		#必填寫的參數:
9735
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
9735
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
9736
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
9736
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
9737
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
9737
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
9738
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
9738
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
9739
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
9739
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
9740
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");
9740
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");
9741
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
9741
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
9742
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
9742
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
9743
		#可以省略的參數:
9743
		#可以省略的參數:
9744
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
9744
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
9745
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
9745
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
9746
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
9746
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
9747
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("baseFrom");
9747
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("baseFrom");
9748
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
9748
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
9749
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
9749
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
9750
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
9750
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
9751
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
9751
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
9752
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
9752
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
9753
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
9753
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
9754
		#參考資料來源:
9754
		#參考資料來源:
9755
		#array_keys=>http://php.net/manual/en/function.array-keys.php
9755
		#array_keys=>http://php.net/manual/en/function.array-keys.php
9756
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
9756
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
9757
		unset($conf["variableCheck::checkArguments"]);
9757
		unset($conf["variableCheck::checkArguments"]);
9758
		
9758
 
9759
		#如果 $checkResult["status"] 等於 "false"
9759
		#如果 $checkResult["status"] 等於 "false"
9760
		if($checkResult["status"]=="false"){
9760
		if($checkResult["status"]=="false"){
9761
			
9761
 
9762
			#設置錯誤識別
9762
			#設置錯誤識別
9763
			$result["status"]="false";
9763
			$result["status"]="false";
9764
			
9764
 
9765
			#設置錯誤訊息
9765
			#設置錯誤訊息
9766
			$result["error"]=$checkResult;
9766
			$result["error"]=$checkResult;
9767
			
9767
 
9768
			#回傳結果
9768
			#回傳結果
9769
			return $result;
9769
			return $result;
9770
			
9770
 
9771
			}#if end
9771
			}#if end
9772
			
9772
 
9773
		#如果 $checkResult["passed"] 等於 "fasle"
9773
		#如果 $checkResult["passed"] 等於 "fasle"
9774
		if($checkResult["passed"]=="false"){
9774
		if($checkResult["passed"]=="false"){
9775
			
9775
 
9776
			#設置錯誤識別
9776
			#設置錯誤識別
9777
			$result["status"]="false";
9777
			$result["status"]="false";
9778
			
9778
 
9779
			#設置錯誤訊息
9779
			#設置錯誤訊息
9780
			$result["error"]=$checkResult;
9780
			$result["error"]=$checkResult;
9781
			
9781
 
9782
			#回傳結果
9782
			#回傳結果
9783
			return $result;
9783
			return $result;
9784
			
9784
 
9785
			}#if end
9785
			}#if end
9786
		
9786
 
9787
		#取得參數
9787
		#取得參數
9788
		$result["argu"]=$conf;
9788
		$result["argu"]=$conf;
9789
		
9789
 
9790
		#函式說明:
9790
		#函式說明:
9791
		#將固定格式的字串分開,並回傳分開的結果.
9791
		#將固定格式的字串分開,並回傳分開的結果.
9792
		#回傳結果:
9792
		#回傳結果:
9793
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9793
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9794
		#$result["error"],錯誤訊息陣列
9794
		#$result["error"],錯誤訊息陣列
Line 9810... Line 9810...
9810
		#無.
9810
		#無.
9811
		#備註:
9811
		#備註:
9812
		#無.
9812
		#無.
9813
		$spiltString=stringProcess::spiltString($conf["fileAccess::spiltString"]);
9813
		$spiltString=stringProcess::spiltString($conf["fileAccess::spiltString"]);
9814
		unset($conf["fileAccess::spiltString"]);
9814
		unset($conf["fileAccess::spiltString"]);
9815
	
9815
 
9816
		#如果執行失敗
9816
		#如果執行失敗
9817
		if($spiltString["status"]==="false"){
9817
		if($spiltString["status"]==="false"){
9818
		
9818
 
9819
			#設置錯誤識別
9819
			#設置錯誤識別
9820
			$result["status"]="false";
9820
			$result["status"]="false";
9821
			
9821
 
9822
			#設置錯誤訊息
9822
			#設置錯誤訊息
9823
			$result["error"]=$spiltString;
9823
			$result["error"]=$spiltString;
9824
			
9824
 
9825
			#回傳結果
9825
			#回傳結果
9826
			return $result;
9826
			return $result;
9827
		
9827
 
9828
			}#if end
9828
			}#if end
9829
			
9829
 
9830
		#如果沒有關鍵字
9830
		#如果沒有關鍵字
9831
		if($spiltString["found"]==="false"){
9831
		if($spiltString["found"]==="false"){
9832
		
9832
 
9833
			#設置錯誤識別
9833
			#設置錯誤識別
9834
			$result["status"]="false";
9834
			$result["status"]="false";
9835
			
9835
 
9836
			#設置錯誤訊息
9836
			#設置錯誤訊息
9837
			$result["error"]=$spiltString;
9837
			$result["error"]=$spiltString;
9838
			
9838
 
9839
			#回傳結果
9839
			#回傳結果
9840
			return $result;
9840
			return $result;
9841
		
9841
 
9842
			}#if end
9842
			}#if end
9843
	
9843
 
9844
		#取得 $conf["fileArgu"] 的路徑
9844
		#取得 $conf["fileArgu"] 的路徑
9845
		#函式說明:
9845
		#函式說明:
9846
		#將固定格式的字串分開,並回傳分開的結果.
9846
		#將固定格式的字串分開,並回傳分開的結果.
9847
		#回傳結果:
9847
		#回傳結果:
9848
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9848
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 9865... Line 9865...
9865
		#無.
9865
		#無.
9866
		#備註:
9866
		#備註:
9867
		#無.
9867
		#無.
9868
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
9868
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
9869
		unset($conf["stringProcess::spiltString"]);
9869
		unset($conf["stringProcess::spiltString"]);
9870
	
9870
 
9871
		#如果執行失敗
9871
		#如果執行失敗
9872
		if($spiltString["status"]==="false"){
9872
		if($spiltString["status"]==="false"){
9873
			
9873
 
9874
			#設置錯誤識別
9874
			#設置錯誤識別
9875
			$result["status"]="false";
9875
			$result["status"]="false";
9876
			
9876
 
9877
			#設置錯誤訊息
9877
			#設置錯誤訊息
9878
			$result["error"]=$spiltString;
9878
			$result["error"]=$spiltString;
9879
			
9879
 
9880
			#回傳結果
9880
			#回傳結果
9881
			return $result;
9881
			return $result;
9882
			
9882
 
9883
			}#if end
9883
			}#if end
9884
		
9884
 
9885
		/*
9885
		/*
9886
		#break point
9886
		#break point
9887
		var_dump($spiltString);
9887
		var_dump($spiltString);
9888
		exit;
9888
		exit;
9889
		*/
9889
		*/
9890
		
9890
 
9891
		#預設 fileArgu 的路徑為 ""
9891
		#預設 fileArgu 的路徑為 ""
9892
		$fileArguPath="";
9892
		$fileArguPath="";
9893
		
9893
 
9894
		#針對每個目錄
9894
		#針對每個目錄
9895
		for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
9895
		for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
9896
		
9896
 
9897
			#串接路徑
9897
			#串接路徑
9898
			$fileArguPath=$fileArguPath."/".$spiltString["dataArray"][$i];
9898
			$fileArguPath=$fileArguPath."/".$spiltString["dataArray"][$i];
9899
		
9899
 
9900
			}#for end
9900
			}#for end
9901
	
9901
 
9902
		#取得相對於目標的當前位置
9902
		#取得相對於目標的當前位置
9903
		#函式說明:
9903
		#函式說明:
9904
		#呼叫shell執行系統命令,並取得回傳的內容.
9904
		#呼叫shell執行系統命令,並取得回傳的內容.
9905
		#回傳結果:
9905
		#回傳結果:
9906
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9906
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 9957... Line 9957...
9957
		#備註:
9957
		#備註:
9958
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
9958
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
9959
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
9959
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
9960
		$callShell=external::callShell($conf["external::callShell"]);
9960
		$callShell=external::callShell($conf["external::callShell"]);
9961
		unset($conf["external::callShell"]);
9961
		unset($conf["external::callShell"]);
9962
	
9962
 
9963
		#如果執行失敗
9963
		#如果執行失敗
9964
		if($callShell["status"]==="false"){
9964
		if($callShell["status"]==="false"){
9965
			
9965
 
9966
			#設置錯誤識別
9966
			#設置錯誤識別
9967
			$result["status"]="false";
9967
			$result["status"]="false";
9968
			
9968
 
9969
			#設置錯誤訊息
9969
			#設置錯誤訊息
9970
			$result["error"]=$callShell;
9970
			$result["error"]=$callShell;
9971
			
9971
 
9972
			#回傳結果
9972
			#回傳結果
9973
			return $result;
9973
			return $result;
9974
			
9974
 
9975
			}#if end
9975
			}#if end
9976
				
9976
 
9977
		#如果執行失敗
9977
		#如果執行失敗
9978
		if(!isset($callShell["output"][0])){
9978
		if(!isset($callShell["output"][0])){
9979
			
9979
 
9980
			#設置錯誤識別
9980
			#設置錯誤識別
9981
			$result["status"]="false";
9981
			$result["status"]="false";
9982
			
9982
 
9983
			#設置錯誤訊息
9983
			#設置錯誤訊息
9984
			$result["error"]=$callShell;
9984
			$result["error"]=$callShell;
9985
			
9985
 
9986
			#回傳結果
9986
			#回傳結果
9987
			return $result;
9987
			return $result;
9988
			
9988
 
9989
			}#if end	
9989
			}#if end
9990
			
9990
 
9991
		/*
9991
		/*
9992
		#break point
9992
		#break point
9993
		var_dump($callShell);
9993
		var_dump($callShell);
9994
		exit;
9994
		exit;
9995
		*/
9995
		*/
9996
		
9996
 
9997
		#記錄執行的指令
9997
		#記錄執行的指令
9998
		$result["cmd"][]=$callShell["cmd"];
9998
		$result["cmd"][]=$callShell["cmd"];
9999
			
9999
 
10000
		#保存相對於目標的當前位置
10000
		#保存相對於目標的當前位置
10001
		$pwd=$callShell["output"][0];
10001
		$pwd=$callShell["output"][0];
10002
	
10002
 
10003
		#更新 fileArgu
10003
		#更新 fileArgu
10004
		$conf["fileArgu"]=$pwd."/".$spiltString["dataArray"][$spiltString["dataCounts"]-1];
10004
		$conf["fileArgu"]=$pwd."/".$spiltString["dataArray"][$spiltString["dataCounts"]-1];
10005
		
10005
 
10006
		#針對每個 $conf["path"]
10006
		#針對每個 $conf["path"]
10007
		foreach($conf["path"] as $path){
10007
		foreach($conf["path"] as $path){
10008
			
10008
 
10009
			#將 $path 變成易讀的格式
10009
			#將 $path 變成易讀的格式
10010
			#函式說明:
10010
			#函式說明:
10011
			#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
10011
			#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
10012
			#回傳的結果:
10012
			#回傳的結果:
10013
			#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
10013
			#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
Line 10018... Line 10018...
10018
			#必填參數:
10018
			#必填參數:
10019
			#$conf["dirStr"],字串,要處理的檔案目錄字串.
10019
			#$conf["dirStr"],字串,要處理的檔案目錄字串.
10020
			$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"]=$path;
10020
			$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"]=$path;
10021
			$changeDirByDotDotSolidus=stringProcess::changeDirByDotDotSolidus($conf["stringProcess::changeDirByDotDotSolidus"]);
10021
			$changeDirByDotDotSolidus=stringProcess::changeDirByDotDotSolidus($conf["stringProcess::changeDirByDotDotSolidus"]);
10022
			unset($conf["stringProcess::changeDirByDotDotSolidus"]);
10022
			unset($conf["stringProcess::changeDirByDotDotSolidus"]);
10023
			
10023
 
10024
			#如果處理失敗
10024
			#如果處理失敗
10025
			if($changeDirByDotDotSolidus["status"]==="false"){
10025
			if($changeDirByDotDotSolidus["status"]==="false"){
10026
				
10026
 
10027
				#設置錯誤識別
10027
				#設置錯誤識別
10028
				$result["status"]="false";
10028
				$result["status"]="false";
10029
				
10029
 
10030
				#設置錯誤訊息
10030
				#設置錯誤訊息
10031
				$result["error"]=$changeDirByDotDotSolidus;
10031
				$result["error"]=$changeDirByDotDotSolidus;
10032
				
10032
 
10033
				#回傳結果
10033
				#回傳結果
10034
				return $result;
10034
				return $result;
10035
				
10035
 
10036
				}#if end
10036
				}#if end
10037
			
10037
 
10038
			#取得易讀的路徑
10038
			#取得易讀的路徑
10039
			$path=$changeDirByDotDotSolidus["changedPath"];
10039
			$path=$changeDirByDotDotSolidus["changedPath"];
10040
			
10040
 
10041
			#判斷 $path 是否為絕對路徑
10041
			#判斷 $path 是否為絕對路徑
10042
			#函式說明:
10042
			#函式說明:
10043
			#取得符合特定字首與字尾的字串
10043
			#取得符合特定字首與字尾的字串
10044
			#回傳結果:
10044
			#回傳結果:
10045
			#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
10045
			#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 10056... Line 10056...
10056
			#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
10056
			#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
10057
			#$conf["tailWord"]="";
10057
			#$conf["tailWord"]="";
10058
			#參考資料:
10058
			#參考資料:
10059
			#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
10059
			#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
10060
			$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
10060
			$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
10061
			unset($conf["search::getMeetConditionsString"]);			
10061
			unset($conf["search::getMeetConditionsString"]);
10062
			
10062
 
10063
			#如果檢查失敗
10063
			#如果檢查失敗
10064
			if($getMeetConditionsString["status"]=="false"){
10064
			if($getMeetConditionsString["status"]=="false"){
10065
				
10065
 
10066
				#設置錯誤識別
10066
				#設置錯誤識別
10067
				$result["status"]="false";
10067
				$result["status"]="false";
10068
				
10068
 
10069
				#設置錯誤訊息
10069
				#設置錯誤訊息
10070
				$result["error"]=$getMeetConditionsString;
10070
				$result["error"]=$getMeetConditionsString;
10071
				
10071
 
10072
				#回傳結果
10072
				#回傳結果
10073
				return $result;
10073
				return $result;
10074
				
10074
 
10075
				}#if end
10075
				}#if end
10076
				
10076
 
10077
			#如果沒有「/」開頭
10077
			#如果沒有「/」開頭
10078
			if($getMeetConditionsString["founded"]==="false"){
10078
			if($getMeetConditionsString["founded"]==="false"){
10079
				
10079
 
10080
				#將 $conf["fileArgu"] 最後面的檔案或目錄名稱剔除
10080
				#將 $conf["fileArgu"] 最後面的檔案或目錄名稱剔除
10081
				#函式說明:
10081
				#函式說明:
10082
				#將固定格式的字串分開,並回傳分開的結果。
10082
				#將固定格式的字串分開,並回傳分開的結果。
10083
				#回傳結果:
10083
				#回傳結果:
10084
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10084
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 10090... Line 10090...
10090
				#必填參數:
10090
				#必填參數:
10091
				$conf["stringProcess::spiltString"]["stringIn"]=$conf["fileArgu"];#要處理的字串。
10091
				$conf["stringProcess::spiltString"]["stringIn"]=$conf["fileArgu"];#要處理的字串。
10092
				$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
10092
				$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
10093
				$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
10093
				$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
10094
				unset($conf["stringProcess::spiltString"]);
10094
				unset($conf["stringProcess::spiltString"]);
10095
				
10095
 
10096
				#如果分割字串失敗
10096
				#如果分割字串失敗
10097
				if($spiltString["status"]=="false"){
10097
				if($spiltString["status"]=="false"){
10098
					
10098
 
10099
					#設置錯誤識別
10099
					#設置錯誤識別
10100
					$result["status"]="false";
10100
					$result["status"]="false";
10101
					
10101
 
10102
					#設置錯誤訊息
10102
					#設置錯誤訊息
10103
					$result["error"]=$spiltString;
10103
					$result["error"]=$spiltString;
10104
					
10104
 
10105
					#回傳結果
10105
					#回傳結果
10106
					return $result;
10106
					return $result;
10107
					
10107
 
10108
					}#if end
10108
					}#if end
10109
				
10109
 
10110
				#初始化相對路徑為開頭片段""
10110
				#初始化相對路徑為開頭片段""
10111
				$relativePathPart="/";
10111
				$relativePathPart="/";
10112
				
10112
 
10113
				#剔除最後一段
10113
				#剔除最後一段
10114
				for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
10114
				for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
10115
					
10115
 
10116
					#串接起來
10116
					#串接起來
10117
					$relativePathPart=$relativePathPart.$spiltString["dataArray"][$i]."/";
10117
					$relativePathPart=$relativePathPart.$spiltString["dataArray"][$i]."/";
10118
					
10118
 
10119
					}#for end
10119
					}#for end
10120
					
10120
 
10121
				#如果有設定 baseFrom
10121
				#如果有設定 baseFrom
10122
				if(isset($conf["baseFrom"])){
10122
				if(isset($conf["baseFrom"])){
10123
				
10123
 
10124
					#函式說明:
10124
					#函式說明:
10125
					#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
10125
					#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
10126
					#回傳結果:
10126
					#回傳結果:
10127
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10127
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10128
					#$result["error"],錯誤訊息陣列.
10128
					#$result["error"],錯誤訊息陣列.
10129
					#$result["function"],函數名稱. 
10129
					#$result["function"],函數名稱.
10130
					#$result["argu"],使用的參數.
10130
					#$result["argu"],使用的參數.
10131
					#$result["content"],網址,若是在命令列執行,則為"null".
10131
					#$result["content"],網址,若是在命令列執行,則為"null".
10132
					#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
10132
					#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
10133
					#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
10133
					#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
10134
					#必填參數:
10134
					#必填參數:
Line 10143... Line 10143...
10143
					#無.
10143
					#無.
10144
					#備註:
10144
					#備註:
10145
					#無.
10145
					#無.
10146
					$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
10146
					$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
10147
					unset($conf["fileAccess::getInternetAddressV2"]);
10147
					unset($conf["fileAccess::getInternetAddressV2"]);
10148
				
10148
 
10149
					##var_dump(__LINE__." ".print_r($getInternetAddressV2,true));
10149
					##var_dump(__LINE__." ".print_r($getInternetAddressV2,true));
10150
				
10150
 
10151
					#如果執行失敗
10151
					#如果執行失敗
10152
					if($getInternetAddressV2["status"]==="false"){
10152
					if($getInternetAddressV2["status"]==="false"){
10153
					
10153
 
10154
						#設置錯誤識別
10154
						#設置錯誤識別
10155
						$result["status"]="false";
10155
						$result["status"]="false";
10156
						
10156
 
10157
						#設置錯誤訊息
10157
						#設置錯誤訊息
10158
						$result["error"]=$getInternetAddressV2;
10158
						$result["error"]=$getInternetAddressV2;
10159
						
10159
 
10160
						#回傳結果
10160
						#回傳結果
10161
						return $result;
10161
						return $result;
10162
					
10162
 
10163
						}#if end
10163
						}#if end
10164
				
10164
 
10165
					#取得絕對位置
10165
					#取得絕對位置
10166
					$path=$getInternetAddressV2["fileSystemAbsoulutePosition"];
10166
					$path=$getInternetAddressV2["fileSystemAbsoulutePosition"];
10167
													
10167
 
10168
					#函式說明:
10168
					#函式說明:
10169
					#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
10169
					#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
10170
					#回傳結果:
10170
					#回傳結果:
10171
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10171
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10172
					#$result["error"],錯誤訊息陣列.
10172
					#$result["error"],錯誤訊息陣列.
10173
					#$result["function"],函數名稱. 
10173
					#$result["function"],函數名稱.
10174
					#$result["argu"],使用的參數.
10174
					#$result["argu"],使用的參數.
10175
					#$result["content"],網址,若是在命令列執行,則為"null".
10175
					#$result["content"],網址,若是在命令列執行,則為"null".
10176
					#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
10176
					#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
10177
					#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
10177
					#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
10178
					#必填參數:
10178
					#必填參數:
Line 10187... Line 10187...
10187
					#無.
10187
					#無.
10188
					#備註:
10188
					#備註:
10189
					#無.
10189
					#無.
10190
					$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
10190
					$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
10191
					unset($conf["fileAccess::getInternetAddressV2"]);
10191
					unset($conf["fileAccess::getInternetAddressV2"]);
10192
				
10192
 
10193
					#var_dump(__LINE__." ".print_r($getInternetAddressV2,true));
10193
					#var_dump(__LINE__." ".print_r($getInternetAddressV2,true));
10194
				
10194
 
10195
					#如果執行失敗
10195
					#如果執行失敗
10196
					if($getInternetAddressV2["status"]==="false"){
10196
					if($getInternetAddressV2["status"]==="false"){
10197
					
10197
 
10198
						#設置錯誤識別
10198
						#設置錯誤識別
10199
						$result["status"]="false";
10199
						$result["status"]="false";
10200
						
10200
 
10201
						#設置錯誤訊息
10201
						#設置錯誤訊息
10202
						$result["error"]=$getInternetAddressV2;
10202
						$result["error"]=$getInternetAddressV2;
10203
						
10203
 
10204
						#回傳結果
10204
						#回傳結果
10205
						return $result;
10205
						return $result;
10206
					
10206
 
10207
						}#if end
10207
						}#if end
10208
				
10208
 
10209
					#取得絕對位置
10209
					#取得絕對位置
10210
					$conf["baseFrom"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
10210
					$conf["baseFrom"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
10211
				
10211
 
10212
					#函式說明:
10212
					#函式說明:
10213
					#將多個路徑字串變成相對於當前路徑的相對路徑字串
10213
					#將多個路徑字串變成相對於當前路徑的相對路徑字串
10214
					#回傳結果:
10214
					#回傳結果:
10215
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10215
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10216
					#$result["error"],錯誤訊息陣列.
10216
					#$result["error"],錯誤訊息陣列.
10217
					#$result["function"],函數名稱. 
10217
					#$result["function"],函數名稱.
10218
					#$result["argu"],使用的參數.
10218
					#$result["argu"],使用的參數.
10219
					#$result["content"],字串陣列,多個轉換好的相對路徑字串.
10219
					#$result["content"],字串陣列,多個轉換好的相對路徑字串.
10220
					#必填參數:
10220
					#必填參數:
10221
					#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
10221
					#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
10222
					$conf["fileAccess::getRelativePath"]["path"]=array($path);
10222
					$conf["fileAccess::getRelativePath"]["path"]=array($path);
Line 10229... Line 10229...
10229
					#無.
10229
					#無.
10230
					#備註:
10230
					#備註:
10231
					#無.
10231
					#無.
10232
					$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
10232
					$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
10233
					unset($conf["fileAccess::getRelativePath"]);
10233
					unset($conf["fileAccess::getRelativePath"]);
10234
				
10234
 
10235
					#var_dump(__LINE__." ".print_r($getRelativePath,true));
10235
					#var_dump(__LINE__." ".print_r($getRelativePath,true));
10236
				
10236
 
10237
					#如果執行失敗
10237
					#如果執行失敗
10238
					if($getRelativePath["status"]==="false"){
10238
					if($getRelativePath["status"]==="false"){
10239
					
10239
 
10240
						#設置錯誤識別
10240
						#設置錯誤識別
10241
						$result["status"]="false";
10241
						$result["status"]="false";
10242
						
10242
 
10243
						#設置錯誤訊息
10243
						#設置錯誤訊息
10244
						$result["error"]=$getRelativePath;
10244
						$result["error"]=$getRelativePath;
10245
						
10245
 
10246
						#回傳結果
10246
						#回傳結果
10247
						return $result;
10247
						return $result;
10248
					
10248
 
10249
						}#if end
10249
						}#if end
10250
						
10250
 
10251
					#取得轉換好的絕對路徑
10251
					#取得轉換好的絕對路徑
10252
					$relativePathPart=$getRelativePath["content"][0]."/";
10252
					$relativePathPart=$getRelativePath["content"][0]."/";
10253
					
10253
 
10254
					#清空path,避免出錯
10254
					#清空path,避免出錯
10255
					$path="";
10255
					$path="";
10256
				
10256
 
10257
					}#if end
10257
					}#if end
10258
				
10258
 
10259
				#轉換成易讀的相對路徑
10259
				#轉換成易讀的相對路徑
10260
				#函式說明:
10260
				#函式說明:
10261
				#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
10261
				#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
10262
				#回傳的結果:
10262
				#回傳的結果:
10263
				#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
10263
				#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
Line 10268... Line 10268...
10268
				#必填參數:
10268
				#必填參數:
10269
				#$conf["dirStr"],字串,要處理的檔案目錄字串.
10269
				#$conf["dirStr"],字串,要處理的檔案目錄字串.
10270
				$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"]=$relativePathPart.$path;
10270
				$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"]=$relativePathPart.$path;
10271
				$changeDirByDotDotSolidus=stringProcess::changeDirByDotDotSolidus($conf["stringProcess::changeDirByDotDotSolidus"]);
10271
				$changeDirByDotDotSolidus=stringProcess::changeDirByDotDotSolidus($conf["stringProcess::changeDirByDotDotSolidus"]);
10272
				unset($conf["stringProcess::changeDirByDotDotSolidus"]);
10272
				unset($conf["stringProcess::changeDirByDotDotSolidus"]);
10273
				
10273
 
10274
				#var_dump($changeDirByDotDotSolidus);	
10274
				#var_dump($changeDirByDotDotSolidus);
10275
				
10275
 
10276
				#如果轉換失敗
10276
				#如果轉換失敗
10277
				if($changeDirByDotDotSolidus["status"]=="false"){
10277
				if($changeDirByDotDotSolidus["status"]=="false"){
10278
					
10278
 
10279
					#設置錯誤識別
10279
					#設置錯誤識別
10280
					$result["status"]="false";
10280
					$result["status"]="false";
10281
					
10281
 
10282
					#設置錯誤訊息
10282
					#設置錯誤訊息
10283
					$result["error"]=$changeDirByDotDotSolidus;
10283
					$result["error"]=$changeDirByDotDotSolidus;
10284
					
10284
 
10285
					#回傳結果
10285
					#回傳結果
10286
					return $result;
10286
					return $result;
10287
					
10287
 
10288
					}#if end
10288
					}#if end
10289
				
10289
 
10290
				#轉換為相對路徑
10290
				#轉換為相對路徑
10291
				#函式說明:
10291
				#函式說明:
10292
				#將多個路徑字串變成相對於當前路徑的相對路徑字串
10292
				#將多個路徑字串變成相對於當前路徑的相對路徑字串
10293
				#回傳結果:
10293
				#回傳結果:
10294
				#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10294
				#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10295
				#$result["error"],錯誤訊息陣列.
10295
				#$result["error"],錯誤訊息陣列.
10296
				#$result["function"],函數名稱. 
10296
				#$result["function"],函數名稱.
10297
				#$result["content"],字串陣列,多個轉換好的相對路徑字串.
10297
				#$result["content"],字串陣列,多個轉換好的相對路徑字串.
10298
				#必填參數:
10298
				#必填參數:
10299
				#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
10299
				#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
10300
				$conf["fileAccess::getRelativePath"]["path"]=array($changeDirByDotDotSolidus["changedPath"]);
10300
				$conf["fileAccess::getRelativePath"]["path"]=array($changeDirByDotDotSolidus["changedPath"]);
10301
				#$conf["fileArgu"],字串,當前路徑.
10301
				#$conf["fileArgu"],字串,當前路徑.
10302
				$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
10302
				$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
10303
				$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
10303
				$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
10304
				unset($conf["fileAccess::getRelativePath"]);
10304
				unset($conf["fileAccess::getRelativePath"]);
10305
					
10305
 
10306
				#var_dump($getRelativePath);	
10306
				#var_dump($getRelativePath);
10307
					
10307
 
10308
				#如果轉換路徑失敗
10308
				#如果轉換路徑失敗
10309
				if($getRelativePath["status"]==="false"){
10309
				if($getRelativePath["status"]==="false"){
10310
					
10310
 
10311
					#設置錯誤識別
10311
					#設置錯誤識別
10312
					$result["status"]="false";
10312
					$result["status"]="false";
10313
					
10313
 
10314
					#設置錯誤訊息
10314
					#設置錯誤訊息
10315
					$result["error"]=$changeDirByDotDotSolidus;
10315
					$result["error"]=$changeDirByDotDotSolidus;
10316
					
10316
 
10317
					#回傳結果
10317
					#回傳結果
10318
					return $result;
10318
					return $result;
10319
					
10319
 
10320
					}#if end
10320
					}#if end
10321
				
10321
 
10322
				#取得相對路徑
10322
				#取得相對路徑
10323
				$result["content"][]=$getRelativePath["content"][0];
10323
				$result["content"][]=$getRelativePath["content"][0];
10324
										
10324
 
10325
				}#if end
10325
				}#if end
10326
				
10326
 
10327
			#反之有「/」開頭
10327
			#反之有「/」開頭
10328
			else{
10328
			else{
10329
				#函式說明:
10329
				#函式說明:
10330
				#移除多個絕對路徑字串開頭相同的部分
10330
				#移除多個絕對路徑字串開頭相同的部分
10331
				#回傳結果:
10331
				#回傳結果:
Line 10333... Line 10333...
10333
				#$result["error"],錯誤訊息陣列.
10333
				#$result["error"],錯誤訊息陣列.
10334
				#$result["function"],當前執行的函數名稱.
10334
				#$result["function"],當前執行的函數名稱.
10335
				#$result["content"],處理好的的字串內容.
10335
				#$result["content"],處理好的的字串內容.
10336
				#必填參數:
10336
				#必填參數:
10337
				#$conf["pathIn"],字串陣列,每個要處理的絕對路徑字串.
10337
				#$conf["pathIn"],字串陣列,每個要處理的絕對路徑字串.
10338
				$conf["fileAccess::delSamePathHead"]["pathIn"]=array($path,$conf["fileArgu"]);		
10338
				$conf["fileAccess::delSamePathHead"]["pathIn"]=array($path,$conf["fileArgu"]);
10339
				$delSamePathHead=fileAccess::delSamePathHead($conf["fileAccess::delSamePathHead"]);
10339
				$delSamePathHead=fileAccess::delSamePathHead($conf["fileAccess::delSamePathHead"]);
10340
				unset($conf["fileAccess::delSamePathHead"]);
10340
				unset($conf["fileAccess::delSamePathHead"]);
10341
				
10341
 
10342
				#var_dump($delSamePathHead);
10342
				#var_dump($delSamePathHead);
10343
				
10343
 
10344
				#如果移除多個絕對路徑字串開頭相同的部分失敗
10344
				#如果移除多個絕對路徑字串開頭相同的部分失敗
10345
				if($delSamePathHead["status"]==="false"){
10345
				if($delSamePathHead["status"]==="false"){
10346
					
10346
 
10347
					#設置錯誤識別
10347
					#設置錯誤識別
10348
					$result["status"]="false";
10348
					$result["status"]="false";
10349
					
10349
 
10350
					#設置錯誤訊息
10350
					#設置錯誤訊息
10351
					$result["error"]=$delSameHead;
10351
					$result["error"]=$delSameHead;
10352
					
10352
 
10353
					#回傳結果
10353
					#回傳結果
10354
					return $result;
10354
					return $result;
10355
					
10355
 
10356
					}#if end
10356
					}#if end
10357
									
10357
 
10358
				#如果 $conf["fileArgu"] 剩下空
10358
				#如果 $conf["fileArgu"] 剩下空
10359
				if($delSamePathHead["content"][1]===""){
10359
				if($delSamePathHead["content"][1]===""){
10360
					
10360
 
10361
					#檢查 $delSamePathHead[0] 開頭是否為「/」
10361
					#檢查 $delSamePathHead[0] 開頭是否為「/」
10362
					#函式說明:
10362
					#函式說明:
10363
					#取得符合特定字首與字尾的字串
10363
					#取得符合特定字首與字尾的字串
10364
					#回傳結果:
10364
					#回傳結果:
10365
					#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
10365
					#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 10377... Line 10377...
10377
					#$conf["tailWord"]="";
10377
					#$conf["tailWord"]="";
10378
					#參考資料:
10378
					#參考資料:
10379
					#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
10379
					#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
10380
					$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
10380
					$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
10381
					unset($conf["search::getMeetConditionsString"]);
10381
					unset($conf["search::getMeetConditionsString"]);
10382
					
10382
 
10383
					#如果檢查失敗
10383
					#如果檢查失敗
10384
					if($getMeetConditionsString["status"]=="false"){
10384
					if($getMeetConditionsString["status"]=="false"){
10385
						
10385
 
10386
						#設置錯誤識別
10386
						#設置錯誤識別
10387
						$result["status"]="false";
10387
						$result["status"]="false";
10388
						
10388
 
10389
						#設置錯誤訊息
10389
						#設置錯誤訊息
10390
						$result["error"]=$getMeetConditionsString;
10390
						$result["error"]=$getMeetConditionsString;
10391
						
10391
 
10392
						#回傳結果
10392
						#回傳結果
10393
						return $result;
10393
						return $result;
10394
						
10394
 
10395
						}#if end
10395
						}#if end
10396
					
10396
 
10397
					#如果有開頭有「/」
10397
					#如果有開頭有「/」
10398
					if($getMeetConditionsString["founded"]==="true"){
10398
					if($getMeetConditionsString["founded"]==="true"){
10399
						
10399
 
10400
						#函式說明:
10400
						#函式說明:
10401
						#將字串特定關鍵字與其前面的內容剔除
10401
						#將字串特定關鍵字與其前面的內容剔除
10402
						#回傳結果:
10402
						#回傳結果:
10403
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10403
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10404
						#$result["error"],錯誤訊息陣列.
10404
						#$result["error"],錯誤訊息陣列.
Line 10409... Line 10409...
10409
						#必填參數:
10409
						#必填參數:
10410
						$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$delSamePathHead["content"][0];#要處理的字串.
10410
						$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$delSamePathHead["content"][0];#要處理的字串.
10411
						$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="/";#特定字串.
10411
						$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="/";#特定字串.
10412
						$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
10412
						$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
10413
						unset($conf["stringProcess::delStrBeforeKeyWord"]);
10413
						unset($conf["stringProcess::delStrBeforeKeyWord"]);
10414
						
10414
 
10415
						#如果 將字串特定關鍵字與其前面的內容剔除 失敗
10415
						#如果 將字串特定關鍵字與其前面的內容剔除 失敗
10416
						if($delStrBeforeKeyWord["status"]=="false"){
10416
						if($delStrBeforeKeyWord["status"]=="false"){
10417
							
10417
 
10418
							#設置錯誤識別
10418
							#設置錯誤識別
10419
							$result["status"]="false";
10419
							$result["status"]="false";
10420
							
10420
 
10421
							#設置錯誤訊息
10421
							#設置錯誤訊息
10422
							$result["error"]=$delStrBeforeKeyWord;
10422
							$result["error"]=$delStrBeforeKeyWord;
10423
							
10423
 
10424
							#回傳結果
10424
							#回傳結果
10425
							return $result;
10425
							return $result;
10426
							
10426
 
10427
							}#if end
10427
							}#if end
10428
						
10428
 
10429
						#取得相對位置
10429
						#取得相對位置
10430
						$result["content"][]=$delStrBeforeKeyWord["content"];
10430
						$result["content"][]=$delStrBeforeKeyWord["content"];
10431
												
10431
 
10432
						}#if end
10432
						}#if end
10433
					
10433
 
10434
					#反之
10434
					#反之
10435
					else{
10435
					else{
10436
						
10436
 
10437
						#取得相對位置
10437
						#取得相對位置
10438
						$result["content"][]=$delSamePathHead["content"][0];
10438
						$result["content"][]=$delSamePathHead["content"][0];
10439
						
10439
 
10440
						}#else end	
10440
						}#else end
10441
					
10441
 
10442
					}#if end
10442
					}#if end
10443
					
10443
 
10444
				#反之剩下的 $conf["fileArgu"] 不為空
10444
				#反之剩下的 $conf["fileArgu"] 不為空
10445
				else{
10445
				else{
10446
					
10446
 
10447
					#檢查 $delSamePathHead["content"][1] 有幾個「/」
10447
					#檢查 $delSamePathHead["content"][1] 有幾個「/」
10448
					#函式說明:
10448
					#函式說明:
10449
					#檢查字串裡面有無指定的關鍵字
10449
					#檢查字串裡面有無指定的關鍵字
10450
					#回傳結果:
10450
					#回傳結果:
10451
					#$result["status"],"true"代表執行成功,"false"代表執行失敗。
10451
					#$result["status"],"true"代表執行成功,"false"代表執行失敗。
Line 10458... Line 10458...
10458
					$conf["search::findKeyWord"]["string"]=$delSamePathHead["content"][1];#要被搜尋的字串內容
10458
					$conf["search::findKeyWord"]["string"]=$delSamePathHead["content"][1];#要被搜尋的字串內容
10459
					#可省略參數:
10459
					#可省略參數:
10460
					#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
10460
					#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
10461
					$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
10461
					$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
10462
					unset($conf["search::findKeyWord"]);
10462
					unset($conf["search::findKeyWord"]);
10463
					
10463
 
10464
					#如果 檢查字串裡面有無指定的關鍵字 失敗
10464
					#如果 檢查字串裡面有無指定的關鍵字 失敗
10465
					if($findKeyWord["status"]==="false"){
10465
					if($findKeyWord["status"]==="false"){
10466
						
10466
 
10467
						#設置錯誤識別
10467
						#設置錯誤識別
10468
						$result["status"]="false";
10468
						$result["status"]="false";
10469
						
10469
 
10470
						#設置錯誤訊息
10470
						#設置錯誤訊息
10471
						$result["error"]=$findKeyWord;
10471
						$result["error"]=$findKeyWord;
10472
						
10472
 
10473
						#回傳結果
10473
						#回傳結果
10474
						return $result;
10474
						return $result;
10475
						
10475
 
10476
						}#if end
10476
						}#if end
10477
						
10477
 
10478
					#有幾個「/」就執行幾次
10478
					#有幾個「/」就執行幾次
10479
					for($i=0;$i<$findKeyWord["keyWordCount"];$i++){
10479
					for($i=0;$i<$findKeyWord["keyWordCount"];$i++){
10480
						
10480
 
10481
						#在前面加上 "../"
10481
						#在前面加上 "../"
10482
						$delSamePathHead["content"][0]="../".$delSamePathHead["content"][0];
10482
						$delSamePathHead["content"][0]="../".$delSamePathHead["content"][0];
10483
						
10483
 
10484
						}#for end
10484
						}#for end
10485
						
10485
 
10486
					#取得相對位置
10486
					#取得相對位置
10487
					$result["content"][]=$delSamePathHead["content"][0];
10487
					$result["content"][]=$delSamePathHead["content"][0];
10488
					
10488
 
10489
					}#else end
10489
					}#else end
10490
				
10490
 
10491
				}#else end
10491
				}#else end
10492
			
10492
 
10493
			}#foreach end
10493
			}#foreach end
10494
			
10494
 
10495
		#設置執行正常
10495
		#設置執行正常
10496
		$result["status"]="true";
10496
		$result["status"]="true";
10497
		
10497
 
10498
		#回傳結果
10498
		#回傳結果
10499
		return $result;
10499
		return $result;
10500
		
10500
 
10501
		}#function getRelativeParh end
10501
		}#function getRelativeParh end
10502
 
10502
 
10503
	/*
10503
	/*
10504
	#函式說明:
10504
	#函式說明:
10505
	#移除多個絕對路徑字串開頭相同的部分
10505
	#移除多個絕對路徑字串開頭相同的部分
Line 10509... Line 10509...
10509
	#$result["function"],當前執行的函數名稱.
10509
	#$result["function"],當前執行的函數名稱.
10510
	#$result["argu"],參數.
10510
	#$result["argu"],參數.
10511
	#$result["content"],處理好的的字串內容.
10511
	#$result["content"],處理好的的字串內容.
10512
	#必填參數:
10512
	#必填參數:
10513
	#$conf["pathIn"],字串陣列,每個要處理的絕對路徑字串.
10513
	#$conf["pathIn"],字串陣列,每個要處理的絕對路徑字串.
10514
	$conf["pathIn"]=array();		
10514
	$conf["pathIn"]=array();
10515
	#可省略參數:
10515
	#可省略參數:
10516
	#無
10516
	#無
10517
	#參考資料:
10517
	#參考資料:
10518
	#無.
10518
	#無.
10519
	#備註:
10519
	#備註:
10520
	#無.
10520
	#無.
10521
	*/
10521
	*/
10522
	public static function delSamePathHead(&$conf){
10522
	public static function delSamePathHead(&$conf){
10523
		
10523
 
10524
		#初始化要回傳的結果
10524
		#初始化要回傳的結果
10525
		$result=array();
10525
		$result=array();
10526
 
10526
 
10527
		#取得當前執行的函數名稱
10527
		#取得當前執行的函數名稱
10528
		$result["function"]=__FUNCTION__;
10528
		$result["function"]=__FUNCTION__;
10529
 
10529
 
10530
		#如果沒有參數
10530
		#如果沒有參數
10531
		if(func_num_args()==0){
10531
		if(func_num_args()==0){
10532
			
10532
 
10533
			#設置執行失敗
10533
			#設置執行失敗
10534
			$result["status"]="false";
10534
			$result["status"]="false";
10535
			
10535
 
10536
			#設置執行錯誤訊息
10536
			#設置執行錯誤訊息
10537
			$result["error"]="函數".$result["function"]."需要參數";
10537
			$result["error"]="函數".$result["function"]."需要參數";
10538
			
10538
 
10539
			#回傳結果
10539
			#回傳結果
10540
			return $result;
10540
			return $result;
10541
			
10541
 
10542
			}#if end
10542
			}#if end
10543
 
10543
 
10544
		#如果 $conf 不為陣列
10544
		#如果 $conf 不為陣列
10545
		if(gettype($conf)!="array"){
10545
		if(gettype($conf)!="array"){
10546
			
10546
 
10547
			#設置執行失敗
10547
			#設置執行失敗
10548
			$result["status"]="false";
10548
			$result["status"]="false";
10549
			
10549
 
10550
			#設置執行錯誤訊息
10550
			#設置執行錯誤訊息
10551
			$result["error"][]="\$conf變數須為陣列形態";
10551
			$result["error"][]="\$conf變數須為陣列形態";
10552
			
10552
 
10553
			#如果傳入的參數為 null
10553
			#如果傳入的參數為 null
10554
			if($conf==null){
10554
			if($conf==null){
10555
				
10555
 
10556
				#設置執行錯誤訊息
10556
				#設置執行錯誤訊息
10557
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
10557
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
10558
				
10558
 
10559
				}#if end
10559
				}#if end
10560
 
10560
 
10561
			#回傳結果
10561
			#回傳結果
10562
			return $result;
10562
			return $result;
10563
			
10563
 
10564
			}#if end
10564
			}#if end
10565
			
10565
 
10566
		#取得參數
10566
		#取得參數
10567
		$result["argv"]=$conf;	
10567
		$result["argv"]=$conf;
10568
			
10568
 
10569
		#檢查參數
10569
		#檢查參數
10570
		#函式說明:
10570
		#函式說明:
10571
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
10571
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
10572
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10572
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10573
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
10573
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 10582... Line 10582...
10582
		#必填寫的參數:
10582
		#必填寫的參數:
10583
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
10583
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
10584
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
10584
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
10585
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
10585
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
10586
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("pathIn");
10586
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("pathIn");
10587
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
10587
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
10588
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");
10588
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");
10589
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
10589
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
10590
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
10590
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
10591
		#可以省略的參數:
10591
		#可以省略的參數:
10592
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
10592
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
10593
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
10593
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
10594
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
10594
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
10595
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileToRead","output");
10595
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileToRead","output");
10596
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
10596
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
10597
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
10597
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
10598
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
10598
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
10599
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("help","help");
10599
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("help","help");
10600
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
10600
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
10601
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
10601
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
10602
		#參考資料來源:
10602
		#參考資料來源:
10603
		#array_keys=>http://php.net/manual/en/function.array-keys.php
10603
		#array_keys=>http://php.net/manual/en/function.array-keys.php
10604
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
10604
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
10605
		unset($conf["variableCheck::checkArguments"]);
10605
		unset($conf["variableCheck::checkArguments"]);
10606
		
10606
 
10607
		#如果 $checkResult["status"] 等於 "fasle"
10607
		#如果 $checkResult["status"] 等於 "fasle"
10608
		if($checkResult["status"]=="false"){
10608
		if($checkResult["status"]=="false"){
10609
			
10609
 
10610
			#設置錯誤識別
10610
			#設置錯誤識別
10611
			$result["status"]="false";
10611
			$result["status"]="false";
10612
			
10612
 
10613
			#設置錯誤訊息
10613
			#設置錯誤訊息
10614
			$result["error"]=$checkResult;
10614
			$result["error"]=$checkResult;
10615
			
10615
 
10616
			#回傳結果
10616
			#回傳結果
10617
			return $result;
10617
			return $result;
10618
			
10618
 
10619
			}#if end
10619
			}#if end
10620
			
10620
 
10621
		#如果 $checkResult["passed"] 等於 "fasle"
10621
		#如果 $checkResult["passed"] 等於 "fasle"
10622
		if($checkResult["passed"]=="false"){
10622
		if($checkResult["passed"]=="false"){
10623
			
10623
 
10624
			#設置錯誤識別
10624
			#設置錯誤識別
10625
			$result["status"]="false";
10625
			$result["status"]="false";
10626
			
10626
 
10627
			#設置錯誤訊息
10627
			#設置錯誤訊息
10628
			$result["error"]=$checkResult;
10628
			$result["error"]=$checkResult;
10629
			
10629
 
10630
			#回傳結果
10630
			#回傳結果
10631
			return $result;
10631
			return $result;
10632
			
10632
 
10633
			}#if end
10633
			}#if end
10634
					
10634
 
10635
		#檢查是否都為絕對路徑
10635
		#檢查是否都為絕對路徑
10636
		#函式說明:
10636
		#函式說明:
10637
		#取得多個符合特定字首與字尾的字串.
10637
		#取得多個符合特定字首與字尾的字串.
10638
		#回傳結果:
10638
		#回傳結果:
10639
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
10639
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 10650... Line 10650...
10650
		#$conf["tailWord"]="";
10650
		#$conf["tailWord"]="";
10651
		#參考資料:
10651
		#參考資料:
10652
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
10652
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
10653
		$getMeetConditionsStringMulti=search::getMeetConditionsStringMulti($conf["search::getMeetConditionsStringMulti"]);
10653
		$getMeetConditionsStringMulti=search::getMeetConditionsStringMulti($conf["search::getMeetConditionsStringMulti"]);
10654
		unset($conf["search::getMeetConditionsStringMulti"]);
10654
		unset($conf["search::getMeetConditionsStringMulti"]);
10655
		
10655
 
10656
		#如果檢測是否為絕對路徑失敗
10656
		#如果檢測是否為絕對路徑失敗
10657
		if($getMeetConditionsStringMulti["status"]=="false"){
10657
		if($getMeetConditionsStringMulti["status"]=="false"){
10658
			
10658
 
10659
			#設置錯誤識別
10659
			#設置錯誤識別
10660
			$result["status"]="false";
10660
			$result["status"]="false";
10661
			
10661
 
10662
			#設置錯誤訊息
10662
			#設置錯誤訊息
10663
			$result["error"]=$getMeetConditionsStringMulti;
10663
			$result["error"]=$getMeetConditionsStringMulti;
10664
			
10664
 
10665
			#增加額外的錯誤訊息
10665
			#增加額外的錯誤訊息
10666
			$result["error"][]="僅接受絕對路徑字串";
10666
			$result["error"][]="僅接受絕對路徑字串";
10667
			
10667
 
10668
			#回傳結果
10668
			#回傳結果
10669
			return $result;
10669
			return $result;
10670
			
10670
 
10671
			}#if end
10671
			}#if end
10672
		
10672
 
10673
		#函式說明:
10673
		#函式說明:
10674
		#將多個固定格式的字串分開,並回傳分開的結果
10674
		#將多個固定格式的字串分開,並回傳分開的結果
10675
		#回傳的參數:
10675
		#回傳的參數:
10676
		#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
10676
		#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
10677
		#$result["error"],錯誤訊息陣列.
10677
		#$result["error"],錯誤訊息陣列.
Line 10684... Line 10684...
10684
		#$conf["stringIn"],字串陣列,要處理的字串陣列.
10684
		#$conf["stringIn"],字串陣列,要處理的字串陣列.
10685
		$conf["stringProcess::spiltMutiString"]["stringIn"]=$conf["pathIn"];
10685
		$conf["stringProcess::spiltMutiString"]["stringIn"]=$conf["pathIn"];
10686
		#$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
10686
		#$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
10687
		$conf["stringProcess::spiltMutiString"]["spiltSymbol"]="/";
10687
		$conf["stringProcess::spiltMutiString"]["spiltSymbol"]="/";
10688
		$spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
10688
		$spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
10689
		
10689
 
10690
		#如果分割所有路徑字串失敗
10690
		#如果分割所有路徑字串失敗
10691
		if($spiltMutiString["status"]=="false"){
10691
		if($spiltMutiString["status"]=="false"){
10692
			
10692
 
10693
			#設置錯誤識別
10693
			#設置錯誤識別
10694
			$result["status"]="false";
10694
			$result["status"]="false";
10695
			
10695
 
10696
			#設置錯誤訊息
10696
			#設置錯誤訊息
10697
			$result["error"]=$spiltMutiString;				
10697
			$result["error"]=$spiltMutiString;
10698
			
10698
 
10699
			#回傳結果
10699
			#回傳結果
10700
			return $result;
10700
			return $result;
10701
			
10701
 
10702
			}#if end
10702
			}#if end
10703
			
10703
 
10704
		#初始化暫存每個路徑分割成的段數
10704
		#初始化暫存每個路徑分割成的段數
10705
		$spiltedPathCount=array();					
10705
		$spiltedPathCount=array();
10706
		
10706
 
10707
		#取得每個路徑分割成的段數
10707
		#取得每個路徑分割成的段數
10708
		#針對每個 $spiltMutiString["spiltString"]
10708
		#針對每個 $spiltMutiString["spiltString"]
10709
		for($i=0;$i<count($spiltMutiString["spiltString"]);$i++){
10709
		for($i=0;$i<count($spiltMutiString["spiltString"]);$i++){
10710
			
10710
 
10711
			$spiltedPathCount[]=$spiltMutiString["spiltString"][$i]["dataCounts"];
10711
			$spiltedPathCount[]=$spiltMutiString["spiltString"][$i]["dataCounts"];
10712
			
10712
 
10713
			}#for end
10713
			}#for end
10714
			
10714
 
10715
		#取得所有路徑字串分割後的最小數量
10715
		#取得所有路徑字串分割後的最小數量
10716
		#涵式說明
10716
		#涵式說明
10717
		#找最小值,結果會回傳最小值
10717
		#找最小值,結果會回傳最小值
10718
		#回傳的內容
10718
		#回傳的內容
10719
		#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
10719
		#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
Line 10723... Line 10723...
10723
		#$result["value"],陣列裏面最小的數值.
10723
		#$result["value"],陣列裏面最小的數值.
10724
		#必填參數:
10724
		#必填參數:
10725
		$conf["math::getMinValue"]["rawDataArray"]=$spiltedPathCount;#爲原始數據
10725
		$conf["math::getMinValue"]["rawDataArray"]=$spiltedPathCount;#爲原始數據
10726
		$getMinValue=math::getMinValue($conf["math::getMinValue"]);
10726
		$getMinValue=math::getMinValue($conf["math::getMinValue"]);
10727
		unset($conf["math::getMinValue"]);
10727
		unset($conf["math::getMinValue"]);
10728
			
10728
 
10729
		#如果取得最小數值失敗
10729
		#如果取得最小數值失敗
10730
		if($getMinValue["status"]=="false"){
10730
		if($getMinValue["status"]=="false"){
10731
			
10731
 
10732
			#設置錯誤識別
10732
			#設置錯誤識別
10733
			$result["status"]="false";
10733
			$result["status"]="false";
10734
			
10734
 
10735
			#設置錯誤訊息
10735
			#設置錯誤訊息
10736
			$result["error"]=$getMinValue;				
10736
			$result["error"]=$getMinValue;
10737
			
10737
 
10738
			#回傳結果
10738
			#回傳結果
10739
			return $result;
10739
			return $result;
10740
			
10740
 
10741
			}#if end	
10741
			}#if end
10742
		
10742
 
10743
		#初始化暫存每個路徑字串的前面幾個片段是相同的
10743
		#初始化暫存每個路徑字串的前面幾個片段是相同的
10744
		$samePartCount=0;
10744
		$samePartCount=0;
10745
			
10745
 
10746
		#var_dump($getMinValue["value"]);	
10746
		#var_dump($getMinValue["value"]);
10747
			
10747
 
10748
		#依據所有路徑字串分割後的最小數量
10748
		#依據所有路徑字串分割後的最小數量
10749
		for($j=0;$j<$getMinValue["value"];$j++){
10749
		for($j=0;$j<$getMinValue["value"];$j++){
10750
			
10750
 
10751
			#初始化暫存第一個路徑的片段字串
10751
			#初始化暫存第一個路徑的片段字串
10752
			$firstPathPart="";
10752
			$firstPathPart="";
10753
			
10753
 
10754
			#針對每個 $spiltMutiString["spiltString"]
10754
			#針對每個 $spiltMutiString["spiltString"]
10755
			for($i=0;$i<count($spiltMutiString["spiltString"]);$i++){
10755
			for($i=0;$i<count($spiltMutiString["spiltString"]);$i++){
10756
				
10756
 
10757
				#暫存分割的字串
10757
				#暫存分割的字串
10758
				$spiltedPath=$spiltMutiString["spiltString"][$i];
10758
				$spiltedPath=$spiltMutiString["spiltString"][$i];
10759
					
10759
 
10760
				#如果是第一個路徑
10760
				#如果是第一個路徑
10761
				if($i==0){
10761
				if($i==0){
10762
					
10762
 
10763
					#取得第一個路徑的片段字串
10763
					#取得第一個路徑的片段字串
10764
					$firstPathPart=$spiltedPath["dataArray"][$j];
10764
					$firstPathPart=$spiltedPath["dataArray"][$j];
10765
					
10765
 
10766
					}#if end									
10766
					}#if end
10767
							
10767
 
10768
				#如果第$i+1個路徑片段不跟第1個路徑的片段字串一樣
10768
				#如果第$i+1個路徑片段不跟第1個路徑的片段字串一樣
10769
				if($spiltedPath["dataArray"][$j]!=$firstPathPart){
10769
				if($spiltedPath["dataArray"][$j]!=$firstPathPart){
10770
					
10770
 
10771
					#讓最外層迴圈中止
10771
					#讓最外層迴圈中止
10772
					$getMinValue["value"]=-1;
10772
					$getMinValue["value"]=-1;
10773
					
10773
 
10774
					#跳出迴圈
10774
					#跳出迴圈
10775
					break;
10775
					break;
10776
					
10776
 
10777
					}#if end			
10777
					}#if end
10778
				
10778
 
10779
				}#for end
10779
				}#for end
10780
				
10780
 
10781
			#代表每個路徑字串的第$j段是一樣的.
10781
			#代表每個路徑字串的第$j段是一樣的.
10782
			$samePartCount=$j;
10782
			$samePartCount=$j;
10783
			
10783
 
10784
			}#for end
10784
			}#for end
10785
		
10785
 
10786
		#var_dump($samePartCount);
10786
		#var_dump($samePartCount);
10787
		
10787
 
10788
		#依據每個路徑
10788
		#依據每個路徑
10789
		for($i=0;$i<count($spiltMutiString["spiltString"]);$i++){			
10789
		for($i=0;$i<count($spiltMutiString["spiltString"]);$i++){
10790
						
10790
 
10791
			#初始化儲存第$i+1個處理好的路徑字串
10791
			#初始化儲存第$i+1個處理好的路徑字串
10792
			$result["content"][$i]="";			
10792
			$result["content"][$i]="";
10793
						
10793
 
10794
			#依據 $samePartCount 與 路徑的段數
10794
			#依據 $samePartCount 與 路徑的段數
10795
			for($j=$samePartCount;$j<$spiltMutiString["spiltString"][$i]["dataCounts"];$j++){
10795
			for($j=$samePartCount;$j<$spiltMutiString["spiltString"][$i]["dataCounts"];$j++){
10796
				
10796
 
10797
				#如果不是第一段
10797
				#如果不是第一段
10798
				if($j!=$samePartCount){
10798
				if($j!=$samePartCount){
10799
					
10799
 
10800
					#組裝每個路徑片段
10800
					#組裝每個路徑片段
10801
					$result["content"][$i]=$result["content"][$i]."/".$spiltMutiString["spiltString"][$i]["dataArray"][$j];
10801
					$result["content"][$i]=$result["content"][$i]."/".$spiltMutiString["spiltString"][$i]["dataArray"][$j];
10802
					
10802
 
10803
					}#if end
10803
					}#if end
10804
				
10804
 
10805
				#反之為第一段
10805
				#反之為第一段
10806
				else{
10806
				else{
10807
					
10807
 
10808
					#組裝每個路徑片段
10808
					#組裝每個路徑片段
10809
					$result["content"][$i]=$result["content"][$i].$spiltMutiString["spiltString"][$i]["dataArray"][$j];
10809
					$result["content"][$i]=$result["content"][$i].$spiltMutiString["spiltString"][$i]["dataArray"][$j];
10810
					
10810
 
10811
					}#else end
10811
					}#else end
10812
				
10812
 
10813
				}#for end
10813
				}#for end
10814
				
10814
 
10815
			}#for end
10815
			}#for end
10816
			
10816
 
10817
		#設置執行正常
10817
		#設置執行正常
10818
		$result["status"]="true";
10818
		$result["status"]="true";
10819
		
10819
 
10820
		#回傳結果
10820
		#回傳結果
10821
		return $result;
10821
		return $result;
10822
		
10822
 
10823
		}#function delSamePathHead end
10823
		}#function delSamePathHead end
10824
 
10824
 
10825
	/*
10825
	/*
10826
	#函式說明:
10826
	#函式說明:
10827
	#於本套件位置底下的tmp資料夾下建立與回傳暫存檔案名稱路徑 
10827
	#於本套件位置底下的tmp資料夾下建立與回傳暫存檔案名稱路徑
10828
	#回傳結果:
10828
	#回傳結果:
10829
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10829
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10830
	#$result["error"],錯誤訊息.
10830
	#$result["error"],錯誤訊息.
10831
	#$result["function"],當前執行的函數名稱.
10831
	#$result["function"],當前執行的函數名稱.
10832
	#$result["content"],暫存檔案的路徑與名稱.
10832
	#$result["content"],暫存檔案的路徑與名稱.
Line 10841... Line 10841...
10841
	#無.
10841
	#無.
10842
	#備註:
10842
	#備註:
10843
	#無.
10843
	#無.
10844
	*/
10844
	*/
10845
	public static function createTempFile(&$conf){
10845
	public static function createTempFile(&$conf){
10846
		
10846
 
10847
		#初始化要回傳的結果
10847
		#初始化要回傳的結果
10848
		$result=array();
10848
		$result=array();
10849
 
10849
 
10850
		#取得當前執行的函數名稱
10850
		#取得當前執行的函數名稱
10851
		$result["function"]=__FUNCTION__;
10851
		$result["function"]=__FUNCTION__;
10852
		
10852
 
10853
		#取得參數
10853
		#取得參數
10854
		$result["argu"]=$conf;
10854
		$result["argu"]=$conf;
10855
 
10855
 
10856
		#如果 $conf 不為陣列
10856
		#如果 $conf 不為陣列
10857
		if(gettype($conf)!="array"){
10857
		if(gettype($conf)!="array"){
Line 10872... Line 10872...
10872
 
10872
 
10873
			#回傳結果
10873
			#回傳結果
10874
			return $result;
10874
			return $result;
10875
 
10875
 
10876
			}#if end
10876
			}#if end
10877
		
10877
 
10878
		#檢查參數
10878
		#檢查參數
10879
		#函式說明:
10879
		#函式說明:
10880
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
10880
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
10881
		#回傳結果:
10881
		#回傳結果:
10882
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10882
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 10928... Line 10928...
10928
		#array_keys=>http://php.net/manual/en/function.array-keys.php
10928
		#array_keys=>http://php.net/manual/en/function.array-keys.php
10929
		#備註:
10929
		#備註:
10930
		#無.
10930
		#無.
10931
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
10931
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
10932
		unset($conf["variableCheck::checkArguments"]);
10932
		unset($conf["variableCheck::checkArguments"]);
10933
		
10933
 
10934
		#如果執行失敗
10934
		#如果執行失敗
10935
		if($checkArguments["status"]==="false"){
10935
		if($checkArguments["status"]==="false"){
10936
		
10936
 
10937
			#設置執行異常
10937
			#設置執行異常
10938
			$result["status"]="false";
10938
			$result["status"]="false";
10939
			
10939
 
10940
			#設置錯誤訊息
10940
			#設置錯誤訊息
10941
			$result["error"]=$checkArguments;
10941
			$result["error"]=$checkArguments;
10942
			
10942
 
10943
			#回傳結果
10943
			#回傳結果
10944
			return $result;
10944
			return $result;
10945
		
10945
 
10946
			}#if end
10946
			}#if end
10947
			
10947
 
10948
		#如果檢查不通過
10948
		#如果檢查不通過
10949
		if($checkArguments["passed"]==="false"){
10949
		if($checkArguments["passed"]==="false"){
10950
		
10950
 
10951
			#設置執行異常
10951
			#設置執行異常
10952
			$result["status"]="false";
10952
			$result["status"]="false";
10953
			
10953
 
10954
			#設置錯誤訊息
10954
			#設置錯誤訊息
10955
			$result["error"]=$checkArguments;
10955
			$result["error"]=$checkArguments;
10956
			
10956
 
10957
			#回傳結果
10957
			#回傳結果
10958
			return $result;
10958
			return $result;
10959
		
10959
 
10960
			}#if end
10960
			}#if end
10961
		
10961
 
10962
		#取得相對於當前路徑的  tmp 目錄.
10962
		#取得相對於當前路徑的  tmp 目錄.
10963
		exec("cd ".pathinfo(__FILE__)["dirname"]."/../../../var/qbpwcf/tmp;pwd;",$output,$status);
10963
		exec("cd ".pathinfo(__FILE__)["dirname"]."/../../../var/qbpwcf/tmp;pwd;",$output,$status);
10964
		
10964
 
10965
		#如果執行失敗
10965
		#如果執行失敗
10966
		if($status!==0){
10966
		if($status!==0){
10967
		
10967
 
10968
			#設置執行失敗
10968
			#設置執行失敗
10969
			$result["status"]="false";
10969
			$result["status"]="false";
10970
 
10970
 
10971
			#設置執行錯誤訊息
10971
			#設置執行錯誤訊息
10972
			$result["error"][]="取得暫存目錄失敗";
10972
			$result["error"][]="取得暫存目錄失敗";
10973
			
10973
 
10974
			#回傳結果
10974
			#回傳結果
10975
			return $result;
10975
			return $result;
10976
		
10976
 
10977
			}#if end	
10977
			}#if end
10978
			
10978
 
10979
		#設置預設的暫存目錄
10979
		#設置預設的暫存目錄
10980
		$defaultTmpDir=$output[0];	
10980
		$defaultTmpDir=$output[0];
10981
			
10981
 
10982
		#取得暫存檔案的路徑與名稱
10982
		#取得暫存檔案的路徑與名稱
10983
		$result["content"]=tempnam($defaultTmpDir,"qbpwcf_tmpfile_");
10983
		$result["content"]=tempnam($defaultTmpDir,"qbpwcf_tmpfile_");
10984
		
10984
 
10985
		#如果產生的暫存檔案位置異常
10985
		#如果產生的暫存檔案位置異常
10986
		#參考資料:
10986
		#參考資料:
10987
		#https://www.php.net/manual/en/function.tempnam.php
10987
		#https://www.php.net/manual/en/function.tempnam.php
10988
		if(strpos("/tmp/",$result["content"])===0){
10988
		if(strpos("/tmp/",$result["content"])===0){
10989
		
10989
 
10990
			#設置執行失敗
10990
			#設置執行失敗
10991
			$result["status"]="false";
10991
			$result["status"]="false";
10992
 
10992
 
10993
			#設置執行錯誤訊息
10993
			#設置執行錯誤訊息
10994
			$result["error"][]="於暫存目錄建立檔案失敗";
10994
			$result["error"][]="於暫存目錄建立檔案失敗";
10995
			
10995
 
10996
			#回傳結果
10996
			#回傳結果
10997
			return $result;
10997
			return $result;
10998
		
10998
 
10999
			}#if end
10999
			}#if end
11000
		
11000
 
11001
		#函式說明:
11001
		#函式說明:
11002
		#將字串特定關鍵字與其前面的內容剔除
11002
		#將字串特定關鍵字與其前面的內容剔除
11003
		#回傳結果:
11003
		#回傳結果:
11004
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11004
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11005
		#$result["error"],錯誤訊息陣列.
11005
		#$result["error"],錯誤訊息陣列.
11006
		#$result["warning"],警告訊息鎮列.
11006
		#$result["warning"],警告訊息鎮列.
11007
		#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
11007
		#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
11008
		#$result["function"],當前執行的函數名稱.
11008
		#$result["function"],當前執行的函數名稱.
11009
		#$result["argu"],使用的參數.
11009
		#$result["argu"],使用的參數.
11010
		#$result["oriStr"],要處理的原始字串內容.
11010
		#$result["oriStr"],要處理的原始字串內容.
11011
		#$result["content"],處理好的的字串內容.	
11011
		#$result["content"],處理好的的字串內容.
11012
		#必填參數:
11012
		#必填參數:
11013
		#$conf["stringIn"],字串,要處理的字串.
11013
		#$conf["stringIn"],字串,要處理的字串.
11014
		$conf["stringPorcess::delStrBeforeKeyWord"]["stringIn"]=$result["content"];
11014
		$conf["stringPorcess::delStrBeforeKeyWord"]["stringIn"]=$result["content"];
11015
		#$conf["keyWord"],字串,特定字串.
11015
		#$conf["keyWord"],字串,特定字串.
11016
		$conf["stringPorcess::delStrBeforeKeyWord"]["keyWord"]=$defaultTmpDir."/";
11016
		$conf["stringPorcess::delStrBeforeKeyWord"]["keyWord"]=$defaultTmpDir."/";
Line 11023... Line 11023...
11023
		#無.
11023
		#無.
11024
		#備註:
11024
		#備註:
11025
		#無.
11025
		#無.
11026
		$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringPorcess::delStrBeforeKeyWord"]);
11026
		$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringPorcess::delStrBeforeKeyWord"]);
11027
		unset($conf["stringPorcess::delStrBeforeKeyWord"]);
11027
		unset($conf["stringPorcess::delStrBeforeKeyWord"]);
11028
		
11028
 
11029
		#如果執行失敗
11029
		#如果執行失敗
11030
		if($delStrBeforeKeyWord["status"]==="false"){
11030
		if($delStrBeforeKeyWord["status"]==="false"){
11031
		
11031
 
11032
			#設置執行失敗
11032
			#設置執行失敗
11033
			$result["status"]="false";
11033
			$result["status"]="false";
11034
 
11034
 
11035
			#設置執行錯誤訊息
11035
			#設置執行錯誤訊息
11036
			$result["error"]=$delStrBeforeKeyWord;
11036
			$result["error"]=$delStrBeforeKeyWord;
11037
			
11037
 
11038
			#回傳結果
11038
			#回傳結果
11039
			return $result;
11039
			return $result;
11040
		
11040
 
11041
			}#if end
11041
			}#if end
11042
			
11042
 
11043
		#如果應該要存在的路徑關鍵字不在
11043
		#如果應該要存在的路徑關鍵字不在
11044
		if($delStrBeforeKeyWord["founded"]==="false"){
11044
		if($delStrBeforeKeyWord["founded"]==="false"){
11045
		
11045
 
11046
			#設置執行失敗
11046
			#設置執行失敗
11047
			$result["status"]="false";
11047
			$result["status"]="false";
11048
 
11048
 
11049
			#設置執行錯誤訊息
11049
			#設置執行錯誤訊息
11050
			$result["error"]=$delStrBeforeKeyWord;
11050
			$result["error"]=$delStrBeforeKeyWord;
11051
			
11051
 
11052
			#回傳結果
11052
			#回傳結果
11053
			return $result;
11053
			return $result;
11054
		
11054
 
11055
			}#if end
11055
			}#if end
11056
		
11056
 
11057
		#取得檔案名稱
11057
		#取得檔案名稱
11058
		$result["fileName"]=$delStrBeforeKeyWord["content"];
11058
		$result["fileName"]=$delStrBeforeKeyWord["content"];
11059
		
11059
 
11060
		#函式說明:
11060
		#函式說明:
11061
		#將字串特定關鍵字與其後面的內容剔除
11061
		#將字串特定關鍵字與其後面的內容剔除
11062
		#回傳結果:
11062
		#回傳結果:
11063
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11063
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11064
		#$result["error"],錯誤訊息陣列.
11064
		#$result["error"],錯誤訊息陣列.
Line 11080... Line 11080...
11080
		#無.
11080
		#無.
11081
		#備註:
11081
		#備註:
11082
		#無.
11082
		#無.
11083
		$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
11083
		$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
11084
		unset($conf["stringProcess::delStrAfterKeyWord"]);
11084
		unset($conf["stringProcess::delStrAfterKeyWord"]);
11085
		
11085
 
11086
		#如果執行失敗
11086
		#如果執行失敗
11087
		if($delStrAfterKeyWord["status"]==="false"){
11087
		if($delStrAfterKeyWord["status"]==="false"){
11088
		
11088
 
11089
			#設置執行失敗
11089
			#設置執行失敗
11090
			$result["status"]="false";
11090
			$result["status"]="false";
11091
 
11091
 
11092
			#設置執行錯誤訊息
11092
			#設置執行錯誤訊息
11093
			$result["error"]=$delStrAfterKeyWord;
11093
			$result["error"]=$delStrAfterKeyWord;
11094
			
11094
 
11095
			#回傳結果
11095
			#回傳結果
11096
			return $result;
11096
			return $result;
11097
		
11097
 
11098
			}#if end
11098
			}#if end
11099
			
11099
 
11100
		#如果應該要存在的檔案名稱關鍵字不在
11100
		#如果應該要存在的檔案名稱關鍵字不在
11101
		if($delStrAfterKeyWord["founded"]==="false"){
11101
		if($delStrAfterKeyWord["founded"]==="false"){
11102
		
11102
 
11103
			#設置執行失敗
11103
			#設置執行失敗
11104
			$result["status"]="false";
11104
			$result["status"]="false";
11105
 
11105
 
11106
			#設置執行錯誤訊息
11106
			#設置執行錯誤訊息
11107
			$result["error"]=$delStrAfterKeyWord;
11107
			$result["error"]=$delStrAfterKeyWord;
11108
			
11108
 
11109
			#回傳結果
11109
			#回傳結果
11110
			return $result;
11110
			return $result;
11111
		
11111
 
11112
			}#if end
11112
			}#if end
11113
		
11113
 
11114
		#取得路徑
11114
		#取得路徑
11115
		$result["path"]=$delStrAfterKeyWord["content"];
11115
		$result["path"]=$delStrAfterKeyWord["content"];
11116
		
11116
 
11117
		#如果有內容要寫入
11117
		#如果有內容要寫入
11118
		if(!empty($conf["content"])){
11118
		if(!empty($conf["content"])){
11119
		
11119
 
11120
			#函式說明:
11120
			#函式說明:
11121
			#將多行字串寫入到檔案
11121
			#將多行字串寫入到檔案
11122
			#回傳結果:
11122
			#回傳結果:
11123
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
11123
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
11124
			#$result["error"],錯誤訊息陣列.
11124
			#$result["error"],錯誤訊息陣列.
Line 11136... Line 11136...
11136
			#無.
11136
			#無.
11137
			#備註:
11137
			#備註:
11138
			#無.
11138
			#無.
11139
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
11139
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
11140
			unset($conf["fileAccess::writeMultiLine"]);
11140
			unset($conf["fileAccess::writeMultiLine"]);
11141
		
11141
 
11142
			#如果執行失敗
11142
			#如果執行失敗
11143
			if($writeMultiLine["status"]==="false"){
11143
			if($writeMultiLine["status"]==="false"){
11144
			
11144
 
11145
				#設置執行失敗
11145
				#設置執行失敗
11146
				$result["status"]="false";
11146
				$result["status"]="false";
11147
 
11147
 
11148
				#設置執行錯誤訊息
11148
				#設置執行錯誤訊息
11149
				$result["error"]=$writeMultiLine;
11149
				$result["error"]=$writeMultiLine;
11150
				
11150
 
11151
				#回傳結果
11151
				#回傳結果
11152
				return $result;
11152
				return $result;
11153
			
11153
 
11154
				}#if end
11154
				}#if end
11155
		
11155
 
11156
			}#if end
11156
			}#if end
11157
		
11157
 
11158
		#設置執行正常
11158
		#設置執行正常
11159
		$result["status"]="true";
11159
		$result["status"]="true";
11160
		
11160
 
11161
		#回傳結果
11161
		#回傳結果
11162
		return $result;
11162
		return $result;
11163
		
11163
 
11164
		}#function createTempFile end
11164
		}#function createTempFile end
11165
 
11165
 
11166
	/*
11166
	/*
11167
	#函式說明:
11167
	#函式說明:
11168
	#分割檔案,分割出來的檔案名稱編號為aa, ab ac...ba, bb, bc...,zx, zy, zz的順序.
11168
	#分割檔案,分割出來的檔案名稱編號為aa, ab ac...ba, bb, bc...,zx, zy, zz的順序.
Line 11172... Line 11172...
11172
	#$result["function"],當前執行的函數名稱.
11172
	#$result["function"],當前執行的函數名稱.
11173
	#$result["cmd"],執行的指令.
11173
	#$result["cmd"],執行的指令.
11174
	#$result["content"],執行指令回傳的結果.
11174
	#$result["content"],執行指令回傳的結果.
11175
	#必填參數:
11175
	#必填參數:
11176
	#$conf["file"],字串,要分割的檔案名稱.
11176
	#$conf["file"],字串,要分割的檔案名稱.
11177
	$conf["file"]="";	
11177
	$conf["file"]="";
11178
	#可省略參數:
11178
	#可省略參數:
11179
	#$conf["splitNameHead"],字串,分割成檔案的名稱開頭,預設為 $conf["file"]."-" .
11179
	#$conf["splitNameHead"],字串,分割成檔案的名稱開頭,預設為 $conf["file"]."-" .
11180
	#$conf["splitNameHead"]="";	
11180
	#$conf["splitNameHead"]="";
11181
	#$conf["partSize"],字串,分割檔的大小為多少?可以為XMB,XGB,XKB,可參見split指令的說明,預設為50MB.
11181
	#$conf["partSize"],字串,分割檔的大小為多少?可以為XMB,XGB,XKB,可參見split指令的說明,預設為50MB.
11182
	#$conf["partSize"]="";
11182
	#$conf["partSize"]="";
11183
	#參考資料:
11183
	#參考資料:
11184
	#無.
11184
	#無.
11185
	#備註:
11185
	#備註:
11186
	#需要有split指令
11186
	#需要有split指令
11187
	*/
11187
	*/
11188
	public static function split(&$conf=array()){
11188
	public static function split(&$conf=array()){
11189
		
11189
 
11190
		#初始化要回傳的結果
11190
		#初始化要回傳的結果
11191
		$result=array();
11191
		$result=array();
11192
 
11192
 
11193
		#取得當前執行的函數名稱
11193
		#取得當前執行的函數名稱
11194
		$result["function"]=__FUNCTION__;
11194
		$result["function"]=__FUNCTION__;
11195
 
11195
 
11196
		#如果沒有參數
11196
		#如果沒有參數
11197
		if(func_num_args()==0){
11197
		if(func_num_args()==0){
11198
			
11198
 
11199
			#設置執行失敗
11199
			#設置執行失敗
11200
			$result["status"]="false";
11200
			$result["status"]="false";
11201
			
11201
 
11202
			#設置執行錯誤訊息
11202
			#設置執行錯誤訊息
11203
			$result["error"]="函數".$result["function"]."需要參數";
11203
			$result["error"]="函數".$result["function"]."需要參數";
11204
			
11204
 
11205
			#回傳結果
11205
			#回傳結果
11206
			return $result;
11206
			return $result;
11207
			
11207
 
11208
			}#if end
11208
			}#if end
11209
 
11209
 
11210
		#函式說明:
11210
		#函式說明:
11211
		#判斷當前環境為web還是cmd
11211
		#判斷當前環境為web還是cmd
11212
		#回傳結果:
11212
		#回傳結果:
11213
		#$result,"web"或"cmd"
11213
		#$result,"web"或"cmd"
11214
		if(csInformation::getEnv()==="web"){
11214
		if(csInformation::getEnv()==="web"){
11215
			
11215
 
11216
			#設置執行失敗
11216
			#設置執行失敗
11217
			$result["status"]="false";
11217
			$result["status"]="false";
11218
			
11218
 
11219
			#設置執行錯誤訊息
11219
			#設置執行錯誤訊息
11220
			$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";
11220
			$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";
11221
			
11221
 
11222
			#回傳結果
11222
			#回傳結果
11223
			return $result;
11223
			return $result;
11224
			
11224
 
11225
			}#if end
11225
			}#if end
11226
			
11226
 
11227
		#取得參數
11227
		#取得參數
11228
		$result["argu"]=$conf;
11228
		$result["argu"]=$conf;
11229
 
11229
 
11230
		#如果 $conf 不為陣列
11230
		#如果 $conf 不為陣列
11231
		if(gettype($conf)!=="array"){
11231
		if(gettype($conf)!=="array"){
11232
			
11232
 
11233
			#設置執行失敗
11233
			#設置執行失敗
11234
			$result["status"]="false";
11234
			$result["status"]="false";
11235
			
11235
 
11236
			#設置執行錯誤訊息
11236
			#設置執行錯誤訊息
11237
			$result["error"][]="\$conf變數須為陣列形態";
11237
			$result["error"][]="\$conf變數須為陣列形態";
11238
			
11238
 
11239
			#如果傳入的參數為 null
11239
			#如果傳入的參數為 null
11240
			if($conf===null){
11240
			if($conf===null){
11241
				
11241
 
11242
				#設置執行錯誤訊息
11242
				#設置執行錯誤訊息
11243
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
11243
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
11244
				
11244
 
11245
				}#if end
11245
				}#if end
11246
 
11246
 
11247
			#回傳結果
11247
			#回傳結果
11248
			return $result;
11248
			return $result;
11249
			
11249
 
11250
			}#if end
11250
			}#if end
11251
		
11251
 
11252
		#檢查參數
11252
		#檢查參數
11253
		#函式說明:
11253
		#函式說明:
11254
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
11254
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
11255
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11255
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11256
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
11256
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 11281... Line 11281...
11281
		#$conf["canBeEmpty"]=array();
11281
		#$conf["canBeEmpty"]=array();
11282
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
11282
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
11283
		#$conf["skipableVariableCanNotBeEmpty"]=array();
11283
		#$conf["skipableVariableCanNotBeEmpty"]=array();
11284
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
11284
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
11285
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("splitNameHead","partSize");
11285
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("splitNameHead","partSize");
11286
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
11286
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
11287
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
11287
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
11288
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]",若後面需要加上內容,則可以再補上\",後面再補上要串接的內容.
11288
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]",若後面需要加上內容,則可以再補上\",後面再補上要串接的內容.
11289
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("\$conf[\"file\"]\"-","50MB");
11289
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("\$conf[\"file\"]\"-","50MB");
11290
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
11290
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
11291
		#$conf["arrayCountEqualCheck"][]=array();
11291
		#$conf["arrayCountEqualCheck"][]=array();
Line 11293... Line 11293...
11293
		#array_keys=>http://php.net/manual/en/function.array-keys.php
11293
		#array_keys=>http://php.net/manual/en/function.array-keys.php
11294
		#建議:
11294
		#建議:
11295
		#增加可省略參數全部不能為空字串或空陣列的參數功能.
11295
		#增加可省略參數全部不能為空字串或空陣列的參數功能.
11296
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
11296
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
11297
		unset($conf["variableCheck::checkArguments"]);
11297
		unset($conf["variableCheck::checkArguments"]);
11298
		
11298
 
11299
		#如果檢查參數失敗
11299
		#如果檢查參數失敗
11300
		if($checkArguments["status"]==="false"){
11300
		if($checkArguments["status"]==="false"){
11301
			
11301
 
11302
			#設置執行失敗
11302
			#設置執行失敗
11303
			$result["status"]="false";
11303
			$result["status"]="false";
11304
			
11304
 
11305
			#設置錯誤訊息
11305
			#設置錯誤訊息
11306
			$result["error"]=$checkArguments;
11306
			$result["error"]=$checkArguments;
11307
			
11307
 
11308
			#回傳結果
11308
			#回傳結果
11309
			return $result;
11309
			return $result;
11310
			
11310
 
11311
			}#if end
11311
			}#if end
11312
			
11312
 
11313
		#如果要分割的檔案存在
11313
		#如果要分割的檔案存在
11314
		if(file_exists($conf["file"])){
11314
		if(file_exists($conf["file"])){
11315
			
11315
 
11316
			#取得執行的指令
11316
			#取得執行的指令
11317
			$result["cmd"]="split -b ".$conf["partSize"]." '".$conf["file"]."' '".$conf["splitNameHead"]."'";
11317
			$result["cmd"]="split -b ".$conf["partSize"]." '".$conf["file"]."' '".$conf["splitNameHead"]."'";
11318
 
11318
 
11319
			#執行還原的指令
11319
			#執行還原的指令
11320
			exec($result["cmd"],$output,$status);
11320
			exec($result["cmd"],$output,$status);
11321
 
11321
 
11322
			#取得執行後的輸出
11322
			#取得執行後的輸出
11323
			$result["content"]=$output;
11323
			$result["content"]=$output;
11324
			
11324
 
11325
			}#if end
11325
			}#if end
11326
			
11326
 
11327
		#反之
11327
		#反之
11328
		else{
11328
		else{
11329
			
11329
 
11330
			#設置執行失敗
11330
			#設置執行失敗
11331
			$result["status"]="false";
11331
			$result["status"]="false";
11332
			
11332
 
11333
			#設置執行錯誤訊息
11333
			#設置執行錯誤訊息
11334
			$result["error"][]="要分割的檔案「".$conf["file"]."」不存在";
11334
			$result["error"][]="要分割的檔案「".$conf["file"]."」不存在";
11335
			
11335
 
11336
			#回傳結果
11336
			#回傳結果
11337
			return $result;
11337
			return $result;
11338
			
11338
 
11339
			}#else end
11339
			}#else end
11340
		
11340
 
11341
		#設置執行正常
11341
		#設置執行正常
11342
		$result["status"]="true";
11342
		$result["status"]="true";
11343
		
11343
 
11344
		#回傳結果
11344
		#回傳結果
11345
		return $result;
11345
		return $result;
11346
		
11346
 
11347
		}#function split end
11347
		}#function split end
11348
 
11348
 
11349
	/*
11349
	/*
11350
	#函式說明:
11350
	#函式說明:
11351
	#合併檔案,檔案編號為aa, ab ac...ba, bb, bc...,zx, zy, zz的順序.
11351
	#合併檔案,檔案編號為aa, ab ac...ba, bb, bc...,zx, zy, zz的順序.
Line 11367... Line 11367...
11367
	#備註:
11367
	#備註:
11368
	#需要有cat指令.
11368
	#需要有cat指令.
11369
	#僅能在命令列執行.
11369
	#僅能在命令列執行.
11370
	*/
11370
	*/
11371
	public static function merge(&$conf=array()){
11371
	public static function merge(&$conf=array()){
11372
		
11372
 
11373
		#初始化要回傳的結果
11373
		#初始化要回傳的結果
11374
		$result=array();
11374
		$result=array();
11375
 
11375
 
11376
		#取得當前執行的函數名稱
11376
		#取得當前執行的函數名稱
11377
		$result["function"]=__FUNCTION__;
11377
		$result["function"]=__FUNCTION__;
11378
 
11378
 
11379
		#如果沒有參數
11379
		#如果沒有參數
11380
		if(func_num_args()==0){
11380
		if(func_num_args()==0){
11381
			
11381
 
11382
			#設置執行失敗
11382
			#設置執行失敗
11383
			$result["status"]="false";
11383
			$result["status"]="false";
11384
			
11384
 
11385
			#設置執行錯誤訊息
11385
			#設置執行錯誤訊息
11386
			$result["error"]="函數".$result["function"]."需要參數";
11386
			$result["error"]="函數".$result["function"]."需要參數";
11387
			
11387
 
11388
			#回傳結果
11388
			#回傳結果
11389
			return $result;
11389
			return $result;
11390
			
11390
 
11391
			}#if end
11391
			}#if end
11392
 
11392
 
11393
		#函式說明:
11393
		#函式說明:
11394
		#判斷當前環境為web還是cmd
11394
		#判斷當前環境為web還是cmd
11395
		#回傳結果:
11395
		#回傳結果:
11396
		#$result,"web"或"cmd"
11396
		#$result,"web"或"cmd"
11397
		if(csInformation::getEnv()==="web"){
11397
		if(csInformation::getEnv()==="web"){
11398
			
11398
 
11399
			#設置執行失敗
11399
			#設置執行失敗
11400
			$result["status"]="false";
11400
			$result["status"]="false";
11401
			
11401
 
11402
			#設置執行錯誤訊息
11402
			#設置執行錯誤訊息
11403
			$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";
11403
			$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";
11404
			
11404
 
11405
			#回傳結果
11405
			#回傳結果
11406
			return $result;
11406
			return $result;
11407
			
11407
 
11408
			}#if end
11408
			}#if end
11409
			
11409
 
11410
		#取得參數
11410
		#取得參數
11411
		$result["argu"]=$conf;
11411
		$result["argu"]=$conf;
11412
 
11412
 
11413
		#如果 $conf 不為陣列
11413
		#如果 $conf 不為陣列
11414
		if(gettype($conf)!=="array"){
11414
		if(gettype($conf)!=="array"){
11415
			
11415
 
11416
			#設置執行失敗
11416
			#設置執行失敗
11417
			$result["status"]="false";
11417
			$result["status"]="false";
11418
			
11418
 
11419
			#設置執行錯誤訊息
11419
			#設置執行錯誤訊息
11420
			$result["error"][]="\$conf變數須為陣列形態";
11420
			$result["error"][]="\$conf變數須為陣列形態";
11421
			
11421
 
11422
			#如果傳入的參數為 null
11422
			#如果傳入的參數為 null
11423
			if($conf===null){
11423
			if($conf===null){
11424
				
11424
 
11425
				#設置執行錯誤訊息
11425
				#設置執行錯誤訊息
11426
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
11426
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
11427
				
11427
 
11428
				}#if end
11428
				}#if end
11429
 
11429
 
11430
			#回傳結果
11430
			#回傳結果
11431
			return $result;
11431
			return $result;
11432
			
11432
 
11433
			}#if end
11433
			}#if end
11434
		
11434
 
11435
		#檢查參數
11435
		#檢查參數
11436
		#函式說明:
11436
		#函式說明:
11437
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
11437
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
11438
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11438
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11439
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
11439
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 11464... Line 11464...
11464
		#$conf["canBeEmpty"]=array();
11464
		#$conf["canBeEmpty"]=array();
11465
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
11465
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
11466
		#$conf["skipableVariableCanNotBeEmpty"]=array();
11466
		#$conf["skipableVariableCanNotBeEmpty"]=array();
11467
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
11467
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
11468
		#$conf["skipableVariableName"]=array();
11468
		#$conf["skipableVariableName"]=array();
11469
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
11469
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
11470
		#$conf["skipableVariableType"]=array();
11470
		#$conf["skipableVariableType"]=array();
11471
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
11471
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
11472
		#$conf["skipableVarDefaultValue"]=array("");
11472
		#$conf["skipableVarDefaultValue"]=array("");
11473
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
11473
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
11474
		#$conf["arrayCountEqualCheck"][]=array();
11474
		#$conf["arrayCountEqualCheck"][]=array();
Line 11476... Line 11476...
11476
		#array_keys=>http://php.net/manual/en/function.array-keys.php
11476
		#array_keys=>http://php.net/manual/en/function.array-keys.php
11477
		#建議:
11477
		#建議:
11478
		#增加可省略參數全部不能為空字串或空陣列的參數功能.
11478
		#增加可省略參數全部不能為空字串或空陣列的參數功能.
11479
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
11479
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
11480
		unset($conf["variableCheck::checkArguments"]);
11480
		unset($conf["variableCheck::checkArguments"]);
11481
		
11481
 
11482
		#如果檢查參數失敗
11482
		#如果檢查參數失敗
11483
		if($checkArguments["status"]==="false"){
11483
		if($checkArguments["status"]==="false"){
11484
			
11484
 
11485
			#設置執行失敗
11485
			#設置執行失敗
11486
			$result["status"]="false";
11486
			$result["status"]="false";
11487
			
11487
 
11488
			#設置錯誤訊息
11488
			#設置錯誤訊息
11489
			$result["error"]=$checkArguments;
11489
			$result["error"]=$checkArguments;
11490
			
11490
 
11491
			#回傳結果
11491
			#回傳結果
11492
			return $result;
11492
			return $result;
11493
			
11493
 
11494
			}#if end
11494
			}#if end
11495
		
11495
 
11496
		#定義編號
11496
		#定義編號
11497
		$charArray=array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","v","u","w","x","y","z");
11497
		$charArray=array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","v","u","w","x","y","z");
11498
 
11498
 
11499
		#定義分割檔案的前置字串
11499
		#定義分割檔案的前置字串
11500
		$filePartHead=$conf["filePartHead"];
11500
		$filePartHead=$conf["filePartHead"];
Line 11522... Line 11522...
11522
				#反之
11522
				#反之
11523
				else{
11523
				else{
11524
 
11524
 
11525
					#如果是第一個分割檔就找不到
11525
					#如果是第一個分割檔就找不到
11526
					if($i===0 && $j===0){
11526
					if($i===0 && $j===0){
11527
						
11527
 
11528
						#設置執行失敗
11528
						#設置執行失敗
11529
						$result["status"]="false";
11529
						$result["status"]="false";
11530
						
11530
 
11531
						#設置錯誤訊息
11531
						#設置錯誤訊息
11532
						$result["error"][]="找不到第一個分割檔「".$filePartHead.$charArray[$i].$charArray[$j]."」";
11532
						$result["error"][]="找不到第一個分割檔「".$filePartHead.$charArray[$i].$charArray[$j]."」";
11533
						
11533
 
11534
						#回傳結果
11534
						#回傳結果
11535
						return $result;
11535
						return $result;
11536
						
11536
 
11537
						}#if end
11537
						}#if end
11538
 
11538
 
11539
					#串接要還原成的檔案名稱
11539
					#串接要還原成的檔案名稱
11540
					$restoreCmd=$restoreCmd." > '".$oriFileName."'";
11540
					$restoreCmd=$restoreCmd." > '".$oriFileName."'";
11541
 
11541
 
Line 11548... Line 11548...
11548
					#取得執行後的輸出
11548
					#取得執行後的輸出
11549
					$result["content"]=$output;
11549
					$result["content"]=$output;
11550
 
11550
 
11551
					#結束回圈
11551
					#結束回圈
11552
					break 2;
11552
					break 2;
11553
					
11553
 
11554
					}#else end
11554
					}#else end
11555
 
11555
 
11556
				}#for end
11556
				}#for end
11557
 
11557
 
11558
			}#for end
11558
			}#for end
11559
		
11559
 
11560
		#設置執行正常
11560
		#設置執行正常
11561
		$result["status"]="true";
11561
		$result["status"]="true";
11562
		
11562
 
11563
		#回傳結果
11563
		#回傳結果
11564
		return $result;
11564
		return $result;
11565
		
11565
 
11566
		}#function merge end
11566
		}#function merge end
11567
 
11567
 
11568
	/*
11568
	/*
11569
	#函式說明:
11569
	#函式說明:
11570
	#取得檔案的部分內容
11570
	#取得檔案的部分內容
Line 11592... Line 11592...
11592
	#無.
11592
	#無.
11593
	#備註:
11593
	#備註:
11594
	#無
11594
	#無
11595
	*/
11595
	*/
11596
	public static function getFilePart(&$conf){
11596
	public static function getFilePart(&$conf){
11597
	
11597
 
11598
		#初始化要回傳的結果
11598
		#初始化要回傳的結果
11599
		$result=array();
11599
		$result=array();
11600
 
11600
 
11601
		#取得當前執行的函數名稱
11601
		#取得當前執行的函數名稱
11602
		$result["function"]=__FUNCTION__;
11602
		$result["function"]=__FUNCTION__;
Line 11612... Line 11612...
11612
 
11612
 
11613
			#回傳結果
11613
			#回傳結果
11614
			return $result;
11614
			return $result;
11615
 
11615
 
11616
			}#if end
11616
			}#if end
11617
			
11617
 
11618
		#取得參數
11618
		#取得參數
11619
		$result["argu"]=$conf;
11619
		$result["argu"]=$conf;
11620
 
11620
 
11621
		#如果 $conf 不為陣列
11621
		#如果 $conf 不為陣列
11622
		if(gettype($conf)!=="array"){
11622
		if(gettype($conf)!=="array"){
Line 11637... Line 11637...
11637
 
11637
 
11638
			#回傳結果
11638
			#回傳結果
11639
			return $result;
11639
			return $result;
11640
 
11640
 
11641
			}#if end
11641
			}#if end
11642
			
11642
 
11643
		#函式說明:
11643
		#函式說明:
11644
		#檢查多個檔案與資料夾是否存在.
11644
		#檢查多個檔案與資料夾是否存在.
11645
		#回傳的結果:
11645
		#回傳的結果:
11646
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
11646
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
11647
		#$result["error"],錯誤訊息陣列.
11647
		#$result["error"],錯誤訊息陣列.
Line 11670... Line 11670...
11670
		#備註:
11670
		#備註:
11671
		#函數file_exists檢查的路徑為檔案系統的路徑
11671
		#函數file_exists檢查的路徑為檔案系統的路徑
11672
		#$result["varName"][$i]結果未實作
11672
		#$result["varName"][$i]結果未實作
11673
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
11673
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
11674
		unset($conf["fileAccess::checkMultiFileExist"]);
11674
		unset($conf["fileAccess::checkMultiFileExist"]);
11675
	
11675
 
11676
		#如果執行失敗
11676
		#如果執行失敗
11677
		if($checkMultiFileExist["status"]==="false"){
11677
		if($checkMultiFileExist["status"]==="false"){
11678
			
11678
 
11679
			#設置執行失敗
11679
			#設置執行失敗
11680
			$result["status"]="false";
11680
			$result["status"]="false";
11681
			
11681
 
11682
			#設置執行錯誤訊息
11682
			#設置執行錯誤訊息
11683
			$result["error"]=$checkMultiFileExist;
11683
			$result["error"]=$checkMultiFileExist;
11684
			
11684
 
11685
			#回傳結果
11685
			#回傳結果
11686
			return $result;
11686
			return $result;
11687
			
11687
 
11688
			}#if end
11688
			}#if end
11689
			
11689
 
11690
		#如果檔案不存在
11690
		#如果檔案不存在
11691
		if($checkMultiFileExist["allExist"]==="false"){
11691
		if($checkMultiFileExist["allExist"]==="false"){
11692
			
11692
 
11693
			#設置執行失敗
11693
			#設置執行失敗
11694
			$result["status"]="false";
11694
			$result["status"]="false";
11695
			
11695
 
11696
			#設置執行錯誤訊息
11696
			#設置執行錯誤訊息
11697
			$result["error"]=$checkMultiFileExist;
11697
			$result["error"]=$checkMultiFileExist;
11698
			
11698
 
11699
			#回傳結果
11699
			#回傳結果
11700
			return $result;
11700
			return $result;
11701
			
11701
 
11702
			}#if end
11702
			}#if end
11703
		
11703
 
11704
		#取得mimetype
11704
		#取得mimetype
11705
		$mimetype=mime_content_type($conf["file"]);
11705
		$mimetype=mime_content_type($conf["file"]);
11706
		
11706
 
11707
		#取得檔案的 mime type
11707
		#取得檔案的 mime type
11708
		$result["mimeType"]=$mimetype;
11708
		$result["mimeType"]=$mimetype;
11709
		
11709
 
11710
		#透過 dd 指令,取得部分內容.
11710
		#透過 dd 指令,取得部分內容.
11711
		#函式說明:
11711
		#函式說明:
11712
		#呼叫shell執行系統命令,並取得回傳的內容.
11712
		#呼叫shell執行系統命令,並取得回傳的內容.
11713
		#回傳結果:
11713
		#回傳結果:
11714
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11714
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 11765... Line 11765...
11765
		#備註:
11765
		#備註:
11766
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
11766
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
11767
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
11767
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
11768
		$callShell=external::callShell($conf["external::callShell"]);
11768
		$callShell=external::callShell($conf["external::callShell"]);
11769
		unset($conf["external::callShell"]);
11769
		unset($conf["external::callShell"]);
11770
	
11770
 
11771
		#如果執行失敗
11771
		#如果執行失敗
11772
		if($callShell["status"]==="false"){
11772
		if($callShell["status"]==="false"){
11773
			
11773
 
11774
			#設置執行失敗
11774
			#設置執行失敗
11775
			$result["status"]="false";
11775
			$result["status"]="false";
11776
			
11776
 
11777
			#設置執行錯誤訊息
11777
			#設置執行錯誤訊息
11778
			$result["error"]=$callShell;
11778
			$result["error"]=$callShell;
11779
			
11779
 
11780
			#回傳結果
11780
			#回傳結果
11781
			return $result;
11781
			return $result;
11782
			
11782
 
11783
			}#if end
11783
			}#if end
11784
			
11784
 
11785
		#取得結果
11785
		#取得結果
11786
		$result["content"]=$callShell["output"][0];
11786
		$result["content"]=$callShell["output"][0];
11787
	
11787
 
11788
		#取得內容長度
11788
		#取得內容長度
11789
		$result["length"]=strlen($result["content"]);
11789
		$result["length"]=strlen($result["content"]);
11790
	
11790
 
11791
		#預設尚未到檔案結尾 
11791
		#預設尚未到檔案結尾
11792
		$result["EOF"]="false";
11792
		$result["EOF"]="false";
11793
	
11793
 
11794
		#如果取得的內容長度小於預期
11794
		#如果取得的內容長度小於預期
11795
		if($result["length"]<$conf["bytes"]){
11795
		if($result["length"]<$conf["bytes"]){
11796
		
11796
 
11797
			#設置已經到檔案結尾了
11797
			#設置已經到檔案結尾了
11798
			$result["EOF"]="true";
11798
			$result["EOF"]="true";
11799
		
11799
 
11800
			}#if end
11800
			}#if end
11801
	
11801
 
11802
		#設置執行正常
11802
		#設置執行正常
11803
		$result["status"]="true";
11803
		$result["status"]="true";
11804
		
11804
 
11805
		#回傳結果
11805
		#回傳結果
11806
		return $result;
11806
		return $result;
11807
	
11807
 
11808
		}#function getFilePart end
11808
		}#function getFilePart end
11809
 
11809
 
11810
	/*
11810
	/*
11811
	#函式說明:
11811
	#函式說明:
11812
	#取得節點的資訊.
11812
	#取得節點的資訊.
11813
	#回傳結果:
11813
	#回傳結果:
11814
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
11814
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
11815
	#$result["error"],錯誤訊息陣列.
11815
	#$result["error"],錯誤訊息陣列.
11816
	#$result["function"],函數名稱. 
11816
	#$result["function"],函數名稱.
11817
	#$result["content"],檔案資訊陣列.
11817
	#$result["content"],檔案資訊陣列.
11818
	#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
11818
	#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.
11819
	#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
11819
	#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
11820
	#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
11820
	#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
11821
	#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
11821
	#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
11822
	#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
11822
	#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
11823
	#$result["content"]["ownerName"],檔案擁有着資訊.
11823
	#$result["content"]["ownerName"],檔案擁有着資訊.
Line 11840... Line 11840...
11840
	#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
11840
	#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
11841
	#備註:
11841
	#備註:
11842
	#無.
11842
	#無.
11843
	*/
11843
	*/
11844
	public static function fileInfo(&$conf=array()){
11844
	public static function fileInfo(&$conf=array()){
11845
		
11845
 
11846
		#初始化要回傳的結果
11846
		#初始化要回傳的結果
11847
		$result=array();
11847
		$result=array();
11848
 
11848
 
11849
		#取得當前執行的函數名稱
11849
		#取得當前執行的函數名稱
11850
		$result["function"]=__FUNCTION__;
11850
		$result["function"]=__FUNCTION__;
11851
 
11851
 
11852
		#如果沒有參數
11852
		#如果沒有參數
11853
		if(func_num_args()==0){
11853
		if(func_num_args()==0){
11854
			
11854
 
11855
			#設置執行失敗
11855
			#設置執行失敗
11856
			$result["status"]="false";
11856
			$result["status"]="false";
11857
			
11857
 
11858
			#設置執行錯誤訊息
11858
			#設置執行錯誤訊息
11859
			$result["error"]="函數".$result["function"]."需要參數";
11859
			$result["error"]="函數".$result["function"]."需要參數";
11860
			
11860
 
11861
			#回傳結果
11861
			#回傳結果
11862
			return $result;
11862
			return $result;
11863
			
11863
 
11864
			}#if end
11864
			}#if end
11865
 
11865
 
11866
		#取得參數
11866
		#取得參數
11867
		$result["argu"]=$conf;
11867
		$result["argu"]=$conf;
11868
 
11868
 
11869
		#如果 $conf 不為陣列
11869
		#如果 $conf 不為陣列
11870
		if(gettype($conf)!=="array"){
11870
		if(gettype($conf)!=="array"){
11871
			
11871
 
11872
			#設置執行失敗
11872
			#設置執行失敗
11873
			$result["status"]="false";
11873
			$result["status"]="false";
11874
			
11874
 
11875
			#設置執行錯誤訊息
11875
			#設置執行錯誤訊息
11876
			$result["error"][]="\$conf變數須為陣列形態";
11876
			$result["error"][]="\$conf變數須為陣列形態";
11877
			
11877
 
11878
			#如果傳入的參數為 null
11878
			#如果傳入的參數為 null
11879
			if($conf===null){
11879
			if($conf===null){
11880
				
11880
 
11881
				#設置執行錯誤訊息
11881
				#設置執行錯誤訊息
11882
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
11882
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
11883
				
11883
 
11884
				}#if end
11884
				}#if end
11885
 
11885
 
11886
			#回傳結果
11886
			#回傳結果
11887
			return $result;
11887
			return $result;
11888
			
11888
 
11889
			}#if end
11889
			}#if end
11890
		
11890
 
11891
		#檢查參數
11891
		#檢查參數
11892
		#函式說明:
11892
		#函式說明:
11893
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
11893
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
11894
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11894
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11895
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
11895
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 11902... Line 11902...
11902
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
11902
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
11903
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
11903
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
11904
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
11904
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
11905
		#必填寫的參數:
11905
		#必填寫的參數:
11906
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
11906
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
11907
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
11907
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
11908
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
11908
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
11909
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
11909
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
11910
		#可以省略的參數:
11910
		#可以省略的參數:
11911
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
11911
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
11912
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
11912
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
Line 11920... Line 11920...
11920
		#$conf["canBeEmpty"]=array();
11920
		#$conf["canBeEmpty"]=array();
11921
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
11921
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
11922
		#$conf["skipableVariableCanNotBeEmpty"]=array();
11922
		#$conf["skipableVariableCanNotBeEmpty"]=array();
11923
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
11923
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
11924
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
11924
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
11925
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
11925
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
11926
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
11926
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
11927
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
11927
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
11928
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
11928
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
11929
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
11929
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
11930
		#$conf["disallowAllSkipableVarIsEmpty"]="";
11930
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 11934... Line 11934...
11934
		#$conf["arrayCountEqualCheck"][]=array();
11934
		#$conf["arrayCountEqualCheck"][]=array();
11935
		#參考資料來源:
11935
		#參考資料來源:
11936
		#array_keys=>http://php.net/manual/en/function.array-keys.php
11936
		#array_keys=>http://php.net/manual/en/function.array-keys.php
11937
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
11937
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
11938
		unset($conf["variableCheck::checkArguments"]);
11938
		unset($conf["variableCheck::checkArguments"]);
11939
		
11939
 
11940
		#如果檢查參數失敗
11940
		#如果檢查參數失敗
11941
		if($checkArguments["status"]==="false"){
11941
		if($checkArguments["status"]==="false"){
11942
			
11942
 
11943
			#設置執行失敗
11943
			#設置執行失敗
11944
			$result["status"]="false";
11944
			$result["status"]="false";
11945
			
11945
 
11946
			#設置執行錯誤訊息
11946
			#設置執行錯誤訊息
11947
			$result["error"]=$checkArguments;
11947
			$result["error"]=$checkArguments;
11948
			
11948
 
11949
			#回傳結果
11949
			#回傳結果
11950
			return $result;
11950
			return $result;
11951
			
11951
 
11952
			}#if end
11952
			}#if end
11953
			
11953
 
11954
		#如果檢查參數不通過
11954
		#如果檢查參數不通過
11955
		if($checkArguments["passed"]==="false"){
11955
		if($checkArguments["passed"]==="false"){
11956
			
11956
 
11957
			#設置執行失敗
11957
			#設置執行失敗
11958
			$result["status"]="false";
11958
			$result["status"]="false";
11959
			
11959
 
11960
			#設置執行錯誤訊息
11960
			#設置執行錯誤訊息
11961
			$result["error"]=$checkArguments;
11961
			$result["error"]=$checkArguments;
11962
			
11962
 
11963
			#回傳結果
11963
			#回傳結果
11964
			return $result;
11964
			return $result;
11965
			
11965
 
11966
			}#if end
11966
			}#if end
11967
	
11967
 
11968
		#函式說明:
11968
		#函式說明:
11969
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
11969
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
11970
		#回傳結果:
11970
		#回傳結果:
11971
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
11971
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
11972
		#$result["error"],錯誤訊息陣列.
11972
		#$result["error"],錯誤訊息陣列.
11973
		#$result["function"],函數名稱. 
11973
		#$result["function"],函數名稱.
11974
		#$result["argu"],使用的參數.
11974
		#$result["argu"],使用的參數.
11975
		#$result["content"],網址,若是在命令列執行,則為"null".
11975
		#$result["content"],網址,若是在命令列執行,則為"null".
11976
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
11976
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
11977
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
11977
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
11978
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
11978
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
Line 11986... Line 11986...
11986
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
11986
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
11987
		#備註:
11987
		#備註:
11988
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
11988
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
11989
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
11989
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
11990
		unset($conf["fileAccess::getInternetAddressV2"]);
11990
		unset($conf["fileAccess::getInternetAddressV2"]);
11991
	
11991
 
11992
		#如果取得位置失敗
11992
		#如果取得位置失敗
11993
		if($getInternetAddressV2["status"]==="false"){
11993
		if($getInternetAddressV2["status"]==="false"){
11994
		
11994
 
11995
			#設置執行失敗
11995
			#設置執行失敗
11996
			$result["status"]="false";
11996
			$result["status"]="false";
11997
			
11997
 
11998
			#設置執行錯誤訊息
11998
			#設置執行錯誤訊息
11999
			$result["error"]=$getInternetAddressV2;
11999
			$result["error"]=$getInternetAddressV2;
12000
			
12000
 
12001
			#回傳結果
12001
			#回傳結果
12002
			return $result;
12002
			return $result;
12003
		
12003
 
12004
			}#if end
12004
			}#if end
12005
 
12005
 
12006
		#函式說明:
12006
		#函式說明:
12007
		#檢查多個檔案與資料夾是否存在.
12007
		#檢查多個檔案與資料夾是否存在.
12008
		#回傳的結果:
12008
		#回傳的結果:
Line 12031... Line 12031...
12031
		#http://php.net/manual/en/control-structures.foreach.php
12031
		#http://php.net/manual/en/control-structures.foreach.php
12032
		#備註:
12032
		#備註:
12033
		#函數file_exists檢查的路徑為檔案系統的路徑
12033
		#函數file_exists檢查的路徑為檔案系統的路徑
12034
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
12034
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
12035
		unset($conf["fileAccess::checkMultiFileExist"]);
12035
		unset($conf["fileAccess::checkMultiFileExist"]);
12036
		
12036
 
12037
		#如果檢查檔案存在失敗
12037
		#如果檢查檔案存在失敗
12038
		if($checkMultiFileExist["status"]==="false"){
12038
		if($checkMultiFileExist["status"]==="false"){
12039
			
12039
 
12040
			#設置執行失敗
12040
			#設置執行失敗
12041
			$result["status"]="false";
12041
			$result["status"]="false";
12042
			
12042
 
12043
			#設置執行錯誤訊息
12043
			#設置執行錯誤訊息
12044
			$result["error"]=$checkMultiFileExist;
12044
			$result["error"]=$checkMultiFileExist;
12045
			
12045
 
12046
			#回傳結果
12046
			#回傳結果
12047
			return $result;
12047
			return $result;
12048
			
12048
 
12049
			}#if end
12049
			}#if end
12050
			
12050
 
12051
		#如果檔案不存在
12051
		#如果檔案不存在
12052
		if($checkMultiFileExist["allExist"]==="false"){
12052
		if($checkMultiFileExist["allExist"]==="false"){
12053
			
12053
 
12054
			#設置執行失敗
12054
			#設置執行失敗
12055
			$result["status"]="false";
12055
			$result["status"]="false";
12056
			
12056
 
12057
			#設置執行錯誤訊息
12057
			#設置執行錯誤訊息
12058
			$result["error"]=$checkMultiFileExist;
12058
			$result["error"]=$checkMultiFileExist;
12059
			
12059
 
12060
			#回傳結果
12060
			#回傳結果
12061
			return $result;
12061
			return $result;
12062
			
12062
 
12063
			}#if end
12063
			}#if end
12064
			
12064
 
12065
		#透過ls指令取得檔案的資訊
12065
		#透過ls指令取得檔案的資訊
12066
		#函式說明:
12066
		#函式說明:
12067
		#呼叫shell執行系統命令,並取得回傳的內容.
12067
		#呼叫shell執行系統命令,並取得回傳的內容.
12068
		#回傳的結果:
12068
		#回傳的結果:
12069
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12069
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 12107... Line 12107...
12107
		#exec=>http://php.net/manual/en/function.exec.php
12107
		#exec=>http://php.net/manual/en/function.exec.php
12108
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
12108
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
12109
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
12109
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
12110
		$callShell=external::callShell($conf["external::callShell"]);
12110
		$callShell=external::callShell($conf["external::callShell"]);
12111
		unset($conf["external::callShell"]);
12111
		unset($conf["external::callShell"]);
12112
				
12112
 
12113
		#如果執行失敗
12113
		#如果執行失敗
12114
		if($callShell["status"]==="false"){
12114
		if($callShell["status"]==="false"){
12115
			
12115
 
12116
			#設置執行失敗
12116
			#設置執行失敗
12117
			$result["status"]="false";
12117
			$result["status"]="false";
12118
			
12118
 
12119
			#設置執行錯誤訊息
12119
			#設置執行錯誤訊息
12120
			$result["error"]=$callShell;
12120
			$result["error"]=$callShell;
12121
			
12121
 
12122
			#回傳結果
12122
			#回傳結果
12123
			return $result;
12123
			return $result;
12124
			
12124
 
12125
			}#if end	
12125
			}#if end
12126
		
12126
 
12127
		#解析檔案資訊
12127
		#解析檔案資訊
12128
		#-rwxrwx--x. 1 apache apache 65K 2017-04-16 22:53:19.044545806 +0800 fileAccessT.php
12128
		#-rwxrwx--x. 1 apache apache 65K 2017-04-16 22:53:19.044545806 +0800 fileAccessT.php
12129
		
12129
 
12130
		#取得權限資訊 -rwxrwx--x
12130
		#取得權限資訊 -rwxrwx--x
12131
		$perm=substr($callShell["output"][0],0,strpos($callShell["output"][0],'.'));
12131
		$perm=substr($callShell["output"][0],0,strpos($callShell["output"][0],'.'));
12132
				
12132
 
12133
		#如果是目錄
12133
		#如果是目錄
12134
		if(substr($perm,0,1)==="d"){
12134
		if(substr($perm,0,1)==="d"){
12135
			
12135
 
12136
			#設定為目錄
12136
			#設定為目錄
12137
			$result["content"]["is_folder"]="true";
12137
			$result["content"]["is_folder"]="true";
12138
			
12138
 
12139
			}#if end
12139
			}#if end
12140
		
12140
 
12141
		#反之
12141
		#反之
12142
		else{
12142
		else{
12143
			
12143
 
12144
			#設定不為目錄
12144
			#設定不為目錄
12145
			$result["content"]["is_folder"]="false";
12145
			$result["content"]["is_folder"]="false";
12146
			
12146
 
12147
			}#else end
12147
			}#else end
12148
		
12148
 
12149
		#解析檔案擁有者權限資訊
12149
		#解析檔案擁有者權限資訊
12150
		$result["content"]["ownerPerm"]=substr($perm,1,3);
12150
		$result["content"]["ownerPerm"]=substr($perm,1,3);
12151
		
12151
 
12152
		#如果檔案擁有者名稱為空
12152
		#如果檔案擁有者名稱為空
12153
		if(empty($result["content"]["ownerPerm"])){
12153
		if(empty($result["content"]["ownerPerm"])){
12154
		
12154
 
12155
			#設置執行失敗
12155
			#設置執行失敗
12156
			$result["status"]="false";
12156
			$result["status"]="false";
12157
			
12157
 
12158
			#設置執行錯誤訊息
12158
			#設置執行錯誤訊息
12159
			$result["error"]=$callShell;
12159
			$result["error"]=$callShell;
12160
			
12160
 
12161
			#回傳結果
12161
			#回傳結果
12162
			return $result;
12162
			return $result;
12163
		
12163
 
12164
			}#if end
12164
			}#if end
12165
		
12165
 
12166
		#解析檔案歸屬群組權限資訊
12166
		#解析檔案歸屬群組權限資訊
12167
		$result["content"]["groupPerm"]=substr($perm,4,3);
12167
		$result["content"]["groupPerm"]=substr($perm,4,3);
12168
		
12168
 
12169
		#解析檔案對於其他身份使用者的權限資訊
12169
		#解析檔案對於其他身份使用者的權限資訊
12170
		$result["content"]["otherPerm"]=substr($perm,7,3);
12170
		$result["content"]["otherPerm"]=substr($perm,7,3);
12171
						
12171
 
12172
		#取得目錄底下的檔案目錄數量起始點
12172
		#取得目錄底下的檔案目錄數量起始點
12173
		$subElementStartPos=strpos($callShell["output"][0],' ');
12173
		$subElementStartPos=strpos($callShell["output"][0],' ');
12174
		
12174
 
12175
		#取得目錄底下的檔案目錄數量結束點
12175
		#取得目錄底下的檔案目錄數量結束點
12176
		$subElementEndPos=strpos($callShell["output"][0],' ',$subElementStartPos+1);
12176
		$subElementEndPos=strpos($callShell["output"][0],' ',$subElementStartPos+1);
12177
		
12177
 
12178
		#取得目錄底下的檔案目錄數量
12178
		#取得目錄底下的檔案目錄數量
12179
		$result["content"]["subElementCount"]=substr($callShell["output"][0],$subElementStartPos,$subElementEndPos-$subElementStartPos);
12179
		$result["content"]["subElementCount"]=substr($callShell["output"][0],$subElementStartPos,$subElementEndPos-$subElementStartPos);
12180
		
12180
 
12181
		#取得檔案擁有着資訊的起點
12181
		#取得檔案擁有着資訊的起點
12182
		$ownerNameStrPos=strpos($callShell["output"][0],' ',$subElementEndPos)+1;
12182
		$ownerNameStrPos=strpos($callShell["output"][0],' ',$subElementEndPos)+1;
12183
		
12183
 
12184
		#取得檔案擁有着資訊的結束點
12184
		#取得檔案擁有着資訊的結束點
12185
		$ownerNameEndPos=strpos($callShell["output"][0],' ',$ownerNameStrPos+1);
12185
		$ownerNameEndPos=strpos($callShell["output"][0],' ',$ownerNameStrPos+1);
12186
		
12186
 
12187
		#取得檔案擁有着資訊
12187
		#取得檔案擁有着資訊
12188
		$result["content"]["ownerName"]=substr($callShell["output"][0],$ownerNameStrPos,$ownerNameEndPos-$ownerNameStrPos);
12188
		$result["content"]["ownerName"]=substr($callShell["output"][0],$ownerNameStrPos,$ownerNameEndPos-$ownerNameStrPos);
12189
		
12189
 
12190
		#取取得檔案群組擁有者資訊的起點
12190
		#取取得檔案群組擁有者資訊的起點
12191
		$groupNameStrPos=strpos($callShell["output"][0],' ',$ownerNameEndPos)+1;
12191
		$groupNameStrPos=strpos($callShell["output"][0],' ',$ownerNameEndPos)+1;
12192
		
12192
 
12193
		#取得檔案群組擁有者資訊的結束點
12193
		#取得檔案群組擁有者資訊的結束點
12194
		$groupNameEndPos=strpos($callShell["output"][0],' ',$groupNameStrPos);
12194
		$groupNameEndPos=strpos($callShell["output"][0],' ',$groupNameStrPos);
12195
		
12195
 
12196
		#取得檔案群組擁有者資訊
12196
		#取得檔案群組擁有者資訊
12197
		$result["content"]["groupName"]=substr($callShell["output"][0],$groupNameStrPos,$groupNameEndPos-$groupNameStrPos);
12197
		$result["content"]["groupName"]=substr($callShell["output"][0],$groupNameStrPos,$groupNameEndPos-$groupNameStrPos);
12198
		
12198
 
12199
		#取得檔案大小的起點
12199
		#取得檔案大小的起點
12200
		$sizeStrPos=strpos($callShell["output"][0],' ',$groupNameEndPos)+1;
12200
		$sizeStrPos=strpos($callShell["output"][0],' ',$groupNameEndPos)+1;
12201
		
12201
 
12202
		#取得檔案大小的結束點
12202
		#取得檔案大小的結束點
12203
		$sizeEndPos=strpos($callShell["output"][0],' ',$sizeStrPos);
12203
		$sizeEndPos=strpos($callShell["output"][0],' ',$sizeStrPos);
12204
		
12204
 
12205
		#取得檔案大小
12205
		#取得檔案大小
12206
		$result["content"]["size"]=substr($callShell["output"][0],$sizeStrPos,$sizeEndPos-$sizeStrPos);
12206
		$result["content"]["size"]=substr($callShell["output"][0],$sizeStrPos,$sizeEndPos-$sizeStrPos);
12207
		
12207
 
12208
		#取得檔案變更年月日的起點
12208
		#取得檔案變更年月日的起點
12209
		$modifyDateStrPos=strpos($callShell["output"][0],' ',$sizeEndPos)+1;
12209
		$modifyDateStrPos=strpos($callShell["output"][0],' ',$sizeEndPos)+1;
12210
		
12210
 
12211
		#取得檔案變更年月日的結束點
12211
		#取得檔案變更年月日的結束點
12212
		$modifyDateEndPos=strpos($callShell["output"][0],' ',$modifyDateStrPos);
12212
		$modifyDateEndPos=strpos($callShell["output"][0],' ',$modifyDateStrPos);
12213
		
12213
 
12214
		#取得檔案變更年月日		
12214
		#取得檔案變更年月日
12215
		$result["content"]["modifyDate"]=substr($callShell["output"][0],$modifyDateStrPos,$modifyDateEndPos-$modifyDateStrPos);
12215
		$result["content"]["modifyDate"]=substr($callShell["output"][0],$modifyDateStrPos,$modifyDateEndPos-$modifyDateStrPos);
12216
		
12216
 
12217
		#取得檔案變更時分秒的起點
12217
		#取得檔案變更時分秒的起點
12218
		$modifyTimeStrPos=strpos($callShell["output"][0],' ',$modifyDateEndPos)+1;
12218
		$modifyTimeStrPos=strpos($callShell["output"][0],' ',$modifyDateEndPos)+1;
12219
		
12219
 
12220
		#取得檔案變更時分秒的結束點
12220
		#取得檔案變更時分秒的結束點
12221
		$modifyTimeEndPos=strpos($callShell["output"][0],'.',$modifyTimeStrPos);
12221
		$modifyTimeEndPos=strpos($callShell["output"][0],'.',$modifyTimeStrPos);
12222
		
12222
 
12223
		#取得檔案變更時分秒
12223
		#取得檔案變更時分秒
12224
		$result["content"]["modifyTime"]=substr($callShell["output"][0],$modifyTimeStrPos,$modifyTimeEndPos-$modifyTimeStrPos);
12224
		$result["content"]["modifyTime"]=substr($callShell["output"][0],$modifyTimeStrPos,$modifyTimeEndPos-$modifyTimeStrPos);
12225
			
12225
 
12226
		#取得檔版變更時間秒的float數值起點
12226
		#取得檔版變更時間秒的float數值起點
12227
		$modifyTimeFloatStrPos=strpos($callShell["output"][0],'.',$modifyTimeEndPos)+1;
12227
		$modifyTimeFloatStrPos=strpos($callShell["output"][0],'.',$modifyTimeEndPos)+1;
12228
			
12228
 
12229
		#取得檔版變更時間秒的float數值結束點
12229
		#取得檔版變更時間秒的float數值結束點
12230
		$modifyTimeFloatEndPos=strpos($callShell["output"][0],' ',$modifyTimeFloatStrPos);
12230
		$modifyTimeFloatEndPos=strpos($callShell["output"][0],' ',$modifyTimeFloatStrPos);
12231
			
12231
 
12232
		#取得檔版變更時間秒的float數值	
12232
		#取得檔版變更時間秒的float數值
12233
		$result["content"]["modifyTimeFloat"]=substr($callShell["output"][0],$modifyTimeFloatStrPos,$modifyTimeFloatEndPos-$modifyTimeFloatStrPos);
12233
		$result["content"]["modifyTimeFloat"]=substr($callShell["output"][0],$modifyTimeFloatStrPos,$modifyTimeFloatEndPos-$modifyTimeFloatStrPos);
12234
				
12234
 
12235
		#取得時區起始點
12235
		#取得時區起始點
12236
		$timezoneStrPos=strpos($callShell["output"][0],' ',$modifyTimeFloatEndPos)+1;
12236
		$timezoneStrPos=strpos($callShell["output"][0],' ',$modifyTimeFloatEndPos)+1;
12237
			
12237
 
12238
		#取得時區結束點
12238
		#取得時區結束點
12239
		$timezoneEndPos=strpos($callShell["output"][0],' ',$timezoneStrPos)+1;	
12239
		$timezoneEndPos=strpos($callShell["output"][0],' ',$timezoneStrPos)+1;
12240
			
12240
 
12241
		#取得檔案變更時間的時區與UTC的差距.
12241
		#取得檔案變更時間的時區與UTC的差距.
12242
		$result["content"]["timezone"]=substr($callShell["output"][0],$timezoneStrPos,$timezoneEndPos-$timezoneStrPos);			
12242
		$result["content"]["timezone"]=substr($callShell["output"][0],$timezoneStrPos,$timezoneEndPos-$timezoneStrPos);
12243
						
12243
 
12244
		#設置執行正常
12244
		#設置執行正常
12245
		$result["status"]="true";
12245
		$result["status"]="true";
12246
		
12246
 
12247
		#回傳結果
12247
		#回傳結果
12248
		return $result;
12248
		return $result;
12249
		
12249
 
12250
		}#function fileInfo end
12250
		}#function fileInfo end
12251
 
12251
 
12252
	/*
12252
	/*
12253
	#函式說明:
12253
	#函式說明:
12254
	#依據函數getListTree執行的結果,將其底下與其子目錄底下的特定檔案內容依據目錄層級輸出成html檔案 
12254
	#依據函數getListTree執行的結果,將其底下與其子目錄底下的特定檔案內容依據目錄層級輸出成html檔案
12255
	#回傳結果:
12255
	#回傳結果:
12256
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
12256
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
12257
	#$result["error"],錯誤訊息陣列.
12257
	#$result["error"],錯誤訊息陣列.
12258
	#$result["function"],函數名稱. 
12258
	#$result["function"],函數名稱.
12259
	#$result["content"],html檔案輸出的位置與名稱.
12259
	#$result["content"],html檔案輸出的位置與名稱.
12260
	#必填參數:
12260
	#必填參數:
12261
	#$conf["getListTree"],陣列變數,函數getListTree執行的結果.
12261
	#$conf["getListTree"],陣列變數,函數getListTree執行的結果.
12262
	$conf["getListTree"]=$getListTree;
12262
	$conf["getListTree"]=$getListTree;
12263
	#可省略參數:
12263
	#可省略參數:
12264
	#$conf["fileToRead"],字串,要讀取的檔案名稱為何?預設為"help".
12264
	#$conf["fileToRead"],字串,要讀取的檔案名稱為何?預設為"help".
12265
	#$conf["fileToRead"]="help";
12265
	#$conf["fileToRead"]="help";
12266
	#$conf["output"],字串,輸出的網頁檔案位置與名稱,副檔名html會自動補上,預設為"help".
12266
	#$conf["output"],字串,輸出的網頁檔案位置與名稱,副檔名html會自動補上,預設為"help".
12267
	#$conf["output"]="help.html"; 
12267
	#$conf["output"]="help.html";
12268
	#參考資料:
12268
	#參考資料:
12269
	#無.
12269
	#無.
12270
	#備註:
12270
	#備註:
12271
	#建構中...
12271
	#建構中...
12272
	*/
12272
	*/
12273
	public static function createHelpFile($conf){
12273
	public static function createHelpFile($conf){
12274
		
12274
 
12275
		#初始化要回傳的結果
12275
		#初始化要回傳的結果
12276
		$result=array();
12276
		$result=array();
12277
		
12277
 
12278
		#設置當其函數名稱
12278
		#設置當其函數名稱
12279
		$result["function"]=__FUNCTION__;
12279
		$result["function"]=__FUNCTION__;
12280
		
12280
 
12281
		#如果 $conf 不為陣列
12281
		#如果 $conf 不為陣列
12282
		if(gettype($conf)!="array"){
12282
		if(gettype($conf)!="array"){
12283
			
12283
 
12284
			#設置執行失敗
12284
			#設置執行失敗
12285
			$result["status"]="false";
12285
			$result["status"]="false";
12286
			
12286
 
12287
			#設置執行錯誤訊息
12287
			#設置執行錯誤訊息
12288
			$result["error"][]="\$conf變數須為陣列形態";
12288
			$result["error"][]="\$conf變數須為陣列形態";
12289
 
12289
 
12290
			#如果傳入的參數為 null
12290
			#如果傳入的參數為 null
12291
			if($conf==null){
12291
			if($conf==null){
12292
				
12292
 
12293
				#設置執行錯誤訊息
12293
				#設置執行錯誤訊息
12294
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
12294
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
12295
				
12295
 
12296
				}#if end
12296
				}#if end
12297
 
12297
 
12298
			#回傳結果
12298
			#回傳結果
12299
			return $result;
12299
			return $result;
12300
			
12300
 
12301
			}#if end
12301
			}#if end
12302
			
12302
 
12303
		#檢查參數
12303
		#檢查參數
12304
		#函式說明:
12304
		#函式說明:
12305
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
12305
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
12306
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12306
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12307
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
12307
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 12316... Line 12316...
12316
		#必填寫的參數:
12316
		#必填寫的參數:
12317
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
12317
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
12318
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
12318
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
12319
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
12319
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
12320
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("getListTree");
12320
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("getListTree");
12321
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
12321
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
12322
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");
12322
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");
12323
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
12323
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
12324
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
12324
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
12325
		#可以省略的參數:
12325
		#可以省略的參數:
12326
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
12326
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
12327
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
12327
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
12328
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
12328
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
12329
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileToRead","output");
12329
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileToRead","output");
12330
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
12330
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
12331
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
12331
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
12332
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
12332
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
12333
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("help","help");
12333
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("help","help");
12334
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
12334
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
12335
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
12335
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
12336
		#參考資料來源:
12336
		#參考資料來源:
12337
		#array_keys=>http://php.net/manual/en/function.array-keys.php
12337
		#array_keys=>http://php.net/manual/en/function.array-keys.php
12338
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
12338
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
12339
		unset($conf["variableCheck::checkArguments"]);
12339
		unset($conf["variableCheck::checkArguments"]);
12340
		
12340
 
12341
		#如果 $checkResult["status"] 等於 "fasle"
12341
		#如果 $checkResult["status"] 等於 "fasle"
12342
		if($checkResult["status"]=="false"){
12342
		if($checkResult["status"]=="false"){
12343
			
12343
 
12344
			#設置錯誤識別
12344
			#設置錯誤識別
12345
			$result["status"]="false";
12345
			$result["status"]="false";
12346
			
12346
 
12347
			#設置錯誤訊息
12347
			#設置錯誤訊息
12348
			$result["error"]=$checkResult;
12348
			$result["error"]=$checkResult;
12349
			
12349
 
12350
			#回傳結果
12350
			#回傳結果
12351
			return $result;
12351
			return $result;
12352
			
12352
 
12353
			}#if end
12353
			}#if end
12354
			
12354
 
12355
		#如果 $checkResult["passed"] 等於 "fasle"
12355
		#如果 $checkResult["passed"] 等於 "fasle"
12356
		if($checkResult["passed"]=="false"){
12356
		if($checkResult["passed"]=="false"){
12357
			
12357
 
12358
			#設置錯誤識別
12358
			#設置錯誤識別
12359
			$result["status"]="false";
12359
			$result["status"]="false";
12360
			
12360
 
12361
			#設置錯誤訊息
12361
			#設置錯誤訊息
12362
			$result["error"]=$checkResult;
12362
			$result["error"]=$checkResult;
12363
			
12363
 
12364
			#回傳結果
12364
			#回傳結果
12365
			return $result;
12365
			return $result;
12366
			
12366
 
12367
			}#if end
12367
			}#if end
12368
		
12368
 
12369
		#如果 $conf["getListTree"]["status"] 不存在
12369
		#如果 $conf["getListTree"]["status"] 不存在
12370
		if(!isset($conf["getListTree"]["status"])){
12370
		if(!isset($conf["getListTree"]["status"])){
12371
			
12371
 
12372
			#設置錯誤識別
12372
			#設置錯誤識別
12373
			$result["status"]="false";
12373
			$result["status"]="false";
12374
			
12374
 
12375
			#設置錯誤訊息
12375
			#設置錯誤訊息
12376
			$result["error"][]="getListTree參數必須為getListTree函數執行後的結果";
12376
			$result["error"][]="getListTree參數必須為getListTree函數執行後的結果";
12377
			
12377
 
12378
			#回傳結果
12378
			#回傳結果
12379
			return $result;
12379
			return $result;
12380
			
12380
 
12381
			}#if end
12381
			}#if end
12382
			
12382
 
12383
		#如果 $conf["getListTree"] 執行失敗
12383
		#如果 $conf["getListTree"] 執行失敗
12384
		if($conf["getListTree"]["status"]=="false"){
12384
		if($conf["getListTree"]["status"]=="false"){
12385
			
12385
 
12386
			#設置錯誤識別
12386
			#設置錯誤識別
12387
			$result["status"]="false";
12387
			$result["status"]="false";
12388
			
12388
 
12389
			#設置錯誤訊息
12389
			#設置錯誤訊息
12390
			$result["error"]=$conf["getListTree"];
12390
			$result["error"]=$conf["getListTree"];
12391
			
12391
 
12392
			#回傳結果
12392
			#回傳結果
12393
			return $result;
12393
			return $result;
12394
			
12394
 
12395
			}#if end
12395
			}#if end
12396
			
12396
 
12397
		#如果有目錄檔案
12397
		#如果有目錄檔案
12398
		if(isset($conf["getListTree"]["content"])){
12398
		if(isset($conf["getListTree"]["content"])){
12399
			
12399
 
12400
			
12400
 
12401
			
12401
 
12402
			}#if end
12402
			}#if end
12403
		
12403
 
12404
		}#function createHelpFile end
12404
		}#function createHelpFile end
12405
		
12405
 
12406
	/*
12406
	/*
12407
	#函式說明:
12407
	#函式說明:
12408
	#嵌入pdf檔案到網頁上面
12408
	#嵌入pdf檔案到網頁上面
12409
	#回傳結果:
12409
	#回傳結果:
12410
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
12410
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
12411
	#$result["error"],錯誤訊息陣列.
12411
	#$result["error"],錯誤訊息陣列.
12412
	#$result["function"],函數名稱. 
12412
	#$result["function"],函數名稱.
12413
	#$result["content"],嵌入pdf檔案的語法
12413
	#$result["content"],嵌入pdf檔案的語法
12414
	#必填參數:
12414
	#必填參數:
12415
	#$conf["fileArgu"],字串,當前檔案的位置亦即__FILE__的內容.
12415
	#$conf["fileArgu"],字串,當前檔案的位置亦即__FILE__的內容.
12416
	$conf["fileArgu"]=__FILE__;
12416
	$conf["fileArgu"]=__FILE__;
12417
	#$conf["file"],字串,pdf檔案位置.
12417
	#$conf["file"],字串,pdf檔案位置.
Line 12423... Line 12423...
12423
	#嵌入pdf到網頁=>https://stackoverflow.com/questions/14690000/embed-a-pdf-in-html5
12423
	#嵌入pdf到網頁=>https://stackoverflow.com/questions/14690000/embed-a-pdf-in-html5
12424
	#備註:
12424
	#備註:
12425
	#如果是網址就會出錯.
12425
	#如果是網址就會出錯.
12426
	*/
12426
	*/
12427
	public static function embedPdf(&$conf=array()){
12427
	public static function embedPdf(&$conf=array()){
12428
		
12428
 
12429
		#初始化要回傳的結果
12429
		#初始化要回傳的結果
12430
		$result=array();
12430
		$result=array();
12431
 
12431
 
12432
		#取得當前執行的函數名稱
12432
		#取得當前執行的函數名稱
12433
		$result["function"]=__FUNCTION__;
12433
		$result["function"]=__FUNCTION__;
12434
 
12434
 
12435
		#如果沒有參數
12435
		#如果沒有參數
12436
		if(func_num_args()==0){
12436
		if(func_num_args()==0){
12437
			
12437
 
12438
			#設置執行失敗
12438
			#設置執行失敗
12439
			$result["status"]="false";
12439
			$result["status"]="false";
12440
			
12440
 
12441
			#設置執行錯誤訊息
12441
			#設置執行錯誤訊息
12442
			$result["error"]="函數".$result["function"]."需要參數";
12442
			$result["error"]="函數".$result["function"]."需要參數";
12443
			
12443
 
12444
			#回傳結果
12444
			#回傳結果
12445
			return $result;
12445
			return $result;
12446
			
12446
 
12447
			}#if end
12447
			}#if end
12448
 
12448
 
12449
		#取得參數
12449
		#取得參數
12450
		$result["argu"]=$conf;
12450
		$result["argu"]=$conf;
12451
 
12451
 
12452
		#如果 $conf 不為陣列
12452
		#如果 $conf 不為陣列
12453
		if(gettype($conf)!=="array"){
12453
		if(gettype($conf)!=="array"){
12454
			
12454
 
12455
			#設置執行失敗
12455
			#設置執行失敗
12456
			$result["status"]="false";
12456
			$result["status"]="false";
12457
			
12457
 
12458
			#設置執行錯誤訊息
12458
			#設置執行錯誤訊息
12459
			$result["error"][]="\$conf變數須為陣列形態";
12459
			$result["error"][]="\$conf變數須為陣列形態";
12460
			
12460
 
12461
			#如果傳入的參數為 null
12461
			#如果傳入的參數為 null
12462
			if($conf===null){
12462
			if($conf===null){
12463
				
12463
 
12464
				#設置執行錯誤訊息
12464
				#設置執行錯誤訊息
12465
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
12465
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
12466
				
12466
 
12467
				}#if end
12467
				}#if end
12468
 
12468
 
12469
			#回傳結果
12469
			#回傳結果
12470
			return $result;
12470
			return $result;
12471
			
12471
 
12472
			}#if end
12472
			}#if end
12473
		
12473
 
12474
		#檢查參數
12474
		#檢查參數
12475
		#函式說明:
12475
		#函式說明:
12476
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
12476
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
12477
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12477
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12478
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
12478
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 12503... Line 12503...
12503
		#$conf["canBeEmpty"]=array();
12503
		#$conf["canBeEmpty"]=array();
12504
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
12504
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
12505
		#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("width","height");
12505
		#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("width","height");
12506
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
12506
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
12507
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("type");
12507
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("type");
12508
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
12508
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
12509
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
12509
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
12510
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
12510
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
12511
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("iframe");
12511
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("iframe");
12512
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
12512
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
12513
		#$conf["arrayCountEqualCheck"][]=array();
12513
		#$conf["arrayCountEqualCheck"][]=array();
12514
		#參考資料來源:
12514
		#參考資料來源:
12515
		#array_keys=>http://php.net/manual/en/function.array-keys.php
12515
		#array_keys=>http://php.net/manual/en/function.array-keys.php
12516
		#建議:
12516
		#建議:
12517
		#增加可省略參數全部不能為空字串或空陣列的參數功能.
12517
		#增加可省略參數全部不能為空字串或空陣列的參數功能.
12518
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
12518
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
12519
		unset($conf["variableCheck::checkArguments"]);		
12519
		unset($conf["variableCheck::checkArguments"]);
12520
		
12520
 
12521
		#如果檢查參數失敗
12521
		#如果檢查參數失敗
12522
		if($checkArguments["status"]==="false"){
12522
		if($checkArguments["status"]==="false"){
12523
			
12523
 
12524
			#設置執行失敗
12524
			#設置執行失敗
12525
			$result["status"]="false";
12525
			$result["status"]="false";
12526
			
12526
 
12527
			#設置執行錯誤訊息
12527
			#設置執行錯誤訊息
12528
			$result["error"]=$checkArguments;
12528
			$result["error"]=$checkArguments;
12529
			
12529
 
12530
			#回傳結果
12530
			#回傳結果
12531
			return $result;
12531
			return $result;
12532
			
12532
 
12533
			}#if end
12533
			}#if end
12534
		
12534
 
12535
		#如果參數檢查不通過
12535
		#如果參數檢查不通過
12536
		if($checkArguments["passed"]==="false"){
12536
		if($checkArguments["passed"]==="false"){
12537
			
12537
 
12538
			#設置執行失敗
12538
			#設置執行失敗
12539
			$result["status"]="false";
12539
			$result["status"]="false";
12540
			
12540
 
12541
			#設置執行錯誤訊息
12541
			#設置執行錯誤訊息
12542
			$result["error"]=$checkArguments;
12542
			$result["error"]=$checkArguments;
12543
			
12543
 
12544
			#回傳結果
12544
			#回傳結果
12545
			return $result;
12545
			return $result;
12546
			
12546
 
12547
			}#if end
12547
			}#if end
12548
		
12548
 
12549
		#檢查檔案是否存在
12549
		#檢查檔案是否存在
12550
		#函式說明:
12550
		#函式說明:
12551
		#檢查多個檔案與資料夾是否存在.
12551
		#檢查多個檔案與資料夾是否存在.
12552
		#回傳的結果:
12552
		#回傳的結果:
12553
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
12553
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 12574... Line 12574...
12574
		#http://php.net/manual/en/control-structures.foreach.php
12574
		#http://php.net/manual/en/control-structures.foreach.php
12575
		#備註:
12575
		#備註:
12576
		#函數file_exists檢查的路徑為檔案系統的路徑
12576
		#函數file_exists檢查的路徑為檔案系統的路徑
12577
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
12577
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
12578
		unset($conf["fileAccess::checkMultiFileExist"]);
12578
		unset($conf["fileAccess::checkMultiFileExist"]);
12579
		
12579
 
12580
		#如果檢查檔案是否存在失敗
12580
		#如果檢查檔案是否存在失敗
12581
		if($checkMultiFileExist["status"]==="false"){
12581
		if($checkMultiFileExist["status"]==="false"){
12582
			
12582
 
12583
			#設置執行失敗
12583
			#設置執行失敗
12584
			$result["status"]="false";
12584
			$result["status"]="false";
12585
			
12585
 
12586
			#設置執行錯誤訊息
12586
			#設置執行錯誤訊息
12587
			$result["error"]=$checkMultiFileExist;
12587
			$result["error"]=$checkMultiFileExist;
12588
			
12588
 
12589
			#回傳結果
12589
			#回傳結果
12590
			return $result;
12590
			return $result;
12591
			
12591
 
12592
			}#if end
12592
			}#if end
12593
			
12593
 
12594
		#如果檔案不存在
12594
		#如果檔案不存在
12595
		if($checkMultiFileExist["allExist"]==="false"){
12595
		if($checkMultiFileExist["allExist"]==="false"){
12596
			
12596
 
12597
			#設置執行失敗
12597
			#設置執行失敗
12598
			$result["status"]="false";
12598
			$result["status"]="false";
12599
			
12599
 
12600
			#設置執行錯誤訊息
12600
			#設置執行錯誤訊息
12601
			$result["error"]=$checkMultiFileExist;
12601
			$result["error"]=$checkMultiFileExist;
12602
			
12602
 
12603
			#回傳結果
12603
			#回傳結果
12604
			return $result;
12604
			return $result;
12605
			
12605
 
12606
			}#if end
12606
			}#if end
12607
		
12607
 
12608
		#產生 base64 的 pdf 編碼字串
12608
		#產生 base64 的 pdf 編碼字串
12609
		$base64pdf=base64_encode(file_get_contents($conf["file"]));
12609
		$base64pdf=base64_encode(file_get_contents($conf["file"]));
12610
		
12610
 
12611
		#產生 base64 的 pdf 編碼字串 data
12611
		#產生 base64 的 pdf 編碼字串 data
12612
		$base64pdfData="data:application/pdf;base64,".$base64pdf;
12612
		$base64pdfData="data:application/pdf;base64,".$base64pdf;
12613
		
12613
 
12614
		#判斷要用哪種方式嵌入pdf
12614
		#判斷要用哪種方式嵌入pdf
12615
		switch($conf["type"]){
12615
		switch($conf["type"]){
12616
			
12616
 
12617
			#如果是用 object 方式
12617
			#如果是用 object 方式
12618
			case "object":
12618
			case "object":
12619
			
12619
 
12620
				#產生嵌入的語法
12620
				#產生嵌入的語法
12621
				$embedSyntax="<object style=\"width:100%;height:100%;\" data=\"".$base64pdfData."\"></object>";
12621
				$embedSyntax="<object style=\"width:100%;height:100%;\" data=\"".$base64pdfData."\"></object>";
12622
			
12622
 
12623
				#取得語法
12623
				#取得語法
12624
				$result["content"]=&$embedSyntax;
12624
				$result["content"]=&$embedSyntax;
12625
			
12625
 
12626
				#跳出 switch
12626
				#跳出 switch
12627
				break;
12627
				break;
12628
			
12628
 
12629
			#預設
12629
			#預設
12630
			default:
12630
			default:
12631
			
12631
 
12632
				#產生嵌入的語法
12632
				#產生嵌入的語法
12633
				$embedSyntax="<iframe style=\"width:100%;height:100%;\" src=\"".$base64pdfData."\"></iframe>";
12633
				$embedSyntax="<iframe style=\"width:100%;height:100%;\" src=\"".$base64pdfData."\"></iframe>";
12634
			
12634
 
12635
				#取得語法
12635
				#取得語法
12636
				$result["content"]=&$embedSyntax;
12636
				$result["content"]=&$embedSyntax;
12637
			
12637
 
12638
			}#switch end
12638
			}#switch end
12639
		
12639
 
12640
		#設置執行正常
12640
		#設置執行正常
12641
		$result["status"]="true";
12641
		$result["status"]="true";
12642
		
12642
 
12643
		#回傳結果
12643
		#回傳結果
12644
		return $result;
12644
		return $result;
12645
		
12645
 
12646
		}#function embedPdf end
12646
		}#function embedPdf end
12647
		
12647
 
12648
	/*
12648
	/*
12649
	#函式說明:
12649
	#函式說明:
12650
	#用linux unzip去解壓縮zip檔案 
12650
	#用linux unzip去解壓縮zip檔案
12651
	#回傳結果:
12651
	#回傳結果:
12652
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12652
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12653
	#$result["error"],錯誤訊息.
12653
	#$result["error"],錯誤訊息.
12654
	#$result["function"],當前執行的函數名稱.
12654
	#$result["function"],當前執行的函數名稱.
12655
	#$result["content"]["each"],每個檔案的資訊.
12655
	#$result["content"]["each"],每個檔案的資訊.
Line 12676... Line 12676...
12676
	#$conf["extract"]="";
12676
	#$conf["extract"]="";
12677
	#備註:
12677
	#備註:
12678
	#建議加上特定邊碼的支援例如、單
12678
	#建議加上特定邊碼的支援例如、單
12679
	*/
12679
	*/
12680
	public static function unzip(&$conf=array()){
12680
	public static function unzip(&$conf=array()){
12681
		
12681
 
12682
		#初始化要回傳的結果
12682
		#初始化要回傳的結果
12683
		$result=array();
12683
		$result=array();
12684
 
12684
 
12685
		#取得當前執行的函數名稱
12685
		#取得當前執行的函數名稱
12686
		$result["function"]=__FUNCTION__;
12686
		$result["function"]=__FUNCTION__;
12687
 
12687
 
12688
		#如果沒有參數
12688
		#如果沒有參數
12689
		if(func_num_args()==0){
12689
		if(func_num_args()==0){
12690
			
12690
 
12691
			#設置執行失敗
12691
			#設置執行失敗
12692
			$result["status"]="false";
12692
			$result["status"]="false";
12693
			
12693
 
12694
			#設置執行錯誤訊息
12694
			#設置執行錯誤訊息
12695
			$result["error"]="函數".$result["function"]."需要參數";
12695
			$result["error"]="函數".$result["function"]."需要參數";
12696
			
12696
 
12697
			#回傳結果
12697
			#回傳結果
12698
			return $result;
12698
			return $result;
12699
			
12699
 
12700
			}#if end
12700
			}#if end
12701
		
12701
 
12702
		#取得參數
12702
		#取得參數
12703
		$result["argu"]=$conf;
12703
		$result["argu"]=$conf;
12704
 
12704
 
12705
		#如果 $conf 不為陣列
12705
		#如果 $conf 不為陣列
12706
		if(gettype($conf)!=="array"){
12706
		if(gettype($conf)!=="array"){
12707
			
12707
 
12708
			#設置執行失敗
12708
			#設置執行失敗
12709
			$result["status"]="false";
12709
			$result["status"]="false";
12710
			
12710
 
12711
			#設置執行錯誤訊息
12711
			#設置執行錯誤訊息
12712
			$result["error"][]="\$conf變數須為陣列形態";
12712
			$result["error"][]="\$conf變數須為陣列形態";
12713
			
12713
 
12714
			#如果傳入的參數為 null
12714
			#如果傳入的參數為 null
12715
			if($conf===null){
12715
			if($conf===null){
12716
				
12716
 
12717
				#設置執行錯誤訊息
12717
				#設置執行錯誤訊息
12718
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
12718
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
12719
				
12719
 
12720
				}#if end
12720
				}#if end
12721
 
12721
 
12722
			#回傳結果
12722
			#回傳結果
12723
			return $result;
12723
			return $result;
12724
			
12724
 
12725
			}#if end
12725
			}#if end
12726
			
12726
 
12727
		#檢查參數
12727
		#檢查參數
12728
		#函式說明:
12728
		#函式說明:
12729
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
12729
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
12730
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12730
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12731
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
12731
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 12739... Line 12739...
12739
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
12739
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
12740
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
12740
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
12741
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
12741
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
12742
		#必填寫的參數:
12742
		#必填寫的參數:
12743
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
12743
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
12744
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
12744
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
12745
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
12745
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
12746
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
12746
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
12747
		#可以省略的參數:
12747
		#可以省略的參數:
12748
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
12748
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
12749
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("zip","fileArgu");
12749
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("zip","fileArgu");
Line 12757... Line 12757...
12757
		#$conf["canBeEmpty"]=array();
12757
		#$conf["canBeEmpty"]=array();
12758
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
12758
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
12759
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("extract");
12759
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("extract");
12760
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
12760
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
12761
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("extract");
12761
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("extract");
12762
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
12762
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
12763
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
12763
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
12764
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
12764
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
12765
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("./");
12765
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("./");
12766
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
12766
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
12767
		#$conf["disallowAllSkipableVarIsEmpty"]="";
12767
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 12771... Line 12771...
12771
		#$conf["arrayCountEqualCheck"][]=array();
12771
		#$conf["arrayCountEqualCheck"][]=array();
12772
		#參考資料來源:
12772
		#參考資料來源:
12773
		#array_keys=>http://php.net/manual/en/function.array-keys.php
12773
		#array_keys=>http://php.net/manual/en/function.array-keys.php
12774
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
12774
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
12775
		unset($conf["variableCheck::checkArguments"]);
12775
		unset($conf["variableCheck::checkArguments"]);
12776
		
12776
 
12777
		#如果檢查參數失敗
12777
		#如果檢查參數失敗
12778
		if($checkArguments["status"]==="false"){
12778
		if($checkArguments["status"]==="false"){
12779
			
12779
 
12780
			#設置執行不正常
12780
			#設置執行不正常
12781
			$result["status"]="false";
12781
			$result["status"]="false";
12782
			
12782
 
12783
			#設置錯誤訊息
12783
			#設置錯誤訊息
12784
			$result["error"]=$checkArguments;
12784
			$result["error"]=$checkArguments;
12785
			
12785
 
12786
			#回傳結果
12786
			#回傳結果
12787
			return $result;
12787
			return $result;
12788
			
12788
 
12789
			}#if end
12789
			}#if end
12790
			
12790
 
12791
		#如果檢查參數不通過
12791
		#如果檢查參數不通過
12792
		if($checkArguments["passed"]==="false"){
12792
		if($checkArguments["passed"]==="false"){
12793
			
12793
 
12794
			#設置執行不正常
12794
			#設置執行不正常
12795
			$result["status"]="false";
12795
			$result["status"]="false";
12796
			
12796
 
12797
			#設置錯誤訊息
12797
			#設置錯誤訊息
12798
			$result["error"]=$checkArguments;
12798
			$result["error"]=$checkArguments;
12799
			
12799
 
12800
			#回傳結果
12800
			#回傳結果
12801
			return $result;
12801
			return $result;
12802
			
12802
 
12803
			}#if end
12803
			}#if end
12804
		
12804
 
12805
		#檢查要解壓縮的檔案是否存在
12805
		#檢查要解壓縮的檔案是否存在
12806
		#函式說明:
12806
		#函式說明:
12807
		#檢查多個檔案與資料夾是否存在.
12807
		#檢查多個檔案與資料夾是否存在.
12808
		#回傳的結果:
12808
		#回傳的結果:
12809
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
12809
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 12830... Line 12830...
12830
		#http://php.net/manual/en/control-structures.foreach.php
12830
		#http://php.net/manual/en/control-structures.foreach.php
12831
		#備註:
12831
		#備註:
12832
		#函數file_exists檢查的路徑為檔案系統的路徑
12832
		#函數file_exists檢查的路徑為檔案系統的路徑
12833
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
12833
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
12834
		unset($conf["fileAccess::checkMultiFileExist"]);
12834
		unset($conf["fileAccess::checkMultiFileExist"]);
12835
		
12835
 
12836
		#如果檢查檔案是否存在失敗
12836
		#如果檢查檔案是否存在失敗
12837
		if($checkMultiFileExist["status"]==="false"){
12837
		if($checkMultiFileExist["status"]==="false"){
12838
			
12838
 
12839
			#設置執行不正常
12839
			#設置執行不正常
12840
			$result["status"]="false";
12840
			$result["status"]="false";
12841
			
12841
 
12842
			#設置錯誤訊息
12842
			#設置錯誤訊息
12843
			$result["error"]=$checkMultiFileExist;
12843
			$result["error"]=$checkMultiFileExist;
12844
			
12844
 
12845
			#回傳結果
12845
			#回傳結果
12846
			return $result;
12846
			return $result;
12847
			
12847
 
12848
			}#if end
12848
			}#if end
12849
			
12849
 
12850
		#如果要解壓縮的檔案不存在
12850
		#如果要解壓縮的檔案不存在
12851
		if($checkMultiFileExist["allExist"]==="false"){
12851
		if($checkMultiFileExist["allExist"]==="false"){
12852
			
12852
 
12853
			#設置執行不正常
12853
			#設置執行不正常
12854
			$result["status"]="false";
12854
			$result["status"]="false";
12855
			
12855
 
12856
			#設置錯誤訊息
12856
			#設置錯誤訊息
12857
			$result["error"]=$checkMultiFileExist;
12857
			$result["error"]=$checkMultiFileExist;
12858
			
12858
 
12859
			#回傳結果
12859
			#回傳結果
12860
			return $result;
12860
			return $result;
12861
			
12861
 
12862
			}#if end
12862
			}#if end
12863
			
12863
 
12864
		#函式說明:
12864
		#函式說明:
12865
		#呼叫shell執行系統命令,並取得回傳的內容.
12865
		#呼叫shell執行系統命令,並取得回傳的內容.
12866
		#回傳結果:
12866
		#回傳結果:
12867
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12867
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12868
		#$result["error"],錯誤訊息陣列.
12868
		#$result["error"],錯誤訊息陣列.
Line 12876... Line 12876...
12876
		#$result["pid"],pid
12876
		#$result["pid"],pid
12877
		#必填參數:
12877
		#必填參數:
12878
		#$conf["command"],字串,要執行的指令與.
12878
		#$conf["command"],字串,要執行的指令與.
12879
		$conf["external::callShell"]["command"]="unzip";
12879
		$conf["external::callShell"]["command"]="unzip";
12880
		#$conf["fileArgu"],字串,變數__FILE__的內容.
12880
		#$conf["fileArgu"],字串,變數__FILE__的內容.
12881
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
12881
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
12882
		#可省略參數:
12882
		#可省略參數:
12883
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
12883
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
12884
		$conf["external::callShell"]["argu"]=array("-d",$conf["extract"],"-o","-q",$conf["zip"]);
12884
		$conf["external::callShell"]["argu"]=array("-d",$conf["extract"],"-o","-q",$conf["zip"]);
12885
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
12885
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
12886
		#$conf["arguIsAddr"]=array();
12886
		#$conf["arguIsAddr"]=array();
Line 12906... Line 12906...
12906
		#exec=>http://php.net/manual/en/function.exec.php
12906
		#exec=>http://php.net/manual/en/function.exec.php
12907
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
12907
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
12908
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
12908
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
12909
		$callShell=external::callShell($conf["external::callShell"]);
12909
		$callShell=external::callShell($conf["external::callShell"]);
12910
		unset($conf["external::callShell"]);
12910
		unset($conf["external::callShell"]);
12911
		
12911
 
12912
		#如果執行cmd失敗
12912
		#如果執行cmd失敗
12913
		if($callShell["status"]==="false"){
12913
		if($callShell["status"]==="false"){
12914
			
12914
 
12915
			#設置執行不正常
12915
			#設置執行不正常
12916
			$result["status"]="false";
12916
			$result["status"]="false";
12917
			
12917
 
12918
			#設置錯誤訊息
12918
			#設置錯誤訊息
12919
			$result["error"]=$callShell;
12919
			$result["error"]=$callShell;
12920
			
12920
 
12921
			#回傳結果
12921
			#回傳結果
12922
			return $result;
12922
			return $result;
12923
			
12923
 
12924
			}#if end
12924
			}#if end
12925
			
12925
 
12926
		#函式說明:
12926
		#函式說明:
12927
		#呼叫shell執行系統命令,並取得回傳的內容.
12927
		#呼叫shell執行系統命令,並取得回傳的內容.
12928
		#回傳的結果:
12928
		#回傳的結果:
12929
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12929
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12930
		#$result["error"],錯誤訊息陣列.
12930
		#$result["error"],錯誤訊息陣列.
Line 12938... Line 12938...
12938
		#$result["pid"],pid
12938
		#$result["pid"],pid
12939
		#必填的參數
12939
		#必填的參數
12940
		#$conf["command"],字串,要執行的指令與.
12940
		#$conf["command"],字串,要執行的指令與.
12941
		$conf["external::callShell"]["command"]="unzip";
12941
		$conf["external::callShell"]["command"]="unzip";
12942
		#$conf["fileArgu"],字串,變數__FILE__的內容.
12942
		#$conf["fileArgu"],字串,變數__FILE__的內容.
12943
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
12943
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
12944
		#可省略參數:
12944
		#可省略參數:
12945
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
12945
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
12946
		$conf["external::callShell"]["argu"]=array("-v",$conf["zip"]);
12946
		$conf["external::callShell"]["argu"]=array("-v",$conf["zip"]);
12947
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
12947
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
12948
		#$conf["arguIsAddr"]=array();
12948
		#$conf["arguIsAddr"]=array();
Line 12968... Line 12968...
12968
		#exec=>http://php.net/manual/en/function.exec.php
12968
		#exec=>http://php.net/manual/en/function.exec.php
12969
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
12969
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
12970
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
12970
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
12971
		$callShell=external::callShell($conf["external::callShell"]);
12971
		$callShell=external::callShell($conf["external::callShell"]);
12972
		unset($conf["external::callShell"]);
12972
		unset($conf["external::callShell"]);
12973
		
12973
 
12974
		#如果執行cmd失敗
12974
		#如果執行cmd失敗
12975
		if($callShell["status"]==="false"){
12975
		if($callShell["status"]==="false"){
12976
			
12976
 
12977
			#設置執行不正常
12977
			#設置執行不正常
12978
			$result["status"]="false";
12978
			$result["status"]="false";
12979
			
12979
 
12980
			#設置錯誤訊息
12980
			#設置錯誤訊息
12981
			$result["error"]=$callShell;
12981
			$result["error"]=$callShell;
12982
			
12982
 
12983
			#回傳結果
12983
			#回傳結果
12984
			return $result;
12984
			return $result;
12985
			
12985
 
12986
			}#if end	
12986
			}#if end
12987
			
12987
 
12988
		#取得輸出的內容陣列
12988
		#取得輸出的內容陣列
12989
		$unzipInfo=$callShell["output"];
12989
		$unzipInfo=$callShell["output"];
12990
		
12990
 
12991
		/*
12991
		/*
12992
		
12992
 
12993
		 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
12993
		 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
12994
		--------  ------  ------- ---- ---------- ----- --------  ----
12994
		--------  ------  ------- ---- ---------- ----- --------  ----
12995
		 4194304  Defl:X  2507269  40% 05-04-2002 17:30 9386a740  PS2 Bios 30004R V6 Pal.bin
12995
		 4194304  Defl:X  2507269  40% 05-04-2002 17:30 9386a740  PS2 Bios 30004R V6 Pal.bin
12996
			   4  Defl:X        6 -50% 05-15-2005 06:45 054a6ec2  PS2 Bios 30004R V6 Pal.MEC
12996
			   4  Defl:X        6 -50% 05-15-2005 06:45 054a6ec2  PS2 Bios 30004R V6 Pal.MEC
12997
			1024  Defl:X       22  98% 06-25-2005 14:55 3493bb06  PS2 Bios 30004R V6 Pal.NVM
12997
			1024  Defl:X       22  98% 06-25-2005 14:55 3493bb06  PS2 Bios 30004R V6 Pal.NVM
Line 13006... Line 13006...
13006
		 4194304  Defl:X  2511182  40% 06-27-2003 10:51 a19e0bf5  scph39001.bin
13006
		 4194304  Defl:X  2511182  40% 06-27-2003 10:51 a19e0bf5  scph39001.bin
13007
			   4  Defl:X        6 -50% 05-14-2005 16:00 054a6ec2  scph39001.MEC
13007
			   4  Defl:X        6 -50% 05-14-2005 16:00 054a6ec2  scph39001.MEC
13008
			1024  Defl:X       20  98% 05-31-2005 16:09 e14a6cd6  scph39001.NVM
13008
			1024  Defl:X       20  98% 05-31-2005 16:09 e14a6cd6  scph39001.NVM
13009
		--------          -------  ---                            -------
13009
		--------          -------  ---                            -------
13010
		21175304         13378622  37%                            14 files
13010
		21175304         13378622  37%                            14 files
13011
		 
13011
 
13012
		*/
13012
		*/
13013
				
13013
 
13014
		#取得行數
13014
		#取得行數
13015
		$lineCount=count($unzipInfo);
13015
		$lineCount=count($unzipInfo);
13016
		
13016
 
13017
		#取得標題
13017
		#取得標題
13018
		#函式說明:
13018
		#函式說明:
13019
		#將固定格式的字串分開,並回傳分開的結果。
13019
		#將固定格式的字串分開,並回傳分開的結果。
13020
		#回傳結果:
13020
		#回傳結果:
13021
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13021
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 13031... Line 13031...
13031
		#可省略參數:
13031
		#可省略參數:
13032
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
13032
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
13033
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
13033
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
13034
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
13034
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
13035
		unset($conf["stringProcess::spiltString"]);
13035
		unset($conf["stringProcess::spiltString"]);
13036
		
13036
 
13037
		#如果分割字串失敗
13037
		#如果分割字串失敗
13038
		if($spiltString["status"]==="false"){
13038
		if($spiltString["status"]==="false"){
13039
			
13039
 
13040
			#設置執行不正常
13040
			#設置執行不正常
13041
			$result["status"]="false";
13041
			$result["status"]="false";
13042
			
13042
 
13043
			#設置錯誤訊息
13043
			#設置錯誤訊息
13044
			$result["error"]=$spiltString;
13044
			$result["error"]=$spiltString;
13045
			
13045
 
13046
			#回傳結果
13046
			#回傳結果
13047
			return $result;
13047
			return $result;
13048
			
13048
 
13049
			}#if end
13049
			}#if end
13050
			
13050
 
13051
		#如果沒有分割用的關鍵字
13051
		#如果沒有分割用的關鍵字
13052
		if($spiltString["found"]==="false"){
13052
		if($spiltString["found"]==="false"){
13053
			
13053
 
13054
			#設置執行不正常
13054
			#設置執行不正常
13055
			$result["status"]="false";
13055
			$result["status"]="false";
13056
			
13056
 
13057
			#設置錯誤訊息
13057
			#設置錯誤訊息
13058
			$result["error"]=$spiltString;
13058
			$result["error"]=$spiltString;
13059
			
13059
 
13060
			#回傳結果
13060
			#回傳結果
13061
			return $result;
13061
			return $result;
13062
			
13062
 
13063
			}#if end
13063
			}#if end
13064
		
13064
 
13065
		#取得標題欄位
13065
		#取得標題欄位
13066
		$titles=$spiltString["dataArray"];	
13066
		$titles=$spiltString["dataArray"];
13067
		
13067
 
13068
		#取得標題欄位數目
13068
		#取得標題欄位數目
13069
		$titleCount=$spiltString["dataCounts"];
13069
		$titleCount=$spiltString["dataCounts"];
13070
					
13070
 
13071
		#針對每列輸出
13071
		#針對每列輸出
13072
		for($i=3;$i<$lineCount-2;$i++){
13072
		for($i=3;$i<$lineCount-2;$i++){
13073
			
13073
 
13074
			#取得各欄位的內容
13074
			#取得各欄位的內容
13075
			#函式說明:
13075
			#函式說明:
13076
			#將固定格式的字串分開,並回傳分開的結果。
13076
			#將固定格式的字串分開,並回傳分開的結果。
13077
			#回傳結果:
13077
			#回傳結果:
13078
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13078
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 13088... Line 13088...
13088
			#可省略參數:
13088
			#可省略參數:
13089
			#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
13089
			#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
13090
			$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
13090
			$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
13091
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
13091
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
13092
			unset($conf["stringProcess::spiltString"]);
13092
			unset($conf["stringProcess::spiltString"]);
13093
			
13093
 
13094
			#如果分割字串失敗
13094
			#如果分割字串失敗
13095
			if($spiltString["status"]==="false"){
13095
			if($spiltString["status"]==="false"){
13096
				
13096
 
13097
				#設置執行不正常
13097
				#設置執行不正常
13098
				$result["status"]="false";
13098
				$result["status"]="false";
13099
				
13099
 
13100
				#設置錯誤訊息
13100
				#設置錯誤訊息
13101
				$result["error"]=$spiltString;
13101
				$result["error"]=$spiltString;
13102
				
13102
 
13103
				#回傳結果
13103
				#回傳結果
13104
				return $result;
13104
				return $result;
13105
				
13105
 
13106
				}#if end
13106
				}#if end
13107
				
13107
 
13108
			#如果沒有分割用的關鍵字
13108
			#如果沒有分割用的關鍵字
13109
			if($spiltString["found"]==="false"){
13109
			if($spiltString["found"]==="false"){
13110
				
13110
 
13111
				#設置執行不正常
13111
				#設置執行不正常
13112
				$result["status"]="false";
13112
				$result["status"]="false";
13113
				
13113
 
13114
				#設置錯誤訊息
13114
				#設置錯誤訊息
13115
				$result["error"]=$spiltString;
13115
				$result["error"]=$spiltString;
13116
				
13116
 
13117
				#回傳結果
13117
				#回傳結果
13118
				return $result;
13118
				return $result;
13119
				
13119
 
13120
				}#if end
13120
				}#if end
13121
					
13121
 
13122
			#取得各欄位的內容
13122
			#取得各欄位的內容
13123
			$cols=$spiltString["dataArray"];
13123
			$cols=$spiltString["dataArray"];
13124
			
13124
 
13125
			#取得欄位的數目
13125
			#取得欄位的數目
13126
			$colsCount=$spiltString["dataCounts"];
13126
			$colsCount=$spiltString["dataCounts"];
13127
			
13127
 
13128
			#如果實際抓出的內容欄位數量大於標題欄位數量,代表檔案/目錄名稱含有空格
13128
			#如果實際抓出的內容欄位數量大於標題欄位數量,代表檔案/目錄名稱含有空格
13129
			if($colsCount>$titleCount){
13129
			if($colsCount>$titleCount){
13130
				
13130
 
13131
				#新的檔案名稱
13131
				#新的檔案名稱
13132
				$newFileName="";
13132
				$newFileName="";
13133
				
13133
 
13134
				#針對每個多出的欄位
13134
				#針對每個多出的欄位
13135
				for($j=$titleCount;$j<$colsCount;$j++){
13135
				for($j=$titleCount;$j<$colsCount;$j++){
13136
					
13136
 
13137
					#串接屬於檔案名稱的部分
13137
					#串接屬於檔案名稱的部分
13138
					$newFileName=$newFileName.$cols[$j];
13138
					$newFileName=$newFileName.$cols[$j];
13139
					
13139
 
13140
					#如果不是最後一個項目
13140
					#如果不是最後一個項目
13141
					if($j!==$colsCount-1){
13141
					if($j!==$colsCount-1){
13142
						
13142
 
13143
						#增加空格
13143
						#增加空格
13144
						$newFileName=$newFileName." ";
13144
						$newFileName=$newFileName." ";
13145
						
13145
 
13146
						}#if end
13146
						}#if end
13147
					
13147
 
13148
					}#for end
13148
					}#for end
13149
				
13149
 
13150
				#取代成對的檔案名稱
13150
				#取代成對的檔案名稱
13151
				$cols[$titleCount-1]=$newFileName;
13151
				$cols[$titleCount-1]=$newFileName;
13152
				
13152
 
13153
				}#if end
13153
				}#if end
13154
			
13154
 
13155
			#針對每個欄位
13155
			#針對每個欄位
13156
			for($j=0;$j<$titleCount;$j++){
13156
			for($j=0;$j<$titleCount;$j++){
13157
				
13157
 
13158
				#取得欄位內容
13158
				#取得欄位內容
13159
				$result["content"]["each"][$titles[$j]][]=$cols[$j];
13159
				$result["content"]["each"][$titles[$j]][]=$cols[$j];
13160
				
13160
 
13161
				}#for end
13161
				}#for end
13162
						
13162
 
13163
			}#for end
13163
			}#for end
13164
				
13164
 
13165
		#取得 total 的輸出內容
13165
		#取得 total 的輸出內容
13166
		#函式說明:
13166
		#函式說明:
13167
		#將固定格式的字串分開,並回傳分開的結果。
13167
		#將固定格式的字串分開,並回傳分開的結果。
13168
		#回傳結果:
13168
		#回傳結果:
13169
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13169
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 13179... Line 13179...
13179
		#可省略參數:
13179
		#可省略參數:
13180
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
13180
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
13181
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
13181
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
13182
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
13182
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
13183
		unset($conf["stringProcess::spiltString"]);
13183
		unset($conf["stringProcess::spiltString"]);
13184
		
13184
 
13185
		#如果分割字串失敗
13185
		#如果分割字串失敗
13186
		if($spiltString["status"]==="false"){
13186
		if($spiltString["status"]==="false"){
13187
			
13187
 
13188
			#設置執行不正常
13188
			#設置執行不正常
13189
			$result["status"]="false";
13189
			$result["status"]="false";
13190
			
13190
 
13191
			#設置錯誤訊息
13191
			#設置錯誤訊息
13192
			$result["error"]=$spiltString;
13192
			$result["error"]=$spiltString;
13193
			
13193
 
13194
			#回傳結果
13194
			#回傳結果
13195
			return $result;
13195
			return $result;
13196
			
13196
 
13197
			}#if end
13197
			}#if end
13198
			
13198
 
13199
		#如果沒有分割用的關鍵字
13199
		#如果沒有分割用的關鍵字
13200
		if($spiltString["found"]==="false"){
13200
		if($spiltString["found"]==="false"){
13201
			
13201
 
13202
			#設置執行不正常
13202
			#設置執行不正常
13203
			$result["status"]="false";
13203
			$result["status"]="false";
13204
			
13204
 
13205
			#設置錯誤訊息
13205
			#設置錯誤訊息
13206
			$result["error"]=$spiltString;
13206
			$result["error"]=$spiltString;
13207
			
13207
 
13208
			#回傳結果
13208
			#回傳結果
13209
			return $result;
13209
			return $result;
13210
			
13210
 
13211
			}#if end
13211
			}#if end
13212
				
13212
 
13213
		#取得各欄位的內容
13213
		#取得各欄位的內容
13214
		$cols=$spiltString["dataArray"];
13214
		$cols=$spiltString["dataArray"];
13215
		
13215
 
13216
		#取得總共的檔案長度
13216
		#取得總共的檔案長度
13217
		$result["content"]["total"][$titles[0]]=$cols[0];
13217
		$result["content"]["total"][$titles[0]]=$cols[0];
13218
		
13218
 
13219
		#取得壓縮時的總共檔案長度
13219
		#取得壓縮時的總共檔案長度
13220
		$result["content"]["total"][$titles[2]]=$cols[1];
13220
		$result["content"]["total"][$titles[2]]=$cols[1];
13221
		
13221
 
13222
		#取得壓縮時的總共檔案長度
13222
		#取得壓縮時的總共檔案長度
13223
		$result["content"]["total"][$titles[3]]=$cols[2];
13223
		$result["content"]["total"][$titles[3]]=$cols[2];
13224
		
13224
 
13225
		#取得解壓縮出了多少檔案跟目錄
13225
		#取得解壓縮出了多少檔案跟目錄
13226
		$result["content"]["total"]["count"]=explode(" ",$cols[3])[0];
13226
		$result["content"]["total"]["count"]=explode(" ",$cols[3])[0];
13227
				
13227
 
13228
		#設置執行正常
13228
		#設置執行正常
13229
		$result["status"]="true";
13229
		$result["status"]="true";
13230
		
13230
 
13231
		#回傳結果
13231
		#回傳結果
13232
		return $result;
13232
		return $result;
13233
		
13233
 
13234
		}#function unzip end
13234
		}#function unzip end
13235
		
13235
 
13236
	/*
13236
	/*
13237
	#函式說明:
13237
	#函式說明:
13238
	#接收Range: bytes=0-499格式的header, 輸出檔案的片段或完整檔案.
13238
	#接收Range: bytes=0-499格式的header, 輸出檔案的片段或完整檔案.
13239
	#回傳結果:
13239
	#回傳結果:
13240
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
13240
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 13253... Line 13253...
13253
	#http://php.net/manual/en/function.fread.php
13253
	#http://php.net/manual/en/function.fread.php
13254
	#備註:
13254
	#備註:
13255
	#請勿在運行該函式前印出任何內容,這是要給用戶端接收的內容.
13255
	#請勿在運行該函式前印出任何內容,這是要給用戶端接收的內容.
13256
	*/
13256
	*/
13257
	public static function partDownload(&$conf=array()){
13257
	public static function partDownload(&$conf=array()){
13258
		
13258
 
13259
		#初始化要回傳的結果
13259
		#初始化要回傳的結果
13260
		$result=array();
13260
		$result=array();
13261
 
13261
 
13262
		#取得當前執行的函數名稱
13262
		#取得當前執行的函數名稱
13263
		$result["function"]=__FUNCTION__;
13263
		$result["function"]=__FUNCTION__;
13264
 
13264
 
13265
		#如果沒有參數
13265
		#如果沒有參數
13266
		if(func_num_args()==0){
13266
		if(func_num_args()==0){
13267
			
13267
 
13268
			#設置執行失敗
13268
			#設置執行失敗
13269
			$result["status"]="false";
13269
			$result["status"]="false";
13270
			
13270
 
13271
			#設置執行錯誤訊息
13271
			#設置執行錯誤訊息
13272
			$result["error"]="函數".$result["function"]."需要參數";
13272
			$result["error"]="函數".$result["function"]."需要參數";
13273
			
13273
 
13274
			#回傳結果
13274
			#回傳結果
13275
			return $result;
13275
			return $result;
13276
			
13276
 
13277
		}#if end
13277
		}#if end
13278
		
13278
 
13279
		#取得參數
13279
		#取得參數
13280
		$result["argu"]=$conf;
13280
		$result["argu"]=$conf;
13281
 
13281
 
13282
		#如果 $conf 不為陣列
13282
		#如果 $conf 不為陣列
13283
		if(gettype($conf)!=="array"){
13283
		if(gettype($conf)!=="array"){
13284
			
13284
 
13285
			#設置執行失敗
13285
			#設置執行失敗
13286
			$result["status"]="false";
13286
			$result["status"]="false";
13287
			
13287
 
13288
			#設置執行錯誤訊息
13288
			#設置執行錯誤訊息
13289
			$result["error"][]="\$conf變數須為陣列形態";
13289
			$result["error"][]="\$conf變數須為陣列形態";
13290
			
13290
 
13291
			#如果傳入的參數為 null
13291
			#如果傳入的參數為 null
13292
			if($conf===null){
13292
			if($conf===null){
13293
				
13293
 
13294
				#設置執行錯誤訊息
13294
				#設置執行錯誤訊息
13295
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
13295
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
13296
				
13296
 
13297
				}#if end
13297
				}#if end
13298
 
13298
 
13299
			#回傳結果
13299
			#回傳結果
13300
			return $result;
13300
			return $result;
13301
			
13301
 
13302
			}#if end
13302
			}#if end
13303
			
13303
 
13304
		#檢查參數
13304
		#檢查參數
13305
		#函式說明:
13305
		#函式說明:
13306
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
13306
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
13307
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13307
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13308
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13308
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 13316... Line 13316...
13316
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
13316
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
13317
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
13317
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
13318
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
13318
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
13319
		#必填寫的參數:
13319
		#必填寫的參數:
13320
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
13320
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
13321
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
13321
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
13322
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
13322
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
13323
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
13323
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
13324
		#可以省略的參數:
13324
		#可以省略的參數:
13325
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
13325
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
13326
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("filePath");
13326
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("filePath");
Line 13334... Line 13334...
13334
		#$conf["canBeEmpty"]=array();
13334
		#$conf["canBeEmpty"]=array();
13335
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
13335
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
13336
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("fileName");
13336
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("fileName");
13337
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
13337
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
13338
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileName");
13338
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileName");
13339
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
13339
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
13340
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
13340
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
13341
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
13341
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
13342
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
13342
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
13343
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
13343
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
13344
		#$conf["disallowAllSkipableVarIsEmpty"]="";
13344
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 13348... Line 13348...
13348
		#$conf["arrayCountEqualCheck"][]=array();
13348
		#$conf["arrayCountEqualCheck"][]=array();
13349
		#參考資料來源:
13349
		#參考資料來源:
13350
		#array_keys=>http://php.net/manual/en/function.array-keys.php
13350
		#array_keys=>http://php.net/manual/en/function.array-keys.php
13351
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
13351
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
13352
		unset($conf["variableCheck::checkArguments"]);
13352
		unset($conf["variableCheck::checkArguments"]);
13353
		
13353
 
13354
		#如果檢查參數失敗
13354
		#如果檢查參數失敗
13355
		if($checkArguments["status"]==="false"){
13355
		if($checkArguments["status"]==="false"){
13356
			
13356
 
13357
			#設置執行失敗
13357
			#設置執行失敗
13358
			$result["status"]="false";
13358
			$result["status"]="false";
13359
			
13359
 
13360
			#設置執行錯誤
13360
			#設置執行錯誤
13361
			$result["error"]=$checkArguments;
13361
			$result["error"]=$checkArguments;
13362
			
13362
 
13363
			#回傳結果
13363
			#回傳結果
13364
			return $result;
13364
			return $result;
13365
			
13365
 
13366
			}#if end
13366
			}#if end
13367
			
13367
 
13368
		#如果檢查參數不通過
13368
		#如果檢查參數不通過
13369
		if($checkArguments["passed"]==="false"){
13369
		if($checkArguments["passed"]==="false"){
13370
			
13370
 
13371
			#設置執行失敗
13371
			#設置執行失敗
13372
			$result["status"]="false";
13372
			$result["status"]="false";
13373
			
13373
 
13374
			#設置執行錯誤
13374
			#設置執行錯誤
13375
			$result["error"]=$checkArguments;
13375
			$result["error"]=$checkArguments;
13376
			
13376
 
13377
			#回傳結果
13377
			#回傳結果
13378
			return $result;
13378
			return $result;
13379
			
13379
 
13380
			}#if end
13380
			}#if end
13381
		
13381
 
13382
		#如果沒有設置 $conf["fileName"]
13382
		#如果沒有設置 $conf["fileName"]
13383
		if(!isset($conf["fileName"])){
13383
		if(!isset($conf["fileName"])){
13384
			
13384
 
13385
			#取得檔案名稱
13385
			#取得檔案名稱
13386
			$filename=basename($conf["filePath"]);
13386
			$filename=basename($conf["filePath"]);
13387
			
13387
 
13388
			}#if end
13388
			}#if end
13389
		
13389
 
13390
		#反之
13390
		#反之
13391
		else{
13391
		else{
13392
			
13392
 
13393
			#取得設定好的檔案名稱
13393
			#取得設定好的檔案名稱
13394
			$filename=&$conf["fileName"];
13394
			$filename=&$conf["fileName"];
13395
			
13395
 
13396
			}#else end
13396
			}#else end
13397
				
13397
 
13398
		#取得檔案路徑
13398
		#取得檔案路徑
13399
		$location=$conf["filePath"];
13399
		$location=$conf["filePath"];
13400
 
13400
 
13401
		#取得mimetype
13401
		#取得mimetype
13402
		$mimetype=mime_content_type($location);
13402
		$mimetype=mime_content_type($location);
13403
		
13403
 
13404
		#如果檔案不存在
13404
		#如果檔案不存在
13405
		if(!file_exists($location)){
13405
		if(!file_exists($location)){
13406
			
13406
 
13407
			#提示找不到檔案
13407
			#提示找不到檔案
13408
			header("HTTP/1.1 404 Not Found");
13408
			header("HTTP/1.1 404 Not Found");
13409
			
13409
 
13410
			#設置執行失敗
13410
			#設置執行失敗
13411
			$result["status"]="false";
13411
			$result["status"]="false";
13412
			
13412
 
13413
			#設置錯誤訊息
13413
			#設置錯誤訊息
13414
			$result["error"][]="檔案 ".$location." 不存在.";
13414
			$result["error"][]="檔案 ".$location." 不存在.";
13415
			
13415
 
13416
			#回傳結果
13416
			#回傳結果
13417
			return $result;
13417
			return $result;
13418
			
13418
 
13419
			}#if end
13419
			}#if end
13420
 
13420
 
13421
		#取得檔案的bytes長度
13421
		#取得檔案的bytes長度
13422
		$size  = filesize($location);
13422
		$size  = filesize($location);
13423
		
13423
 
13424
		#取得檔案的最後變更日期
13424
		#取得檔案的最後變更日期
13425
		$time  = date('r', filemtime($location));
13425
		$time  = date('r', filemtime($location));
13426
 
13426
 
13427
		#讀取檔案的2元碼內容
13427
		#讀取檔案的2元碼內容
13428
		$fm = @fopen($location, 'rb');
13428
		$fm = @fopen($location, 'rb');
13429
		
13429
 
13430
		#如果開啟檔案失敗
13430
		#如果開啟檔案失敗
13431
		if(!$fm){
13431
		if(!$fm){
13432
			 
13432
 
13433
			#提示錯誤
13433
			#提示錯誤
13434
			header("HTTP/1.1 505 Internal server error");
13434
			header("HTTP/1.1 505 Internal server error");
13435
			
13435
 
13436
			#設置執行失敗
13436
			#設置執行失敗
13437
			$result["status"]="false";
13437
			$result["status"]="false";
13438
			
13438
 
13439
			#設置錯誤訊息
13439
			#設置錯誤訊息
13440
			$result["error"][]="開啟檔案 ".$location." 失敗.";
13440
			$result["error"][]="開啟檔案 ".$location." 失敗.";
13441
			
13441
 
13442
			#回傳結果
13442
			#回傳結果
13443
			return $result;
13443
			return $result;
13444
		
13444
 
13445
			}#if end
13445
			}#if end
13446
 
13446
 
13447
		#初始化要提供的bytes長度起始點
13447
		#初始化要提供的bytes長度起始點
13448
		$begin  = 0;
13448
		$begin  = 0;
13449
		
13449
 
13450
		#初始化要提供的bytes長度結束點
13450
		#初始化要提供的bytes長度結束點
13451
		$end  = $size - 1;
13451
		$end  = $size - 1;
13452
 
13452
 
13453
		#如果有接收到 'HTTP_RANGE' 的 header 訊息
13453
		#如果有接收到 'HTTP_RANGE' 的 header 訊息
13454
		if(isset($_SERVER['HTTP_RANGE'])){
13454
		if(isset($_SERVER['HTTP_RANGE'])){
13455
			
13455
 
13456
			#接收到的範例
13456
			#接收到的範例
13457
			#Range: bytes=0-499 
13457
			#Range: bytes=0-499
13458
			
13458
 
13459
			#取得要求的bytes位置範圍
13459
			#取得要求的bytes位置範圍
13460
			sscanf($_SERVER['HTTP_RANGE'], "bytes=%d-%d",$begin,$end);
13460
			sscanf($_SERVER['HTTP_RANGE'], "bytes=%d-%d",$begin,$end);
13461
			
13461
 
13462
			#如果 $begin 或 $end  有缺
13462
			#如果 $begin 或 $end  有缺
13463
			if(!isset($begin) || !isset($end)){
13463
			if(!isset($begin) || !isset($end)){
13464
				
13464
 
13465
				#設置執行失敗
13465
				#設置執行失敗
13466
				$result["status"]="false";
13466
				$result["status"]="false";
13467
				
13467
 
13468
				#設置錯誤訊息
13468
				#設置錯誤訊息
13469
				$result["error"][]="header \"Range\" 的數值格式為 \"bytes=0-499\"";
13469
				$result["error"][]="header \"Range\" 的數值格式為 \"bytes=0-499\"";
13470
				
13470
 
13471
				#回傳結果
13471
				#回傳結果
13472
				return $result;
13472
				return $result;
13473
				
13473
 
13474
				}#if end
13474
				}#if end
13475
			
13475
 
13476
			#如果 $begin 沒有小於等於 $end
13476
			#如果 $begin 沒有小於等於 $end
13477
			if(!($begin<=$end)){
13477
			if(!($begin<=$end)){
13478
				
13478
 
13479
				#設置執行失敗
13479
				#設置執行失敗
13480
				$result["status"]="false";
13480
				$result["status"]="false";
13481
				
13481
 
13482
				#設置錯誤訊息
13482
				#設置錯誤訊息
13483
				$result["error"][]="header \"Range\" 的數值格式為 \"bytes=0-499\"";
13483
				$result["error"][]="header \"Range\" 的數值格式為 \"bytes=0-499\"";
13484
				
13484
 
13485
				#回傳結果
13485
				#回傳結果
13486
				return $result;
13486
				return $result;
13487
				
13487
 
13488
				}#if end
13488
				}#if end
13489
			
13489
 
13490
			}#if end
13490
			}#if end
13491
		
13491
 
13492
		#提示 200 ok
13492
		#提示 200 ok
13493
		header('HTTP/1.1 200 OK');
13493
		header('HTTP/1.1 200 OK');
13494
		
13494
 
13495
		#提示 mimetype
13495
		#提示 mimetype
13496
		header("Content-Type: $mimetype");
13496
		header("Content-Type: $mimetype");
13497
		
13497
 
13498
		#要先驗證cache中的資料,取得的內容放在快取的時間為0
13498
		#要先驗證cache中的資料,取得的內容放在快取的時間為0
13499
		header('Cache-Control: public, must-revalidate, max-age=0');
13499
		header('Cache-Control: public, must-revalidate, max-age=0');
13500
		
13500
 
13501
		#提示不要cache
13501
		#提示不要cache
13502
		header('Pragma: no-cache');  
13502
		header('Pragma: no-cache');
13503
		
13503
 
13504
		#提示接收的 Ranges 單位為 bytes
13504
		#提示接收的 Ranges 單位為 bytes
13505
		header('Accept-Ranges: bytes');
13505
		header('Accept-Ranges: bytes');
13506
		
13506
 
13507
		#數值傳輸的內容長度為多少
13507
		#數值傳輸的內容長度為多少
13508
		header('Content-Length:' . (($end - $begin) + 1));
13508
		header('Content-Length:' . (($end - $begin) + 1));
13509
		
13509
 
13510
		#提示內容為檔案的哪邊到哪邊與總共的長度
13510
		#提示內容為檔案的哪邊到哪邊與總共的長度
13511
		header("Content-Range: bytes $begin-$end/$size");
13511
		header("Content-Range: bytes $begin-$end/$size");
13512
	
13512
 
13513
		#提示檔案的名稱
13513
		#提示檔案的名稱
13514
		header("Content-Disposition: inline; filename=$filename");
13514
		header("Content-Disposition: inline; filename=$filename");
13515
		
13515
 
13516
		#提示用2元碼傳輸
13516
		#提示用2元碼傳輸
13517
		header("Content-Transfer-Encoding: binary");
13517
		header("Content-Transfer-Encoding: binary");
13518
		
13518
 
13519
		#提示檔案最後變更日期
13519
		#提示檔案最後變更日期
13520
		header("Last-Modified: $time");
13520
		header("Last-Modified: $time");
13521
 
13521
 
13522
		#初始化當前位置
13522
		#初始化當前位置
13523
		$cur  = $begin;
13523
		$cur  = $begin;
13524
		
13524
 
13525
		#指定讀取的起始點為 $begin 
13525
		#指定讀取的起始點為 $begin
13526
		fseek($fm, $begin, 0);
13526
		fseek($fm, $begin, 0);
13527
 
13527
 
13528
		#讀取內容, 若不是檔案結尾, 且當前位置($cur)小於等於 本次要提供的長度結尾($end), 且connection_status為0
13528
		#讀取內容, 若不是檔案結尾, 且當前位置($cur)小於等於 本次要提供的長度結尾($end), 且connection_status為0
13529
		while(!feof($fm) && $cur<=$end && (connection_status()===0)){
13529
		while(!feof($fm) && $cur<=$end && (connection_status()===0)){
13530
			
13530
 
13531
			#一次最多印出 1024*16bytes 的長度,若剩下長度不足則只印出剩下的長度.
13531
			#一次最多印出 1024*16bytes 的長度,若剩下長度不足則只印出剩下的長度.
13532
			echo fread($fm, min(1024 * 16, ($end - $cur) + 1));
13532
			echo fread($fm, min(1024 * 16, ($end - $cur) + 1));
13533
			
13533
 
13534
			#更改位置
13534
			#更改位置
13535
			$cur += 1024 * 16;
13535
			$cur += 1024 * 16;
13536
		
13536
 
13537
			}#while end
13537
			}#while end
13538
		
13538
 
13539
		}#function partDownload end
13539
		}#function partDownload end
13540
		
13540
 
13541
	/*
13541
	/*
13542
	#函式說明:
13542
	#函式說明:
13543
	#尋找檔案. 
13543
	#尋找檔案.
13544
	#回傳結果:
13544
	#回傳結果:
13545
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13545
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13546
	#$result["error"],錯誤訊息.
13546
	#$result["error"],錯誤訊息.
13547
	#$result["warning"],警告訊息陣列.
13547
	#$result["warning"],警告訊息陣列.
13548
	#$result["function"],當前執行的函數名稱.
13548
	#$result["function"],當前執行的函數名稱.
Line 13560... Line 13560...
13560
	#http://php.net/manual/en/function.glob.php
13560
	#http://php.net/manual/en/function.glob.php
13561
	#備註:
13561
	#備註:
13562
	#無.
13562
	#無.
13563
	*/
13563
	*/
13564
	public static function findFile(&$conf=array()){
13564
	public static function findFile(&$conf=array()){
13565
		
13565
 
13566
		#初始化要回傳的結果
13566
		#初始化要回傳的結果
13567
		$result=array();
13567
		$result=array();
13568
 
13568
 
13569
		#取得當前執行的函數名稱
13569
		#取得當前執行的函數名稱
13570
		$result["function"]=__FUNCTION__;
13570
		$result["function"]=__FUNCTION__;
13571
 
13571
 
13572
		#如果沒有參數
13572
		#如果沒有參數
13573
		if(func_num_args()==0){
13573
		if(func_num_args()==0){
13574
			
13574
 
13575
			#設置執行失敗
13575
			#設置執行失敗
13576
			$result["status"]="false";
13576
			$result["status"]="false";
13577
			
13577
 
13578
			#設置執行錯誤訊息
13578
			#設置執行錯誤訊息
13579
			$result["error"]="函數".$result["function"]."需要參數";
13579
			$result["error"]="函數".$result["function"]."需要參數";
13580
			
13580
 
13581
			#回傳結果
13581
			#回傳結果
13582
			return $result;
13582
			return $result;
13583
			
13583
 
13584
			}#if end		
13584
			}#if end
13585
 
13585
 
13586
		#取得參數
13586
		#取得參數
13587
		$result["argu"]=$conf;
13587
		$result["argu"]=$conf;
13588
 
13588
 
13589
		#如果 $conf 不為陣列
13589
		#如果 $conf 不為陣列
13590
		if(gettype($conf)!=="array"){
13590
		if(gettype($conf)!=="array"){
13591
			
13591
 
13592
			#設置執行失敗
13592
			#設置執行失敗
13593
			$result["status"]="false";
13593
			$result["status"]="false";
13594
			
13594
 
13595
			#設置執行錯誤訊息
13595
			#設置執行錯誤訊息
13596
			$result["error"][]="\$conf變數須為陣列形態";
13596
			$result["error"][]="\$conf變數須為陣列形態";
13597
			
13597
 
13598
			#如果傳入的參數為 null
13598
			#如果傳入的參數為 null
13599
			if($conf===null){
13599
			if($conf===null){
13600
				
13600
 
13601
				#設置執行錯誤訊息
13601
				#設置執行錯誤訊息
13602
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
13602
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
13603
				
13603
 
13604
				}#if end
13604
				}#if end
13605
 
13605
 
13606
			#回傳結果
13606
			#回傳結果
13607
			return $result;
13607
			return $result;
13608
			
13608
 
13609
			}#if end
13609
			}#if end
13610
		
13610
 
13611
		#函式說明:
13611
		#函式說明:
13612
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
13612
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
13613
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13613
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13614
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13614
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13615
		#$result["function"],當前執行的函式名稱.
13615
		#$result["function"],當前執行的函式名稱.
Line 13622... Line 13622...
13622
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
13622
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
13623
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
13623
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
13624
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
13624
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
13625
		#必填寫的參數:
13625
		#必填寫的參數:
13626
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
13626
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
13627
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
13627
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
13628
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
13628
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
13629
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
13629
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
13630
		#可以省略的參數:
13630
		#可以省略的參數:
13631
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
13631
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
13632
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","keyWord","fileArgu");
13632
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","keyWord","fileArgu");
Line 13640... Line 13640...
13640
		#$conf["canBeEmpty"]=array();
13640
		#$conf["canBeEmpty"]=array();
13641
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
13641
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
13642
		#$conf["skipableVariableCanNotBeEmpty"]=array();
13642
		#$conf["skipableVariableCanNotBeEmpty"]=array();
13643
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
13643
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
13644
		#$conf["skipableVariableName"]=array();
13644
		#$conf["skipableVariableName"]=array();
13645
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
13645
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
13646
		#$conf["skipableVariableType"]=array();
13646
		#$conf["skipableVariableType"]=array();
13647
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
13647
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
13648
		#$conf["skipableVarDefaultValue"]=array("");
13648
		#$conf["skipableVarDefaultValue"]=array("");
13649
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
13649
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
13650
		#$conf["disallowAllSkipableVarIsEmpty"]="";
13650
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 13654... Line 13654...
13654
		#$conf["arrayCountEqualCheck"][]=array();
13654
		#$conf["arrayCountEqualCheck"][]=array();
13655
		#參考資料來源:
13655
		#參考資料來源:
13656
		#array_keys=>http://php.net/manual/en/function.array-keys.php
13656
		#array_keys=>http://php.net/manual/en/function.array-keys.php
13657
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
13657
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
13658
		unset($conf["variableCheck::checkArguments"]);
13658
		unset($conf["variableCheck::checkArguments"]);
13659
		
13659
 
13660
		#如果檢查參數失敗
13660
		#如果檢查參數失敗
13661
		if($checkArguments["status"]==="false"){
13661
		if($checkArguments["status"]==="false"){
13662
			
13662
 
13663
			#設置執行失敗
13663
			#設置執行失敗
13664
			$result["status"]="false";
13664
			$result["status"]="false";
13665
			
13665
 
13666
			#設置執行失敗訊息
13666
			#設置執行失敗訊息
13667
			$result["error"]=$checkArguments;
13667
			$result["error"]=$checkArguments;
13668
			
13668
 
13669
			#回傳結果
13669
			#回傳結果
13670
			return $result;
13670
			return $result;
13671
			
13671
 
13672
			}#if end
13672
			}#if end
13673
			
13673
 
13674
		#如果檢查參數不通過
13674
		#如果檢查參數不通過
13675
		if($checkArguments["passed"]==="false"){
13675
		if($checkArguments["passed"]==="false"){
13676
			
13676
 
13677
			#設置執行失敗
13677
			#設置執行失敗
13678
			$result["status"]="false";
13678
			$result["status"]="false";
13679
			
13679
 
13680
			#設置執行失敗訊息
13680
			#設置執行失敗訊息
13681
			$result["error"]=$checkArguments;
13681
			$result["error"]=$checkArguments;
13682
			
13682
 
13683
			#回傳結果
13683
			#回傳結果
13684
			return $result;
13684
			return $result;
13685
			
13685
 
13686
			}#if end
13686
			}#if end
13687
		
13687
 
13688
		#檢查要搜尋的路徑是否都存在
13688
		#檢查要搜尋的路徑是否都存在
13689
		#函式說明:
13689
		#函式說明:
13690
		#s檢查多個檔案與資料夾是否存在.
13690
		#s檢查多個檔案與資料夾是否存在.
13691
		#回傳的結果:
13691
		#回傳的結果:
13692
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
13692
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 13713... Line 13713...
13713
		#http://php.net/manual/en/control-structures.foreach.php
13713
		#http://php.net/manual/en/control-structures.foreach.php
13714
		#備註:
13714
		#備註:
13715
		#函數file_exists檢查的路徑為檔案系統的路徑
13715
		#函數file_exists檢查的路徑為檔案系統的路徑
13716
		$checkMultiFileExist=self::checkMultiFileExist($conf["self::checkMultiFileExist"]);
13716
		$checkMultiFileExist=self::checkMultiFileExist($conf["self::checkMultiFileExist"]);
13717
		unset($conf["self::checkMultiFileExist"]);
13717
		unset($conf["self::checkMultiFileExist"]);
13718
			
13718
 
13719
		#如果檢查目錄存在失敗
13719
		#如果檢查目錄存在失敗
13720
		if($checkMultiFileExist["status"]==="false"){
13720
		if($checkMultiFileExist["status"]==="false"){
13721
			
13721
 
13722
			#設置執行失敗
13722
			#設置執行失敗
13723
			$result["status"]="false";
13723
			$result["status"]="false";
13724
			
13724
 
13725
			#設置執行失敗訊息
13725
			#設置執行失敗訊息
13726
			$result["error"]=$checkMultiFileExist;
13726
			$result["error"]=$checkMultiFileExist;
13727
			
13727
 
13728
			#回傳結果
13728
			#回傳結果
13729
			return $result;
13729
			return $result;
13730
			
13730
 
13731
			}#if end	
13731
			}#if end
13732
			
13732
 
13733
		#如果目錄不存在
13733
		#如果目錄不存在
13734
		if($checkMultiFileExist["status"]==="false"){
13734
		if($checkMultiFileExist["status"]==="false"){
13735
			
13735
 
13736
			#設置執行失敗
13736
			#設置執行失敗
13737
			$result["status"]="false";
13737
			$result["status"]="false";
13738
			
13738
 
13739
			#設置執行失敗訊息
13739
			#設置執行失敗訊息
13740
			$result["error"]=$checkMultiFileExist;
13740
			$result["error"]=$checkMultiFileExist;
13741
			
13741
 
13742
			#回傳結果
13742
			#回傳結果
13743
			return $result;
13743
			return $result;
13744
			
13744
 
13745
			}#if end
13745
			}#if end
13746
		
13746
 
13747
		#如果有路徑不存在
13747
		#如果有路徑不存在
13748
		if($checkMultiFileExist["allExist"]==="false"){
13748
		if($checkMultiFileExist["allExist"]==="false"){
13749
			
13749
 
13750
			#設置執行失敗
13750
			#設置執行失敗
13751
			$result["status"]="false";
13751
			$result["status"]="false";
13752
			
13752
 
13753
			#設置執行失敗訊息
13753
			#設置執行失敗訊息
13754
			$result["error"]=$checkMultiFileExist;
13754
			$result["error"]=$checkMultiFileExist;
13755
			
13755
 
13756
			#設置提示有路徑不存在的訊息
13756
			#設置提示有路徑不存在的訊息
13757
			$result["warning"][]="參數path的路徑沒有每個都存在";
13757
			$result["warning"][]="參數path的路徑沒有每個都存在";
13758
			
13758
 
13759
			#回傳結果
13759
			#回傳結果
13760
			return $result;
13760
			return $result;
13761
			
13761
 
13762
			}#if end
13762
			}#if end
13763
		
13763
 
13764
		#預設沒有找到檔案
13764
		#預設沒有找到檔案
13765
		$result["found"]="false";	
13765
		$result["found"]="false";
13766
			
13766
 
13767
		#針對每個要搜尋的路徑
13767
		#針對每個要搜尋的路徑
13768
		foreach($conf["path"] as $path){
13768
		foreach($conf["path"] as $path){
13769
			
13769
 
13770
			#函式說明:
13770
			#函式說明:
13771
			#用find指令尋找檔案
13771
			#用find指令尋找檔案
13772
			#回傳結果:
13772
			#回傳結果:
13773
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13773
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13774
			#$result["error"],錯誤訊息.
13774
			#$result["error"],錯誤訊息.
Line 13776... Line 13776...
13776
			#$result["argu"],所使用的參數.
13776
			#$result["argu"],所使用的參數.
13777
			#$result["found"],是否有找到符合的檔案,"true"代表有;"false"代表沒有.
13777
			#$result["found"],是否有找到符合的檔案,"true"代表有;"false"代表沒有.
13778
			#$result["content"],找到的檔案陣列.
13778
			#$result["content"],找到的檔案陣列.
13779
			#必填參數:
13779
			#必填參數:
13780
			#$conf["keyWord"],字串,要搜尋的檔案關鍵字,可用"*"符號,例如"*.qcow2",就代表檔案名成為"qcow2"結尾的檔案.
13780
			#$conf["keyWord"],字串,要搜尋的檔案關鍵字,可用"*"符號,例如"*.qcow2",就代表檔案名成為"qcow2"結尾的檔案.
13781
			$conf["cmd::find"]["keyWord"]=$conf["keyWord"];	
13781
			$conf["cmd::find"]["keyWord"]=$conf["keyWord"];
13782
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
13782
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
13783
			$conf["cmd::find"]["fileArgu"]=$conf["fileArgu"];
13783
			$conf["cmd::find"]["fileArgu"]=$conf["fileArgu"];
13784
			#可省略參數:
13784
			#可省略參數:
13785
			#$conf["path"],字串,搜尋的路徑,預設為"/".
13785
			#$conf["path"],字串,搜尋的路徑,預設為"/".
13786
			$conf["cmd::find"]["path"]=$path;
13786
			$conf["cmd::find"]["path"]=$path;
Line 13788... Line 13788...
13788
			$conf["cmd::find"]["fileOnly"]="true";
13788
			$conf["cmd::find"]["fileOnly"]="true";
13789
			#參考資料:
13789
			#參考資料:
13790
			#http://php.net/manual/en/function.glob.php
13790
			#http://php.net/manual/en/function.glob.php
13791
			$find=cmd::find($conf["cmd::find"]);
13791
			$find=cmd::find($conf["cmd::find"]);
13792
			unset($conf["cmd::find"]);
13792
			unset($conf["cmd::find"]);
13793
						
13793
 
13794
			#如果尋找檔案失敗
13794
			#如果尋找檔案失敗
13795
			if($find["status"]==="false"){
13795
			if($find["status"]==="false"){
13796
				
13796
 
13797
				#設置執行失敗
13797
				#設置執行失敗
13798
				$result["status"]="false";
13798
				$result["status"]="false";
13799
				
13799
 
13800
				#設置執行失敗訊息
13800
				#設置執行失敗訊息
13801
				$result["error"]=$find;
13801
				$result["error"]=$find;
13802
							
13802
 
13803
				#回傳結果
13803
				#回傳結果
13804
				return $result;
13804
				return $result;
13805
				
13805
 
13806
				}#if end
13806
				}#if end
13807
				
13807
 
13808
			#如果有找到符合的檔案
13808
			#如果有找到符合的檔案
13809
			if($find["found"]==="true"){
13809
			if($find["found"]==="true"){
13810
				
13810
 
13811
				#設置有找到檔案
13811
				#設置有找到檔案
13812
				$result["found"]="true";
13812
				$result["found"]="true";
13813
				
13813
 
13814
				#針對每個找到的檔案
13814
				#針對每個找到的檔案
13815
				foreach($find["content"] as $filtedFile){
13815
				foreach($find["content"] as $filtedFile){
13816
					
13816
 
13817
					#設置有找到的檔案
13817
					#設置有找到的檔案
13818
					$result["content"][]=$filtedFile;
13818
					$result["content"][]=$filtedFile;
13819
					
13819
 
13820
					}#foreach end
13820
					}#foreach end
13821
								
13821
 
13822
				}#if end
13822
				}#if end
13823
						
13823
 
13824
			}#foreach end		
13824
			}#foreach end
13825
				
13825
 
13826
		#設置執行正常
13826
		#設置執行正常
13827
		$result["status"]="true";
13827
		$result["status"]="true";
13828
				
13828
 
13829
		#回傳結果
13829
		#回傳結果
13830
		return $result;
13830
		return $result;
13831
		
13831
 
13832
		}#function findFile end
13832
		}#function findFile end
13833
 
13833
 
13834
	/*
13834
	/*
13835
	#函式說明:
13835
	#函式說明:
13836
	#判斷檔案位於哪個分割區
13836
	#判斷檔案位於哪個分割區
Line 13851... Line 13851...
13851
	#無.
13851
	#無.
13852
	#備註:
13852
	#備註:
13853
	#無.
13853
	#無.
13854
	*/
13854
	*/
13855
	public static function addrInMountPoint(&$conf=array()){
13855
	public static function addrInMountPoint(&$conf=array()){
13856
		
13856
 
13857
		#初始化要回傳的結果
13857
		#初始化要回傳的結果
13858
		$result=array();
13858
		$result=array();
13859
 
13859
 
13860
		#取得當前執行的函數名稱
13860
		#取得當前執行的函數名稱
13861
		$result["function"]=__FUNCTION__;
13861
		$result["function"]=__FUNCTION__;
13862
 
13862
 
13863
		#如果沒有參數
13863
		#如果沒有參數
13864
		if(func_num_args()==0){
13864
		if(func_num_args()==0){
13865
			
13865
 
13866
			#設置執行失敗
13866
			#設置執行失敗
13867
			$result["status"]="false";
13867
			$result["status"]="false";
13868
			
13868
 
13869
			#設置執行錯誤訊息
13869
			#設置執行錯誤訊息
13870
			$result["error"]="函數".$result["function"]."需要參數";
13870
			$result["error"]="函數".$result["function"]."需要參數";
13871
			
13871
 
13872
			#回傳結果
13872
			#回傳結果
13873
			return $result;
13873
			return $result;
13874
			
13874
 
13875
			}#if end		
13875
			}#if end
13876
 
13876
 
13877
		#取得參數
13877
		#取得參數
13878
		$result["argu"]=$conf;
13878
		$result["argu"]=$conf;
13879
 
13879
 
13880
		#如果 $conf 不為陣列
13880
		#如果 $conf 不為陣列
13881
		if(gettype($conf)!=="array"){
13881
		if(gettype($conf)!=="array"){
13882
			
13882
 
13883
			#設置執行失敗
13883
			#設置執行失敗
13884
			$result["status"]="false";
13884
			$result["status"]="false";
13885
			
13885
 
13886
			#設置執行錯誤訊息
13886
			#設置執行錯誤訊息
13887
			$result["error"][]="\$conf變數須為陣列形態";
13887
			$result["error"][]="\$conf變數須為陣列形態";
13888
			
13888
 
13889
			#如果傳入的參數為 null
13889
			#如果傳入的參數為 null
13890
			if($conf===null){
13890
			if($conf===null){
13891
				
13891
 
13892
				#設置執行錯誤訊息
13892
				#設置執行錯誤訊息
13893
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
13893
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
13894
				
13894
 
13895
				}#if end
13895
				}#if end
13896
 
13896
 
13897
			#回傳結果
13897
			#回傳結果
13898
			return $result;
13898
			return $result;
13899
			
13899
 
13900
			}#if end
13900
			}#if end
13901
		
13901
 
13902
		#函式說明:
13902
		#函式說明:
13903
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
13903
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
13904
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13904
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13905
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13905
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13906
		#$result["function"],當前執行的函式名稱.
13906
		#$result["function"],當前執行的函式名稱.
Line 13913... Line 13913...
13913
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
13913
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
13914
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
13914
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
13915
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
13915
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
13916
		#必填寫的參數:
13916
		#必填寫的參數:
13917
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
13917
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
13918
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
13918
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
13919
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
13919
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
13920
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
13920
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
13921
		#可以省略的參數:
13921
		#可以省略的參數:
13922
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
13922
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
13923
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
13923
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
Line 13931... Line 13931...
13931
		#$conf["canBeEmpty"]=array();
13931
		#$conf["canBeEmpty"]=array();
13932
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
13932
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
13933
		#$conf["skipableVariableCanNotBeEmpty"]=array();
13933
		#$conf["skipableVariableCanNotBeEmpty"]=array();
13934
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
13934
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
13935
		#$conf["skipableVariableName"]=array();
13935
		#$conf["skipableVariableName"]=array();
13936
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
13936
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
13937
		#$conf["skipableVariableType"]=array();
13937
		#$conf["skipableVariableType"]=array();
13938
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
13938
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
13939
		#$conf["skipableVarDefaultValue"]=array("");
13939
		#$conf["skipableVarDefaultValue"]=array("");
13940
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
13940
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
13941
		#$conf["disallowAllSkipableVarIsEmpty"]="";
13941
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 13945... Line 13945...
13945
		#$conf["arrayCountEqualCheck"][]=array();
13945
		#$conf["arrayCountEqualCheck"][]=array();
13946
		#參考資料來源:
13946
		#參考資料來源:
13947
		#array_keys=>http://php.net/manual/en/function.array-keys.php
13947
		#array_keys=>http://php.net/manual/en/function.array-keys.php
13948
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
13948
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
13949
		unset($conf["variableCheck::checkArguments"]);
13949
		unset($conf["variableCheck::checkArguments"]);
13950
		
13950
 
13951
		#如果檢查參數失敗
13951
		#如果檢查參數失敗
13952
		if($checkArguments["status"]==="false"){
13952
		if($checkArguments["status"]==="false"){
13953
			
13953
 
13954
			#設置執行失敗
13954
			#設置執行失敗
13955
			$result["status"]="false";
13955
			$result["status"]="false";
13956
			
13956
 
13957
			#設置執行失敗訊息
13957
			#設置執行失敗訊息
13958
			$result["error"]=$checkArguments;
13958
			$result["error"]=$checkArguments;
13959
			
13959
 
13960
			#回傳結果
13960
			#回傳結果
13961
			return $result;
13961
			return $result;
13962
			
13962
 
13963
			}#if end
13963
			}#if end
13964
			
13964
 
13965
		#如果檢查參數不通過
13965
		#如果檢查參數不通過
13966
		if($checkArguments["passed"]==="false"){
13966
		if($checkArguments["passed"]==="false"){
13967
			
13967
 
13968
			#設置執行失敗
13968
			#設置執行失敗
13969
			$result["status"]="false";
13969
			$result["status"]="false";
13970
			
13970
 
13971
			#設置執行失敗訊息
13971
			#設置執行失敗訊息
13972
			$result["error"]=$checkArguments;
13972
			$result["error"]=$checkArguments;
13973
			
13973
 
13974
			#回傳結果
13974
			#回傳結果
13975
			return $result;
13975
			return $result;
13976
			
13976
 
13977
			}#if end
13977
			}#if end
13978
		
13978
 
13979
		#函式說明:
13979
		#函式說明:
13980
		#透過lsblk指令的輸出取得已經掛載的blk.
13980
		#透過lsblk指令的輸出取得已經掛載的blk.
13981
		#回傳結果:
13981
		#回傳結果:
13982
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13982
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13983
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13983
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 13985... Line 13985...
13985
		#$result["content"],lsblk的輸出內容.
13985
		#$result["content"],lsblk的輸出內容.
13986
		#必填參數:
13986
		#必填參數:
13987
		#$conf["fileArgu"],字串,變數__FILE__的內容.
13987
		#$conf["fileArgu"],字串,變數__FILE__的內容.
13988
		$conf["cmd::lsblk"]["fileArgu"]=$conf["fileArgu"];
13988
		$conf["cmd::lsblk"]["fileArgu"]=$conf["fileArgu"];
13989
		#可省略參數:
13989
		#可省略參數:
13990
		#無.	
13990
		#無.
13991
		$lsblk=cmd::lsblk($conf["cmd::lsblk"]);
13991
		$lsblk=cmd::lsblk($conf["cmd::lsblk"]);
13992
		unset($conf["cmd::lsblk"]);
13992
		unset($conf["cmd::lsblk"]);
13993
		
13993
 
13994
		#如果執行失敗
13994
		#如果執行失敗
13995
		if($lsblk["status"]==="false"){
13995
		if($lsblk["status"]==="false"){
13996
			
13996
 
13997
			#設置執行失敗
13997
			#設置執行失敗
13998
			$result["status"]="false";
13998
			$result["status"]="false";
13999
			
13999
 
14000
			#設置執行失敗訊息
14000
			#設置執行失敗訊息
14001
			$result["error"]=$lsblk;
14001
			$result["error"]=$lsblk;
14002
						
14002
 
14003
			#回傳結果
14003
			#回傳結果
14004
			return $result;
14004
			return $result;
14005
			
14005
 
14006
			}#if end
14006
			}#if end
14007
		
14007
 
14008
		#將 $conf["file"] 轉換成絕對路徑
14008
		#將 $conf["file"] 轉換成絕對路徑
14009
		#函式說明:
14009
		#函式說明:
14010
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
14010
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
14011
		#回傳結果:
14011
		#回傳結果:
14012
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
14012
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
14013
		#$result["error"],錯誤訊息陣列.
14013
		#$result["error"],錯誤訊息陣列.
14014
		#$result["function"],函數名稱. 
14014
		#$result["function"],函數名稱.
14015
		#$result["argu"],使用的參數.
14015
		#$result["argu"],使用的參數.
14016
		#$result["content"],網址,若是在命令列執行,則為"null".
14016
		#$result["content"],網址,若是在命令列執行,則為"null".
14017
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
14017
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
14018
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
14018
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
14019
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
14019
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
Line 14025... Line 14025...
14025
		#可省略參數:
14025
		#可省略參數:
14026
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
14026
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
14027
		#$conf["userDir"]="true";
14027
		#$conf["userDir"]="true";
14028
		$getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
14028
		$getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
14029
		unset($conf["fileAccess::getInternetAddress"]);
14029
		unset($conf["fileAccess::getInternetAddress"]);
14030
			
14030
 
14031
		#如果執行失敗
14031
		#如果執行失敗
14032
		if($getInternetAddress["status"]==="false"){
14032
		if($getInternetAddress["status"]==="false"){
14033
			
14033
 
14034
			#設置執行失敗
14034
			#設置執行失敗
14035
			$result["status"]="false";
14035
			$result["status"]="false";
14036
			
14036
 
14037
			#設置執行失敗訊息
14037
			#設置執行失敗訊息
14038
			$result["error"]=$getInternetAddress;
14038
			$result["error"]=$getInternetAddress;
14039
						
14039
 
14040
			#回傳結果
14040
			#回傳結果
14041
			return $result;
14041
			return $result;
14042
			
14042
 
14043
			}#if end	
14043
			}#if end
14044
			
14044
 
14045
		#使用絕對位置作為輸入字串
14045
		#使用絕對位置作為輸入字串
14046
		#函式說明:
14046
		#函式說明:
14047
		#尋找字串是否存在對應的關鍵字,且符合的最常關鍵字為何?
14047
		#尋找字串是否存在對應的關鍵字,且符合的最常關鍵字為何?
14048
		#回傳結果:
14048
		#回傳結果:
14049
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14049
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 14057... Line 14057...
14057
		$conf["search::findLikelyStr"]["input"]=$getInternetAddress["fileSystemAbsoulutePosition"];
14057
		$conf["search::findLikelyStr"]["input"]=$getInternetAddress["fileSystemAbsoulutePosition"];
14058
		#$conf["keyWord"],字串陣列,要搜尋的關鍵字.
14058
		#$conf["keyWord"],字串陣列,要搜尋的關鍵字.
14059
		$conf["search::findLikelyStr"]["keyWord"]=$lsblk["content"]["MOUNTPOINT"];
14059
		$conf["search::findLikelyStr"]["keyWord"]=$lsblk["content"]["MOUNTPOINT"];
14060
		$findLikelyStr=search::findLikelyStr($conf["search::findLikelyStr"]);
14060
		$findLikelyStr=search::findLikelyStr($conf["search::findLikelyStr"]);
14061
		unset($conf["search::findLikelyStr"]);
14061
		unset($conf["search::findLikelyStr"]);
14062
		
14062
 
14063
		#如果執行失敗
14063
		#如果執行失敗
14064
		if($findLikelyStr["status"]==="false"){
14064
		if($findLikelyStr["status"]==="false"){
14065
			
14065
 
14066
			#設置執行失敗
14066
			#設置執行失敗
14067
			$result["status"]="false";
14067
			$result["status"]="false";
14068
			
14068
 
14069
			#設置執行失敗訊息
14069
			#設置執行失敗訊息
14070
			$result["error"]=$findLikelyStr;
14070
			$result["error"]=$findLikelyStr;
14071
						
14071
 
14072
			#回傳結果
14072
			#回傳結果
14073
			return $result;
14073
			return $result;
14074
			
14074
 
14075
			}#if end
14075
			}#if end
14076
			
14076
 
14077
		#如果找不到歸屬的分割區
14077
		#如果找不到歸屬的分割區
14078
		if($findLikelyStr["found"]==="false"){
14078
		if($findLikelyStr["found"]==="false"){
14079
			
14079
 
14080
			#設置執行失敗
14080
			#設置執行失敗
14081
			$result["status"]="false";
14081
			$result["status"]="false";
14082
			
14082
 
14083
			#設置執行失敗訊息
14083
			#設置執行失敗訊息
14084
			$result["error"]=$findLikelyStr;
14084
			$result["error"]=$findLikelyStr;
14085
						
14085
 
14086
			#回傳結果
14086
			#回傳結果
14087
			return $result;
14087
			return $result;
14088
			
14088
 
14089
			}#if end
14089
			}#if end
14090
			
14090
 
14091
		#設置歸屬的分割區資訊
14091
		#設置歸屬的分割區資訊
14092
		$result["content"]=$findLikelyStr["content"];
14092
		$result["content"]=$findLikelyStr["content"];
14093
		
14093
 
14094
		#設置執行正常
14094
		#設置執行正常
14095
		$result["status"]="true";
14095
		$result["status"]="true";
14096
		
14096
 
14097
		#回傳結果
14097
		#回傳結果
14098
		return $result;
14098
		return $result;
14099
		
14099
 
14100
		}#function addrInMountPoint end
14100
		}#function addrInMountPoint end
14101
 
14101
 
14102
	/*
14102
	/*
14103
	#函式說明:
14103
	#函式說明:
14104
	#取得檔案的副檔名
14104
	#取得檔案的副檔名
14105
	#回傳結果:
14105
	#回傳結果:
14106
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14106
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14107
	#$result["error"],錯誤訊息.
14107
	#$result["error"],錯誤訊息.
14108
	#$result["function"],當前執行的函數名稱.
14108
	#$result["function"],當前執行的函數名稱.
14109
	#$result["argu"],所使用的參數.	
14109
	#$result["argu"],所使用的參數.
14110
	#$result["content"],副檔名.
14110
	#$result["content"],副檔名.
14111
	#$result["name"],不含副檔的名稱.
14111
	#$result["name"],不含副檔的名稱.
14112
	#$result["fullName"],含副檔的名稱.
14112
	#$result["fullName"],含副檔的名稱.
14113
	#$result["path"],檔案所處的路徑.
14113
	#$result["path"],檔案所處的路徑.
14114
	#必填參數:
14114
	#必填參數:
Line 14122... Line 14122...
14122
	#無.
14122
	#無.
14123
	#備註:
14123
	#備註:
14124
	#無.
14124
	#無.
14125
	*/
14125
	*/
14126
	public static function getExtension(&$conf=array()){
14126
	public static function getExtension(&$conf=array()){
14127
		
14127
 
14128
		#初始化要回傳的結果
14128
		#初始化要回傳的結果
14129
		$result=array();
14129
		$result=array();
14130
 
14130
 
14131
		#取得當前執行的函數名稱
14131
		#取得當前執行的函數名稱
14132
		$result["function"]=__FUNCTION__;
14132
		$result["function"]=__FUNCTION__;
14133
 
14133
 
14134
		#如果沒有參數
14134
		#如果沒有參數
14135
		if(func_num_args()==0){
14135
		if(func_num_args()==0){
14136
			
14136
 
14137
			#設置執行失敗
14137
			#設置執行失敗
14138
			$result["status"]="false";
14138
			$result["status"]="false";
14139
			
14139
 
14140
			#設置執行錯誤訊息
14140
			#設置執行錯誤訊息
14141
			$result["error"]="函數".$result["function"]."需要參數";
14141
			$result["error"]="函數".$result["function"]."需要參數";
14142
			
14142
 
14143
			#回傳結果
14143
			#回傳結果
14144
			return $result;
14144
			return $result;
14145
			
14145
 
14146
			}#if end		
14146
			}#if end
14147
 
14147
 
14148
		#取得參數
14148
		#取得參數
14149
		$result["argu"]=$conf;
14149
		$result["argu"]=$conf;
14150
 
14150
 
14151
		#如果 $conf 不為陣列
14151
		#如果 $conf 不為陣列
14152
		if(gettype($conf)!=="array"){
14152
		if(gettype($conf)!=="array"){
14153
			
14153
 
14154
			#設置執行失敗
14154
			#設置執行失敗
14155
			$result["status"]="false";
14155
			$result["status"]="false";
14156
			
14156
 
14157
			#設置執行錯誤訊息
14157
			#設置執行錯誤訊息
14158
			$result["error"][]="\$conf變數須為陣列形態";
14158
			$result["error"][]="\$conf變數須為陣列形態";
14159
			
14159
 
14160
			#如果傳入的參數為 null
14160
			#如果傳入的參數為 null
14161
			if($conf===null){
14161
			if($conf===null){
14162
				
14162
 
14163
				#設置執行錯誤訊息
14163
				#設置執行錯誤訊息
14164
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
14164
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
14165
				
14165
 
14166
				}#if end
14166
				}#if end
14167
 
14167
 
14168
			#回傳結果
14168
			#回傳結果
14169
			return $result;
14169
			return $result;
14170
			
14170
 
14171
			}#if end
14171
			}#if end
14172
		
14172
 
14173
		#函式說明:
14173
		#函式說明:
14174
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
14174
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
14175
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14175
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14176
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
14176
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
14177
		#$result["function"],當前執行的函式名稱.
14177
		#$result["function"],當前執行的函式名稱.
Line 14184... Line 14184...
14184
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
14184
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
14185
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
14185
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
14186
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
14186
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
14187
		#必填寫的參數:
14187
		#必填寫的參數:
14188
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
14188
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
14189
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
14189
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
14190
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
14190
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
14191
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
14191
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
14192
		#可以省略的參數:
14192
		#可以省略的參數:
14193
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
14193
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
14194
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
14194
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
Line 14202... Line 14202...
14202
		#$conf["canBeEmpty"]=array();
14202
		#$conf["canBeEmpty"]=array();
14203
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
14203
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
14204
		#$conf["skipableVariableCanNotBeEmpty"]=array();
14204
		#$conf["skipableVariableCanNotBeEmpty"]=array();
14205
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
14205
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
14206
		#$conf["skipableVariableName"]=array();
14206
		#$conf["skipableVariableName"]=array();
14207
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
14207
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
14208
		#$conf["skipableVariableType"]=array();
14208
		#$conf["skipableVariableType"]=array();
14209
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
14209
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
14210
		#$conf["skipableVarDefaultValue"]=array("");
14210
		#$conf["skipableVarDefaultValue"]=array("");
14211
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
14211
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
14212
		#$conf["disallowAllSkipableVarIsEmpty"]="";
14212
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 14216... Line 14216...
14216
		#$conf["arrayCountEqualCheck"][]=array();
14216
		#$conf["arrayCountEqualCheck"][]=array();
14217
		#參考資料來源:
14217
		#參考資料來源:
14218
		#array_keys=>http://php.net/manual/en/function.array-keys.php
14218
		#array_keys=>http://php.net/manual/en/function.array-keys.php
14219
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
14219
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
14220
		unset($conf["variableCheck::checkArguments"]);
14220
		unset($conf["variableCheck::checkArguments"]);
14221
		
14221
 
14222
		#如果檢查參數失敗
14222
		#如果檢查參數失敗
14223
		if($checkArguments["status"]==="false"){
14223
		if($checkArguments["status"]==="false"){
14224
			
14224
 
14225
			#設置執行失敗
14225
			#設置執行失敗
14226
			$result["status"]="false";
14226
			$result["status"]="false";
14227
			
14227
 
14228
			#設置執行失敗訊息
14228
			#設置執行失敗訊息
14229
			$result["error"]=$checkArguments;
14229
			$result["error"]=$checkArguments;
14230
			
14230
 
14231
			#回傳結果
14231
			#回傳結果
14232
			return $result;
14232
			return $result;
14233
			
14233
 
14234
			}#if end
14234
			}#if end
14235
			
14235
 
14236
		#如果檢查參數不通過
14236
		#如果檢查參數不通過
14237
		if($checkArguments["passed"]==="false"){
14237
		if($checkArguments["passed"]==="false"){
14238
			
14238
 
14239
			#設置執行失敗
14239
			#設置執行失敗
14240
			$result["status"]="false";
14240
			$result["status"]="false";
14241
			
14241
 
14242
			#設置執行失敗訊息
14242
			#設置執行失敗訊息
14243
			$result["error"]=$checkArguments;
14243
			$result["error"]=$checkArguments;
14244
			
14244
 
14245
			#回傳結果
14245
			#回傳結果
14246
			return $result;
14246
			return $result;
14247
			
14247
 
14248
			}#if end
14248
			}#if end
14249
		
14249
 
14250
		#初始化檔案的路徑
14250
		#初始化檔案的路徑
14251
		$result["path"]="./";
14251
		$result["path"]="./";
14252
			
14252
 
14253
		#用 "/" 來分割字串
14253
		#用 "/" 來分割字串
14254
		#函式說明:
14254
		#函式說明:
14255
		#將固定格式的字串分開,並回傳分開的結果。
14255
		#將固定格式的字串分開,並回傳分開的結果。
14256
		#回傳結果:
14256
		#回傳結果:
14257
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14257
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 14267... Line 14267...
14267
		#可省略參數:
14267
		#可省略參數:
14268
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
14268
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
14269
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
14269
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
14270
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
14270
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
14271
		unset($conf["stringProcess::spiltString"]);
14271
		unset($conf["stringProcess::spiltString"]);
14272
		
14272
 
14273
		#如果檢查參數失敗
14273
		#如果檢查參數失敗
14274
		if($spiltString["status"]==="false"){
14274
		if($spiltString["status"]==="false"){
14275
			
14275
 
14276
			#設置執行失敗
14276
			#設置執行失敗
14277
			$result["status"]="false";
14277
			$result["status"]="false";
14278
			
14278
 
14279
			#設置執行失敗訊息
14279
			#設置執行失敗訊息
14280
			$result["error"]=$spiltString;
14280
			$result["error"]=$spiltString;
14281
			
14281
 
14282
			#回傳結果
14282
			#回傳結果
14283
			return $result;
14283
			return $result;
14284
			
14284
 
14285
			}#if end
14285
			}#if end
14286
		
14286
 
14287
		#初始化含副檔名的檔案名稱
14287
		#初始化含副檔名的檔案名稱
14288
		$result["fullName"]=$conf["file"];
14288
		$result["fullName"]=$conf["file"];
14289
			
14289
 
14290
		#如果有"/"存在
14290
		#如果有"/"存在
14291
		if($spiltString["found"]==="true"){
14291
		if($spiltString["found"]==="true"){
14292
			
14292
 
14293
			#取得含副檔名的檔案名稱
14293
			#取得含副檔名的檔案名稱
14294
			$result["fullName"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
14294
			$result["fullName"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
14295
				
14295
 
14296
			#取得檔案的路徑
14296
			#取得檔案的路徑
14297
			$result["path"]=substr($conf["file"],0,strlen($conf["file"])-strlen($result["fullName"]));
14297
			$result["path"]=substr($conf["file"],0,strlen($conf["file"])-strlen($result["fullName"]));
14298
						
14298
 
14299
			}#if end
14299
			}#if end
14300
		
14300
 
14301
		#用 "." 來分割字串
14301
		#用 "." 來分割字串
14302
		#函式說明:
14302
		#函式說明:
14303
		#將固定格式的字串分開,並回傳分開的結果。
14303
		#將固定格式的字串分開,並回傳分開的結果。
14304
		#回傳結果:
14304
		#回傳結果:
14305
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14305
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 14315... Line 14315...
14315
		#可省略參數:
14315
		#可省略參數:
14316
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
14316
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
14317
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
14317
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
14318
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
14318
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
14319
		unset($conf["stringProcess::spiltString"]);
14319
		unset($conf["stringProcess::spiltString"]);
14320
		
14320
 
14321
		#如果檢查參數失敗
14321
		#如果檢查參數失敗
14322
		if($spiltString["status"]==="false"){
14322
		if($spiltString["status"]==="false"){
14323
			
14323
 
14324
			#設置執行失敗
14324
			#設置執行失敗
14325
			$result["status"]="false";
14325
			$result["status"]="false";
14326
			
14326
 
14327
			#設置執行失敗訊息
14327
			#設置執行失敗訊息
14328
			$result["error"]=$spiltString;
14328
			$result["error"]=$spiltString;
14329
			
14329
 
14330
			#回傳結果
14330
			#回傳結果
14331
			return $result;
14331
			return $result;
14332
			
14332
 
14333
			}#if end
14333
			}#if end
14334
		
14334
 
14335
		#預設副檔名為 ""
14335
		#預設副檔名為 ""
14336
		$result["content"]="";
14336
		$result["content"]="";
14337
		
14337
 
14338
		#預設不含副檔名的檔案名稱
14338
		#預設不含副檔名的檔案名稱
14339
		$result["name"]=$result["fullName"];
14339
		$result["name"]=$result["fullName"];
14340
		
14340
 
14341
		#如果有"."存在
14341
		#如果有"."存在
14342
		if($spiltString["found"]==="true"){
14342
		if($spiltString["found"]==="true"){
14343
			
14343
 
14344
			#取得含副檔名
14344
			#取得含副檔名
14345
			$result["content"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
14345
			$result["content"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
14346
					
14346
 
14347
			#取得不含副檔名的檔案名稱
14347
			#取得不含副檔名的檔案名稱
14348
			$result["name"]=substr($result["fullName"],0,strlen($result["fullName"])-strlen($result["content"])-1);	
14348
			$result["name"]=substr($result["fullName"],0,strlen($result["fullName"])-strlen($result["content"])-1);
14349
						
14349
 
14350
			}#if end
14350
			}#if end
14351
					
14351
 
14352
		#設置執行正常
14352
		#設置執行正常
14353
		$result["status"]="true";
14353
		$result["status"]="true";
14354
		
14354
 
14355
		#回傳結果
14355
		#回傳結果
14356
		return $result;
14356
		return $result;
14357
		
14357
 
14358
		}#function getExtension end
14358
		}#function getExtension end
14359
 
14359
 
14360
	/*
14360
	/*
14361
	#函式說明:
14361
	#函式說明:
14362
	#從檔案尾部開始讀取
14362
	#從檔案尾部開始讀取
14363
	#回傳結果:
14363
	#回傳結果:
14364
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14364
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14365
	#$result["error"],錯誤訊息.
14365
	#$result["error"],錯誤訊息.
14366
	#$result["function"],當前執行的函數名稱.
14366
	#$result["function"],當前執行的函數名稱.
14367
	#$result["argu"],所使用的參數.	
14367
	#$result["argu"],所使用的參數.
14368
	#$result["content"],讀取到的內容陣列.
14368
	#$result["content"],讀取到的內容陣列.
14369
	#$result["totalLineCount"],檔案的總共行數.
14369
	#$result["totalLineCount"],檔案的總共行數.
14370
	#$result["lines"],取得輸出的行數.
14370
	#$result["lines"],取得輸出的行數.
14371
	#$result["lineNum"],取得當前行數.
14371
	#$result["lineNum"],取得當前行數.
14372
	#必填參數:
14372
	#必填參數:
Line 14378... Line 14378...
14378
	#$conf["web"],字串,"true"代表位網頁系統,"false"為檔案系統,預設為"false".
14378
	#$conf["web"],字串,"true"代表位網頁系統,"false"為檔案系統,預設為"false".
14379
	#$conf["web"]="false";
14379
	#$conf["web"]="false";
14380
	#$conf["line2start"],字串,從第幾列開始,預設為總行書減去linesPerTime+1.
14380
	#$conf["line2start"],字串,從第幾列開始,預設為總行書減去linesPerTime+1.
14381
	#$conf["line2start"]="";
14381
	#$conf["line2start"]="";
14382
	#$conf["linesPerTime"],字串,一次最多讀取幾列,預設爲10列.
14382
	#$conf["linesPerTime"],字串,一次最多讀取幾列,預設爲10列.
14383
	#$conf["linesPerTime"]="10";	
14383
	#$conf["linesPerTime"]="10";
14384
	#參考資料:
14384
	#參考資料:
14385
	#無.
14385
	#無.
14386
	#備註:
14386
	#備註:
14387
	#無.
14387
	#無.
14388
	*/
14388
	*/
Line 14394... Line 14394...
14394
		#取得當前執行的函數名稱
14394
		#取得當前執行的函數名稱
14395
		$result["function"]=__FUNCTION__;
14395
		$result["function"]=__FUNCTION__;
14396
 
14396
 
14397
		#如果沒有參數
14397
		#如果沒有參數
14398
		if(func_num_args()==0){
14398
		if(func_num_args()==0){
14399
			
14399
 
14400
			#設置執行失敗
14400
			#設置執行失敗
14401
			$result["status"]="false";
14401
			$result["status"]="false";
14402
			
14402
 
14403
			#設置執行錯誤訊息
14403
			#設置執行錯誤訊息
14404
			$result["error"]="函數".$result["function"]."需要參數";
14404
			$result["error"]="函數".$result["function"]."需要參數";
14405
			
14405
 
14406
			#回傳結果
14406
			#回傳結果
14407
			return $result;
14407
			return $result;
14408
			
14408
 
14409
			}#if end		
14409
			}#if end
14410
 
14410
 
14411
		#取得參數
14411
		#取得參數
14412
		$result["argu"]=$conf;
14412
		$result["argu"]=$conf;
14413
 
14413
 
14414
		#如果 $conf 不為陣列
14414
		#如果 $conf 不為陣列
14415
		if(gettype($conf)!=="array"){
14415
		if(gettype($conf)!=="array"){
14416
			
14416
 
14417
			#設置執行失敗
14417
			#設置執行失敗
14418
			$result["status"]="false";
14418
			$result["status"]="false";
14419
			
14419
 
14420
			#設置執行錯誤訊息
14420
			#設置執行錯誤訊息
14421
			$result["error"][]="\$conf變數須為陣列形態";
14421
			$result["error"][]="\$conf變數須為陣列形態";
14422
			
14422
 
14423
			#如果傳入的參數為 null
14423
			#如果傳入的參數為 null
14424
			if($conf===null){
14424
			if($conf===null){
14425
				
14425
 
14426
				#設置執行錯誤訊息
14426
				#設置執行錯誤訊息
14427
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
14427
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
14428
				
14428
 
14429
				}#if end
14429
				}#if end
14430
 
14430
 
14431
			#回傳結果
14431
			#回傳結果
14432
			return $result;
14432
			return $result;
14433
			
14433
 
14434
			}#if end
14434
			}#if end
14435
		
14435
 
14436
		#函式說明:
14436
		#函式說明:
14437
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
14437
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
14438
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14438
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14439
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
14439
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
14440
		#$result["function"],當前執行的函式名稱.
14440
		#$result["function"],當前執行的函式名稱.
Line 14447... Line 14447...
14447
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
14447
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
14448
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
14448
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
14449
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
14449
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
14450
		#必填寫的參數:
14450
		#必填寫的參數:
14451
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
14451
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
14452
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
14452
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
14453
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
14453
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
14454
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
14454
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
14455
		#可以省略的參數:
14455
		#可以省略的參數:
14456
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
14456
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
14457
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
14457
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
Line 14465... Line 14465...
14465
		#$conf["canBeEmpty"]=array();
14465
		#$conf["canBeEmpty"]=array();
14466
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
14466
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
14467
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web","line2start","linesPerTime");
14467
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web","line2start","linesPerTime");
14468
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
14468
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
14469
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web","line2start","linesPerTime");
14469
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web","line2start","linesPerTime");
14470
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
14470
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
14471
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
14471
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
14472
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
14472
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
14473
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false",null,"10");
14473
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false",null,"10");
14474
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
14474
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
14475
		#$conf["disallowAllSkipableVarIsEmpty"]="";
14475
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 14479... Line 14479...
14479
		#$conf["arrayCountEqualCheck"][]=array();
14479
		#$conf["arrayCountEqualCheck"][]=array();
14480
		#參考資料來源:
14480
		#參考資料來源:
14481
		#array_keys=>http://php.net/manual/en/function.array-keys.php
14481
		#array_keys=>http://php.net/manual/en/function.array-keys.php
14482
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
14482
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
14483
		unset($conf["variableCheck::checkArguments"]);
14483
		unset($conf["variableCheck::checkArguments"]);
14484
		
14484
 
14485
		#如果檢查參數失敗
14485
		#如果檢查參數失敗
14486
		if($checkArguments["status"]==="false"){
14486
		if($checkArguments["status"]==="false"){
14487
			
14487
 
14488
			#設置執行失敗
14488
			#設置執行失敗
14489
			$result["status"]="false";
14489
			$result["status"]="false";
14490
			
14490
 
14491
			#設置執行失敗訊息
14491
			#設置執行失敗訊息
14492
			$result["error"]=$checkArguments;
14492
			$result["error"]=$checkArguments;
14493
			
14493
 
14494
			#回傳結果
14494
			#回傳結果
14495
			return $result;
14495
			return $result;
14496
			
14496
 
14497
			}#if end
14497
			}#if end
14498
			
14498
 
14499
		#如果檢查參數不通過
14499
		#如果檢查參數不通過
14500
		if($checkArguments["passed"]==="false"){
14500
		if($checkArguments["passed"]==="false"){
14501
			
14501
 
14502
			#設置執行失敗
14502
			#設置執行失敗
14503
			$result["status"]="false";
14503
			$result["status"]="false";
14504
			
14504
 
14505
			#設置執行失敗訊息
14505
			#設置執行失敗訊息
14506
			$result["error"]=$checkArguments;
14506
			$result["error"]=$checkArguments;
14507
			
14507
 
14508
			#回傳結果
14508
			#回傳結果
14509
			return $result;
14509
			return $result;
14510
			
14510
 
14511
			}#if end
14511
			}#if end
14512
 
14512
 
14513
		#檢查檔案是否存在
14513
		#檢查檔案是否存在
14514
		#函式說明:
14514
		#函式說明:
14515
		#檢查多個檔案與資料夾是否存在.
14515
		#檢查多個檔案與資料夾是否存在.
Line 14543... Line 14543...
14543
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
14543
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
14544
		unset($conf["fileAccess::checkMultiFileExist"]);
14544
		unset($conf["fileAccess::checkMultiFileExist"]);
14545
 
14545
 
14546
		#如果執行失敗
14546
		#如果執行失敗
14547
		if($checkMultiFileExist["status"]==="false"){
14547
		if($checkMultiFileExist["status"]==="false"){
14548
			
14548
 
14549
			#設置執行失敗
14549
			#設置執行失敗
14550
			$result["status"]="false";
14550
			$result["status"]="false";
14551
			
14551
 
14552
			#設置執行失敗訊息
14552
			#設置執行失敗訊息
14553
			$result["error"]=$checkMultiFileExist;
14553
			$result["error"]=$checkMultiFileExist;
14554
			
14554
 
14555
			#回傳結果
14555
			#回傳結果
14556
			return $result;
14556
			return $result;
14557
			
14557
 
14558
			}#if end
14558
			}#if end
14559
			
14559
 
14560
		#如果檔案無法存取
14560
		#如果檔案無法存取
14561
		if($checkMultiFileExist["allExist"]==="false"){
14561
		if($checkMultiFileExist["allExist"]==="false"){
14562
			
14562
 
14563
			#設置執行失敗
14563
			#設置執行失敗
14564
			$result["status"]="false";
14564
			$result["status"]="false";
14565
			
14565
 
14566
			#設置執行失敗訊息
14566
			#設置執行失敗訊息
14567
			$result["error"]=$checkMultiFileExist;
14567
			$result["error"]=$checkMultiFileExist;
14568
			
14568
 
14569
			#回傳結果
14569
			#回傳結果
14570
			return $result;
14570
			return $result;
14571
			
14571
 
14572
			}#if end
14572
			}#if end
14573
 
14573
 
14574
		#取得檔案的行數
14574
		#取得檔案的行數
14575
		#函式說明:
14575
		#函式說明:
14576
		#呼叫shell執行系統命令,並取得回傳的內容.
14576
		#呼叫shell執行系統命令,並取得回傳的內容.
Line 14588... Line 14588...
14588
		#$result["statusCode"],執行結束後的代碼.
14588
		#$result["statusCode"],執行結束後的代碼.
14589
		#必填的參數
14589
		#必填的參數
14590
		#$conf["command"],字串,要執行的指令與.
14590
		#$conf["command"],字串,要執行的指令與.
14591
		$conf["external::callShell"]["command"]="cat";
14591
		$conf["external::callShell"]["command"]="cat";
14592
		#$conf["fileArgu"],字串,變數__FILE__的內容.
14592
		#$conf["fileArgu"],字串,變數__FILE__的內容.
14593
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
14593
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
14594
		#可省略參數:
14594
		#可省略參數:
14595
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
14595
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
14596
		$conf["external::callShell"]["argu"]=array($conf["file"],"|","wc","-l");
14596
		$conf["external::callShell"]["argu"]=array($conf["file"],"|","wc","-l");
14597
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
14597
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
14598
		#$conf["arguIsAddr"]=array();	
14598
		#$conf["arguIsAddr"]=array();
14599
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
14599
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
14600
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
14600
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
14601
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
14601
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
14602
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
14602
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
14603
		#$conf["enablePrintDescription"]="true";
14603
		#$conf["enablePrintDescription"]="true";
Line 14626... Line 14626...
14626
		$callShell=external::callShell($conf["external::callShell"]);
14626
		$callShell=external::callShell($conf["external::callShell"]);
14627
		unset($conf["external::callShell"]);
14627
		unset($conf["external::callShell"]);
14628
 
14628
 
14629
		#如果檢查參數失敗
14629
		#如果檢查參數失敗
14630
		if($callShell["status"]==="false"){
14630
		if($callShell["status"]==="false"){
14631
			
14631
 
14632
			#設置執行失敗
14632
			#設置執行失敗
14633
			$result["status"]="false";
14633
			$result["status"]="false";
14634
			
14634
 
14635
			#設置執行失敗訊息
14635
			#設置執行失敗訊息
14636
			$result["error"]=$callShell;
14636
			$result["error"]=$callShell;
14637
			
14637
 
14638
			#回傳結果
14638
			#回傳結果
14639
			return $result;
14639
			return $result;
14640
			
14640
 
14641
			}#if end
14641
			}#if end
14642
	
14642
 
14643
		#取得檔案總行數
14643
		#取得檔案總行數
14644
		$result["totalLineCount"]=$callShell["output"][0];
14644
		$result["totalLineCount"]=$callShell["output"][0];
14645
	
14645
 
14646
		#如果未設置 $conf["line2start"]
14646
		#如果未設置 $conf["line2start"]
14647
		if(!isset($conf["line2start"])){
14647
		if(!isset($conf["line2start"])){
14648
		
14648
 
14649
			#$conf["line2start"]為總行數減去一次要看的行數減1
14649
			#$conf["line2start"]為總行數減去一次要看的行數減1
14650
			$conf["line2start"]=$result["totalLineCount"]-$conf["linesPerTime"]+1;
14650
			$conf["line2start"]=$result["totalLineCount"]-$conf["linesPerTime"]+1;
14651
		
14651
 
14652
			}#if end	
14652
			}#if end
14653
				
14653
 
14654
		#如果開始行數小於1		
14654
		#如果開始行數小於1
14655
		if($conf["line2start"]<1){
14655
		if($conf["line2start"]<1){
14656
		
14656
 
14657
			#$conf["line2start"]為總行數減去一次要看的行數減1
14657
			#$conf["line2start"]為總行數減去一次要看的行數減1
14658
			$conf["line2start"]=$result["totalLineCount"]-$conf["linesPerTime"]+1;
14658
			$conf["line2start"]=$result["totalLineCount"]-$conf["linesPerTime"]+1;
14659
		
14659
 
14660
			}#if end
14660
			}#if end
14661
			
14661
 
14662
		#如果開始行數小於1		
14662
		#如果開始行數小於1
14663
		if($conf["line2start"]<1){
14663
		if($conf["line2start"]<1){
14664
		
14664
 
14665
			#$conf["line2start"]為1
14665
			#$conf["line2start"]為1
14666
			$conf["line2start"]=1;
14666
			$conf["line2start"]=1;
14667
		
14667
 
14668
			}#if end
14668
			}#if end
14669
	
14669
 
14670
		#取得指定範圍的行數
14670
		#取得指定範圍的行數
14671
		#取得檔案的行數
14671
		#取得檔案的行數
14672
		#函式說明:
14672
		#函式說明:
14673
		#呼叫shell執行系統命令,並取得回傳的內容.
14673
		#呼叫shell執行系統命令,並取得回傳的內容.
14674
		#回傳的結果:
14674
		#回傳的結果:
Line 14685... Line 14685...
14685
		#$result["statusCode"],執行結束後的代碼.
14685
		#$result["statusCode"],執行結束後的代碼.
14686
		#必填的參數
14686
		#必填的參數
14687
		#$conf["command"],字串,要執行的指令與.
14687
		#$conf["command"],字串,要執行的指令與.
14688
		$conf["external::callShell"]["command"]="sed";
14688
		$conf["external::callShell"]["command"]="sed";
14689
		#$conf["fileArgu"],字串,變數__FILE__的內容.
14689
		#$conf["fileArgu"],字串,變數__FILE__的內容.
14690
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
14690
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
14691
		#可省略參數:
14691
		#可省略參數:
14692
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
14692
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
14693
		$conf["external::callShell"]["argu"]=array("-n",$conf["line2start"].",".($conf["line2start"]+$conf["linesPerTime"]-1)."p",$conf["file"]);
14693
		$conf["external::callShell"]["argu"]=array("-n",$conf["line2start"].",".($conf["line2start"]+$conf["linesPerTime"]-1)."p",$conf["file"]);
14694
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
14694
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
14695
		#$conf["arguIsAddr"]=array();	
14695
		#$conf["arguIsAddr"]=array();
14696
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
14696
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
14697
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
14697
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
14698
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
14698
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
14699
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
14699
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
14700
		#$conf["enablePrintDescription"]="true";
14700
		#$conf["enablePrintDescription"]="true";
Line 14723... Line 14723...
14723
		$callShell=external::callShell($conf["external::callShell"]);
14723
		$callShell=external::callShell($conf["external::callShell"]);
14724
		unset($conf["external::callShell"]);
14724
		unset($conf["external::callShell"]);
14725
 
14725
 
14726
		#如果檢查參數失敗
14726
		#如果檢查參數失敗
14727
		if($callShell["status"]==="false"){
14727
		if($callShell["status"]==="false"){
14728
			
14728
 
14729
			#設置執行失敗
14729
			#設置執行失敗
14730
			$result["status"]="false";
14730
			$result["status"]="false";
14731
			
14731
 
14732
			#設置執行失敗訊息
14732
			#設置執行失敗訊息
14733
			$result["error"]=$callShell;
14733
			$result["error"]=$callShell;
14734
			
14734
 
14735
			#回傳結果
14735
			#回傳結果
14736
			return $result;
14736
			return $result;
14737
			
14737
 
14738
			}#if end
14738
			}#if end
14739
 
14739
 
14740
		#取得輸出的行數
14740
		#取得輸出的行數
14741
		$result["lines"]=count($callShell["output"]);
14741
		$result["lines"]=count($callShell["output"]);
14742
 
14742
 
Line 14744... Line 14744...
14744
		$result["content"]=$callShell["output"];
14744
		$result["content"]=$callShell["output"];
14745
 
14745
 
14746
		#取得當前行數
14746
		#取得當前行數
14747
		$result["lineNum"]=$conf["line2start"]+$result["lines"]-1;
14747
		$result["lineNum"]=$conf["line2start"]+$result["lines"]-1;
14748
 
14748
 
14749
		#如果當前行號小於總行數 
14749
		#如果當前行號小於總行數
14750
		if($result["lineNum"]<$result["totalLineCount"]){
14750
		if($result["lineNum"]<$result["totalLineCount"]){
14751
 
14751
 
14752
			#設置還有剩餘的內容
14752
			#設置還有剩餘的內容
14753
			$result["left"]="true";
14753
			$result["left"]="true";
14754
		
14754
 
14755
			}#if end
14755
			}#if end
14756
 
14756
 
14757
		#反之 
14757
		#反之
14758
		else{
14758
		else{
14759
 
14759
 
14760
			#設置無剩餘的內容
14760
			#設置無剩餘的內容
14761
			$result["left"]="false";
14761
			$result["left"]="false";
14762
 
14762
 
Line 14767... Line 14767...
14767
 
14767
 
14768
		#回傳結果
14768
		#回傳結果
14769
		return $result;
14769
		return $result;
14770
 
14770
 
14771
		}#function tail end
14771
		}#function tail end
14772
		
14772
 
14773
	/*
14773
	/*
14774
	#函式說明:
14774
	#函式說明:
14775
	#解析PHP檔案裡面的變數.
14775
	#解析PHP檔案裡面的變數.
14776
	#回傳結果:
14776
	#回傳結果:
14777
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14777
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14778
	#$result["error"],錯誤訊息.
14778
	#$result["error"],錯誤訊息.
14779
	#$result["function"],當前執行的函數名稱.
14779
	#$result["function"],當前執行的函數名稱.
14780
	#$result["argu"],所使用的參數.	
14780
	#$result["argu"],所使用的參數.
14781
	#$result["content"],找到的變數內容陣列,若有多個變數則會用array來表示.
14781
	#$result["content"],找到的變數內容陣列,若有多個變數則會用array來表示.
14782
	#必填參數:
14782
	#必填參數:
14783
	#$conf["file"],字串,檔案的路徑與名稱.
14783
	#$conf["file"],字串,檔案的路徑與名稱.
14784
	$conf["file"]="";
14784
	$conf["file"]="";
14785
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
14785
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
Line 14793... Line 14793...
14793
	#https://www.php.net/manual/en/function.parse-str.php
14793
	#https://www.php.net/manual/en/function.parse-str.php
14794
	#備註:
14794
	#備註:
14795
	#無.
14795
	#無.
14796
	*/
14796
	*/
14797
	public static function parseVaraiableInPHPfile(&$conf){
14797
	public static function parseVaraiableInPHPfile(&$conf){
14798
	
14798
 
14799
		#初始化要回傳的結果
14799
		#初始化要回傳的結果
14800
		$result=array();
14800
		$result=array();
14801
 
14801
 
14802
		#取得當前執行的函數名稱
14802
		#取得當前執行的函數名稱
14803
		$result["function"]=__FUNCTION__;
14803
		$result["function"]=__FUNCTION__;
14804
 
14804
 
14805
		#如果沒有參數
14805
		#如果沒有參數
14806
		if(func_num_args()==0){
14806
		if(func_num_args()==0){
14807
			
14807
 
14808
			#設置執行失敗
14808
			#設置執行失敗
14809
			$result["status"]="false";
14809
			$result["status"]="false";
14810
			
14810
 
14811
			#設置執行錯誤訊息
14811
			#設置執行錯誤訊息
14812
			$result["error"]="函數".$result["function"]."需要參數";
14812
			$result["error"]="函數".$result["function"]."需要參數";
14813
			
14813
 
14814
			#回傳結果
14814
			#回傳結果
14815
			return $result;
14815
			return $result;
14816
			
14816
 
14817
			}#if end		
14817
			}#if end
14818
 
14818
 
14819
		#取得參數
14819
		#取得參數
14820
		$result["argu"]=$conf;
14820
		$result["argu"]=$conf;
14821
 
14821
 
14822
		#如果 $conf 不為陣列
14822
		#如果 $conf 不為陣列
14823
		if(gettype($conf)!=="array"){
14823
		if(gettype($conf)!=="array"){
14824
			
14824
 
14825
			#設置執行失敗
14825
			#設置執行失敗
14826
			$result["status"]="false";
14826
			$result["status"]="false";
14827
			
14827
 
14828
			#設置執行錯誤訊息
14828
			#設置執行錯誤訊息
14829
			$result["error"][]="\$conf變數須為陣列形態";
14829
			$result["error"][]="\$conf變數須為陣列形態";
14830
			
14830
 
14831
			#如果傳入的參數為 null
14831
			#如果傳入的參數為 null
14832
			if($conf===null){
14832
			if($conf===null){
14833
				
14833
 
14834
				#設置執行錯誤訊息
14834
				#設置執行錯誤訊息
14835
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
14835
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
14836
				
14836
 
14837
				}#if end
14837
				}#if end
14838
 
14838
 
14839
			#回傳結果
14839
			#回傳結果
14840
			return $result;
14840
			return $result;
14841
			
14841
 
14842
			}#if end
14842
			}#if end
14843
		
14843
 
14844
		#函式說明:
14844
		#函式說明:
14845
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
14845
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
14846
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14846
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14847
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
14847
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
14848
		#$result["function"],當前執行的函式名稱.
14848
		#$result["function"],當前執行的函式名稱.
Line 14855... Line 14855...
14855
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
14855
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
14856
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
14856
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
14857
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
14857
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
14858
		#必填寫的參數:
14858
		#必填寫的參數:
14859
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
14859
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
14860
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
14860
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
14861
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
14861
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
14862
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
14862
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
14863
		#可以省略的參數:
14863
		#可以省略的參數:
14864
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
14864
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
14865
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu","varName");
14865
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu","varName");
Line 14873... Line 14873...
14873
		#$conf["canBeEmpty"]=array();
14873
		#$conf["canBeEmpty"]=array();
14874
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
14874
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
14875
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web");
14875
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web");
14876
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
14876
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
14877
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
14877
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
14878
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
14878
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
14879
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
14879
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
14880
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
14880
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
14881
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
14881
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
14882
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
14882
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
14883
		#$conf["disallowAllSkipableVarIsEmpty"]="";
14883
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 14887... Line 14887...
14887
		#$conf["arrayCountEqualCheck"][]=array();
14887
		#$conf["arrayCountEqualCheck"][]=array();
14888
		#參考資料來源:
14888
		#參考資料來源:
14889
		#array_keys=>http://php.net/manual/en/function.array-keys.php
14889
		#array_keys=>http://php.net/manual/en/function.array-keys.php
14890
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
14890
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
14891
		unset($conf["variableCheck::checkArguments"]);
14891
		unset($conf["variableCheck::checkArguments"]);
14892
		
14892
 
14893
		#如果檢查參數失敗
14893
		#如果檢查參數失敗
14894
		if($checkArguments["status"]==="false"){
14894
		if($checkArguments["status"]==="false"){
14895
			
14895
 
14896
			#設置執行失敗
14896
			#設置執行失敗
14897
			$result["status"]="false";
14897
			$result["status"]="false";
14898
			
14898
 
14899
			#設置執行失敗訊息
14899
			#設置執行失敗訊息
14900
			$result["error"]=$checkArguments;
14900
			$result["error"]=$checkArguments;
14901
			
14901
 
14902
			#回傳結果
14902
			#回傳結果
14903
			return $result;
14903
			return $result;
14904
			
14904
 
14905
			}#if end
14905
			}#if end
14906
			
14906
 
14907
		#如果檢查參數不通過
14907
		#如果檢查參數不通過
14908
		if($checkArguments["passed"]==="false"){
14908
		if($checkArguments["passed"]==="false"){
14909
			
14909
 
14910
			#設置執行失敗
14910
			#設置執行失敗
14911
			$result["status"]="false";
14911
			$result["status"]="false";
14912
			
14912
 
14913
			#設置執行失敗訊息
14913
			#設置執行失敗訊息
14914
			$result["error"]=$checkArguments;
14914
			$result["error"]=$checkArguments;
14915
			
14915
 
14916
			#回傳結果
14916
			#回傳結果
14917
			return $result;
14917
			return $result;
14918
			
14918
 
14919
			}#if end
14919
			}#if end
14920
		
14920
 
14921
		#初始化儲存解析出來的變數內容
14921
		#初始化儲存解析出來的變數內容
14922
		$result["content"]=array();
14922
		$result["content"]=array();
14923
			
14923
 
14924
		#讀取檔案
14924
		#讀取檔案
14925
		#函式說明:
14925
		#函式說明:
14926
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
14926
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
14927
		#回傳的變數說明:
14927
		#回傳的變數說明:
14928
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
14928
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
Line 14950... Line 14950...
14950
		$getFileContent=fileAccess::getFileContent($conf["ileAccess::getFileContent"]);
14950
		$getFileContent=fileAccess::getFileContent($conf["ileAccess::getFileContent"]);
14951
		unset($conf["ileAccess::getFileContent"]);
14951
		unset($conf["ileAccess::getFileContent"]);
14952
 
14952
 
14953
		#如果讀取檔案失敗
14953
		#如果讀取檔案失敗
14954
		if($getFileContent["status"]==="false"){
14954
		if($getFileContent["status"]==="false"){
14955
		
14955
 
14956
			#設置執行失敗
14956
			#設置執行失敗
14957
			$result["status"]="false";
14957
			$result["status"]="false";
14958
			
14958
 
14959
			#設置執行失敗訊息
14959
			#設置執行失敗訊息
14960
			$result["error"]=$getFileContent;
14960
			$result["error"]=$getFileContent;
14961
			
14961
 
14962
			#回傳結果
14962
			#回傳結果
14963
			return $result;
14963
			return $result;
14964
		
14964
 
14965
			}#if end
14965
			}#if end
14966
		
14966
 
14967
		#針對每列檔案內容
14967
		#針對每列檔案內容
14968
		foreach($getFileContent["fileContent"] as $line){
14968
		foreach($getFileContent["fileContent"] as $line){
14969
			
14969
 
14970
			#針對每個要搜尋的變數
14970
			#針對每個要搜尋的變數
14971
			foreach($conf["varName"] as $keyWord){
14971
			foreach($conf["varName"] as $keyWord){
14972
			
14972
 
14973
				#如果關鍵字小於被搜尋的字串長度
14973
				#如果關鍵字小於被搜尋的字串長度
14974
				if( strlen($line) < strlen($keyWord)+1 ){
14974
				if( strlen($line) < strlen($keyWord)+1 ){
14975
					
14975
 
14976
					#跳過
14976
					#跳過
14977
					continue;
14977
					continue;
14978
				
14978
 
14979
					}#if end
14979
					}#if end
14980
			
14980
 
14981
				#函式說明:
14981
				#函式說明:
14982
				#取得符合特定字首與字尾的字串
14982
				#取得符合特定字首與字尾的字串
14983
				#回傳結果:
14983
				#回傳結果:
14984
				#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
14984
				#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
14985
				#$result["function"],當前執行的函數名稱.
14985
				#$result["function"],當前執行的函數名稱.
Line 14997... Line 14997...
14997
				$conf["search::getMeetConditionsString"]["tailWord"]=";";
14997
				$conf["search::getMeetConditionsString"]["tailWord"]=";";
14998
				#參考資料:
14998
				#參考資料:
14999
				#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
14999
				#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
15000
				$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
15000
				$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
15001
				unset($conf["search::getMeetConditionsString"]);
15001
				unset($conf["search::getMeetConditionsString"]);
15002
				
15002
 
15003
				#如果失敗
15003
				#如果失敗
15004
				if($getMeetConditionsString["status"]==="false"){
15004
				if($getMeetConditionsString["status"]==="false"){
15005
 
15005
 
15006
					#設置執行失敗
15006
					#設置執行失敗
15007
					$result["status"]="false";
15007
					$result["status"]="false";
15008
					
15008
 
15009
					#設置執行失敗訊息
15009
					#設置執行失敗訊息
15010
					$result["error"]=$getMeetConditionsString;
15010
					$result["error"]=$getMeetConditionsString;
15011
					
15011
 
15012
					#回傳結果
15012
					#回傳結果
15013
					return $result;
15013
					return $result;
15014
				
15014
 
15015
					}#if end	
15015
					}#if end
15016
					
15016
 
15017
				#如果有找到關鍵字
15017
				#如果有找到關鍵字
15018
				if($getMeetConditionsString["founded"]==="true"){
15018
				if($getMeetConditionsString["founded"]==="true"){
15019
				
15019
 
15020
					#剔除變數名稱
15020
					#剔除變數名稱
15021
					#函式說明:
15021
					#函式說明:
15022
					#將字串特定關鍵字與其前面的內容剔除
15022
					#將字串特定關鍵字與其前面的內容剔除
15023
					#回傳結果:
15023
					#回傳結果:
15024
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15024
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15025
					#$result["error"],錯誤訊息陣列.
15025
					#$result["error"],錯誤訊息陣列.
15026
					#$result["warning"],警告訊息鎮列.
15026
					#$result["warning"],警告訊息鎮列.
15027
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
15027
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
15028
					#$result["function"],當前執行的函數名稱.
15028
					#$result["function"],當前執行的函數名稱.
15029
					#$result["oriStr"],要處理的原始字串內容.
15029
					#$result["oriStr"],要處理的原始字串內容.
15030
					#$result["content"],處理好的的字串內容.	
15030
					#$result["content"],處理好的的字串內容.
15031
					#必填參數:
15031
					#必填參數:
15032
					#$conf["stringIn"],字串,要處理的字串.
15032
					#$conf["stringIn"],字串,要處理的字串.
15033
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$line;
15033
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$line;
15034
					#$conf["keyWord"],字串,特定字串.
15034
					#$conf["keyWord"],字串,特定字串.
15035
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="$".$keyWord;
15035
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="$".$keyWord;
Line 15040... Line 15040...
15040
					#無.
15040
					#無.
15041
					#備註:
15041
					#備註:
15042
					#無.
15042
					#無.
15043
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
15043
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
15044
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
15044
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
15045
				
15045
 
15046
					#如果執行失敗
15046
					#如果執行失敗
15047
					if($delStrBeforeKeyWord["status"]==="false"){
15047
					if($delStrBeforeKeyWord["status"]==="false"){
15048
					
15048
 
15049
						#設置執行失敗
15049
						#設置執行失敗
15050
						$result["status"]="false";
15050
						$result["status"]="false";
15051
						
15051
 
15052
						#設置執行失敗訊息
15052
						#設置執行失敗訊息
15053
						$result["error"]=$delStrBeforeKeyWord;
15053
						$result["error"]=$delStrBeforeKeyWord;
15054
						
15054
 
15055
						#回傳結果
15055
						#回傳結果
15056
						return $result;
15056
						return $result;
15057
					
15057
 
15058
						}#if end
15058
						}#if end
15059
						
15059
 
15060
					#如果沒有找到應該存在的php變數
15060
					#如果沒有找到應該存在的php變數
15061
					if($delStrBeforeKeyWord["founded"]==="false"){
15061
					if($delStrBeforeKeyWord["founded"]==="false"){
15062
					
15062
 
15063
						#設置執行失敗
15063
						#設置執行失敗
15064
						$result["status"]="false";
15064
						$result["status"]="false";
15065
						
15065
 
15066
						#設置執行失敗訊息
15066
						#設置執行失敗訊息
15067
						$result["error"]=$delStrBeforeKeyWord;
15067
						$result["error"]=$delStrBeforeKeyWord;
15068
						
15068
 
15069
						#回傳結果
15069
						#回傳結果
15070
						return $result;
15070
						return $result;
15071
					
15071
 
15072
						}#if end
15072
						}#if end
15073
						
15073
 
15074
					#剔除 "=" 前面的內容
15074
					#剔除 "=" 前面的內容
15075
					#函式說明:
15075
					#函式說明:
15076
					#將字串特定關鍵字與其前面的內容剔除
15076
					#將字串特定關鍵字與其前面的內容剔除
15077
					#回傳結果:
15077
					#回傳結果:
15078
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15078
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15079
					#$result["error"],錯誤訊息陣列.
15079
					#$result["error"],錯誤訊息陣列.
15080
					#$result["warning"],警告訊息鎮列.
15080
					#$result["warning"],警告訊息鎮列.
15081
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
15081
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
15082
					#$result["function"],當前執行的函數名稱.
15082
					#$result["function"],當前執行的函數名稱.
15083
					#$result["oriStr"],要處理的原始字串內容.
15083
					#$result["oriStr"],要處理的原始字串內容.
15084
					#$result["content"],處理好的的字串內容.	
15084
					#$result["content"],處理好的的字串內容.
15085
					#必填參數:
15085
					#必填參數:
15086
					#$conf["stringIn"],字串,要處理的字串.
15086
					#$conf["stringIn"],字串,要處理的字串.
15087
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$delStrBeforeKeyWord["content"];
15087
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$delStrBeforeKeyWord["content"];
15088
					#$conf["keyWord"],字串,特定字串.
15088
					#$conf["keyWord"],字串,特定字串.
15089
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="=";
15089
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="=";
Line 15094... Line 15094...
15094
					#無.
15094
					#無.
15095
					#備註:
15095
					#備註:
15096
					#無.
15096
					#無.
15097
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
15097
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
15098
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
15098
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
15099
				
15099
 
15100
					#如果執行失敗
15100
					#如果執行失敗
15101
					if($delStrBeforeKeyWord["status"]==="false"){
15101
					if($delStrBeforeKeyWord["status"]==="false"){
15102
					
15102
 
15103
						#設置執行失敗
15103
						#設置執行失敗
15104
						$result["status"]="false";
15104
						$result["status"]="false";
15105
						
15105
 
15106
						#設置執行失敗訊息
15106
						#設置執行失敗訊息
15107
						$result["error"]=$delStrBeforeKeyWord;
15107
						$result["error"]=$delStrBeforeKeyWord;
15108
						
15108
 
15109
						#回傳結果
15109
						#回傳結果
15110
						return $result;
15110
						return $result;
15111
					
15111
 
15112
						}#if end
15112
						}#if end
15113
						
15113
 
15114
					#如果沒有找“=”關鍵字
15114
					#如果沒有找“=”關鍵字
15115
					if($delStrBeforeKeyWord["founded"]==="false"){
15115
					if($delStrBeforeKeyWord["founded"]==="false"){
15116
					
15116
 
15117
						#跳過
15117
						#跳過
15118
						continue;
15118
						continue;
15119
					
15119
 
15120
						}#if end
15120
						}#if end
15121
				
15121
 
15122
					#剔除 value 前面的空白
15122
					#剔除 value 前面的空白
15123
					#函式說明:
15123
					#函式說明:
15124
					#將字串特定關鍵字與其前面的內容剔除
15124
					#將字串特定關鍵字與其前面的內容剔除
15125
					#回傳結果:
15125
					#回傳結果:
15126
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15126
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15127
					#$result["error"],錯誤訊息陣列.
15127
					#$result["error"],錯誤訊息陣列.
15128
					#$result["warning"],警告訊息鎮列.
15128
					#$result["warning"],警告訊息鎮列.
15129
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
15129
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
15130
					#$result["function"],當前執行的函數名稱.
15130
					#$result["function"],當前執行的函數名稱.
15131
					#$result["oriStr"],要處理的原始字串內容.
15131
					#$result["oriStr"],要處理的原始字串內容.
15132
					#$result["content"],處理好的的字串內容.	
15132
					#$result["content"],處理好的的字串內容.
15133
					#必填參數:
15133
					#必填參數:
15134
					#$conf["stringIn"],字串,要處理的字串.
15134
					#$conf["stringIn"],字串,要處理的字串.
15135
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$delStrBeforeKeyWord["content"];
15135
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$delStrBeforeKeyWord["content"];
15136
					#$conf["keyWord"],字串,特定字串.
15136
					#$conf["keyWord"],字串,特定字串.
15137
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
15137
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
Line 15142... Line 15142...
15142
					#無.
15142
					#無.
15143
					#備註:
15143
					#備註:
15144
					#無.
15144
					#無.
15145
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
15145
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
15146
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
15146
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
15147
				
15147
 
15148
					#如果執行失敗
15148
					#如果執行失敗
15149
					if($delStrBeforeKeyWord["status"]==="false"){
15149
					if($delStrBeforeKeyWord["status"]==="false"){
15150
					
15150
 
15151
						#設置執行失敗
15151
						#設置執行失敗
15152
						$result["status"]="false";
15152
						$result["status"]="false";
15153
						
15153
 
15154
						#設置執行失敗訊息
15154
						#設置執行失敗訊息
15155
						$result["error"]=$delStrBeforeKeyWord;
15155
						$result["error"]=$delStrBeforeKeyWord;
15156
						
15156
 
15157
						#回傳結果
15157
						#回傳結果
15158
						return $result;
15158
						return $result;
15159
					
15159
 
15160
						}#if end
15160
						}#if end
15161
				
15161
 
15162
					#取得找到的變數
15162
					#取得找到的變數
15163
					eval("\$result[\"content\"][\"".$keyWord."\"][]=".$delStrBeforeKeyWord["content"]);
15163
					eval("\$result[\"content\"][\"".$keyWord."\"][]=".$delStrBeforeKeyWord["content"]);
15164
											
15164
 
15165
					}#if end
15165
					}#if end
15166
				
15166
 
15167
				}#foreach end
15167
				}#foreach end
15168
			
15168
 
15169
			}#foreach end
15169
			}#foreach end
15170
		
15170
 
15171
		#設置執行正常
15171
		#設置執行正常
15172
		$result["status"]="true";
15172
		$result["status"]="true";
15173
	
15173
 
15174
		#回傳結果
15174
		#回傳結果
15175
		return $result;
15175
		return $result;
15176
	
15176
 
15177
		}#function parseVaraiableInPHPfile end
15177
		}#function parseVaraiableInPHPfile end
15178
 
15178
 
15179
	/*
15179
	/*
15180
	#函式說明:
15180
	#函式說明:
15181
	#開啟特定目錄,取得底下的檔案路徑清單.
15181
	#開啟特定目錄,取得底下的檔案路徑清單.
Line 15199... Line 15199...
15199
	#無.
15199
	#無.
15200
	#備註:
15200
	#備註:
15201
	#無.
15201
	#無.
15202
	*/
15202
	*/
15203
	public static function listInfo(&$conf){
15203
	public static function listInfo(&$conf){
15204
	
15204
 
15205
		#初始化要回傳的結果
15205
		#初始化要回傳的結果
15206
		$result=array();
15206
		$result=array();
15207
 
15207
 
15208
		#取得當前執行的函數名稱
15208
		#取得當前執行的函數名稱
15209
		$result["function"]=__FUNCTION__;
15209
		$result["function"]=__FUNCTION__;
15210
 
15210
 
15211
		#如果沒有參數
15211
		#如果沒有參數
15212
		if(func_num_args()==0){
15212
		if(func_num_args()==0){
15213
			
15213
 
15214
			#設置執行失敗
15214
			#設置執行失敗
15215
			$result["status"]="false";
15215
			$result["status"]="false";
15216
			
15216
 
15217
			#設置執行錯誤訊息
15217
			#設置執行錯誤訊息
15218
			$result["error"]="函數".$result["function"]."需要參數";
15218
			$result["error"]="函數".$result["function"]."需要參數";
15219
			
15219
 
15220
			#回傳結果
15220
			#回傳結果
15221
			return $result;
15221
			return $result;
15222
			
15222
 
15223
			}#if end		
15223
			}#if end
15224
 
15224
 
15225
		#取得參數
15225
		#取得參數
15226
		$result["argu"]=$conf;
15226
		$result["argu"]=$conf;
15227
 
15227
 
15228
		#如果 $conf 不為陣列
15228
		#如果 $conf 不為陣列
15229
		if(gettype($conf)!=="array"){
15229
		if(gettype($conf)!=="array"){
15230
			
15230
 
15231
			#設置執行失敗
15231
			#設置執行失敗
15232
			$result["status"]="false";
15232
			$result["status"]="false";
15233
			
15233
 
15234
			#設置執行錯誤訊息
15234
			#設置執行錯誤訊息
15235
			$result["error"][]="\$conf變數須為陣列形態";
15235
			$result["error"][]="\$conf變數須為陣列形態";
15236
			
15236
 
15237
			#如果傳入的參數為 null
15237
			#如果傳入的參數為 null
15238
			if($conf===null){
15238
			if($conf===null){
15239
				
15239
 
15240
				#設置執行錯誤訊息
15240
				#設置執行錯誤訊息
15241
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
15241
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
15242
				
15242
 
15243
				}#if end
15243
				}#if end
15244
 
15244
 
15245
			#回傳結果
15245
			#回傳結果
15246
			return $result;
15246
			return $result;
15247
			
15247
 
15248
			}#if end
15248
			}#if end
15249
		
15249
 
15250
		#函式說明:
15250
		#函式說明:
15251
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
15251
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
15252
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15252
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15253
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
15253
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
15254
		#$result["function"],當前執行的函式名稱.
15254
		#$result["function"],當前執行的函式名稱.
Line 15261... Line 15261...
15261
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
15261
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
15262
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
15262
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
15263
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
15263
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
15264
		#必填寫的參數:
15264
		#必填寫的參數:
15265
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
15265
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
15266
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
15266
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
15267
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
15267
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
15268
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
15268
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
15269
		#可以省略的參數:
15269
		#可以省略的參數:
15270
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
15270
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
15271
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path");
15271
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path");
Line 15279... Line 15279...
15279
		#$conf["canBeEmpty"]=array();
15279
		#$conf["canBeEmpty"]=array();
15280
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
15280
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
15281
		#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web");
15281
		#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web");
15282
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
15282
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
15283
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
15283
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
15284
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
15284
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
15285
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
15285
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
15286
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
15286
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
15287
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
15287
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
15288
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
15288
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
15289
		#$conf["disallowAllSkipableVarIsEmpty"]="";
15289
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 15293... Line 15293...
15293
		#$conf["arrayCountEqualCheck"][]=array();
15293
		#$conf["arrayCountEqualCheck"][]=array();
15294
		#參考資料來源:
15294
		#參考資料來源:
15295
		#array_keys=>http://php.net/manual/en/function.array-keys.php
15295
		#array_keys=>http://php.net/manual/en/function.array-keys.php
15296
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
15296
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
15297
		unset($conf["variableCheck::checkArguments"]);
15297
		unset($conf["variableCheck::checkArguments"]);
15298
		
15298
 
15299
		#如果檢查參數失敗
15299
		#如果檢查參數失敗
15300
		if($checkArguments["status"]==="false"){
15300
		if($checkArguments["status"]==="false"){
15301
			
15301
 
15302
			#設置執行失敗
15302
			#設置執行失敗
15303
			$result["status"]="false";
15303
			$result["status"]="false";
15304
			
15304
 
15305
			#設置執行失敗訊息
15305
			#設置執行失敗訊息
15306
			$result["error"]=$checkArguments;
15306
			$result["error"]=$checkArguments;
15307
			
15307
 
15308
			#回傳結果
15308
			#回傳結果
15309
			return $result;
15309
			return $result;
15310
			
15310
 
15311
			}#if end
15311
			}#if end
15312
			
15312
 
15313
		#如果檢查參數不通過
15313
		#如果檢查參數不通過
15314
		if($checkArguments["passed"]==="false"){
15314
		if($checkArguments["passed"]==="false"){
15315
			
15315
 
15316
			#設置執行失敗
15316
			#設置執行失敗
15317
			$result["status"]="false";
15317
			$result["status"]="false";
15318
			
15318
 
15319
			#設置執行失敗訊息
15319
			#設置執行失敗訊息
15320
			$result["error"]=$checkArguments;
15320
			$result["error"]=$checkArguments;
15321
			
15321
 
15322
			#回傳結果
15322
			#回傳結果
15323
			return $result;
15323
			return $result;
15324
			
15324
 
15325
			}#if end
15325
			}#if end
15326
		
15326
 
15327
		#初始化儲存解析出來的變數內容
15327
		#初始化儲存解析出來的變數內容
15328
		$result["content"]=array();
15328
		$result["content"]=array();
15329
	
15329
 
15330
		#取得特定位置的資訊
15330
		#取得特定位置的資訊
15331
		$pathInfo=@dir($conf["path"]);
15331
		$pathInfo=@dir($conf["path"]);
15332
		
15332
 
15333
		#如果取得路徑資訊失敗
15333
		#如果取得路徑資訊失敗
15334
		if($pathInfo===false){
15334
		if($pathInfo===false){
15335
		
15335
 
15336
			#設置執行失敗
15336
			#設置執行失敗
15337
			$result["status"]="false";
15337
			$result["status"]="false";
15338
			
15338
 
15339
			#設置執行失敗訊息
15339
			#設置執行失敗訊息
15340
			$result["error"][]="無法存取路徑(".$conf["path"].")";
15340
			$result["error"][]="無法存取路徑(".$conf["path"].")";
15341
			
15341
 
15342
			#回傳結果
15342
			#回傳結果
15343
			return $result;
15343
			return $result;
15344
			
15344
 
15345
			}#if end
15345
			}#if end
15346
		
15346
 
15347
		#讀取底下一個檔案,暫存到 $tmpItem 裡面,且當結果不為 false 時進入迴圈.
15347
		#讀取底下一個檔案,暫存到 $tmpItem 裡面,且當結果不為 false 時進入迴圈.
15348
		while(false !== $tmpItem = $pathInfo->read()){
15348
		while(false !== $tmpItem = $pathInfo->read()){
15349
		
15349
 
15350
			#宣告儲存資訊的變數
15350
			#宣告儲存資訊的變數
15351
			$item=array();
15351
			$item=array();
15352
			
15352
 
15353
			#儲存名稱
15353
			#儲存名稱
15354
			$item["name"]=$tmpItem;
15354
			$item["name"]=$tmpItem;
15355
			
15355
 
15356
			#預設不為資料夾
15356
			#預設不為資料夾
15357
			$item["dir"]="false";
15357
			$item["dir"]="false";
15358
			
15358
 
15359
			#若為資料夾
15359
			#若為資料夾
15360
			if(is_dir($conf["path"]."/".$tmpItem)){
15360
			if(is_dir($conf["path"]."/".$tmpItem)){
15361
			
15361
 
15362
				#設置為"true"
15362
				#設置為"true"
15363
				$item["dir"]="true";
15363
				$item["dir"]="true";
15364
			
15364
 
15365
				}#if end
15365
				}#if end
15366
				
15366
 
15367
			#取得檔案識別器
15367
			#取得檔案識別器
15368
			$finfo = finfo_open(FILEINFO_MIME);
15368
			$finfo = finfo_open(FILEINFO_MIME);
15369
			
15369
 
15370
			#取得 info
15370
			#取得 info
15371
			$item["info"]=@finfo_file($finfo,$conf["path"]."/".$tmpItem);
15371
			$item["info"]=@finfo_file($finfo,$conf["path"]."/".$tmpItem);
15372
 
15372
 
15373
			#取得檔案大小
15373
			#取得檔案大小
15374
			$item["size"]=filesize($conf["path"]."/".$tmpItem);
15374
			$item["size"]=filesize($conf["path"]."/".$tmpItem);
15375
 
15375
 
15376
			#close connection
15376
			#close connection
15377
			finfo_close($finfo);
15377
			finfo_close($finfo);
15378
					
15378
 
15379
			#記錄該檔案資訊
15379
			#記錄該檔案資訊
15380
			$result["content"][]=$item;
15380
			$result["content"][]=$item;
15381
		
15381
 
15382
			}#while end
15382
			}#while end
15383
			
15383
 
15384
		#設置執行正常
15384
		#設置執行正常
15385
		$result["status"]="true";
15385
		$result["status"]="true";
15386
		
15386
 
15387
		#回傳結果
15387
		#回傳結果
15388
		return $result;
15388
		return $result;
15389
		
15389
 
15390
		}#function listInfo end
15390
		}#function listInfo end
15391
 
15391
 
15392
	/*
15392
	/*
15393
	#函式說明:
15393
	#函式說明:
15394
	#取得目錄底下的詳細資訊.
15394
	#取得目錄底下的詳細資訊.
Line 15422... Line 15422...
15422
	#https://www.businessweekly.com.tw/careers/Blog/14307
15422
	#https://www.businessweekly.com.tw/careers/Blog/14307
15423
	#備註:
15423
	#備註:
15424
	#無.
15424
	#無.
15425
	*/
15425
	*/
15426
	public static function ls(&$conf){
15426
	public static function ls(&$conf){
15427
	
15427
 
15428
		#初始化要回傳的結果
15428
		#初始化要回傳的結果
15429
		$result=array();
15429
		$result=array();
15430
 
15430
 
15431
		#取得當前執行的函數名稱
15431
		#取得當前執行的函數名稱
15432
		$result["function"]=__FUNCTION__;
15432
		$result["function"]=__FUNCTION__;
Line 15467... Line 15467...
15467
 
15467
 
15468
			#回傳結果
15468
			#回傳結果
15469
			return $result;
15469
			return $result;
15470
 
15470
 
15471
			}#if end
15471
			}#if end
15472
	
15472
 
15473
		#函式說明:
15473
		#函式說明:
15474
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
15474
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
15475
		#回傳結果:
15475
		#回傳結果:
15476
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15476
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15477
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
15477
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 15520... Line 15520...
15520
		#array_keys=>http://php.net/manual/en/function.array-keys.php
15520
		#array_keys=>http://php.net/manual/en/function.array-keys.php
15521
		#備註:
15521
		#備註:
15522
		#無.
15522
		#無.
15523
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
15523
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
15524
		unset($conf["variableCheck::checkArguments"]);
15524
		unset($conf["variableCheck::checkArguments"]);
15525
	
15525
 
15526
		#如果執行失敗
15526
		#如果執行失敗
15527
		if($checkArguments["status"]==="false"){
15527
		if($checkArguments["status"]==="false"){
15528
		
15528
 
15529
			#設置執行錯誤
15529
			#設置執行錯誤
15530
			$result["status"]="false";
15530
			$result["status"]="false";
15531
		
15531
 
15532
			#設置錯誤訊息
15532
			#設置錯誤訊息
15533
			$result["error"]=$checkArguments;
15533
			$result["error"]=$checkArguments;
15534
		
15534
 
15535
			#回傳結果
15535
			#回傳結果
15536
			return $result;
15536
			return $result;
15537
		
15537
 
15538
			}#if end
15538
			}#if end
15539
			
15539
 
15540
		#如果參數檢查不通過
15540
		#如果參數檢查不通過
15541
		if($checkArguments["passed"]==="false"){
15541
		if($checkArguments["passed"]==="false"){
15542
		
15542
 
15543
			#設置執行錯誤
15543
			#設置執行錯誤
15544
			$result["status"]="false";
15544
			$result["status"]="false";
15545
		
15545
 
15546
			#設置錯誤訊息
15546
			#設置錯誤訊息
15547
			$result["error"]=$checkArguments;
15547
			$result["error"]=$checkArguments;
15548
		
15548
 
15549
			#回傳結果
15549
			#回傳結果
15550
			return $result;
15550
			return $result;
15551
		
15551
 
15552
			}#if end
15552
			}#if end
15553
	
15553
 
15554
		#確認 $conf["path"] 是否為 "/" 結尾
15554
		#確認 $conf["path"] 是否為 "/" 結尾
15555
		#函式說明:
15555
		#函式說明:
15556
		#取得符合特定字首與字尾的字串
15556
		#取得符合特定字首與字尾的字串
15557
		#回傳結果:
15557
		#回傳結果:
15558
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
15558
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
Line 15574... Line 15574...
15574
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
15574
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
15575
		#備註:
15575
		#備註:
15576
		#無.
15576
		#無.
15577
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
15577
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
15578
		unset($conf["search::getMeetConditionsString"]);
15578
		unset($conf["search::getMeetConditionsString"]);
15579
	
15579
 
15580
		#如果執行失敗
15580
		#如果執行失敗
15581
		if($getMeetConditionsString["status"]==="false"){
15581
		if($getMeetConditionsString["status"]==="false"){
15582
		
15582
 
15583
			#設置執行錯誤
15583
			#設置執行錯誤
15584
			$result["status"]="false";
15584
			$result["status"]="false";
15585
		
15585
 
15586
			#設置錯誤訊息
15586
			#設置錯誤訊息
15587
			$result["error"]=$getMeetConditionsString;
15587
			$result["error"]=$getMeetConditionsString;
15588
		
15588
 
15589
			#回傳結果
15589
			#回傳結果
15590
			return $result;
15590
			return $result;
15591
		
15591
 
15592
			}#if end
15592
			}#if end
15593
			
15593
 
15594
		#如果沒有 "/" 結尾
15594
		#如果沒有 "/" 結尾
15595
		if($getMeetConditionsString["founded"]==="false"){
15595
		if($getMeetConditionsString["founded"]==="false"){
15596
		
15596
 
15597
			#於結尾加上 "/"
15597
			#於結尾加上 "/"
15598
			$conf["path"]=$conf["path"]."/";
15598
			$conf["path"]=$conf["path"]."/";
15599
			
15599
 
15600
			}#if end
15600
			}#if end
15601
			
15601
 
15602
		#記錄真正的路徑
15602
		#記錄真正的路徑
15603
		$result["path"]=$conf["path"];
15603
		$result["path"]=$conf["path"];
15604
	
15604
 
15605
		#函式說明:
15605
		#函式說明:
15606
		#呼叫shell執行系統命令,並取得回傳的內容.
15606
		#呼叫shell執行系統命令,並取得回傳的內容.
15607
		#回傳結果:
15607
		#回傳結果:
15608
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15608
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15609
		#$result["error"],錯誤訊息陣列.
15609
		#$result["error"],錯誤訊息陣列.
Line 15659... Line 15659...
15659
		#備註:
15659
		#備註:
15660
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
15660
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
15661
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
15661
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
15662
		$callShell=external::callShell($conf["external::callShell"]);
15662
		$callShell=external::callShell($conf["external::callShell"]);
15663
		unset($conf["external::callShell"]);
15663
		unset($conf["external::callShell"]);
15664
	
15664
 
15665
		#debug
15665
		#debug
15666
		#var_dump(__FILE__,__LINE__,$callShell);
15666
		#var_dump(__FILE__,__LINE__,$callShell);
15667
	
15667
 
15668
		#如果執行失敗
15668
		#如果執行失敗
15669
		if($callShell["status"]==="false"){
15669
		if($callShell["status"]==="false"){
15670
		
15670
 
15671
			#設置執行錯誤
15671
			#設置執行錯誤
15672
			$result["status"]="false";
15672
			$result["status"]="false";
15673
		
15673
 
15674
			#設置錯誤訊息
15674
			#設置錯誤訊息
15675
			$result["error"]=$callShell;
15675
			$result["error"]=$callShell;
15676
		
15676
 
15677
			#回傳結果
15677
			#回傳結果
15678
			return $result;
15678
			return $result;
15679
		
15679
 
15680
			}#if end
15680
			}#if end
15681
		
15681
 
15682
		#初始化儲存檔案資訊為空
15682
		#初始化儲存檔案資訊為空
15683
		$result["content"]=array();
15683
		$result["content"]=array();
15684
		
15684
 
15685
		#針對每行輸出
15685
		#針對每行輸出
15686
		foreach($callShell["output"] as $index=>$line){
15686
		foreach($callShell["output"] as $index=>$line){
15687
		
15687
 
15688
			#如果是第一筆
15688
			#如果是第一筆
15689
			if($index===0){
15689
			if($index===0){
15690
		
15690
 
15691
				#取得資料筆數
15691
				#取得資料筆數
15692
				$result["dataCount"]=explode(" ",$line)[0];
15692
				$result["dataCount"]=explode(" ",$line)[0];
15693
		
15693
 
15694
				#換下一輪
15694
				#換下一輪
15695
				continue;
15695
				continue;
15696
		
15696
 
15697
				}#if end
15697
				}#if end
15698
		
15698
 
15699
			#函式說明:
15699
			#函式說明:
15700
			#將固定格式的字串分開,並回傳分開的結果.
15700
			#將固定格式的字串分開,並回傳分開的結果.
15701
			#回傳結果:
15701
			#回傳結果:
15702
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15702
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15703
			#$result["error"],錯誤訊息陣列
15703
			#$result["error"],錯誤訊息陣列
Line 15719... Line 15719...
15719
			#無.
15719
			#無.
15720
			#備註:
15720
			#備註:
15721
			#無.
15721
			#無.
15722
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
15722
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
15723
			unset($conf["stringProcess::spiltString"]);
15723
			unset($conf["stringProcess::spiltString"]);
15724
		
15724
 
15725
			#如果執行失敗
15725
			#如果執行失敗
15726
			if($spiltString["status"]==="false"){
15726
			if($spiltString["status"]==="false"){
15727
			
15727
 
15728
				#設置執行錯誤
15728
				#設置執行錯誤
15729
				$result["status"]="false";
15729
				$result["status"]="false";
15730
			
15730
 
15731
				#設置錯誤訊息
15731
				#設置錯誤訊息
15732
				$result["error"]=$spiltString;
15732
				$result["error"]=$spiltString;
15733
			
15733
 
15734
				#回傳結果
15734
				#回傳結果
15735
				return $result;
15735
				return $result;
15736
			
15736
 
15737
				}#if end
15737
				}#if end
15738
				
15738
 
15739
			#如果沒有分割用的" "
15739
			#如果沒有分割用的" "
15740
			if($spiltString["found"]==="false"){
15740
			if($spiltString["found"]==="false"){
15741
			
15741
 
15742
				#設置執行錯誤
15742
				#設置執行錯誤
15743
				$result["status"]="false";
15743
				$result["status"]="false";
15744
			
15744
 
15745
				#設置錯誤訊息
15745
				#設置錯誤訊息
15746
				$result["error"]=$spiltString;
15746
				$result["error"]=$spiltString;
15747
			
15747
 
15748
				#回傳結果
15748
				#回傳結果
15749
				return $result;
15749
				return $result;
15750
			
15750
 
15751
				}#if end
15751
				}#if end
15752
		
15752
 
15753
			#如果分割好的數量小於8
15753
			#如果分割好的數量小於8
15754
			if($spiltString["dataCounts"]<8){
15754
			if($spiltString["dataCounts"]<8){
15755
			
15755
 
15756
				#設置執行錯誤
15756
				#設置執行錯誤
15757
				$result["status"]="false";
15757
				$result["status"]="false";
15758
			
15758
 
15759
				#設置錯誤訊息
15759
				#設置錯誤訊息
15760
				$result["error"]=$spiltString;
15760
				$result["error"]=$spiltString;
15761
			
15761
 
15762
				#回傳結果
15762
				#回傳結果
15763
				return $result;
15763
				return $result;
15764
			
15764
 
15765
				}#if end
15765
				}#if end
15766
		
15766
 
15767
			#初始化要儲存的檔案資訊陣列
15767
			#初始化要儲存的檔案資訊陣列
15768
			$fileInfo=array();
15768
			$fileInfo=array();
15769
			
15769
 
15770
			#取得 節點類型、權限
15770
			#取得 節點類型、權限
15771
			$fileInfo["nType&permission"]=$spiltString["dataArray"][0];
15771
			$fileInfo["nType&permission"]=$spiltString["dataArray"][0];
15772
		
15772
 
15773
			#剔除結尾的 "."
15773
			#剔除結尾的 "."
15774
			$fileInfo["nType&permission"]=substr($fileInfo["nType&permission"],0,strlen($fileInfo["nType&permission"])-1);
15774
			$fileInfo["nType&permission"]=substr($fileInfo["nType&permission"],0,strlen($fileInfo["nType&permission"])-1);
15775
		
15775
 
15776
			#取得節點類型
15776
			#取得節點類型
15777
			$fileInfo["nType"]=$fileInfo["nType&permission"][0];
15777
			$fileInfo["nType"]=$fileInfo["nType&permission"][0];
15778
			
15778
 
15779
			#取得節點權限
15779
			#取得節點權限
15780
			$fileInfo["permission"]=substr($fileInfo["nType&permission"],1);
15780
			$fileInfo["permission"]=substr($fileInfo["nType&permission"],1);
15781
			
15781
 
15782
			#取得擁有者賬號
15782
			#取得擁有者賬號
15783
			$fileInfo["ownByUser"]=$spiltString["dataArray"][2];
15783
			$fileInfo["ownByUser"]=$spiltString["dataArray"][2];
15784
		
15784
 
15785
			#取得群組擁有者群組
15785
			#取得群組擁有者群組
15786
			$fileInfo["ownByGroup"]=$spiltString["dataArray"][3];
15786
			$fileInfo["ownByGroup"]=$spiltString["dataArray"][3];
15787
			
15787
 
15788
			#取得size
15788
			#取得size
15789
			$fileInfo["bytes"]=$spiltString["dataArray"][4];
15789
			$fileInfo["bytes"]=$spiltString["dataArray"][4];
15790
		
15790
 
15791
			#取得最後異動日期 
15791
			#取得最後異動日期
15792
			$fileInfo["date"]=$spiltString["dataArray"][5];
15792
			$fileInfo["date"]=$spiltString["dataArray"][5];
15793
		
15793
 
15794
			#取得最後異動時間
15794
			#取得最後異動時間
15795
			$fileInfo["time"]=explode(".",$spiltString["dataArray"][6])[0];
15795
			$fileInfo["time"]=explode(".",$spiltString["dataArray"][6])[0];
15796
		
15796
 
15797
			#取得最後異動的詳細時間
15797
			#取得最後異動的詳細時間
15798
			$fileInfo["timeDetail"]=$spiltString["dataArray"][6];
15798
			$fileInfo["timeDetail"]=$spiltString["dataArray"][6];
15799
		
15799
 
15800
			#取得timezone資訊
15800
			#取得timezone資訊
15801
			$fileInfo["timezone"]=$spiltString["dataArray"][7];
15801
			$fileInfo["timezone"]=$spiltString["dataArray"][7];
15802
		
15802
 
15803
			#函式說明:
15803
			#函式說明:
15804
			#將固定格式的字串分開,並回傳分開的結果.
15804
			#將固定格式的字串分開,並回傳分開的結果.
15805
			#回傳結果:
15805
			#回傳結果:
15806
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15806
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15807
			#$result["error"],錯誤訊息陣列
15807
			#$result["error"],錯誤訊息陣列
Line 15823... Line 15823...
15823
			#無.
15823
			#無.
15824
			#備註:
15824
			#備註:
15825
			#無.
15825
			#無.
15826
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
15826
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
15827
			unset($conf["stringProcess::spiltString"]);
15827
			unset($conf["stringProcess::spiltString"]);
15828
		
15828
 
15829
			#如果執行失敗
15829
			#如果執行失敗
15830
			if($spiltString["status"]==="false"){
15830
			if($spiltString["status"]==="false"){
15831
			
15831
 
15832
				#設置執行錯誤
15832
				#設置執行錯誤
15833
				$result["status"]="false";
15833
				$result["status"]="false";
15834
			
15834
 
15835
				#設置錯誤訊息
15835
				#設置錯誤訊息
15836
				$result["error"]=$spiltString;
15836
				$result["error"]=$spiltString;
15837
			
15837
 
15838
				#回傳結果
15838
				#回傳結果
15839
				return $result;
15839
				return $result;
15840
			
15840
 
15841
				}#if end
15841
				}#if end
15842
				
15842
 
15843
			#如果沒有分割用的" "
15843
			#如果沒有分割用的" "
15844
			if($spiltString["found"]==="false"){
15844
			if($spiltString["found"]==="false"){
15845
			
15845
 
15846
				#設置執行錯誤
15846
				#設置執行錯誤
15847
				$result["status"]="false";
15847
				$result["status"]="false";
15848
			
15848
 
15849
				#設置錯誤訊息
15849
				#設置錯誤訊息
15850
				$result["error"]=$spiltString;
15850
				$result["error"]=$spiltString;
15851
			
15851
 
15852
				#回傳結果
15852
				#回傳結果
15853
				return $result;
15853
				return $result;
15854
			
15854
 
15855
				}#if end
15855
				}#if end
15856
		
15856
 
15857
			#如果分割好的數量小於8
15857
			#如果分割好的數量小於8
15858
			if($spiltString["dataCounts"]<2){
15858
			if($spiltString["dataCounts"]<2){
15859
			
15859
 
15860
				#設置執行錯誤
15860
				#設置執行錯誤
15861
				$result["status"]="false";
15861
				$result["status"]="false";
15862
			
15862
 
15863
				#設置錯誤訊息
15863
				#設置錯誤訊息
15864
				$result["error"]=$spiltString;
15864
				$result["error"]=$spiltString;
15865
			
15865
 
15866
				#回傳結果
15866
				#回傳結果
15867
				return $result;
15867
				return $result;
15868
			
15868
 
15869
				}#if end
15869
				}#if end
15870
		
15870
 
15871
			#取得節點名稱,剔除開頭的空白.
15871
			#取得節點名稱,剔除開頭的空白.
15872
			$fileInfo["name"]=substr($spiltString["dataArray"][1],1);
15872
			$fileInfo["name"]=substr($spiltString["dataArray"][1],1);
15873
		
15873
 
15874
			#排除 "." 跟 ".."
15874
			#排除 "." 跟 ".."
15875
			if($fileInfo["name"]==="." || $fileInfo["name"]===".."){
15875
			if($fileInfo["name"]==="." || $fileInfo["name"]===".."){
15876
			
15876
 
15877
				#跳過
15877
				#跳過
15878
				continue;
15878
				continue;
15879
			
15879
 
15880
				}#if end
15880
				}#if end
15881
				
15881
 
15882
			#如果是檔案
15882
			#如果是檔案
15883
			if($fileInfo["nType"]==="-"){
15883
			if($fileInfo["nType"]==="-"){
15884
			
15884
 
15885
				#取得mime type
15885
				#取得mime type
15886
				$fileInfo["mimeType"]=@mime_content_type($conf["path"].$fileInfo["name"]);
15886
				$fileInfo["mimeType"]=@mime_content_type($conf["path"].$fileInfo["name"]);
15887
		
15887
 
15888
				#如果讀取失敗
15888
				#如果讀取失敗
15889
				if($fileInfo["mimeType"]===false){
15889
				if($fileInfo["mimeType"]===false){
15890
				
15890
 
15891
					#通常為沒有權限
15891
					#通常為沒有權限
15892
					
15892
 
15893
					#跳過該檔案
15893
					#跳過該檔案
15894
					continue;
15894
					continue;
15895
				
15895
 
15896
					}#if end
15896
					}#if end
15897
		
15897
 
15898
				#確認檔案名稱中間含是否有 "."
15898
				#確認檔案名稱中間含是否有 "."
15899
				#函式說明:
15899
				#函式說明:
15900
				#取得關鍵字在字串的哪個位置(字首,字尾,中間)
15900
				#取得關鍵字在字串的哪個位置(字首,字尾,中間)
15901
				#回傳結果:
15901
				#回傳結果:
15902
				#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
15902
				#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
Line 15920... Line 15920...
15920
				#http://php.net/manual/en/function.strpos.php
15920
				#http://php.net/manual/en/function.strpos.php
15921
				#備註:
15921
				#備註:
15922
				#無.
15922
				#無.
15923
				$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
15923
				$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
15924
				unset($conf["search::findKeyWordPosition"]);
15924
				unset($conf["search::findKeyWordPosition"]);
15925
		
15925
 
15926
				#如果執行失敗
15926
				#如果執行失敗
15927
				if($findKeyWordPosition["status"]==="false"){
15927
				if($findKeyWordPosition["status"]==="false"){
15928
				
15928
 
15929
					#設置執行錯誤
15929
					#設置執行錯誤
15930
					$result["status"]="false";
15930
					$result["status"]="false";
15931
				
15931
 
15932
					#設置錯誤訊息
15932
					#設置錯誤訊息
15933
					$result["error"]=$spiltString;
15933
					$result["error"]=$spiltString;
15934
				
15934
 
15935
					#回傳結果
15935
					#回傳結果
15936
					return $result;
15936
					return $result;
15937
				
15937
 
15938
					}#if end
15938
					}#if end
15939
					
15939
 
15940
				#如果含有 "." 存在
15940
				#如果含有 "." 存在
15941
				if($findKeyWordPosition["found"]==="true"){
15941
				if($findKeyWordPosition["found"]==="true"){
15942
				
15942
 
15943
					#如果 "." 是在中間,不是在尾巴.
15943
					#如果 "." 是在中間,不是在尾巴.
15944
					if($findKeyWordPosition["center"]==="true" && $findKeyWordPosition["tail"]==="false"){
15944
					if($findKeyWordPosition["center"]==="true" && $findKeyWordPosition["tail"]==="false"){
15945
					
15945
 
15946
						#取得 "." 之後的內容
15946
						#取得 "." 之後的內容
15947
						#函式說明:
15947
						#函式說明:
15948
						#將字串特定關鍵字與其前面的內容剔除
15948
						#將字串特定關鍵字與其前面的內容剔除
15949
						#回傳結果:
15949
						#回傳結果:
15950
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15950
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 15970... Line 15970...
15970
						#無.
15970
						#無.
15971
						#備註:
15971
						#備註:
15972
						#無.
15972
						#無.
15973
						$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
15973
						$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
15974
						unset($conf["stringProcess::delStrBeforeKeyWord"]);
15974
						unset($conf["stringProcess::delStrBeforeKeyWord"]);
15975
					
15975
 
15976
						#如果執行失敗
15976
						#如果執行失敗
15977
						if($delStrBeforeKeyWord["status"]==="false"){
15977
						if($delStrBeforeKeyWord["status"]==="false"){
15978
						
15978
 
15979
							#設置執行錯誤
15979
							#設置執行錯誤
15980
							$result["status"]="false";
15980
							$result["status"]="false";
15981
						
15981
 
15982
							#設置錯誤訊息
15982
							#設置錯誤訊息
15983
							$result["error"]=$spiltString;
15983
							$result["error"]=$spiltString;
15984
						
15984
 
15985
							#回傳結果
15985
							#回傳結果
15986
							return $result;
15986
							return $result;
15987
						
15987
 
15988
							}#if end
15988
							}#if end
15989
							
15989
 
15990
						#如果該存在的 "." 不存在
15990
						#如果該存在的 "." 不存在
15991
						if($delStrBeforeKeyWord["founded"]==="false"){
15991
						if($delStrBeforeKeyWord["founded"]==="false"){
15992
						
15992
 
15993
							#設置執行錯誤
15993
							#設置執行錯誤
15994
							$result["status"]="false";
15994
							$result["status"]="false";
15995
						
15995
 
15996
							#設置錯誤訊息
15996
							#設置錯誤訊息
15997
							$result["error"]=$spiltString;
15997
							$result["error"]=$spiltString;
15998
						
15998
 
15999
							#回傳結果
15999
							#回傳結果
16000
							return $result;
16000
							return $result;
16001
						
16001
 
16002
							}#if end
16002
							}#if end
16003
							
16003
 
16004
						#取得附檔名
16004
						#取得附檔名
16005
						$fileInfo["secondName"]=$delStrBeforeKeyWord["content"];
16005
						$fileInfo["secondName"]=$delStrBeforeKeyWord["content"];
16006
					
16006
 
16007
						}#if end
16007
						}#if end
16008
				
16008
 
16009
					}#if end
16009
					}#if end
16010
		
16010
 
16011
				}#if end
16011
				}#if end
16012
				
16012
 
16013
			#儲存檔案資訊
16013
			#儲存檔案資訊
16014
			$result["content"][]=$fileInfo;
16014
			$result["content"][]=$fileInfo;
16015
		
16015
 
16016
			}#foreach end
16016
			}#foreach end
16017
			
16017
 
16018
		#設置清單的長度
16018
		#設置清單的長度
16019
		$result["dataCount"]=count($result["content"]);
16019
		$result["dataCount"]=count($result["content"]);
16020
		
16020
 
16021
		#設置執行正常
16021
		#設置執行正常
16022
		$result["status"]="true";
16022
		$result["status"]="true";
16023
	
16023
 
16024
		#回傳結果
16024
		#回傳結果
16025
		return $result;
16025
		return $result;
16026
		
16026
 
16027
		}#function ls end
16027
		}#function ls end
16028
 
16028
 
16029
	/*
16029
	/*
16030
	#函式說明:
16030
	#函式說明:
16031
	#將 ~ 轉換為家目錄路徑
16031
	#將 ~ 轉換為家目錄路徑
Line 16043... Line 16043...
16043
	#https://www.businessweekly.com.tw/careers/Blog/14307
16043
	#https://www.businessweekly.com.tw/careers/Blog/14307
16044
	#備註:
16044
	#備註:
16045
	#無.
16045
	#無.
16046
	*/
16046
	*/
16047
	public static function tildeToPath(&$conf){
16047
	public static function tildeToPath(&$conf){
16048
	
16048
 
16049
		#初始化要回傳的結果
16049
		#初始化要回傳的結果
16050
		$result=array();
16050
		$result=array();
16051
 
16051
 
16052
		#取得當前執行的函數名稱
16052
		#取得當前執行的函數名稱
16053
		$result["function"]=__FUNCTION__;
16053
		$result["function"]=__FUNCTION__;
16054
 
16054
 
16055
		#如果沒有參數
16055
		#如果沒有參數
16056
		if(func_num_args()==0){
16056
		if(func_num_args()==0){
16057
			
16057
 
16058
			#設置執行失敗
16058
			#設置執行失敗
16059
			$result["status"]="false";
16059
			$result["status"]="false";
16060
			
16060
 
16061
			#設置執行錯誤訊息
16061
			#設置執行錯誤訊息
16062
			$result["error"]="函數".$result["function"]."需要參數";
16062
			$result["error"]="函數".$result["function"]."需要參數";
16063
			
16063
 
16064
			#回傳結果
16064
			#回傳結果
16065
			return $result;
16065
			return $result;
16066
			
16066
 
16067
			}#if end
16067
			}#if end
16068
 
16068
 
16069
		#取得參數
16069
		#取得參數
16070
		$result["argu"]=$conf;
16070
		$result["argu"]=$conf;
16071
 
16071
 
16072
		#如果 $conf 不為陣列
16072
		#如果 $conf 不為陣列
16073
		if(gettype($conf)!=="array"){
16073
		if(gettype($conf)!=="array"){
16074
			
16074
 
16075
			#設置執行失敗
16075
			#設置執行失敗
16076
			$result["status"]="false";
16076
			$result["status"]="false";
16077
			
16077
 
16078
			#設置執行錯誤訊息
16078
			#設置執行錯誤訊息
16079
			$result["error"][]="\$conf變數須為陣列形態";
16079
			$result["error"][]="\$conf變數須為陣列形態";
16080
			
16080
 
16081
			#如果傳入的參數為 null
16081
			#如果傳入的參數為 null
16082
			if($conf===null){
16082
			if($conf===null){
16083
				
16083
 
16084
				#設置執行錯誤訊息
16084
				#設置執行錯誤訊息
16085
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
16085
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
16086
				
16086
 
16087
				}#if end
16087
				}#if end
16088
 
16088
 
16089
			#回傳結果
16089
			#回傳結果
16090
			return $result;
16090
			return $result;
16091
			
16091
 
16092
			}#if end
16092
			}#if end
16093
		
16093
 
16094
		#函式說明:
16094
		#函式說明:
16095
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
16095
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
16096
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16096
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16097
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
16097
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
16098
		#$result["function"],當前執行的函式名稱.
16098
		#$result["function"],當前執行的函式名稱.
Line 16105... Line 16105...
16105
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
16105
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
16106
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
16106
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
16107
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
16107
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
16108
		#必填寫的參數:
16108
		#必填寫的參數:
16109
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
16109
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
16110
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
16110
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
16111
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
16111
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
16112
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
16112
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
16113
		#可以省略的參數:
16113
		#可以省略的參數:
16114
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
16114
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
16115
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
16115
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
Line 16123... Line 16123...
16123
		#$conf["canBeEmpty"]=array();
16123
		#$conf["canBeEmpty"]=array();
16124
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
16124
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
16125
		#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web");
16125
		#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web");
16126
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
16126
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
16127
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
16127
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
16128
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
16128
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
16129
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
16129
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
16130
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
16130
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
16131
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
16131
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
16132
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
16132
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
16133
		#$conf["disallowAllSkipableVarIsEmpty"]="";
16133
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 16137... Line 16137...
16137
		#$conf["arrayCountEqualCheck"][]=array();
16137
		#$conf["arrayCountEqualCheck"][]=array();
16138
		#參考資料來源:
16138
		#參考資料來源:
16139
		#array_keys=>http://php.net/manual/en/function.array-keys.php
16139
		#array_keys=>http://php.net/manual/en/function.array-keys.php
16140
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
16140
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
16141
		unset($conf["variableCheck::checkArguments"]);
16141
		unset($conf["variableCheck::checkArguments"]);
16142
		
16142
 
16143
		#如果檢查參數失敗
16143
		#如果檢查參數失敗
16144
		if($checkArguments["status"]==="false"){
16144
		if($checkArguments["status"]==="false"){
16145
			
16145
 
16146
			#設置執行失敗
16146
			#設置執行失敗
16147
			$result["status"]="false";
16147
			$result["status"]="false";
16148
			
16148
 
16149
			#設置執行失敗訊息
16149
			#設置執行失敗訊息
16150
			$result["error"]=$checkArguments;
16150
			$result["error"]=$checkArguments;
16151
			
16151
 
16152
			#回傳結果
16152
			#回傳結果
16153
			return $result;
16153
			return $result;
16154
			
16154
 
16155
			}#if end
16155
			}#if end
16156
			
16156
 
16157
		#如果檢查參數不通過
16157
		#如果檢查參數不通過
16158
		if($checkArguments["passed"]==="false"){
16158
		if($checkArguments["passed"]==="false"){
16159
			
16159
 
16160
			#設置執行失敗
16160
			#設置執行失敗
16161
			$result["status"]="false";
16161
			$result["status"]="false";
16162
			
16162
 
16163
			#設置執行失敗訊息
16163
			#設置執行失敗訊息
16164
			$result["error"]=$checkArguments;
16164
			$result["error"]=$checkArguments;
16165
			
16165
 
16166
			#回傳結果
16166
			#回傳結果
16167
			return $result;
16167
			return $result;
16168
			
16168
 
16169
			}#if end
16169
			}#if end
16170
 
16170
 
16171
		#函式說明:
16171
		#函式說明:
16172
		#呼叫shell執行系統命令,並取得回傳的內容.
16172
		#呼叫shell執行系統命令,並取得回傳的內容.
16173
		#回傳結果:
16173
		#回傳結果:
Line 16230... Line 16230...
16230
		$callShell=external::callShell($conf["external::callShell"]);
16230
		$callShell=external::callShell($conf["external::callShell"]);
16231
		unset($conf["external::callShell"]);
16231
		unset($conf["external::callShell"]);
16232
 
16232
 
16233
		#如果執行失敗
16233
		#如果執行失敗
16234
		if($callShell["status"]==="false"){
16234
		if($callShell["status"]==="false"){
16235
			
16235
 
16236
			#設置執行失敗
16236
			#設置執行失敗
16237
			$result["status"]="false";
16237
			$result["status"]="false";
16238
			
16238
 
16239
			#設置執行失敗訊息
16239
			#設置執行失敗訊息
16240
			$result["error"]=$callShell;
16240
			$result["error"]=$callShell;
16241
			
16241
 
16242
			#回傳結果
16242
			#回傳結果
16243
			return $result;
16243
			return $result;
16244
			
16244
 
16245
			}#if end
16245
			}#if end
16246
	
16246
 
16247
		#如果沒有預期的輸出
16247
		#如果沒有預期的輸出
16248
		if(!isset($callShell["output"][0])){
16248
		if(!isset($callShell["output"][0])){
16249
		
16249
 
16250
			#設置執行失敗
16250
			#設置執行失敗
16251
			$result["status"]="false";
16251
			$result["status"]="false";
16252
			
16252
 
16253
			#設置執行失敗訊息
16253
			#設置執行失敗訊息
16254
			$result["error"][]="沒有得到預期的輸出";
16254
			$result["error"][]="沒有得到預期的輸出";
16255
			
16255
 
16256
			#設置執行失敗訊息
16256
			#設置執行失敗訊息
16257
			$result["error"][]=$callShell;
16257
			$result["error"][]=$callShell;
16258
			
16258
 
16259
			#回傳結果
16259
			#回傳結果
16260
			return $result;
16260
			return $result;
16261
		
16261
 
16262
			}#if end
16262
			}#if end
16263
	
16263
 
16264
		#取得輸出
16264
		#取得輸出
16265
		$result["content"]=$callShell["output"][0];
16265
		$result["content"]=$callShell["output"][0];
16266
	
16266
 
16267
		#設置執行正常
16267
		#設置執行正常
16268
		$result["status"]="true";
16268
		$result["status"]="true";
16269
	
16269
 
16270
		#回傳結果
16270
		#回傳結果
16271
		return $result;
16271
		return $result;
16272
	
16272
 
16273
		}#function tildeToPath end
16273
		}#function tildeToPath end
16274
 
16274
 
16275
	/*
16275
	/*
16276
	#函式說明:
16276
	#函式說明:
16277
	#建立軟連結.
16277
	#建立軟連結.
Line 16297... Line 16297...
16297
	#無.
16297
	#無.
16298
	#備註:
16298
	#備註:
16299
	#無.
16299
	#無.
16300
	*/
16300
	*/
16301
	public static function createLink(&$conf){
16301
	public static function createLink(&$conf){
16302
	
16302
 
16303
		#初始化要回傳的結果
16303
		#初始化要回傳的結果
16304
		$result=array();
16304
		$result=array();
16305
 
16305
 
16306
		#取得當前執行的函數名稱
16306
		#取得當前執行的函數名稱
16307
		$result["function"]=__FUNCTION__;
16307
		$result["function"]=__FUNCTION__;
16308
 
16308
 
16309
		#如果沒有參數
16309
		#如果沒有參數
16310
		if(func_num_args()==0){
16310
		if(func_num_args()==0){
16311
			
16311
 
16312
			#設置執行失敗
16312
			#設置執行失敗
16313
			$result["status"]="false";
16313
			$result["status"]="false";
16314
			
16314
 
16315
			#設置執行錯誤訊息
16315
			#設置執行錯誤訊息
16316
			$result["error"]="函數".$result["function"]."需要參數";
16316
			$result["error"]="函數".$result["function"]."需要參數";
16317
			
16317
 
16318
			#回傳結果
16318
			#回傳結果
16319
			return $result;
16319
			return $result;
16320
			
16320
 
16321
			}#if end
16321
			}#if end
16322
 
16322
 
16323
		#取得參數
16323
		#取得參數
16324
		$result["argu"]=$conf;
16324
		$result["argu"]=$conf;
16325
 
16325
 
16326
		#如果 $conf 不為陣列
16326
		#如果 $conf 不為陣列
16327
		if(gettype($conf)!=="array"){
16327
		if(gettype($conf)!=="array"){
16328
			
16328
 
16329
			#設置執行失敗
16329
			#設置執行失敗
16330
			$result["status"]="false";
16330
			$result["status"]="false";
16331
			
16331
 
16332
			#設置執行錯誤訊息
16332
			#設置執行錯誤訊息
16333
			$result["error"][]="\$conf變數須為陣列形態";
16333
			$result["error"][]="\$conf變數須為陣列形態";
16334
			
16334
 
16335
			#如果傳入的參數為 null
16335
			#如果傳入的參數為 null
16336
			if($conf===null){
16336
			if($conf===null){
16337
				
16337
 
16338
				#設置執行錯誤訊息
16338
				#設置執行錯誤訊息
16339
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
16339
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
16340
				
16340
 
16341
				}#if end
16341
				}#if end
16342
 
16342
 
16343
			#回傳結果
16343
			#回傳結果
16344
			return $result;
16344
			return $result;
16345
			
16345
 
16346
			}#if end
16346
			}#if end
16347
		
16347
 
16348
		#函式說明:
16348
		#函式說明:
16349
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
16349
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
16350
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16350
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16351
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
16351
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
16352
		#$result["function"],當前執行的函式名稱.
16352
		#$result["function"],當前執行的函式名稱.
Line 16359... Line 16359...
16359
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
16359
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
16360
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
16360
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
16361
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
16361
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
16362
		#必填寫的參數:
16362
		#必填寫的參數:
16363
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
16363
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
16364
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
16364
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
16365
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
16365
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
16366
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
16366
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
16367
		#可以省略的參數:
16367
		#可以省略的參數:
16368
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
16368
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
16369
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","linkTo");
16369
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","linkTo");
Line 16377... Line 16377...
16377
		#$conf["canBeEmpty"]=array();
16377
		#$conf["canBeEmpty"]=array();
16378
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
16378
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
16379
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("path","name","overWrite");
16379
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("path","name","overWrite");
16380
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
16380
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
16381
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("path","name","overWrite");
16381
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("path","name","overWrite");
16382
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
16382
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
16383
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
16383
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
16384
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
16384
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
16385
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,"false");
16385
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,"false");
16386
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
16386
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
16387
		#$conf["disallowAllSkipableVarIsEmpty"]="";
16387
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 16391... Line 16391...
16391
		#$conf["arrayCountEqualCheck"][]=array();
16391
		#$conf["arrayCountEqualCheck"][]=array();
16392
		#參考資料來源:
16392
		#參考資料來源:
16393
		#array_keys=>http://php.net/manual/en/function.array-keys.php
16393
		#array_keys=>http://php.net/manual/en/function.array-keys.php
16394
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
16394
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
16395
		unset($conf["variableCheck::checkArguments"]);
16395
		unset($conf["variableCheck::checkArguments"]);
16396
		
16396
 
16397
		#如果檢查參數失敗
16397
		#如果檢查參數失敗
16398
		if($checkArguments["status"]==="false"){
16398
		if($checkArguments["status"]==="false"){
16399
			
16399
 
16400
			#設置執行失敗
16400
			#設置執行失敗
16401
			$result["status"]="false";
16401
			$result["status"]="false";
16402
			
16402
 
16403
			#設置執行失敗訊息
16403
			#設置執行失敗訊息
16404
			$result["error"]=$checkArguments;
16404
			$result["error"]=$checkArguments;
16405
			
16405
 
16406
			#回傳結果
16406
			#回傳結果
16407
			return $result;
16407
			return $result;
16408
			
16408
 
16409
			}#if end
16409
			}#if end
16410
			
16410
 
16411
		#如果檢查參數不通過
16411
		#如果檢查參數不通過
16412
		if($checkArguments["passed"]==="false"){
16412
		if($checkArguments["passed"]==="false"){
16413
			
16413
 
16414
			#設置執行失敗
16414
			#設置執行失敗
16415
			$result["status"]="false";
16415
			$result["status"]="false";
16416
			
16416
 
16417
			#設置執行失敗訊息
16417
			#設置執行失敗訊息
16418
			$result["error"]=$checkArguments;
16418
			$result["error"]=$checkArguments;
16419
			
16419
 
16420
			#回傳結果
16420
			#回傳結果
16421
			return $result;
16421
			return $result;
16422
			
16422
 
16423
			}#if end
16423
			}#if end
16424
 
16424
 
16425
		#如果是相對位置
16425
		#如果是相對位置
16426
		if(!(strpos($conf["linkTo"],"/")===0)){
16426
		if(!(strpos($conf["linkTo"],"/")===0)){
16427
		
16427
 
16428
			#將 $conf["linkTo"] 轉換為針對產生位置的相對位置.
16428
			#將 $conf["linkTo"] 轉換為針對產生位置的相對位置.
16429
			#函式說明:
16429
			#函式說明:
16430
			#將多個路徑字串變成相對於當前路徑的相對路徑字串
16430
			#將多個路徑字串變成相對於當前路徑的相對路徑字串
16431
			#回傳結果:
16431
			#回傳結果:
16432
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
16432
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
16433
			#$result["error"],錯誤訊息陣列.
16433
			#$result["error"],錯誤訊息陣列.
16434
			#$result["function"],函數名稱. 
16434
			#$result["function"],函數名稱.
16435
			#$result["argu"],使用的參數.
16435
			#$result["argu"],使用的參數.
16436
			#$result["content"],字串陣列,多個轉換好的相對路徑字串.
16436
			#$result["content"],字串陣列,多個轉換好的相對路徑字串.
16437
			#必填參數:
16437
			#必填參數:
16438
			#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
16438
			#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
16439
			$conf["fileAccess::getRelativePath"]["path"]=array($conf["linkTo"]);
16439
			$conf["fileAccess::getRelativePath"]["path"]=array($conf["linkTo"]);
Line 16449... Line 16449...
16449
			$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
16449
			$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
16450
			unset($conf["fileAccess::getRelativePath"]);
16450
			unset($conf["fileAccess::getRelativePath"]);
16451
 
16451
 
16452
			#如果執行失敗
16452
			#如果執行失敗
16453
			if($getRelativePath["status"]==="false"){
16453
			if($getRelativePath["status"]==="false"){
16454
			
16454
 
16455
				#設置執行失敗
16455
				#設置執行失敗
16456
				$result["status"]="false";
16456
				$result["status"]="false";
16457
				
16457
 
16458
				#設置執行失敗訊息
16458
				#設置執行失敗訊息
16459
				$result["error"]=$getRelativePath;
16459
				$result["error"]=$getRelativePath;
16460
				
16460
 
16461
				#回傳結果
16461
				#回傳結果
16462
				return $result;
16462
				return $result;
16463
			
16463
 
16464
				}#if end
16464
				}#if end
16465
 
16465
 
16466
			/*
16466
			/*
16467
			#break point
16467
			#break point
16468
			var_dump($conf);
16468
			var_dump($conf);
Line 16473... Line 16473...
16473
			#取得執行的指令
16473
			#取得執行的指令
16474
			$result["cmd"][]=$getRelativePath["cmd"];
16474
			$result["cmd"][]=$getRelativePath["cmd"];
16475
 
16475
 
16476
			#取得正確的相對位置
16476
			#取得正確的相對位置
16477
			$conf["linkTo"]=$getRelativePath["content"][0];
16477
			$conf["linkTo"]=$getRelativePath["content"][0];
16478
		
16478
 
16479
			}#if end
16479
			}#if end
16480
 
16480
 
16481
		#初始化給 ln 指令的參數
16481
		#初始化給 ln 指令的參數
16482
		$paramsForLn=array("-s",$conf["linkTo"]);
16482
		$paramsForLn=array("-s",$conf["linkTo"]);
16483
 
16483
 
Line 16488... Line 16488...
16488
		#$result["error"],錯誤訊息陣列.
16488
		#$result["error"],錯誤訊息陣列.
16489
		#$result["warning"],警告訊息鎮列.
16489
		#$result["warning"],警告訊息鎮列.
16490
		#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
16490
		#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
16491
		#$result["function"],當前執行的函數名稱.
16491
		#$result["function"],當前執行的函數名稱.
16492
		#$result["oriStr"],要處理的原始字串內容.
16492
		#$result["oriStr"],要處理的原始字串內容.
16493
		#$result["content"],處理好的的字串內容.	
16493
		#$result["content"],處理好的的字串內容.
16494
		#必填參數:
16494
		#必填參數:
16495
		#$conf["stringIn"],字串,要處理的字串.
16495
		#$conf["stringIn"],字串,要處理的字串.
16496
		$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$conf["linkTo"];
16496
		$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$conf["linkTo"];
16497
		#$conf["keyWord"],字串,特定字串.
16497
		#$conf["keyWord"],字串,特定字串.
16498
		$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="/";
16498
		$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="/";
Line 16508... Line 16508...
16508
 
16508
 
16509
		#var_dump(__LINE__." ".print_r($delStrBeforeKeyWord,true));
16509
		#var_dump(__LINE__." ".print_r($delStrBeforeKeyWord,true));
16510
 
16510
 
16511
		#如果執行失敗
16511
		#如果執行失敗
16512
		if($delStrBeforeKeyWord["status"]==="false"){
16512
		if($delStrBeforeKeyWord["status"]==="false"){
16513
		
16513
 
16514
			#設置執行失敗
16514
			#設置執行失敗
16515
			$result["status"]="false";
16515
			$result["status"]="false";
16516
			
16516
 
16517
			#設置執行失敗訊息
16517
			#設置執行失敗訊息
16518
			$result["error"]=$delStrBeforeKeyWord;
16518
			$result["error"]=$delStrBeforeKeyWord;
16519
			
16519
 
16520
			#回傳結果
16520
			#回傳結果
16521
			return $result;
16521
			return $result;
16522
		
16522
 
16523
			}#if end
16523
			}#if end
16524
		
16524
 
16525
		#如果沒有找到 "/"
16525
		#如果沒有找到 "/"
16526
		if($delStrBeforeKeyWord["founded"]==="false"){
16526
		if($delStrBeforeKeyWord["founded"]==="false"){
16527
		
16527
 
16528
			#設置 預設的 軟連名稱
16528
			#設置 預設的 軟連名稱
16529
			$softLink=$conf["linkTo"];
16529
			$softLink=$conf["linkTo"];
16530
		
16530
 
16531
			}#if end
16531
			}#if end
16532
 
16532
 
16533
		#反之有 "/"
16533
		#反之有 "/"
16534
		else{
16534
		else{
16535
		
16535
 
16536
			#設置 預設的 軟連結名稱
16536
			#設置 預設的 軟連結名稱
16537
			$softLink=$delStrBeforeKeyWord["content"];
16537
			$softLink=$delStrBeforeKeyWord["content"];
16538
					
16538
 
16539
			}#else end
16539
			}#else end
16540
 
16540
 
16541
		/*
16541
		/*
16542
		#break point
16542
		#break point
16543
		var_dump(__LINE__." ".$softLink);
16543
		var_dump(__LINE__." ".$softLink);
Line 16547... Line 16547...
16547
		#預設欲建立的軟連結名稱
16547
		#預設欲建立的軟連結名稱
16548
		$createdSoftLink=$softLink;
16548
		$createdSoftLink=$softLink;
16549
 
16549
 
16550
		#如果有設置 path
16550
		#如果有設置 path
16551
		if(isset($conf["path"])){
16551
		if(isset($conf["path"])){
16552
		
16552
 
16553
			#確認 path 存在
16553
			#確認 path 存在
16554
			#函式說明:
16554
			#函式說明:
16555
			#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
16555
			#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
16556
			#回傳結果:
16556
			#回傳結果:
16557
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
16557
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
Line 16572... Line 16572...
16572
			#無.
16572
			#無.
16573
			#備註:
16573
			#備註:
16574
			#同 function createFolderAfterCheck.
16574
			#同 function createFolderAfterCheck.
16575
			$createNewFolder=fileAccess::createNewFolder($conf["fileAccess::createNewFolder"]);
16575
			$createNewFolder=fileAccess::createNewFolder($conf["fileAccess::createNewFolder"]);
16576
			unset($conf["fileAccess::createNewFolder"]);
16576
			unset($conf["fileAccess::createNewFolder"]);
16577
		
16577
 
16578
			#如果執行失敗
16578
			#如果執行失敗
16579
			if($createNewFolder["status"]==="false"){
16579
			if($createNewFolder["status"]==="false"){
16580
				
16580
 
16581
				#設置執行失敗
16581
				#設置執行失敗
16582
				$result["status"]="false";
16582
				$result["status"]="false";
16583
				
16583
 
16584
				#設置執行失敗訊息
16584
				#設置執行失敗訊息
16585
				$result["error"]=$createNewFolder;
16585
				$result["error"]=$createNewFolder;
16586
				
16586
 
16587
				#回傳結果
16587
				#回傳結果
16588
				return $result;
16588
				return $result;
16589
				
16589
 
16590
				}#if end
16590
				}#if end
16591
		
16591
 
16592
			#var_dump(__LINE__." ".print_r($conf,true));
16592
			#var_dump(__LINE__." ".print_r($conf,true));
16593
		
16593
 
16594
			#預設要加 slash
16594
			#預設要加 slash
16595
			$slash="/";
16595
			$slash="/";
16596
			
16596
 
16597
			#如果 path 為 "/" 結尾
16597
			#如果 path 為 "/" 結尾
16598
			if($conf["path"][strlen($conf["path"])-1]==="/"){
16598
			if($conf["path"][strlen($conf["path"])-1]==="/"){
16599
			
16599
 
16600
				#不用 slash
16600
				#不用 slash
16601
				$slash="";
16601
				$slash="";
16602
				
16602
 
16603
				}#if end
16603
				}#if end
16604
		
16604
 
16605
			#如果有設置 name
16605
			#如果有設置 name
16606
			if(isset($conf["name"])){
16606
			if(isset($conf["name"])){
16607
					
16607
 
16608
				#指定軟連結要放在哪邊
16608
				#指定軟連結要放在哪邊
16609
				$paramsForLn[]=$conf["path"].$slash.$conf["name"];
16609
				$paramsForLn[]=$conf["path"].$slash.$conf["name"];
16610
			
16610
 
16611
				#更新欲建立的軟連結名稱
16611
				#更新欲建立的軟連結名稱
16612
				$createdSoftLink=$conf["path"].$slash.$conf["name"];
16612
				$createdSoftLink=$conf["path"].$slash.$conf["name"];
16613
			
16613
 
16614
				/*
16614
				/*
16615
				#break point
16615
				#break point
16616
				var_dump($conf["path"],$softLink,$createdSoftLink);
16616
				var_dump($conf["path"],$softLink,$createdSoftLink);
16617
				exit;
16617
				exit;
16618
				*/
16618
				*/
16619
							
16619
 
16620
				}#if end
16620
				}#if end
16621
			
16621
 
16622
			#反之
16622
			#反之
16623
			else{
16623
			else{
16624
			
16624
 
16625
				#指定軟連結要放在哪邊
16625
				#指定軟連結要放在哪邊
16626
				$paramsForLn[]=$conf["path"];
16626
				$paramsForLn[]=$conf["path"];
16627
				
16627
 
16628
				#更新欲建立的軟連結名稱
16628
				#更新欲建立的軟連結名稱
16629
				$createdSoftLink=$conf["path"].$slash.$softLink;
16629
				$createdSoftLink=$conf["path"].$slash.$softLink;
16630
			
16630
 
16631
				/*
16631
				/*
16632
				#break point
16632
				#break point
16633
				var_dump($conf["path"],$softLink,$createdSoftLink);
16633
				var_dump($conf["path"],$softLink,$createdSoftLink);
16634
				exit;
16634
				exit;
16635
				*/
16635
				*/
16636
			
16636
 
16637
				}#else end
16637
				}#else end
16638
				
16638
 
16639
			#var_dump($createdSoftLink);
16639
			#var_dump($createdSoftLink);
16640
		
16640
 
16641
			}#if end
16641
			}#if end
16642
			
16642
 
16643
		#反之如果有設置 name
16643
		#反之如果有設置 name
16644
		else if(isset($conf["name"])){
16644
		else if(isset($conf["name"])){
16645
		
16645
 
16646
			#指定軟連結的名稱
16646
			#指定軟連結的名稱
16647
			$paramsForLn[]=$conf["name"];
16647
			$paramsForLn[]=$conf["name"];
16648
			
16648
 
16649
			#更新欲建立的軟連結名稱
16649
			#更新欲建立的軟連結名稱
16650
			$createdSoftLink=$conf["name"];
16650
			$createdSoftLink=$conf["name"];
16651
		
16651
 
16652
			#var_dump(__LINE__." ".$createdSoftLink);
16652
			#var_dump(__LINE__." ".$createdSoftLink);
16653
		
16653
 
16654
			}#if end
16654
			}#if end
16655
		
16655
 
16656
		/*
16656
		/*
16657
		# break point
16657
		# break point
16658
		var_dump($createdSoftLink);
16658
		var_dump($createdSoftLink);
16659
		exit;
16659
		exit;
16660
		*/
16660
		*/
16661
		
16661
 
16662
		#如果要覆蓋既有的目標
16662
		#如果要覆蓋既有的目標
16663
		if($conf["overWrite"]==="true"){
16663
		if($conf["overWrite"]==="true"){
16664
		
16664
 
16665
			#函式說明:
16665
			#函式說明:
16666
			#移除檔案
16666
			#移除檔案
16667
			#回傳結果:
16667
			#回傳結果:
16668
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
16668
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
16669
			#$result["error"],錯誤訊息陣列
16669
			#$result["error"],錯誤訊息陣列
Line 16684... Line 16684...
16684
			#參考資料:
16684
			#參考資料:
16685
			#無.
16685
			#無.
16686
			#備註:
16686
			#備註:
16687
			#無.
16687
			#無.
16688
			$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
16688
			$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
16689
			unset($conf["fileAccess::delFile"]);	
16689
			unset($conf["fileAccess::delFile"]);
16690
			
16690
 
16691
			/*
16691
			/*
16692
			#break point
16692
			#break point
16693
			var_dump($delFile);
16693
			var_dump($delFile);
16694
			exit;
16694
			exit;
16695
			*/
16695
			*/
16696
			
16696
 
16697
			#如果執行失敗
16697
			#如果執行失敗
16698
			if($delFile["status"]==="false"){
16698
			if($delFile["status"]==="false"){
16699
			
16699
 
16700
				#設置執行失敗
16700
				#設置執行失敗
16701
				$result["status"]="false";
16701
				$result["status"]="false";
16702
				
16702
 
16703
				#設置執行失敗訊息
16703
				#設置執行失敗訊息
16704
				$result["error"]=$delFile;
16704
				$result["error"]=$delFile;
16705
				
16705
 
16706
				#回傳結果
16706
				#回傳結果
16707
				return $result;
16707
				return $result;
16708
			
16708
 
16709
				}#if end
16709
				}#if end
16710
			
16710
 
16711
			}#if end
16711
			}#if end
16712
 
16712
 
16713
		#函式說明:
16713
		#函式說明:
16714
		#呼叫shell執行系統命令,並取得回傳的內容.
16714
		#呼叫shell執行系統命令,並取得回傳的內容.
16715
		#回傳結果:
16715
		#回傳結果:
Line 16772... Line 16772...
16772
		$callShell=external::callShell($conf["external::callShell"]);
16772
		$callShell=external::callShell($conf["external::callShell"]);
16773
		unset($conf["external::callShell"]);
16773
		unset($conf["external::callShell"]);
16774
 
16774
 
16775
		#如果執行失敗
16775
		#如果執行失敗
16776
		if($callShell["status"]==="false"){
16776
		if($callShell["status"]==="false"){
16777
			
16777
 
16778
			#設置執行失敗
16778
			#設置執行失敗
16779
			$result["status"]="false";
16779
			$result["status"]="false";
16780
			
16780
 
16781
			#設置執行失敗訊息
16781
			#設置執行失敗訊息
16782
			$result["error"]=$callShell;
16782
			$result["error"]=$callShell;
16783
			
16783
 
16784
			#回傳結果
16784
			#回傳結果
16785
			return $result;
16785
			return $result;
16786
			
16786
 
16787
			}#if end
16787
			}#if end
16788
		
16788
 
16789
		#保存執行的指令
16789
		#保存執行的指令
16790
		$result["cmd"][]=$callShell["cmd"];
16790
		$result["cmd"][]=$callShell["cmd"];
16791
		
16791
 
16792
		#初始化給 ls 指令的參數
16792
		#初始化給 ls 指令的參數
16793
		$paramsForLs=array("-l",$paramsForLn[count($paramsForLn)-1]);
16793
		$paramsForLs=array("-l",$paramsForLn[count($paramsForLn)-1]);
16794
				
16794
 
16795
		#取得軟連結的資訊
16795
		#取得軟連結的資訊
16796
		#函式說明:
16796
		#函式說明:
16797
		#呼叫shell執行系統命令,並取得回傳的內容.
16797
		#呼叫shell執行系統命令,並取得回傳的內容.
16798
		#回傳結果:
16798
		#回傳結果:
16799
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16799
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 16855... Line 16855...
16855
		$callShell=external::callShell($conf["external::callShell"]);
16855
		$callShell=external::callShell($conf["external::callShell"]);
16856
		unset($conf["external::callShell"]);
16856
		unset($conf["external::callShell"]);
16857
 
16857
 
16858
		#如果執行失敗
16858
		#如果執行失敗
16859
		if($callShell["status"]==="false"){
16859
		if($callShell["status"]==="false"){
16860
			
16860
 
16861
			#設置執行失敗
16861
			#設置執行失敗
16862
			$result["status"]="false";
16862
			$result["status"]="false";
16863
			
16863
 
16864
			#設置執行失敗訊息
16864
			#設置執行失敗訊息
16865
			$result["error"]=$callShell;
16865
			$result["error"]=$callShell;
16866
			
16866
 
16867
			#回傳結果
16867
			#回傳結果
16868
			return $result;
16868
			return $result;
16869
			
16869
 
16870
			}#if end
16870
			}#if end
16871
		
16871
 
16872
		#保存執行的指令
16872
		#保存執行的指令
16873
		$result["cmd"][]=$callShell["cmd"];
16873
		$result["cmd"][]=$callShell["cmd"];
16874
		
16874
 
16875
		#取得軟連結的資訊
16875
		#取得軟連結的資訊
16876
		$result["content"]=$callShell["output"];
16876
		$result["content"]=$callShell["output"];
16877
		
16877
 
16878
		#設置執行正常
16878
		#設置執行正常
16879
		$result["status"]="true";
16879
		$result["status"]="true";
16880
	
16880
 
16881
		#回傳結果
16881
		#回傳結果
16882
		return $result;
16882
		return $result;
16883
	
16883
 
16884
		}#function createLink end
16884
		}#function createLink end
16885
 
16885
 
16886
	/*
16886
	/*
16887
	#函式說明:
16887
	#函式說明:
16888
	#針對特定目錄下的內容建立軟連結.
16888
	#針對特定目錄下的內容建立軟連結.
Line 16907... Line 16907...
16907
	#無.
16907
	#無.
16908
	#備註:
16908
	#備註:
16909
	#無.
16909
	#無.
16910
	*/
16910
	*/
16911
	public static function createMultiLinkInDir(&$conf){
16911
	public static function createMultiLinkInDir(&$conf){
16912
	
16912
 
16913
		#初始化要回傳的結果
16913
		#初始化要回傳的結果
16914
		$result=array();
16914
		$result=array();
16915
 
16915
 
16916
		#取得當前執行的函數名稱
16916
		#取得當前執行的函數名稱
16917
		$result["function"]=__FUNCTION__;
16917
		$result["function"]=__FUNCTION__;
16918
 
16918
 
16919
		#如果沒有參數
16919
		#如果沒有參數
16920
		if(func_num_args()==0){
16920
		if(func_num_args()==0){
16921
			
16921
 
16922
			#設置執行失敗
16922
			#設置執行失敗
16923
			$result["status"]="false";
16923
			$result["status"]="false";
16924
			
16924
 
16925
			#設置執行錯誤訊息
16925
			#設置執行錯誤訊息
16926
			$result["error"]="函數".$result["function"]."需要參數";
16926
			$result["error"]="函數".$result["function"]."需要參數";
16927
			
16927
 
16928
			#回傳結果
16928
			#回傳結果
16929
			return $result;
16929
			return $result;
16930
			
16930
 
16931
			}#if end
16931
			}#if end
16932
 
16932
 
16933
		#取得參數
16933
		#取得參數
16934
		$result["argu"]=$conf;
16934
		$result["argu"]=$conf;
16935
 
16935
 
16936
		#如果 $conf 不為陣列
16936
		#如果 $conf 不為陣列
16937
		if(gettype($conf)!=="array"){
16937
		if(gettype($conf)!=="array"){
16938
			
16938
 
16939
			#設置執行失敗
16939
			#設置執行失敗
16940
			$result["status"]="false";
16940
			$result["status"]="false";
16941
			
16941
 
16942
			#設置執行錯誤訊息
16942
			#設置執行錯誤訊息
16943
			$result["error"][]="\$conf變數須為陣列形態";
16943
			$result["error"][]="\$conf變數須為陣列形態";
16944
			
16944
 
16945
			#如果傳入的參數為 null
16945
			#如果傳入的參數為 null
16946
			if($conf===null){
16946
			if($conf===null){
16947
				
16947
 
16948
				#設置執行錯誤訊息
16948
				#設置執行錯誤訊息
16949
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
16949
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
16950
				
16950
 
16951
				}#if end
16951
				}#if end
16952
 
16952
 
16953
			#回傳結果
16953
			#回傳結果
16954
			return $result;
16954
			return $result;
16955
			
16955
 
16956
			}#if end
16956
			}#if end
16957
				
16957
 
16958
		#檢查參數
16958
		#檢查參數
16959
		#函式說明:
16959
		#函式說明:
16960
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
16960
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
16961
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16961
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16962
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
16962
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 16970... Line 16970...
16970
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
16970
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
16971
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
16971
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
16972
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
16972
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
16973
		#必填寫的參數:
16973
		#必填寫的參數:
16974
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
16974
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
16975
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
16975
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
16976
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
16976
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
16977
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
16977
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
16978
		#可以省略的參數:
16978
		#可以省略的參數:
16979
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
16979
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
16980
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","linkToDir");
16980
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","linkToDir");
Line 16988... Line 16988...
16988
		#$conf["canBeEmpty"]=array();
16988
		#$conf["canBeEmpty"]=array();
16989
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
16989
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
16990
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("path","name","overWrite");
16990
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("path","name","overWrite");
16991
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
16991
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
16992
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("path","name","overWrite");
16992
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("path","name","overWrite");
16993
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
16993
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
16994
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","array","string");
16994
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","array","string");
16995
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
16995
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
16996
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(".",null,"false");
16996
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(".",null,"false");
16997
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
16997
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
16998
		#$conf["disallowAllSkipableVarIsEmpty"]="";
16998
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 17002... Line 17002...
17002
		#$conf["arrayCountEqualCheck"][]=array();
17002
		#$conf["arrayCountEqualCheck"][]=array();
17003
		#參考資料來源:
17003
		#參考資料來源:
17004
		#array_keys=>http://php.net/manual/en/function.array-keys.php
17004
		#array_keys=>http://php.net/manual/en/function.array-keys.php
17005
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
17005
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
17006
		unset($conf["variableCheck::checkArguments"]);
17006
		unset($conf["variableCheck::checkArguments"]);
17007
		
17007
 
17008
		#如果檢查參數失敗
17008
		#如果檢查參數失敗
17009
		if($checkArguments["status"]==="false"){
17009
		if($checkArguments["status"]==="false"){
17010
			
17010
 
17011
			#設置執行失敗
17011
			#設置執行失敗
17012
			$result["status"]="false";
17012
			$result["status"]="false";
17013
			
17013
 
17014
			#設置執行失敗訊息
17014
			#設置執行失敗訊息
17015
			$result["error"]=$checkArguments;
17015
			$result["error"]=$checkArguments;
17016
			
17016
 
17017
			#回傳結果
17017
			#回傳結果
17018
			return $result;
17018
			return $result;
17019
			
17019
 
17020
			}#if end
17020
			}#if end
17021
			
17021
 
17022
		#如果檢查參數不通過
17022
		#如果檢查參數不通過
17023
		if($checkArguments["passed"]==="false"){
17023
		if($checkArguments["passed"]==="false"){
17024
			
17024
 
17025
			#設置執行失敗
17025
			#設置執行失敗
17026
			$result["status"]="false";
17026
			$result["status"]="false";
17027
			
17027
 
17028
			#設置執行失敗訊息
17028
			#設置執行失敗訊息
17029
			$result["error"]=$checkArguments;
17029
			$result["error"]=$checkArguments;
17030
			
17030
 
17031
			#回傳結果
17031
			#回傳結果
17032
			return $result;
17032
			return $result;
17033
			
17033
 
17034
			}#if end
17034
			}#if end
17035
			
17035
 
17036
		#函式說明:
17036
		#函式說明:
17037
		#取得目錄底下所有目錄與檔案清單.
17037
		#取得目錄底下所有目錄與檔案清單.
17038
		#回傳結果:
17038
		#回傳結果:
17039
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
17039
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
17040
		#$result["error"],錯誤訊息陣列.
17040
		#$result["error"],錯誤訊息陣列.
Line 17056... Line 17056...
17056
		#is_dir=>http://php.net/manual/en/function.is-dir.php
17056
		#is_dir=>http://php.net/manual/en/function.is-dir.php
17057
		#備註:
17057
		#備註:
17058
		#無.
17058
		#無.
17059
		$getList=fileAccess::getList($conf["fileAccess::getList"]);
17059
		$getList=fileAccess::getList($conf["fileAccess::getList"]);
17060
		unset($conf["fileAccess::getList"]);
17060
		unset($conf["fileAccess::getList"]);
17061
	
17061
 
17062
		#如果檢查參數失敗
17062
		#如果檢查參數失敗
17063
		if($getList["status"]==="false"){
17063
		if($getList["status"]==="false"){
17064
			
17064
 
17065
			#設置執行失敗
17065
			#設置執行失敗
17066
			$result["status"]="false";
17066
			$result["status"]="false";
17067
			
17067
 
17068
			#設置執行失敗訊息
17068
			#設置執行失敗訊息
17069
			$result["error"]=$getList;
17069
			$result["error"]=$getList;
17070
			
17070
 
17071
			#回傳結果
17071
			#回傳結果
17072
			return $result;
17072
			return $result;
17073
			
17073
 
17074
			}#if end
17074
			}#if end
17075
			
17075
 
17076
		#針對目標目錄底下的所有檔案
17076
		#針對目標目錄底下的所有檔案
17077
		foreach($getList["content"] as $oriName){
17077
		foreach($getList["content"] as $oriName){
17078
		
17078
 
17079
			#如果有設定 $conf["name"]
17079
			#如果有設定 $conf["name"]
17080
			if(isset($conf["name"])){
17080
			if(isset($conf["name"])){
17081
			
17081
 
17082
				#預設不指定新的軟連結名稱
17082
				#預設不指定新的軟連結名稱
17083
				unset($newSoftLinkName);
17083
				unset($newSoftLinkName);
17084
			
17084
 
17085
				#針對每個原始目標的名稱
17085
				#針對每個原始目標的名稱
17086
				foreach($conf["name"] as $customName){
17086
				foreach($conf["name"] as $customName){
17087
				
17087
 
17088
					#如果是指定的目標
17088
					#如果是指定的目標
17089
					if($oriName["name"]===$customName[0]){
17089
					if($oriName["name"]===$customName[0]){
17090
					
17090
 
17091
						#設置新的軟連結名稱
17091
						#設置新的軟連結名稱
17092
						$newSoftLinkName=$customName[1];
17092
						$newSoftLinkName=$customName[1];
17093
					
17093
 
17094
						}#if end
17094
						}#if end
17095
					
17095
 
17096
					}#foreach end
17096
					}#foreach end
17097
			
17097
 
17098
				}#if end
17098
				}#if end
17099
				
17099
 
17100
			#建立軟連結
17100
			#建立軟連結
17101
			#函式說明:
17101
			#函式說明:
17102
			#建立軟連結.
17102
			#建立軟連結.
17103
			#回傳結果:
17103
			#回傳結果:
17104
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17104
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 17111... Line 17111...
17111
			#$conf["linkTo"],字串,軟連結要指向哪邊.
17111
			#$conf["linkTo"],字串,軟連結要指向哪邊.
17112
			$conf["fileAccess::createLink"]["linkTo"]=$conf["linkToDir"]."/".$oriName["name"];
17112
			$conf["fileAccess::createLink"]["linkTo"]=$conf["linkToDir"]."/".$oriName["name"];
17113
			#可省略參數:
17113
			#可省略參數:
17114
			#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
17114
			#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
17115
			$conf["fileAccess::createLink"]["path"]=$conf["path"];
17115
			$conf["fileAccess::createLink"]["path"]=$conf["path"];
17116
			
17116
 
17117
			#如果有新的軟連結名稱
17117
			#如果有新的軟連結名稱
17118
			if(isset($newSoftLinkName)){
17118
			if(isset($newSoftLinkName)){
17119
			
17119
 
17120
				#$conf["name"],字串,軟連結的名稱,預設為 "linkTo" 參數的檔案或目錄名稱.
17120
				#$conf["name"],字串,軟連結的名稱,預設為 "linkTo" 參數的檔案或目錄名稱.
17121
				$conf["fileAccess::createLink"]["name"]=$newSoftLinkName;
17121
				$conf["fileAccess::createLink"]["name"]=$newSoftLinkName;
17122
			
17122
 
17123
				}#if end
17123
				}#if end
17124
			
17124
 
17125
			#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
17125
			#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
17126
			$conf["fileAccess::createLink"]["overWrite"]=$conf["overWrite"];
17126
			$conf["fileAccess::createLink"]["overWrite"]=$conf["overWrite"];
17127
			
17127
 
17128
			#參考資料:
17128
			#參考資料:
17129
			#無.
17129
			#無.
17130
			#備註:
17130
			#備註:
17131
			#無.
17131
			#無.
17132
			$createLink=fileAccess::createLink($conf["fileAccess::createLink"]);
17132
			$createLink=fileAccess::createLink($conf["fileAccess::createLink"]);
17133
			unset($conf["fileAccess::createLink"]);
17133
			unset($conf["fileAccess::createLink"]);
17134
		
17134
 
17135
			#var_dump(__LINE__." ".print_r($createLink,true));
17135
			#var_dump(__LINE__." ".print_r($createLink,true));
17136
		
17136
 
17137
			#如果檢查參數失敗
17137
			#如果檢查參數失敗
17138
			if($createLink["status"]==="false"){
17138
			if($createLink["status"]==="false"){
17139
				
17139
 
17140
				#設置執行失敗
17140
				#設置執行失敗
17141
				$result["status"]="false";
17141
				$result["status"]="false";
17142
				
17142
 
17143
				#設置執行失敗訊息
17143
				#設置執行失敗訊息
17144
				$result["error"]=$createLink;
17144
				$result["error"]=$createLink;
17145
				
17145
 
17146
				#回傳結果
17146
				#回傳結果
17147
				return $result;
17147
				return $result;
17148
				
17148
 
17149
				}#if end
17149
				}#if end
17150
		
17150
 
17151
			#儲存建立好的軟連結資訊
17151
			#儲存建立好的軟連結資訊
17152
			$result["content"][]=$createLink["content"];
17152
			$result["content"][]=$createLink["content"];
17153
		
17153
 
17154
			}#foreach end
17154
			}#foreach end
17155
			
17155
 
17156
		#設置執行正常
17156
		#設置執行正常
17157
		$result["status"]="true";
17157
		$result["status"]="true";
17158
	
17158
 
17159
		#回傳結果
17159
		#回傳結果
17160
		return $result;
17160
		return $result;
17161
	
17161
 
17162
		}#function createMultiLink end
17162
		}#function createMultiLink end
17163
 
17163
 
17164
	/*
17164
	/*
17165
	#函式說明:
17165
	#函式說明:
17166
	#更新檔案的內容.
17166
	#更新檔案的內容.
Line 17195... Line 17195...
17195
	#無.
17195
	#無.
17196
	#備註:
17196
	#備註:
17197
	#無.
17197
	#無.
17198
	*/
17198
	*/
17199
	public static function updateFile(&$conf){
17199
	public static function updateFile(&$conf){
17200
	
17200
 
17201
		#初始化要回傳的結果
17201
		#初始化要回傳的結果
17202
		$result=array();
17202
		$result=array();
17203
 
17203
 
17204
		#取得當前執行的函數名稱
17204
		#取得當前執行的函數名稱
17205
		$result["function"]=__FUNCTION__;
17205
		$result["function"]=__FUNCTION__;
17206
 
17206
 
17207
		#如果沒有參數
17207
		#如果沒有參數
17208
		if(func_num_args()==0){
17208
		if(func_num_args()==0){
17209
			
17209
 
17210
			#設置執行失敗
17210
			#設置執行失敗
17211
			$result["status"]="false";
17211
			$result["status"]="false";
17212
			
17212
 
17213
			#設置執行錯誤訊息
17213
			#設置執行錯誤訊息
17214
			$result["error"]="函數".$result["function"]."需要參數";
17214
			$result["error"]="函數".$result["function"]."需要參數";
17215
			
17215
 
17216
			#回傳結果
17216
			#回傳結果
17217
			return $result;
17217
			return $result;
17218
			
17218
 
17219
			}#if end
17219
			}#if end
17220
 
17220
 
17221
		#取得參數
17221
		#取得參數
17222
		$result["argu"]=$conf;
17222
		$result["argu"]=$conf;
17223
 
17223
 
17224
		#如果 $conf 不為陣列
17224
		#如果 $conf 不為陣列
17225
		if(gettype($conf)!=="array"){
17225
		if(gettype($conf)!=="array"){
17226
			
17226
 
17227
			#設置執行失敗
17227
			#設置執行失敗
17228
			$result["status"]="false";
17228
			$result["status"]="false";
17229
			
17229
 
17230
			#設置執行錯誤訊息
17230
			#設置執行錯誤訊息
17231
			$result["error"][]="\$conf變數須為陣列形態";
17231
			$result["error"][]="\$conf變數須為陣列形態";
17232
			
17232
 
17233
			#如果傳入的參數為 null
17233
			#如果傳入的參數為 null
17234
			if($conf===null){
17234
			if($conf===null){
17235
				
17235
 
17236
				#設置執行錯誤訊息
17236
				#設置執行錯誤訊息
17237
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
17237
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
17238
				
17238
 
17239
				}#if end
17239
				}#if end
17240
 
17240
 
17241
			#回傳結果
17241
			#回傳結果
17242
			return $result;
17242
			return $result;
17243
			
17243
 
17244
			}#if end
17244
			}#if end
17245
			
17245
 
17246
		#檢查參數
17246
		#檢查參數
17247
		#函式說明:
17247
		#函式說明:
17248
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
17248
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
17249
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17249
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17250
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
17250
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 17276... Line 17276...
17276
		#$conf["canBeEmpty"]=array();
17276
		#$conf["canBeEmpty"]=array();
17277
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
17277
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
17278
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("overWriteWith","replaceWith","addToTailWhenNoMatch","addToTailBeforeThat","replaceLike","replaceSpecifyLine","outputPath");
17278
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("overWriteWith","replaceWith","addToTailWhenNoMatch","addToTailBeforeThat","replaceLike","replaceSpecifyLine","outputPath");
17279
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
17279
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
17280
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("overWriteWith","replaceWith","addToTailWhenNoMatch","addToTailBeforeThat","replaceLike","replaceSpecifyLine","outputPath");
17280
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("overWriteWith","replaceWith","addToTailWhenNoMatch","addToTailBeforeThat","replaceLike","replaceSpecifyLine","outputPath");
17281
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
17281
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
17282
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","array","string","string","string","array","string");
17282
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","array","string","string","string","array","string");
17283
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
17283
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
17284
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,"false",null,"false",null,null);
17284
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,"false",null,"false",null,null);
17285
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
17285
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
17286
		#$conf["disallowAllSkipableVarIsEmpty"]="";
17286
		#$conf["disallowAllSkipableVarIsEmpty"]="";
Line 17290... Line 17290...
17290
		#$conf["arrayCountEqualCheck"][]=array();
17290
		#$conf["arrayCountEqualCheck"][]=array();
17291
		#參考資料來源:
17291
		#參考資料來源:
17292
		#array_keys=>http://php.net/manual/en/function.array-keys.php
17292
		#array_keys=>http://php.net/manual/en/function.array-keys.php
17293
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
17293
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
17294
		unset($conf["variableCheck::checkArguments"]);
17294
		unset($conf["variableCheck::checkArguments"]);
17295
		
17295
 
17296
		#如果檢查參數失敗
17296
		#如果檢查參數失敗
17297
		if($checkArguments["status"]==="false"){
17297
		if($checkArguments["status"]==="false"){
17298
			
17298
 
17299
			#設置執行失敗
17299
			#設置執行失敗
17300
			$result["status"]="false";
17300
			$result["status"]="false";
17301
			
17301
 
17302
			#設置執行失敗訊息
17302
			#設置執行失敗訊息
17303
			$result["error"]=$checkArguments;
17303
			$result["error"]=$checkArguments;
17304
			
17304
 
17305
			#回傳結果
17305
			#回傳結果
17306
			return $result;
17306
			return $result;
17307
			
17307
 
17308
			}#if end
17308
			}#if end
17309
			
17309
 
17310
		#如果檢查參數不通過
17310
		#如果檢查參數不通過
17311
		if($checkArguments["passed"]==="false"){
17311
		if($checkArguments["passed"]==="false"){
17312
			
17312
 
17313
			#設置執行失敗
17313
			#設置執行失敗
17314
			$result["status"]="false";
17314
			$result["status"]="false";
17315
			
17315
 
17316
			#設置執行失敗訊息
17316
			#設置執行失敗訊息
17317
			$result["error"]=$checkArguments;
17317
			$result["error"]=$checkArguments;
17318
			
17318
 
17319
			#回傳結果
17319
			#回傳結果
17320
			return $result;
17320
			return $result;
17321
			
17321
 
17322
			}#if end
17322
			}#if end
17323
			
17323
 
17324
		#檢查檔案是否存在
17324
		#檢查檔案是否存在
17325
		#函式說明:
17325
		#函式說明:
17326
		#檢查多個檔案與資料夾是否存在.
17326
		#檢查多個檔案與資料夾是否存在.
17327
		#回傳的結果:
17327
		#回傳的結果:
17328
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
17328
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
Line 17352... Line 17352...
17352
		#備註:
17352
		#備註:
17353
		#函數file_exists檢查的路徑為檔案系統的路徑
17353
		#函數file_exists檢查的路徑為檔案系統的路徑
17354
		#$result["varName"][$i]結果未實作
17354
		#$result["varName"][$i]結果未實作
17355
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
17355
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
17356
		unset($conf["fileAccess::checkMultiFileExist"]);
17356
		unset($conf["fileAccess::checkMultiFileExist"]);
17357
	
17357
 
17358
		#如果檢查參數失敗
17358
		#如果檢查參數失敗
17359
		if($checkMultiFileExist["status"]==="false"){
17359
		if($checkMultiFileExist["status"]==="false"){
17360
			
17360
 
17361
			#設置執行失敗
17361
			#設置執行失敗
17362
			$result["status"]="false";
17362
			$result["status"]="false";
17363
			
17363
 
17364
			#設置執行失敗訊息
17364
			#設置執行失敗訊息
17365
			$result["error"]=$checkMultiFileExist;
17365
			$result["error"]=$checkMultiFileExist;
17366
			
17366
 
17367
			#回傳結果
17367
			#回傳結果
17368
			return $result;
17368
			return $result;
17369
			
17369
 
17370
			}#if end
17370
			}#if end
17371
			
17371
 
17372
		#如果目標檔案不存在
17372
		#如果目標檔案不存在
17373
		if($checkMultiFileExist["allExist"]==="false"){
17373
		if($checkMultiFileExist["allExist"]==="false"){
17374
			
17374
 
17375
			#設置執行失敗
17375
			#設置執行失敗
17376
			$result["status"]="false";
17376
			$result["status"]="false";
17377
			
17377
 
17378
			#設置執行失敗訊息
17378
			#設置執行失敗訊息
17379
			$result["error"]=$checkMultiFileExist;
17379
			$result["error"]=$checkMultiFileExist;
17380
			
17380
 
17381
			#回傳結果
17381
			#回傳結果
17382
			return $result;
17382
			return $result;
17383
			
17383
 
17384
			}#if end
17384
			}#if end
17385
		
17385
 
17386
		#預設要寫入的位置為原始檔案
17386
		#預設要寫入的位置為原始檔案
17387
		$file2write=$conf["file"];
17387
		$file2write=$conf["file"];
17388
		
17388
 
17389
		#如果有設置 outputPath
17389
		#如果有設置 outputPath
17390
		if(isset($conf["outputPath"])){
17390
		if(isset($conf["outputPath"])){
17391
		
17391
 
17392
			#寫入檔案的路徑與名稱
17392
			#寫入檔案的路徑與名稱
17393
			$file2write=$conf["outputPath"]."/".$conf["file"];
17393
			$file2write=$conf["outputPath"]."/".$conf["file"];
17394
		
17394
 
17395
			}#if end
17395
			}#if end
17396
		
17396
 
17397
		#如果有設置 overWriteWith
17397
		#如果有設置 overWriteWith
17398
		if(isset($conf["overWriteWith"])){
17398
		if(isset($conf["overWriteWith"])){
17399
		
17399
 
17400
			#函式說明:
17400
			#函式說明:
17401
			#將多行字串寫入到檔案
17401
			#將多行字串寫入到檔案
17402
			#回傳結果:
17402
			#回傳結果:
17403
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
17403
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
17404
			#$result["error"],錯誤訊息陣列.
17404
			#$result["error"],錯誤訊息陣列.
Line 17418... Line 17418...
17418
			#無.
17418
			#無.
17419
			#備註:
17419
			#備註:
17420
			#無.
17420
			#無.
17421
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
17421
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
17422
			unset($conf["fileAccess::writeMultiLine"]);
17422
			unset($conf["fileAccess::writeMultiLine"]);
17423
		
17423
 
17424
			#如果執行失敗
17424
			#如果執行失敗
17425
			if($writeMultiLine["status"]==="false"){
17425
			if($writeMultiLine["status"]==="false"){
17426
				
17426
 
17427
				#設置執行失敗
17427
				#設置執行失敗
17428
				$result["status"]="false";
17428
				$result["status"]="false";
17429
				
17429
 
17430
				#設置執行失敗訊息
17430
				#設置執行失敗訊息
17431
				$result["error"]=$writeMultiLine;
17431
				$result["error"]=$writeMultiLine;
17432
				
17432
 
17433
				#回傳結果
17433
				#回傳結果
17434
				return $result;
17434
				return $result;
17435
				
17435
 
17436
				}#if end
17436
				}#if end
17437
			
17437
 
17438
			#取得原始檔案的內容
17438
			#取得原始檔案的內容
17439
			#函式說明:
17439
			#函式說明:
17440
			#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
17440
			#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
17441
			#回傳的變數說明:
17441
			#回傳的變數說明:
17442
			#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
17442
			#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
Line 17465... Line 17465...
17465
			#無.
17465
			#無.
17466
			#備註:
17466
			#備註:
17467
			#無.
17467
			#無.
17468
			$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
17468
			$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
17469
			unset($conf["fileAccess::getFileContent"]);
17469
			unset($conf["fileAccess::getFileContent"]);
17470
		
17470
 
17471
			#如果執行失敗
17471
			#如果執行失敗
17472
			if($getFileContent["status"]==="false"){
17472
			if($getFileContent["status"]==="false"){
17473
				
17473
 
17474
				#設置執行失敗
17474
				#設置執行失敗
17475
				$result["status"]="false";
17475
				$result["status"]="false";
17476
				
17476
 
17477
				#設置執行失敗訊息
17477
				#設置執行失敗訊息
17478
				$result["error"]=$getFileContent;
17478
				$result["error"]=$getFileContent;
17479
				
17479
 
17480
				#回傳結果
17480
				#回傳結果
17481
				return $result;
17481
				return $result;
17482
				
17482
 
17483
				}#if end
17483
				}#if end
17484
			
17484
 
17485
			#無窮迴圈
17485
			#無窮迴圈
17486
			for($i=0;$i>=0;$i++){
17486
			for($i=0;$i>=0;$i++){
17487
			
17487
 
17488
				#如果有舊或新的行內容存在
17488
				#如果有舊或新的行內容存在
17489
				if( isset($getFileContent["fileContent"][$i]) || isset($conf["overWriteWith"][$i]) ){
17489
				if( isset($getFileContent["fileContent"][$i]) || isset($conf["overWriteWith"][$i]) ){
17490
				
17490
 
17491
					#初始化暫存舊行內容的變數
17491
					#初始化暫存舊行內容的變數
17492
					$oriLine=null;
17492
					$oriLine=null;
17493
					
17493
 
17494
					#初始化暫存新行內容的變數
17494
					#初始化暫存新行內容的變數
17495
					$newLine=null;
17495
					$newLine=null;
17496
					
17496
 
17497
					#如果存在原行內容
17497
					#如果存在原行內容
17498
					if(isset($getFileContent["fileContent"][$i])){
17498
					if(isset($getFileContent["fileContent"][$i])){
17499
					
17499
 
17500
						#儲存原行內容
17500
						#儲存原行內容
17501
						$oriLine=$getFileContent["fileContent"][$i];
17501
						$oriLine=$getFileContent["fileContent"][$i];
17502
					
17502
 
17503
						}#if end
17503
						}#if end
17504
						
17504
 
17505
					#如果存在新行內容
17505
					#如果存在新行內容
17506
					if(isset($conf["overWriteWith"][$i])){
17506
					if(isset($conf["overWriteWith"][$i])){
17507
					
17507
 
17508
						#儲存新行內容
17508
						#儲存新行內容
17509
						$newLine=$conf["overWriteWith"][$i];
17509
						$newLine=$conf["overWriteWith"][$i];
17510
					
17510
 
17511
						}#if end
17511
						}#if end
17512
					
17512
 
17513
					#設置更新的資訊
17513
					#設置更新的資訊
17514
					$result["content"][$i]=array("ori"=>$oriLine,"new"=>$newLine);
17514
					$result["content"][$i]=array("ori"=>$oriLine,"new"=>$newLine);
17515
				
17515
 
17516
					}#if end
17516
					}#if end
17517
					
17517
 
17518
				#反之
17518
				#反之
17519
				else{
17519
				else{
17520
				
17520
 
17521
					#結束迴圈
17521
					#結束迴圈
17522
					break;
17522
					break;
17523
				
17523
 
17524
					}#else end
17524
					}#else end
17525
				
17525
 
17526
				}#for end
17526
				}#for end
17527
			
17527
 
17528
			}#if end
17528
			}#if end
17529
			
17529
 
17530
		#反之如果有設置 "replaceWith"
17530
		#反之如果有設置 "replaceWith"
17531
		else if(isset($conf["replaceWith"])){
17531
		else if(isset($conf["replaceWith"])){
17532
		
17532
 
17533
			#取得檔案的內容
17533
			#取得檔案的內容
17534
			#函式說明:
17534
			#函式說明:
17535
			#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
17535
			#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
17536
			#回傳的變數說明:
17536
			#回傳的變數說明:
17537
			#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
17537
			#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
Line 17560... Line 17560...
17560
			#無.
17560
			#無.
17561
			#備註:
17561
			#備註:
17562
			#無.
17562
			#無.
17563
			$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
17563
			$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
17564
			unset($conf["fileAccess::getFileContent"]);
17564
			unset($conf["fileAccess::getFileContent"]);
17565
		
17565
 
17566
			#如果執行失敗
17566
			#如果執行失敗
17567
			if($getFileContent["status"]==="false"){
17567
			if($getFileContent["status"]==="false"){
17568
				
17568
 
17569
				#設置執行失敗
17569
				#設置執行失敗
17570
				$result["status"]="false";
17570
				$result["status"]="false";
17571
				
17571
 
17572
				#設置執行失敗訊息
17572
				#設置執行失敗訊息
17573
				$result["error"]=$getFileContent;
17573
				$result["error"]=$getFileContent;
17574
				
17574
 
17575
				#回傳結果
17575
				#回傳結果
17576
				return $result;
17576
				return $result;
17577
				
17577
 
17578
				}#if end
17578
				}#if end
17579
				
17579
 
17580
			#取得原始檔案的每行內容
17580
			#取得原始檔案的每行內容
17581
			$oriFileContentByLine=&$getFileContent["fileContent"];
17581
			$oriFileContentByLine=&$getFileContent["fileContent"];
17582
		
17582
 
17583
			#針對每個 replaceWith 條件
17583
			#針對每個 replaceWith 條件
17584
			foreach($conf["replaceWith"] as $replaceInfo){
17584
			foreach($conf["replaceWith"] as $replaceInfo){
17585
			
17585
 
17586
				#預設尚未找到符合的關鍵字
17586
				#預設尚未找到符合的關鍵字
17587
				$foundKeyWord=false;
17587
				$foundKeyWord=false;
17588
			
17588
 
17589
				#取得要替換的目標字串
17589
				#取得要替換的目標字串
17590
				$oriStr=$replaceInfo[0];
17590
				$oriStr=$replaceInfo[0];
17591
			
17591
 
17592
				#取得要替換成的字串內容
17592
				#取得要替換成的字串內容
17593
				$newStr=$replaceInfo[1];
17593
				$newStr=$replaceInfo[1];
17594
				
17594
 
17595
				#針對每行原始內容
17595
				#針對每行原始內容
17596
				foreach($oriFileContentByLine as $index => $line){
17596
				foreach($oriFileContentByLine as $index => $line){
17597
				
17597
 
17598
					#函式說明:
17598
					#函式說明:
17599
					#檢查字串裡面有無指定的關鍵字
17599
					#檢查字串裡面有無指定的關鍵字
17600
					#回傳結果:
17600
					#回傳結果:
17601
					#$result["status"],"true"代表執行成功,"false"代表執行失敗。
17601
					#$result["status"],"true"代表執行成功,"false"代表執行失敗。
17602
					#$result["error"],錯誤訊息
17602
					#$result["error"],錯誤訊息
Line 17608... Line 17608...
17608
					#$conf["keyWord"],字串,想要搜尋的關鍵字.
17608
					#$conf["keyWord"],字串,想要搜尋的關鍵字.
17609
					$conf["search::findKeyWord"]["keyWord"]=$oriStr;
17609
					$conf["search::findKeyWord"]["keyWord"]=$oriStr;
17610
					#$conf["string"],字串,要被搜尋的字串內容
17610
					#$conf["string"],字串,要被搜尋的字串內容
17611
					$conf["search::findKeyWord"]["string"]=$line;
17611
					$conf["search::findKeyWord"]["string"]=$line;
17612
					#可省略參數:
17612
					#可省略參數:
17613
					
17613
 
17614
					#如果要完全符合關鍵字
17614
					#如果要完全符合關鍵字
17615
					if($conf["replaceLike"]==="false"){
17615
					if($conf["replaceLike"]==="false"){
17616
					
17616
 
17617
						#$conf["completeEqual"],字串,是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
17617
						#$conf["completeEqual"],字串,是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
17618
						$conf["search::findKeyWord"]["completeEqual"]="true";
17618
						$conf["search::findKeyWord"]["completeEqual"]="true";
17619
					
17619
 
17620
						}#if end
17620
						}#if end
17621
					
17621
 
17622
					#參考資料:
17622
					#參考資料:
17623
					#無.
17623
					#無.
17624
					#備註:
17624
					#備註:
17625
					#無.
17625
					#無.
17626
					$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
17626
					$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
17627
					unset($conf["search::findKeyWord"]);
17627
					unset($conf["search::findKeyWord"]);
17628
				
17628
 
17629
					#如果執行失敗
17629
					#如果執行失敗
17630
					if($findKeyWord["status"]==="false"){
17630
					if($findKeyWord["status"]==="false"){
17631
						
17631
 
17632
						#設置執行失敗
17632
						#設置執行失敗
17633
						$result["status"]="false";
17633
						$result["status"]="false";
17634
						
17634
 
17635
						#設置執行失敗訊息
17635
						#設置執行失敗訊息
17636
						$result["error"]=$findKeyWord;
17636
						$result["error"]=$findKeyWord;
17637
						
17637
 
17638
						#回傳結果
17638
						#回傳結果
17639
						return $result;
17639
						return $result;
17640
						
17640
 
17641
						}#if end
17641
						}#if end
17642
						
17642
 
17643
					#如果有找到關鍵字
17643
					#如果有找到關鍵字
17644
					if($findKeyWord["founded"]==="true"){
17644
					if($findKeyWord["founded"]==="true"){
17645
						
17645
 
17646
						#設置更新的資訊
17646
						#設置更新的資訊
17647
						$result["content"][$lineIndex]=array("ori"=>$oriFileContentByLine[$index],"new"=>$newStr);
17647
						$result["content"][$lineIndex]=array("ori"=>$oriFileContentByLine[$index],"new"=>$newStr);
17648
						
17648
 
17649
						#更新該行內容
17649
						#更新該行內容
17650
						$oriFileContentByLine[$index]=$newStr;
17650
						$oriFileContentByLine[$index]=$newStr;
17651
						
17651
 
17652
						#設置有找到符合的關鍵字
17652
						#設置有找到符合的關鍵字
17653
						$foundKeyWord=true;
17653
						$foundKeyWord=true;
17654
						
17654
 
17655
						}#if end
17655
						}#if end
17656
				
17656
 
17657
					}#foreach end
17657
					}#foreach end
17658
			
17658
 
17659
				#如果沒有找到關鍵字
17659
				#如果沒有找到關鍵字
17660
				if($foundKeyWord===false){
17660
				if($foundKeyWord===false){
17661
				
17661
 
17662
					#如果要新增內容
17662
					#如果要新增內容
17663
					if($conf["addToTailWhenNoMatch"]==="true"){
17663
					if($conf["addToTailWhenNoMatch"]==="true"){
17664
					
17664
 
17665
						#如果有設置 addToTailBeforeThat
17665
						#如果有設置 addToTailBeforeThat
17666
						if(isset($conf["addToTailBeforeThat"])){
17666
						if(isset($conf["addToTailBeforeThat"])){
17667
						
17667
 
17668
							#預設沒有找到符合的關鍵字
17668
							#預設沒有找到符合的關鍵字
17669
							$foundKeyWord=false;
17669
							$foundKeyWord=false;
17670
						
17670
 
17671
							#初始化要記錄要 append 回去的各行內容.
17671
							#初始化要記錄要 append 回去的各行內容.
17672
							$linesToAppend=array();
17672
							$linesToAppend=array();
17673
						
17673
 
17674
							#倒敘,針對每行內容
17674
							#倒敘,針對每行內容
17675
							for($i=count($oriFileContentByLine)-1;$i>=0;$i--){
17675
							for($i=count($oriFileContentByLine)-1;$i>=0;$i--){
17676
							
17676
 
17677
								#儲存要 append 回去的行內容
17677
								#儲存要 append 回去的行內容
17678
								$linesToAppend[]=$oriFileContentByLine[$i];
17678
								$linesToAppend[]=$oriFileContentByLine[$i];
17679
							
17679
 
17680
								#如果找到關鍵字了
17680
								#如果找到關鍵字了
17681
								if($oriFileContentByLine[$i]===$conf["addToTailBeforeThat"]){
17681
								if($oriFileContentByLine[$i]===$conf["addToTailBeforeThat"]){
17682
								
17682
 
17683
									#設置有找到符合的關鍵字
17683
									#設置有找到符合的關鍵字
17684
									$foundKeyWord=true;
17684
									$foundKeyWord=true;
17685
								
17685
 
17686
									#設置更新的資訊
17686
									#設置更新的資訊
17687
									$result["content"][$lineIndex]=array("ori"=>$oriFileContentByLine[$i],"new"=>$line);
17687
									$result["content"][$lineIndex]=array("ori"=>$oriFileContentByLine[$i],"new"=>$line);
17688
									
17688
 
17689
									#更新該行內容
17689
									#更新該行內容
17690
									$oriFileContentByLine[$i]=$line;
17690
									$oriFileContentByLine[$i]=$line;
17691
								
17691
 
17692
									#倒敘陣列
17692
									#倒敘陣列
17693
									$linesToAppend=array_reverse($linesToAppend);
17693
									$linesToAppend=array_reverse($linesToAppend);
17694
								
17694
 
17695
									#針對每行要 append 回去的內容
17695
									#針對每行要 append 回去的內容
17696
									foreach($linesToAppend as $lineToAppend){
17696
									foreach($linesToAppend as $lineToAppend){
17697
									
17697
 
17698
										#append 行內容
17698
										#append 行內容
17699
										$oriFileContentByLine[]=$lineToAppend;
17699
										$oriFileContentByLine[]=$lineToAppend;
17700
										
17700
 
17701
										#設置更新的資訊
17701
										#設置更新的資訊
17702
										$result["content"][count($oriFileContentByLine)-1]=array("ori"=>null,"new"=>$lineToAppend);
17702
										$result["content"][count($oriFileContentByLine)-1]=array("ori"=>null,"new"=>$lineToAppend);
17703
										
17703
 
17704
										}#foreach end
17704
										}#foreach end
17705
								
17705
 
17706
									}#if end
17706
									}#if end
17707
							
17707
 
17708
								}#for end
17708
								}#for end
17709
								
17709
 
17710
							#如果沒有找到關鍵字
17710
							#如果沒有找到關鍵字
17711
							if($foundKeyWord===false){
17711
							if($foundKeyWord===false){
17712
							
17712
 
17713
								#設置執行失敗
17713
								#設置執行失敗
17714
								$result["status"]="false";
17714
								$result["status"]="false";
17715
								
17715
 
17716
								#設置錯誤訊息
17716
								#設置錯誤訊息
17717
								$result["error"]="can't find \"".$conf["addToTailBeforeThat"]."\" to insert before it.";
17717
								$result["error"]="can't find \"".$conf["addToTailBeforeThat"]."\" to insert before it.";
17718
							
17718
 
17719
								#回傳結果
17719
								#回傳結果
17720
								return $result;
17720
								return $result;
17721
							
17721
 
17722
								}#if end
17722
								}#if end
17723
						
17723
 
17724
							}#if end
17724
							}#if end
17725
					
17725
 
17726
						}#if end
17726
						}#if end
17727
				
17727
 
17728
					}#if end
17728
					}#if end
17729
			
17729
 
17730
				}#foreach end
17730
				}#foreach end
17731
				
17731
 
17732
			#函式說明:
17732
			#函式說明:
17733
			#將多行字串寫入到檔案
17733
			#將多行字串寫入到檔案
17734
			#回傳結果:
17734
			#回傳結果:
17735
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
17735
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
17736
			#$result["error"],錯誤訊息陣列.
17736
			#$result["error"],錯誤訊息陣列.
Line 17750... Line 17750...
17750
			#無.
17750
			#無.
17751
			#備註:
17751
			#備註:
17752
			#無.
17752
			#無.
17753
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
17753
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
17754
			unset($conf["fileAccess::writeMultiLine"]);
17754
			unset($conf["fileAccess::writeMultiLine"]);
17755
		
17755
 
17756
			#如果執行失敗
17756
			#如果執行失敗
17757
			if($writeMultiLine["status"]==="false"){
17757
			if($writeMultiLine["status"]==="false"){
17758
				
17758
 
17759
				#設置執行失敗
17759
				#設置執行失敗
17760
				$result["status"]="false";
17760
				$result["status"]="false";
17761
				
17761
 
17762
				#設置執行失敗訊息
17762
				#設置執行失敗訊息
17763
				$result["error"]=$writeMultiLine;
17763
				$result["error"]=$writeMultiLine;
17764
				
17764
 
17765
				#回傳結果
17765
				#回傳結果
17766
				return $result;
17766
				return $result;
17767
				
17767
 
17768
				}#if end
17768
				}#if end
17769
		
17769
 
17770
			}#if end
17770
			}#if end
17771
	
17771
 
17772
		#反之如果有設置 replaceSpecifyLine
17772
		#反之如果有設置 replaceSpecifyLine
17773
		else if(isset($conf["replaceSpecifyLine"])){
17773
		else if(isset($conf["replaceSpecifyLine"])){
17774
		
17774
 
17775
			#讀取原始檔案內容
17775
			#讀取原始檔案內容
17776
			#函式說明:
17776
			#函式說明:
17777
			#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
17777
			#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
17778
			#回傳的變數說明:
17778
			#回傳的變數說明:
17779
			#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
17779
			#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
Line 17807... Line 17807...
17807
			#無.
17807
			#無.
17808
			#備註:
17808
			#備註:
17809
			#無.
17809
			#無.
17810
			$getFileContent=fileAccess::getFileContent($conf["fileAcceess::getFileContent"]);
17810
			$getFileContent=fileAccess::getFileContent($conf["fileAcceess::getFileContent"]);
17811
			unset($conf["fileAcceess::getFileContent"]);
17811
			unset($conf["fileAcceess::getFileContent"]);
17812
		
17812
 
17813
			#如果執行失敗
17813
			#如果執行失敗
17814
			if($getFileContent["status"]==="false"){
17814
			if($getFileContent["status"]==="false"){
17815
				
17815
 
17816
				#設置執行失敗
17816
				#設置執行失敗
17817
				$result["status"]="false";
17817
				$result["status"]="false";
17818
				
17818
 
17819
				#設置執行失敗訊息
17819
				#設置執行失敗訊息
17820
				$result["error"]=$getFileContent;
17820
				$result["error"]=$getFileContent;
17821
				
17821
 
17822
				#回傳結果
17822
				#回傳結果
17823
				return $result;
17823
				return $result;
17824
				
17824
 
17825
				}#if end
17825
				}#if end
17826
		
17826
 
17827
			#針對每個要更新的行
17827
			#針對每個要更新的行
17828
			foreach($conf["replaceSpecifyLine"] as $lineIndex => $newLineContent){
17828
			foreach($conf["replaceSpecifyLine"] as $lineIndex => $newLineContent){
17829
			
17829
 
17830
				#設置更新的資訊
17830
				#設置更新的資訊
17831
				$result["content"][$lineIndex]=array("ori"=>$getFileContent["fileContent"][$lineIndex],"new"=>$newLineContent);
17831
				$result["content"][$lineIndex]=array("ori"=>$getFileContent["fileContent"][$lineIndex],"new"=>$newLineContent);
17832
			
17832
 
17833
				#更新行內容
17833
				#更新行內容
17834
				$getFileContent["fileContent"][$lineIndex]=$newLineContent;
17834
				$getFileContent["fileContent"][$lineIndex]=$newLineContent;
17835
			
17835
 
17836
				}#foreach end
17836
				}#foreach end
17837
				
17837
 
17838
			#debug
17838
			#debug
17839
			#var_dump(__FILE__,__LINE__,count($getFileContent["fileContent"]));
17839
			#var_dump(__FILE__,__LINE__,count($getFileContent["fileContent"]));
17840
				
17840
 
17841
			#將變更寫入到檔案裡面
17841
			#將變更寫入到檔案裡面
17842
			#函式說明:
17842
			#函式說明:
17843
			#將多行字串寫入到檔案
17843
			#將多行字串寫入到檔案
17844
			#回傳結果:
17844
			#回傳結果:
17845
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
17845
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
Line 17860... Line 17860...
17860
			#無.
17860
			#無.
17861
			#備註:
17861
			#備註:
17862
			#無.
17862
			#無.
17863
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
17863
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
17864
			unset($conf["fileAccess::writeMultiLine"]);
17864
			unset($conf["fileAccess::writeMultiLine"]);
17865
			
17865
 
17866
			#如果執行失敗
17866
			#如果執行失敗
17867
			if($writeMultiLine["status"]==="false"){
17867
			if($writeMultiLine["status"]==="false"){
17868
				
17868
 
17869
				#設置執行失敗
17869
				#設置執行失敗
17870
				$result["status"]="false";
17870
				$result["status"]="false";
17871
				
17871
 
17872
				#設置執行失敗訊息
17872
				#設置執行失敗訊息
17873
				$result["error"]=$writeMultiLine;
17873
				$result["error"]=$writeMultiLine;
17874
				
17874
 
17875
				#回傳結果
17875
				#回傳結果
17876
				return $result;
17876
				return $result;
17877
				
17877
 
17878
				}#if end
17878
				}#if end
17879
				
17879
 
17880
			#debug
17880
			#debug
17881
			#var_dump(__FILE__,__LINE__,$writeMultiLine);exit(1);
17881
			#var_dump(__FILE__,__LINE__,$writeMultiLine);exit(1);
17882
		
17882
 
17883
			}#if end
17883
			}#if end
17884
		
17884
 
17885
		#設置執行正常
17885
		#設置執行正常
17886
		$result["status"]="true";
17886
		$result["status"]="true";
17887
	
17887
 
17888
		#回傳結果
17888
		#回傳結果
17889
		return $result;
17889
		return $result;
17890
	
17890
 
17891
		}#function updateFile end
17891
		}#function updateFile end
17892
		
17892
 
17893
	/*
17893
	/*
17894
	#函式說明:
17894
	#函式說明:
17895
	#輔助使用PHP內建的chmod函式.
17895
	#輔助使用PHP內建的chmod函式.
17896
	#回傳結果:
17896
	#回傳結果:
17897
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17897
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 17911... Line 17911...
17911
	#無.
17911
	#無.
17912
	#備註:
17912
	#備註:
17913
	#無.
17913
	#無.
17914
	*/
17914
	*/
17915
	public static function chmod(&$conf){
17915
	public static function chmod(&$conf){
17916
	
17916
 
17917
		#初始化要回傳的結果
17917
		#初始化要回傳的結果
17918
		$result=array();
17918
		$result=array();
17919
 
17919
 
17920
		#取得當前執行的函數名稱
17920
		#取得當前執行的函數名稱
17921
		$result["function"]=__FUNCTION__;
17921
		$result["function"]=__FUNCTION__;
Line 17956... Line 17956...
17956
 
17956
 
17957
			#回傳結果
17957
			#回傳結果
17958
			return $result;
17958
			return $result;
17959
 
17959
 
17960
			}#if end
17960
			}#if end
17961
			
17961
 
17962
		#函式說明:
17962
		#函式說明:
17963
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
17963
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
17964
		#回傳結果:
17964
		#回傳結果:
17965
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17965
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17966
		#$result["error"],執行不正常結束的錯訊息陣列.
17966
		#$result["error"],執行不正常結束的錯訊息陣列.
Line 18009... Line 18009...
18009
		#array_keys=>http://php.net/manual/en/function.array-keys.php
18009
		#array_keys=>http://php.net/manual/en/function.array-keys.php
18010
		#備註:
18010
		#備註:
18011
		#無.
18011
		#無.
18012
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
18012
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
18013
		unset($conf["variableCheck::checkArguments"]);
18013
		unset($conf["variableCheck::checkArguments"]);
18014
	
18014
 
18015
		#如果檢查參數失敗
18015
		#如果檢查參數失敗
18016
		if($checkArguments["status"]==="false"){
18016
		if($checkArguments["status"]==="false"){
18017
		
18017
 
18018
			#設置執行失敗
18018
			#設置執行失敗
18019
			$result["status"]="false";
18019
			$result["status"]="false";
18020
 
18020
 
18021
			#設置錯誤資訊
18021
			#設置錯誤資訊
18022
			$result["error"]=$checkArguments;
18022
			$result["error"]=$checkArguments;
18023
			
18023
 
18024
			#回傳結果
18024
			#回傳結果
18025
			return $result;
18025
			return $result;
18026
		
18026
 
18027
			}#if end
18027
			}#if end
18028
			
18028
 
18029
		#如果檢查參數不通過
18029
		#如果檢查參數不通過
18030
		if($checkArguments["passed"]==="false"){
18030
		if($checkArguments["passed"]==="false"){
18031
		
18031
 
18032
			#設置執行失敗
18032
			#設置執行失敗
18033
			$result["status"]="false";
18033
			$result["status"]="false";
18034
 
18034
 
18035
			#設置錯誤資訊
18035
			#設置錯誤資訊
18036
			$result["error"]=$checkArguments;
18036
			$result["error"]=$checkArguments;
18037
			
18037
 
18038
			#回傳結果
18038
			#回傳結果
18039
			return $result;
18039
			return $result;
18040
		
18040
 
18041
			}#if end
18041
			}#if end
18042
				
18042
 
18043
		#將$conf["mode"]轉換為10進位的整數
18043
		#將$conf["mode"]轉換為10進位的整數
18044
		$conf["mode"]=(int)base_convert($conf["mode"],8,10);
18044
		$conf["mode"]=(int)base_convert($conf["mode"],8,10);
18045
		
18045
 
18046
		#變更 target 的檔案權限為代碼
18046
		#變更 target 的檔案權限為代碼
18047
		$chmod=chmod($conf["target"],$conf["mode"]); 
18047
		$chmod=chmod($conf["target"],$conf["mode"]);
18048
		
18048
 
18049
		#如果改變檔案權限失敗
18049
		#如果改變檔案權限失敗
18050
		if($chmod===false){
18050
		if($chmod===false){
18051
				
18051
 
18052
			#設置執行失敗
18052
			#設置執行失敗
18053
			$result["status"]="false";
18053
			$result["status"]="false";
18054
			
18054
 
18055
			#設置錯誤訊息
18055
			#設置錯誤訊息
18056
			$result["error"][]="改變 ".$conf["target"]." 檔案的權限資訊為 ".$conf["mode"]." 失敗,通常只有系統帳戶才能變更之.";
18056
			$result["error"][]="改變 ".$conf["target"]." 檔案的權限資訊為 ".$conf["mode"]." 失敗,通常只有系統帳戶才能變更之.";
18057
			
18057
 
18058
			#回傳結果
18058
			#回傳結果
18059
			return $result;	
18059
			return $result;
18060
				
18060
 
18061
			}#if end
18061
			}#if end
18062
			
18062
 
18063
		#設置執行正常
18063
		#設置執行正常
18064
		$result["status"]="true";
18064
		$result["status"]="true";
18065
	
18065
 
18066
		#回傳結果
18066
		#回傳結果
18067
		return $result;
18067
		return $result;
18068
	
18068
 
18069
		}#function chmod end
18069
		}#function chmod end
18070
 
18070
 
18071
	}#class fileAccess end
18071
	}#class fileAccess end
18072
 
18072
 
18073
?>
-
 
18074
18073
?>
-
 
18074