Subversion Repositories php-qbpwcf

Rev

Rev 36 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 1
<?php
2
 
3
/*
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2015~2024 Min-Jhin,Chen
7
 
8
    This file is part of QBPWCF.
9
 
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
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
 
15
    QBPWCF is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
*/
24
namespace qbpwcf;
25
 
26
/*
27
類別說明:
28
檔案存取應用的類別.
29
備註:
30
無.
31
*/
32
class fileAccess{
33
 
34
	/*
35
	#函式說明:
36
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
37
	#回傳結果:
38
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
39
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
40
	#$result["function"],當前執行的函式名稱.
41
	#必填參數:
42
	#$method,物件,為物件實體或類別名稱,會自動置入該參數.
43
	#$arguments,陣列,為呼叫方法時所用的參數.
44
	#參考資料:
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
46
	*/
47
	public function __call($method,$arguments){
48
 
49
		#取得當前執行的函式
50
		$result["function"]=__FUNCTION__;
51
 
52
		#設置執行不正常
53
		$result["status"]="false";
54
 
55
		#設置執行錯誤
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
57
 
58
		#設置所丟入的參數
59
		$result["error"][]=$arguments;
60
 
61
		#回傳結果
62
		return $result;
63
 
64
		}#function __call end
65
 
66
	/*
67
	#函式說明:
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
69
	#回傳結果:
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
71
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
72
	#$result["function"],當前執行的函式名稱.
73
	#必填參數:
74
	#$method,物件,為物件實體或類別名稱,會自動置入該參數.
75
	#$arguments,陣列,為呼叫方法時所用的參數.
76
	#參考資料:
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
78
	*/
79
	public static function __callStatic($method,$arguments){
80
 
81
		#取得當前執行的函式
82
		$result["function"]=__FUNCTION__;
83
 
84
		#設置執行不正常
85
		$result["status"]="false";
86
 
87
		#設置執行錯誤
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
89
 
90
		#設置所丟入的參數
91
		$result["error"][]=$arguments;
92
 
93
		#回傳結果
94
		return $result;
95
 
96
		}#function __callStatic end
97
 
98
	/*
99
	#函式說明:
100
	#將字串寫入到檔案
101
	#回傳結果:
102
	#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
103
	#$result["error"],錯誤訊息陣列.
104
	#$result["function"],當前執行的函數名稱.
105
	#$result["fileInfo"],實際上寫入的檔案資訊陣列.
106
	#$result["fileInfo"]["createdFileName"],建立好的檔案名稱.
107
	#$result["fileInfo"]["createdFilePath"],檔案建立的路徑.
108
	#$result["fileInfo"]["createdFilePathAndName"].建立好的檔案名稱與路徑.
109
	#$result["argu"],使用的參數.
110
	#必填參數:
111
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
112
	$conf["fileArgu"]=__FILE__;
113
	#可省略參數:
114
	#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
115
	#$conf["fileName"]="";
116
	#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
117
	#$conf["inputString"]="";
118
	#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
119
	#$conf["writeMethod"]="a";
120
	#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
121
	#$conf["checkRepeat"]="";
122
	#$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點,必須與$conf["checkRepeat"]搭配才會生效.
123
	#$conf["filenameExtensionStartPoint"]="";
124
	#$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)",必須與$conf["checkRepeat"]搭配才會生效.
125
	#$conf["repeatNameRule"]="";
126
	#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
127
	#$conf["web"]="true";
128
	#參考資料:
129
	#無.
130
	#備註:
131
	#無.
132
	*/
133
	public static function writeTextIntoFile(&$conf){
134
 
135
		#初始化要回傳的變數
136
		$result=array();
137
 
138
		#初始化當前執行的函數名稱
139
		$result["function"]=__FUNCTION__;
140
 
141
		#如果 $conf 不為陣列
142
		if(gettype($conf)!="array"){
143
 
144
			#設置執行失敗
145
			$result["status"]="false";
146
 
147
			#設置執行錯誤訊息
148
			$result["error"][]="\$conf變數須為陣列形態";
149
 
150
			#如果傳入的參數為 null
151
			if($conf==null){
152
 
153
				#設置執行錯誤訊息
154
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
155
 
156
				}#if end
157
 
158
			#回傳結果
159
			return $result;
160
 
161
			}#if end
162
 
163
		#取得使用的參數
164
		$result["argu"]=$conf;
165
 
166
		#檢查參數
167
		#函式說明:
168
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
169
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
170
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
171
		#$result["function"],當前執行的函式名稱.
172
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
173
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
174
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
175
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
176
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
177
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
178
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
179
		#必填寫的參數:
180
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
181
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
182
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
183
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
184
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
185
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
186
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
187
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
188
		#可以省略的參數:
189
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
190
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
191
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
192
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileName","inputString","writeMethod","checkRepeat","filenameExtensionStartPoint","repeatNameRule","web");
193
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
194
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string","string","string","string","string");
195
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
196
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"","w","false",null,null,"true");
197
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
198
		#$conf["arrayCountEqualCheck"][]=array();
199
		#參考資料來源:
200
		#array_keys=>http://php.net/manual/en/function.array-keys.php
201
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
202
		unset($conf["variableCheck::checkArguments"]);
203
 
204
		#如果 $checkArguments["status"] 等於 "false"
205
		if($checkArguments["status"]=="false"){
206
 
207
			#設置錯誤識別
208
			$result["status"]="false";
209
 
210
			#設置錯誤訊息
211
			$result["error"]=$checkArguments;
212
 
213
			#回傳結果
214
			return $result;				
215
 
216
			}#if end
217
 
218
		#如果 $checkArguments["passed"] 等於 "false"
219
		if($checkArguments["passed"]=="false"){
220
 
221
			#設置錯誤識別
222
			$result["status"]="false";
223
 
224
			#設置錯誤訊息
225
			$result["error"]=$checkArguments;
226
 
227
			#回傳結果
228
			return $result;				
229
 
230
			}#if end
231
 
232
		#如果沒有設置 $conf["fileName"]
233
		if(!isset($conf["fileName"])){
234
 
235
			#設定要檢查是否有重複的檔案名稱
236
			$conf["checkRepeat"]="true";
237
 
238
			#亂數產生檔案名稱
239
			#函式說明:
240
			#建立以圖片(PNG格式)呈現的驗證碼.
241
			#回傳的解果:
242
			#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
243
			#$result["error"],錯誤訊息.
244
			#$result["function"],檔前執行的函數名稱.
245
			#$result["randNumberWord"],傳驗證碼的內容.
246
			#$result["imgAddress"],圖片的位置與名稱.
247
			#必填參數:
248
			#$conf["imgAddressAndName"],字串,爲驗證碼圖片儲存的位置與名稱,副檔名程式會自動產生
249
			$conf["authenticate::validationCode"]["imgAddressAndName"]="don't need!";
250
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
251
			$conf["authenticate::validationCode"]["fileArgu"]=$conf["fileArgu"];
252
			#可省略參數:
253
			#$conf["num"],字串,爲驗證碼的位數,請輸入阿拉伯數字,預設為"8"位數.
254
			$conf["authenticate::validationCode"]["num"]="10";
255
			#$conf["disableImg"],字串,是否要取消驗證碼圖片的輸出,"true"為要取消,預設為"false"為不取消
256
			$conf["authenticate::validationCode"]["disableImg"]="true";
257
			#$conf["imgToData"],字串,預設為"true"代表將圖片轉存成base64圖片,並將原始圖片移除;反之為"false"
258
			#$conf["imgToData"]="true";
259
			$validationCode=authenticate::validationCode($conf["authenticate::validationCode"]);
260
			unset($conf["authenticate::validationCode"]);
261
 
262
			#如果亂數產生錯誤
263
			if($validationCode["status"]=="false"){
264
 
265
				#設置錯誤識別
266
				$result["status"]="false";
267
 
268
				#設置錯誤訊息
269
				$result["error"]=$validationCode;
270
 
271
				#回傳結果
272
				return $result;	
273
 
274
				}#if end
275
 
276
			#取得產生的檔案名稱
277
			$conf["fileName"]=$validationCode["randNumberWord"];
278
 
279
			}#if end
280
 
281
		#剃除 $conf["fileName"] 開頭的 "./"
282
		#函式說明:
283
		#移除字串開頭的特定內容
284
		#回傳的接結果:
285
		#$result["status"],寄信的情況,若爲"true",則十之八九沒有問題.
286
		#$result["error"],錯誤訊息陣列.
287
		#$result["function"],當前執行的函數.
288
		#$result["content"],處理好的字串.
289
		#必填參數:
290
		#$conf["inputStr"],字串,要檢查並移除開頭有 $conf["keyWords"] 的字串.
291
		$conf["stringProcess::delKeyWordsInStrHead"]["inputStr"]=$conf["fileName"];
292
		#$conf["keyWord"],字串,要移除的字串開頭關鍵字.
293
		$conf["stringProcess::delKeyWordsInStrHead"]["keyWord"]="./"; 
294
		#可省略參數:
295
		#無.
296
		$delKeyWordsInStrHead=stringProcess::delKeyWordsInStrHead($conf["stringProcess::delKeyWordsInStrHead"]);
297
		unset($conf["stringProcess::delKeyWordsInStrHead"]);
298
 
299
		#如果處理失敗
300
		if($delKeyWordsInStrHead["status"]=="false"){
301
 
302
			#設置錯誤識別
303
			$result["status"]="false";
304
 
305
			#設置錯誤訊息
306
			$result["error"]=$delKeyWordsInStrHead;
307
 
308
			#回傳結果
309
			return $result;	
310
 
311
			}#if end
312
 
313
		#取得處理好的檔案名稱
314
		$conf["fileName"]=$delKeyWordsInStrHead["content"];
315
 
316
		#函式說明:
317
		#確保路徑存在.
318
		#回傳結果:
319
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
320
		#$result["error"],錯誤訊息陣列.
321
		#$resutl["function"],當前執行的涵式名稱.
322
		#必填參數:
323
		#$conf["path"],要檢查的路徑
324
		$conf["fileAccess::validatePath"]["path"]=$conf["fileName"];		
325
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
326
		$conf["fileAccess::validatePath"]["fileArgu"]=$conf["fileArgu"];
327
		#可省略參數:
328
		#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
329
		$conf["fileAccess::validatePath"]["haveFileName"]="true";
330
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
331
		#$conf["dirPermission"]="";
332
		$conf["fileAccess::validatePath"]["web"]=$conf["web"];
333
		$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
334
		unset($conf["fileAccess::validatePath"]);
335
 
336
		#debug
337
		#var_dump($validatePath);exit;
338
 
339
		#如果確保路徑失敗
340
		if($validatePath["status"]=="false"){
341
 
342
			#設置錯誤識別
343
			$result["status"]="false";
344
 
345
			#設置錯誤訊息
346
			$result["error"]=$validatePath;
347
 
348
			#回傳結果
349
			return $result;	
350
 
351
			}#if end
352
 
353
		if($conf["checkRepeat"]=="true"){
354
 
355
			#函式說明:
356
			#檢查要建立的檔案路徑是否存在,若不存在則建立新檔案,若檔案已存在則會在原檔名後面加上從(1)開始的編號,再度嘗試建立檔案,以避免資料異常.
357
			#回傳的結果:
358
			#$result["status"],執行狀態,"true"代表執行正常,"false"代表執行失敗.
359
			#$result["error"],錯誤訊息陣列.
360
			#$result["function"],當前執行的函數名稱.
361
			#$result["createdFileName"],建立好的檔案名稱.
362
			#$result["createdFilePath"],檔案建立的路徑.
363
			#$result["createdFilePathAndName"].建立好的檔案名稱與路徑.
364
			#必填參數:
365
			#$conf["checkedFileAndPath"],字串陣列,要建立的檔案路徑
366
			$conf["fileAccess::createFileAfterCheck"]["checkedFileAndPath"]=$conf["fileName"];
367
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
368
			$conf["fileAccess::createFileAfterCheck"]["fileArgu"]=$conf["fileArgu"];
369
			#可省略參數:
370
 
371
			#如果有設定 $conf["filenameExtensionStartPoint"]
372
			if(isset($conf["filenameExtensionStartPoint"])){
373
 
374
				#$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點.
375
				$conf["fileAccess::createFileAfterCheck"]["filenameExtensionStartPoint"]=$conf["filenameExtensionStartPoint"];
376
 
377
				}#if end
378
 
379
			#如果有設定 $conf["repeatNameRule"]
380
			if(isset($conf["repeatNameRule"])){
381
 
382
				#$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)".
383
				$conf["fileAccess::createFileAfterCheck"]["repeatNameRule"]=$conf["repeatNameRule"];
384
 
385
				}#if end
386
 
387
			#如果有設定 $conf["web"] 參數
388
			if(isset($conf["web"])){
389
 
390
				$conf["fileAccess::createFileAfterCheck"]["web"]=$conf["web"];
391
 
392
				}#if end
393
 
394
			$createFileAfterCheck=fileAccess::createFileAfterCheck($conf["fileAccess::createFileAfterCheck"]);
395
			unset($conf["fileAccess::createFileAfterCheck"]);
396
 
397
			#debug
398
			#var_dump($createFileAfterCheck);
399
			#exit;
400
 
401
			#如果嘗試建立檔案失敗
402
			if($createFileAfterCheck["status"]=="false"){
403
 
404
				#設置執行不正常
405
				$result["status"]="false";
406
 
407
				#設置錯誤訊息
408
				$result["error"]=$createFileAfterCheck;
409
 
410
				#回傳結果
411
				return $result;
412
 
413
				}#if end
414
 
415
			#取得建立的檔案資訊
416
			$result["fileInfo"]["createdFilePathAndName"]=$createFileAfterCheck["createdFilePathAndName"];
417
			$result["fileInfo"]["createdFilePath"]=$createFileAfterCheck["createdFilePath"];
418
			$result["fileInfo"]["createdFileName"]=$createFileAfterCheck["createdFileName"];	
419
 
420
			#取得建立好的檔案路徑與名稱
421
			$conf["fileName"]=$createFileAfterCheck["createdFilePathAndName"];
422
 
423
			}#if end			
424
 
425
		#反之沒有要檢查檔案是否存在
426
		else{
427
 
428
			#取得建立的檔案資訊
429
			$result["fileInfo"]["createdFilePathAndName"]=$conf["fileName"];
430
			$result["fileInfo"]["createdFilePath"]=$validatePath["path"];
431
			$result["fileInfo"]["createdFileName"]=$validatePath["fileName"];	
432
 
433
			}#else end
434
 
435
		#設定要寫入或複寫的檔案
436
		$fileopenResult=fopen($conf["fileName"],$conf["writeMethod"]);
437
 
438
		#如果 $fileopenResult 等於 FALSE
439
		if($fileopenResult==FALSE){
440
 
441
			#設置錯誤識別
442
			$result["status"]="false";
443
 
444
			#代表打開檔案失敗
445
			$result["error"][]="檔案".$conf["fileName"]."開啟失敗";
446
 
447
			#回傳結果
448
			return $result;
449
 
450
			}#if end
451
 
452
		#將資料寫入到檔案裡面
453
		$fwriteResult=fwrite($fileopenResult,$conf["inputString"]);
454
 
455
		#如果 $fwriteResult 等於 FALSE
456
		if($fwriteResult!=0 && $fwriteResult==FALSE){
457
 
458
			#設置錯誤識別
459
			$result["status"]="false";
460
 
461
			#代表檔案寫入失敗
462
			$result["error"][]="檔案".$conf["fileName"]."寫入失敗";
463
 
464
			#回傳結果
465
			return $result;
466
 
467
			}#if end
468
 
469
		#存檔並關閉檔案
470
		$fcloseResult=fclose($fileopenResult);
471
 
472
		#如果 $fcloseResult 等於 FALSE
473
		if($fcloseResult==FALSE){
474
 
475
			#設置錯誤識別
476
			$result["status"]="false";
477
 
478
			#代表檔案寫入失敗
479
			$result["error"][]="檔案".$conf["fileName"]."儲存失敗";
480
 
481
			#回傳結果
482
			return $result;
483
 
484
			}#if end
485
 
486
		#檢查用來寫入的檔案是否存在
487
		#函式說明:檢查多個檔案與資料夾是否存在
488
		#回傳的結果:
489
		#$result["varName"][$i],爲第$i個變數的名稱。
490
		#$result["varExist"][$i],爲第$i個變數是否存在,true代表存在,false代表不存在。
491
		#必填參數:
492
		$conf["fileAccess::checkMutiFileExist"]["fileArray"]=array($conf["fileName"]);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
493
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
494
		$conf["fileAccess::checkMutiFileExist"]["fileArgu"]=$conf["fileArgu"];
495
		#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false".
496
		$conf["fileAccess::checkMutiFileExist"]["web"]=$conf["web"];
497
		#參考資料來源:
498
		#http:#php.net/manual/en/function.file-exists.php
499
		#http:#php.net/manual/en/control-structures.foreach.php
500
		$fileAccess["checkMutiFileExist"]=fileAccess::checkMultiFileExist($conf["fileAccess::checkMutiFileExist"]);
501
		unset($conf["fileAccess::checkMutiFileExist"]);
502
 
503
		#如果檢查檔案是否存在失敗
504
		if($fileAccess["checkMutiFileExist"]["status"]==="false"){
505
 
506
			#設置錯誤識別
507
			$result["status"]="false";
508
 
509
			#設置錯誤訊息陣列
510
			$result["error"]=$fileAccess["checkMutiFileExist"];
511
 
512
			#回傳結果
513
			return $result;
514
 
515
			}#if end
516
 
517
		#如果$fileAccess["checkMutiFileExist"]["varExist"][0] 等於 "false" 
518
		if($fileAccess["checkMutiFileExist"]["varExist"][0]==="false"){
519
 
520
			#設置錯誤識別
521
			$result["status"]="false";
522
 
523
			#設置錯誤訊息
524
			$result["error"]=$fileAccess["checkMutiFileExist"];
525
 
526
			#設置錯誤訊息陣列
527
			$result["error"][]="愈建立的檔案不存在";
528
 
529
			#回傳結果
530
			return $result;
531
 
532
			}#if end
533
 
534
		#函式說明:
535
		#依據取得檔案的擁有着資訊
536
		#回傳結果:
537
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
538
		#$result["error"],錯誤訊息陣列.
539
		#$result["function"],函數名稱. 
540
		#$result["content"],檔案擁有着資訊.
541
		#$result["content"],檔案資訊陣列.
542
		#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
543
		#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
544
		#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
545
		#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
546
		#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
547
		#$result["content"]["ownerName"],檔案擁有着資訊.
548
		#$result["content"]["groupName"],檔案所屬擁有着資訊.
549
		#$result["content"]["size"],檔案大小.
550
		#$result["content"]["modifyDate"],檔案變更年月日.
551
		#$result["content"]["modifyTime"],檔案變更時分秒.
552
		#$result["content"]["modifyTimeFloat"],檔案變更時間秒的float數值.
553
		#$result["content"]["timezone"],檔案變更時間的時區與UTC的差距.
554
		#必填參數:
555
		#$conf["fileArgu"],字串,當前檔案的位置亦即__FILE__的內容.
556
		$conf["fileAccess::fileInfo"]["fileArgu"]=$conf["fileArgu"];
557
		#$conf["file"],字串,要查看擁有者資訊的檔案.
558
		$conf["fileAccess::fileInfo"]["file"]=$conf["fileName"];
559
		#可省略參數:
560
		#$conf["fileToRead"],字串,要讀取的檔案名稱為何?預設為"help".
561
		#$conf["fileToRead"]="help";
562
		#$conf["output"],字串,輸出的網頁檔案位置與名稱,副檔名html會自動補上,預設為"help".
563
		#$conf["output"]="help.html"; 
564
		#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false".
565
		$conf["fileAccess::fileInfo"]["web"]=$conf["web"];
566
		#參考資料:
567
		#fileowner=>http://php.net/manual/en/function.fileowner.php
568
		#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
569
		$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
570
		unset($conf["fileAccess::fileInfo"]);
571
 
572
		#如果取得檔案資訊失敗
573
		if($fileInfo["status"]==="false"){
574
 
575
			#設置執行失敗
576
			$result["status"]="false";
577
 
578
			#設置錯誤訊息
579
			$result["error"]=$fileInfo;
580
 
581
			#回傳結果
582
			return $result;
583
 
584
			}#if end	
585
 
586
		#取得檔案的擁有者名稱
587
		$fileOwner=$fileInfo["content"]["ownerName"];
588
 
589
		#執行php的帳戶
590
		$runner=csInformation::runner();	
591
 
592
		#如果執行php的使用者等於檔案的擁有者名稱或為root
593
		if($runner===$fileOwner || $runner==="root"){
594
 
595
			#改變檔案的權限為0770
596
			chmod($conf["fileName"],0770);
597
 
598
			}#if end
599
 
600
		#執行到這邊代表執行正常
601
		$result["status"]="true";
602
 
603
		#回傳結果
604
		return $result;
605
 
606
		}#function writeTextIntoFile end
607
 
608
	/*
609
	#函式說明:
610
	#一次建立多個檔案,並寫入內容.
611
	#回傳結果:
612
	#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
613
	#$result["error"],錯誤訊息陣列.
614
	#$result["function"],當前執行的函數名稱.
615
	#$result["content"][i],實際上寫入的第$i+1個檔案資訊陣列.
616
	#$result["content"][i]["createdFileName"],第$i+1個建立好的檔案名稱.
617
	#$result["content"][i]["createdFilePath"],第$i+1個檔案建立的路徑.
618
	#$result["content"][i]["createdFilePathAndName"].第$i+1個建立好的檔案名稱與路徑.
619
	#$result["argu"],使用的參數.
620
	#必填參數:
621
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
622
	$conf["fileArgu"]=__FILE__;
623
	#$conf["fileName"],字串陣列,爲要寫入的多個檔案名稱
624
	$conf["fileName"]=array("");
625
	#可省略參數:
626
	#$conf["inputString"],字串陣列,爲要寫入到各別檔案裏面的內容,預設每個元素為空字串.
627
	#$conf["inputString"]=array("");
628
	#參考資料:
629
	#無.
630
	#備註:
631
	#無.
632
	*/
633
	public static function writeMultiFile(&$conf){
634
 
635
		#初始化要回傳的變數
636
		$result=array();
637
 
638
		#初始化當前執行的函數名稱
639
		$result["function"]=__FUNCTION__;
640
 
641
		#如果 $conf 不為陣列
642
		if(gettype($conf)!="array"){
643
 
644
			#設置執行失敗
645
			$result["status"]="false";
646
 
647
			#設置執行錯誤訊息
648
			$result["error"][]="\$conf變數須為陣列形態";
649
 
650
			#如果傳入的參數為 null
651
			if($conf==null){
652
 
653
				#設置執行錯誤訊息
654
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
655
 
656
				}#if end
657
 
658
			#回傳結果
659
			return $result;
660
 
661
			}#if end
662
 
663
		#取得使用的參數
664
		$result["argu"]=$conf;
665
 
666
		#檢查參數
667
		#函式說明:
668
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
669
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
670
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
671
		#$result["function"],當前執行的函式名稱.
672
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
673
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
674
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
675
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
676
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
677
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
678
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
679
		#必填寫的參數:
680
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
681
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
682
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
683
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileName");
684
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
685
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");
686
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
687
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
688
		#可以省略的參數:
689
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
690
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
691
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
692
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("inputString");
693
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
694
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
695
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
696
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
697
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
698
		$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("fileName","inputString");
699
		#參考資料來源:
700
		#array_keys=>http://php.net/manual/en/function.array-keys.php
701
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
702
		unset($conf["variableCheck::checkArguments"]);
703
 
704
		#如果 $checkArguments["status"] 等於 "false"
705
		if($checkArguments["status"]=="false"){
706
 
707
			#設置錯誤識別
708
			$result["status"]="false";
709
 
710
			#設置錯誤訊息
711
			$result["error"]=$checkArguments;
712
 
713
			#回傳結果
714
			return $result;				
715
 
716
			}#if end
717
 
718
		#如果 $checkArguments["passed"] 等於 "false"
719
		if($checkArguments["passed"]=="false"){
720
 
721
			#設置錯誤識別
722
			$result["status"]="false";
723
 
724
			#設置錯誤訊息
725
			$result["error"]=$checkArguments;
726
 
727
			#回傳結果
728
			return $result;				
729
 
730
			}#if end
731
 
732
		#如果沒有設定要個別寫入的內容
733
		if(!isset($conf["inputString"])){
734
 
735
			#針對每個檔案名稱
736
			for($i=0;$i<count($conf["fileName"]);$i++){
737
 
738
				#建立空的 $conf["inputString"]
739
				$conf["inputString"][$i]="";
740
 
741
				}#for end
742
 
743
			}#if end
744
 
745
		#針對每個要寫入的檔案
746
		foreach($conf["fileName"] as $index => $file2writre){
747
 
748
			#取得要寫入的內容
749
			$content2writre=$conf["inputString"][$index];
750
 
751
			#函式說明:
752
			#將字串寫入到檔案
753
			#回傳結果:
754
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
755
			#$result["error"],錯誤訊息陣列.
756
			#$result["function"],當前執行的函數名稱.
757
			#$result["fileInfo"],實際上寫入的檔案資訊陣列.
758
			#$result["fileInfo"]["createdFileName"],建立好的檔案名稱.
759
			#$result["fileInfo"]["createdFilePath"],檔案建立的路徑.
760
			#$result["fileInfo"]["createdFilePathAndName"].建立好的檔案名稱與路徑.
761
			#$result["argu"],使用的參數.
762
			#必填參數:
763
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
764
			$conf["fileAccess::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
765
			#可省略參數:
766
			#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
767
			$conf["fileAccess::writeTextIntoFile"]["fileName"]=$file2writre;
768
			#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
769
			$conf["fileAccess::writeTextIntoFile"]["inputString"]=$content2writre;
770
			#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
771
			#$conf["writeMethod"]="a";
772
			#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
773
			#$conf["checkRepeat"]="";
774
			#$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點,必須與$conf["checkRepeat"]搭配才會生效.
775
			#$conf["filenameExtensionStartPoint"]="";
776
			#$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)",必須與$conf["checkRepeat"]搭配才會生效.
777
			#$conf["repeatNameRule"]="";
778
			#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
779
			$conf["fileAccess::writeTextIntoFile"]["web"]="false";
780
			#備註:
781
			#無.
782
			$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
783
			unset($conf["fileAccess::writeTextIntoFile"]);
784
 
785
			#如果建立檔案失敗
786
			if($writeTextIntoFile["status"]==="false"){
787
 
788
				#設置錯誤識別
789
				$result["status"]="false";
790
 
791
				#設置錯誤訊息
792
				$result["error"]=$writeTextIntoFile;
793
 
794
				#回傳結果
795
				return $result;		
796
 
797
				}#if end
798
 
799
			#設置建立好的檔案資訊
800
			$result["content"][]=$writeTextIntoFile["fileInfo"];	
801
 
802
			}#foreach end
803
 
804
			#設置執行正常
805
			$result["status"]="true";
806
 
807
			#回傳結果
808
			return $result;	
809
 
810
		}#function writeMultiFile end
811
 
812
	/*
813
	#函式說明:
814
	#將多行字串寫入到檔案
815
	#回傳結果:
816
	#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
817
	#$result["error"],錯誤訊息陣列.
818
	#$result["function"],當前執行函數的名稱.
819
	#必填參數:
820
	#$conf["fileName"],字串,爲要編輯的檔案名稱
821
	$conf["fileName"]="";
822
	#$conf["inputString"],字串陣列,爲要寫入到 $conf["fileName"] 裏面的內容. $conf["inputString"][$i] 代表第 $i+1 行。
823
	$conf["inputString"]=array("");
824
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
825
	$conf["fileArgu"]=__FILE__;
826
	#可省略參數:
827
	#$conf["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
828
	#參考資料:
829
	#無.
830
	#備註:
831
	#無.
832
	*/
833
	public static function writeMultiLine(&$conf){
834
 
835
		#初始化要回傳的結果
836
		$result=array();
837
 
838
		#取得當前執行的函數
839
		$result["function"]=__FUNCTION__;
840
 
841
		#如果 $conf 不為陣列
842
		if(gettype($conf)!="array"){
843
 
844
			#設置執行失敗
845
			$result["status"]="false";
846
 
847
			#設置執行錯誤訊息
848
			$result["error"][]="\$conf變數須為陣列形態";
849
 
850
			#如果傳入的參數為 null
851
			if($conf==null){
852
 
853
				#設置執行錯誤訊息
854
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
855
 
856
				}#if end
857
 
858
			#回傳結果
859
			return $result;
860
 
861
			}#if end
862
 
863
		#檢查必填參數
864
		#函式說明:
865
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
866
		#回傳的結果:
867
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
868
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
869
		#$result["function"],當前執行的函式名稱.
870
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
871
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
872
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
873
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
874
		#必填寫的參數:
875
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
876
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("fileName","inputString","fileArgu");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
877
		#可以省略的參數:
878
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string","array","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
879
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
880
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
881
		unset($conf["variableCheck.isexistMulti"]);
882
 
883
		#如果檢查失敗
884
		if($checkResult["status"]=="false"){
885
 
886
			#設置執行錯誤
887
			$result["status"]="false";
888
 
889
			#設置執行錯誤訊息
890
			$result["error"]=$checkResult;
891
 
892
			#回傳結果
893
			return $result;
894
 
895
			}#if end
896
 
897
		#如果檢查不通過
898
		if($checkResult["passed"]=="false"){
899
 
900
			#設置執行錯誤
901
			$result["status"]="false";
902
 
903
			#設置執行錯誤訊息
904
			$result["error"]=$checkResult;
905
 
906
			#回傳結果
907
			return $result;
908
 
909
			}#if end
910
 
911
		#檢查可省略參數 
912
		#函式說明:
913
		#檢查一包含數個可省略變數的陣列變數,其型態是否正確,省略掉的陣列變數可以直接給定預設值。
914
		#回傳結果:
915
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
916
		#$result["error"],錯誤訊息陣列.
917
		#$result["function"],當前執行的函式名稱.
918
		#$result["passed"],參數是否都通過檢查,"true",代表有通過檢查,"false"代表沒有通過檢查。
919
		#必填參數:
920
		#$conf["variableCheck.checkSkipableVarType"]["checkedVar"],陣列,要檢查的變數陣列名稱為?
921
		$conf["variableCheck.checkSkipableVarType"]["checkedVar"]=$conf;
922
		#$conf["variableCheck.checkSkipableVarType"]["sikpableVarNameArray"],字串陣列,要檢查型態是否設定正確的變數名稱陣列.
923
		$conf["variableCheck.checkSkipableVarType"]["sikpableVarNameArray"]=array("writeMethod");
924
		#$conf["variableCheck.checkSkipableVarType"]["skipableVarTypeArray"],字串陣列,要檢查的每個變數,其型態應該要為何?
925
		$conf["variableCheck.checkSkipableVarType"]["skipableVarTypeArray"]=array("string");
926
		#$argu,要直接存取的陣列變數名稱,變數前面加上「&」,如果要在別的函式裡面使用本函式,請記得將變動過結果($argu)給使用該函式的設定變數(通常是$conf=$argu).
927
		$argu=&$conf;
928
		#可省略參數:
929
		#$conf["variableCheck.checkSkipableVarType"]["skipableVarDefaultValue"],字串陣列,每個不存的變數要初始化為什麼,"null"代表不指定.
930
		$conf["variableCheck.checkSkipableVarType"]["skipableVarDefaultValue"]=array("w");
931
		#無
932
		$checkResult=variableCheck::checkSkipableVarType($conf["variableCheck.checkSkipableVarType"],$argu);
933
		unset($conf["variableCheck.checkSkipableVarType"]);
934
 
935
		#如果檢查不通過
936
		if($checkResult["status"]=="false"){
937
 
938
			#設置執行錯誤
939
			$result["status"]="false";
940
 
941
			#設置執行錯誤訊息
942
			$result["error"]=$checkResult;
943
 
944
			#回傳結果
945
			return $result;
946
 
947
			}#if end
948
 
949
		#如果檢查不通過
950
		if($checkResult["passed"]=="false"){
951
 
952
			#設置執行錯誤
953
			$result["status"]="false";
954
 
955
			#設置執行錯誤訊息
956
			$result["error"]=$checkResult;
957
 
958
			#回傳結果
959
			return $result;
960
 
961
			}#if end
962
 
963
		#初始化第一次寫入識別變數
964
		$firstTimeToWrite="true";
965
 
966
		#有幾行字要寫就執行幾次
967
		foreach($conf["inputString"] as $inputStr){
968
 
969
			#附加 "\r\n"
970
			$inputStr=$inputStr.PHP_EOL;
971
 
972
			#如果是第一次寫入
973
			if($firstTimeToWrite=="true"){
974
 
975
				#如果是要重新寫入
976
				if($conf["writeMethod"]=="w"){
977
 
978
					#函式說明:
979
					#將字串寫入到檔案
980
					#回傳結果:
981
					#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
982
					#$result["error"],錯誤訊息陣列.
983
					#必填參數:
984
					$conf["fileAccess.writeTextIntoFile"]["fileName"]=$conf["fileName"];#爲要編輯的檔案名稱
985
					$conf["fileAccess.writeTextIntoFile"]["inputString"]=$inputStr;#爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可。
986
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
987
					$conf["fileAccess.writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
988
					#可省略參數:
989
					$conf["fileAccess.writeTextIntoFile"]["writeMethod"]="w";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
990
					#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
991
					$conf["fileAccess.writeTextIntoFile"]["web"]="false";
992
					$writeStatus=fileAccess::writeTextIntoFile($conf["fileAccess.writeTextIntoFile"]);
993
					unset($conf["fileAccess.writeTextIntoFile"]);
994
 
995
					#如果寫入失敗
996
					if($writeStatus["status"]=="false"){
997
 
998
						#設置執行錯誤
999
						$result["status"]="false";
1000
 
1001
						#設置執行錯誤訊息
1002
						$result["error"]=$writeStatus;
1003
 
1004
						#回傳結果
1005
						return $result;
1006
 
1007
						}#if end
1008
 
1009
					}#if end
1010
 
1011
				#反之不是重新寫入,而是附加寫入。
1012
				else{
1013
 
1014
					#函式說明:
1015
					#將字串寫入到檔案
1016
					#回傳結果:
1017
					#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1018
					#$result["error"],錯誤訊息陣列.
1019
					#必填參數:
1020
					$conf["fileAccess.writeTextIntoFile"]["fileName"]=$conf["fileName"];#爲要編輯的檔案名稱
1021
					$conf["fileAccess.writeTextIntoFile"]["inputString"]=$inputStr;#爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可。
1022
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1023
					$conf["fileAccess.writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
1024
					#可省略參數:
1025
					$conf["fileAccess.writeTextIntoFile"]["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1026
					#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1027
					$conf["fileAccess.writeTextIntoFile"]["web"]="false";
1028
					$writeStatus=fileAccess::writeTextIntoFile($conf["fileAccess.writeTextIntoFile"]);
1029
					unset($conf["fileAccess.writeTextIntoFile"]);
1030
 
1031
					#如果寫入失敗
1032
					if($writeStatus["status"]=="false"){
1033
 
1034
						#設置執行錯誤
1035
						$result["status"]="false";
1036
 
1037
						#設置執行錯誤訊息
1038
						$result["error"]=$writeStatus;
1039
 
1040
						#回傳結果
1041
						return $result;
1042
 
1043
						}#if end
1044
 
1045
					}#else end
1046
 
1047
				#將之設為不是第一次寫入
1048
				$firstTimeToWrite="false";
1049
 
1050
				}#if end
1051
 
1052
			#反之不是第一次寫入
1053
			else{
1054
 
1055
				#函式說明:
1056
				#將字串寫入到檔案
1057
				#回傳結果:
1058
				#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1059
				#$result["error"],錯誤訊息陣列.
1060
				#必填參數:
1061
				$conf["fileAccess.writeTextIntoFile"]["fileName"]=$conf["fileName"];#爲要編輯的檔案名稱
1062
				$conf["fileAccess.writeTextIntoFile"]["inputString"]=$inputStr;#爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可。
1063
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1064
				$conf["fileAccess.writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
1065
				#可省略參數:
1066
				$conf["fileAccess.writeTextIntoFile"]["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
1067
				#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1068
				$conf["fileAccess.writeTextIntoFile"]["web"]="false";
1069
				$writeStatus=fileAccess::writeTextIntoFile($conf["fileAccess.writeTextIntoFile"]);
1070
				unset($conf["fileAccess.writeTextIntoFile"]);
1071
 
1072
				#如果寫入失敗
1073
				if($writeStatus["status"]=="false"){
1074
 
1075
					#設置執行錯誤
1076
					$result["status"]="false";
1077
 
1078
					#設置執行錯誤訊息
1079
					$result["error"]=$writeStatus;
1080
 
1081
					#回傳結果
1082
					return $result;
1083
 
1084
					}#if end
1085
 
1086
				}#else end
1087
 
1088
			}#foreach end
1089
 
1090
		#執行到這邊代表一切正常
1091
		$result["status"]="true";
1092
 
1093
		#回傳結果
1094
		return $result;
1095
 
1096
		}#function writeMultiLine end
1097
 
1098
	/*
1099
	#函式說明:
1100
	#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
1101
	#回傳的變數說明:
1102
	#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
1103
	#$result["error"],錯誤訊息提示.
1104
	#$result["warning"],警告訊息.
1105
	#$result["function"],當前執行的函數名稱.
1106
	#$result["fileContent"],爲檔案的內容陣列.
1107
	#$result["lineCount"],爲檔案內容總共的行數.
1108
	#$result["fullContent"],為檔案的完整內容.
1109
	#$result["base64data"],為檔案的base64內容.
1110
	#$result["mimeType"],為檔案的mime type.
1111
	#必填參數:
1112
	#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
1113
	$conf["filePositionAndName"]="";
1114
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1115
	$conf["fileArgu"]=__FILE__;
1116
	#可省略參數:
1117
	#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
1118
	#$conf["web"]="true";
1119
	#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
1120
	#$conf["createIfnotExist"]="false";
1121
	#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
1122
	#$conf["autoDeleteSpaceOnEachLineStart"]="false";
1123
	#參考資料:
1124
	#file(),取得檔案內容的行數.
1125
	#file=>http:#php.net/manual/en/function.file.php
1126
	#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
1127
	#filesize=>http://php.net/manual/en/function.filesize.php
1128
	#參考資料:
1129
	#無.
1130
	#備註:
1131
	#無.
1132
	*/
1133
	public static function getFileContent($conf){
1134
 
1135
		#初始化要回傳的內容
1136
		$result=array();
1137
 
1138
		#取得當前執行函數名稱
1139
		$result["function"]=__FUNCTION__;
1140
 
1141
		#如果 $conf 不為陣列
1142
		if(gettype($conf)!="array"){
1143
 
1144
			#設置執行失敗
1145
			$result["status"]="false";
1146
 
1147
			#設置執行錯誤訊息
1148
			$result["error"][]="\$conf變數須為陣列形態";
1149
 
1150
			#如果傳入的參數為 null
1151
			if($conf==null){
1152
 
1153
				#設置執行錯誤訊息
1154
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1155
 
1156
				}#if end
1157
 
1158
			#回傳結果
1159
			return $result;
1160
 
1161
			}#if end
1162
 
1163
		#檢查參數
1164
		#函式說明:
1165
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
1166
		#回傳結果:
1167
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1168
		#$result["error"],執行不正常結束的錯訊息陣列.
1169
		#$result["simpleError"],簡單表示的錯誤訊息.
1170
		#$result["function"],當前執行的函式名稱.
1171
		#$result["argu"],設置給予的參數.
1172
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
1173
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
1174
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
1175
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
1176
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
1177
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
1178
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
1179
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
1180
		#必填參數:
1181
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
1182
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
1183
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
1184
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
1185
		#可省略參數:
1186
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
1187
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("filePositionAndName","fileArgu");
1188
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
1189
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
1190
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
1191
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1192
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
1193
		#$conf["canNotBeEmpty"]=array();
1194
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
1195
		#$conf["canBeEmpty"]=array();
1196
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
1197
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("createIfnotExist","web","autoDeleteSpaceOnEachLineStart");
1198
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1199
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("createIfnotExist","web","autoDeleteSpaceOnEachLineStart");
1200
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
1201
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
1202
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1203
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","false","false");
1204
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
1205
		#$conf["disallowAllSkipableVarIsEmpty"]="";
1206
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
1207
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
1208
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
1209
		#$conf["disallowAllSkipableVarNotExist"]="";
1210
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1211
		#$conf["arrayCountEqualCheck"][]=array();
1212
		#參考資料:
1213
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1214
		#備註:
1215
		#無.
1216
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1217
		unset($conf["variableCheck::checkArguments"]);
1218
 
1219
		#如果檢查出錯
1220
		if($checkArguments["status"]==="false"){
1221
 
1222
			#設置執行錯誤識別
1223
			$result["status"]="false";
1224
 
1225
			#設置執行錯誤訊息
1226
			$result["error"]=$checkArguments;
1227
 
1228
			#回傳結果
1229
			return $result;
1230
 
1231
			}#if end
1232
 
1233
		#如果檢查參數不通過
1234
		if($checkArguments["passed"]==="false"){
1235
 
1236
			#設置執行錯誤識別
1237
			$result["status"]="false";
1238
 
1239
			#設置執行錯誤訊息
1240
			$result["error"]=$checkArguments;
1241
 
1242
			#回傳結果
1243
			return $result;
1244
 
1245
			}#if end
1246
 
1247
		#檢查檔案是否存在
1248
		#函式說明:檢查多個檔案與資料夾是否存在
1249
		#回傳的結果:
1250
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
1251
		#$result["error"],錯誤訊息陣列.
1252
		#$resutl["function"],當前執行的涵式名稱.
1253
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
1254
		#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
1255
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
1256
		#必填參數:
1257
		$conf["fileAccess"]["checkMutiFileExist"]["fileArray"]=array($conf["filePositionAndName"]);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
1258
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1259
		$conf["fileAccess"]["checkMutiFileExist"]["fileArgu"]=$conf["fileArgu"];
1260
		#可省略參數:
1261
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
1262
		$conf["fileAccess"]["checkMutiFileExist"]["disableWebSearch"]="true";
1263
 
1264
		#如果有設置 $conf["web"]
1265
		if(isset($conf["web"])){
1266
 
1267
			#設置 web 參數.
1268
			$conf["fileAccess"]["checkMutiFileExist"]["web"]=$conf["web"];
1269
 
1270
			}#if end
1271
 
1272
		#參考資料來源:
1273
		#http:#php.net/manual/en/function.file-exists.php
1274
		#http:#php.net/manual/en/control-structures.foreach.php
1275
		$fileCheckResult=fileAccess::checkMultiFileExist($conf["fileAccess"]["checkMutiFileExist"]);
1276
		unset($conf["fileAccess"]["checkMutiFileExist"]);
1277
 
1278
		#如果檢查檔案是否存在出錯
1279
		if($fileCheckResult["status"]=="false"){
1280
 
1281
			#設置執行錯誤識別
1282
			$result["status"]="false";
1283
 
1284
			#設置執行錯誤訊息
1285
			$result["error"]=$fileCheckResult;
1286
 
1287
			#回傳結果
1288
			return $result;
1289
 
1290
			}#if end
1291
 
1292
		#如果該檔案不存在
1293
		if($fileCheckResult["varExist"][0]=="false"){
1294
 
1295
			#如果也不要自動建立檔案
1296
			if($conf["createIfnotExist"]==="false"){
1297
 
1298
				#設置執行錯誤識別
1299
				$result["status"]="false";
1300
 
1301
				#設置執行錯誤訊息
1302
				$result["error"]=$fileCheckResult;
1303
 
1304
				#設置易讀的錯誤訊息
1305
				$result["error"][]="名為".$fileCheckResult["varName"][0]."的檔案不存在";
1306
 
1307
				#回傳結果
1308
				return $result;
1309
 
1310
				}#if end
1311
 
1312
			#執行到這邊代表需要建立該檔案
1313
			#函式說明:
1314
			#將字串寫入到檔案
1315
			#回傳結果:
1316
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1317
			#$result["error"],錯誤訊息陣列.
1318
			#$result["function"],當前執行的函數名稱.
1319
			#$result["fileInfo"],實際上寫入的檔案資訊陣列.
1320
			#$result["fileInfo"]["createdFileName"],建立好的檔案名稱.
1321
			#$result["fileInfo"]["createdFilePath"],檔案建立的路徑.
1322
			#$result["fileInfo"]["createdFilePathAndName"].建立好的檔案名稱與路徑.
1323
			#$result["argu"],使用的參數.
1324
			#必填參數:
1325
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1326
			$conf["fileAccess::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
1327
			#可省略參數:
1328
			#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
1329
			$conf["fileAccess::writeTextIntoFile"]["fileName"]=$fileCheckResult["varNameFullPath"][0];
1330
			#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
1331
			$conf["fileAccess::writeTextIntoFile"]["inputString"]="";			
1332
			#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
1333
			#$conf["checkRepeat"]="";
1334
			#$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點,必須與$conf["checkRepeat"]搭配才會生效.
1335
			#$conf["filenameExtensionStartPoint"]="";
1336
			#$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)",必須與$conf["checkRepeat"]搭配才會生效.
1337
			#$conf["repeatNameRule"]="";
1338
 
1339
			#如果有設置 $conf["web"]
1340
			if(isset($conf["web"])){
1341
 
1342
				#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1343
				$conf["fileAccess::writeTextIntoFile"]["web"]=$conf["web"];
1344
 
1345
				}#if end			
1346
 
1347
			#參考資料:
1348
			#無.
1349
			#備註:
1350
			#無.
1351
			$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
1352
			unset($conf["fileAccess::writeTextIntoFile"]);
1353
 
1354
			#如果建立檔案失敗
1355
			if($writeTextIntoFile["status"]=="false"){
1356
 
1357
				#設置執行錯誤識別
1358
				$result["status"]="false";
1359
 
1360
				#設置執行錯誤訊息
1361
				$result["error"]=$writeTextIntoFile;
1362
 
1363
				#回傳結果
1364
				return $result;
1365
 
1366
				}#if end
1367
 
1368
			}#if end
1369
 
1370
		#file absolute addr
1371
		$fileAbAddr=$fileCheckResult["varNameFullPath"][0];
1372
 
1373
		#將檔案的內容放進變數裡面(會得到陣列)
1374
		$fileContent=file($fileAbAddr);
1375
 
1376
		#如果 $fileContent 等於
1377
		if($fileContent==FALSE){
1378
 
1379
			#如果檔案大小為0bytes
1380
			if(filesize($fileAbAddr)==0){
1381
 
1382
				#設置錯誤識別
1383
				$result["warning"][]="執行結果沒有輸出內容";
1384
 
1385
				}#if end
1386
 
1387
			#反之檔案有內容
1388
			else{
1389
 
1390
				#設置錯誤識別
1391
				$result["status"]="false";
1392
 
1393
				#設置錯誤訊息
1394
				$result["error"][]="讀取檔案失敗";
1395
 
1396
				#回傳結果
1397
				return $result;
1398
 
1399
				}#else end
1400
 
1401
			}#if end
1402
 
1403
		#針對每行內容
1404
		for($i=0;$i<count($fileContent);$i++){
1405
 
1406
			#剔除字串尾的換行符號
1407
			$fileContent[$i]=rtrim($fileContent[$i]);
1408
 
1409
			#如果要移除開頭的空白
1410
			if($conf["autoDeleteSpaceOnEachLineStart"]==="true"){
1411
 
1412
				#如果開頭是空格
1413
				while(strpos($fileContent[$i]," ")===0){
1414
 
1415
					#函式說明:
1416
					#將字串特定關鍵字與其前面的內容剔除
1417
					#回傳結果:
1418
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1419
					#$result["error"],錯誤訊息陣列.
1420
					#$result["warning"],警告訊息鎮列.
1421
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
1422
					#$result["function"],當前執行的函數名稱.
1423
					#$result["argu"],使用的參數.
1424
					#$result["oriStr"],要處理的原始字串內容.
1425
					#$result["content"],處理好的的字串內容.	
1426
					#必填參數:
1427
					#$conf["stringIn"],字串,要處理的字串.
1428
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$fileContent[$i];
1429
					#$conf["keyWord"],字串,特定字串.
1430
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
1431
					#可省略參數:
1432
					#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
1433
					#$conf["stringProcess::delStrBeforeKeyWord"]["recursive"]="true";
1434
					#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
1435
					#$conf["lastResult"]=$delStrBeforeKeyWord;
1436
					#參考資料:
1437
					#無.
1438
					#備註:
1439
					#無.
1440
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
1441
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
1442
 
1443
					#如果建立檔案失敗
1444
					if($delStrBeforeKeyWord["status"]=="false"){
1445
 
1446
						#設置執行錯誤識別
1447
						$result["status"]="false";
1448
 
1449
						#設置執行錯誤訊息
1450
						$result["error"]=$delStrBeforeKeyWord;
1451
 
1452
						#回傳結果
1453
						return $result;
1454
 
1455
						}#if end
1456
 
1457
					#取得剔除開頭空格後的內容
1458
					$fileContent[$i]=$delStrBeforeKeyWord["content"];
1459
 
1460
					}#while end
1461
 
1462
				}#if end
1463
 
1464
			}#for end
1465
 
1466
		#取得總共有幾行
1467
		$lineCount=count($fileContent);
1468
 
1469
		#將檔案內容的陣列放進 $result 陣列變數裏面
1470
		$result["fileContent"]=$fileContent;
1471
 
1472
		#建立暫存檔案
1473
		$tmpFile=tempnam("/tmp", "qbpwcf");
1474
 
1475
		#讀取要取得的檔案內容
1476
		$content=file_get_contents($fileAbAddr);
1477
 
1478
		#debug
1479
		#var_dump(__FILE__,__LINE__,$content);
1480
 
1481
		#開啟暫存檔案(寫入模式)
1482
		$file=fopen($tmpFile,'w');
1483
 
1484
		#寫入讀取到的內容
1485
		fwrite($file,$content);
1486
 
1487
		#關閉暫存檔案
1488
		fclose($file);
1489
 
1490
		#取得檔案的 mime 類型
1491
		$mimeType=mime_content_type($tmpFile);
1492
 
1493
		#設置檔案的mime類型
1494
		$result["mimeType"]=$mimeType;
1495
 
1496
		#取得檔案的內容為字串
1497
		$result["fullContent"]=file_get_contents($tmpFile);
1498
 
1499
		#debug
1500
		#var_dump(__FILE__,__LINE__,$result["fullContent"]);
1501
 
1502
		#取得檔案的base64data
1503
		$result["base64data"]="data:".$result["mimeType"].";base64,".base64_encode($result["fullContent"]);
1504
 
1505
		#移除暫存檔案
1506
		unlink($tmpFile);
1507
 
1508
		#將檔案內容的行數放進 $result 陣列變數裏面
1509
		$result["lineCount"]=$lineCount;
1510
 
1511
		#執行到這邊代表執行成功
1512
		$result["status"]="true";
1513
 
1514
		#回傳結果
1515
		return $result;
1516
 
1517
		}#function getFileContent end
1518
 
1519
	/*
1520
	#函式說明:
1521
	#依據逗號分隔抓取檔案的內容,結果會回傳一個陣列
1522
	#回傳結果:	
1523
	#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
1524
	#$result["error"],錯誤訊息提示.
1525
	#$result["function"],函數名稱.
1526
	#$result["lineCount"]爲總共有幾行
1527
	#$result["lineContent"][i]["dataCounts"],爲第 i+1 行總共有幾個字串
1528
	#$result["lineContent"][0][i],爲第1行第 i+1 個分割好的字串
1529
	#$result["lineContent"][1][i],爲第2行第 i+1 個分割好的字串
1530
	#必填參數:
1531
	#$conf["filePositionAndName"],字串,要抓取的檔案位置與名稱
1532
	$conf["filePositionAndName"]="";
1533
	#可省略參數:
1534
	#$conf["spiltSign"],字串,爲要用來分割字串的符號,可省略,預設爲「,」
1535
	#$conf["spiltSign"]="";
1536
	#參考資料:
1537
	#無.
1538
	#備註:
1539
	#無.
1540
	*/
1541
	public static function getFileContentSpiltBySomething($conf){
1542
 
1543
		#初始化要回傳的內容
1544
		$result=array();
1545
 
1546
		#取得當前執行函數名稱
1547
		$result["function"]=__FUNCTION__;
1548
 
1549
		#如果 $conf 不為陣列
1550
		if(gettype($conf)!="array"){
1551
 
1552
			#設置執行失敗
1553
			$result["status"]="false";
1554
 
1555
			#設置執行錯誤訊息
1556
			$result["error"][]="\$conf變數須為陣列形態";
1557
 
1558
			#如果傳入的參數為 null
1559
			if($conf==null){
1560
 
1561
				#設置執行錯誤訊息
1562
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1563
 
1564
				}#if end
1565
 
1566
			#回傳結果
1567
			return $result;
1568
 
1569
			}#if end
1570
 
1571
		#如果 $conf["spiltSign"] 爲空,則預設爲","。
1572
		if(!isset($conf["spiltSign"])){
1573
 
1574
			$conf["spiltSign"]=",";
1575
 
1576
			}#if end
1577
 
1578
		#依據行號抓取所有的內容
1579
		#函式說明:
1580
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
1581
		#回傳的變數說明:
1582
		#$result["fileContent"],爲檔案的內容陣列
1583
		#$result["lineCount"],爲檔案內容總共的行數
1584
		#必填參數:
1585
		$conf["fileAccess"]["getFileContent"]["filePositionAndName"]=$conf["filePositionAndName"];#爲檔案的位置以及名稱
1586
		#參考資料:
1587
		#file():取得檔案內容的行數
1588
		#http:#php.net/manual/en/function.file.php
1589
		$fileContent=fileAccess::getFileContent($conf["fileAccess"]["getFileContent"]);
1590
		unset($conf["fileAccess"]["getFileContent"]);
1591
 
1592
		#如果取得檔案內容失敗
1593
		if($fileContent["status"]=="false"){
1594
 
1595
			#設置執行失敗
1596
			$result["status"]="false";
1597
 
1598
			#設置執行錯誤訊息
1599
			$result["error"]=$fileContent;
1600
 
1601
			#回傳結果
1602
			return $result;
1603
 
1604
			}#if end
1605
 
1606
		#迴圈,有幾行資料就執行幾次
1607
		for($i=0;$i<$fileContent["lineCount"];$i++){
1608
 
1609
			#將該行內容用逗號分隔
1610
			$conf["stringProcess"]["spiltString"]["stringIn"]=$fileContent["fileContent"][$i];#要處理的字串。
1611
			$conf["stringProcess"]["spiltString"]["spiltSymbol"]=$conf["spiltSign"];#爲以哪個符號作爲分割
1612
			$lineSpiltResult[$i]=stringProcess::spiltString($conf["stringProcess"]["spiltString"]);
1613
			unset($conf["stringProcess"]["spiltString"]);	
1614
 
1615
			#如果分割字串失敗
1616
			if($lineSpiltResult[$i]["status"]=="false"){
1617
 
1618
				#設置執行失敗
1619
				$result["status"]="false";
1620
 
1621
				#設置執行錯誤訊息
1622
				$result["error"]=$lineSpiltResult[$i];
1623
 
1624
				#回傳結果
1625
				return $result;
1626
 
1627
				}#if end
1628
 
1629
			}#for end
1630
 
1631
		#取得
1632
		$result["lineContent"]=$lineSpiltResult;
1633
 
1634
		#取得資料的行數
1635
		$result["lineCount"]=$fileContent["lineCount"];
1636
 
1637
		#回傳結果
1638
		return $result;
1639
 
1640
		}#function getFileContentSpiltBySomething end
1641
 
1642
	/*
1643
	#函式說明:
1644
	#檢查多個檔案與資料夾是否存在.
1645
	#回傳的結果:
1646
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
1647
	#$result["error"],錯誤訊息陣列.
1648
	#$resutl["function"],當前執行的涵式名稱.
1649
	#$result["argu"],使用的參數.
1650
	#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
1651
	#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
1652
	#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
1653
	#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
1654
	#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
1655
	#必填參數:
1656
	#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
1657
	$conf["fileArray"]=array();
1658
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1659
	$conf["fileArgu"]=__FILE__;
1660
	#可省略參數:
1661
	#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
1662
	#$conf["disableWebSearch"]="false";
1663
	#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
1664
	#$conf["userDir"]="true";
1665
	#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false",預設為"true".
1666
	#$conf["web"]="true";
1667
	#參考資料:
1668
	#http://php.net/manual/en/function.file-exists.php
1669
	#http://php.net/manual/en/control-structures.foreach.php
1670
	#備註:
1671
	#函數file_exists檢查的路徑為檔案系統的路徑
1672
	#$result["varName"][$i]結果未實作
1673
	*/
1674
	public static function checkMultiFileExist(&$conf){
1675
 
1676
		#初始化要回傳的變數
1677
		$result=array();
1678
 
1679
		#設置當前執行的涵式
1680
		$result["function"]=__FUNCTION__;
1681
 
1682
		#如果 $conf 不為陣列
1683
		if(gettype($conf)!="array"){
1684
 
1685
			#設置執行失敗
1686
			$result["status"]="false";
1687
 
1688
			#設置執行錯誤訊息
1689
			$result["error"][]="\$conf變數須為陣列形態";
1690
 
1691
			#如果傳入的參數為 null
1692
			if($conf==null){
1693
 
1694
				#設置執行錯誤訊息
1695
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1696
 
1697
				}#if end
1698
 
1699
			#回傳結果
1700
			return $result;
1701
 
1702
			}#if end
1703
 
1704
		#取得使用的參數
1705
		$result["argu"]=$conf;
1706
 
1707
		#檢查參數
1708
		#函式說明:
1709
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
1710
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1711
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
1712
		#$result["function"],當前執行的函式名稱.
1713
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
1714
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
1715
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
1716
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
1717
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
1718
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
1719
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
1720
		#必填寫的參數:
1721
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
1722
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
1723
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
1724
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArray","fileArgu");
1725
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
1726
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");
1727
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
1728
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
1729
		#可以省略的參數:
1730
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
1731
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1732
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1733
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("disableWebSearch","userDir","web");
1734
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
1735
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
1736
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1737
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true","true","true");
1738
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1739
		#$conf["arrayCountEqualCheck"][]=array();
1740
		#參考資料來源:
1741
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1742
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1743
		unset($conf["variableCheck::checkArguments"]);
1744
 
1745
		#如果 $checkArguments["status"] 等於 "false"
1746
		if($checkArguments["status"]=="false"){
1747
 
1748
			#設置錯誤識別
1749
			$result["status"]="false";
1750
 
1751
			#設置錯誤訊息
1752
			$result["error"]=$checkArguments;
1753
 
1754
			#回傳結果
1755
			return $result;				
1756
 
1757
			}#if end
1758
 
1759
		#如果 $checkArguments["passed"] 等於 "false"
1760
		if($checkArguments["passed"]=="false"){
1761
 
1762
			#設置錯誤識別
1763
			$result["status"]="false";
1764
 
1765
			#設置錯誤訊息
1766
			$result["error"]=$checkArguments;
1767
 
1768
			#回傳結果
1769
			return $result;				
1770
 
1771
			}#if end
1772
 
1773
		#初始化儲存每個檔案是否存在的陣列變數
1774
		$result["varName"]=array();
1775
		$result["varExist"]=array();
1776
 
1777
		#針對每個要檢查的檔案
1778
		foreach($conf["fileArray"] as $i=>$varName){
1779
 
1780
			#儲存要判斷是否存在的物件
1781
			$result["varName"][]=$varName;
1782
 
1783
			#函式說明:
1784
			#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
1785
			#回傳結果:
1786
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1787
			#$result["error"],錯誤訊息陣列.
1788
			#$result["function"],函數名稱. 
1789
			#$result["argu"],使用的參數.
1790
			#$result["content"],網址,若是在命令列執行,則為"null".
1791
			#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
1792
			#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
1793
			#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
1794
			#必填參數:
1795
			#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
1796
			$conf["fileAccess::getInternetAddressV2"]["address"]=$varName;
1797
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
1798
			$conf["fileAccess::getInternetAddressV2"]["fileArgu"]=$conf["fileArgu"];
1799
			#可省略參數:
1800
			$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
1801
			#備註:
1802
			#建構中,fileSystemRelativePosition尚未實作.
1803
			$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
1804
			unset($conf["fileAccess::getInternetAddressV2"]);
1805
 
1806
			#如果轉換成絕對路徑失敗
1807
			if($getInternetAddressV2["status"]=="false"){
1808
 
1809
				#設置錯誤識別
1810
				$result["status"]="false";
1811
 
1812
				#設置錯誤訊息
1813
				$result["error"]=$getInternetAddressV2;
1814
 
1815
				#回傳結果
1816
				return $result;
1817
 
1818
				}#if end
1819
 
1820
			#傳參考
1821
			$getInternetAddress=&$getInternetAddressV2;
1822
 
1823
			#如果沒有檔案的絕對路徑位置
1824
			if(!isset($getInternetAddress["fileSystemAbsoulutePosition"])){
1825
 
1826
				#置換成給予的參數網址
1827
				$conf["fileArray"][$i]=$getInternetAddress["content"];
1828
 
1829
				#設置無法從檔案系統找到
1830
				$exist=FALSE;
1831
 
1832
				}#if end
1833
 
1834
			#反之取得
1835
			else{
1836
 
1837
				#轉換好的絕對路徑
1838
				$conf["fileArray"][$i]=$getInternetAddress["fileSystemAbsoulutePosition"];
1839
 
1840
				#判斷該檔案是否存在
1841
				$exist=file_exists($conf["fileArray"][$i]);
1842
 
1843
				#如果不存在或是指向不存在目標的連結
1844
				if($exist===false){
1845
 
1846
					#判斷是否為軟連結
1847
					$exist=is_link($conf["fileArray"][$i]);
1848
 
1849
					}#if end`
1850
 
1851
				}#else end
1852
 
1853
			#如果 $exist 等於 false (檔案不存在) 且 沒有停用網路搜尋功能
1854
			if($exist===FALSE && $conf["disableWebSearch"]==="false"){
1855
 
1856
				#將目標轉換成網址
1857
				#函式說明:
1858
				#將檔案的位置名稱變成網址
1859
				#回傳結果:
1860
				#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1861
				#$result["error"],錯誤訊息陣列.
1862
				#$result["function"],函數名稱. 
1863
				#$result["content"],網址.
1864
				#必填參數:
1865
				#$conf["address"],字串,檔案的相對位置.
1866
				$conf["fileAccess::getInternetAddress"]["address"]=$conf["fileArray"][$i];
1867
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
1868
				$conf["fileAccess::getInternetAddress"]["fileArgu"]=$conf["fileArgu"];
1869
				$getInternetAddress=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddress"]);
1870
				unset($conf["fileAccess::getInternetAddress"]);
1871
 
1872
				#如果轉換失敗
1873
				if($getInternetAddress["status"]=="false"){
1874
 
1875
					#設置錯誤識別
1876
					$result["status"]="false";
1877
 
1878
					#設置錯誤訊息
1879
					$result["error"]=$getInternetAddress;
1880
 
1881
					#回傳結果
1882
					return $result;	
1883
 
1884
					}#if end
1885
 
1886
				#函式說明:
1887
				#運行curl cmd
1888
				#回傳結果:
1889
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1890
				#$result["error"],錯誤訊息陣列.
1891
				#$result["function"],當前執行的函式名稱.
1892
				#$result["content"],取得的回應內容.
1893
				#$result["cookie"],cookie檔案的位置與名稱.
1894
				#$result["cmd"],執行的command.
1895
				#$result["argu],使用的參數.
1896
				#必填參數:
1897
				#$conf["url"],字串,目標url.
1898
				$conf["catchWebContent::curlCmd"]["url"]=$getInternetAddress["content"];
1899
				#$conf["fileArgu"],字串,變數__FILE__的內容.
1900
				$conf["catchWebContent::curlCmd"]["fileArgu"]=$conf["fileArgu"];
1901
				#可省略參數:
1902
				#$conf["header"],字串陣列,要傳送的header.
1903
				#$conf["header"]=array();
1904
				#$conf["allowAnySSLcertificate"],字串,是否允許不可信任的SSL憑證,預設為"true".
1905
				#$conf["allowAnySSLcertificate"]="";
1906
				#$conf["postVar"],字串陣列,每個要傳送的post變數名稱(陣列的key值)與數值.
1907
				#$conf["postVar"]=array();
1908
				#$conf["rawPost"]="字串",要傳送的raw post內容.
1909
				#$conf["rawPost"]="";
1910
				#$conf["urlEncode"],字串,post的內容是否要url_encode,"true"代表要,預設為"false"代表不要.
1911
				#$conf["urlEncode"]="false";
1912
				#$conf["agent"],字串,user agent的名稱.
1913
				#$conf["agent"]="";
1914
				#$conf["cookie"],字串,cookie位置與檔案位置.
1915
				#$conf["cookie"]="";
1916
				#$conf["forceNewCookie"],字串,是否要重置cookie,"true"代表要,"false"代表不要,預設為"false".
1917
				#$conf["forceNewCookie"]="";
1918
				$curlCmd=catchWebContent::curlCmd($conf["catchWebContent::curlCmd"]);
1919
				unset($conf["catchWebContent::curlCmd"]);
1920
 
1921
				#如果抓取資料失敗
1922
				if($curlCmd["status"]==="false"){
1923
 
1924
					#設置錯誤識別
1925
					$result["status"]="false";
1926
 
1927
					#設置錯誤訊息
1928
					$result["error"]=$curlCmd;
1929
 
1930
					#回傳結果
1931
					return $result;
1932
 
1933
					}#if end
1934
 
1935
				#反之檔案存在網路上
1936
				else{
1937
 
1938
					#將該檔案的路徑名稱與是否存在的訊息儲存到 $result 陣列變數裏面
1939
					$result["varName"][$i]=$getInternetAddress["content"];
1940
 
1941
					#如果存在檔案路徑的絕對位置
1942
					if(isset($getInternetAddress["fileSystemAbsoulutePosition"])){
1943
 
1944
						#設置該檔案的絕對路徑位置						
1945
						$result["varNameFullPath"][$i]=$getInternetAddress["fileSystemAbsoulutePosition"];
1946
 
1947
						}#if end
1948
 
1949
					#反之代表輸入參數是網址	
1950
					else{
1951
 
1952
						#設置該檔案的網址
1953
						$result["varNameWebPath"][$i]=$getInternetAddress["content"];
1954
 
1955
						}#else end
1956
 
1957
					#設置有無找到的識別
1958
					$result["varExist"][$i]=$curlCmd["founded"];
1959
 
1960
					}#else end
1961
 
1962
				}#if end
1963
 
1964
			#反之檔案不存在,且停用網路搜尋.
1965
			else if($exist===FALSE){
1966
 
1967
				#將該檔案的路徑名稱與是否存在的訊息儲存到 $result 陣列變數裏面
1968
				$result["varName"][$i]=$conf["fileArray"][$i];
1969
				$result["varNameFullPath"][$i]=$conf["fileArray"][$i];
1970
				$result["varExist"][$i]="false";
1971
 
1972
				#設置全部檔案都存在的識別變數為 "false"
1973
				$result["allExist"]="false";
1974
 
1975
				}#if end
1976
 
1977
			#反之代表檔案存在
1978
			else{
1979
 
1980
				#將該檔案的路徑名稱與是否存在的訊息儲存到 $result 陣列變數裏面
1981
				$result["varNameFullPath"][$i]=$conf["fileArray"][$i];
1982
 
1983
				#如果 web 參數為 "true"
1984
				if($conf["web"]==="true"){
1985
 
1986
					#設置網路上的位置
1987
					$result["varNameWebPath"][$i]=$getInternetAddress["content"];
1988
 
1989
					}#if end
1990
 
1991
				$result["varExist"][$i]="true";
1992
 
1993
				}#else end
1994
 
1995
			}#foreach end
1996
 
1997
		#如果所有檔案與資料夾都找到的識別變數不存在
1998
		if(!isset($result["allExist"])){
1999
 
2000
			#設置全部檔案與資料夾都有找到
2001
			$result["allExist"]="true";
2002
 
2003
			}#if end
2004
 
2005
		#執行到這邊代表執行正常
2006
		$result["status"]="true";
2007
 
2008
		#回傳結果
2009
		return $result;
2010
 
2011
		}#function checkMutiFileExist
2012
 
2013
	/*
2014
	#函式說明:
2015
	#檢查要建立的檔案路徑是否存在,若不存在則建立新檔案,若檔案已存在則會在原檔名後面加上從(1)開始的編號,再度嘗試建立檔案,以避免資料異常.
2016
	#回傳結果:
2017
	#$result["status"],執行狀態,"true"代表執行正常,"false"代表執行失敗.
2018
	#$result["error"],錯誤訊息陣列.
2019
	#$result["function"],當前執行的函數名稱.
2020
	#$result["argu"],使用的參數.
2021
	#$result["createdFileName"],建立好的檔案名稱.
2022
	#$result["createdFilePath"],檔案建立的路徑.
2023
	#$result["createdFilePathAndName"].建立好的檔案名稱與路徑.
2024
	#必填參數:
2025
	#$conf["checkedFileAndPath"],字串陣列,要建立的檔案路徑
2026
	$conf["checkedFileAndPath"]="";
2027
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2028
	$conf["fileArgu"]=__FILE__;
2029
	#可省略參數:
2030
	#$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點.
2031
	#$conf["filenameExtensionStartPoint"]="";
2032
	#$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)".
2033
	#$conf["repeatNameRule"]="";
2034
	#$conf["web"],"true"代表為網頁系統,"false"代表檔案系統,預設為"false".
2035
	#$conf["web"]="false";
2036
	#參考資料:
2037
	#無.
2038
	#備註:
2039
	#如果要在/tmp底下建立檔案,若在apache環境下則會被作業系統特殊處理,即不等於實際上的路徑.
2040
	*/
2041
	public static function createFileAfterCheck(&$conf){
2042
 
2043
		#初始化要回傳的結果
2044
		$result=array();
2045
 
2046
		#設置當前執行的涵式
2047
		$result["function"]=__FUNCTION__;
2048
 
2049
		#如果 $conf 不為陣列
2050
		if(gettype($conf)!="array"){
2051
 
2052
			#設置執行失敗
2053
			$result["status"]="false";
2054
 
2055
			#設置執行錯誤訊息
2056
			$result["error"][]="\$conf變數須為陣列形態";
2057
 
2058
			#如果傳入的參數為 null
2059
			if($conf==null){
2060
 
2061
				#設置執行錯誤訊息
2062
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
2063
 
2064
				}#if end
2065
 
2066
			#回傳結果
2067
			return $result;
2068
 
2069
			}#if end
2070
 
2071
		#取得參數
2072
		$result["argu"]=$conf;
2073
 
2074
		#檢查參數
2075
		#函式說明:
2076
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
2077
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2078
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
2079
		#$result["function"],當前執行的函式名稱.
2080
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
2081
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
2082
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
2083
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
2084
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
2085
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
2086
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
2087
		#必填寫的參數:
2088
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
2089
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
2090
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
2091
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","checkedFileAndPath");
2092
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
2093
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
2094
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
2095
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
2096
		#可以省略的參數:
2097
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
2098
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
2099
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
2100
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("filenameExtensionStartPoint","repeatNameRule","web");
2101
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
2102
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
2103
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
2104
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("1","(\$i)","false");
2105
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
2106
		#$conf["arrayCountEqualCheck"][]=array();
2107
		#參考資料來源:
2108
		#array_keys=>http://php.net/manual/en/function.array-keys.php
2109
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2110
		unset($conf["variableCheck::checkArguments"]);
2111
 
2112
		#如果 $checkArguments["status"] 等於 "false"
2113
		if($checkArguments["status"]=="false"){
2114
 
2115
			#設置錯誤識別
2116
			$result["status"]="false";
2117
 
2118
			#設置錯誤訊息
2119
			$result["error"]=$checkArguments;
2120
 
2121
			#回傳結果
2122
			return $result;				
2123
 
2124
			}#if end
2125
 
2126
		#如果 $checkArguments["passed"] 等於 "false"
2127
		if($checkArguments["passed"]=="false"){
2128
 
2129
			#設置錯誤識別
2130
			$result["status"]="false";
2131
 
2132
			#設置錯誤訊息
2133
			$result["error"]=$checkArguments;
2134
 
2135
			#回傳結果
2136
			return $result;				
2137
 
2138
			}#if end	
2139
 
2140
		#確保要建立檔案的路徑
2141
		#函式說明:
2142
		#確保路徑存在.
2143
		#回傳結果:
2144
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
2145
		#$result["error"],錯誤訊息陣列.
2146
		#$resutl["function"],當前執行的涵式名稱.
2147
		#$result["path"],建立好的路徑字串.
2148
		#$result["fileName"],檔案名稱,若 $conf["haveFileName"] 為 "true" 則會回傳.
2149
		#必填參數:
2150
		#$conf["path"],要檢查的路徑
2151
		$conf["fileAccess::validatePath"]["path"]=$conf["checkedFileAndPath"];		
2152
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2153
		$conf["fileAccess::validatePath"]["fileArgu"]=$conf["fileArgu"];
2154
		#可省略參數:
2155
		#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
2156
		$conf["fileAccess::validatePath"]["haveFileName"]="true";
2157
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
2158
		#$conf["dirPermission"]="";
2159
		$conf["fileAccess::validatePath"]["web"]=$conf["web"];
2160
		$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
2161
		unset($conf["fileAccess::validatePath"]);	
2162
 
2163
		#debug
2164
		#var_dump($validatePath);
2165
		#exit;	
2166
 
2167
		#如果確保路徑失敗
2168
		if($validatePath["status"]==="false"){
2169
 
2170
			#設置錯誤識別
2171
			$result["status"]="false";
2172
 
2173
			#設置錯誤訊息
2174
			$result["error"]=$validatePath;
2175
 
2176
			#回傳結果
2177
			return $result;
2178
 
2179
			}#if end
2180
 
2181
		#取得要建立的檔案名稱
2182
		$createdFileName=$validatePath["fileName"];
2183
 
2184
		#取得要建立的路徑			
2185
		$createdFilePath=$validatePath["path"];
2186
 
2187
		#透過無窮迴圈嘗試建立不同編號的檔案
2188
		for($i=0;$i>-1;$i++){
2189
 
2190
			#如果 $i 為 0
2191
			if($i==0){
2192
 
2193
				#檢查該檔案是否存在
2194
				#函式說明:
2195
				#檢查多個檔案與資料夾是否存在.
2196
				#回傳的結果:
2197
				#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
2198
				#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
2199
				#必填參數:
2200
				$conf["fileAccess"]["checkMutiFileExist"]["fileArray"]=array($createdFilePath."/".$createdFileName);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
2201
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2202
				$conf["fileAccess"]["checkMutiFileExist"]["fileArgu"]=$conf["fileArgu"];
2203
				#參考資料來源:
2204
				#http://php.net/manual/en/function.file-exists.php
2205
				#http://php.net/manual/en/control-structures.foreach.php
2206
				$conf["fileAccess"]["checkMutiFileExist"]["web"]=$conf["web"];
2207
				$checkResult=fileAccess::checkMultiFileExist($conf["fileAccess"]["checkMutiFileExist"]);
2208
				unset($conf["fileAccess"]["checkMutiFileExist"]);
2209
 
2210
				#debug
2211
				#var_dump($checkResult);
2212
				#exit;
2213
 
2214
				#如果檢查檔案是否存在失敗
2215
				if($checkResult["status"]=="false"){
2216
 
2217
					#設置執行失敗
2218
					$result["status"]="false";
2219
 
2220
					#設置錯誤訊息
2221
					$result["error"]=$checkResult;
2222
 
2223
					#回傳結果
2224
					return $result;
2225
 
2226
					}#if end
2227
 
2228
				#如果 $createFilePath.$createdFileName 檔案存在
2229
				if($checkResult["varExist"][0]=="true"){
2230
 
2231
					#跳過這次迴圈
2232
					continue;
2233
 
2234
					}#if end
2235
 
2236
				#反之代表 $createFilePath.$createdFileName 檔案不存在
2237
				else{
2238
 
2239
					#嘗試建立該檔案
2240
					#函式說明:
2241
					#將字串寫入到檔案
2242
					#回傳結果:
2243
					#$result["status"],true表示檔案寫入成功,false表示檔案寫入失敗.
2244
					#$result["error"],錯誤訊息陣列.
2245
					#必填參數:
2246
					$conf["fileAccess"]["writeTextIntoFile"]["fileName"]=$createdFilePath."/".$createdFileName;#爲要編輯的檔案名稱
2247
					$conf["fileAccess"]["writeTextIntoFile"]["inputString"]="";#爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可。
2248
					$conf["fileAccess"]["writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
2249
					#可省略參數:
2250
					$conf["fileAccess"]["writeTextIntoFile"]["writeMethod"]="w";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
2251
					$conf["fileAccess"]["writeTextIntoFile"]["web"]=$conf["web"];
2252
					$fileCreateResult=fileAccess::writeTextIntoFile($conf["fileAccess"]["writeTextIntoFile"]);
2253
					unset($conf["fileAccess"]["writeTextIntoFile"]);
2254
 
2255
					#如果 $fileCreateResult["status"] 等於 "true"
2256
					if($fileCreateResult["status"]=="true"){
2257
 
2258
						#代表檔案建立成功
2259
 
2260
						#更新建立的檔案名稱
2261
						$result["createdFileName"]=$createdFileName;
2262
 
2263
						#設置新建立的檔案名稱與路徑
2264
						$result["createdFilePathAndName"]=$createdFilePath."/".$result["createdFileName"];
2265
 
2266
						#設置新建立的檔與路徑
2267
						$result["createdFilePath"]=$createdFilePath;
2268
 
2269
						#跳出迴圈
2270
						break;
2271
 
2272
						}#if end
2273
 
2274
					#反之代表檔案建立失敗
2275
					else{
2276
 
2277
						#設置錯誤識別
2278
						$result["status"]="false";
2279
 
2280
						#設置錯誤訊息
2281
						$result["error"]=$fileCreateResult;
2282
 
2283
						#回傳結果
2284
						return $result;
2285
 
2286
						}#else end
2287
 
2288
					}#else end	
2289
 
2290
				}#if end
2291
 
2292
			#反之代表有相同檔名存在
2293
			else{					
2294
 
2295
				#用「.」分割檔案名稱
2296
				#函式說明:
2297
				#將固定格式的字串分開,並回傳分開的結果。
2298
				#回傳結果:
2299
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2300
				#$result["error"],錯誤訊息陣列
2301
				#$result["function"],當前執行的函數名稱.
2302
				#$result["oriStr"],要分割的原始字串內容
2303
				#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
2304
				#$result["dataCounts"],爲總共分成幾段
2305
				#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
2306
				#必填參數:
2307
				$conf["stringProcess::spiltString"]["stringIn"]=$createdFileName;#要處理的字串。
2308
				$conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
2309
				#可省略參數:
2310
				#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
2311
				$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
2312
				$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
2313
				unset($conf["stringProcess::spiltString"]);					
2314
 
2315
				#如果分割檔案名稱失敗
2316
				if($spiltString["status"]=="false"){
2317
 
2318
					#設置執行失敗
2319
					$result["status"]="false";
2320
 
2321
					#設置錯誤訊息
2322
					$result["error"]=$spiltString;
2323
 
2324
					#回傳結果
2325
					return $result;
2326
 
2327
					}#if end
2328
 
2329
				#初始化儲存建立的檔案名稱
2330
				$createdFileName="";
2331
 
2332
				#初始化儲存編號的變數
2333
				$no="";
2334
 
2335
				#如果沒有dot存在
2336
				if($spiltString["found"]=="false"){
2337
 
2338
					#解析 $conf["repeatNameRule"],用 \$i 分割.
2339
					#函式說明:
2340
					#將固定格式的字串分開,並回傳分開的結果。
2341
					#回傳結果:
2342
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2343
					#$result["error"],錯誤訊息陣列
2344
					#$result["function"],當前執行的函數名稱.
2345
					#$result["oriStr"],要分割的原始字串內容
2346
					#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
2347
					#$result["dataCounts"],爲總共分成幾段
2348
					#必填參數:
2349
					$conf["stringProcess::spiltString"]["stringIn"]=$conf["repeatNameRule"];#要處理的字串。
2350
					$conf["stringProcess::spiltString"]["spiltSymbol"]="\$i";#爲以哪個符號作爲分割
2351
					#可省略參數:
2352
					#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
2353
					$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
2354
					$noString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
2355
					unset($conf["stringProcess::spiltString"]);					
2356
 
2357
					#如果分割檔案名稱失敗
2358
					if($noString["status"]=="false"){
2359
 
2360
						#設置執行失敗
2361
						$result["status"]="false";
2362
 
2363
						#設置錯誤訊息
2364
						$result["error"]=$noString;
2365
 
2366
						#回傳結果
2367
						return $result;
2368
 
2369
						}#if end
2370
 
2371
					#如果 編號規則字串 分割出來的段數為2
2372
					if($noString["dataCounts"]==2){
2373
 
2374
						#組合編號
2375
						$no=$noString["dataArray"][0].$i.$noString["dataArray"][1];
2376
 
2377
						}#if end
2378
 
2379
					#反之 號規則字串 分割出來的段數為1
2380
					else if($noString["dataCounts"]==1){
2381
 
2382
						#判斷 "\$i" 在開頭或結尾
2383
						#函式說明:
2384
						#取得關鍵字在字串的哪個位置
2385
						#回傳結果:
2386
						#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
2387
						#$result["error"],錯誤訊息陣列.
2388
						#$result["function"],當前執行的函數名稱.
2389
						#$result["argu"],傳入的參數.
2390
						#$result["head"],關鍵字是否在字串的開頭,"true"代表是,"false"代表不是.
2391
						#$result["tail"],關鍵字是否在字串的尾端,"true"代表是,"false"代表不是.
2392
						#$result["center"],關鍵字是否在字串的中間,"true"代表是,"false"代表不是.
2393
						#必填參數:
2394
						#$conf["inputStr"],字串,被搜尋的字串.
2395
						$conf["search::findKeyWordPosition"]["inputStr"]=$conf["repeatNameRule"];
2396
						#$conf["keyWord"],字串,關鍵字.
2397
						$conf["search::findKeyWordPosition"]["keyWord"]="\$i";
2398
						#參考資料:
2399
						#http://php.net/manual/en/function.strpos.php
2400
						$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
2401
						unset($conf["search::findKeyWordPosition"]);
2402
 
2403
						#如果取得關鍵字位置失敗
2404
						if($findKeyWordPosition["status"]=="false"){
2405
 
2406
							#設置執行失敗
2407
							$result["status"]="false";
2408
 
2409
							#設置錯誤訊息
2410
							$result["error"]=$findKeyWordPosition;
2411
 
2412
							#回傳結果
2413
							return $result;
2414
 
2415
							}#if end
2416
 
2417
						#如果關鍵字在開頭
2418
						if($findKeyWordPosition["head"]=="true"){
2419
 
2420
							#組合編號
2421
							$no=$i.$noString["dataArray"][0];
2422
 
2423
							}#if end
2424
 
2425
						#反之如果關鍵字在結尾
2426
						else if($findKeyWordPosition["tail"]=="true"){
2427
 
2428
							#組合編號
2429
							$no=$noString["dataArray"][0].$i;
2430
 
2431
							}#if end
2432
 
2433
						#其他情況
2434
						else{
2435
 
2436
							#設置執行失敗
2437
							$result["status"]="false";
2438
 
2439
							#設置錯誤訊息
2440
							$result["error"]=$findKeyWordPosition;
2441
 
2442
							#設置額外的錯誤訊息
2443
							$result["error"][]="非預期的結果";
2444
 
2445
							#回傳結果
2446
							return $result;
2447
 
2448
							}#else end
2449
 
2450
						}#if end
2451
 
2452
					#反之 編號規則字串 分割出來的段數為0
2453
					else if($noString["dataCounts"]==0){
2454
 
2455
						#組合編號
2456
						$no=$j;
2457
 
2458
						}#if end
2459
 
2460
					#其他結果
2461
					else{
2462
 
2463
						#設置執行失敗
2464
						$result["status"]="false";
2465
 
2466
						#設置錯誤訊息
2467
						$result["error"]=$noString;
2468
 
2469
						#設置額外的錯誤訊息
2470
						$result["error"][]="非預期的結果";
2471
 
2472
						#回傳結果
2473
						return $result;
2474
 
2475
						}#else end	
2476
 
2477
					#串接編號到檔案名稱上
2478
					$createdFileName=$validatePath["fileName"].$no;
2479
 
2480
					}#if end
2481
 
2482
				#反之有dot存在	
2483
				else{
2484
 
2485
					#依據 $spiltString["dataCounts"] 值來組裝新的檔案名稱
2486
					for($j=0;$j<$spiltString["dataCounts"];$j++){
2487
 
2488
						#如果是副檔名的前一段內容
2489
						if(($conf["filenameExtensionStartPoint"]+1)==($spiltString["dataCounts"]-$j)){
2490
 
2491
							#解析 $conf["repeatNameRule"],用 \$i 分割.
2492
							#函式說明:
2493
							#將固定格式的字串分開,並回傳分開的結果。
2494
							#回傳結果:
2495
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2496
							#$result["error"],錯誤訊息陣列
2497
							#$result["function"],當前執行的函數名稱.
2498
							#$result["oriStr"],要分割的原始字串內容
2499
							#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
2500
							#$result["dataCounts"],爲總共分成幾段
2501
							#必填參數:
2502
							$conf["stringProcess::spiltString"]["stringIn"]=$conf["repeatNameRule"];#要處理的字串。
2503
							$conf["stringProcess::spiltString"]["spiltSymbol"]="\$i";#爲以哪個符號作爲分割
2504
							#可省略參數:
2505
							#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
2506
							$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
2507
							$noString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
2508
							unset($conf["stringProcess::spiltString"]);					
2509
 
2510
							#如果分割檔案名稱失敗
2511
							if($noString["status"]=="false"){
2512
 
2513
								#設置執行失敗
2514
								$result["status"]="false";
2515
 
2516
								#設置錯誤訊息
2517
								$result["error"]=$noString;
2518
 
2519
								#回傳結果
2520
								return $result;
2521
 
2522
								}#if end
2523
 
2524
							#如果 編號規則字串 分割出來的段數為2
2525
							if($noString["dataCounts"]==2){
2526
 
2527
								#組合編號
2528
								$no=$noString["dataArray"][0].$i.$noString["dataArray"][1];
2529
 
2530
								}#if end
2531
 
2532
							#反之 號規則字串 分割出來的段數為1
2533
							else if($noString["dataCounts"]==1){
2534
 
2535
								#判斷 "\$i" 在開頭或結尾
2536
								#函式說明:
2537
								#取得關鍵字在字串的哪個位置
2538
								#回傳結果:
2539
								#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
2540
								#$result["error"],錯誤訊息陣列.
2541
								#$result["function"],當前執行的函數名稱.
2542
								#$result["argu"],傳入的參數.
2543
								#$result["head"],關鍵字是否在字串的開頭,"true"代表是,"false"代表不是.
2544
								#$result["tail"],關鍵字是否在字串的尾端,"true"代表是,"false"代表不是.
2545
								#$result["center"],關鍵字是否在字串的中間,"true"代表是,"false"代表不是.
2546
								#必填參數:
2547
								#$conf["inputStr"],字串,被搜尋的字串.
2548
								$conf["search::findKeyWordPosition"]["inputStr"]=$conf["repeatNameRule"];
2549
								#$conf["keyWord"],字串,關鍵字.
2550
								$conf["search::findKeyWordPosition"]["keyWord"]="\$i";
2551
								#參考資料:
2552
								#http://php.net/manual/en/function.strpos.php
2553
								$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
2554
								unset($conf["search::findKeyWordPosition"]);
2555
 
2556
								#如果取得關鍵字位置失敗
2557
								if($findKeyWordPosition["status"]=="false"){
2558
 
2559
									#設置執行失敗
2560
									$result["status"]="false";
2561
 
2562
									#設置錯誤訊息
2563
									$result["error"]=$findKeyWordPosition;
2564
 
2565
									#回傳結果
2566
									return $result;
2567
 
2568
									}#if end
2569
 
2570
								#如果關鍵字在開頭
2571
								if($findKeyWordPosition["head"]=="true"){
2572
 
2573
									#組合編號
2574
									$no=$i.$noString["dataArray"][0];
2575
 
2576
									}#if end
2577
 
2578
								#反之如果關鍵字在結尾
2579
								else if($findKeyWordPosition["tail"]=="true"){
2580
 
2581
									#組合編號
2582
									$no=$noString["dataArray"][0].$i;
2583
 
2584
									}#if end
2585
 
2586
								#其他情況
2587
								else{
2588
 
2589
									#設置執行失敗
2590
									$result["status"]="false";
2591
 
2592
									#設置錯誤訊息
2593
									$result["error"]=$findKeyWordPosition;
2594
 
2595
									#設置額外的錯誤訊息
2596
									$result["error"][]="非預期的結果";
2597
 
2598
									#回傳結果
2599
									return $result;
2600
 
2601
									}#else end
2602
 
2603
								}#if end
2604
 
2605
							#反之 編號規則字串 分割出來的段數為0
2606
							else if($noString["dataCounts"]==0){
2607
 
2608
								#組合編號
2609
								$no=$j;
2610
 
2611
								}#if end
2612
 
2613
							#其他結果
2614
							else{
2615
 
2616
								#設置執行失敗
2617
								$result["status"]="false";
2618
 
2619
								#設置錯誤訊息
2620
								$result["error"]=$noString;
2621
 
2622
								#設置額外的錯誤訊息
2623
								$result["error"][]="非預期的結果";
2624
 
2625
								#回傳結果
2626
								return $result;
2627
 
2628
								}#else end	
2629
 
2630
							#串接編號到檔案名稱上
2631
							$createdFileName=$createdFileName.$spiltString["dataArray"][$j].$no;
2632
 
2633
							#如果不是最後一段
2634
							if($j!=$spiltString["dataCounts"]-1){
2635
 
2636
								#串接並加上 dot
2637
								$createdFileName=$createdFileName.".";
2638
 
2639
								}#if end
2640
 
2641
							}#if end
2642
 
2643
						#反之如果不是最後一段
2644
						else if($j!=$spiltString["dataCounts"]-1){
2645
 
2646
							#串接並加上 dot
2647
							$createdFileName=$createdFileName.$spiltString["dataArray"][$j].".";
2648
 
2649
							}#if end
2650
 
2651
						#反之是最後一段	
2652
						else{
2653
 
2654
							#串接並加上 dot
2655
							$createdFileName=$createdFileName.$spiltString["dataArray"][$j];
2656
 
2657
							}#else end
2658
 
2659
						}#for end
2660
 
2661
					}#else end
2662
 
2663
				#檢查加上編號的檔案是否存在
2664
				#函式說明:
2665
				#檢查多個檔案與資料夾是否存在.
2666
				#回傳的結果:
2667
				#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
2668
				#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
2669
				#必填參數:
2670
				$conf["fileAccess"]["checkMutiFileExist"]["fileArray"]=array($createdFilePath."/".$createdFileName);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
2671
				$conf["fileAccess"]["checkMutiFileExist"]["fileArgu"]=$conf["fileArgu"];
2672
				#參考資料來源:
2673
				#http://php.net/manual/en/function.file-exists.php
2674
				#http://php.net/manual/en/control-structures.foreach.php
2675
				$conf["fileAccess"]["checkMutiFileExist"]["web"]=$conf["web"];
2676
				$checkResult=fileAccess::checkMultiFileExist($conf["fileAccess"]["checkMutiFileExist"]);
2677
				unset($conf["fileAccess"]["checkMutiFileExist"]);
2678
 
2679
				#如果檢查檔案是否存在失敗
2680
				if($checkResult["status"]=="false"){
2681
 
2682
					#設置執行失敗
2683
					$result["status"]="false";
2684
 
2685
					#設置錯誤訊息
2686
					$result["error"]=$checkResult;
2687
 
2688
					#回傳結果
2689
					return $result;
2690
 
2691
					}#if end						
2692
 
2693
				#如果 $checkResult["varExist"][0] 等於 "true"
2694
				if($checkResult["varExist"][0]=="true"){						
2695
 
2696
					#取得要建立的檔案名稱
2697
					$createdFileName=$validatePath["fileName"];
2698
 
2699
					#跳到下個迴圈
2700
					continue;
2701
 
2702
					}#if end
2703
 
2704
				#反之代表 $createFilePath.$createdFileName."(".$i.")" 檔檔案不存在
2705
				else{
2706
 
2707
					#嘗試建立該檔案
2708
					#函式說明:
2709
					#將字串寫入到檔案
2710
					#回傳結果:
2711
					#$result["status"],true表示檔案寫入成功,false表示檔案寫入失敗.
2712
					#$result["error"],錯誤訊息陣列.
2713
					#必填參數:
2714
					$conf["fileAccess"]["writeTextIntoFile"]["fileName"]=$createdFilePath."/".$createdFileName;#爲要編輯的檔案名稱
2715
					$conf["fileAccess"]["writeTextIntoFile"]["inputString"]="";#爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可。
2716
					$conf["fileAccess"]["writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
2717
					#可省略參數:
2718
					$conf["fileAccess"]["writeTextIntoFile"]["writeMethod"]="w";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
2719
					$conf["fileAccess"]["writeTextIntoFile"]["web"]=$conf["web"];
2720
					$fileCreateResult=fileAccess::writeTextIntoFile($conf["fileAccess"]["writeTextIntoFile"]);
2721
					unset($conf["fileAccess"]["writeTextIntoFile"]);
2722
 
2723
					#如果 $fileCreateResult["status"] 等於 "true"
2724
					if($fileCreateResult["status"]=="true"){
2725
 
2726
						#代表檔案建立成功
2727
 
2728
						#更新建立的檔案名稱
2729
						$result["createdFileName"]=$createdFileName;
2730
 
2731
						#跳出迴圈
2732
						break;
2733
 
2734
						}#if end
2735
 
2736
					#反之代表檔案建立失敗
2737
					else{
2738
 
2739
						#設置錯誤識別
2740
						$result["status"]="false";
2741
 
2742
						#設置錯誤訊息
2743
						$result["error"]=$fileCreateResult;
2744
 
2745
						#回傳結果
2746
						return $result;
2747
 
2748
						}#else end
2749
 
2750
					}#else end
2751
 
2752
				}#else end
2753
 
2754
			}#for end
2755
 
2756
		#如果不存在建立的檔案名稱
2757
		if(!isset($result["createdFileName"])){
2758
 
2759
			#設置錯誤識別
2760
			$result["status"]="false";
2761
 
2762
			#設置錯誤訊息
2763
			$result["error"][]="建立的檔案名稱不存在";
2764
 
2765
			#回傳結果
2766
			return $result;
2767
 
2768
			}#if end	
2769
 
2770
		#執行到這邊代表執行成功
2771
		$result["status"]="true";
2772
 
2773
		#設置新建立的檔案名稱與路徑
2774
		$result["createdFilePathAndName"]=$createdFilePath."/".$result["createdFileName"];
2775
 
2776
		#設置新建立的檔與路徑
2777
		$result["createdFilePath"]=$createdFilePath;
2778
 
2779
		#回傳結果
2780
		return $result;
2781
 
2782
		}#fucntion createFileAfterCheck end
2783
 
2784
	/*
2785
	#函式說明:
2786
	#將檔案內容清空
2787
	#回傳結果:
2788
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
2789
	#$result["error"],錯誤訊息陣列
2790
	#必填參數:
2791
	#$conf["fileAddr"],字串,要清空的檔案位置與名稱.
2792
	$conf["fileAddr"]="";
2793
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2794
	$conf["fileArgu"]=__FILE__;
2795
	#可省略參數:
2796
	#$conf["web"],"true"代表為網頁系統,"false"代表檔案系統,預設為"false".
2797
	#$conf["web"]="false";
2798
	#參考資料:
2799
	#無.
2800
	#備註:
2801
	#無.
2802
	*/
2803
	public static function emptyFile(&$conf){
2804
 
2805
		#初始化要回傳的結果
2806
		$result=array();
2807
 
2808
		#設置當前執行的涵式
2809
		$result["function"]=__FUNCTION__;
2810
 
2811
		#如果 $conf 不為陣列
2812
		if(gettype($conf)!="array"){
2813
 
2814
			#設置執行失敗
2815
			$result["status"]="false";
2816
 
2817
			#設置執行錯誤訊息
2818
			$result["error"][]="\$conf變數須為陣列形態";
2819
 
2820
			#如果傳入的參數為 null
2821
			if($conf==null){
2822
 
2823
				#設置執行錯誤訊息
2824
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
2825
 
2826
				}#if end
2827
 
2828
			#回傳結果
2829
			return $result;
2830
 
2831
			}#if end
2832
 
2833
		#取得參數
2834
		$result["argu"]=$conf;
2835
 
2836
		#檢查參數
2837
		#函式說明:
2838
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
2839
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2840
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
2841
		#$result["function"],當前執行的函式名稱.
2842
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
2843
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
2844
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
2845
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
2846
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
2847
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
2848
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
2849
		#必填寫的參數:
2850
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
2851
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
2852
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
2853
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileAddr");
2854
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
2855
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
2856
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
2857
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
2858
		#可以省略的參數:
2859
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
2860
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
2861
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
2862
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
2863
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
2864
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
2865
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
2866
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
2867
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
2868
		#$conf["arrayCountEqualCheck"][]=array();
2869
		#參考資料來源:
2870
		#array_keys=>http://php.net/manual/en/function.array-keys.php
2871
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2872
		unset($conf["variableCheck::checkArguments"]);
2873
 
2874
		#如果 $checkArguments["status"] 等於 "false"
2875
		if($checkArguments["status"]=="false"){
2876
 
2877
			#設置錯誤識別
2878
			$result["status"]="false";
2879
 
2880
			#設置錯誤訊息
2881
			$result["error"]=$checkArguments;
2882
 
2883
			#回傳結果
2884
			return $result;				
2885
 
2886
			}#if end
2887
 
2888
		#如果 $checkArguments["passed"] 等於 "false"
2889
		if($checkArguments["passed"]=="false"){
2890
 
2891
			#設置錯誤識別
2892
			$result["status"]="false";
2893
 
2894
			#設置錯誤訊息
2895
			$result["error"]=$checkArguments;
2896
 
2897
			#回傳結果
2898
			return $result;				
2899
 
2900
			}#if end	
2901
 
2902
		#函式說明:
2903
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
2904
		#回傳結果:
2905
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
2906
		#$result["error"],錯誤訊息陣列.
2907
		#$result["function"],函數名稱. 
2908
		#$result["argu"],使用的參數.
2909
		#$result["content"],網址,若是在命令列執行,則為"null".
2910
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
2911
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
2912
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
2913
		#必填參數:
2914
		#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
2915
		$conf["fileAccess::getInternetAddressV2"]["address"]=$conf["fileAddr"];
2916
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
2917
		$conf["fileAccess::getInternetAddressV2"]["fileArgu"]=$conf["fileArgu"];
2918
		#可省略參數:
2919
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
2920
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
2921
		#備註:
2922
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
2923
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
2924
		unset($conf["fileAccess::getInternetAddressV2"]);
2925
 
2926
		#如果確保路徑失敗
2927
		if($getInternetAddressV2["status"]==="false"){
2928
 
2929
			#設置錯誤識別
2930
			$result["status"]="false";
2931
 
2932
			#設置錯誤訊息
2933
			$result["error"]=$getInternetAddressV2;
2934
 
2935
			#回傳結果
2936
			return $result;
2937
 
2938
			}#if end
2939
 
2940
		#更新檔案路徑
2941
		$conf["fileAddr"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
2942
 
2943
		#確保要建立檔案的路徑
2944
		#函式說明:
2945
		#確保路徑存在.
2946
		#回傳結果:
2947
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
2948
		#$result["error"],錯誤訊息陣列.
2949
		#$resutl["function"],當前執行的涵式名稱.
2950
		#$result["path"],建立好的路徑字串.
2951
		#$result["fileName"],檔案名稱,若 $conf["haveFileName"] 為 "true" 則會回傳.
2952
		#必填參數:
2953
		#$conf["path"],要檢查的路徑
2954
		$conf["fileAccess::validatePath"]["path"]=$conf["fileAddr"];		
2955
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2956
		$conf["fileAccess::validatePath"]["fileArgu"]=$conf["fileArgu"];
2957
		#可省略參數:
2958
		#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
2959
		$conf["fileAccess::validatePath"]["haveFileName"]="true";
2960
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
2961
		#$conf["dirPermission"]="";
2962
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
2963
		$conf["fileAccess::validatePath"]["web"]="false";
2964
		$validatePath=fileAccess::validatePath($conf["fileAccess::validatePath"]);
2965
		unset($conf["fileAccess::validatePath"]);	
2966
 
2967
		#如果確保路徑失敗
2968
		if($validatePath["status"]==="false"){
2969
 
2970
			#設置錯誤識別
2971
			$result["status"]="false";
2972
 
2973
			#設置錯誤訊息
2974
			$result["error"]=$validatePath;
2975
 
2976
			#回傳結果
2977
			return $result;
2978
 
2979
			}#if end
2980
 
2981
		#清空檔案
2982
		#函式說明:
2983
		#將字串寫入到檔案
2984
		#回傳結果:
2985
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
2986
		#$result["error"],錯誤訊息陣列.
2987
		#$result["function"],當前執行的函數名稱.
2988
		#$result["fileInfo"],實際上寫入的檔案資訊陣列.
2989
		#$result["fileInfo"]["createdFileName"],建立好的檔案名稱.
2990
		#$result["fileInfo"]["createdFilePath"],檔案建立的路徑.
2991
		#$result["fileInfo"]["createdFilePathAndName"].建立好的檔案名稱與路徑.
2992
		#$result["argu"],使用的參數.
2993
		#必填參數:
2994
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2995
		$conf["fileAccess::writeTextIntoFile"]["fileArgu"]=$conf["fileArgu"];
2996
		#可省略參數:
2997
		#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
2998
		#$conf["fileAccess::writeTextIntoFile"]["fileName"]=$validatePath["path"]."/".$validatePath["fileName"];
2999
		$conf["fileAccess::writeTextIntoFile"]["fileName"]=$validatePath["path"]."/".$validatePath["fileName"];;
3000
		#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
3001
		#$conf["inputString"]="";
3002
		#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
3003
		#$conf["writeMethod"]="a";
3004
		#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
3005
		#$conf["checkRepeat"]="";
3006
		#$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點,必須與$conf["checkRepeat"]搭配才會生效.
3007
		#$conf["filenameExtensionStartPoint"]="";
3008
		#$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)",必須與$conf["checkRepeat"]搭配才會生效.
3009
		#$conf["repeatNameRule"]="";
3010
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
3011
		$conf["fileAccess::writeTextIntoFile"]["web"]="false";
3012
		$writeTextIntoFile=fileAccess::writeTextIntoFile($conf["fileAccess::writeTextIntoFile"]);
3013
		unset($conf["fileAccess::writeTextIntoFile"]);
3014
 
3015
		#如果確保路徑失敗
3016
		if($writeTextIntoFile["status"]==="false"){
3017
 
3018
			#設置錯誤識別
3019
			$result["status"]="false";
3020
 
3021
			#設置錯誤訊息
3022
			$result["error"]=$writeTextIntoFile;
3023
 
3024
			#回傳結果
3025
			return $result;
3026
 
3027
			}#if end
3028
 
3029
		#設置執行正常
3030
		$result["status"]="true";
3031
 
3032
		#儲存建立的結果
3033
		$result["content"]=$writeTextIntoFile;
3034
 
3035
		#回傳結果
3036
		return $result;
3037
 
3038
		}#function emptyFile end
3039
 
3040
	/*
3041
	#函式說明:
3042
	#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
3043
	#回傳結果:
3044
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
3045
	#$result["error"],錯誤訊息陣列
3046
	#$result["warning"],警告訊息陣列
3047
	#必填參數:
3048
	#$conf["dirPositionAndName"]="";#新建的位置與名稱
3049
	$conf["dirPositionAndName"]="";
3050
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3051
	$conf["fileArgu"]=__FILE__;
3052
	#可省略參數:
3053
	#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
3054
	#$conf["dirPermission"]="";
3055
	#參考資料:
3056
	#mkdir=>http://php.net/manual/en/function.mkdir.php
3057
	#chmod=>http://php.net/manual/en/function.chmod.php
3058
	#參考資料:
3059
	#無.
3060
	#備註:
3061
	#同 function createFolderAfterCheck.
3062
	*/
3063
	public static function createNewFolder(&$conf){
3064
 
3065
		/*
3066
		#函式說明:
3067
		#檢查要建立的檔案路徑是否存在,若不存在則建立新檔案,若檔案已存在則會在原檔名後面加上從(1)開始的編號,再度嘗試建立檔案,以避免資料異常.
3068
		#回傳的結果:
3069
		#$result["status"],執行狀態,"true"代表執行正常,"false"代表執行失敗.
3070
		#$result["error"],錯誤訊息陣列.
3071
		#$result["function"],當前執行的函數名稱.
3072
		#$result["createdFileName"],建立好的檔案名稱.
3073
		#$result["createdFilePath"],檔案建立的路徑.
3074
		#$result["createdFilePathAndName"].建立好的檔案名稱與路徑.
3075
		#必填參數:
3076
		#$conf["checkedFileAndPath"],字串陣列,要建立的檔案路徑
3077
		$conf["checkedFileAndPath"]="";
3078
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3079
		$conf["fileArgu"]=__FILE__;
3080
		*/
3081
		return fileAccess::createFolderAfterCheck($conf);
3082
		unset($conf);
3083
 
3084
		}#function createNewFolder end
3085
 
3086
	/*
3087
	#函式說明:
3088
	#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
3089
	#回傳結果:
3090
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
3091
	#$result["error"],錯誤訊息陣列
3092
	#$result["warning"],警告訊息陣列
3093
	#$result["argu"],使用的參數.
3094
	#$result["content"],建立的目錄路徑.
3095
	#必填參數:
3096
	#$conf["dirPositionAndName"]="";#新建的位置與名稱
3097
	$conf["dirPositionAndName"]="";
3098
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3099
	$conf["fileArgu"]=__FILE__;
3100
	#可省略參數:
3101
	#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
3102
	#$conf["dirPermission"]="";
3103
	#$conf["web"],"false"代表在檔案系統環境,"true"代表在網頁稀系統環境.
3104
	#$conf["web"]="false";
3105
	#參考資料:
3106
	#mkdir=>http://php.net/manual/en/function.mkdir.php
3107
	#chmod=>http://php.net/manual/en/function.chmod.php
3108
	#備註:
3109
	#無.
3110
	*/
3111
	public static function createFolderAfterCheck(&$conf){
3112
 
3113
		#初始化要回傳的結果
3114
		$result=array();
3115
 
3116
		#初始化警告訊息陣列
3117
		$result["warning"]=array();
3118
 
3119
		#記錄當前執行的函數名稱
3120
		$result["function"]=__FUNCTION__;
3121
 
3122
		#如果 $conf 不為陣列
3123
		if(gettype($conf)!="array"){
3124
 
3125
			#設置執行失敗
3126
			$result["status"]="false";
3127
 
3128
			#設置執行錯誤訊息
3129
			$result["error"][]="\$conf變數須為陣列形態";
3130
 
3131
			#如果傳入的參數為 null
3132
			if($conf==null){
3133
 
3134
				#設置執行錯誤訊息
3135
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3136
 
3137
				}#if end
3138
 
3139
			#回傳結果
3140
			return $result;
3141
 
3142
			}#if end
3143
 
3144
		#取得參數
3145
		$result["argu"]=$conf;
3146
 
3147
		#檢查參數
3148
		#函式說明:
3149
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
3150
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3151
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
3152
		#$result["function"],當前執行的函式名稱.
3153
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
3154
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
3155
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
3156
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
3157
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
3158
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
3159
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
3160
		#必填寫的參數:
3161
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
3162
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
3163
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
3164
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","dirPositionAndName");
3165
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
3166
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
3167
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
3168
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
3169
		#可以省略的參數:
3170
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
3171
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
3172
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3173
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("dirPermission","web");
3174
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
3175
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
3176
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3177
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("0770","false");
3178
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3179
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
3180
		#參考資料來源:
3181
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3182
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3183
		unset($conf["variableCheck::checkArguments"]);
3184
 
3185
		#如果 $checkArguments["status"] 等於 "false"
3186
		if($checkArguments["status"]==="false"){
3187
 
3188
			#設置 $result["status"] 為 "false"
3189
			$result["status"]="false";
3190
 
3191
			#設置 $result["error"]
3192
			$result["error"]=$checkArguments;
3193
 
3194
			#回傳結果
3195
			return $result;
3196
 
3197
			}#if end
3198
 
3199
		#如果 $checkArguments["passed"] 等於 "false"
3200
		if($checkArguments["passed"]==="false"){
3201
 
3202
			#設置 $result["status"] 為 "false"
3203
			$result["status"]="false";
3204
 
3205
			#設置 $result["error"]
3206
			$result["error"]=$checkArguments;
3207
 
3208
			#回傳結果
3209
			return $result;
3210
 
3211
			}#if end			
3212
 
3213
		#函式說明:
3214
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
3215
		#回傳結果:
3216
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
3217
		#$result["error"],錯誤訊息陣列.
3218
		#$result["function"],函數名稱. 
3219
		#$result["argu"],使用的參數.
3220
		#$result["content"],網址,若是在命令列執行,則為"null".
3221
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
3222
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
3223
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
3224
		#必填參數:
3225
		#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
3226
		$conf["fileAccess::getInternetAddressV2"]["address"]=$conf["dirPositionAndName"];
3227
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
3228
		$conf["fileAccess::getInternetAddressV2"]["fileArgu"]=$conf["fileArgu"];
3229
		#可省略參數:
3230
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
3231
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
3232
		#備註:
3233
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
3234
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
3235
		unset($conf["fileAccess::getInternetAddressV2"]);
3236
 
3237
		#如果 $getInternetAddressV2["status"] 等於 "false"
3238
		if($getInternetAddressV2["status"]==="false"){
3239
 
3240
			#設置 $result["status"] 為 "false"
3241
			$result["status"]="false";
3242
 
3243
			#設置 $result["error"]
3244
			$result["error"]=$getInternetAddressV2;
3245
 
3246
			#回傳結果
3247
			return $result;
3248
 
3249
			}#if end
3250
 
3251
		#取得絕對位置
3252
		$conf["dirPositionAndName"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
3253
 
3254
		#用「/」分割要建立的路徑
3255
		#函式說明:
3256
		#將固定格式的字串分開,並回傳分開的結果。
3257
		#回傳結果:
3258
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3259
		#$result["error"],錯誤訊息陣列
3260
		#$result["function"],當前執行的函數名稱.
3261
		#$result["oriStr"],要分割的原始字串內容
3262
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
3263
		#$result["dataCounts"],爲總共分成幾段
3264
		#必填參數:
3265
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["dirPositionAndName"];
3266
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
3267
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
3268
		unset($conf["stringProcess::spiltString"]);	
3269
 
3270
		#如果分割失敗
3271
		if($spiltString["status"]=="false"){
3272
 
3273
			#設置 $result["status"] 為 "false"
3274
			$result["status"]="false";
3275
 
3276
			#設置 $result["error"]
3277
			$result["error"]=$spiltString;
3278
 
3279
			#回傳結果
3280
			return $result;
3281
 
3282
			}#if end
3283
 
3284
		$checkedPath="";
3285
 
3286
		#依據切割成的路徑片段數目
3287
		for($i=0;$i<$spiltString["dataCounts"];$i++){
3288
 
3289
			$checkedPath=$checkedPath."/".$spiltString["dataArray"][$i];
3290
 
3291
			#檢查路徑是否存在
3292
			#函式說明:
3293
			#檢查多個檔案與資料夾是否存在.
3294
			#回傳的結果:
3295
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
3296
			#$result["error"],錯誤訊息陣列.
3297
			#$resutl["function"],當前執行的涵式名稱.
3298
			#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
3299
			#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
3300
			#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱。
3301
			#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址
3302
			#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
3303
			#必填參數:
3304
			#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
3305
			$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($checkedPath);
3306
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3307
			$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
3308
			#可省略參數
3309
			#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
3310
			#$conf["disableWebSearch"]="false";
3311
			#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
3312
			#$conf["userDir"]="true";
3313
			#參考資料來源:
3314
			#http://php.net/manual/en/function.file-exists.php
3315
			#http://php.net/manual/en/control-structures.foreach.php
3316
			#備註:
3317
			#函數file_exists檢查的路徑為檔案系統的路徑
3318
			$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
3319
 
3320
			#如果檢查資料夾路徑失敗
3321
			if($checkMultiFileExist["status"]=="false"){
3322
 
3323
				#設置 $result["status"] 為 "false"
3324
				$result["status"]="false";
3325
 
3326
				#設置 $result["error"]
3327
				$result["error"]=$spiltString;
3328
 
3329
				#回傳結果
3330
				return $result;
3331
 
3332
				}#if end
3333
 
3334
			#如果目錄不存在
3335
			if($checkMultiFileExist["allExist"]=="false"){
3336
 
3337
				#如果有這個名稱的東西存在
3338
				if(file_exists($checkedPath)){
3339
 
3340
					#如果目錄存在
3341
					if(is_dir($checkedPath)){
3342
 
3343
						#目錄已經存在換下一層
3344
						continue;
3345
 
3346
						}#if end
3347
 
3348
					}#if end
3349
 
3350
				#建立目錄
3351
				$mkdir=@mkdir($checkedPath,0770);
3352
 
3353
				#如果建立目錄失敗
3354
				#參考資料:
3355
				#http://php.net/manual/en/function.mkdir.php
3356
				if($mkdir===false){
3357
 
3358
					#設置 $result["status"] 為 "false"
3359
					$result["status"]="false";
3360
 
3361
					#設置 $result["error"]
3362
					$result["error"][]="建立目錄「".$checkedPath."」失敗";
3363
 
3364
					#回傳結果
3365
					return $result;
3366
 
3367
					}#if end
3368
 
3369
				#更改目錄的權限為 0770
3370
				chmod($checkedPath,0770);
3371
 
3372
				}#if end
3373
 
3374
			}#for end
3375
 
3376
		#取得建立好的目錄
3377
		$result["content"]=$checkedPath;	
3378
 
3379
		#執行到這邊代表執行成功
3380
		$result["status"]="true";
3381
 
3382
		#回傳結果
3383
		return $result;
3384
 
3385
		}#function createFolderAfterCheck end
3386
 
3387
	/*
3388
	#函式說明:
3389
	#移除檔案
3390
	#回傳結果:
3391
	#$result["status"],"true"代表移除成功,"false"代表移除失敗.
3392
	#$result["error"],錯誤訊息陣列.
3393
	#$result["warning"],警告訊息陣列.
3394
	#$result["function"],當前執行的函數名稱.
3395
	#$result["argu"],當前函式使用的參數.
3396
	#必填參數:
3397
	#$conf["fileAddress"],字串,要移除檔案的位置.
3398
	$conf["fileAddress"]="";
3399
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
3400
	$conf["fileArgu"]=__FILE__;
3401
	#可省略參數:
3402
	#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
3403
	#$conf["commentsArray"]=array("");
3404
	#$conf["allowDelSymlink"],字串,預設為"false",不移除軟連結;"true"代表要移除軟連結.
3405
	#$conf["allowDelSymlink"]="true";
3406
	#$conf["allowDelFolder"],字串,預設為"false",不移除目錄;"true"代表要移除目錄.
3407
	#$conf["allowDelFolder"]="true";
3408
	#參考資料:
3409
	#無.
3410
	#備註:
3411
	#無.
3412
	*/		
3413
	public static function delFile(&$conf){
3414
 
3415
		#初始化要回傳的結果
3416
		$result=array();
3417
 
3418
		#設置當其函數名稱
3419
		$result["function"]=__FUNCTION__;
3420
 
3421
		#如果 $conf 不為陣列
3422
		if(gettype($conf)!="array"){
3423
 
3424
			#設置執行失敗
3425
			$result["status"]="false";
3426
 
3427
			#設置執行錯誤訊息
3428
			$result["error"][]="\$conf變數須為陣列形態";
3429
 
3430
			#如果傳入的參數為 null
3431
			if($conf==null){
3432
 
3433
				#設置執行錯誤訊息
3434
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3435
 
3436
				}#if end
3437
 
3438
			#回傳結果
3439
			return $result;
3440
 
3441
			}#if end
3442
 
3443
		#取得參數
3444
		$result["argu"]=$conf;
3445
 
3446
		#檢查參數
3447
		#函式說明:
3448
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
3449
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3450
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
3451
		#$result["function"],當前執行的函式名稱.
3452
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
3453
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
3454
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
3455
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
3456
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
3457
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
3458
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
3459
		#必填寫的參數:
3460
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
3461
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
3462
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
3463
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileAddress");
3464
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
3465
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
3466
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
3467
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
3468
		#可以省略的參數:
3469
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
3470
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
3471
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3472
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray","allowDelSymlink","allowDelFolder");
3473
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
3474
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string");
3475
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3476
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"false","false");
3477
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3478
		#$conf["arrayCountEqualCheck"][]=array();
3479
		#參考資料來源:
3480
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3481
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3482
		unset($conf["variableCheck::checkArguments"]);
3483
 
3484
		#如果檢查失敗
3485
		if($checkResult["status"]=="false"){
3486
 
3487
			#設置錯誤識別
3488
			$result["status"]="false";
3489
 
3490
			#設置錯誤訊息
3491
			$result["error"]=$checkResult;
3492
 
3493
			#回傳結果
3494
			return $result;
3495
 
3496
			}#if end
3497
 
3498
		#如果檢查不通過
3499
		if($checkResult["passed"]=="false"){
3500
 
3501
			#設置錯誤識別
3502
			$result["status"]="false";
3503
 
3504
			#設置錯誤訊息
3505
			$result["error"]=$checkResult;
3506
 
3507
			#回傳結果
3508
			return $result;
3509
 
3510
			}#if end
3511
 
3512
		#如果 $conf["commentsArray"] 有設定
3513
		if(isset($conf["commentsArray"])){
3514
 
3515
			#印出提示文字
3516
			#函式說明:
3517
			#印出多行文字,結尾自動換行.
3518
			#回傳的結果:
3519
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
3520
			#$result["function"],當前執行的函數名稱.
3521
			#$result["error"],錯誤訊息陣列.
3522
			#必填參數:
3523
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
3524
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
3525
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
3526
			unset($conf["cmd::echoMultiLine"]);
3527
 
3528
			#如果印出提示文字失敗
3529
			if($echoMultiLine["status"]=="false"){
3530
 
3531
				#設置執行失敗
3532
				$result["status"]="false";
3533
 
3534
				#設置執行錯誤訊息
3535
				$result["error"]=$echoMultiLine;
3536
 
3537
				#回傳結果
3538
				return $result;
3539
 
3540
				}#if end
3541
 
3542
			}#if end
3543
 
3544
		#檢查要移除的檔案是否存在
3545
		#函式說明:
3546
		#檢查多個檔案與資料夾是否存在.
3547
		#回傳的結果:
3548
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
3549
		#$result["error"],錯誤訊息陣列.
3550
		#$resutl["function"],當前執行的涵式名稱.
3551
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
3552
		#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
3553
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
3554
		#必填參數:
3555
		$conf["fileAccess.checkMultiFileExist"]["fileArray"]=array($conf["fileAddress"]);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
3556
		#$conf["fileAccess.checkMultiFileExist"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3557
		$conf["fileAccess.checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
3558
		#可省略參數:
3559
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
3560
		#$conf["disableWebSearch"]="false";
3561
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
3562
		#$conf["userDir"]="true";
3563
		#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false",預設為"true".
3564
		$conf["fileAccess.checkMultiFileExist"]["web"]="false";
3565
		#參考資料來源:
3566
		#http://php.net/manual/en/function.file-exists.php
3567
		#http://php.net/manual/en/control-structures.foreach.php
3568
		$checkResult=fileAccess::checkMultiFileExist($conf["fileAccess.checkMultiFileExist"]);
3569
		unset($conf["fileAccess.checkMultiFileExist"]);
3570
 
3571
		#var_dump($checkResult);
3572
 
3573
		#如果檢查檔案是否存在失敗
3574
		if($checkResult["status"]==="false"){
3575
 
3576
			#設置執行失敗
3577
			$result["status"]="false";
3578
 
3579
			#回傳錯誤訊息
3580
			$result["error"]=$checkResult;
3581
 
3582
			#回傳結果
3583
			return $result;
3584
 
3585
			}#if end
3586
 
3587
		#如果目標檔案不存在
3588
		if($checkResult["varExist"][0]==="false"){
3589
 
3590
			#設置錯誤識別
3591
			$result["status"]="true";
3592
 
3593
			#回傳錯誤訊息
3594
			$result["warning"][]="要移除的檔案不存在";
3595
 
3596
			#回傳結果
3597
			return $result;
3598
 
3599
			}#if end
3600
 
3601
		#如果要移除的目標是檔案
3602
		if(is_file($conf["fileAddress"])){
3603
 
3604
			#移除檔案,並回傳移除的結果
3605
			$eraseResult=(@unlink($conf["fileAddress"]));
3606
 
3607
			#如果 $eraseResult 等於 false
3608
			if($eraseResult===false){
3609
 
3610
				#設置錯誤識別
3611
				$result["status"]="false";
3612
 
3613
				#回傳錯誤訊息
3614
				$result["error"][]="檔案移除失敗";
3615
 
3616
				#回傳結果
3617
				return $result;
3618
 
3619
				}#if end
3620
 
3621
			}#if end
3622
 
3623
		#反之要移除的目標是目錄
3624
		else if(is_dir($conf["fileAddress"])){
3625
 
3626
			#如果允許移除目錄
3627
			if($conf["allowDelFolder"]==="true"){
3628
 
3629
				#移除目錄跟底下的內容
3630
				w函式說明:
3631
				#呼叫shell執行系統命令,並取得回傳的內容.
3632
				#回傳結果:
3633
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3634
				#$result["error"],錯誤訊息陣列.
3635
				#$result["function"],當前執行的函數名稱.
3636
				#$result["argu"],使用的參數.
3637
				#$result["cmd"],執行的指令內容.
3638
				#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
3639
				#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
3640
				#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
3641
				#$result["running"],是否還在執行.
3642
				#$result["pid"],pid.
3643
				#$result["statusCode"],執行結束後的代碼.
3644
				#必填參數:
3645
				#$conf["command"],字串,要執行的指令.
3646
				$conf["external::callShell"]["command"]="rm";
3647
				#$conf["fileArgu"],字串,變數__FILE__的內容.
3648
				$conf["external::callShell"]["fileArgu"]=__FILE__;
3649
				#可省略參數:
3650
				#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
3651
				$conf["external::callShell"]["argu"]=array("-rf",$conf["fileAddress"]);
3652
				#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
3653
				#$conf["arguIsAddr"]=array();
3654
				#$conf["plainArgu"],字串陣列,哪幾個參數不要加上"",若為"true"則代表不用包;反之"false"則代表要包.
3655
				#$conf["plainArgu"]=array();
3656
				#$conf["useApostrophe"],字串陣列,如果有需要包住,則用「'」,而非「"」處理.前者為"true";後者為"false".
3657
				#$conf["useApostrophe"]=array();
3658
				#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
3659
				#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
3660
				#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
3661
				#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
3662
				#$conf["enablePrintDescription"]="true";
3663
				#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
3664
				#$conf["printDescription"]="";
3665
				#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
3666
				$conf["external::callShell"]["escapeshellarg"]="true";
3667
				#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
3668
				#$conf["thereIsShellVar"]=array();
3669
				#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
3670
				#$conf["username"]="";
3671
				#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
3672
				#$conf["password"]="";
3673
				#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
3674
				#$conf["useScript"]="";
3675
				#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
3676
				#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
3677
				#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
3678
				#$conf["inBackGround"]="";
3679
				#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
3680
				#$conf["getErr"]="false";
3681
				#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
3682
				#$conf["doNotRun"]="false";
3683
				#參考資料:
3684
				#exec=>http://php.net/manual/en/function.exec.php
3685
				#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
3686
				#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
3687
				#備註:
3688
				#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
3689
				#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
3690
				$callShell=external::callShell($conf["external::callShell"]);
3691
				unset($conf["external::callShell"]);
3692
 
3693
				#如果執行失敗
3694
				if($callShell["status"]==="false"){
3695
 
3696
					#設置錯誤識別
3697
					$result["status"]="false";
3698
 
3699
					#回傳錯誤訊息
3700
					$result["error"]=$callShell;
3701
 
3702
					#回傳結果
3703
					return $result;
3704
 
3705
					}#if end
3706
 
3707
				}#if end	
3708
 
3709
			#反之不允許
3710
			else{
3711
 
3712
				#設置錯誤識別
3713
				$result["status"]="false";
3714
 
3715
				#回傳錯誤訊息
3716
				$result["error"][]="不允許移除目錄";
3717
 
3718
				#回傳結果
3719
				return $result;
3720
 
3721
				}#else end
3722
 
3723
			}#if end
3724
 
3725
		#反之
3726
		else{
3727
 
3728
			#可能為 軟連結
3729
 
3730
			#如果允許移除
3731
			if($conf["allowDelSymlink"]==="true"){
3732
 
3733
				#移除檔案,並回傳移除的結果
3734
				$eraseResult=(@unlink($conf["fileAddress"]));
3735
 
3736
				#如果 $eraseResult 等於 false
3737
				if($eraseResult===false){
3738
 
3739
					#設置錯誤識別
3740
					$result["status"]="false";
3741
 
3742
					#回傳錯誤訊息
3743
					$result["error"][]="檔案移除失敗";
3744
 
3745
					#回傳結果
3746
					return $result;
3747
 
3748
					}#if end
3749
 
3750
				}#if end
3751
 
3752
			#反之
3753
			else{
3754
 
3755
				#設置錯誤識別
3756
				$result["status"]="false";
3757
 
3758
				#設置錯誤訊息
3759
				$result["error"][]="不允許移除 檔案、目錄 以外類型的目標";
3760
 
3761
				#回傳結果
3762
				return $result;
3763
 
3764
				}#else end
3765
 
3766
			}#else end
3767
 
3768
		#執行到這邊代表執行正常.
3769
		$result["status"]="true";
3770
 
3771
		#回傳結果
3772
		return $result;
3773
 
3774
		}#function delFile end
3775
 
3776
	/*
3777
	#函式說明:
3778
	#移除多個檔案
3779
	#回傳結果:
3780
	#$result["status"],"true"代表移除成功,"false"代表移除失敗.
3781
	#$result["error"],錯誤訊息陣列
3782
	#$result["function"],當前執行的函數名稱.
3783
	#$result["argu"],使用的參數.
3784
	#$result["content"],陣列,移除各個檔案的結果.
3785
	#必填參數:
3786
	#$conf["fileAddress"],字串陣列,要移除檔案的位置.
3787
	$conf["fileAddress"]=array("");
3788
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
3789
	$conf["fileArgu"]=__FILE__;
3790
	#可省略參數:
3791
	#無.
3792
	#參考資料:
3793
	#無.
3794
	#備註:
3795
	#無.
3796
	*/		
3797
	public static function delMultiFile(&$conf){
3798
 
3799
		#初始化要回傳的結果
3800
		$result=array();
3801
 
3802
		#設置當其函數名稱
3803
		$result["function"]=__FUNCTION__;
3804
 
3805
		#如果 $conf 不為陣列
3806
		if(gettype($conf)!="array"){
3807
 
3808
			#設置執行失敗
3809
			$result["status"]="false";
3810
 
3811
			#設置執行錯誤訊息
3812
			$result["error"][]="\$conf變數須為陣列形態";
3813
 
3814
			#如果傳入的參數為 null
3815
			if($conf==null){
3816
 
3817
				#設置執行錯誤訊息
3818
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3819
 
3820
				}#if end
3821
 
3822
			#回傳結果
3823
			return $result;
3824
 
3825
			}#if end
3826
 
3827
		#取得使用的參數.
3828
		$result["argu"]=$conf;
3829
 
3830
		#檢查參數
3831
		#函式說明:
3832
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
3833
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3834
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
3835
		#$result["function"],當前執行的函式名稱.
3836
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
3837
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
3838
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
3839
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
3840
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
3841
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
3842
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
3843
		#必填寫的參數:
3844
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
3845
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
3846
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
3847
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","fileAddress");
3848
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
3849
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array");
3850
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
3851
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
3852
		#可以省略的參數:
3853
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
3854
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
3855
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3856
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray");
3857
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
3858
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
3859
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
3860
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
3861
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3862
		#$conf["arrayCountEqualCheck"][]=array();
3863
		#參考資料來源:
3864
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3865
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3866
		unset($conf["variableCheck::checkArguments"]);
3867
 
3868
		#如果檢查失敗
3869
		if($checkResult["status"]=="false"){
3870
 
3871
			#設置錯誤識別
3872
			$result["status"]="false";
3873
 
3874
			#設置錯誤訊息
3875
			$result["error"]=$checkResult;
3876
 
3877
			#回傳結果
3878
			return $result;
3879
 
3880
			}#if end
3881
 
3882
		#如果檢查不通過
3883
		if($checkResult["passed"]=="false"){
3884
 
3885
			#設置錯誤識別
3886
			$result["status"]="false";
3887
 
3888
			#設置錯誤訊息
3889
			$result["error"]=$checkResult;
3890
 
3891
			#回傳結果
3892
			return $result;
3893
 
3894
			}#if end
3895
 
3896
		#針對每個要移除的檔案
3897
		foreach($conf["fileAddress"] as $fileAddr){
3898
 
3899
			#函式說明:
3900
			#移除檔案
3901
			#回傳結果:
3902
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
3903
			#$result["error"],錯誤訊息陣列
3904
			#$result["warning"],警告訊息陣列
3905
			#$result["function"],當前執行的函數名稱
3906
			#必填參數:
3907
			#$conf["fileAddress"],字串,要移除檔案的位置.
3908
			$conf["fileAccess::delFile"]["fileAddress"]=$fileAddr;
3909
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
3910
			$conf["fileAccess::delFile"]["fileArgu"]=$conf["fileArgu"];
3911
			#可省略參數:
3912
			#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
3913
			#$conf["commentsArray"]=array("");
3914
			#備註:
3915
			#無.
3916
			$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
3917
			unset($conf["fileAccess::delFile"]);
3918
 
3919
			#如果檢查失敗
3920
			if($delFile["status"]==="false"){
3921
 
3922
				#設置錯誤識別
3923
				$result["status"]="false";
3924
 
3925
				#設置錯誤訊息
3926
				$result["error"]=$delFile;
3927
 
3928
				#回傳結果
3929
				return $result;
3930
 
3931
				}#if end
3932
 
3933
			#取得移除檔案的結果
3934
			$result["content"][]=$delFile;
3935
 
3936
			}#foreach end
3937
 
3938
		#設置執行正常
3939
		$result["status"]="true";
3940
 
3941
		#回傳結果
3942
		return $result;
3943
 
3944
		}#function delMultiFile end
3945
 
3946
	/*
3947
	#函式說明:
3948
	#確保路徑存在.
3949
	#回傳結果:
3950
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
3951
	#$result["error"],錯誤訊息陣列.
3952
	#$resutl["function"],當前執行的涵式名稱.
3953
	#$result["path"],建立好的路徑字串.
3954
	#$result["fileName"],檔案名稱,若 $conf["haveFileName"] 為 "true" 則會回傳.
3955
	#$result["argu"],使用的參數.
3956
	#必填參數:
3957
	#$conf["path"],要檢查的路徑
3958
	$conf["path"]="";		
3959
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3960
	$conf["fileArgu"]=__FILE__;
3961
	#可省略參數:
3962
	#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
3963
	#$conf["haveFileName"]="false";
3964
	#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人無法使用.
3965
	#$conf["dirPermission"]="";
3966
	#$conf["web"],是否為檔案系統,"true"為網頁路徑,"false"為網頁系統,預設為"false".
3967
	#$conf["web"]="";
3968
	#參考資料:
3969
	#無.
3970
	#備註:
3971
	#無.
3972
	*/ 
3973
	public static function validatePath(&$conf){
3974
 
3975
		#初始化要回傳的結果
3976
		$result=array();
3977
 
3978
		#設置當其函數名稱
3979
		$result["function"]=__FUNCTION__;
3980
 
3981
		#如果 $conf 不為陣列
3982
		if(gettype($conf)!="array"){
3983
 
3984
			#設置執行失敗
3985
			$result["status"]="false";
3986
 
3987
			#設置執行錯誤訊息
3988
			$result["error"][]="\$conf變數須為陣列形態";
3989
 
3990
			#如果傳入的參數為 null
3991
			if($conf==null){
3992
 
3993
				#設置執行錯誤訊息
3994
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3995
 
3996
				}#if end
3997
 
3998
			#回傳結果
3999
			return $result;
4000
 
4001
			}#if end
4002
 
4003
		#取得使用的參數
4004
		$result["argu"]=$conf;	
4005
 
4006
		#檢查參數
4007
		#函式說明:
4008
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
4009
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4010
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
4011
		#$result["function"],當前執行的函式名稱.
4012
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
4013
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
4014
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
4015
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
4016
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
4017
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
4018
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
4019
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
4020
		#必填寫的參數:
4021
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
4022
		$conf["variableCheck::checkArgument"]["varInput"]=&$conf;
4023
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
4024
		$conf["variableCheck::checkArgument"]["mustBeFilledVariableName"]=array("path","fileArgu");
4025
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
4026
		$conf["variableCheck::checkArgument"]["mustBeFilledVariableType"]=array("string","string");
4027
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4028
		$conf["variableCheck::checkArgument"]["referenceVarKey"]="variableCheck::checkArgument";
4029
		#可以省略的參數:
4030
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
4031
		$conf["variableCheck::checkArgument"]["canBeEmptyString"]="false";
4032
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
4033
		$conf["variableCheck::checkArgument"]["skipableVariableCanNotBeEmpty"]=array("haveFileName","dirPermission","web");
4034
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4035
		$conf["variableCheck::checkArgument"]["skipableVariableName"]=array("haveFileName","dirPermission","web");
4036
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
4037
		$conf["variableCheck::checkArgument"]["skipableVariableType"]=array("string","string","string");
4038
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4039
		$conf["variableCheck::checkArgument"]["skipableVarDefaultValue"]=array("false","0770","false");
4040
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4041
		#$conf["arrayCountEqualCheck"][]=array();
4042
		#參考資料來源:
4043
		#array_keys=>http://php.net/manual/en/function.array-keys.php
4044
		$checkArgument=variableCheck::checkArguments($conf["variableCheck::checkArgument"]);
4045
		unset($conf["variableCheck::checkArgument"]);
4046
 
4047
		#如果檢查過程出錯
4048
		if($checkArgument["status"]==="false"){
4049
 
4050
			#設置執行失敗
4051
			$result["status"]="false";
4052
 
4053
			#設置執行錯誤訊息
4054
			$result["error"]=$checkArgument;
4055
 
4056
			#回傳結果
4057
			return $result;
4058
 
4059
			}#if end
4060
 
4061
		#如果檢查不通過
4062
		if($checkArgument["passed"]==="false"){
4063
 
4064
			#設置執行失敗
4065
			$result["status"]="false";
4066
 
4067
			#設置執行錯誤訊息
4068
			$result["error"]=$checkArgument;
4069
 
4070
			#回傳結果
4071
			return $result;
4072
 
4073
			}#if end
4074
 
4075
		#函式說明:
4076
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
4077
		#回傳結果:
4078
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
4079
		#$result["error"],錯誤訊息陣列.
4080
		#$result["function"],函數名稱. 
4081
		#$result["argu"],使用的參數.
4082
		#$result["content"],網址,若是在命令列執行,則為"null".
4083
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
4084
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
4085
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
4086
		#必填參數:
4087
		#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
4088
		$conf["fileAccess::getInternetAddressV2"]["address"]=$conf["path"];
4089
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
4090
		$conf["fileAccess::getInternetAddressV2"]["fileArgu"]=$conf["fileArgu"];
4091
		#可省略參數:
4092
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
4093
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
4094
		#備註:
4095
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
4096
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
4097
		unset($conf["fileAccess::getInternetAddressV2"]);	
4098
 
4099
		#如果檢查過程出錯
4100
		if($getInternetAddressV2["status"]=="false"){
4101
 
4102
			#設置執行失敗
4103
			$result["status"]="false";
4104
 
4105
			#設置執行錯誤訊息
4106
			$result["error"]=$getInternetAddressV2;
4107
 
4108
			#回傳結果
4109
			return $result;
4110
 
4111
			}#if end		
4112
 
4113
		#取得轉換好的絕對路徑
4114
		$result["path"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
4115
 
4116
		#debug
4117
		#var_dump($getInternetAddressV2);exit;
4118
 
4119
		#如果 路徑 含有檔案名稱
4120
		if($conf["haveFileName"]==="true"){
4121
 
4122
			#預設要加回去的結束字串為空字串
4123
			$endStr="";
4124
 
4125
			#如果開頭跟結尾都是 "'"
4126
			if( strpos($result["path"],"'")===0 && strpos($result["path"],"'")===(strlen($result["path"])-1) ){
4127
 
4128
				#設置要加回去的結束字串
4129
				$endStr="'";
4130
 
4131
				}#if end
4132
 
4133
			#函式說明:
4134
			#將固定格式的字串分開,並回傳分開的結果。
4135
			#回傳結果:
4136
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4137
			#$result["error"],錯誤訊息陣列
4138
			#$result["function"],當前執行的函數名稱.
4139
			#$result["argu"],使用的參數.
4140
			#$result["oriStr"],要分割的原始字串內容
4141
			#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
4142
			#$result["dataCounts"],爲總共分成幾段
4143
			#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
4144
			#必填參數:
4145
			#$conf["stringIn"],字串,要處理的字串.
4146
			$conf["stringProcess::spiltString"]["stringIn"]=$result["path"];
4147
			#$conf["spiltSymbol"],字串,爲以哪個符號作爲分割.
4148
			$conf["stringProcess::spiltString"]["spiltSymbol"]="/";
4149
			#可省略參數:
4150
			#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
4151
			$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
4152
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
4153
			unset($conf["stringProcess::spiltString"]);
4154
 
4155
			#如果檢查過程出錯
4156
			if($spiltString["status"]==="false"){
4157
 
4158
				#設置執行失敗
4159
				$result["status"]="false";
4160
 
4161
				#設置執行錯誤訊息
4162
				$result["error"]=$spiltString;
4163
 
4164
				#回傳結果
4165
				return $result;
4166
 
4167
				}#if end
4168
 
4169
			#初始化儲存 path
4170
			$path="";
4171
 
4172
			#針對n-1段的內容
4173
			for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
4174
 
4175
				#串接路徑
4176
				$path=$path."/".$spiltString["dataArray"][$i];
4177
 
4178
				}#for end
4179
 
4180
			#如果路徑為空
4181
			if($path===""){
4182
 
4183
				#則與設為根目錄
4184
				$path="/";
4185
 
4186
				}#if end
4187
 
4188
			#設置檔案名稱
4189
			$result["fileName"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
4190
 
4191
			#取得不含檔案名稱的路徑
4192
			$conf["path"]=$path.$endStr;
4193
 
4194
			#取得不含檔案名稱的路徑
4195
			$result["path"]=$path.$endStr;
4196
 
4197
			}#if end
4198
 
4199
		#函式說明:
4200
		#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
4201
		#回傳結果:
4202
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
4203
		#$result["error"],錯誤訊息陣列
4204
		#必填參數:
4205
		$conf["fileAccess::createFolderAfterCheck"]["dirPositionAndName"]=$conf["path"];#新建的位置與名稱
4206
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4207
		$conf["fileAccess::createFolderAfterCheck"]["fileArgu"]=$conf["fileArgu"];
4208
		#可省略參數:
4209
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
4210
		$conf["fileAccess::createFolderAfterCheck"]["dirPermission"]=$conf["dirPermission"];
4211
		$conf["fileAccess::createFolderAfterCheck"]["web"]="false";
4212
		#參考資料:
4213
		#mkdir=>http://php.net/manual/en/function.mkdir.php
4214
		#chmod=>http://php.net/manual/en/function.chmod.php
4215
		$createFolderAfterCheck=fileAccess::createFolderAfterCheck($conf["fileAccess::createFolderAfterCheck"]);
4216
		unset($conf["fileAccess::createFolderAfterCheck"]);
4217
 
4218
		#如果建立路徑過程出錯
4219
		if($createFolderAfterCheck["status"]==="false"){
4220
 
4221
			#設置執行失敗
4222
			$result["status"]="false";
4223
 
4224
			#設置執行錯誤訊息
4225
			$result["error"]=$createFolderAfterCheck;
4226
 
4227
			#回傳結果
4228
			return $result;
4229
 
4230
			}#if end
4231
 
4232
		#如果有警告訊息
4233
		if(count($createFolderAfterCheck["warning"])>0){
4234
 
4235
			#取得警告訊息
4236
			$result["error"]=$createFolderAfterCheck["warning"];
4237
 
4238
			#設置執行失敗
4239
			$result["status"]="false";
4240
 
4241
			#回傳結果
4242
			return $result;
4243
 
4244
			}#if end
4245
 
4246
		#執行到這邊代表成功
4247
		$result["status"]="true";
4248
 
4249
		#回傳結果
4250
		return $result;
4251
 
4252
		}#function validatePath end
4253
 
4254
	/*
4255
	#函式說明:
4256
	#解析路徑的每個層級.
4257
	#回傳結果:
4258
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
4259
	#$result["error"],錯誤訊息陣列.
4260
	#$resutl["function"],當前執行的涵式名稱.
4261
	#$result["argu"],使用的參數.
4262
	#$result["content"],解析出來的路徑階層.
4263
	#必填參數:
4264
	#$conf["path"],要檢查的路徑
4265
	$conf["path"]="";
4266
	#可省略參數:
4267
	#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
4268
	#$conf["haveFileName"]="false";
4269
	#參考資料:
4270
	#無.
4271
	#備註:
4272
	#無.
4273
	*/
4274
	public static function parsePath(&$conf){
4275
 
4276
		#初始化要回傳的內容
4277
		$result=array();
4278
 
4279
		#取得當前執行的函數名稱
4280
		$result["function"]=__FUNCTION__;
4281
 
4282
		#如果 $conf 不為陣列
4283
		if(gettype($conf)!="array"){
4284
 
4285
			#設置執行失敗
4286
			$result["status"]="false";
4287
 
4288
			#設置執行錯誤訊息
4289
			$result["error"][]="\$conf變數須為陣列形態";
4290
 
4291
			#如果傳入的參數為 null
4292
			if($conf==null){
4293
 
4294
				#設置執行錯誤訊息
4295
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
4296
 
4297
				}#if end
4298
 
4299
			#回傳結果
4300
			return $result;
4301
 
4302
			}#if end
4303
 
4304
		#記錄使用的參數
4305
		$result["argu"]=$conf;
4306
 
4307
		#檢查參數
4308
		#函式說明:
4309
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
4310
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4311
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
4312
		#$result["function"],當前執行的函式名稱.
4313
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
4314
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
4315
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
4316
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
4317
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
4318
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
4319
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
4320
		#必填寫的參數:
4321
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
4322
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
4323
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
4324
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path");
4325
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
4326
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
4327
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4328
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
4329
		#可以省略的參數:
4330
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
4331
		#$conf["canBeEmptyString"]="false";
4332
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4333
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("haveFileName");
4334
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
4335
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
4336
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4337
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
4338
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4339
		#$conf["arrayCountEqualCheck"][]=array();
4340
		#參考資料來源:
4341
		#array_keys=>http://php.net/manual/en/function.array-keys.php
4342
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
4343
		unset($conf["variableCheck::checkArguments"]);
4344
 
4345
		#如果檢查有誤
4346
		if($checkResult["status"]=="false"){
4347
 
4348
			#設置錯誤識別
4349
			$result["status"]="false";
4350
 
4351
			#設置錯誤訊息
4352
			$result["error"]=$checkResult;
4353
 
4354
			#回傳結果
4355
			return $result;
4356
 
4357
			}#if end
4358
 
4359
		#如果檢查不通過
4360
		if($checkResult["passed"]=="false"){
4361
 
4362
			#設置錯誤識別
4363
			$result["status"]="false";
4364
 
4365
			#設置錯誤訊息
4366
			$result["error"]=$checkResult;
4367
 
4368
			#回傳結果
4369
			return $result;
4370
 
4371
			}#if end
4372
 
4373
		#函式說明:
4374
		#將固定格式的字串分開,並回傳分開的結果.
4375
		#回傳結果:
4376
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4377
		#$result["error"],錯誤訊息陣列
4378
		#$result["function"],當前執行的函數名稱.
4379
		#$result["argu"],使用的參數.
4380
		#$result["oriStr"],要分割的原始字串內容
4381
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
4382
		#$result["dataCounts"],爲總共分成幾段
4383
		#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
4384
		#必填參數:
4385
		#$conf["stringIn"],字串,要處理的字串.
4386
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["path"];
4387
		#$conf["spiltSymbol"],字串,爲以哪個符號作爲分割.
4388
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";
4389
		#可省略參數:
4390
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
4391
		#$conf["allowEmptyStr"]="false";
4392
		#參考資料:
4393
		#無.
4394
		#備註:
4395
		#無.
4396
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
4397
		unset($conf["stringProcess::spiltString"]);
4398
 
4399
		#如果檢查有誤
4400
		if($spiltString["status"]==="false"){
4401
 
4402
			#設置錯誤識別
4403
			$result["status"]="false";
4404
 
4405
			#設置錯誤訊息
4406
			$result["error"]=$spiltString;
4407
 
4408
			#回傳結果
4409
			return $result;
4410
 
4411
			}#if end
4412
 
4413
		#確認是否為絕對路徑
4414
		#函式說明:
4415
		#取得符合特定字首與字尾的字串
4416
		#回傳結果:
4417
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
4418
		#$result["function"],當前執行的函數名稱.
4419
		#$result["error"],錯誤訊息陣列.
4420
		#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
4421
		#$result["content"],符合條件的字串,去掉字首字尾後的結果.
4422
		#$result["returnString"],爲符合字首字、尾條件的字串內容。
4423
		#$result["argu"],使用的參數.
4424
		#必填參數:
4425
		#$conf["checkString"],字串,要檢查的字串.
4426
		$conf["search::getMeetConditionsString"]["checkString"]=$conf["path"];
4427
		#可省略參數:
4428
		#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
4429
		$conf["search::getMeetConditionsString"]["frontWord"]="/";
4430
		#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
4431
		#$conf["search::getMeetConditionsString"]["tailWord"]="";
4432
		#參考資料:
4433
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
4434
		#備註:
4435
		#無.
4436
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
4437
		unset($conf["search::getMeetConditionsString"]);
4438
 
4439
		#如果檢查有誤
4440
		if($getMeetConditionsString["status"]==="false"){
4441
 
4442
			#設置錯誤識別
4443
			$result["status"]="false";
4444
 
4445
			#設置錯誤訊息
4446
			$result["error"]=$getMeetConditionsString;
4447
 
4448
			#回傳結果
4449
			return $result;
4450
 
4451
			}#if end
4452
 
4453
		#如果是絕對路徑
4454
		if($getMeetConditionsString["founded"]==="true"){
4455
 
4456
			#初始化路徑為 "/"
4457
			$result["content"][]="/";
4458
 
4459
			}#if end
4460
 
4461
		#針對每個切割出來的路徑階層
4462
		foreach($spiltString["dataArray"] as $index => $dir){
4463
 
4464
			#如果路徑結尾含有檔案名稱
4465
			if($conf["haveFileName"]==="true"){
4466
 
4467
				#如果是最後一段
4468
				if($index===$spiltString["dataCounts"]-1){
4469
 
4470
					#忽略
4471
					continue;
4472
 
4473
					}#if end
4474
 
4475
				}#if end
4476
 
4477
			#後面加上 資料夾名稱 跟 "/"
4478
			$newPath=$dir."/";
4479
 
4480
			#如果有 content
4481
			if(isset($result["content"])){
4482
 
4483
				#如果有上個資料夾
4484
				if(isset($result["content"][count($result["content"])-1])){
4485
 
4486
					#後面加上 上個資料夾名稱 加上資料夾名稱 跟 "/"
4487
					$newPath=$result["content"][count($result["content"])-1].$dir."/";
4488
 
4489
					}#if end
4490
 
4491
				}#if end
4492
 
4493
			#並新增置結果
4494
			$result["content"][]=$newPath;
4495
 
4496
			}#foreach end
4497
 
4498
		#var_dump($result["content"]);
4499
 
4500
		#設置執行正常
4501
		$result["status"]="true";
4502
 
4503
		#回傳結果
4504
		return $result;
4505
 
4506
		}#function parsePath end
4507
 
4508
	/*
4509
	#函式說明:
4510
	#檢查路徑是否存在.
4511
	#回傳結果:
4512
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
4513
	#$result["error"],錯誤訊息陣列.
4514
	#$resutl["function"],當前執行的涵式名稱.
4515
	#$result["argu"],使用的參數.
4516
	#$result["found"],路徑是否存在,"true"代表存在,"false"代表不存在.
4517
	#$result["content"],每個階層路徑的檢查結果,每個元素有檢查的路徑"path"跟是否有存在或可存取的識別"found".
4518
	#必填參數:
4519
	#$conf["path"],要檢查的路徑
4520
	$conf["path"]="";
4521
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4522
	$conf["fileArgu"]=__FILE__;
4523
	#可省略參數:
4524
	#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
4525
	#$conf["haveFileName"]="false";
4526
	#參考資料:
4527
	#無.
4528
	#備註:
4529
	#無.
4530
	*/
4531
	public static function checkPathExist(&$conf){
4532
 
4533
		#初始化要回傳的內容
4534
		$result=array();
4535
 
4536
		#取得當前執行的函數名稱
4537
		$result["function"]=__FUNCTION__;
4538
 
4539
		#如果 $conf 不為陣列
4540
		if(gettype($conf)!="array"){
4541
 
4542
			#設置執行失敗
4543
			$result["status"]="false";
4544
 
4545
			#設置執行錯誤訊息
4546
			$result["error"][]="\$conf變數須為陣列形態";
4547
 
4548
			#如果傳入的參數為 null
4549
			if($conf==null){
4550
 
4551
				#設置執行錯誤訊息
4552
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
4553
 
4554
				}#if end
4555
 
4556
			#回傳結果
4557
			return $result;
4558
 
4559
			}#if end
4560
 
4561
		#記錄使用的參數
4562
		$result["argu"]=$conf;
4563
 
4564
		#檢查參數
4565
		#函式說明:
4566
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
4567
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4568
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
4569
		#$result["function"],當前執行的函式名稱.
4570
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
4571
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
4572
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
4573
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
4574
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
4575
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
4576
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
4577
		#必填寫的參數:
4578
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
4579
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
4580
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
4581
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
4582
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
4583
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
4584
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4585
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
4586
		#可以省略的參數:
4587
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
4588
		#$conf["canBeEmptyString"]="false";
4589
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4590
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("haveFileName");
4591
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
4592
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
4593
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4594
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
4595
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4596
		#$conf["arrayCountEqualCheck"][]=array();
4597
		#參考資料來源:
4598
		#array_keys=>http://php.net/manual/en/function.array-keys.php
4599
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
4600
		unset($conf["variableCheck::checkArguments"]);
4601
 
4602
		#如果檢查有誤
4603
		if($checkResult["status"]=="false"){
4604
 
4605
			#設置錯誤識別
4606
			$result["status"]="false";
4607
 
4608
			#設置錯誤訊息
4609
			$result["error"]=$checkResult;
4610
 
4611
			#回傳結果
4612
			return $result;
4613
 
4614
			}#if end
4615
 
4616
		#如果檢查不通過
4617
		if($checkResult["passed"]=="false"){
4618
 
4619
			#設置錯誤識別
4620
			$result["status"]="false";
4621
 
4622
			#設置錯誤訊息
4623
			$result["error"]=$checkResult;
4624
 
4625
			#回傳結果
4626
			return $result;
4627
 
4628
			}#if end
4629
 
4630
		#函式說明:
4631
		#解析路徑的每個層級.
4632
		#回傳結果:
4633
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
4634
		#$result["error"],錯誤訊息陣列.
4635
		#$resutl["function"],當前執行的涵式名稱.
4636
		#$result["argu"],使用的參數.
4637
		#$result["content"],解析出來的路徑階層.
4638
		#必填參數:
4639
		#$conf["path"],要檢查的路徑
4640
		$conf["fileAccess::parsePath"]["path"]=$conf["path"];
4641
		#可省略參數:
4642
		#$conf["haveFileName"],字串,"true"代表有$conf["path"]檔案名稱,"false"代表$conf["path"]為純路徑,預設為"false".
4643
		$conf["fileAccess::parsePath"]["haveFileName"]=$conf["haveFileName"];
4644
		#參考資料:
4645
		#無.
4646
		#備註:
4647
		#無.
4648
		$parsePath=fileAccess::parsePath($conf["fileAccess::parsePath"]);
4649
		unset($conf["fileAccess::parsePath"]);
4650
 
4651
		#如果檢查有誤
4652
		if($parsePath["status"]==="false"){
4653
 
4654
			#設置錯誤識別
4655
			$result["status"]="false";
4656
 
4657
			#設置錯誤訊息
4658
			$result["error"]=$parsePath;
4659
 
4660
			#回傳結果
4661
			return $result;
4662
 
4663
			}#if end
4664
 
4665
		#函式說明:
4666
		#檢查多個檔案與資料夾是否存在.
4667
		#回傳的結果:
4668
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
4669
		#$result["error"],錯誤訊息陣列.
4670
		#$resutl["function"],當前執行的涵式名稱.
4671
		#$result["argu"],使用的參數.
4672
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
4673
		#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
4674
		#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
4675
		#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
4676
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
4677
		#必填參數:
4678
		#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
4679
		$conf["fileAccess::checkMultiFileExist"]["fileArray"]=$parsePath["content"];
4680
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4681
		$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
4682
		#可省略參數:
4683
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
4684
		$conf["fileAccess::checkMultiFileExist"]["disableWebSearch"]="true";
4685
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
4686
		$conf["fileAccess::checkMultiFileExist"]["userDir"]="false";
4687
		#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false",預設為"true".
4688
		$conf["fileAccess::checkMultiFileExist"]["web"]="false";
4689
		#參考資料:
4690
		#http://php.net/manual/en/function.file-exists.php
4691
		#http://php.net/manual/en/control-structures.foreach.php
4692
		#備註:
4693
		#函數file_exists檢查的路徑為檔案系統的路徑
4694
		#$result["varName"][$i]結果未實作
4695
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
4696
		unset($conf["fileAccess::checkMultiFileExist"]);
4697
 
4698
		#如果執行異常
4699
		if($checkMultiFileExist["status"]==="false"){
4700
 
4701
			#設置錯誤識別
4702
			$result["status"]="false";
4703
 
4704
			#設置錯誤訊息
4705
			$result["error"]=$checkMultiFileExist;
4706
 
4707
			#回傳結果
4708
			return $result;
4709
 
4710
			}#if end
4711
 
4712
		#如果有路徑無法存取
4713
		if($checkMultiFileExist["allExist"]==="false"){
4714
 
4715
			#設置執行正常識別
4716
			$result["status"]="true";
4717
 
4718
			#設置路徑找不到
4719
			$result["found"]="false";
4720
 
4721
			#針對每個路徑的搜尋結果
4722
			foreach($checkMultiFileExist["varExist"] as $index => $found){
4723
 
4724
				#設置路徑尋找結果
4725
				$result["content"][]=array("found"=>$found,"path"=>$checkMultiFileExist["varNameFullPath"][$index]);
4726
 
4727
				}#foreach end
4728
 
4729
			#回傳結果
4730
			return $result;
4731
 
4732
			}#if end
4733
 
4734
		#設置路徑有找到
4735
		$result["found"]="true";
4736
 
4737
		#設置執行正常識別
4738
		$result["status"]="true";
4739
 
4740
		#回傳結果
4741
		return $result;
4742
 
4743
		}#function checkPathExist end
4744
 
4745
	/*	
4746
	#函式說明:
4747
	#demo建立pdf檔
4748
	#必填參數:
4749
	#無
4750
	#可省略參數:
4751
	#無
4752
	#參考資料:
4753
	#tcpdf=>http://www.tcpdf.org/examples.php
4754
	#備註:
4755
	#開發中,需要安裝 php-tcpdf 套件.
4756
	*/
4757
	public static function demoCreateTcPdfFile(){
4758
 
4759
		#避免 TCPDF ERROR: Some data has already been output, can't send PDF file 錯誤產生
4760
		ob_end_clean();
4761
 
4762
		#create new PDF document
4763
		$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
4764
 
4765
		#set document information
4766
		$pdf->SetCreator(PDF_CREATOR);
4767
		$pdf->SetAuthor('qbpwc');
4768
		$pdf->SetTitle('pdf sample title');
4769
		$pdf->SetSubject('pdf sample subject');
4770
		$pdf->SetKeywords('pdf, sample, tcpdf, qbpwc');
4771
 
4772
		#set default header data
4773
		$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
4774
		$pdf->setFooterData(array(0,64,0), array(0,64,128));
4775
 
4776
		#set header and footer fonts
4777
		$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
4778
		$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
4779
 
4780
		#set default monospaced font
4781
		$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
4782
 
4783
		#set margins
4784
		$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
4785
		$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
4786
		$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
4787
 
4788
		#set auto page breaks
4789
		$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
4790
 
4791
		#set image scale factor
4792
		$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
4793
 
4794
		#set some language-dependent strings (optional)
4795
		if (@file_exists(dirname(__FILE__).'/lang/eng.php')){
4796
 
4797
			require_once(dirname(__FILE__).'/lang/eng.php');
4798
 
4799
			$pdf->setLanguageArray($l);
4800
 
4801
			}#if end
4802
 
4803
		#set default font subsetting mode
4804
		$pdf->setFontSubsetting(true);
4805
 
4806
		#Set font
4807
		#dejavusans is a UTF-8 Unicode font, if you only need to
4808
		#print standard ASCII chars, you can use core fonts like
4809
		#helvetica or times to reduce file size.
4810
		$pdf->SetFont('dejavusans', '', 14, '', true);
4811
 
4812
		#Add a page
4813
		#This method has several options, check the source code documentation for more information.
4814
		$pdf->AddPage();
4815
 
4816
		#set text shadow effect
4817
		$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
4818
 
4819
		#Set some content to print
4820
		$html="<h5>Hello World!</h5>";
4821
 
4822
		// Print text using writeHTMLCell()
4823
		$pdf->writeHTMLCell(0,0,'','',$html,0,1,0,true,'',true);
4824
 
4825
		// Close and output PDF document
4826
		// This method has several options, check the source code documentation for more information.
4827
		$pdf->Output('fileAccessT/example_001.pdf','I');
4828
 
4829
		}#function demoCreateTcPdfFile end
4830
 
4831
	/*
4832
	#函式說明:
4833
	#取得檔案路徑字串的路徑與檔案的名稱與檔案副檔名
4834
	#回傳的結果:
4835
	#$result["status"],執行是否正常,"true"正常,"false"代表不正常.
4836
	#$result["error"],錯誤訊息.
4837
	#$result["function"],當前執行的函式名稱.
4838
	#$result["filePath"],路徑字串.
4839
	#$result["fileName"],檔案名稱字串.
4840
	#$result["fileExtention"],檔案的副檔名.
4841
	#$result["fullFileName"],含副檔名的檔案名稱.
4842
	#$result["fullFilePathAndName"],完整的檔案路徑(含副檔名).
4843
	#必填參數:
4844
	#$conf["fileAddressAndName"],字串,檔案名稱與其路徑.
4845
	$conf["fileAddressAndName"]="";
4846
	#可省略參數:
4847
	#無.
4848
	#參考資料:
4849
	#無.
4850
	#備註:
4851
	#無.
4852
	*/
4853
	public static function getFileAddressAndNameAndFileExtention(&$conf){
4854
 
4855
		#初始化要回傳的參數
4856
		$result=array();
4857
 
4858
		#取得當前執行函數名稱
4859
		$result["function"]=__FUNCTION__;
4860
 
4861
		#如果 $conf 不為陣列
4862
		if(gettype($conf)!="array"){
4863
 
4864
			#設置執行失敗
4865
			$result["status"]="false";
4866
 
4867
			#設置執行錯誤訊息
4868
			$result["error"][]="\$conf變數須為陣列形態";
4869
 
4870
			#如果傳入的參數為 null
4871
			if($conf==null){
4872
 
4873
				#設置執行錯誤訊息
4874
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
4875
 
4876
				}#if end
4877
 
4878
			#回傳結果
4879
			return $result;
4880
 
4881
			}#if end
4882
 
4883
		#檢查參數
4884
		#函式說明:
4885
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
4886
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4887
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
4888
		#$result["function"],當前執行的函式名稱.
4889
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
4890
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
4891
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
4892
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
4893
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
4894
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
4895
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
4896
		#必填寫的參數:
4897
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
4898
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
4899
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
4900
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileAddressAndName");
4901
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
4902
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
4903
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
4904
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
4905
		#可以省略的參數:
4906
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
4907
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
4908
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
4909
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("outputAddress","noDownload");
4910
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
4911
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
4912
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
4913
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(".bin/".$conf["cppAddress"].".bin","true");
4914
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
4915
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
4916
		#參考資料來源:
4917
		#array_keys=>http://php.net/manual/en/function.array-keys.php
4918
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
4919
		unset($conf["variableCheck::checkArguments"]);
4920
 
4921
		#如果 $checkArguments["status"] 等於 "false"
4922
		if($checkArguments["status"]=="false"){
4923
 
4924
			#設置 $result["status"] 為 "false"
4925
			$result["status"]="false";
4926
 
4927
			#設置 $result["error"]
4928
			$result["error"]=$checkArguments;
4929
 
4930
			#回傳結果
4931
			return $result;
4932
 
4933
			}#if end
4934
 
4935
		#如果 $checkArguments["passed"] 等於 "false"
4936
		if($checkArguments["passed"]=="false"){
4937
 
4938
			#設置 $result["status"] 為 "false"
4939
			$result["status"]="false";
4940
 
4941
			#設置 $result["error"]
4942
			$result["error"]=$checkArguments;
4943
 
4944
			#回傳結果
4945
			return $result;
4946
 
4947
			}#if end
4948
 
4949
		#確認路徑是否為絕對路徑
4950
		#函式說明:
4951
		#取得符合特定字首與字尾的字串
4952
		#回傳結果:
4953
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
4954
		#$result["function"],當前執行的函數名稱.
4955
		#$result["error"],錯誤訊息陣列.
4956
		#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
4957
		#$result["content"],符合條件的字串,去掉字首字尾後的結果.
4958
		#$result["returnString"],爲符合字首字、尾條件的字串內容。
4959
		#$result["argu"],使用的參數.
4960
		#必填參數:
4961
		#$conf["checkString"],字串,要檢查的字串.
4962
		$conf["fileAccess::getMeetConditionsString"]["checkString"]=$conf["fileAddressAndName"];
4963
		#可省略參數:
4964
		#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
4965
		$conf["fileAccess::getMeetConditionsString"]["frontWord"]="/";
4966
		#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
4967
		#$conf["tailWord"]="";
4968
		#參考資料:
4969
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
4970
		#備註:
4971
		#無.
4972
		$getMeetConditionsString=search::getMeetConditionsString($conf["fileAccess::getMeetConditionsString"]);
4973
		unset($conf["fileAccess::getMeetConditionsString"]);
4974
 
4975
		#如果執行出錯
4976
		if($getMeetConditionsString["status"]==="false"){
4977
 
4978
			#設置錯誤識別
4979
			$result["status"]="false";
4980
 
4981
			#設置錯誤訊息
4982
			$result["error"]=$getMeetConditionsString;
4983
 
4984
			#回傳結果
4985
			return $result;
4986
 
4987
			}#if end
4988
 
4989
		#預設參數 $conf["fileAddressAndName"] 不為 "/" 開始
4990
		$fileAddressAndNameStarFromRoot="true";
4991
 
4992
		#如果是 "/" 開頭
4993
		if($getMeetConditionsString["founded"]==="false"){
4994
 
4995
			#設置參數 $conf["fileAddressAndName"] 為 "/" 開始
4996
			$fileAddressAndNameStarFromRoot="true";
4997
 
4998
			}#if end
4999
 
5000
		#檢查是否有路徑資訊 
5001
		#函式說明:
5002
		#將固定格式的字串分開,並回傳分開的結果。
5003
		#回傳的參數:
5004
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5005
		#$result["error"],錯誤訊息陣列
5006
		#$result["oriStr"],要分割的原始字串內容
5007
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
5008
		#$result["dataCounts"],爲總共分成幾段
5009
		#必填參數:
5010
		$conf["stringProcess"]["spiltString"]["stringIn"]=$conf["fileAddressAndName"];#要處理的字串。
5011
		$conf["stringProcess"]["spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
5012
		$spiledResult=stringProcess::spiltString($conf["stringProcess"]["spiltString"]);
5013
		unset($conf["stringProcess"]["spiltString"]);
5014
 
5015
		#如果 $spiledResult["status"] 等於 "false"
5016
		if($spiledResult["status"]==="false"){
5017
 
5018
			#設置錯誤識別
5019
			$result["status"]="false";
5020
 
5021
			#設置錯誤訊息
5022
			$result["error"]=$spiledResult;
5023
 
5024
			#回傳結果
5025
			return $result;
5026
 
5027
			}#if end
5028
 
5029
		#如果 $spiledResult["dataCounts"] 大於 1
5030
		if($spiledResult["dataCounts"]>1){
5031
 
5032
			#代表有路徑字串
5033
 
5034
			#初始化路徑字串暫存變數
5035
			$tempPathStr="";
5036
 
5037
			#如果是絕對路徑
5038
			if($fileAddressAndNameStarFromRoot==="true"){
5039
 
5040
				#加上根目錄
5041
				$tempPathStr=$tempPathStr."/";
5042
 
5043
				}#if end
5044
 
5045
			#取得路徑字串
5046
			for($i=0;$i<$spiledResult["dataCounts"]-1;$i++){
5047
 
5048
				#串連片段路徑字串
5049
				$tempPathStr=$tempPathStr.$spiledResult["dataArray"][$i]."/";
5050
 
5051
				}#for end
5052
 
5053
			#取得檔案的路徑
5054
			$result["filePath"]=$tempPathStr;
5055
 
5056
			}#if end
5057
 
5058
		#反之 $spiledResult["dataCounts"] 等於 1
5059
		else{
5060
 
5061
			#檔案的路徑設為""
5062
			$result["filePath"]="";
5063
 
5064
			}#else end
5065
 
5066
		#取得檔案名稱(含副檔名)
5067
		$result["fullFileName"]=$spiledResult["dataArray"][$spiledResult["dataCounts"]-1];
5068
 
5069
		#取得副檔名
5070
		#函式說明:
5071
		#將固定格式的字串分開,並回傳分開的結果。
5072
		#回傳的參數:
5073
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5074
		#$result["error"],錯誤訊息陣列
5075
		#$result["oriStr"],要分割的原始字串內容
5076
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
5077
		#$result["dataCounts"],爲總共分成幾段
5078
		#必填參數:
5079
		$conf["stringProcess"]["spiltString"]["stringIn"]=$result["fullFileName"];#要處理的字串。
5080
		$conf["stringProcess"]["spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
5081
		$spiledResult=stringProcess::spiltString($conf["stringProcess"]["spiltString"]);
5082
		unset($conf["stringProcess"]["spiltString"]);
5083
 
5084
		#如果 $spiledResult["status"] 等於 "false"
5085
		if($spiledResult["status"]=="false"){
5086
 
5087
			#設置錯誤識別
5088
			$result["status"]="false";
5089
 
5090
			#設置錯誤訊息
5091
			$result["error"]=$spiledResult;
5092
 
5093
			#回傳結果
5094
			return $result;
5095
 
5096
			}#if end
5097
 
5098
		#如果 $spiledResult["dataCounts"] 大於 1
5099
		if($spiledResult["dataCounts"]>1){
5100
 
5101
			#代表有副檔名
5102
 
5103
			#初始化檔名字串暫存變數
5104
			$tempFileNameStr="";
5105
 
5106
			#取得路徑字串
5107
			for($i=0;$i<$spiledResult["dataCounts"]-1;$i++){
5108
 
5109
				#如果是最後一個小黑點前面的字串片段
5110
				if($i==$spiledResult["dataCounts"]-2){
5111
 
5112
					#串連片段路徑字串
5113
					$tempFileNameStr=$tempFileNameStr.$spiledResult["dataArray"][$i];
5114
 
5115
					}#if end
5116
 
5117
				#反之不是最後一個小黑點前面的字串片段
5118
				else{
5119
 
5120
					#串連片段路徑字串(含小黑點)
5121
					$tempFileNameStr=$tempFileNameStr.$spiledResult["dataArray"][$i].".";
5122
 
5123
					}#else end
5124
 
5125
				}#for end
5126
 
5127
			#取得檔名
5128
			$result["fileName"]=$tempFileNameStr;
5129
 
5130
			#取得副檔名
5131
			$result["fileExtention"]=$spiledResult["dataArray"][$spiledResult["dataCounts"]-1];
5132
 
5133
			}#if end
5134
 
5135
		#反之 $spiledResult["dataCounts"] 等於 1
5136
		else{
5137
 
5138
			#檔案的副檔名設為""
5139
			$result["fileExtention"]="";
5140
 
5141
			#取得檔案的名稱
5142
			$result["fileName"]=$spiledResult["dataArray"][0];
5143
 
5144
			}#else end
5145
 
5146
		#如果 $result["fileExtention"] 不等於 ""
5147
		if($result["fileExtention"]!=""){
5148
 
5149
			#將副檔名用小黑點跟檔案名稱連在一塊
5150
			$result["fullFileName"]=$result["fileName"].".".$result["fileExtention"];
5151
 
5152
			}#if end
5153
 
5154
		#反之代表沒有副檔名
5155
		else{
5156
 
5157
			#取得含副檔名的檔案名稱
5158
			$result["fullFileName"]=$result["fileName"].$result["fileExtention"];
5159
 
5160
			}#else end
5161
 
5162
		#完整的檔案路徑(含副檔名).
5163
		$result["fullFilePathAndName"]=$result["filePath"].$result["fullFileName"];
5164
 
5165
		#設置執行正常的識別
5166
		$result["status"]="true";
5167
 
5168
		#回傳結果
5169
		return $result;
5170
 
5171
		}#funciton getFileAddressAndNameAndFileExtention end
5172
 
5173
	/*
5174
	#函式說明:
5175
	#將資料夾或檔案打包成tar檔案
5176
	#回傳結果:
5177
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5178
	#$result["function"],當前執行的函數名稱
5179
	#$result["error"],錯誤訊息.
5180
	#$result["content"],檔案輸出後的位置與名稱.
5181
	#必填參數:
5182
	#$conf["packetTarget"],陣列,要打包的每個資料夾與檔案位置
5183
	$conf["packetTarget"]=array("");
5184
	#$conf["createdTarFile"],字串,打包好的檔案要放在哪裡,副檔名.tar會自動加上.
5185
	$conf["createdTarFile"]="";
5186
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5187
	$conf["fileArgu"]=__FILE__;
5188
	#可省略參數:
5189
	#無.
5190
	#參考資料:
5191
	#無.
5192
	#備註:
5193
	#無.
5194
	*/
5195
	public static function makeTarFile(&$conf){
5196
 
5197
		#初始化要回傳的內容
5198
		$result=array();
5199
 
5200
		#記錄當前執行的函數名稱
5201
		$result["function"]=__FUNCTION__;
5202
 
5203
		#如果 $conf 不為陣列
5204
		if(gettype($conf)!="array"){
5205
 
5206
			#設置執行失敗
5207
			$result["status"]="false";
5208
 
5209
			#設置執行錯誤訊息
5210
			$result["error"][]="\$conf變數須為陣列形態";
5211
 
5212
			#如果傳入的參數為 null
5213
			if($conf==null){
5214
 
5215
				#設置執行錯誤訊息
5216
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
5217
 
5218
				}#if end
5219
 
5220
			#回傳結果
5221
			return $result;
5222
 
5223
			}#if end
5224
 
5225
		#檢查參數
5226
		#函式說明:
5227
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
5228
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5229
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
5230
		#$result["function"],當前執行的函式名稱.
5231
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
5232
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
5233
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
5234
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
5235
		#必填寫的參數:
5236
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
5237
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
5238
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
5239
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","packetTarget","createdTarFile");
5240
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
5241
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array","string");
5242
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
5243
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
5244
		#可以省略的參數:
5245
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
5246
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
5247
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
5248
		#$conf["skipableVariableName"]=array();
5249
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
5250
		#$conf["skipableVariableType"]=array();
5251
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
5252
		#$conf["skipableVarDefaultValue"]=array("");
5253
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
5254
		#$conf["arrayCountEqualCheck"][]=array();
5255
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
5256
		unset($conf["variableCheck::checkArguments"]);
5257
 
5258
		#若檢查失敗
5259
		if($checkResult["status"]=="false"){
5260
 
5261
			#設置執行失敗
5262
			$result["status"]="false";
5263
 
5264
			#設置執行錯誤訊息
5265
			$result["error"]=$checkResult;
5266
 
5267
			#回傳結果
5268
			return $result;
5269
 
5270
			}#if end
5271
 
5272
		#若檢查不通過
5273
		if($checkResult["passed"]=="false"){
5274
 
5275
			#設置執行失敗
5276
			$result["status"]="false";
5277
 
5278
			#設置執行錯誤訊息
5279
			$result["error"]=$checkResult;
5280
 
5281
			#回傳結果
5282
			return $result;
5283
 
5284
			}#if end
5285
 
5286
		#初始化打包要用的tar指令參數
5287
		$paramsArray=array("-cvf",$conf["createdTarFile"].".tar");
5288
 
5289
		#檢查要打包的檔案是否存在
5290
		#函式說明:
5291
		#檢查多個檔案與資料夾是否存在.
5292
		#回傳的結果:
5293
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
5294
		#$result["error"],錯誤訊息陣列.
5295
		#$resutl["function"],當前執行的涵式名稱.
5296
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
5297
		#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
5298
		#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱。
5299
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
5300
		#必填參數:
5301
		#$conf["fileArray"],陣列字串,要檢查書否存在的檔案有哪些,須爲一維陣列數值。
5302
		$conf["fileAccess::checkMultiFileExist"]["fileArray"]=$conf["packetTarget"];
5303
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5304
		$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
5305
		#可省略參數
5306
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
5307
		#$conf["disableWebSearch"]="false";
5308
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
5309
		#$conf["userDir"]="true";
5310
		#參考資料來源:
5311
		#http://php.net/manual/en/function.file-exists.php
5312
		#http://php.net/manual/en/control-structures.foreach.php
5313
		#備註:
5314
		#函數file_exists檢查的路徑為檔案系統的路徑
5315
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
5316
		unset($conf["fileAccess::checkMultiFileExist"]);
5317
 
5318
		#如果檢查要打包的檔案失敗
5319
		if($checkMultiFileExist["status"]=="false"){
5320
 
5321
			#設置執行失敗
5322
			$result["status"]="false";
5323
 
5324
			#設置執行錯誤訊息
5325
			$result["error"]=$checkMultiFileExist;
5326
 
5327
			#回傳結果
5328
			return $result;
5329
 
5330
			}#if end
5331
 
5332
		#如果要打包的檔案有缺
5333
		if($checkMultiFileExist["allExist"]=="false"){
5334
 
5335
			#設置執行失敗
5336
			$result["status"]="false";
5337
 
5338
			#設置執行錯誤訊息
5339
			$result["error"]=$checkMultiFileExist;
5340
 
5341
			#回傳結果
5342
			return $result;
5343
 
5344
			}#if end
5345
 
5346
		#有幾個要打包的目標就執行幾次
5347
		for($i=0;$i<count($conf["packetTarget"]);$i++){
5348
 
5349
			#串接上要打包的檔案或資料夾
5350
			$paramsArray[]=$conf["packetTarget"][$i];
5351
 
5352
			}#for end
5353
 
5354
		#函式說明:
5355
		#呼叫shell執行系統命令,並取得回傳的內容.
5356
		#回傳結果:
5357
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5358
		#$result["error"],錯誤訊息陣列.
5359
		#$result["function"],當前執行的函數名稱.
5360
		#$result["argu"],使用的參數.
5361
		#$result["cmd"],執行的指令內容.
5362
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
5363
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
5364
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
5365
		#$result["running"],是否還在執行.
5366
		#$result["pid"],pid.
5367
		#$result["statusCode"],執行結束後的代碼.
5368
		#$result["escape"],陣列,儲存出新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu").
5369
		#必填參數:
5370
		#$conf["command"],字串,要執行的指令.
5371
		$conf["external::callShell"]["command"]="tar";
5372
		#$conf["fileArgu"],字串,變數__FILE__的內容.
5373
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
5374
		#可省略參數:
5375
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
5376
		$conf["external::callShell"]["argu"]=$paramsArray;
5377
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
5378
		#$conf["arguIsAddr"]=array();
5379
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
5380
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
5381
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
5382
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
5383
		#$conf["enablePrintDescription"]="true";
5384
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
5385
		#$conf["printDescription"]="";
5386
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
5387
		$conf["external::callShell"]["escapeshellarg"]="true";
5388
		#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
5389
		#$conf["thereIsShellVar"]=array();
5390
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
5391
		#$conf["username"]="";
5392
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
5393
		#$conf["password"]="";
5394
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
5395
		#$conf["useScript"]="";
5396
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
5397
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
5398
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
5399
		#$conf["inBackGround"]="";
5400
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
5401
		#$conf["getErr"]="false";
5402
		#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
5403
		#$conf["doNotRun"]="false";
5404
		#參考資料:
5405
		#exec=>http://php.net/manual/en/function.exec.php
5406
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
5407
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
5408
		#備註:
5409
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
5410
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
5411
		$conf["external::callShell"]=external::callShell($conf["external::callShell"]);
5412
		unset($conf["external::callShell"]);
5413
 
5414
		#如果執行shell失敗
5415
		if($callShell["status"]=="false"){
5416
 
5417
			#設置執行失敗
5418
			$result["status"]="false";
5419
 
5420
			#設置執行錯誤訊息
5421
			$result["error"]=$callShell;
5422
 
5423
			#回傳結果
5424
			return $result;
5425
 
5426
			}#if end
5427
 
5428
		#打包好的檔案位置與名稱
5429
		$result["content"]=$conf["createdTarFile"].".tar";
5430
 
5431
		#執行到這邊代表執行正常
5432
		$result["status"]="true";
5433
 
5434
		#回傳結果
5435
		return $result;
5436
 
5437
		}#function makeTarFile end
5438
 
5439
	/*
5440
	#函式說明:
5441
	#將一個檔案壓縮成xz檔案
5442
	#回傳結果:
5443
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5444
	#$result["function"],當前執行的函數名稱
5445
	#$result["error"],錯誤訊息.
5446
	#$result["content"],檔案輸出後的位置與名稱.
5447
	#必填參數:
5448
	#$conf["compressTarget"],字串,要打包的每個資料夾與檔案位置
5449
	$conf["compressTarget"]="";
5450
	#$conf["createdXzFile"],字串,打包好的檔案要放在哪裡,副檔名.xz會自動加上.
5451
	$conf["createdXzFile"]="";
5452
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5453
	$conf["fileArgu"]=__FILE__;
5454
	#可省略參數:
5455
	#無.
5456
	#參考資料:
5457
	#無.
5458
	#備註:
5459
	#無.
5460
	*/
5461
	public static function makeXzFile(&$conf){
5462
 
5463
		#初始化要回傳的內容
5464
		$result=array();
5465
 
5466
		#記錄當前執行的函數名稱
5467
		$result["function"]=__FUNCTION__;
5468
 
5469
		#如果 $conf 不為陣列
5470
		if(gettype($conf)!="array"){
5471
 
5472
			#設置執行失敗
5473
			$result["status"]="false";
5474
 
5475
			#設置執行錯誤訊息
5476
			$result["error"][]="\$conf變數須為陣列形態";
5477
 
5478
			#如果傳入的參數為 null
5479
			if($conf==null){
5480
 
5481
				#設置執行錯誤訊息
5482
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
5483
 
5484
				}#if end
5485
 
5486
			#回傳結果
5487
			return $result;
5488
 
5489
			}#if end
5490
 
5491
		#檢查參數
5492
		#函式說明:
5493
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
5494
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5495
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
5496
		#$result["function"],當前執行的函式名稱.
5497
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
5498
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
5499
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
5500
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
5501
		#必填寫的參數:
5502
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
5503
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
5504
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
5505
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","compressTarget","createdXzFile");
5506
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
5507
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
5508
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
5509
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
5510
		#可以省略的參數:
5511
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
5512
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
5513
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
5514
		#$conf["skipableVariableName"]=array();
5515
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
5516
		#$conf["skipableVariableType"]=array();
5517
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
5518
		#$conf["skipableVarDefaultValue"]=array("");
5519
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
5520
		#$conf["arrayCountEqualCheck"][]=array();
5521
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
5522
		unset($conf["variableCheck::checkArguments"]);
5523
 
5524
		#若檢查失敗
5525
		if($checkResult["status"]=="false"){
5526
 
5527
			#設置執行失敗
5528
			$result["status"]="false";
5529
 
5530
			#設置執行錯誤訊息
5531
			$result["error"]=$checkResult;
5532
 
5533
			#回傳結果
5534
			return $result;
5535
 
5536
			}#if end
5537
 
5538
		#若檢查不通過
5539
		if($checkResult["passed"]=="false"){
5540
 
5541
			#設置執行失敗
5542
			$result["status"]="false";
5543
 
5544
			#設置執行錯誤訊息
5545
			$result["error"]=$checkResult;
5546
 
5547
			#回傳結果
5548
			return $result;
5549
 
5550
			}#if end
5551
 
5552
		#檢查要用xz壓縮的檔案是否存在
5553
		#函式說明:
5554
		#檢查多個檔案與資料夾是否存在.
5555
		#回傳的結果:
5556
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
5557
		#$result["error"],錯誤訊息陣列.
5558
		#$resutl["function"],當前執行的涵式名稱.
5559
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
5560
		#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
5561
		#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱。
5562
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
5563
		#必填參數:
5564
		#$conf["fileArray"],陣列字串,要檢查書否存在的檔案有哪些,須爲一維陣列數值。
5565
		$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["compressTarget"]);
5566
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5567
		$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
5568
		#可省略參數
5569
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
5570
		#$conf["disableWebSearch"]="false";
5571
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
5572
		#$conf["userDir"]="true";
5573
		#參考資料來源:
5574
		#http://php.net/manual/en/function.file-exists.php
5575
		#http://php.net/manual/en/control-structures.foreach.php
5576
		#備註:
5577
		#函數file_exists檢查的路徑為檔案系統的路徑
5578
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
5579
		unset($conf["fileAccess::checkMultiFileExist"]);
5580
 
5581
		#如果檢查要用xz壓縮的檔案失敗
5582
		if($checkMultiFileExist["status"]=="false"){
5583
 
5584
			#設置執行失敗
5585
			$result["status"]="false";
5586
 
5587
			#設置執行錯誤訊息
5588
			$result["error"]=$checkMultiFileExist;
5589
 
5590
			#回傳結果
5591
			return $result;
5592
 
5593
			}#if end
5594
 
5595
		#如果要用xz壓縮的檔案有缺
5596
		if($checkMultiFileExist["allExist"]=="false"){
5597
 
5598
			#設置執行失敗
5599
			$result["status"]="false";
5600
 
5601
			#設置執行錯誤訊息
5602
			$result["error"]=$checkMultiFileExist;
5603
 
5604
			#回傳結果
5605
			return $result;
5606
 
5607
			}#if end
5608
 
5609
		#壓縮要用的xz語法
5610
		#函式說明:
5611
		#呼叫shell執行系統命令,並取得回傳的內容.
5612
		#回傳的結果:
5613
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5614
		#$result["error"],錯誤訊息陣列
5615
		#$result["output"],爲執行完二元碼後的輸出陣列
5616
		#必填的參數
5617
		$conf["external::callShell"]["command"]="xz";#要執行的指令與參數
5618
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5619
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
5620
		#可省略參數:
5621
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
5622
		$conf["external::callShell"]["argu"]=array("-v","-v","-z","-c",$conf["compressTarget"],">",$conf["createdXzFile"].".xz ");
5623
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
5624
		#$conf["enablePrintDescription"]="true";
5625
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
5626
		#$conf["printDescription"]="";
5627
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"true".
5628
		$conf["external::callShell"]["escapeshellarg"]="true";
5629
		#參考資料:
5630
		#http://php.net/manual/en/function.exec.php
5631
		$callShell=external::callShell($conf["external::callShell"]);
5632
		unset($conf["external::callShell"]);
5633
 
5634
		#如果執行shell失敗
5635
		if($callShell["status"]=="false"){
5636
 
5637
			#設置執行失敗
5638
			$result["status"]="false";
5639
 
5640
			#設置執行錯誤訊息
5641
			$result["error"]=$callShell;
5642
 
5643
			#回傳結果
5644
			return $result;
5645
 
5646
			}#if end
5647
 
5648
		#壓縮好的檔案位置與名稱
5649
		$result["content"]=$conf["createdXzFile"].".xz";
5650
 
5651
		#執行到這邊代表執行正常
5652
		$result["status"]="status";
5653
 
5654
		#回傳結果
5655
		return $result;
5656
 
5657
		}#function makeXzFile end
5658
 
5659
	/*
5660
	#函式說明:
5661
	#將資料夾或檔案打包壓縮成tar.xz檔案
5662
	#回傳結果:
5663
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5664
	#$result["function"],當前執行的函數名稱
5665
	#$result["error"],錯誤訊息.
5666
	#$result["content"],檔案輸出後的位置與名稱.
5667
	#必填參數:
5668
	#$conf["compressTarget"],陣列,要打包壓縮的每個資料夾與檔案位置
5669
	$conf["compressTarget"]=array();
5670
	#$conf["createdTarXzFile"],字串,打包壓縮好的檔案要放在哪裡,副檔名.tar.xz會自動加上.
5671
	$conf["createdTarXzFile"]="";
5672
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5673
	$conf["fileArgu"]=__FILE__;
5674
	#可省略參數:
5675
	#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
5676
	#$conf["commentsArray"]=array("");
5677
	#$conf["includeDotStart"],字串,當參數$conf["commentsArray"]含有星號時是否要包含「.」開頭的檔案目錄,預設為"false",不包含,"true"為要包含.
5678
	#$conf["includeDotStart"]="false";
5679
	#$conf["includeWaveEnd"],字串,當參數$conf["commentsArray"]含有星號時是否要包含「~」結尾的檔案.預設為"false",不包含,"true"為要包含.
5680
	#$conf["includeWaveEnd"]="false";
5681
	#參考資料:
5682
	#無.
5683
	#備註:
5684
	#建議加上 --exclude-backups, --exclude-caches-all 	
5685
	*/
5686
	public static function makeTarXzFile(&$conf){
5687
 
5688
		#初始化要回傳的內容
5689
		$result=array();
5690
 
5691
		#記錄當前執行的函數名稱
5692
		$result["function"]=__FUNCTION__;
5693
 
5694
		#如果 $conf 不為陣列
5695
		if(gettype($conf)!="array"){
5696
 
5697
			#設置執行失敗
5698
			$result["status"]="false";
5699
 
5700
			#設置執行錯誤訊息
5701
			$result["error"][]="\$conf變數須為陣列形態";
5702
 
5703
			#如果傳入的參數為 null
5704
			if($conf==null){
5705
 
5706
				#設置執行錯誤訊息
5707
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
5708
 
5709
				}#if end
5710
 
5711
			#回傳結果
5712
			return $result;
5713
 
5714
			}#if end
5715
 
5716
		#檢查參數
5717
		#函式說明:
5718
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
5719
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5720
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
5721
		#$result["function"],當前執行的函式名稱.
5722
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
5723
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
5724
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
5725
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
5726
		#必填寫的參數:
5727
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
5728
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
5729
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
5730
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","compressTarget","createdTarXzFile");
5731
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
5732
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","array","string");
5733
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
5734
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
5735
		#可以省略的參數:
5736
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
5737
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
5738
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
5739
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray","includeDotStart","includeWaveEnd");
5740
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
5741
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string");
5742
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
5743
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,"false","false");
5744
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
5745
		#$conf["arrayCountEqualCheck"][]=array();
5746
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
5747
		unset($conf["variableCheck::checkArguments"]);
5748
 
5749
		#若檢查失敗
5750
		if($checkResult["status"]=="false"){
5751
 
5752
			#設置執行失敗
5753
			$result["status"]="false";
5754
 
5755
			#設置執行錯誤訊息
5756
			$result["error"]=$checkResult;
5757
 
5758
			#回傳結果
5759
			return $result;
5760
 
5761
			}#if end
5762
 
5763
		#若檢查不通過
5764
		if($checkResult["passed"]=="false"){
5765
 
5766
			#設置執行失敗
5767
			$result["status"]="false";
5768
 
5769
			#設置執行錯誤訊息
5770
			$result["error"]=$checkResult;
5771
 
5772
			#回傳結果
5773
			return $result;
5774
 
5775
			}#if end
5776
 
5777
		#如果 $conf["commentsArray"] 有設定
5778
		if(isset($conf["commentsArray"])){
5779
 
5780
			#印出提示文字
5781
			#函式說明:
5782
			#印出多行文字,結尾自動換行.
5783
			#回傳的結果:
5784
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
5785
			#$result["function"],當前執行的函數名稱.
5786
			#$result["error"],錯誤訊息陣列.
5787
			#必填參數:
5788
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
5789
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
5790
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
5791
			unset($conf["cmd::echoMultiLine"]);
5792
 
5793
			#如果印出提示文字失敗
5794
			if($echoMultiLine["status"]=="false"){
5795
 
5796
				#設置執行失敗
5797
				$result["status"]="false";
5798
 
5799
				#設置執行錯誤訊息
5800
				$result["error"]=$echoMultiLine;
5801
 
5802
				#回傳結果
5803
				return $result;
5804
 
5805
				}#if end
5806
 
5807
			}#if end	
5808
 
5809
		#解析要處理的檔案路徑
5810
		#函式說明:
5811
		#將含有「*」的多個檔案路徑名稱,變成多個符合條件的路徑檔案.
5812
		#回傳結果:
5813
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
5814
		#$result["error"],錯誤訊息陣列.
5815
		#$result["function"],函數名稱. 
5816
		#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
5817
		#$result["pathCount"],整數,有幾個路徑.
5818
		#必填參數:
5819
		#$conf["path"],字串陣列,要解析含有「*」的檔案路徑字串.
5820
		$conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]["path"]=$conf["compressTarget"];
5821
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
5822
		$conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]["fileArgu"]=$conf["fileArgu"];
5823
		#可省略參數:
5824
		#$conf["noDotStart"],字串,"true"代表不包含「.」開頭的名稱,預設為"false"代表包含「.」開頭的名稱.
5825
		$conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]["noDotStart"]=$conf["includeDotStart"]==="true"?"false":"true";
5826
		#$conf["noWaveEnd"],字串,預設為"true"代表不包含「~」結尾的名稱,"false"代表包含結尾為「~」的名稱.
5827
		$conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]["noWaveEnd"]=$conf["includeWaveEnd"]==="true"?"false":"true";
5828
		$realPathArray=fileAccess::resolveMultiPostionStringWhichContainStarSymbol($conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]);
5829
		unset($conf["fileAccess::resolveMultiPostionStringWhichContainStarSymbol"]);
5830
 
5831
		#如果解析路徑失敗
5832
		if($realPathArray["status"]=="false"){
5833
 
5834
			#設置執行失敗
5835
			$result["status"]="false";
5836
 
5837
			#設置執行錯誤訊息
5838
			$result["error"]=$realPathArray;
5839
 
5840
			#回傳結果
5841
			return $result;
5842
 
5843
			}#if end
5844
 
5845
		#取得解析好的檔案路徑陣列
5846
		$conf["compressTarget"]=$realPathArray["content"];	
5847
 
5848
		#將路徑轉換成相對路徑
5849
		#函式說明:
5850
		#將多個路徑字串變成相對於當前路徑的相對路徑字串
5851
		#回傳結果:
5852
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
5853
		#$result["error"],錯誤訊息陣列.
5854
		#$result["function"],函數名稱. 
5855
		#$result["content"],字串陣列,多個轉換好的相對路徑字串.
5856
		#必填參數:
5857
		#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
5858
		$conf["fileAccess::getRelativePath"]["path"]=$conf["compressTarget"];
5859
		#$conf["fileArgu"],字串,當前路徑.
5860
		$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
5861
		$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
5862
		unset($conf["fileAccess::getRelativePath"]);
5863
 
5864
		#如果轉換失敗
5865
		if($getRelativePath["status"]=="false"){
5866
 
5867
			#設置執行失敗
5868
			$result["status"]="false";
5869
 
5870
			#設置執行錯誤訊息
5871
			$result["error"]=$getRelativePat;
5872
 
5873
			#回傳結果
5874
			return $result;
5875
 
5876
			}#if end	
5877
 
5878
		#打包成tar檔
5879
		#函式說明:
5880
		#將資料夾或檔案打包成tar檔案
5881
		#回傳的結果:
5882
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5883
		#$result["function"],當前執行的函數名稱
5884
		#$result["error"],錯誤訊息.
5885
		#$result["content"],檔案輸出後的位置與名稱.
5886
		#必填參數:
5887
		#$conf["fileAccess::makeTarFile"]["packetTarget"],陣列,要打包的每個資料夾與檔案位置
5888
		$conf["fileAccess::makeTarFile"]["packetTarget"]=$getRelativePath["content"];
5889
		#$conf["fileAccess::makeTarFile"]["createdTarFile"],字串,打包好的檔案要放在哪裡,副檔名.tar會自動加上.
5890
		$conf["fileAccess::makeTarFile"]["createdTarFile"]=$conf["createdTarXzFile"];
5891
		#$conf["fileAccess::makeTarFile"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5892
		$conf["fileAccess::makeTarFile"]["fileArgu"]=$conf["fileArgu"];
5893
		$makeTarFile=fileAccess::makeTarFile($conf["fileAccess::makeTarFile"]);
5894
		unset($conf["fileAccess::makeTarFile"]);
5895
 
5896
		#如果打包失敗
5897
		if($makeTarFile["status"]=="false"){
5898
 
5899
			#設置執行不正常
5900
			$result["status"]="false";
5901
 
5902
			#設置錯誤訊息
5903
			$result["error"]=$makeTarFile;
5904
 
5905
			#回傳結果
5906
			return $result;
5907
 
5908
			}#if end
5909
 
5910
		#壓縮成xz檔
5911
		#函式說明:
5912
		#將一個檔案壓縮成xz檔案
5913
		#回傳的結果:
5914
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5915
		#$result["function"],當前執行的函數名稱
5916
		#$result["error"],錯誤訊息.
5917
		#$result["content"],檔案輸出後的位置與名稱.
5918
		#必填參數:
5919
		#$conf["fileAccess::makeXzFile"]["compressTarget"],字串,要打包的每個資料夾與檔案位置
5920
		$conf["fileAccess::makeXzFile"]["compressTarget"]=$makeTarFile["content"];
5921
		#$conf["fileAccess::makeXzFile"]["createdXzFile"],字串,打包好的檔案要放在哪裡,副檔名.xz會自動加上.
5922
		$conf["fileAccess::makeXzFile"]["createdXzFile"]=$makeTarFile["content"];
5923
		#$conf["fileAccess::makeXzFile"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5924
		$conf["fileAccess::makeXzFile"]["fileArgu"]=$conf["fileArgu"];
5925
		$makeXzFile=fileAccess::makeXzFile($conf["fileAccess::makeXzFile"]);
5926
		unset($conf["fileAccess::makeXzFile"]);
5927
 
5928
		#如果壓縮失敗
5929
		if($makeXzFile["status"]=="false"){
5930
 
5931
			#設置執行不正常
5932
			$result["status"]="false";
5933
 
5934
			#設置錯誤訊息
5935
			$result["error"]=$makeXzFile;
5936
 
5937
			#回傳結果
5938
			return $result;
5939
 
5940
			}#if end
5941
 
5942
		#移除tar檔案
5943
		#函式說明:
5944
		#移除檔案
5945
		#回傳結果:
5946
		#$result["status"],"true"代表移除成功,"false"代表移除失敗.
5947
		#$result["error"],錯誤訊息陣列
5948
		#$result["warning"],警告訊息陣列
5949
		#$result["function"],當前執行的函數名稱
5950
		#必填參數:
5951
		$conf["fileAccess::delFile"]["fileAddress"]=$makeTarFile["content"];#要移除檔案的位置
5952
		#$conf["fileAccess::delFile"]["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
5953
		$conf["fileAccess::delFile"]["fileArgu"]=$conf["fileArgu"];
5954
		$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
5955
		unset($conf["fileAccess::delFile"]);
5956
 
5957
		#如果移除tar檔案失敗
5958
		if($delFile["status"]=="false"){
5959
 
5960
			#設置執行不正常
5961
			$result["status"]="false";
5962
 
5963
			#設置錯誤訊息
5964
			$result["error"]=$delFile;
5965
 
5966
			#回傳結果
5967
			return $result;
5968
 
5969
			}#if end
5970
 
5971
		#取得壓縮好的檔案位置與名稱
5972
		$result["content"]=$makeXzFile["content"];
5973
 
5974
		#執行到這邊代表執行正常
5975
		$result["status"]="true";
5976
 
5977
		#回傳結果
5978
		return $result;
5979
 
5980
		}#function makeTarXzFile end
5981
 
5982
	/*
5983
	#函式說明:
5984
	#移動檔案
5985
	#回傳結果:
5986
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5987
	#$result["function"],當前執行的函數名稱
5988
	#$result["error"],錯誤訊息.
5989
	#$result["content"],檔案輸出後的位置與名稱.
5990
	#必填參數:
5991
	#$conf["from"],字串,要移動的檔案名稱與位置.
5992
	$conf["from"]="";
5993
	#$conf["to"],字串,要移動到的位置與名稱
5994
	$conf["to"]="";
5995
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5996
	$conf["fileArgu"]=__FILE__;
5997
	#可省略參數:
5998
	#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
5999
	#$conf["commentsArray"]=array("");
6000
	#參考資料:
6001
	#無.
6002
	#備註:
6003
	#無.
6004
	*/
6005
	public static function mv(&$conf){
6006
 
6007
		#初始化要回傳的結果
6008
		$result=array();
6009
 
6010
		#取得當前執行的函數名稱
6011
		$result["function"]=__FUNCTION__;
6012
 
6013
		#如果 $conf 不為陣列
6014
		if(gettype($conf)!="array"){
6015
 
6016
			#設置執行失敗
6017
			$result["status"]="false";
6018
 
6019
			#設置執行錯誤訊息
6020
			$result["error"][]="\$conf變數須為陣列形態";
6021
 
6022
			#如果傳入的參數為 null
6023
			if($conf==null){
6024
 
6025
				#設置執行錯誤訊息
6026
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6027
 
6028
				}#if end
6029
 
6030
			#回傳結果
6031
			return $result;
6032
 
6033
			}#if end
6034
 
6035
		#檢查參數
6036
		#函式說明:
6037
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
6038
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6039
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
6040
		#$result["function"],當前執行的函式名稱.
6041
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
6042
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
6043
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
6044
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
6045
		#必填寫的參數:
6046
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
6047
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
6048
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
6049
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("from","to","fileArgu");
6050
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
6051
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
6052
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
6053
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
6054
		#可以省略的參數:
6055
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
6056
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
6057
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
6058
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray");
6059
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
6060
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array");
6061
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
6062
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
6063
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
6064
		#$conf["arrayCountEqualCheck"][]=array();
6065
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
6066
		unset($conf["variableCheck::checkArguments"]);
6067
 
6068
		#若檢查失敗
6069
		if($checkResult["status"]=="false"){
6070
 
6071
			#設置執行失敗
6072
			$result["status"]="false";
6073
 
6074
			#設置執行錯誤訊息
6075
			$result["error"]=$checkResult;
6076
 
6077
			#回傳結果
6078
			return $result;
6079
 
6080
			}#if end
6081
 
6082
		#若檢查不通過
6083
		if($checkResult["passed"]=="false"){
6084
 
6085
			#設置執行失敗
6086
			$result["status"]="false";
6087
 
6088
			#設置執行錯誤訊息
6089
			$result["error"]=$checkResult;
6090
 
6091
			#回傳結果
6092
			return $result;
6093
 
6094
			}#if end
6095
 
6096
		#如果 $conf["commentsArray"] 有設定
6097
		if(isset($conf["commentsArray"])){
6098
 
6099
			#印出提示文字
6100
			#函式說明:
6101
			#印出多行文字,結尾自動換行.
6102
			#回傳的結果:
6103
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
6104
			#$result["function"],當前執行的函數名稱.
6105
			#$result["error"],錯誤訊息陣列.
6106
			#必填參數:
6107
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
6108
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
6109
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
6110
			unset($conf["cmd::echoMultiLine"]);
6111
 
6112
			#如果印出提示文字失敗
6113
			if($echoMultiLine["status"]=="false"){
6114
 
6115
				#設置執行失敗
6116
				$result["status"]="false";
6117
 
6118
				#設置執行錯誤訊息
6119
				$result["error"]=$echoMultiLine;
6120
 
6121
				#回傳結果
6122
				return $result;
6123
 
6124
				}#if end
6125
 
6126
			}#if end	
6127
 
6128
		#檢查要移動的檔案是否存在
6129
		#函式說明:
6130
		#檢查多個檔案與資料夾是否存在.
6131
		#回傳的結果:
6132
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
6133
		#$result["error"],錯誤訊息陣列.
6134
		#$resutl["function"],當前執行的涵式名稱.
6135
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
6136
		#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
6137
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
6138
		#必填參數:
6139
		$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["from"]);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
6140
		$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
6141
		#參考資料來源:
6142
		#http://php.net/manual/en/function.file-exists.php
6143
		#http://php.net/manual/en/control-structures.foreach.php
6144
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
6145
		unset($conf["fileAccess::checkMultiFileExist"]);
6146
 
6147
		#如果檢查失敗
6148
		if($checkMultiFileExist["status"]=="false"){
6149
 
6150
			#設置執行失敗
6151
			$result["status"]="false";
6152
 
6153
			#設置執行錯誤訊息
6154
			$result["error"]=$checkMultiFileExist;
6155
 
6156
			#回傳結果
6157
			return $result;
6158
 
6159
			}#if end	
6160
 
6161
		#如果來源檔案不存在
6162
		if($checkMultiFileExist["allExist"]=="false"){
6163
 
6164
			#設置執行失敗
6165
			$result["status"]="false";
6166
 
6167
			#設置執行錯誤訊息
6168
			$result["error"][]="檔案「".$conf["from"]."」不存在";
6169
 
6170
			#回傳結果
6171
			return $result;
6172
 
6173
			}#if end
6174
 
6175
		#函式說明:
6176
		#呼叫shell執行系統命令,並取得回傳的內容.
6177
		#回傳的結果:
6178
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6179
		#$result["error"],錯誤訊息陣列
6180
		#$result["output"],爲執行完二元碼後的輸出陣列
6181
		#必填的參數
6182
		$conf["external::callShell"]["command"]="mv";#要執行的指令與參數
6183
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"]; #__FILE__的內容
6184
		#可省略參數:
6185
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
6186
		$conf["external::callShell"]["argu"]=array("-v",$conf["from"],$conf["to"]);
6187
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
6188
		#$conf["external::callShell"]["enablePrintDescription"]="true";
6189
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
6190
		#$conf["printDescription"]="";
6191
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"true".
6192
		$conf["external::callShell"]["escapeshellarg"]="true";
6193
		#參考資料:
6194
		#http://php.net/manual/en/function.exec.php
6195
		$callShell=external::callShell($conf["external::callShell"]);
6196
		unset($conf["external::callShell"]);
6197
 
6198
		#如果移動檔案失敗
6199
		if($callShell["status"]=="false"){
6200
 
6201
			#設置執行失敗
6202
			$result["status"]="false";
6203
 
6204
			#設置執行錯誤訊息
6205
			$result["error"]=$callShell;
6206
 
6207
			#回傳結果
6208
			return $result;
6209
 
6210
			}#if end
6211
 
6212
		#執行到這邊代表正常
6213
		$result["status"]="true";
6214
 
6215
		#儲存移動後的位置與名稱
6216
		$result["content"]=$conf["to"];
6217
 
6218
		#回傳結果
6219
		return $result;
6220
 
6221
		}#function mv end
6222
 
6223
	/*
6224
	#函式說明:
6225
	#取得目錄底下所有目錄與檔案的樹狀結構.
6226
	#回傳結果:
6227
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6228
	#$result["error"],錯誤訊息陣列.
6229
	#$result["function"],函數名稱.
6230
	#$result["position"],根目錄位置.
6231
	#$result["content"],陣列,檔案目錄的樹狀結構.
6232
	#$result["content"][$i]["name"],根目錄底下第$i+1個檔案或目錄的名稱
6233
	#$result["content"][$i]["folder"],根目錄底下第$i+1個名稱是目錄("true")還是檔案("false").
6234
	#$result["content"][$i]["position"],根目錄底下第$i+1個名稱或目錄的位置.
6235
	#$result["content"][$i]["ownerPerm"],根目錄底下第$i+1個使用者的權限.
6236
	#$result["content"][$i]["groupPerm"],根目錄底下第$i+1個群組使用者的權限.
6237
	#$result["content"][$i]["otherPerm"],根目錄底下第$i+1個其他使用者的權限.
6238
	#$result["content"][$i]["ownerName"],根目錄底下第$i+1個擁有者賬戶.
6239
	#$result["content"][$i]["groupName"],根目錄底下第$i+1個群組擁有者賬戶.
6240
	#$result["content"][$i]["next"][$j]["name"],第$i+1個為目錄的名稱的目錄底下第$j+1個檔案或目錄的名稱
6241
	#$result["content"][$i]["next"][$j]["folder"],第$i+1個為目錄的名稱的目錄底下第$j+1個名稱是目錄("true")還是檔案("false").
6242
	#$result["content"][$i]["next"][$j]["position"],第$i+1個為目錄的名稱的目錄底下第$j+1個名稱或目錄的位置.
6243
	#$result["content"][$i]["next"][$j]["ownerPerm"],第$i+1個為目錄的名稱的目錄底下第$j+1個使用者的權限.
6244
	#$result["content"][$i]["next"][$j]["groupPerm"],第$i+1個為目錄的名稱的目錄底下第$j+1個群組使用者的權限.
6245
	#$result["content"][$i]["next"][$j]["otherPerm"],第$i+1個為目錄的名稱的目錄底下第$j+1個其他使用者的權限.
6246
	#$result["content"][$i]["next"][$j]["ownerName"],第$i+1個為目錄的名稱的目錄底下第$j+1個擁有者賬戶.
6247
	#$result["content"][$i]["next"][$j]["groupName"],第$i+1個為目錄的名稱的目錄底下第$j+1個群組擁有者賬戶.
6248
	#以此類推...		
6249
	#必填參數:
6250
	#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
6251
	$conf["position"]="";
6252
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6253
	$conf["fileArgu"]=__FILE__;
6254
	#可省略參數:
6255
	#無.
6256
	#參考資料:
6257
	#無.
6258
	#備註:
6259
	#無.
6260
	*/
6261
	public static function getListTree(&$conf){
6262
 
6263
		#初始化要回傳的結果
6264
		$result=array();
6265
 
6266
		#設置當其函數名稱
6267
		$result["function"]=__FUNCTION__;
6268
 
6269
		#如果 $conf 不為陣列
6270
		if(gettype($conf)!="array"){
6271
 
6272
			#設置執行失敗
6273
			$result["status"]="false";
6274
 
6275
			#設置執行錯誤訊息
6276
			$result["error"][]="\$conf變數須為陣列形態";
6277
 
6278
			#如果傳入的參數為 null
6279
			if($conf==null){
6280
 
6281
				#設置執行錯誤訊息
6282
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6283
 
6284
				}#if end
6285
 
6286
			#回傳結果
6287
			return $result;
6288
 
6289
			}#if end
6290
 
6291
		#檢查必填參數
6292
		#函式說明:
6293
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
6294
		#回傳的結果:
6295
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6296
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
6297
		#$result["function"],當前執行的函式名稱.
6298
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
6299
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
6300
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
6301
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
6302
		#必填寫的參數:
6303
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
6304
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("fileArgu","position");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
6305
		#可以省略的參數:
6306
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
6307
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
6308
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
6309
		unset($conf["variableCheck.isexistMulti"]);
6310
 
6311
		#如果檢查失敗
6312
		if($checkResult["status"]=="false"){
6313
 
6314
			#設置錯誤識別
6315
			$result["status"]="false";
6316
 
6317
			#設置錯誤訊息
6318
			$result["error"]=$checkResult;
6319
 
6320
			#回傳結果
6321
			return $result;
6322
 
6323
			}#if end
6324
 
6325
		#如果檢查不通過
6326
		if($checkResult["passed"]=="false"){
6327
 
6328
			#設置錯誤識別
6329
			$result["status"]="false";
6330
 
6331
			#設置錯誤訊息
6332
			$result["error"]=$checkResult;
6333
 
6334
			#回傳結果
6335
			return $result;
6336
 
6337
			}#if end
6338
 
6339
		#如果目錄不為 . 與 ..
6340
		if(basename($conf["position"])!="." && basename($conf["position"])!=".."){
6341
 
6342
			#檢查目錄是否存在
6343
			#函式說明:
6344
			#檢查多個檔案與資料夾是否存在.
6345
			#回傳的結果:
6346
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
6347
			#$result["error"],錯誤訊息陣列.
6348
			#$resutl["function"],當前執行的涵式名稱.
6349
			#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
6350
			#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
6351
			#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
6352
			#必填參數:
6353
			$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["position"]);#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
6354
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6355
			$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
6356
			#參考資料來源:
6357
			#http://php.net/manual/en/function.file-exists.php
6358
			#http://php.net/manual/en/control-structures.foreach.php
6359
			$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
6360
			unset($conf["fileAccess::checkMultiFileExist"]);
6361
 
6362
			#如果檢查目錄失敗
6363
			if($checkMultiFileExist["status"]=="false"){
6364
 
6365
				#設置錯誤識別
6366
				$result["status"]="false";
6367
 
6368
				#設置錯誤訊息
6369
				$result["error"]=$checkMultiFileExist;
6370
 
6371
				#回傳結果
6372
				return $result;
6373
 
6374
				}#if end	
6375
 
6376
			#如果目錄不存在
6377
			if($checkMultiFileExist["varExist"][0]=="false"){
6378
 
6379
				#設置錯誤識別
6380
				$result["status"]="false";
6381
 
6382
				#設置錯誤訊息
6383
				$result["error"]=$checkMultiFileExist;
6384
 
6385
				#回傳結果
6386
				return $result;
6387
 
6388
				}#if end	
6389
 
6390
			}#if end
6391
 
6392
		#取得根目錄的樹狀結構
6393
		#函式說明:
6394
		#取得目錄底下所有目錄與檔案清單.
6395
		#回傳結果:
6396
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6397
		#$result["error"],錯誤訊息陣列.
6398
		#$result["function"],函數名稱.
6399
		#$result["content"],陣列,目錄底下的檔案與子目錄.
6400
		#$result["content"][$i]["name"],字串,目錄底下的檔案與子目錄的名稱.
6401
		#$result["content"][$i]["folder"],字串,第$i+1個名稱為目錄還是檔案.
6402
		#$result["folder"],字串,當前目標為目錄還是檔案"true"代表為目錄,"false"代表為檔案.
6403
		#$result["position"],目前的位置.
6404
		#必填參數:
6405
		#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
6406
		$conf["fileAccess::getList"]["position"]=$conf["position"];
6407
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6408
		$conf["fileAccess::getList"]["fileArgu"]=$conf["fileArgu"];
6409
		#可省略參數:
6410
		#無
6411
		#參考資料來源:
6412
		#opendir=>http://php.net/manual/en/function.opendir.php
6413
		#is_dir=>http://php.net/manual/en/function.is-dir.php
6414
		$rootList=fileAccess::getList($conf["fileAccess::getList"]);
6415
		unset($conf["fileAccess::getList"]);	
6416
 
6417
		#如果取得根目錄底下的資料失敗
6418
		if($rootList["status"]=="false"){
6419
 
6420
			#設置錯誤識別
6421
			$result["status"]="false";
6422
 
6423
			#設置錯誤訊息
6424
			$result["error"]=$rootList;
6425
 
6426
			#回傳結果
6427
			return $result;
6428
 
6429
			}#if end
6430
 
6431
		#取得當前目錄	
6432
		$result["position"]=$rootList["position"];	
6433
 
6434
		#取得根目錄層級可以看到的檔案與目錄
6435
		$result["content"]=$rootList["content"];
6436
 
6437
		#如果當前目錄有檔案與子目錄
6438
		if(isset($result["content"])){
6439
 
6440
			#當前層級有幾個檔案目錄就執行幾次
6441
			for($i=0;$i<count($result["content"]);$i++){
6442
 
6443
				#如果該單位是目錄
6444
				if($result["content"][$i]["folder"]=="true"){
6445
 
6446
					#呼叫當前函數,取得 $conf["position"]."/".$result["content"][$i]["name"] 目錄底下的檔案目錄資訊
6447
					#函式說明:
6448
					#取得目錄底下所有目錄與檔案的樹狀結構.
6449
					#回傳結果:
6450
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6451
					#$result["error"],錯誤訊息陣列.
6452
					#$result["function"],函數名稱.
6453
					#$result["content"],陣列,檔案目錄的樹狀結構.
6454
					#$result["total"],根目錄底下有多少目錄與檔案
6455
					#必填參數:
6456
					#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
6457
					$conf["fileAccess::getListTree"]["position"]=$conf["position"]."/".$result["content"][$i]["name"];
6458
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6459
					$conf["fileAccess::getListTree"]["fileArgu"]=$conf["fileArgu"];
6460
					#可省略參數:
6461
					#無
6462
					$getListTree=fileAccess::getListTree($conf["fileAccess::getListTree"]);
6463
					unset($conf["fileAccess::getListTree"]);
6464
 
6465
					#如果取得 $conf["position"]."/".$result["content"][$i]["name"] 目錄底下的檔案目錄資訊失敗
6466
					if($getListTree["status"]=="false"){
6467
 
6468
						#設置錯誤識別
6469
						$result["status"]="false";
6470
 
6471
						#設置錯誤訊息
6472
						$result["error"]=$getListTree;
6473
 
6474
						#回傳結果
6475
						return $result;
6476
 
6477
						}#if end
6478
 
6479
					#如果 $conf["position"]."/".$result["content"][$i]["name"] 目錄有檔案與子目錄
6480
					if(isset($getListTree["content"])){	
6481
 
6482
						#取得 $conf["position"]."/".$result["content"][$i]["name"] 目錄底下的檔案目錄資訊
6483
						$result["content"][$i]["next"]=$getListTree["content"];
6484
 
6485
						}#if end
6486
 
6487
					#取得當前目錄	
6488
					$result["content"][$i]["position"]=$rootList["position"];	
6489
 
6490
					}#if end
6491
 
6492
				}#for end
6493
 
6494
			}#if end
6495
 
6496
		#執行到這邊代表執行正常
6497
		$result["status"]="true";
6498
 
6499
		#回傳結果
6500
		return $result;
6501
 
6502
		}#function getListTree end
6503
 
6504
	/*
6505
	#函式說明:
6506
	#取得目錄底下所有目錄與檔案清單.
6507
	#回傳結果:
6508
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6509
	#$result["error"],錯誤訊息陣列.
6510
	#$result["function"],函數名稱.
6511
	#$result["content"],陣列,目錄底下的檔案與子目錄.
6512
	#$result["content"][$i]["name"],字串,目錄底下的檔案與子目錄的名稱.
6513
	#$result["content"][$i]["folder"],字串,第$i+1個名稱為目錄還是檔案.
6514
	#$result["content"][$i]["ownerPerm"],字串,使用者的權限.
6515
	#$result["content"][$i]["groupPerm"],字串,群組使用者的權限.
6516
	#$result["content"][$i]["otherPerm"],字串,其他使用者的權限.
6517
	#$result["content"][$i]["ownerName"],字串,擁有者賬戶.
6518
	#$result["content"][$i]["groupName"],字串,群組擁有者賬戶.
6519
	#$result["folder"],字串,當前目標為目錄還是檔案"true"代表為目錄,"false"代表為檔案.
6520
	#$result["position"],目前的位置.
6521
	#必填參數:
6522
	#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
6523
	$conf["position"]="";
6524
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6525
	$conf["fileArgu"]=__FILE__;
6526
	#可省略參數:
6527
	#無
6528
	#參考資料:
6529
	#opendir=>http://php.net/manual/en/function.opendir.php
6530
	#is_dir=>http://php.net/manual/en/function.is-dir.php
6531
	#備註:
6532
	#無.
6533
	*/
6534
	public static function getList(&$conf){
6535
 
6536
		#初始化要回傳的結果
6537
		$result=array();
6538
 
6539
		#設置當其函數名稱
6540
		$result["function"]=__FUNCTION__;
6541
 
6542
		#初始化記載檔案目錄名單的陣列
6543
		$result["content"]=array();
6544
 
6545
		#如果 $conf 不為陣列
6546
		if(gettype($conf)!="array"){
6547
 
6548
			#設置執行失敗
6549
			$result["status"]="false";
6550
 
6551
			#設置執行錯誤訊息
6552
			$result["error"][]="\$conf變數須為陣列形態";
6553
 
6554
			#如果傳入的參數為 null
6555
			if($conf==null){
6556
 
6557
				#設置執行錯誤訊息
6558
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6559
 
6560
				}#if end
6561
 
6562
			#回傳結果
6563
			return $result;
6564
 
6565
			}#if end
6566
 
6567
		#檢查必填參數
6568
		#函式說明:
6569
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
6570
		#回傳的結果:
6571
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6572
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
6573
		#$result["function"],當前執行的函式名稱.
6574
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
6575
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
6576
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
6577
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
6578
		#必填寫的參數:
6579
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
6580
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("fileArgu","position");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
6581
		#可以省略的參數:
6582
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
6583
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
6584
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
6585
		unset($conf["variableCheck.isexistMulti"]);
6586
 
6587
		#如果檢查失敗
6588
		if($checkResult["status"]=="false"){
6589
 
6590
			#設置錯誤識別
6591
			$result["status"]="false";
6592
 
6593
			#設置錯誤訊息
6594
			$result["error"]=$checkResult;
6595
 
6596
			#回傳結果
6597
			return $result;
6598
 
6599
			}#if end
6600
 
6601
		#如果檢查不通過
6602
		if($checkResult["passed"]==="false"){
6603
 
6604
			#設置錯誤識別
6605
			$result["status"]="false";
6606
 
6607
			#設置錯誤訊息
6608
			$result["error"]=$checkResult;
6609
 
6610
			#回傳結果
6611
			return $result;
6612
 
6613
			}#if end
6614
 
6615
		#檢查目標路徑是否為「/」開頭的路徑
6616
		#函式說明:
6617
		#取得符合特定字首與字尾的字串
6618
		#回傳結果:
6619
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
6620
		#$result["function"],當前執行的函數名稱.
6621
		#$result["error"],錯誤訊息陣列.
6622
		#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
6623
		#$result["returnString"],爲符合字首條件的字串內容。
6624
		#必填參數:
6625
		#$conf["checkString"],字串,要檢查的字串.
6626
		$conf["search::getMeetConditionsString"]["checkString"]=$conf["position"];
6627
		#可省略參數:
6628
		#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
6629
		$conf["search::getMeetConditionsString"]["frontWord"]="/";
6630
		#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
6631
		#$conf["tailWord"]="";
6632
		#參考資料:
6633
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
6634
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
6635
		unset($conf["search::getMeetConditionsString"]);
6636
 
6637
		#如果檢查關鍵字失敗
6638
		if($getMeetConditionsString["status"]=="false"){
6639
 
6640
			#設置錯誤識別
6641
			$result["status"]="false";
6642
 
6643
			#設置錯誤訊息
6644
			$result["error"]=$getMeetConditionsString;
6645
 
6646
			#回傳結果
6647
			return $result;
6648
 
6649
			}#if end					
6650
 
6651
		#如果目標路徑不為「/」開頭的路徑,則為相對路徑
6652
		if($getMeetConditionsString["founded"]=="false"){
6653
 
6654
			#取得目標位置的路徑
6655
			#函式說明:
6656
			#將檔案的位置名稱變成網址
6657
			#回傳結果:
6658
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6659
			#$result["error"],錯誤訊息陣列.
6660
			#$result["function"],函數名稱. 
6661
			#$result["content"],網址.
6662
			#$result["localAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
6663
			#$result["fileSystemAbsoulutePosition"],針對伺服器檔案系統的絕對位置.
6664
			#必填參數:
6665
			#$conf["address"],字串,檔案的相對位置.
6666
			$conf["fileAccess::getInternetAddress"]["address"]=$conf["position"];
6667
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
6668
			$conf["fileAccess::getInternetAddress"]["fileArgu"]=$conf["fileArgu"];
6669
			#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是.
6670
			#$conf["fileAccess::getInternetAddress"]["userDir"]="true";
6671
			$getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
6672
			unset($conf["fileAccess::getInternetAddress"]);	
6673
 
6674
			#如果將檔案的位置名稱變成網址失敗
6675
			if($getInternetAddress["status"]=="false"){
6676
 
6677
				#設置錯誤識別
6678
				$result["status"]="false";
6679
 
6680
				#設置錯誤訊息
6681
				$result["error"]=$getInternetAddress;
6682
 
6683
				#回傳結果
6684
				return $result;
6685
 
6686
				}#if end	
6687
 
6688
			#置換目標位置為檔案系統路徑的絕對位置
6689
			$conf["position"]=$getInternetAddress["fileSystemAbsoulutePosition"];
6690
 
6691
			}#if end						
6692
 
6693
		#如果目標是資料夾	
6694
		if(is_dir($conf["position"])) {
6695
 
6696
			#設置為資料夾
6697
			$result["folder"]="true";
6698
 
6699
			#如果開啟資料夾成功
6700
			if($dh=opendir($conf["position"])){
6701
 
6702
				#初始化計數變數
6703
				$count=0;
6704
 
6705
				#如果資料夾裡面有檔案
6706
				while(($fileName=readdir($dh))!==false){
6707
 
6708
					#debug
6709
					#echo "有檔案";
6710
 
6711
					#如果名稱是「.」或「..」
6712
					if($fileName=="." || $fileName==".."){
6713
 
6714
						#則跳過
6715
						continue;
6716
 
6717
						}#if end
6718
 
6719
					#取得檔案或子目錄名稱
6720
					$result["content"][$count]["name"]=$fileName;					
6721
 
6722
					#取得詳細資訊
6723
					#函式說明:
6724
					#取得節點的資訊.
6725
					#回傳結果:
6726
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6727
					#$result["error"],錯誤訊息陣列.
6728
					#$result["function"],函數名稱. 
6729
					#$result["content"],檔案資訊陣列.
6730
					#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
6731
					#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
6732
					#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
6733
					#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
6734
					#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
6735
					#$result["content"]["ownerName"],檔案擁有着資訊.
6736
					#$result["content"]["groupName"],檔案所屬擁有着資訊.
6737
					#$result["content"]["size"],檔案大小.
6738
					#$result["content"]["modifyDate"],檔案變更年月日.
6739
					#$result["content"]["modifyTime"],檔案變更時分秒.
6740
					#$result["content"]["modifyTimeFloat"],檔案變更時間秒的float數值.
6741
					#$result["content"]["timezone"],檔案變更時間的時區與UTC的差距.
6742
					#必填參數:
6743
					#$conf["fileArgu"],字串,當前檔案的位置亦即__FILE__的內容.
6744
					$conf["fileAccess::fileInfo"]["fileArgu"]=$conf["fileArgu"];
6745
					#$conf["file"],字串,要查看擁有者資訊的檔案.
6746
					$conf["fileAccess::fileInfo"]["file"]=$conf["position"]."/".$fileName;
6747
					#可省略參數:
6748
					#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
6749
					$conf["fileAccess::fileInfo"]["web"]="false";
6750
					#參考資料:
6751
					#fileowner=>http://php.net/manual/en/function.fileowner.php
6752
					#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
6753
					#備註:
6754
					#無.
6755
					$fileInfo=fileAccess::fileInfo($conf["fileAccess::fileInfo"]);
6756
					unset($conf["fileAccess::fileInfo"]);
6757
 
6758
					#如果執行失敗
6759
					if($fileInfo["status"]=="false"){
6760
 
6761
						#設置錯誤識別
6762
						$result["status"]="false";
6763
 
6764
						#設置錯誤訊息
6765
						$result["error"]=$fileInfo;
6766
 
6767
						#回傳結果
6768
						return $result;
6769
 
6770
						}#if end
6771
 
6772
					#設置是否為資料夾
6773
					$result["content"][$count]["folder"]=$fileInfo["content"]["is_folder"];
6774
 
6775
					#設置使用者的權限
6776
					$result["content"][$count]["ownerPerm"]=$fileInfo["content"]["ownerPerm"];
6777
 
6778
					#設置群組的權限
6779
					$result["content"][$count]["groupPerm"]=$fileInfo["content"]["groupPerm"];
6780
 
6781
					#設置其他使用者的權限
6782
					$result["content"][$count]["otherPerm"]=$fileInfo["content"]["otherPerm"];
6783
 
6784
					#設置其擁有者賬戶
6785
					$result["content"][$count]["ownerName"]=$fileInfo["content"]["ownerName"];
6786
 
6787
					#設置其群組擁有者賬戶
6788
					$result["content"][$count]["groupName"]=$fileInfo["content"]["groupName"];
6789
 
6790
					#計數加1
6791
					$count++;
6792
 
6793
					}#while
6794
 
6795
				#關閉資料夾
6796
				closedir($dh);
6797
 
6798
				}#if end
6799
 
6800
			#開啟資料夾失敗	
6801
			else{
6802
 
6803
				#設置執行失敗
6804
				$result["status"]="false";
6805
 
6806
				#設置執行錯誤訊息
6807
				$result["error"][]="開啟資料夾「".$conf["position"]."」失敗";
6808
 
6809
				#回傳結果
6810
				return $result;
6811
 
6812
				}#else end
6813
 
6814
			}#if end
6815
 
6816
		#反之是檔案
6817
		else{
6818
 
6819
			#設置不為目錄
6820
			$result["folder"]="false";
6821
 
6822
			}#else end
6823
 
6824
		#取得目前位置
6825
		$result["position"]=$conf["position"];	
6826
 
6827
		#執行到這邊代表執行正常
6828
		$result["status"]="true";
6829
 
6830
		#回傳結果
6831
		return $result;	
6832
 
6833
		}#function getList end
6834
 
6835
	/*
6836
	#函式說明:
6837
	#取得目錄底下所有目錄與檔案的樹狀結構.
6838
	#回傳結果:
6839
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6840
	#$result["error"],錯誤訊息陣列.
6841
	#$result["function"],函數名稱.
6842
	#$result["content"],陣列,檔案目錄的樹狀結構.
6843
	#必填參數:
6844
	#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
6845
	$conf["position"]="";
6846
	#可省略參數:
6847
	#無.
6848
	#參考資料:
6849
	#無.
6850
	#備註:
6851
	#無.
6852
	*/
6853
	public static function exportListTree(&$conf){
6854
 
6855
		#初始化要回傳的結果
6856
		$result=array();
6857
 
6858
		#設置當其函數名稱
6859
		$result["function"]=__FUNCTION__;
6860
 
6861
		#如果 $conf 不為陣列
6862
		if(gettype($conf)!="array"){
6863
 
6864
			#設置執行失敗
6865
			$result["status"]="false";
6866
 
6867
			#設置執行錯誤訊息
6868
			$result["error"][]="\$conf變數須為陣列形態";
6869
 
6870
			#如果傳入的參數為 null
6871
			if($conf==null){
6872
 
6873
				#設置執行錯誤訊息
6874
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6875
 
6876
				}#if end
6877
 
6878
			#回傳結果
6879
			return $result;
6880
 
6881
			}#if end
6882
 
6883
		#檢查必填參數
6884
		#函式說明:
6885
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
6886
		#回傳的結果:
6887
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6888
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
6889
		#$result["function"],當前執行的函式名稱.
6890
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
6891
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
6892
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
6893
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
6894
		#必填寫的參數:
6895
		$conf["variableCheck.isexistMulti"]["varInput"]=$conf;#要檢查的陣列變數
6896
		$conf["variableCheck.isexistMulti"]["variableCheck"]=array("position");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
6897
		#可以省略的參數:
6898
		$conf["variableCheck.isexistMulti"]["variableType"]=array("string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
6899
		$conf["variableCheck.isexistMulti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
6900
		$checkResult=variableCheck::isexistMulti($conf["variableCheck.isexistMulti"]);
6901
		unset($conf["variableCheck.isexistMulti"]);
6902
 
6903
		#如果檢查失敗
6904
		if($checkResult["status"]=="false"){
6905
 
6906
			#設置錯誤識別
6907
			$result["status"]="false";
6908
 
6909
			#設置錯誤訊息
6910
			$result["error"]=$checkResult;
6911
 
6912
			#回傳結果
6913
			return $result;
6914
 
6915
			}#if end
6916
 
6917
		#如果檢查不通過
6918
		if($checkResult["passed"]=="false"){
6919
 
6920
			#設置錯誤識別
6921
			$result["status"]="false";
6922
 
6923
			#設置錯誤訊息
6924
			$result["error"]=$checkResult;
6925
 
6926
			#回傳結果
6927
			return $result;
6928
 
6929
			}#if end
6930
 
6931
		#函式說明:
6932
		#取得目錄底下所有目錄與檔案的樹狀結構.
6933
		#回傳結果:
6934
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6935
		#$result["error"],錯誤訊息陣列.
6936
		#$result["function"],函數名稱.
6937
		#$result["content"],陣列,檔案目錄的樹狀結構.
6938
		#必填參數:
6939
		#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
6940
		$conf["fileAccess::getListTree"]["position"]=$conf["position"];
6941
		#可省略參數:
6942
		#無
6943
		#備註:
6944
		#若檔案與目錄的名稱含有「[」與「]」與「(」與「)」將會無法取得其目錄底下的內容	
6945
		#若檔案與目錄的名稱含有「 」將會無法檢查檔案是否存在
6946
		#改用opendir()函數應該可以解決大部分的bug.
6947
		$getListTree=fileAccess::getListTree($conf["fileAccess::getListTree"]);
6948
		unset($conf["fileAccess::getListTree"]);
6949
 
6950
		#如果取得 目標目錄底下所有目錄與檔案的樹狀結構 失敗
6951
		if($getListTree["status"]==="false"){
6952
 
6953
			#設置錯誤識別
6954
			$result["status"]="false";
6955
 
6956
			#設置錯誤訊息
6957
			$result["error"]=$getListTree;
6958
 
6959
			#回傳結果
6960
			return $result;
6961
 
6962
			}#if end
6963
 
6964
		#目標目錄底下有幾個
6965
 
6966
		}#function exportListTree end
6967
 
6968
	/*
6969
	#函式說明:
6970
	#解壓縮tar.xz檔案,解壓縮完畢後,tar.xz檔案會被移除.
6971
	#回傳結果:
6972
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
6973
	#$result["error"],錯誤訊息陣列.
6974
	#$result["function"],函數名稱. 
6975
	#必填參數:
6976
	#$conf["tarXzFile"],字串變數,壓縮檔的位置與名稱,副檔名".tar.xz"會自動補上.
6977
	$conf["tarXzFile"]="";
6978
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6979
	$conf["fileArgu"]=__FILE__;
6980
	#可省略參數:
6981
	#$conf["extractTo"],字串,要解壓縮到哪邊,預設為當前路徑"."
6982
	#$conf["extractTo"]=".";
6983
	#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
6984
	#$conf["commentsArray"]=array("");
6985
	#參考資料:
6986
	#無.
6987
	#備註:
6988
	#無.
6989
	*/
6990
	public static function unpackTarXzFile(&$conf){
6991
 
6992
		#初始化要回傳的內容
6993
		$result=array();
6994
 
6995
		#記錄當前執行的函數名稱
6996
		$result["function"]=__FUNCTION__;
6997
 
6998
		#如果 $conf 不為陣列
6999
		if(gettype($conf)!="array"){
7000
 
7001
			#設置執行失敗
7002
			$result["status"]="false";
7003
 
7004
			#設置執行錯誤訊息
7005
			$result["error"][]="\$conf變數須為陣列形態";
7006
 
7007
			#如果傳入的參數為 null
7008
			if($conf==null){
7009
 
7010
				#設置執行錯誤訊息
7011
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
7012
 
7013
				}#if end
7014
 
7015
			#回傳結果
7016
			return $result;
7017
 
7018
			}#if end
7019
 
7020
		#檢查參數
7021
		#函式說明:
7022
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
7023
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7024
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
7025
		#$result["function"],當前執行的函式名稱.
7026
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
7027
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
7028
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
7029
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
7030
		#必填寫的參數:
7031
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
7032
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
7033
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
7034
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","tarXzFile");
7035
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
7036
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
7037
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
7038
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
7039
		#可以省略的參數:
7040
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
7041
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
7042
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
7043
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("commentsArray","extractTo");
7044
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
7045
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string");
7046
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,"null"代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
7047
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,".");
7048
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
7049
		#$conf["arrayCountEqualCheck"][]=array();
7050
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
7051
		unset($conf["variableCheck::checkArguments"]);
7052
 
7053
		#若檢查失敗
7054
		if($checkResult["status"]=="false"){
7055
 
7056
			#設置執行失敗
7057
			$result["status"]="false";
7058
 
7059
			#設置執行錯誤訊息
7060
			$result["error"]=$checkResult;
7061
 
7062
			#回傳結果
7063
			return $result;
7064
 
7065
			}#if end
7066
 
7067
		#若檢查不通過
7068
		if($checkResult["passed"]=="false"){
7069
 
7070
			#設置執行失敗
7071
			$result["status"]="false";
7072
 
7073
			#設置執行錯誤訊息
7074
			$result["error"]=$checkResult;
7075
 
7076
			#回傳結果
7077
			return $result;
7078
 
7079
			}#if end
7080
 
7081
		#如果 $conf["commentsArray"] 有設定
7082
		if(isset($conf["commentsArray"])){
7083
 
7084
			#印出提示文字
7085
			#函式說明:
7086
			#印出多行文字,結尾自動換行.
7087
			#回傳的結果:
7088
			#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
7089
			#$result["function"],當前執行的函數名稱.
7090
			#$result["error"],錯誤訊息陣列.
7091
			#必填參數:
7092
			#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.
7093
			$conf["cmd::echoMultiLine"]["outputStringArray"]=$conf["commentsArray"];
7094
			$echoMultiLine=cmd::echoMultiLine($conf["cmd::echoMultiLine"]);
7095
			unset($conf["cmd::echoMultiLine"]);
7096
 
7097
			#如果印出提示文字失敗
7098
			if($echoMultiLine["status"]=="false"){
7099
 
7100
				#設置執行失敗
7101
				$result["status"]="false";
7102
 
7103
				#設置執行錯誤訊息
7104
				$result["error"]=$echoMultiLine;
7105
 
7106
				#回傳結果
7107
				return $result;
7108
 
7109
				}#if end
7110
 
7111
			}#if end
7112
 
7113
		#檢查要移動的檔案是否存在
7114
		#函式說明:
7115
		#檢查多個檔案與資料夾是否存在.
7116
		#回傳的結果:
7117
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
7118
		#$result["error"],錯誤訊息陣列.
7119
		#$resutl["function"],當前執行的涵式名稱.
7120
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
7121
		#$result["varName"][$i],爲第$i個資料夾或檔案的名稱。
7122
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
7123
		#必填參數:
7124
		$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["tarXzFile"].".tar.xz");#要檢查書否存在的檔案有哪些,須爲一維陣列數值。
7125
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
7126
		$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
7127
		#參考資料來源:
7128
		#http://php.net/manual/en/function.file-exists.php
7129
		#http://php.net/manual/en/control-structures.foreach.php
7130
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
7131
		unset($conf["fileAccess::checkMultiFileExist"]);
7132
 
7133
		#如果檢查失敗
7134
		if($checkMultiFileExist["status"]=="false"){
7135
 
7136
			#設置執行失敗
7137
			$result["status"]="false";
7138
 
7139
			#設置執行錯誤訊息
7140
			$result["error"]=$checkMultiFileExist;
7141
 
7142
			#回傳結果
7143
			return $result;
7144
 
7145
			}#if end	
7146
 
7147
		#如果來源檔案不存在
7148
		if($checkMultiFileExist["allExist"]=="false"){
7149
 
7150
			#設置執行失敗
7151
			$result["status"]="false";
7152
 
7153
			#設置執行錯誤訊息
7154
			$result["error"][]="檔案「".$conf["tarXzFile"].".tar.xz」不存在";
7155
 
7156
			#回傳結果
7157
			return $result;
7158
 
7159
			}#if end
7160
 
7161
		#進行解壓縮xz檔
7162
		#函式說明:
7163
		#呼叫shell執行系統命令,並取得回傳的內容.
7164
		#回傳的結果:
7165
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7166
		#$result["error"],錯誤訊息陣列.
7167
		#$result["function"],當前執行的函數名稱.
7168
		#$result["cmd"],執行的指令內容.
7169
		#$result["output"],爲執行完二元碼後的輸出陣列.
7170
		#必填的參數
7171
		#$conf["command"],字串,要執行的指令與.
7172
		$conf["fileAccess::callShell"]["command"]="xz -v -v -d -f ".$conf["tarXzFile"].".tar.xz";
7173
		#可省略參數:
7174
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
7175
		#$conf["fileAccess::callShell"]["argu"]=array();
7176
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
7177
		#$conf["enablePrintDescription"]="true";
7178
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
7179
		#$conf["printDescription"]="";
7180
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"true".
7181
		#$conf["escapeshellarg"]="true";
7182
		#備註:
7183
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.
7184
		#參考資料:
7185
		#exec=>http://php.net/manual/en/function.exec.php
7186
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
7187
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
7188
		$callShell=external::callShell($conf["fileAccess::callShell"]);
7189
		unset($conf["fileAccess::callShell"]);
7190
 
7191
		#如果解壓縮xz檔案失敗
7192
		if($callShell["status"]=="false"){
7193
 
7194
			#設置執行失敗
7195
			$result["status"]="false";
7196
 
7197
			#設置執行錯誤訊息
7198
			$result["error"]=$callShell;
7199
 
7200
			#回傳結果
7201
			return $result;
7202
 
7203
			}#if end
7204
 
7205
		#解壓縮tar檔
7206
		#函式說明:
7207
		#呼叫shell執行系統命令,並取得回傳的內容.
7208
		#回傳的結果:
7209
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7210
		#$result["error"],錯誤訊息陣列.
7211
		#$result["function"],當前執行的函數名稱.
7212
		#$result["cmd"],執行的指令內容.
7213
		#$result["output"],爲執行完二元碼後的輸出陣列.
7214
		#必填的參數
7215
		#$conf["command"],字串,要執行的指令與.
7216
		$conf["fileAccess::callShell"]["command"]="tar";
7217
		#可省略參數:
7218
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
7219
		$conf["fileAccess::callShell"]["argu"]=array("-xvf",$conf["tarXzFile"]."tar",$conf["extractTo"]);
7220
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
7221
		#$conf["enablePrintDescription"]="true";
7222
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
7223
		#$conf["printDescription"]="";
7224
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"true".
7225
		$conf["fileAccess::callShell"]["escapeshellarg"]="true";
7226
		#備註:
7227
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行.
7228
		#參考資料:
7229
		#exec=>http://php.net/manual/en/function.exec.php
7230
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
7231
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
7232
		$callShell=external::callShell($conf["fileAccess::callShell"]);
7233
		unset($conf["fileAccess::callShell"]);
7234
 
7235
		#如果解壓縮xz檔案失敗
7236
		if($callShell["status"]=="false"){
7237
 
7238
			#設置執行失敗
7239
			$result["status"]="false";
7240
 
7241
			#設置執行錯誤訊息
7242
			$result["error"]=$callShell;
7243
 
7244
			#回傳結果
7245
			return $result;
7246
 
7247
			}#if end
7248
 
7249
		#移除tar檔
7250
		#函式說明:
7251
		#移除檔案
7252
		#回傳結果:
7253
		#$result["status"],"true"代表移除成功,"false"代表移除失敗.
7254
		#$result["error"],錯誤訊息陣列
7255
		#$result["warning"],警告訊息陣列
7256
		#$result["function"],當前執行的函數名稱
7257
		#必填參數:
7258
		$conf["fileAccess::delFile"]["fileAddress"]=$conf["tarXzFile"].".tar";#要移除檔案的位置
7259
		#可省略參數:
7260
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
7261
		$conf["fileAccess::delFile"]["fileArgu"]=$conf["fileArgu"];
7262
		#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
7263
		#$conf["commentsArray"]=array("");
7264
		$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
7265
		unset($conf["fileAccess::delFile"]);	
7266
 
7267
		#如果移除檔案失敗
7268
		if($delFile["status"]=="false"){
7269
 
7270
			#設置執行失敗
7271
			$result["status"]="false";
7272
 
7273
			#設置執行錯誤訊息
7274
			$result["error"]=$delFile;
7275
 
7276
			#回傳結果
7277
			return $result;
7278
 
7279
			}#if end	
7280
 
7281
		#執行到這邊代表執行正常
7282
		$result["status"]="true";
7283
 
7284
		#回傳結果
7285
		return $result;
7286
 
7287
		}#function unpackTarXzFile end
7288
 
7289
	/*
7290
	#函式說明:
7291
	#用data:mimeType;base64,fileVar的形式來提供檔案的連結,亦即檔案儲存在變數裡面.
7292
	#回傳結果:
7293
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7294
	#$result["error"],錯誤訊息
7295
	#$result["content"],檔案變數的內容
7296
	#$result["fileTypeName"],副檔名,ex:「.tar.xz」.
7297
	#$result["function"],當前執行的函數名稱 
7298
	#必填參數:
7299
	#$conf["filePosition"],要轉存成2元碼的檔案位置與名稱
7300
	$conf["filePosition"]="";
7301
	#$conf["mimeType"],2元碼的內容是什麼
7302
	$conf["mimeType"]="";
7303
	#可省略參數:
7304
	#$conf["compressType"],2元碼壓縮的方式,預設為"base64".
7305
	#$conf["compressType"]="base64";
7306
	#$conf["delFile"],讀取完檔案後,要移除檔案嗎?"true"代表要移除,"false"代表不要移除,預設為"false".
7307
	#$conf["delFile"]="false";
7308
	#參考資料:
7309
	#將檔案用字串變數儲存起來=>http://php.net/manual/en/function.file-get-contents.php
7310
	#壓縮2元碼=>http://php.net/manual/en/function.base64-encode.php
7311
	#備註:
7312
	#無.
7313
	*/
7314
	public static function data(&$conf){
7315
 
7316
		#初始化要回傳的內容
7317
		$result=array();
7318
 
7319
		#取得當前執行的函數名稱
7320
		$result["function"]=__FUNCTION__;
7321
 
7322
		#如果 $conf 不為陣列
7323
		if(gettype($conf)!="array"){
7324
 
7325
			#設置執行失敗
7326
			$result["status"]="false";
7327
 
7328
			#設置執行錯誤訊息
7329
			$result["error"][]="\$conf變數須為陣列形態";
7330
 
7331
			#如果傳入的參數為 null
7332
			if($conf==null){
7333
 
7334
				#設置執行錯誤訊息
7335
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
7336
 
7337
				}#if end
7338
 
7339
			#回傳結果
7340
			return $result;
7341
 
7342
			}#if end
7343
 
7344
		#檢查參數
7345
		#函式說明:
7346
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
7347
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7348
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
7349
		#$result["function"],當前執行的函式名稱.
7350
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
7351
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
7352
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
7353
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
7354
		#必填寫的參數:
7355
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
7356
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
7357
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
7358
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("filePosition");
7359
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
7360
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
7361
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
7362
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
7363
		#可以省略的參數:
7364
		#$conf["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
7365
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
7366
		#$conf["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
7367
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("mimeType","compressType","delFile");
7368
		#$conf["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
7369
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
7370
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,「null」代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
7371
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("null","base64","false");
7372
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
7373
		#$conf["arrayCountEqualCheck"][]=array();
7374
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
7375
		unset($conf["variableCheck::checkArguments"]);
7376
 
7377
		#如果檢查參數失敗
7378
		if($checkResult["status"]=="false"){
7379
 
7380
			#設置執行失敗
7381
			$result["status"]="false";
7382
 
7383
			#設置錯誤訊息
7384
			$result["error"]=$checkResult;
7385
 
7386
			#回傳結果
7387
			return $result;
7388
 
7389
			}#if end
7390
 
7391
		#如果檢查參數不通過
7392
		if($checkResult["passed"]=="false"){
7393
 
7394
			#設置執行失敗
7395
			$result["status"]="false";
7396
 
7397
			#設置錯誤訊息
7398
			$result["error"]=$checkResult;
7399
 
7400
			#回傳結果
7401
			return $result;
7402
 
7403
			}#if end
7404
 
7405
		#依據檔案名稱取得副檔名 $result["fileTypeName"]
7406
		#函式說明:
7407
		#將固定格式的字串分開,並回傳分開的結果。
7408
		#回傳的參數:
7409
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7410
		#$result["error"],錯誤訊息陣列
7411
		#$result["function"],當前執行的函數名稱.
7412
		#$result["oriStr"],要分割的原始字串內容
7413
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
7414
		#$result["dataCounts"],爲總共分成幾段
7415
		#必填參數:
7416
		$conf["stringProcess::spiltString"]["stringIn"]=basename($conf["filePosition"]);#要處理的字串。
7417
		$conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
7418
		#備註:
7419
		#建議新增如果透過" "分割後的內容含有""的元素,將其移除,並將後面有內容的元素補上,key也重新排序。
7420
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7421
		unset($conf["stringProcess::spiltString"]);
7422
 
7423
		#如果分割字串失敗
7424
		if($spiltString["status"]=="false"){
7425
 
7426
			#設置執行失敗
7427
			$result["status"]="false";
7428
 
7429
			#設置錯誤訊息
7430
			$result["error"]=$spiltString;
7431
 
7432
			#回傳結果
7433
			return $result;
7434
 
7435
			}#if end
7436
 
7437
		#初始化副檔名
7438
		$result["fileTypeName"]="";	
7439
 
7440
		#如果只有一段代表沒有副檔名
7441
		if($spiltString["dataCounts"]==1){
7442
 
7443
			#副檔名設置為 "unknow"
7444
			$result["fileTypeName"]="unknow";
7445
 
7446
			}#if end
7447
 
7448
		#不符合以上條件,但至少有兩段
7449
		else if($spiltString["dataCounts"]>=2){
7450
 
7451
			#執行 $spiltString["dataCounts"] 減一次的迴圈
7452
			for($i=1;$i<$spiltString["dataCounts"];$i++){
7453
 
7454
				#串接副檔名
7455
				$result["fileTypeName"]=$result["fileTypeName"].".".$spiltString["dataArray"][$i];
7456
 
7457
				}#for end
7458
 
7459
			}#if end
7460
 
7461
		#讀取檔案內容
7462
		$fileBin=file_get_contents($conf["filePosition"],"rb");
7463
 
7464
		#編碼檔案
7465
		$base64fileBin=base64_encode($fileBin);
7466
 
7467
		#如果 $conf["delFile"] 等於 "true"
7468
		if($conf["delFile"]=="true"){
7469
 
7470
			#移除檔案
7471
			#函式說明:
7472
			#移除檔案
7473
			#回傳結果:
7474
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
7475
			#$result["error"],錯誤訊息陣列
7476
			#$result["warning"],警告訊息陣列
7477
			#$result["function"],當前執行的函數名稱
7478
			#必填參數:
7479
			$conf["fileAccess::delFile"]["fileAddress"]=$conf["filePosition"];#要移除檔案的位置
7480
			$del=fileAccess::delFile($conf["fileAccess::delFile"]);
7481
			unset($conf["fileAccess::delFile"]);
7482
 
7483
			#如果移除圖片失敗
7484
			if($del["status"]=="false"){
7485
 
7486
				#設置執行失敗
7487
				$result["status"]="false";
7488
 
7489
				#設置錯誤訊息
7490
				$result["error"]=$del;
7491
 
7492
				#回傳結果
7493
				return $result;
7494
 
7495
				}#if end
7496
 
7497
			}#if end
7498
 
7499
		#放置檔案的語法
7500
		$result["content"]="data:".$conf["mimeType"].";".$conf["compressType"].",".$base64fileBin;
7501
 
7502
		#執行到這邊代表執行正常
7503
		$result["status"]="true";
7504
 
7505
		#回傳結果
7506
		return $result;
7507
 
7508
		}#function data end
7509
 
7510
	/*
7511
	#函式說明:
7512
	#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
7513
	#回傳結果:
7514
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
7515
	#$result["error"],錯誤訊息陣列.
7516
	#$result["function"],函數名稱. 
7517
	#$result["argu"],使用的參數.
7518
	#$result["content"],網址,若是在命令列執行,則為"null".
7519
	#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
7520
	#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
7521
	#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
7522
	#必填參數:
7523
	#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
7524
	$conf["address"]="";
7525
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
7526
	$conf["fileArgu"]=__FILE__;
7527
	#可省略參數:
7528
	#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
7529
	#$conf["userDir"]="true";
7530
	#參考資料:
7531
	#無.
7532
	#備註:
7533
	#無.
7534
	*/
7535
	public static function getInternetAddress(&$conf){
7536
 
7537
		#初始化要回傳的變數
7538
		$result=array();
7539
 
7540
		#記錄當前執行的函數名稱
7541
		$result["function"]=__FUNCTION__;
7542
 
7543
		#如果 $conf 不為陣列
7544
		if(gettype($conf)!="array"){
7545
 
7546
			#設置執行失敗
7547
			$result["status"]="false";
7548
 
7549
			#設置執行錯誤訊息
7550
			$result["error"][]="\$conf變數須為陣列形態";
7551
 
7552
			#如果傳入的參數為 null
7553
			if($conf==null){
7554
 
7555
				#設置執行錯誤訊息
7556
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
7557
 
7558
				}#if end
7559
 
7560
			#回傳結果
7561
			return $result;
7562
 
7563
			}#if end
7564
 
7565
		#取得使用的參數
7566
		$result["argu"]=$conf;
7567
 
7568
		#檢查參數
7569
		#函式說明:
7570
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
7571
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7572
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
7573
		#$result["function"],當前執行的函式名稱.
7574
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
7575
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
7576
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
7577
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
7578
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
7579
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
7580
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
7581
		#必填寫的參數:
7582
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
7583
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
7584
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
7585
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("address","fileArgu");
7586
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
7587
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
7588
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
7589
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
7590
		#可以省略的參數:
7591
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
7592
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
7593
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
7594
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("userDir");
7595
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
7596
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
7597
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
7598
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
7599
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
7600
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array();
7601
		#參考資料來源:
7602
		#array_keys=>http://php.net/manual/en/function.array-keys.php
7603
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
7604
		unset($conf["variableCheck::checkArguments"]);
7605
 
7606
		#如果檢查失敗
7607
		if($checkResult["status"]==="false"){
7608
 
7609
			#設置錯誤狀態
7610
			$result["status"]="false";
7611
 
7612
			#設置錯誤提示
7613
			$result["error"]=$checkResult;
7614
 
7615
			#回傳結果
7616
			return $result;
7617
 
7618
			}#if end
7619
 
7620
		#如果檢查不通過
7621
		if($checkResult["passed"]==="false"){
7622
 
7623
			#設置錯誤狀態
7624
			$result["status"]="false";
7625
 
7626
			#設置錯誤提示
7627
			$result["error"]=$checkResult;
7628
 
7629
			#回傳結果
7630
			return $result;
7631
 
7632
			}#if end
7633
 
7634
		#如果是本來就是網址了
7635
		if(strpos($conf["address"],'https://')===0 || strpos($conf["address"],'http://')===0){
7636
 
7637
			#設置執行正常
7638
			$result["status"]="true";
7639
 
7640
			#取得網址
7641
			$result["content"]=$conf["address"];
7642
 
7643
			#回傳結果
7644
			return $result;			
7645
 
7646
			}#if end	
7647
 
7648
		#解析 $conf["fileArgu"]
7649
		#函式說明:
7650
		#將固定格式的字串分開,並回傳分開的結果。
7651
		#回傳的參數:
7652
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7653
		#$result["error"],錯誤訊息陣列
7654
		#$result["function"],當前執行的函數名稱.
7655
		#$result["oriStr"],要分割的原始字串內容
7656
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
7657
		#$result["dataCounts"],爲總共分成幾段
7658
		#必填參數:
7659
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["fileArgu"];#要處理的字串。
7660
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
7661
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7662
		unset($conf["stringProcess::spiltString"]); 
7663
 
7664
		#如果分割字串失敗
7665
		if($spiltString["status"]==="false"){
7666
 
7667
			#設置錯誤狀態
7668
			$result["status"]="false";
7669
 
7670
			#設置錯誤提示
7671
			$result["error"]=$spiltString;
7672
 
7673
			#回傳結果
7674
			return $result;
7675
 
7676
			}#if end
7677
 
7678
		#函式說明:
7679
		#將多個路徑字串變成相對於當前路徑的相對路徑字串
7680
		#回傳結果:
7681
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
7682
		#$result["error"],錯誤訊息陣列.
7683
		#$result["function"],函數名稱. 
7684
		#$result["content"],字串陣列,多個轉換好的相對路徑字串.
7685
		#必填參數:
7686
		#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
7687
		$conf["fileAccess::getRelativePath"]["path"]=array($conf["address"]);
7688
		#$conf["fileArgu"],字串,當前路徑.
7689
		$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
7690
		$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
7691
		unset($conf["fileAccess::getRelativePath"]);
7692
 
7693
		#如果取得相對位置失敗
7694
		if($getRelativePath["status"]==="false"){
7695
 
7696
			#設置錯誤狀態
7697
			$result["status"]="false";
7698
 
7699
			#設置錯誤提示
7700
			$result["error"]=$getRelativePath;
7701
 
7702
			#回傳結果
7703
			return $result;
7704
 
7705
			}#if end			
7706
 
7707
		#取得轉換成相對路徑的位置
7708
		$result["fileSystemRelativePosition"]=$getRelativePath["content"][0];
7709
 
7710
		#解析 $conf["fileArgu"]
7711
		#函式說明:
7712
		#將固定格式的字串分開,並回傳分開的結果。
7713
		#回傳的參數:
7714
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7715
		#$result["error"],錯誤訊息陣列
7716
		#$result["function"],當前執行的函數名稱.
7717
		#$result["oriStr"],要分割的原始字串內容
7718
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
7719
		#$result["dataCounts"],爲總共分成幾段
7720
		#必填參數:
7721
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["fileArgu"];#要處理的字串。
7722
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
7723
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7724
		unset($conf["stringProcess::spiltString"]); 
7725
 
7726
		#如果分割字串失敗
7727
		if($spiltString["status"]==="false"){
7728
 
7729
			#設置錯誤狀態
7730
			$result["status"]="false";
7731
 
7732
			#設置錯誤提示
7733
			$result["error"]=$spiltString;
7734
 
7735
			#回傳結果
7736
			return $result;
7737
 
7738
			}#if end
7739
 
7740
		#debug
7741
		#var_dump($spiltString);
7742
		#var_dump($_SERVER);
7743
 
7744
		#初始化檔案在伺服器上的檔案系統位置
7745
		$result["fileSystemAbsoulutePosition"]="/";
7746
 
7747
		#將最後一段捨棄
7748
		for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
7749
 
7750
			$result["fileSystemAbsoulutePosition"]=$result["fileSystemAbsoulutePosition"].$spiltString["dataArray"][$i]."/";
7751
 
7752
			}#for end				
7753
 
7754
		#取得非直觀的絕對位置
7755
		$result["fileSystemAbsoulutePosition"]=$result["fileSystemAbsoulutePosition"].$result["fileSystemRelativePosition"];
7756
 
7757
		#將檔案的相對路徑進行整理,變成可以直接讀的路徑.
7758
		#函式說明:
7759
		#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
7760
		#回傳的結果:
7761
		#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
7762
		#$result["function"],當前執行的函數.
7763
		#$result["error"],錯誤訊息陣列.
7764
		#$result["changedPath"],處理完後回傳的目錄字串.
7765
		#$result["oriPath"],原始的路徑字串
7766
		#必填參數:
7767
		#$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"],字串,要處理的檔案目錄字串.
7768
		$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"]=$result["fileSystemAbsoulutePosition"];
7769
		$changeDirByDotDotSolidus=stringProcess::changeDirByDotDotSolidus($conf["stringProcess::changeDirByDotDotSolidus"]);
7770
		unset($conf["stringProcess::changeDirByDotDotSolidus"]);
7771
 
7772
		#如果處理失敗
7773
		if($changeDirByDotDotSolidus["status"]==="false"){
7774
 
7775
			#設置錯誤狀態
7776
			$result["status"]="false";
7777
 
7778
			#設置錯誤提示
7779
			$result["error"]=$changeDirByDotDotSolidus;
7780
 
7781
			#回傳結果
7782
			return $result;
7783
 
7784
			}#if end
7785
 
7786
		#改變為易讀的絕對路徑
7787
		$result["fileSystemAbsoulutePosition"]=$changeDirByDotDotSolidus["changedPath"];	
7788
 
7789
		#如果 $conf["userDir"] 為 "true"
7790
		if($conf["userDir"]==="true"){
7791
 
7792
			#重設為 絕對路徑 [/~家目錄名稱」
7793
			$result["webPathFromRoot"]="/~".$spiltString["dataArray"][1];
7794
 
7795
			#從第四段到倒數第二段,將其內容合併
7796
			for($i=3;$i<$spiltString["dataCounts"]-1;$i++){
7797
 
7798
				$result["webPathFromRoot"]=$result["webPathFromRoot"]."/".$spiltString["dataArray"][$i];
7799
 
7800
				}#for end
7801
 
7802
			}#if end
7803
 
7804
		#反之 $conf["userDir"] 為 "false",
7805
		else{
7806
 
7807
			#重設為 ""
7808
			$result["webPathFromRoot"]="";
7809
 
7810
			#可能的根目錄層級 - start 
7811
 
7812
			#解析 $conf["fileArgu"]
7813
			#函式說明:
7814
			#將固定格式的字串分開,並回傳分開的結果。
7815
			#回傳的參數:
7816
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7817
			#$result["error"],錯誤訊息陣列
7818
			#$result["function"],當前執行的函數名稱.
7819
			#$result["oriStr"],要分割的原始字串內容
7820
			#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
7821
			#$result["dataCounts"],爲總共分成幾段
7822
			#必填參數:
7823
			$conf["stringProcess::spiltString"]["stringIn"]=$_SERVER["PHP_SELF"];#要處理的字串。
7824
			$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
7825
			$keyWord=stringProcess::spiltString($conf["stringProcess::spiltString"]);
7826
			unset($conf["stringProcess::spiltString"]); 
7827
 
7828
			#如果處理失敗
7829
			if($keyWord["status"]==="false"){
7830
 
7831
				#設置錯誤狀態
7832
				$result["status"]="false";
7833
 
7834
				#設置錯誤提示
7835
				$result["error"]=$keyWord;
7836
 
7837
				#回傳結果
7838
				return $result;
7839
 
7840
				}#if end
7841
 
7842
			#取得關鍵字
7843
			$keyWord=$keyWord["dataArray"][0];
7844
 
7845
			#預設層級為4層
7846
			$layer=4;
7847
 
7848
			#檢查每個絕對路徑片段
7849
			for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
7850
 
7851
				#如果路徑片段等於 $keyWord
7852
				if($spiltString["dataArray"][$i]===$keyWord){
7853
 
7854
					#取得層級
7855
					$layer=$i;
7856
 
7857
					#跳出迴圈
7858
					break;
7859
 
7860
					}#if end
7861
 
7862
				}#for end
7863
 
7864
			#可能的根目錄層級 - end
7865
 
7866
			#網頁於檔案系統中的存放路徑可能為「/var/www/html」,從第四段到倒數第二段,將其內容合併
7867
			for($i=$layer;$i<$spiltString["dataCounts"]-1;$i++){
7868
 
7869
				$result["webPathFromRoot"]=$result["webPathFromRoot"]."/".$spiltString["dataArray"][$i];
7870
 
7871
				}#for end
7872
 
7873
			}#else end
7874
 
7875
		#加上檔案的路徑
7876
		$result["webPathFromRoot"]=$result["webPathFromRoot"]."/".$conf["address"];			
7877
 
7878
		#取得檔案位於網頁伺服器的絕對位置
7879
		#函式說明:
7880
		#取得用戶端的資訊,並依據需要寫入到資料表裡面
7881
		#回傳結果:
7882
		#$result["status"],執行是否正常,"true"代表執行成功,"false"代表執行失敗.
7883
		#$result["error"],錯誤訊息.
7884
		#$result["function"],檔前執行的函數名稱.
7885
		#$result["userBrowserType"],爲使用者的瀏覽器資訊
7886
		#$result["userIp"],爲使用者的IP
7887
		#$result["serverIp"],為伺服器的IP
7888
		#$result["scheme"],通訊協定
7889
		#$result["serverPort"],伺服器給對外下載網頁的port
7890
		#$result["requestUri"],爲使用者要求的網址
7891
		#$result["username"],爲使用者目前的帳戶,若爲""則表示尚未登入成功
7892
		#$result["clientRequestIP"],用戶端要求的ip與port
7893
		#必填參數:
7894
		$conf["csInformation::getConnectionInfo"]["getAccount"]="false";#是否要取得帳號
7895
		#可省略參數:
7896
		#$conf["accountVar"]=$_SESSION["username"];#帳號儲存在哪個變數裏面,預設爲$_SESSION["username"]
7897
		#$conf["saveToDb"]="true";#是否要除儲存到資料庫,"true"為要儲存",預設為不儲存
7898
		#$conf["dbAddress"]=$dbAddress;;#爲mysql-Server的位置,若#$conf["saveToDb"]設為"true",則該參數為必填。
7899
		#$conf["dbAccount"]=$dbAccount;#爲用於連入mysql-Server時要使用的帳號,若#$conf["saveToDb"]設為"true",則該參數為必填。
7900
		#$conf["dbName"]=$dbName;#要選取的資料庫名稱,若#$conf["saveToDb"]設為"true",則該參數為必填。
7901
		#$conf["tableName"]="visitorInfo";#爲要插入資料的資料表名稱,若#$conf["saveToDb"]設為"true",則該參數為必填。
7902
		#$conf["columnName"]=array("username","userWebBrowser","userIp","requestUri","systemDateAndTime");#爲資料表的項目名稱,
7903
			#例如:$conf["columnName"]=array("columnName1","columnName2","columnName3",...);
7904
			#寫入的資料依序為,使用者帳戶、瀏覽器資訊、使用者IP、觀看的網址、當時的時間
7905
			#$conf["saveToDb"]設為"true",則該參數為必填。
7906
		#$conf["dbPassword"]=$dbPassword;#爲連線到mysql-Server時要使用的密碼,可省略,若省略則代表不使用密碼
7907
		$getConnectionInfo=csInformation::getConnectionInfo($conf["csInformation::getConnectionInfo"]);
7908
		unset($conf["csInformation::getConnectionInfo"]);	
7909
 
7910
		#如果取得連線資訊失敗
7911
		if($getConnectionInfo["status"]==="false"){
7912
 
7913
			#設置錯誤狀態
7914
			$result["status"]="false";
7915
 
7916
			#設置錯誤提示
7917
			$result["error"]=$getConnectionInfo;
7918
 
7919
			#回傳結果
7920
			return $result;
7921
 
7922
			}#if end
7923
 
7924
		#如果運行環境為 "web"
7925
		if($getConnectionInfo["mode"]=="web"){
7926
 
7927
			#為絕對路徑加上通訊協定與ip與port
7928
			#$result["content"]=$getConnectionInfo["scheme"]."://".$getConnectionInfo["serverIp"].":".$getConnectionInfo["serverPort"].$result["webPathFromRoot"];	
7929
 
7930
			#為絕對路徑加上用戶端通訊協定與ip與port	
7931
			$result["content"]=$getConnectionInfo["scheme"]."://".$getConnectionInfo["clientRequestIP"].$result["webPathFromRoot"];
7932
 
7933
			}#if end
7934
 
7935
		#反之如果為 "cmd" 環境
7936
		else{
7937
 
7938
			$result["content"]="null";
7939
 
7940
			}#else end
7941
 
7942
		#設置執行正常
7943
		$result["status"]="true";
7944
 
7945
		#回傳結果
7946
		return $result;
7947
 
7948
		}#function getInternetAddress end
7949
 
7950
	/*
7951
	#函式說明:
7952
	#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
7953
	#回傳結果:
7954
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
7955
	#$result["error"],錯誤訊息陣列.
7956
	#$result["function"],函數名稱. 
7957
	#$result["argu"],使用的參數.
7958
	#$result["content"],網址,若是在命令列執行,則為"null".
7959
	#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
7960
	#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
7961
	#必填參數:
7962
	#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
7963
	$conf["address"]="";
7964
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
7965
	$conf["fileArgu"]=__FILE__;
7966
	#可省略參數:
7967
	#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
7968
	#$conf["web"]="true";
7969
	#參考資料:
7970
	#無.
7971
	#備註:
7972
	#無.
7973
	*/
7974
	public static function getInternetAddressV2(&$conf){
7975
 
7976
		#初始化要回傳的變數
7977
		$result=array();
7978
 
7979
		#記錄當前執行的函數名稱
7980
		$result["function"]=__FUNCTION__;
7981
 
7982
		#取得參數
7983
		$result["argu"]=$conf;
7984
 
7985
		#檢查參數
7986
		#函式說明:
7987
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
7988
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7989
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
7990
		#$result["function"],當前執行的函式名稱.
7991
		#$result["argu"],設置給予的參數.
7992
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
7993
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
7994
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
7995
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
7996
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
7997
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
7998
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
7999
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
8000
		#必填寫的參數:
8001
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
8002
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
8003
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
8004
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
8005
		#可以省略的參數:
8006
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
8007
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("address","fileArgu");
8008
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
8009
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
8010
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
8011
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
8012
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
8013
		#$conf["canNotBeEmpty"]=array();
8014
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
8015
		#$conf["canBeEmpty"]=array();
8016
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
8017
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web");
8018
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
8019
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
8020
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
8021
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
8022
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
8023
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
8024
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
8025
		#$conf["disallowAllSkipableVarIsEmpty"]="";
8026
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
8027
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
8028
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
8029
		#$conf["arrayCountEqualCheck"][]=array();
8030
		#參考資料來源:
8031
		#array_keys=>http://php.net/manual/en/function.array-keys.php
8032
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
8033
		unset($conf["variableCheck::checkArguments"]);
8034
 
8035
		#如果檢查失敗
8036
		if($checkArguments["status"]==="false"){
8037
 
8038
			#設置錯誤狀態
8039
			$result["status"]="false";
8040
 
8041
			#設置錯誤提示
8042
			$result["error"]=$checkArguments;
8043
 
8044
			#回傳結果
8045
			return $result;
8046
 
8047
			}#if end
8048
 
8049
		#如果檢查不通過
8050
		if($checkArguments["passed"]==="false"){
8051
 
8052
			#設置錯誤狀態
8053
			$result["status"]="false";
8054
 
8055
			#設置錯誤提示
8056
			$result["error"]=$checkArguments;
8057
 
8058
			#回傳結果
8059
			return $result;
8060
 
8061
			}#if end
8062
 
8063
		#如果是本來就是網址了
8064
		if(strpos($conf["address"],'https://')===0 || strpos($conf["address"],'http://')===0){
8065
 
8066
			#取得網址
8067
			$result["content"]=$conf["address"];
8068
 
8069
			}#if end
8070
 
8071
		#反之是絕對或相對路徑
8072
		else{
8073
 
8074
			#確認 $conf["address"] 是否為 escaped 後的內容
8075
			#函式說明:
8076
			#判斷字串是否一定需要經過escapeshellarg才能為單一shell參數,並回傳可以成為單一shell參數的結果.
8077
			#回傳結果:
8078
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8079
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
8080
			#$result["function"],當前執行的函式名稱.
8081
			#$result["argu"],使用的參數.
8082
			#$result["content"],字串,單一shell參數.
8083
			#$result["escaped"],字串,"true"代表content為 escape後的結果;反之為"false".
8084
			#$result["urlEncodeStr"],字串,未被escape過的單一shell參數被url encode後的結果.
8085
			#必填參數:
8086
			#$conf["str"],字串,認為要為單一 shell參數的字串.
8087
			$conf["stringProcess::toSingleShellArg"]["str"]=$conf["address"];
8088
			#可省略參數:
8089
			#無.
8090
			#參考資料:
8091
			#無.
8092
			#備註:
8093
			#無.
8094
			$toSingleShellArg=stringProcess::toSingleShellArg($conf["stringProcess::toSingleShellArg"]);
8095
			unset($conf["stringProcess::toSingleShellArg"]);
8096
 
8097
			#如果執行失敗
8098
			if($toSingleShellArg["status"]==="false"){
8099
 
8100
				#設置錯誤狀態
8101
				$result["status"]="false";
8102
 
8103
				#設置錯誤提示
8104
				$result["error"]=$toSingleShellArg;
8105
 
8106
				#回傳結果
8107
				return $result;
8108
 
8109
				}#if end
8110
 
8111
			#取得不含escape字元的address參數
8112
			$conf["address"]=urldecode($toSingleShellArg["urlEncodeStr"]);
8113
 
8114
			#不是絕對位置
8115
			if(strpos($conf["address"],"/")!==0){
8116
 
8117
				#如果有這些參數
8118
				if( isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) ){
8119
 
8120
					#網址
8121
					$result["content"]=$_SERVER['REQUEST_SCHEME']."://".$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT']."/".$conf["address"];
8122
 
8123
					}#if end
8124
 
8125
				#反之
8126
				else{
8127
 
8128
					#網址設置為 null
8129
					$result["content"]=null;
8130
 
8131
					}#else
8132
 
8133
				}#if end
8134
 
8135
			#反之是絕對位置
8136
			else{
8137
 
8138
				#移除開頭的 "/"
8139
				$conf["address"]=substr($conf["address"],1);
8140
 
8141
				#如果有這些參數
8142
				if( isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) ){
8143
 
8144
					#網址
8145
					$result["content"]=$_SERVER['REQUEST_SCHEME']."://".$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT']."/".$conf["address"];
8146
 
8147
					}#if end
8148
 
8149
				#反之
8150
				else{
8151
 
8152
					#網址設置為 null
8153
					$result["content"]=null;
8154
 
8155
					}#else
8156
 
8157
				}#else end
8158
 
8159
			#取得 doc root;
8160
			$docRoot=$_SERVER['DOCUMENT_ROOT'];
8161
 
8162
			#如果不是網路環境
8163
			if($conf["web"]==="false"){
8164
 
8165
				#不採用 docRoot
8166
				$docRoot="";
8167
 
8168
				}#if end
8169
 
8170
			#如果不存在 DOCUMENT_ROOT 變數或 web 參數為 "false" 且為相對位置.
8171
			if( ($_SERVER['DOCUMENT_ROOT']==="" || $conf["web"]==="false") && (strpos($result["argu"]["address"],"/")!==0) ){
8172
 
8173
				#執行 "pwd" 取得當前位置
8174
				exec("pwd",$output,$status);
8175
 
8176
				#預設為`pwd`的結果加"/"
8177
				$docRoot=$output[0]."/";
8178
 
8179
				}#if end	
8180
 
8181
			#如果是絕對位置
8182
			else if(strpos($result["argu"]["address"],"/")===0){
8183
 
8184
				#補回 "/" 
8185
				$conf["address"]="/".$conf["address"];
8186
 
8187
				}#if end
8188
 
8189
			#針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
8190
			$result["fileSystemAbsoulutePosition"]=$docRoot.$conf["address"];
8191
 
8192
			}#else end
8193
 
8194
		#設置執行正常
8195
		$result["status"]="true";	
8196
 
8197
		#回傳結果
8198
		return $result;
8199
 
8200
		}#function getInternetAddressV2 end
8201
 
8202
	/*
8203
	#函式說明:
8204
	#將含有「*」的檔案路徑名稱,變成多個符合條件的路徑檔案.
8205
	#回傳結果:
8206
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
8207
	#$result["error"],錯誤訊息陣列.
8208
	#$result["function"],函數名稱. 
8209
	#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
8210
	#必填參數:
8211
	#$conf["path"],字串,要解析含有「*」的檔案路徑字串.
8212
	$conf["path"]="";
8213
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
8214
	$conf["fileArgu"]=__FILE__;
8215
	#可省略參數:
8216
	#$conf["noDotStart"],字串,"true"代表不包含「.」開頭的名稱,預設為"false"代表包含「.」開頭的名稱.
8217
	#$conf["noDotStart"]="true";
8218
	#$conf["noWaveEnd"],字串,預設為"true"代表不包含「~」結尾的名稱,"false"代表包含結尾為「~」的名稱.
8219
	#$conf["noWaveEnd"]="true";
8220
	#參考資料:
8221
	#無.
8222
	#備註:
8223
	#無.
8224
	*/
8225
	public static function resolvePostionStringWhichContainStarSymbol(&$conf){
8226
 
8227
		#初始化要回傳的結果
8228
		$result=array();
8229
 
8230
		#設置當其函數名稱
8231
		$result["function"]=__FUNCTION__;
8232
 
8233
		#如果 $conf 不為陣列
8234
		if(gettype($conf)!="array"){
8235
 
8236
			#設置執行失敗
8237
			$result["status"]="false";
8238
 
8239
			#設置執行錯誤訊息
8240
			$result["error"][]="\$conf變數須為陣列形態";
8241
 
8242
			#如果傳入的參數為 null
8243
			if($conf==null){
8244
 
8245
				#設置執行錯誤訊息
8246
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
8247
 
8248
				}#if end
8249
 
8250
			#回傳結果
8251
			return $result;
8252
 
8253
			}#if end
8254
 
8255
		#檢查參數
8256
		#函式說明:
8257
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
8258
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8259
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
8260
		#$result["function"],當前執行的函式名稱.
8261
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
8262
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
8263
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
8264
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
8265
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
8266
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
8267
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
8268
		#必填寫的參數:
8269
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
8270
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
8271
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
8272
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
8273
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
8274
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
8275
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
8276
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
8277
		#可以省略的參數:
8278
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
8279
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
8280
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
8281
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("noDotStart","noWaveEnd");
8282
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
8283
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
8284
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
8285
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","true");
8286
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
8287
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
8288
		#參考資料來源:
8289
		#array_keys=>http://php.net/manual/en/function.array-keys.php
8290
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
8291
		unset($conf["variableCheck::checkArguments"]);
8292
 
8293
		#如果 $checkResult["status"] 等於 "fasle"
8294
		if($checkResult["status"]==="false"){
8295
 
8296
			#設置錯誤識別
8297
			$result["status"]="false";
8298
 
8299
			#設置錯誤訊息
8300
			$result["error"]=$checkResult;
8301
 
8302
			#回傳結果
8303
			return $result;
8304
 
8305
			}#if end
8306
 
8307
		#如果 $checkResult["passed"] 等於 "fasle"
8308
		if($checkResult["passed"]==="false"){
8309
 
8310
			#設置錯誤識別
8311
			$result["status"]="false";
8312
 
8313
			#設置錯誤訊息
8314
			$result["error"]=$checkResult;
8315
 
8316
			#回傳結果
8317
			return $result;
8318
 
8319
			}#if end
8320
 
8321
		#轉換檔案路徑為相對於伺服器檔案系統的絕對路徑
8322
		#函式說明:
8323
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
8324
		#回傳結果:
8325
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
8326
		#$result["error"],錯誤訊息陣列.
8327
		#$result["function"],函數名稱. 
8328
		#$result["content"],網址.
8329
		#$result["localAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
8330
		#$result["fileSystemAbsoulutePosition"],針對伺服器檔案系統的絕對位置.
8331
		#必填參數:
8332
		#$conf["address"],字串,檔案的相對位置.
8333
		$conf["fileAccess::getInternetAddress"]["address"]=$conf["path"];
8334
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
8335
		$conf["fileAccess::getInternetAddress"]["fileArgu"]=$conf["fileArgu"];
8336
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是.
8337
		$conf["fileAccess::getInternetAddress"]["userDir"]="true";
8338
		$getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
8339
		unset($conf["fileAccess::getInternetAddress"]);
8340
 
8341
		#如果轉換路徑失敗
8342
		if($getInternetAddress["status"]=="false"){
8343
 
8344
			#設置錯誤識別
8345
			$result["status"]="false";
8346
 
8347
			#設置錯誤訊息
8348
			$result["error"]=$checkResult;
8349
 
8350
			#回傳結果
8351
			return $result;
8352
 
8353
			}#if end
8354
 
8355
		#取得轉換好的路徑
8356
		$conf["path"]=$getInternetAddress["fileSystemAbsoulutePosition"];
8357
 
8358
		#檢查檔案路徑字串是否含有「*」
8359
		#函式說明:
8360
		#檢查字串裡面有無指定的關鍵字
8361
		#回傳結果:
8362
		#$result["status"],"true"代表執行成功,"false"代表執行失敗。
8363
		#$result["error"],錯誤訊息
8364
		#$result["function"],當前執行的函數名稱.
8365
		#$result["founded"],是否找到關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
8366
		#$result["keyWordCount"],找到的關鍵字數量.
8367
		#必填參數:
8368
		$conf["search::findKeyWord"]["keyWord"]="*";#想要搜尋的關鍵字
8369
		$conf["search::findKeyWord"]["string"]=$conf["path"];#要被搜尋的字串內容
8370
		#可省略參數:
8371
		#$conf["fileAccess::findKeyWord"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
8372
		$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
8373
		unset($conf["search::findKeyWord"]);
8374
 
8375
		#如果尋找關鍵字出錯
8376
		if($findKeyWord["status"]=="false"){
8377
 
8378
			#設置錯誤識別
8379
			$result["status"]="false";
8380
 
8381
			#設置錯誤訊息
8382
			$result["error"]=$findKeyWord;
8383
 
8384
			#回傳結果
8385
			return $result;
8386
 
8387
			}#if end
8388
 
8389
		#如果含有「*」
8390
		if($findKeyWord["founded"]=="true"){
8391
 
8392
			#透過「/」分割路徑字串
8393
			#函式說明:
8394
			#將固定格式的字串分開,並回傳分開的結果。
8395
			#回傳的參數:
8396
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8397
			#$result["error"],錯誤訊息陣列
8398
			#$result["function"],當前執行的函數名稱.
8399
			#$result["oriStr"],要分割的原始字串內容
8400
			#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
8401
			#$result["dataCounts"],爲總共分成幾段
8402
			#必填參數:
8403
			$conf["stringProcess::spiltString"]["stringIn"]=$conf["path"];#要處理的字串。
8404
			$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
8405
			$spiltPathStr=stringProcess::spiltString($conf["stringProcess::spiltString"]);
8406
			unset($conf["stringProcess::spiltString"]);
8407
 
8408
			#如果分割字串失敗
8409
			if($spiltPathStr["status"]=="false"){
8410
 
8411
				#設置錯誤識別
8412
				$result["status"]="false";
8413
 
8414
				#設置錯誤訊息
8415
				$result["error"]=$spiltPathStr;
8416
 
8417
				#回傳結果
8418
				return $result;
8419
 
8420
				}#if end
8421
 
8422
			#初始化暫存展開後的檔案路徑字串
8423
			$extendPath=array("");			
8424
 
8425
			#要解析的路徑分成幾段就執行幾次
8426
			foreach($spiltPathStr["dataArray"] as $pathPart){
8427
 
8428
				#檢查該段名稱是否有「*」
8429
				#函式說明:
8430
				#檢查字串裡面有無指定的關鍵字
8431
				#回傳結果:
8432
				#$result["status"],"true"代表執行成功,"false"代表執行失敗。
8433
				#$result["error"],錯誤訊息
8434
				#$result["function"],當前執行的函數名稱.
8435
				#$result["founded"],是否找到關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
8436
				#$result["keyWordCount"],找到的關鍵字數量.
8437
				#必填參數:
8438
				$conf["search::findKeyWord"]["keyWord"]="*";#想要搜尋的關鍵字
8439
				$conf["search::findKeyWord"]["string"]=$pathPart;#要被搜尋的字串內容
8440
				#可省略參數:
8441
				#$conf["fileAccess::findKeyWord"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
8442
				$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
8443
				unset($conf["search::findKeyWord"]);
8444
 
8445
				#如果尋找關鍵字出錯
8446
				if($findKeyWord["status"]=="false"){
8447
 
8448
					#設置錯誤識別
8449
					$result["status"]="false";
8450
 
8451
					#設置錯誤訊息
8452
					$result["error"]=$findKeyWord;
8453
 
8454
					#回傳結果
8455
					return $result;
8456
 
8457
					}#if end									
8458
 
8459
				#如果不含「*」
8460
				if($findKeyWord["founded"]=="false"){
8461
 
8462
					#針對每個既有的路徑
8463
					for($i=0;$i<count($extendPath);$i++){
8464
 
8465
						#加上切割好的路徑
8466
						$extendPath[$i]=$extendPath[$i]."/".$pathPart;
8467
 
8468
						}#for end
8469
 
8470
					}#if end
8471
 
8472
				#反之該段含有「*」	
8473
				else{
8474
 
8475
					#用「*」分割該段
8476
					#函式說明:
8477
					#將固定格式的字串分開,並回傳分開的結果。
8478
					#回傳的參數:
8479
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8480
					#$result["error"],錯誤訊息陣列
8481
					#$result["function"],當前執行的函數名稱.
8482
					#$result["oriStr"],要分割的原始字串內容
8483
					#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
8484
					#$result["dataCounts"],爲總共分成幾段
8485
					#必填參數:
8486
					$conf["stringProcess::spiltString"]["stringIn"]=$pathPart;#要處理的字串。
8487
					$conf["stringProcess::spiltString"]["spiltSymbol"]="*";#爲以哪個符號作爲分割
8488
					$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
8489
					unset($conf["stringProcess::spiltString"]);
8490
 
8491
					#如果分字串失敗
8492
					if($spiltString["status"]=="false"){
8493
 
8494
						#設置錯誤識別
8495
						$result["status"]="false";
8496
 
8497
						#設置錯誤訊息
8498
						$result["error"]=$spiltStringByStar;
8499
 
8500
						#回傳結果
8501
						return $result;
8502
 
8503
						}#if end
8504
 
8505
					#如果用「*」分割後的段數為0
8506
					if($spiltString["dataCounts"]==0){
8507
 
8508
						#初始化儲存符合條件的路徑
8509
						$newExtendPath=array();
8510
 
8511
						#代表沒有塞選條件
8512
						#當前有幾個符合條件的路徑就執行幾次
8513
						for($i=0;$i<count($extendPath);$i++){
8514
 
8515
							#取得該目錄下所有的東西
8516
							#取得該目錄底下的檔案目錄清單
8517
							#函式說明:
8518
							#取得目錄底下所有目錄與檔案清單.
8519
							#回傳結果:
8520
							#$result["status"],"true"爲建立成功,"false"爲建立失敗.
8521
							#$result["error"],錯誤訊息陣列.
8522
							#$result["function"],函數名稱.
8523
							#$result["content"],陣列,目錄底下的檔案與子目錄.
8524
							#$result["content"][$i]["name"],字串,目錄底下的檔案與子目錄的名稱.
8525
							#$result["content"][$i]["folder"],字串,第$i+1個名稱為目錄還是檔案.
8526
							#$result["folder"],字串,當前目標為目錄還是檔案"true"代表為目錄,"false"代表為檔案.
8527
							#$result["position"],目前的位置.
8528
							#必填參數:
8529
							#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
8530
							$conf["fileAccess::getList"]["position"]=$extendPath[$i];
8531
							#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
8532
							$conf["fileAccess::getList"]["fileArgu"]=$conf["fileArgu"];
8533
							#可省略參數:
8534
							#無
8535
							#參考資料來源:
8536
							#opendir=>http://php.net/manual/en/function.opendir.php
8537
							#is_dir=>http://php.net/manual/en/function.is-dir.php
8538
							$getList=fileAccess::getList($conf["fileAccess::getList"]);
8539
							unset($conf["fileAccess::getList"]);										
8540
 
8541
							#如果取得目標目錄底下的檔案目錄清單失敗
8542
							if($getList["status"]=="false"){
8543
 
8544
								#設置錯誤識別
8545
								$result["status"]="false";
8546
 
8547
								#設置錯誤訊息
8548
								$result["error"]=$getList;																				
8549
 
8550
								#回傳結果
8551
								return $result;
8552
 
8553
								}#if end
8554
 
8555
							#如果底下有東西
8556
							if(count($getList["content"])>0){
8557
 
8558
								#初始化儲存要檢查的檔案或資料夾名稱陣列
8559
								$list=array();
8560
 
8561
								#針對每個檔案或資料夾
8562
								foreach($getList["content"] as $num=>$array){
8563
 
8564
									#儲存該名稱
8565
									$list[]=$array["name"];
8566
 
8567
									}#foreach end
8568
 
8569
								#初始化儲存符合新條件字串的陣列
8570
								$tempExtendPath=array();
8571
 
8572
								#針對每個現有的路徑字串
8573
								for($j=0;$j<count($extendPath);$j++){
8574
 
8575
									#附加每個符合條件的名稱到路徑字串裡面
8576
									for($k=0;$k<count($list);$k++){
8577
 
8578
										#如果 $conf["noDotStart"] 為 "true"
8579
										if($conf["noDotStart"]==="true"){
8580
 
8581
											#將 $list[$k] 用 "/" 分割
8582
											#函式說明:
8583
											#將固定格式的字串分開,並回傳分開的結果。
8584
											#回傳結果:
8585
											#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
8586
											#$result["error"],錯誤訊息陣列
8587
											#$result["function"],當前執行的函數名稱.
8588
											#$result["oriStr"],要分割的原始字串內容
8589
											#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
8590
											#$result["dataCounts"],爲總共分成幾段
8591
											#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
8592
											#必填參數:
8593
											$conf["stringProcess::spiltString"]["stringIn"]=$list[$k];#要處理的字串。
8594
											$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
8595
											#可省略參數:
8596
											#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
8597
											$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
8598
											$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
8599
											unset($conf["stringProcess::spiltString"]);
8600
 
8601
											#如果分割路徑失敗
8602
											if($spiltString["status"]==="false"){
8603
 
8604
												#設置執行錯誤識別
8605
												$result["status"]="false";
8606
 
8607
												#取得錯誤訊息
8608
												$result["error"]=$spiltString;
8609
 
8610
												#回傳結果
8611
												return $result;
8612
 
8613
												}#if end
8614
 
8615
											#如果有關鍵字「/」存在
8616
											if($spiltString["found"]==="true"){
8617
 
8618
												#針對每個段落
8619
												foreach($spiltString["dataArray"] as $pp){
8620
 
8621
													#看該符合的名稱開頭是否包含「.」
8622
													#函式說明:
8623
													#取得符合特定字首與字尾的字串
8624
													#回傳結果:
8625
													#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
8626
													#$result["function"],當前執行的函數名稱.
8627
													#$result["error"],錯誤訊息陣列.
8628
													#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
8629
													#$result["returnString"],爲符合字首條件的字串內容。
8630
													#必填參數:
8631
													#$conf["checkString"],字串,要檢查的字串.
8632
													$conf["search::getMeetConditionsString"]["checkString"]=$pp;
8633
													#可省略參數:
8634
													#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
8635
													$conf["search::getMeetConditionsString"]["frontWord"]=".";
8636
													#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
8637
													#$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
8638
													#參考資料:
8639
													#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
8640
													$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
8641
													unset($conf["search::getMeetConditionsString"]);
8642
 
8643
													#如果 取得符合特定字首的字串 出錯
8644
													if($getMeetConditionsString["status"]=="false"){
8645
 
8646
														#設置執行錯誤識別
8647
														$result["status"]="false";
8648
 
8649
														#設置錯誤訊息
8650
														$result["error"]=$getMeetConditionsString;
8651
 
8652
														#回傳結果
8653
														return $result;
8654
 
8655
														}#if end
8656
 
8657
													#如果有「.」在開頭
8658
													if($getMeetConditionsString["founded"]=="true"){
8659
 
8660
														#忽略這個名稱 
8661
														continue 2;
8662
 
8663
														}#if end
8664
 
8665
													}#foreach end
8666
 
8667
												}#if end
8668
 
8669
											#反之沒有關鍵字「/」存在
8670
											else{
8671
 
8672
												#看該符合的名稱開頭是否包含「.」
8673
												#函式說明:
8674
												#取得符合特定字首與字尾的字串
8675
												#回傳結果:
8676
												#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
8677
												#$result["function"],當前執行的函數名稱.
8678
												#$result["error"],錯誤訊息陣列.
8679
												#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
8680
												#$result["returnString"],爲符合字首條件的字串內容。
8681
												#必填參數:
8682
												#$conf["checkString"],字串,要檢查的字串.
8683
												$conf["search::getMeetConditionsString"]["checkString"]=$list[$k];
8684
												#可省略參數:
8685
												#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
8686
												$conf["search::getMeetConditionsString"]["frontWord"]=".";
8687
												#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
8688
												#$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
8689
												#參考資料:
8690
												#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
8691
												$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
8692
												unset($conf["search::getMeetConditionsString"]);
8693
 
8694
												#如果 取得符合特定字首的字串 出錯
8695
												if($getMeetConditionsString["status"]=="false"){
8696
 
8697
													#設置執行錯誤識別
8698
													$result["status"]="false";
8699
 
8700
													#設置錯誤訊息
8701
													$result["error"]=$getMeetConditionsString;
8702
 
8703
													#回傳結果
8704
													return $result;
8705
 
8706
													}#if end
8707
 
8708
												#如果有「.」在開頭
8709
												if($getMeetConditionsString["founded"]=="true"){
8710
 
8711
													#忽略這個名稱 
8712
													continue;
8713
 
8714
													}#if end
8715
 
8716
												}#else end
8717
 
8718
											}#if end
8719
 
8720
										#如果 $conf["noWaveEnd"] 為 "true"
8721
										if($conf["noWaveEnd"]==="true"){
8722
 
8723
											#看該符合的名稱結尾是否包含「~」
8724
											#函式說明:
8725
											#取得符合特定字首與字尾的字串
8726
											#回傳結果:
8727
											#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
8728
											#$result["function"],當前執行的函數名稱.
8729
											#$result["error"],錯誤訊息陣列.
8730
											#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
8731
											#$result["returnString"],爲符合字首條件的字串內容。
8732
											#必填參數:
8733
											#$conf["checkString"],字串,要檢查的字串.
8734
											$conf["search::getMeetConditionsString"]["checkString"]=$list[$k];
8735
											#可省略參數:
8736
											#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
8737
											#$conf["search::getMeetConditionsString"]["frontWord"]=".";
8738
											#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
8739
											$conf["search::getMeetConditionsString"]["tailWord"]="~";
8740
											#參考資料:
8741
											#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
8742
											$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
8743
											unset($conf["search::getMeetConditionsString"]);
8744
 
8745
											#如果 取得符合特定字首的字串 出錯
8746
											if($getMeetConditionsString["status"]=="false"){
8747
 
8748
												#設置執行錯誤識別
8749
												$result["status"]="false";
8750
 
8751
												#設置錯誤訊息
8752
												$result["error"]=$getMeetConditionsString;
8753
 
8754
												#回傳結果
8755
												return $result;
8756
 
8757
												}#if end
8758
 
8759
											#如果有「~」在結尾
8760
											if($getMeetConditionsString["founded"]=="true"){
8761
 
8762
												#忽略這個名稱
8763
												continue;
8764
 
8765
												}#if end
8766
 
8767
											}#if end
8768
 
8769
										#暫存該符合的路徑
8770
										$tempExtendPath[]=$extendPath[$j]."/".$list[$k];
8771
 
8772
										}#for end
8773
 
8774
									}#for end	
8775
 
8776
								#該次有幾個符合的路徑就執行幾次
8777
								foreach($tempExtendPath as $path){
8778
 
8779
									#暫存符合的路徑
8780
									$newExtendPath[]=$path;
8781
 
8782
									}#for end	
8783
 
8784
								}#if end
8785
 
8786
							#反之該目錄底下沒有東西
8787
							else{
8788
 
8789
								#移除該 $extendPath[$i]
8790
								unset($extendPath[$i]);
8791
 
8792
								}#else end					
8793
 
8794
							}#for end
8795
 
8796
						#置換原始符合條件字串的路徑字串陣列
8797
						$extendPath=$newExtendPath;
8798
 
8799
						}#if end
8800
 
8801
						#反之用「*」分割後有分段
8802
						else{
8803
 
8804
							#初始化暫存符合條件的新路徑陣列變數
8805
							$newExtendPath=array();
8806
 
8807
							#當前有幾個符合條件的路徑就執行幾次
8808
							for($i=0;$i<count($extendPath);$i++){
8809
 
8810
								#取得該目錄下所有的東西
8811
								#函式說明:
8812
								#取得目錄底下所有目錄與檔案清單.
8813
								#回傳結果:
8814
								#$result["status"],"true"爲建立成功,"false"爲建立失敗.
8815
								#$result["error"],錯誤訊息陣列.
8816
								#$result["function"],函數名稱.
8817
								#$result["content"],陣列,目錄底下的檔案與子目錄.
8818
								#$result["content"][$i]["name"],字串,目錄底下的檔案與子目錄的名稱.
8819
								#$result["content"][$i]["folder"],字串,第$i+1個名稱為目錄還是檔案.
8820
								#$result["folder"],字串,當前目標為目錄還是檔案"true"代表為目錄,"false"代表為檔案.
8821
								#$result["position"],目前的位置.
8822
								#必填參數:
8823
								#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
8824
								$conf["fileAccess::getList"]["position"]=$extendPath[$i];
8825
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
8826
								$conf["fileAccess::getList"]["fileArgu"]=$conf["fileArgu"];
8827
								#可省略參數:
8828
								#無
8829
								#參考資料來源:
8830
								#opendir=>http://php.net/manual/en/function.opendir.php
8831
								#is_dir=>http://php.net/manual/en/function.is-dir.php
8832
								$getList=fileAccess::getList($conf["fileAccess::getList"]);
8833
								unset($conf["fileAccess::getList"]);										
8834
 
8835
								#如果取得目標目錄底下的檔案目錄清單失敗
8836
								if($getList["status"]=="false"){
8837
 
8838
									#設置錯誤識別
8839
									$result["status"]="false";
8840
 
8841
									#設置錯誤訊息
8842
									$result["error"]=$getList;																				
8843
 
8844
									#回傳結果
8845
									return $result;
8846
 
8847
									}#if end
8848
 
8849
								#如果底下有東西
8850
								if(count($getList["content"])>0){
8851
 
8852
									#初始化儲存要檢查的檔案或資料夾名稱陣列
8853
									$list=array();
8854
 
8855
									#針對每個檔案或資料夾
8856
									foreach($getList["content"] as $num=>$array){
8857
 
8858
										#儲存該名稱
8859
										$list[]=$array["name"];
8860
 
8861
										}#foreach end
8862
 
8863
									#初始化儲存符合的名稱
8864
									$passedName=array();
8865
 
8866
									#依據每個檔案目錄名稱,檢查有無符合篩選條件
8867
									foreach($list as $filteredName){
8868
 
8869
										#初始化儲存被檢查的片段檔案資料夾名稱
8870
										$partName=$filteredName;
8871
 
8872
										#依據 $pathPart 分割成幾段(關鍵字數量)就執行幾次
8873
										for($i=0;$i<$spiltString["dataCounts"];$i++){
8874
 
8875
											#尋找關鍵字 $spiltString["dataArray"][$i]
8876
											#函式說明:
8877
											#檢查字串裡面有無指定的關鍵字
8878
											#回傳結果:
8879
											#$result["status"],"true"代表執行成功,"false"代表執行失敗。
8880
											#$result["error"],錯誤訊息
8881
											#$result["function"],當前執行的函數名稱.
8882
											#$result["founded"],是否找到關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
8883
											#$result["keyWordCount"],找到的關鍵字數量.
8884
											#必填參數:
8885
											$conf["search::findKeyWord"]["keyWord"]=$spiltString["dataArray"][$i];#想要搜尋的關鍵字
8886
											$conf["search::findKeyWord"]["string"]=$partName;#要被搜尋的字串內容
8887
											#可省略參數:
8888
											#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
8889
											$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
8890
											unset($conf["search::findKeyWord"]);
8891
 
8892
											#如果尋找關鍵字失敗
8893
											if($findKeyWord["status"]=="false"){
8894
 
8895
												#設置執行錯誤識別
8896
												$result["status"]="false";
8897
 
8898
												#設置錯誤訊息
8899
												$result["error"]=$findKeyWord;
8900
 
8901
												#回傳結果
8902
												return $result;
8903
 
8904
												}#if end
8905
 
8906
											#如果有找到關鍵字
8907
											if($findKeyWord["founded"]=="true"){
8908
 
8909
												#如果是最後一段要檢查的關鍵字
8910
												if($i==$spiltString["dataCounts"]-1){
8911
 
8912
													#判斷該關鍵字是否在該未分割的 $pathPart(含有*字號的關鍵字字串) 的開頭
8913
													#函式說明:
8914
													#取得符合特定字首與字尾的字串
8915
													#回傳結果:
8916
													#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
8917
													#$result["function"],當前執行的函數名稱.
8918
													#$result["error"],錯誤訊息陣列.
8919
													#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
8920
													#$result["returnString"],爲符合字首條件的字串內容。
8921
													#必填參數:
8922
													#$conf["checkString"],字串,要檢查的字串.
8923
													$conf["search::getMeetConditionsString"]["checkString"]=$pathPart;
8924
													#可省略參數:
8925
													#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
8926
													$conf["search::getMeetConditionsString"]["frontWord"]=$spiltString["dataArray"][0];
8927
													#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
8928
													#$conf["tailWord"]="";
8929
													#參考資料:
8930
													#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
8931
													$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
8932
													unset($conf["search::getMeetConditionsString"]);
8933
 
8934
													#如果 取得符合特定字首的字串 出錯
8935
													if($getMeetConditionsString["status"]=="false"){
8936
 
8937
														#設置執行錯誤識別
8938
														$result["status"]="false";
8939
 
8940
														#設置錯誤訊息
8941
														$result["error"]=$getMeetConditionsString;
8942
 
8943
														#回傳結果
8944
														return $result;
8945
 
8946
														}#if end
8947
 
8948
													#如果關鍵字是在開頭
8949
													if($getMeetConditionsString["founded"]=="true"){
8950
 
8951
														#判斷關鍵字是否在該檔案目錄名稱的開頭
8952
														#函式說明:
8953
														#取得符合特定字首與字尾的字串
8954
														#回傳結果:
8955
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
8956
														#$result["function"],當前執行的函數名稱.
8957
														#$result["error"],錯誤訊息陣列.
8958
														#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
8959
														#$result["returnString"],爲符合字首條件的字串內容。
8960
														#必填參數:
8961
														#$conf["checkString"],字串,要檢查的字串.
8962
														$conf["search::getMeetConditionsString"]["checkString"]=$filteredName;
8963
														#可省略參數:
8964
														#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
8965
														$conf["search::getMeetConditionsString"]["frontWord"]=$spiltString["dataArray"][0];
8966
														#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
8967
														#$conf["tailWord"]="";
8968
														#參考資料:
8969
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
8970
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
8971
														unset($conf["search::getMeetConditionsString"]);
8972
 
8973
														#如果 取得符合特定字首的字串 出錯
8974
														if($getMeetConditionsString["status"]=="false"){
8975
 
8976
															#設置執行錯誤識別
8977
															$result["status"]="false";
8978
 
8979
															#設置錯誤訊息
8980
															$result["error"]=$getMeetConditionsString;
8981
 
8982
															#回傳結果
8983
															return $result;
8984
 
8985
															}#if end
8986
 
8987
														#如果關鍵字不在開頭
8988
														if($getMeetConditionsString["founded"]=="false"){
8989
 
8990
															#不符合條件,跳過該檔案目錄名稱
8991
															break;
8992
 
8993
															}#if end
8994
 
8995
														}#if end
8996
 
8997
													#判斷最後一個關鍵字是否在該未分割的 $pathPart(含有*字號的關鍵字字串) 的結尾
8998
													#函式說明:
8999
													#取得符合特定字首與字尾的字串
9000
													#回傳結果:
9001
													#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
9002
													#$result["function"],當前執行的函數名稱.
9003
													#$result["error"],錯誤訊息陣列.
9004
													#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
9005
													#$result["returnString"],爲符合字首條件的字串內容。
9006
													#必填參數:
9007
													#$conf["checkString"],字串,要檢查的字串.
9008
													$conf["search::getMeetConditionsString"]["checkString"]=$pathPart;
9009
													#可省略參數:
9010
													#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
9011
													#$conf["search::getMeetConditionsString"]["frontWord"]=$partName;
9012
													#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
9013
													$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
9014
													#參考資料:
9015
													#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9016
													$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9017
													unset($conf["search::getMeetConditionsString"]);
9018
 
9019
													#如果 取得符合特定字尾的字串 出錯
9020
													if($getMeetConditionsString["status"]=="false"){
9021
 
9022
														#設置執行錯誤識別
9023
														$result["status"]="false";
9024
 
9025
														#設置錯誤訊息
9026
														$result["error"]=$getMeetConditionsString;
9027
 
9028
														#回傳結果
9029
														return $result;
9030
 
9031
														}#if end
9032
 
9033
													#如果關鍵字是在字尾
9034
													if($getMeetConditionsString["founded"]=="true"){
9035
 
9036
														#判斷關鍵字是否在該片段的開頭
9037
														#函式說明:
9038
														#取得符合特定字首與字尾的字串
9039
														#回傳結果:
9040
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
9041
														#$result["function"],當前執行的函數名稱.
9042
														#$result["error"],錯誤訊息陣列.
9043
														#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
9044
														#$result["returnString"],爲符合字首條件的字串內容。
9045
														#必填參數:
9046
														#$conf["checkString"],字串,要檢查的字串.
9047
														$conf["search::getMeetConditionsString"]["checkString"]=$filteredName;
9048
														#可省略參數:
9049
														#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
9050
														#$conf["search::getMeetConditionsString"]["frontWord"]=$partName;
9051
														#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
9052
														$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
9053
														#參考資料:
9054
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9055
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9056
														unset($conf["search::getMeetConditionsString"]);
9057
 
9058
														#如果 取得符合特定字首的字串 出錯
9059
														if($getMeetConditionsString["status"]=="false"){
9060
 
9061
															#設置執行錯誤識別
9062
															$result["status"]="false";
9063
 
9064
															#設置錯誤訊息
9065
															$result["error"]=$getMeetConditionsString;
9066
 
9067
															#回傳結果
9068
															return $result;
9069
 
9070
															}#if end
9071
 
9072
														#如果關鍵字不在結尾
9073
														if($getMeetConditionsString["founded"]=="false"){
9074
 
9075
															#不符合條件,跳過該檔案目錄名稱
9076
															break;
9077
 
9078
															}#if end
9079
 
9080
														}#if end
9081
 
9082
													#如果 $conf["noDotStart"] 為 "true"
9083
													if($conf["noDotStart"]==="true"){
9084
 
9085
														#看該符合的名稱開頭是否包含「.」
9086
														#函式說明:
9087
														#取得符合特定字首與字尾的字串
9088
														#回傳結果:
9089
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
9090
														#$result["function"],當前執行的函數名稱.
9091
														#$result["error"],錯誤訊息陣列.
9092
														#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
9093
														#$result["returnString"],爲符合字首條件的字串內容。
9094
														#必填參數:
9095
														#$conf["checkString"],字串,要檢查的字串.
9096
														$conf["search::getMeetConditionsString"]["checkString"]=$filteredName;
9097
														#可省略參數:
9098
														#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
9099
														$conf["search::getMeetConditionsString"]["frontWord"]=".";
9100
														#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
9101
														#$conf["search::getMeetConditionsString"]["tailWord"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
9102
														#參考資料:
9103
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9104
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9105
														unset($conf["search::getMeetConditionsString"]);
9106
 
9107
														#如果 取得符合特定字首的字串 出錯
9108
														if($getMeetConditionsString["status"]=="false"){
9109
 
9110
															#設置執行錯誤識別
9111
															$result["status"]="false";
9112
 
9113
															#設置錯誤訊息
9114
															$result["error"]=$getMeetConditionsString;
9115
 
9116
															#回傳結果
9117
															return $result;
9118
 
9119
															}#if end
9120
 
9121
														#如果有「.」在開頭
9122
														if($getMeetConditionsString["founded"]=="true"){
9123
 
9124
															#中斷迴圈
9125
															break;
9126
 
9127
															}#if end
9128
 
9129
														}#if end
9130
 
9131
													#如果 $conf["noWaveEnd"] 為 "true"
9132
													if($conf["noWaveEnd"]==="true"){
9133
 
9134
														#看該符合的名稱結尾是否包含「~」
9135
														#函式說明:
9136
														#取得符合特定字首與字尾的字串
9137
														#回傳結果:
9138
														#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
9139
														#$result["function"],當前執行的函數名稱.
9140
														#$result["error"],錯誤訊息陣列.
9141
														#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
9142
														#$result["returnString"],爲符合字首條件的字串內容。
9143
														#必填參數:
9144
														#$conf["checkString"],字串,要檢查的字串.
9145
														$conf["search::getMeetConditionsString"]["checkString"]=$filteredName;
9146
														#可省略參數:
9147
														#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
9148
														#$conf["search::getMeetConditionsString"]["frontWord"]=".";
9149
														#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
9150
														$conf["search::getMeetConditionsString"]["tailWord"]="~";
9151
														#參考資料:
9152
														#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9153
														$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9154
														unset($conf["search::getMeetConditionsString"]);
9155
 
9156
														#如果 取得符合特定字首的字串 出錯
9157
														if($getMeetConditionsString["status"]=="false"){
9158
 
9159
															#設置執行錯誤識別
9160
															$result["status"]="false";
9161
 
9162
															#設置錯誤訊息
9163
															$result["error"]=$getMeetConditionsString;
9164
 
9165
															#回傳結果
9166
															return $result;
9167
 
9168
															}#if end
9169
 
9170
														#如果有「~」在結尾
9171
														if($getMeetConditionsString["founded"]=="true"){
9172
 
9173
															#中斷迴圈
9174
															break;
9175
 
9176
															}#if end
9177
 
9178
														}#if end
9179
 
9180
													#取得該符合的名稱
9181
													$passedName[]=$filteredName;
9182
 
9183
													#中斷迴圈
9184
													break;
9185
 
9186
													}#if end
9187
 
9188
												#將 $partName 從左到關鍵字結束的部份剔除
9189
												#函式說明:
9190
												#將特定字串前面的內容剔除
9191
												#回傳結果:
9192
												#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9193
												#$result["error"],錯誤訊息陣列.
9194
												#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
9195
												#$result["function"],當前執行的函數名稱.
9196
												#$result["oriStr"],要處理的原始字串內容.
9197
												#$result["content"],處理好的的字串內容.
9198
												#必填參數:
9199
												$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$partName;#要處理的字串.
9200
												$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$spiltString["dataArray"][$i];#特定字串.
9201
												$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
9202
												unset($conf["stringProcess::delStrBeforeKeyWord"]);
9203
 
9204
												#如果將 $partName 從左到關鍵字結束的部份剔除失敗
9205
												if($delStrBeforeKeyWord["status"]=="false"){
9206
 
9207
													#設置執行錯誤識別
9208
													$result["status"]="false";
9209
 
9210
													#設置錯誤訊息
9211
													$result["error"]=$delStrBeforeKeyWord;
9212
 
9213
													#回傳結果
9214
													return $result;
9215
 
9216
													}#if end
9217
 
9218
												#如果沒有找到特定關鍵字字串
9219
												if($delStrBeforeKeyWord["founded"]=="false"){
9220
 
9221
													#設置執行錯誤識別
9222
													$result["status"]="false";
9223
 
9224
													#設置錯誤訊息
9225
													$result["error"]=$delStrBeforeKeyWord;
9226
 
9227
													#回傳結果
9228
													return $result;
9229
 
9230
													}#if end
9231
 
9232
												#取得剔除過關鍵字前字串的字串	
9233
												$partName=$delStrBeforeKeyWord["content"];
9234
 
9235
												}#if end
9236
 
9237
											#反之關鍵字不存在	
9238
											else{
9239
 
9240
												#儲存被拋棄的片段
9241
												#$result["dismissLog"][]="片段「".$partName."」沒有關鍵字「".$spiltString["dataArray"][$i]."」";
9242
 
9243
												#該名稱不符合條件
9244
												break;
9245
 
9246
												}#else end
9247
 
9248
											}#for end
9249
 
9250
										}#foreach end
9251
 
9252
									#初始化儲存符合的暫存路徑
9253
									$tempExtendPath=array();
9254
 
9255
									#針對每個現有的路徑字串
9256
									for($j=0;$j<count($extendPath);$j++){
9257
 
9258
										#附加每個符合條件的名稱到路徑字串裡面
9259
										for($k=0;$k<count($passedName);$k++){
9260
 
9261
											#暫存該符合的路徑
9262
											$tempExtendPath[]=$extendPath[$j]."/".$passedName[$k];
9263
 
9264
											}#for end
9265
 
9266
										}#for end	
9267
 
9268
									#該次有幾個符合的路徑就執行幾次
9269
									foreach($tempExtendPath as $path){
9270
 
9271
										#暫存符合的路徑
9272
										$newExtendPath[]=$path;
9273
 
9274
										}#foreach end	
9275
 
9276
									}#if end
9277
 
9278
								#反之該目錄底下沒有東西
9279
								else{
9280
 
9281
									#移除該 $extendPath[$i]
9282
									unset($extendPath[$i]);
9283
 
9284
									}#else end					
9285
 
9286
								}#for end
9287
 
9288
							#如果有新的路徑產生
9289
							if(count($newExtendPath)>0){
9290
 
9291
								#置換原始符合條件字串的路徑字串陣列
9292
								$extendPath=$newExtendPath;
9293
 
9294
								}#if end
9295
 
9296
							#反之找不到後續符合的路徑
9297
							else{
9298
 
9299
								$extendPath=array();
9300
 
9301
								}#else end
9302
 
9303
							}#else end
9304
 
9305
					}#else end
9306
 
9307
				}#foreach end
9308
 
9309
			}#if end
9310
 
9311
		#反之沒有含有「*」
9312
		else{
9313
 
9314
			#判斷 $conf["path"] 是否存在
9315
			#函式說明:
9316
			#檢查多個檔案與資料夾是否存在.
9317
			#回傳的結果:
9318
			#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
9319
			#$result["error"],錯誤訊息陣列.
9320
			#$resutl["function"],當前執行的涵式名稱.
9321
			#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
9322
			#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
9323
			#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱。
9324
			#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
9325
			#必填參數:
9326
			#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
9327
			$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["path"]);
9328
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
9329
			$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
9330
			#可省略參數
9331
			#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
9332
			#$conf["disableWebSearch"]="false";
9333
			#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
9334
			#$conf["userDir"]="true";
9335
			#參考資料來源:
9336
			#http://php.net/manual/en/function.file-exists.php
9337
			#http://php.net/manual/en/control-structures.foreach.php
9338
			#備註:
9339
			#函數file_exists檢查的路徑為檔案系統的路徑
9340
			$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
9341
			unset($conf["fileAccess::checkMultiFileExist"]);
9342
 
9343
			#如果檢查失敗
9344
			if($checkMultiFileExist["status"]=="false"){
9345
 
9346
				#設置錯誤識別
9347
				$result["status"]="false";
9348
 
9349
				#設置錯誤訊息
9350
				$result["error"]=$checkMultiFileExist;
9351
 
9352
				#回傳結果
9353
				return $result;
9354
 
9355
				}#if end
9356
 
9357
			#如果存在
9358
			if($checkMultiFileExist["varExist"][0]=="true"){
9359
 
9360
				#初始化暫存展開後的檔案路徑字串
9361
				$extendPath=array($conf["path"]);
9362
 
9363
				}#if end
9364
 
9365
			#反之不存在
9366
			else{
9367
 
9368
				#置換符合的路徑為空字串
9369
				$extendPath=array();
9370
 
9371
				}#else end
9372
 
9373
			#初始化暫存展開後的檔案路徑字串
9374
			$extendPath=array($conf["path"]);
9375
 
9376
			}#else end
9377
 
9378
		#取得解析完「*」的檔案路徑字串
9379
		$result["content"]=$extendPath;
9380
 
9381
		#取得有幾個檔案路徑
9382
		$result["pathCount"]=count($result["content"]);
9383
 
9384
		#設置執行正常
9385
		$result["status"]="true";
9386
 
9387
		#回傳結果
9388
		return $result;
9389
 
9390
		}#function resolvePostionStringWhichContainStarSymbol end
9391
 
9392
	/*
9393
	#函式說明:
9394
	#將含有「*」的多個檔案路徑名稱,變成多個符合條件的路徑檔案.
9395
	#回傳結果:
9396
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
9397
	#$result["error"],錯誤訊息陣列.
9398
	#$result["function"],函數名稱. 
9399
	#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
9400
	#$result["pathCount"],整數,有幾個路徑.
9401
	#必填參數:
9402
	#$conf["path"],字串陣列,要解析含有「*」的檔案路徑字串.
9403
	$conf["path"]=array();
9404
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
9405
	$conf["fileArgu"]=__FILE__;
9406
	#可省略參數:
9407
	#$conf["noDotStart"],字串,"true"代表不包含「.」開頭的名稱,預設為"false"代表包含「.」開頭的名稱.
9408
	#$conf["noDotStart"]="true";
9409
	#$conf["noWaveEnd"],字串,預設為"true"代表不包含「~」結尾的名稱,"false"代表包含結尾為「~」的名稱.
9410
	#$conf["noWaveEnd"]="true";
9411
	#參考資料:
9412
	#無.
9413
	#備註:
9414
	#無.
9415
	*/
9416
	public static function resolveMultiPostionStringWhichContainStarSymbol(&$conf){
9417
 
9418
		#初始化要回傳的結果
9419
		$result=array();
9420
 
9421
		#設置當其函數名稱
9422
		$result["function"]=__FUNCTION__;
9423
 
9424
		#如果 $conf 不為陣列
9425
		if(gettype($conf)!="array"){
9426
 
9427
			#設置執行失敗
9428
			$result["status"]="false";
9429
 
9430
			#設置執行錯誤訊息
9431
			$result["error"][]="\$conf變數須為陣列形態";
9432
 
9433
			#如果傳入的參數為 null
9434
			if($conf==null){
9435
 
9436
				#設置執行錯誤訊息
9437
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
9438
 
9439
				}#if end
9440
 
9441
			#回傳結果
9442
			return $result;
9443
 
9444
			}#if end
9445
 
9446
		#檢查參數
9447
		#函式說明:
9448
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
9449
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9450
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
9451
		#$result["function"],當前執行的函式名稱.
9452
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
9453
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
9454
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
9455
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
9456
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
9457
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
9458
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
9459
		#必填寫的參數:
9460
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
9461
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
9462
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
9463
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
9464
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
9465
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");
9466
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
9467
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
9468
		#可以省略的參數:
9469
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
9470
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
9471
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
9472
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("noDotStart","noWaveEnd");
9473
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
9474
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
9475
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
9476
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false","true");
9477
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
9478
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
9479
		#參考資料來源:
9480
		#array_keys=>http://php.net/manual/en/function.array-keys.php
9481
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
9482
		unset($conf["variableCheck::checkArguments"]);
9483
 
9484
		#如果 $checkResult["status"] 等於 "fasle"
9485
		if($checkResult["status"]=="false"){
9486
 
9487
			#設置錯誤識別
9488
			$result["status"]="false";
9489
 
9490
			#設置錯誤訊息
9491
			$result["error"]=$checkResult;
9492
 
9493
			#回傳結果
9494
			return $result;
9495
 
9496
			}#if end
9497
 
9498
		#如果 $checkResult["passed"] 等於 "fasle"
9499
		if($checkResult["passed"]=="false"){
9500
 
9501
			#設置錯誤識別
9502
			$result["status"]="false";
9503
 
9504
			#設置錯誤訊息
9505
			$result["error"]=$checkResult;
9506
 
9507
			#回傳結果
9508
			return $result;
9509
 
9510
			}#if end
9511
 
9512
		#針對每個要解析的路徑字串
9513
		foreach($conf["path"] as $path){
9514
 
9515
			#函式說明:
9516
			#將含有「*」的檔案路徑名稱,變成多個符合條件的路徑檔案.
9517
			#回傳結果:
9518
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
9519
			#$result["error"],錯誤訊息陣列.
9520
			#$result["function"],函數名稱. 
9521
			#$result["content"],字串陣列,多個解析回來的檔案路徑字串.
9522
			#必填參數:
9523
			#$conf["path"],字串,要解析含有「*」的檔案路徑字串.
9524
			$conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]["path"]=$path;
9525
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
9526
			$conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]["fileArgu"]=$conf["fileArgu"];
9527
			#可省略參數:
9528
			#$conf["noDotStart"],字串,"true"代表不包含「.」開頭的名稱,預設為"false"代表包含「.」開頭的名稱.
9529
			$conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]["noDotStart"]=$conf["noDotStart"];
9530
			#$conf["noWaveEnd"],字串,預設為"true"代表不包含「~」結尾的名稱,"false"代表包含結尾為「~」的名稱.
9531
			$conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]["noWaveEnd"]=$conf["noWaveEnd"];
9532
			$resolvePostionStringWhichContainStarSymbol=fileAccess::resolvePostionStringWhichContainStarSymbol($conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]);
9533
			unset($conf["fileAccess::resolvePostionStringWhichContainStarSymbol"]);
9534
 
9535
			#如果解析失敗
9536
			if($resolvePostionStringWhichContainStarSymbol["status"]=="false"){
9537
 
9538
				#設置錯誤識別
9539
				$result["status"]="false";
9540
 
9541
				#設置錯誤訊息
9542
				$result["error"]=$resolvePostionStringWhichContainStarSymbol;
9543
 
9544
				#回傳結果
9545
				return $result;
9546
 
9547
				}#if end
9548
 
9549
			#針對每個解析出來的路徑
9550
			foreach($resolvePostionStringWhichContainStarSymbol["content"] as $filteredPath){
9551
 
9552
				#儲存符合條件的路徑
9553
				$result["content"][]=$filteredPath;
9554
 
9555
				}#foreach end
9556
 
9557
			}#foreach end
9558
 
9559
		#如果有路徑存在
9560
		if(isset($result["content"])){
9561
 
9562
			#取得有幾個路徑
9563
			$result["pathCount"]=count($result["content"]);
9564
 
9565
			}#if end
9566
 
9567
		#反之 
9568
		else{
9569
 
9570
			#設置空的路徑結果
9571
			$result["content"]=array();
9572
 
9573
			#取得有幾個路徑
9574
			$result["pathCount"]=count($result["content"]);
9575
 
9576
			}#else end
9577
 
9578
		#設置執行正常
9579
		$result["status"]="true";
9580
 
9581
		#回傳結果
9582
		return $result;
9583
 
9584
		}#function resolveMultiPostionStringWhichContainStarSymbol end
9585
 
9586
	/*
9587
	#函式說明:
9588
	#將多個路徑字串變成相對於當前路徑的相對路徑字串
9589
	#回傳結果:
9590
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
9591
	#$result["error"],錯誤訊息陣列.
9592
	#$result["function"],函數名稱. 
9593
	#$result["argu"],使用的參數.
9594
	#$result["content"],字串陣列,多個轉換好的相對路徑字串.
9595
	#$result["cmd"],使用的指令.
9596
	#必填參數:
9597
	#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
9598
	$conf["path"]=array();
9599
	#$conf["fileArgu"],字串,當前路徑.
9600
	$conf["fileArgu"]=__FILE__;
9601
	#可省略參數:
9602
	#$conf["baseFrom"],字串,指定要依據哪個位置為起點的起始位置,預設不指定,代表使用當前路徑.
9603
	#$conf["baseFrom"]="";
9604
	#參考資料:
9605
	#無.
9606
	#備註:
9607
	#無.
9608
	*/
9609
	public static function getRelativePath(&$conf){
9610
 
9611
		#初始化要回傳的結果
9612
		$result=array();
9613
 
9614
		#設置當其函數名稱
9615
		$result["function"]=__FUNCTION__;
9616
 
9617
		#如果 $conf 不為陣列
9618
		if(gettype($conf)!="array"){
9619
 
9620
			#設置執行失敗
9621
			$result["status"]="false";
9622
 
9623
			#設置執行錯誤訊息
9624
			$result["error"][]="\$conf變數須為陣列形態";
9625
 
9626
			#如果傳入的參數為 null
9627
			if($conf==null){
9628
 
9629
				#設置執行錯誤訊息
9630
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
9631
 
9632
				}#if end
9633
 
9634
			#回傳結果
9635
			return $result;
9636
 
9637
			}#if end
9638
 
9639
		#檢查參數
9640
		#函式說明:
9641
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
9642
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9643
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
9644
		#$result["function"],當前執行的函式名稱.
9645
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
9646
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
9647
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
9648
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
9649
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
9650
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
9651
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
9652
		#必填寫的參數:
9653
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
9654
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
9655
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
9656
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","fileArgu");
9657
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
9658
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string");
9659
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
9660
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
9661
		#可以省略的參數:
9662
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
9663
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
9664
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
9665
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("baseFrom");
9666
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
9667
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
9668
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
9669
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
9670
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
9671
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
9672
		#參考資料來源:
9673
		#array_keys=>http://php.net/manual/en/function.array-keys.php
9674
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
9675
		unset($conf["variableCheck::checkArguments"]);
9676
 
9677
		#如果 $checkResult["status"] 等於 "false"
9678
		if($checkResult["status"]=="false"){
9679
 
9680
			#設置錯誤識別
9681
			$result["status"]="false";
9682
 
9683
			#設置錯誤訊息
9684
			$result["error"]=$checkResult;
9685
 
9686
			#回傳結果
9687
			return $result;
9688
 
9689
			}#if end
9690
 
9691
		#如果 $checkResult["passed"] 等於 "fasle"
9692
		if($checkResult["passed"]=="false"){
9693
 
9694
			#設置錯誤識別
9695
			$result["status"]="false";
9696
 
9697
			#設置錯誤訊息
9698
			$result["error"]=$checkResult;
9699
 
9700
			#回傳結果
9701
			return $result;
9702
 
9703
			}#if end
9704
 
9705
		#取得參數
9706
		$result["argu"]=$conf;
9707
 
9708
		#函式說明:
9709
		#將固定格式的字串分開,並回傳分開的結果.
9710
		#回傳結果:
9711
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9712
		#$result["error"],錯誤訊息陣列
9713
		#$result["function"],當前執行的函數名稱.
9714
		#$result["argu"],使用的參數.
9715
		#$result["oriStr"],要分割的原始字串內容
9716
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
9717
		#$result["dataCounts"],爲總共分成幾段
9718
		#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
9719
		#必填參數:
9720
		#$conf["stringIn"],字串,要處理的字串.
9721
		$conf["fileAccess::spiltString"]["stringIn"]=$conf["fileArgu"];
9722
		#$conf["spiltSymbol"],字串,爲以哪個符號作爲分割.
9723
		$conf["fileAccess::spiltString"]["spiltSymbol"]="/";
9724
		#可省略參數:
9725
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
9726
		$conf["fileAccess::spiltString"]["allowEmptyStr"]="false";
9727
		#參考資料:
9728
		#無.
9729
		#備註:
9730
		#無.
9731
		$spiltString=stringProcess::spiltString($conf["fileAccess::spiltString"]);
9732
		unset($conf["fileAccess::spiltString"]);
9733
 
9734
		#如果執行失敗
9735
		if($spiltString["status"]==="false"){
9736
 
9737
			#設置錯誤識別
9738
			$result["status"]="false";
9739
 
9740
			#設置錯誤訊息
9741
			$result["error"]=$spiltString;
9742
 
9743
			#回傳結果
9744
			return $result;
9745
 
9746
			}#if end
9747
 
9748
		#如果沒有關鍵字
9749
		if($spiltString["found"]==="false"){
9750
 
9751
			#設置錯誤識別
9752
			$result["status"]="false";
9753
 
9754
			#設置錯誤訊息
9755
			$result["error"]=$spiltString;
9756
 
9757
			#回傳結果
9758
			return $result;
9759
 
9760
			}#if end
9761
 
9762
		#取得 $conf["fileArgu"] 的路徑
9763
		#函式說明:
9764
		#將固定格式的字串分開,並回傳分開的結果.
9765
		#回傳結果:
9766
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9767
		#$result["error"],錯誤訊息陣列
9768
		#$result["function"],當前執行的函數名稱.
9769
		#$result["argu"],使用的參數.
9770
		#$result["oriStr"],要分割的原始字串內容
9771
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
9772
		#$result["dataCounts"],爲總共分成幾段
9773
		#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
9774
		#必填參數:
9775
		#$conf["stringIn"],字串,要處理的字串.
9776
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["fileArgu"];
9777
		#$conf["spiltSymbol"],字串,爲以哪個符號作爲分割.
9778
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";
9779
		#可省略參數:
9780
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
9781
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
9782
		#參考資料:
9783
		#無.
9784
		#備註:
9785
		#無.
9786
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
9787
		unset($conf["stringProcess::spiltString"]);
9788
 
9789
		#如果執行失敗
9790
		if($spiltString["status"]==="false"){
9791
 
9792
			#設置錯誤識別
9793
			$result["status"]="false";
9794
 
9795
			#設置錯誤訊息
9796
			$result["error"]=$spiltString;
9797
 
9798
			#回傳結果
9799
			return $result;
9800
 
9801
			}#if end
9802
 
9803
		/*
9804
		#break point
9805
		var_dump($spiltString);
9806
		exit;
9807
		*/
9808
 
9809
		#預設 fileArgu 的路徑為 ""
9810
		$fileArguPath="";
9811
 
9812
		#針對每個目錄
9813
		for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
9814
 
9815
			#串接路徑
9816
			$fileArguPath=$fileArguPath."/".$spiltString["dataArray"][$i];
9817
 
9818
			}#for end
9819
 
9820
		#取得相對於目標的當前位置
9821
		#函式說明:
9822
		#呼叫shell執行系統命令,並取得回傳的內容.
9823
		#回傳結果:
9824
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
9825
		#$result["error"],錯誤訊息陣列.
9826
		#$result["function"],當前執行的函數名稱.
9827
		#$result["argu"],使用的參數.
9828
		#$result["cmd"],執行的指令內容.
9829
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
9830
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
9831
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
9832
		#$result["running"],是否還在執行.
9833
		#$result["pid"],pid.
9834
		#$result["statusCode"],執行結束後的代碼.
9835
		#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu").
9836
		#必填參數:
9837
		#$conf["command"],字串,要執行的指令.
9838
		$conf["external::callShell"]["command"]="cd";
9839
		#$conf["fileArgu"],字串,變數__FILE__的內容.
9840
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
9841
		#可省略參數:
9842
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
9843
		$conf["external::callShell"]["argu"]=array($fileArguPath,";","pwd");
9844
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
9845
		#$conf["arguIsAddr"]=array();
9846
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
9847
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
9848
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
9849
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
9850
		#$conf["enablePrintDescription"]="true";
9851
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
9852
		#$conf["printDescription"]="";
9853
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
9854
		$conf["external::callShell"]["escapeshellarg"]="true";
9855
		#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
9856
		#$conf["thereIsShellVar"]=array();
9857
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
9858
		#$conf["username"]="";
9859
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
9860
		#$conf["password"]="";
9861
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
9862
		#$conf["useScript"]="";
9863
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
9864
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
9865
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
9866
		#$conf["inBackGround"]="";
9867
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
9868
		#$conf["getErr"]="false";
9869
		#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
9870
		#$conf["doNotRun"]="false";
9871
		#參考資料:
9872
		#exec=>http://php.net/manual/en/function.exec.php
9873
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
9874
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
9875
		#備註:
9876
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
9877
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
9878
		$callShell=external::callShell($conf["external::callShell"]);
9879
		unset($conf["external::callShell"]);
9880
 
9881
		#如果執行失敗
9882
		if($callShell["status"]==="false"){
9883
 
9884
			#設置錯誤識別
9885
			$result["status"]="false";
9886
 
9887
			#設置錯誤訊息
9888
			$result["error"]=$callShell;
9889
 
9890
			#回傳結果
9891
			return $result;
9892
 
9893
			}#if end
9894
 
9895
		#如果執行失敗
9896
		if(!isset($callShell["output"][0])){
9897
 
9898
			#設置錯誤識別
9899
			$result["status"]="false";
9900
 
9901
			#設置錯誤訊息
9902
			$result["error"]=$callShell;
9903
 
9904
			#回傳結果
9905
			return $result;
9906
 
9907
			}#if end	
9908
 
9909
		/*
9910
		#break point
9911
		var_dump($callShell);
9912
		exit;
9913
		*/
9914
 
9915
		#記錄執行的指令
9916
		$result["cmd"][]=$callShell["cmd"];
9917
 
9918
		#保存相對於目標的當前位置
9919
		$pwd=$callShell["output"][0];
9920
 
9921
		#更新 fileArgu
9922
		$conf["fileArgu"]=$pwd."/".$spiltString["dataArray"][$spiltString["dataCounts"]-1];
9923
 
9924
		#針對每個 $conf["path"]
9925
		foreach($conf["path"] as $path){
9926
 
9927
			#將 $path 變成易讀的格式
9928
			#函式說明:
9929
			#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
9930
			#回傳的結果:
9931
			#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
9932
			#$result["function"],當前執行的函數.
9933
			#$result["error"],錯誤訊息陣列.
9934
			#$result["changedPath"],處理完後回傳的目錄字串.
9935
			#$result["oriPath"],原始的路徑字串
9936
			#必填參數:
9937
			#$conf["dirStr"],字串,要處理的檔案目錄字串.
9938
			$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"]=$path;
9939
			$changeDirByDotDotSolidus=stringProcess::changeDirByDotDotSolidus($conf["stringProcess::changeDirByDotDotSolidus"]);
9940
			unset($conf["stringProcess::changeDirByDotDotSolidus"]);
9941
 
9942
			#如果處理失敗
9943
			if($changeDirByDotDotSolidus["status"]==="false"){
9944
 
9945
				#設置錯誤識別
9946
				$result["status"]="false";
9947
 
9948
				#設置錯誤訊息
9949
				$result["error"]=$changeDirByDotDotSolidus;
9950
 
9951
				#回傳結果
9952
				return $result;
9953
 
9954
				}#if end
9955
 
9956
			#取得易讀的路徑
9957
			$path=$changeDirByDotDotSolidus["changedPath"];
9958
 
9959
			#判斷 $path 是否為絕對路徑
9960
			#函式說明:
9961
			#取得符合特定字首與字尾的字串
9962
			#回傳結果:
9963
			#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
9964
			#$result["function"],當前執行的函數名稱.
9965
			#$result["error"],錯誤訊息陣列.
9966
			#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
9967
			#$result["returnString"],爲符合字首條件的字串內容。
9968
			#必填參數:
9969
			#$conf["checkString"],字串,要檢查的字串.
9970
			$conf["search::getMeetConditionsString"]["checkString"]=$path;
9971
			#可省略參數:
9972
			#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
9973
			$conf["search::getMeetConditionsString"]["frontWord"]="/";
9974
			#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
9975
			#$conf["tailWord"]="";
9976
			#參考資料:
9977
			#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
9978
			$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
9979
			unset($conf["search::getMeetConditionsString"]);			
9980
 
9981
			#如果檢查失敗
9982
			if($getMeetConditionsString["status"]=="false"){
9983
 
9984
				#設置錯誤識別
9985
				$result["status"]="false";
9986
 
9987
				#設置錯誤訊息
9988
				$result["error"]=$getMeetConditionsString;
9989
 
9990
				#回傳結果
9991
				return $result;
9992
 
9993
				}#if end
9994
 
9995
			#如果沒有「/」開頭
9996
			if($getMeetConditionsString["founded"]==="false"){
9997
 
9998
				#將 $conf["fileArgu"] 最後面的檔案或目錄名稱剔除
9999
				#函式說明:
10000
				#將固定格式的字串分開,並回傳分開的結果。
10001
				#回傳結果:
10002
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10003
				#$result["error"],錯誤訊息陣列
10004
				#$result["function"],當前執行的函數名稱.
10005
				#$result["oriStr"],要分割的原始字串內容
10006
				#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
10007
				#$result["dataCounts"],爲總共分成幾段
10008
				#必填參數:
10009
				$conf["stringProcess::spiltString"]["stringIn"]=$conf["fileArgu"];#要處理的字串。
10010
				$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
10011
				$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
10012
				unset($conf["stringProcess::spiltString"]);
10013
 
10014
				#如果分割字串失敗
10015
				if($spiltString["status"]=="false"){
10016
 
10017
					#設置錯誤識別
10018
					$result["status"]="false";
10019
 
10020
					#設置錯誤訊息
10021
					$result["error"]=$spiltString;
10022
 
10023
					#回傳結果
10024
					return $result;
10025
 
10026
					}#if end
10027
 
10028
				#初始化相對路徑為開頭片段""
10029
				$relativePathPart="/";
10030
 
10031
				#剔除最後一段
10032
				for($i=0;$i<$spiltString["dataCounts"]-1;$i++){
10033
 
10034
					#串接起來
10035
					$relativePathPart=$relativePathPart.$spiltString["dataArray"][$i]."/";
10036
 
10037
					}#for end
10038
 
10039
				#如果有設定 baseFrom
10040
				if(isset($conf["baseFrom"])){
10041
 
10042
					#函式說明:
10043
					#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
10044
					#回傳結果:
10045
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10046
					#$result["error"],錯誤訊息陣列.
10047
					#$result["function"],函數名稱. 
10048
					#$result["argu"],使用的參數.
10049
					#$result["content"],網址,若是在命令列執行,則為"null".
10050
					#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
10051
					#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
10052
					#必填參數:
10053
					#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
10054
					$conf["fileAccess::getInternetAddressV2"]["address"]=$path;
10055
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
10056
					$conf["fileAccess::getInternetAddressV2"]["fileArgu"]=$conf["fileArgu"];
10057
					#可省略參數:
10058
					#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
10059
					$conf["fileAccess::getInternetAddressV2"]["web"]="false";
10060
					#參考資料:
10061
					#無.
10062
					#備註:
10063
					#無.
10064
					$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
10065
					unset($conf["fileAccess::getInternetAddressV2"]);
10066
 
10067
					##var_dump(__LINE__." ".print_r($getInternetAddressV2,true));
10068
 
10069
					#如果執行失敗
10070
					if($getInternetAddressV2["status"]==="false"){
10071
 
10072
						#設置錯誤識別
10073
						$result["status"]="false";
10074
 
10075
						#設置錯誤訊息
10076
						$result["error"]=$getInternetAddressV2;
10077
 
10078
						#回傳結果
10079
						return $result;
10080
 
10081
						}#if end
10082
 
10083
					#取得絕對位置
10084
					$path=$getInternetAddressV2["fileSystemAbsoulutePosition"];
10085
 
10086
					#函式說明:
10087
					#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
10088
					#回傳結果:
10089
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10090
					#$result["error"],錯誤訊息陣列.
10091
					#$result["function"],函數名稱. 
10092
					#$result["argu"],使用的參數.
10093
					#$result["content"],網址,若是在命令列執行,則為"null".
10094
					#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
10095
					#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
10096
					#必填參數:
10097
					#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
10098
					$conf["fileAccess::getInternetAddressV2"]["address"]=$conf["baseFrom"];
10099
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
10100
					$conf["fileAccess::getInternetAddressV2"]["fileArgu"]=$conf["fileArgu"];
10101
					#可省略參數:
10102
					#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
10103
					$conf["fileAccess::getInternetAddressV2"]["web"]="false";
10104
					#參考資料:
10105
					#無.
10106
					#備註:
10107
					#無.
10108
					$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
10109
					unset($conf["fileAccess::getInternetAddressV2"]);
10110
 
10111
					#var_dump(__LINE__." ".print_r($getInternetAddressV2,true));
10112
 
10113
					#如果執行失敗
10114
					if($getInternetAddressV2["status"]==="false"){
10115
 
10116
						#設置錯誤識別
10117
						$result["status"]="false";
10118
 
10119
						#設置錯誤訊息
10120
						$result["error"]=$getInternetAddressV2;
10121
 
10122
						#回傳結果
10123
						return $result;
10124
 
10125
						}#if end
10126
 
10127
					#取得絕對位置
10128
					$conf["baseFrom"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
10129
 
10130
					#函式說明:
10131
					#將多個路徑字串變成相對於當前路徑的相對路徑字串
10132
					#回傳結果:
10133
					#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10134
					#$result["error"],錯誤訊息陣列.
10135
					#$result["function"],函數名稱. 
10136
					#$result["argu"],使用的參數.
10137
					#$result["content"],字串陣列,多個轉換好的相對路徑字串.
10138
					#必填參數:
10139
					#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
10140
					$conf["fileAccess::getRelativePath"]["path"]=array($path);
10141
					#$conf["fileArgu"],字串,當前路徑.
10142
					$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["baseFrom"]."/name";
10143
					#可省略參數:
10144
					#$conf["baseFrom"],字串,指定要依據哪個位置為起點的起始位置,預設不指定,代表使用當前路徑.
10145
					#$conf["baseFrom"]="";
10146
					#參考資料:
10147
					#無.
10148
					#備註:
10149
					#無.
10150
					$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
10151
					unset($conf["fileAccess::getRelativePath"]);
10152
 
10153
					#var_dump(__LINE__." ".print_r($getRelativePath,true));
10154
 
10155
					#如果執行失敗
10156
					if($getRelativePath["status"]==="false"){
10157
 
10158
						#設置錯誤識別
10159
						$result["status"]="false";
10160
 
10161
						#設置錯誤訊息
10162
						$result["error"]=$getRelativePath;
10163
 
10164
						#回傳結果
10165
						return $result;
10166
 
10167
						}#if end
10168
 
10169
					#取得轉換好的絕對路徑
10170
					$relativePathPart=$getRelativePath["content"][0]."/";
10171
 
10172
					#清空path,避免出錯
10173
					$path="";
10174
 
10175
					}#if end
10176
 
10177
				#轉換成易讀的相對路徑
10178
				#函式說明:
10179
				#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
10180
				#回傳的結果:
10181
				#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
10182
				#$result["function"],當前執行的函數.
10183
				#$result["error"],錯誤訊息陣列.
10184
				#$result["changedPath"],處理完後回傳的目錄字串.
10185
				#$result["oriPath"],原始的路徑字串
10186
				#必填參數:
10187
				#$conf["dirStr"],字串,要處理的檔案目錄字串.
10188
				$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"]=$relativePathPart.$path;
10189
				$changeDirByDotDotSolidus=stringProcess::changeDirByDotDotSolidus($conf["stringProcess::changeDirByDotDotSolidus"]);
10190
				unset($conf["stringProcess::changeDirByDotDotSolidus"]);
10191
 
10192
				#var_dump($changeDirByDotDotSolidus);	
10193
 
10194
				#如果轉換失敗
10195
				if($changeDirByDotDotSolidus["status"]=="false"){
10196
 
10197
					#設置錯誤識別
10198
					$result["status"]="false";
10199
 
10200
					#設置錯誤訊息
10201
					$result["error"]=$changeDirByDotDotSolidus;
10202
 
10203
					#回傳結果
10204
					return $result;
10205
 
10206
					}#if end
10207
 
10208
				#轉換為相對路徑
10209
				#函式說明:
10210
				#將多個路徑字串變成相對於當前路徑的相對路徑字串
10211
				#回傳結果:
10212
				#$result["status"],"true"爲建立成功,"false"爲建立失敗.
10213
				#$result["error"],錯誤訊息陣列.
10214
				#$result["function"],函數名稱. 
10215
				#$result["content"],字串陣列,多個轉換好的相對路徑字串.
10216
				#必填參數:
10217
				#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
10218
				$conf["fileAccess::getRelativePath"]["path"]=array($changeDirByDotDotSolidus["changedPath"]);
10219
				#$conf["fileArgu"],字串,當前路徑.
10220
				$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
10221
				$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
10222
				unset($conf["fileAccess::getRelativePath"]);
10223
 
10224
				#var_dump($getRelativePath);	
10225
 
10226
				#如果轉換路徑失敗
10227
				if($getRelativePath["status"]==="false"){
10228
 
10229
					#設置錯誤識別
10230
					$result["status"]="false";
10231
 
10232
					#設置錯誤訊息
10233
					$result["error"]=$changeDirByDotDotSolidus;
10234
 
10235
					#回傳結果
10236
					return $result;
10237
 
10238
					}#if end
10239
 
10240
				#取得相對路徑
10241
				$result["content"][]=$getRelativePath["content"][0];
10242
 
10243
				}#if end
10244
 
10245
			#反之有「/」開頭
10246
			else{
10247
				#函式說明:
10248
				#移除多個絕對路徑字串開頭相同的部分
10249
				#回傳結果:
10250
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10251
				#$result["error"],錯誤訊息陣列.
10252
				#$result["function"],當前執行的函數名稱.
10253
				#$result["content"],處理好的的字串內容.
10254
				#必填參數:
10255
				#$conf["pathIn"],字串陣列,每個要處理的絕對路徑字串.
10256
				$conf["fileAccess::delSamePathHead"]["pathIn"]=array($path,$conf["fileArgu"]);		
10257
				$delSamePathHead=fileAccess::delSamePathHead($conf["fileAccess::delSamePathHead"]);
10258
				unset($conf["fileAccess::delSamePathHead"]);
10259
 
10260
				#var_dump($delSamePathHead);
10261
 
10262
				#如果移除多個絕對路徑字串開頭相同的部分失敗
10263
				if($delSamePathHead["status"]==="false"){
10264
 
10265
					#設置錯誤識別
10266
					$result["status"]="false";
10267
 
10268
					#設置錯誤訊息
10269
					$result["error"]=$delSameHead;
10270
 
10271
					#回傳結果
10272
					return $result;
10273
 
10274
					}#if end
10275
 
10276
				#如果 $conf["fileArgu"] 剩下空
10277
				if($delSamePathHead["content"][1]===""){
10278
 
10279
					#檢查 $delSamePathHead[0] 開頭是否為「/」
10280
					#函式說明:
10281
					#取得符合特定字首與字尾的字串
10282
					#回傳結果:
10283
					#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
10284
					#$result["function"],當前執行的函數名稱.
10285
					#$result["error"],錯誤訊息陣列.
10286
					#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
10287
					#$result["returnString"],爲符合字首條件的字串內容。
10288
					#必填參數:
10289
					#$conf["checkString"],字串,要檢查的字串.
10290
					$conf["search::getMeetConditionsString"]["checkString"]=$delSamePathHead["content"][0];
10291
					#可省略參數:
10292
					#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
10293
					$conf["search::getMeetConditionsString"]["frontWord"]="/";
10294
					#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
10295
					#$conf["tailWord"]="";
10296
					#參考資料:
10297
					#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
10298
					$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
10299
					unset($conf["search::getMeetConditionsString"]);
10300
 
10301
					#如果檢查失敗
10302
					if($getMeetConditionsString["status"]=="false"){
10303
 
10304
						#設置錯誤識別
10305
						$result["status"]="false";
10306
 
10307
						#設置錯誤訊息
10308
						$result["error"]=$getMeetConditionsString;
10309
 
10310
						#回傳結果
10311
						return $result;
10312
 
10313
						}#if end
10314
 
10315
					#如果有開頭有「/」
10316
					if($getMeetConditionsString["founded"]==="true"){
10317
 
10318
						#函式說明:
10319
						#將字串特定關鍵字與其前面的內容剔除
10320
						#回傳結果:
10321
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10322
						#$result["error"],錯誤訊息陣列.
10323
						#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
10324
						#$result["function"],當前執行的函數名稱.
10325
						#$result["oriStr"],要處理的原始字串內容.
10326
						#$result["content"],處理好的的字串內容.
10327
						#必填參數:
10328
						$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$delSamePathHead["content"][0];#要處理的字串.
10329
						$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="/";#特定字串.
10330
						$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
10331
						unset($conf["stringProcess::delStrBeforeKeyWord"]);
10332
 
10333
						#如果 將字串特定關鍵字與其前面的內容剔除 失敗
10334
						if($delStrBeforeKeyWord["status"]=="false"){
10335
 
10336
							#設置錯誤識別
10337
							$result["status"]="false";
10338
 
10339
							#設置錯誤訊息
10340
							$result["error"]=$delStrBeforeKeyWord;
10341
 
10342
							#回傳結果
10343
							return $result;
10344
 
10345
							}#if end
10346
 
10347
						#取得相對位置
10348
						$result["content"][]=$delStrBeforeKeyWord["content"];
10349
 
10350
						}#if end
10351
 
10352
					#反之
10353
					else{
10354
 
10355
						#取得相對位置
10356
						$result["content"][]=$delSamePathHead["content"][0];
10357
 
10358
						}#else end	
10359
 
10360
					}#if end
10361
 
10362
				#反之剩下的 $conf["fileArgu"] 不為空
10363
				else{
10364
 
10365
					#檢查 $delSamePathHead["content"][1] 有幾個「/」
10366
					#函式說明:
10367
					#檢查字串裡面有無指定的關鍵字
10368
					#回傳結果:
10369
					#$result["status"],"true"代表執行成功,"false"代表執行失敗。
10370
					#$result["error"],錯誤訊息
10371
					#$result["function"],當前執行的函數名稱.
10372
					#$result["founded"],是否找到關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
10373
					#$result["keyWordCount"],找到的關鍵字數量.
10374
					#必填參數:
10375
					$conf["search::findKeyWord"]["keyWord"]="/";#想要搜尋的關鍵字
10376
					$conf["search::findKeyWord"]["string"]=$delSamePathHead["content"][1];#要被搜尋的字串內容
10377
					#可省略參數:
10378
					#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
10379
					$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
10380
					unset($conf["search::findKeyWord"]);
10381
 
10382
					#如果 檢查字串裡面有無指定的關鍵字 失敗
10383
					if($findKeyWord["status"]==="false"){
10384
 
10385
						#設置錯誤識別
10386
						$result["status"]="false";
10387
 
10388
						#設置錯誤訊息
10389
						$result["error"]=$findKeyWord;
10390
 
10391
						#回傳結果
10392
						return $result;
10393
 
10394
						}#if end
10395
 
10396
					#有幾個「/」就執行幾次
10397
					for($i=0;$i<$findKeyWord["keyWordCount"];$i++){
10398
 
10399
						#在前面加上 "../"
10400
						$delSamePathHead["content"][0]="../".$delSamePathHead["content"][0];
10401
 
10402
						}#for end
10403
 
10404
					#取得相對位置
10405
					$result["content"][]=$delSamePathHead["content"][0];
10406
 
10407
					}#else end
10408
 
10409
				}#else end
10410
 
10411
			}#foreach end
10412
 
10413
		#設置執行正常
10414
		$result["status"]="true";
10415
 
10416
		#回傳結果
10417
		return $result;
10418
 
10419
		}#function getRelativeParh end
10420
 
10421
	/*
10422
	#函式說明:
10423
	#移除多個絕對路徑字串開頭相同的部分
10424
	#回傳結果:
10425
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10426
	#$result["error"],錯誤訊息陣列.
10427
	#$result["function"],當前執行的函數名稱.
10428
	#$result["argu"],參數.
10429
	#$result["content"],處理好的的字串內容.
10430
	#必填參數:
10431
	#$conf["pathIn"],字串陣列,每個要處理的絕對路徑字串.
10432
	$conf["pathIn"]=array();		
10433
	#可省略參數:
10434
	#無
10435
	#參考資料:
10436
	#無.
10437
	#備註:
10438
	#無.
10439
	*/
10440
	public static function delSamePathHead(&$conf){
10441
 
10442
		#初始化要回傳的結果
10443
		$result=array();
10444
 
10445
		#取得當前執行的函數名稱
10446
		$result["function"]=__FUNCTION__;
10447
 
10448
		#如果沒有參數
10449
		if(func_num_args()==0){
10450
 
10451
			#設置執行失敗
10452
			$result["status"]="false";
10453
 
10454
			#設置執行錯誤訊息
10455
			$result["error"]="函數".$result["function"]."需要參數";
10456
 
10457
			#回傳結果
10458
			return $result;
10459
 
10460
			}#if end
10461
 
10462
		#如果 $conf 不為陣列
10463
		if(gettype($conf)!="array"){
10464
 
10465
			#設置執行失敗
10466
			$result["status"]="false";
10467
 
10468
			#設置執行錯誤訊息
10469
			$result["error"][]="\$conf變數須為陣列形態";
10470
 
10471
			#如果傳入的參數為 null
10472
			if($conf==null){
10473
 
10474
				#設置執行錯誤訊息
10475
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
10476
 
10477
				}#if end
10478
 
10479
			#回傳結果
10480
			return $result;
10481
 
10482
			}#if end
10483
 
10484
		#取得參數
10485
		$result["argv"]=$conf;	
10486
 
10487
		#檢查參數
10488
		#函式說明:
10489
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
10490
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10491
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
10492
		#$result["function"],當前執行的函式名稱.
10493
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
10494
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
10495
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
10496
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
10497
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
10498
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
10499
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
10500
		#必填寫的參數:
10501
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
10502
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
10503
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
10504
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("pathIn");
10505
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
10506
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");
10507
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
10508
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
10509
		#可以省略的參數:
10510
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
10511
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
10512
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
10513
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileToRead","output");
10514
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
10515
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
10516
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
10517
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("help","help");
10518
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
10519
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
10520
		#參考資料來源:
10521
		#array_keys=>http://php.net/manual/en/function.array-keys.php
10522
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
10523
		unset($conf["variableCheck::checkArguments"]);
10524
 
10525
		#如果 $checkResult["status"] 等於 "fasle"
10526
		if($checkResult["status"]=="false"){
10527
 
10528
			#設置錯誤識別
10529
			$result["status"]="false";
10530
 
10531
			#設置錯誤訊息
10532
			$result["error"]=$checkResult;
10533
 
10534
			#回傳結果
10535
			return $result;
10536
 
10537
			}#if end
10538
 
10539
		#如果 $checkResult["passed"] 等於 "fasle"
10540
		if($checkResult["passed"]=="false"){
10541
 
10542
			#設置錯誤識別
10543
			$result["status"]="false";
10544
 
10545
			#設置錯誤訊息
10546
			$result["error"]=$checkResult;
10547
 
10548
			#回傳結果
10549
			return $result;
10550
 
10551
			}#if end
10552
 
10553
		#檢查是否都為絕對路徑
10554
		#函式說明:
10555
		#取得多個符合特定字首與字尾的字串.
10556
		#回傳結果:
10557
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
10558
		#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
10559
		#$result["function"],當前執行的函數名稱.
10560
		#$result["returnString"],爲符合字首條件的字串陣列內容。
10561
		#必填參數:
10562
		#$conf["checkString"],陣列字串,要檢查的字串們.
10563
		$conf["search::getMeetConditionsStringMulti"]["checkString"]=$conf["pathIn"];#要檢查的字串陣列
10564
		#可省略參數:
10565
		#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
10566
		$conf["search::getMeetConditionsStringMulti"]["frontWord"]="/";
10567
		#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
10568
		#$conf["tailWord"]="";
10569
		#參考資料:
10570
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
10571
		$getMeetConditionsStringMulti=search::getMeetConditionsStringMulti($conf["search::getMeetConditionsStringMulti"]);
10572
		unset($conf["search::getMeetConditionsStringMulti"]);
10573
 
10574
		#如果檢測是否為絕對路徑失敗
10575
		if($getMeetConditionsStringMulti["status"]=="false"){
10576
 
10577
			#設置錯誤識別
10578
			$result["status"]="false";
10579
 
10580
			#設置錯誤訊息
10581
			$result["error"]=$getMeetConditionsStringMulti;
10582
 
10583
			#增加額外的錯誤訊息
10584
			$result["error"][]="僅接受絕對路徑字串";
10585
 
10586
			#回傳結果
10587
			return $result;
10588
 
10589
			}#if end
10590
 
10591
		#函式說明:
10592
		#將多個固定格式的字串分開,並回傳分開的結果
10593
		#回傳的參數:
10594
		#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
10595
		#$result["error"],錯誤訊息陣列.
10596
		#$result["function"],當前執行的函數名稱.
10597
		#$result["spiltString"][$i]["oriStr"],爲第i個字串的原始內容
10598
		#$result["spiltString"][$i]["dataArray"],爲第($i+1)個字串分割後的字串陣列
10599
		#$result["spiltString"][$i]["dataArray"][$j],爲第($i+1)的分割好的字串的第($j+1)段內容
10600
		#$result["spiltString"][$i]["dataCounts"],爲第($i+1)個字串分割後總共分成幾段
10601
		#必填參數:
10602
		#$conf["stringIn"],字串陣列,要處理的字串陣列.
10603
		$conf["stringProcess::spiltMutiString"]["stringIn"]=$conf["pathIn"];
10604
		#$conf["spiltSymbol"],字串,爲要以哪個符號作爲分割.
10605
		$conf["stringProcess::spiltMutiString"]["spiltSymbol"]="/";
10606
		$spiltMutiString=stringProcess::spiltMutiString($conf["stringProcess::spiltMutiString"]);
10607
 
10608
		#如果分割所有路徑字串失敗
10609
		if($spiltMutiString["status"]=="false"){
10610
 
10611
			#設置錯誤識別
10612
			$result["status"]="false";
10613
 
10614
			#設置錯誤訊息
10615
			$result["error"]=$spiltMutiString;				
10616
 
10617
			#回傳結果
10618
			return $result;
10619
 
10620
			}#if end
10621
 
10622
		#初始化暫存每個路徑分割成的段數
10623
		$spiltedPathCount=array();					
10624
 
10625
		#取得每個路徑分割成的段數
10626
		#針對每個 $spiltMutiString["spiltString"]
10627
		for($i=0;$i<count($spiltMutiString["spiltString"]);$i++){
10628
 
10629
			$spiltedPathCount[]=$spiltMutiString["spiltString"][$i]["dataCounts"];
10630
 
10631
			}#for end
10632
 
10633
		#取得所有路徑字串分割後的最小數量
10634
		#涵式說明
10635
		#找最小值,結果會回傳最小值
10636
		#回傳的內容
10637
		#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
10638
		#$result["error"],錯誤訊息陣列.
10639
		#$result["function"],當前執行的函數名稱.
10640
		#$result["key"],最大值原先的key.
10641
		#$result["value"],陣列裏面最小的數值.
10642
		#必填參數:
10643
		$conf["math::getMinValue"]["rawDataArray"]=$spiltedPathCount;#爲原始數據
10644
		$getMinValue=math::getMinValue($conf["math::getMinValue"]);
10645
		unset($conf["math::getMinValue"]);
10646
 
10647
		#如果取得最小數值失敗
10648
		if($getMinValue["status"]=="false"){
10649
 
10650
			#設置錯誤識別
10651
			$result["status"]="false";
10652
 
10653
			#設置錯誤訊息
10654
			$result["error"]=$getMinValue;				
10655
 
10656
			#回傳結果
10657
			return $result;
10658
 
10659
			}#if end	
10660
 
10661
		#初始化暫存每個路徑字串的前面幾個片段是相同的
10662
		$samePartCount=0;
10663
 
10664
		#var_dump($getMinValue["value"]);	
10665
 
10666
		#依據所有路徑字串分割後的最小數量
10667
		for($j=0;$j<$getMinValue["value"];$j++){
10668
 
10669
			#初始化暫存第一個路徑的片段字串
10670
			$firstPathPart="";
10671
 
10672
			#針對每個 $spiltMutiString["spiltString"]
10673
			for($i=0;$i<count($spiltMutiString["spiltString"]);$i++){
10674
 
10675
				#暫存分割的字串
10676
				$spiltedPath=$spiltMutiString["spiltString"][$i];
10677
 
10678
				#如果是第一個路徑
10679
				if($i==0){
10680
 
10681
					#取得第一個路徑的片段字串
10682
					$firstPathPart=$spiltedPath["dataArray"][$j];
10683
 
10684
					}#if end									
10685
 
10686
				#如果第$i+1個路徑片段不跟第1個路徑的片段字串一樣
10687
				if($spiltedPath["dataArray"][$j]!=$firstPathPart){
10688
 
10689
					#讓最外層迴圈中止
10690
					$getMinValue["value"]=-1;
10691
 
10692
					#跳出迴圈
10693
					break;
10694
 
10695
					}#if end			
10696
 
10697
				}#for end
10698
 
10699
			#代表每個路徑字串的第$j段是一樣的.
10700
			$samePartCount=$j;
10701
 
10702
			}#for end
10703
 
10704
		#var_dump($samePartCount);
10705
 
10706
		#依據每個路徑
10707
		for($i=0;$i<count($spiltMutiString["spiltString"]);$i++){			
10708
 
10709
			#初始化儲存第$i+1個處理好的路徑字串
10710
			$result["content"][$i]="";			
10711
 
10712
			#依據 $samePartCount 與 路徑的段數
10713
			for($j=$samePartCount;$j<$spiltMutiString["spiltString"][$i]["dataCounts"];$j++){
10714
 
10715
				#如果不是第一段
10716
				if($j!=$samePartCount){
10717
 
10718
					#組裝每個路徑片段
10719
					$result["content"][$i]=$result["content"][$i]."/".$spiltMutiString["spiltString"][$i]["dataArray"][$j];
10720
 
10721
					}#if end
10722
 
10723
				#反之為第一段
10724
				else{
10725
 
10726
					#組裝每個路徑片段
10727
					$result["content"][$i]=$result["content"][$i].$spiltMutiString["spiltString"][$i]["dataArray"][$j];
10728
 
10729
					}#else end
10730
 
10731
				}#for end
10732
 
10733
			}#for end
10734
 
10735
		#設置執行正常
10736
		$result["status"]="true";
10737
 
10738
		#回傳結果
10739
		return $result;
10740
 
10741
		}#function delSamePathHead end
10742
 
10743
	/*
10744
	#函式說明:
10745
	#於本套件位置底下的tmp資料夾下建立與回傳暫存檔案名稱路徑 
10746
	#回傳結果:
10747
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10748
	#$result["error"],錯誤訊息.
10749
	#$result["function"],當前執行的函數名稱.
10750
	#$result["content"],暫存檔案的路徑與名稱.
10751
	#$result["fileName"],暫存檔案的名稱.
10752
	#$result["path"],暫存檔案的路徑.
10753
	#必填參數:
10754
	#無.
10755
	#可省略參數:
10756
	#無.
10757
	#參考資料:
10758
	#無.
10759
	#備註:
10760
	#無.
10761
	*/
10762
	public static function createTempFile(){
10763
 
10764
		#初始化要回傳的結果
10765
		$result=array();
10766
 
10767
		#取得當前執行的函數名稱
10768
		$result["function"]=__FUNCTION__;
10769
 
10770
		#取得相對於當前路徑的  tmp 目錄.
10771
		exec("cd ".pathinfo(__FILE__)["dirname"]."/../../../var/qbpwcf/tmp;pwd;",$output,$status);
10772
 
10773
		#如果執行失敗
10774
		if($status!==0){
10775
 
10776
			#設置執行失敗
10777
			$result["status"]="false";
10778
 
10779
			#設置執行錯誤訊息
10780
			$result["error"][]="取得暫存目錄失敗";
10781
 
10782
			#回傳結果
10783
			return $result;
10784
 
10785
			}#if end	
10786
 
10787
		#設置預設的暫存目錄
10788
		$defaultTmpDir=$output[0];	
10789
 
10790
		#取得暫存檔案的路徑與名稱
10791
		$result["content"]=tempnam($defaultTmpDir,"qbpwcf_tmpfile_");
10792
 
10793
		#函式說明:
10794
		#將字串特定關鍵字與其前面的內容剔除
10795
		#回傳結果:
10796
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10797
		#$result["error"],錯誤訊息陣列.
10798
		#$result["warning"],警告訊息鎮列.
10799
		#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
10800
		#$result["function"],當前執行的函數名稱.
10801
		#$result["argu"],使用的參數.
10802
		#$result["oriStr"],要處理的原始字串內容.
10803
		#$result["content"],處理好的的字串內容.	
10804
		#必填參數:
10805
		#$conf["stringIn"],字串,要處理的字串.
10806
		$conf["stringPorcess::delStrBeforeKeyWord"]["stringIn"]=$result["content"];
10807
		#$conf["keyWord"],字串,特定字串.
10808
		$conf["stringPorcess::delStrBeforeKeyWord"]["keyWord"]=$defaultTmpDir."/qbpwcf_tmpfile_";
10809
		#可省略參數:
10810
		#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
10811
		#$conf["recursive"]="true";
10812
		#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
10813
		#$conf["lastResult"]=$delStrBeforeKeyWord;
10814
		#參考資料:
10815
		#無.
10816
		#備註:
10817
		#無.
10818
		$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringPorcess::delStrBeforeKeyWord"]);
10819
		unset($conf["stringPorcess::delStrBeforeKeyWord"]);
10820
 
10821
		#如果執行失敗
10822
		if($delStrBeforeKeyWord["status"]==="false"){
10823
 
10824
			#設置執行失敗
10825
			$result["status"]="false";
10826
 
10827
			#設置執行錯誤訊息
10828
			$result["error"]=$delStrBeforeKeyWord;
10829
 
10830
			#回傳結果
10831
			return $result;
10832
 
10833
			}#if end
10834
 
10835
		#如果應該要存在的路徑關鍵字不在
10836
		if($delStrBeforeKeyWord["founded"]==="false"){
10837
 
10838
			#設置執行失敗
10839
			$result["status"]="false";
10840
 
10841
			#設置執行錯誤訊息
10842
			$result["error"]=$delStrBeforeKeyWord;
10843
 
10844
			#回傳結果
10845
			return $result;
10846
 
10847
			}#if end
10848
 
10849
		#取得檔案名稱
10850
		$result["fileName"]=$delStrBeforeKeyWord["content"];
10851
 
10852
		#函式說明:
10853
		#將字串特定關鍵字與其後面的內容剔除
10854
		#回傳結果:
10855
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
10856
		#$result["error"],錯誤訊息陣列.
10857
		#$result["warning"],警告訊息鎮列.
10858
		#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
10859
		#$result["function"],當前執行的函數名稱.
10860
		#$result["oriStr"],要處理的原始字串內容.
10861
		#$result["content"],處理好的的字串內容.
10862
		#$result["argu"],使用的參數.
10863
		#必填參數:
10864
		#$conf["stringIn"],字串,要處理的字串.
10865
		$conf["stringProcess::delStrAfterKeyWord"]["stringIn"]=$result["content"];
10866
		#$conf["keyWord"],字串,特定字串.
10867
		$conf["stringProcess::delStrAfterKeyWord"]["keyWord"]=$result["fileName"];
10868
		#可省略參數:
10869
		#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
10870
		#$conf["deleteLastRepeatedOne"]="";
10871
		#參考資料:
10872
		#無.
10873
		#備註:
10874
		#無.
10875
		$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
10876
		unset($conf["stringProcess::delStrAfterKeyWord"]);
10877
 
10878
		#如果執行失敗
10879
		if($delStrAfterKeyWord["status"]==="false"){
10880
 
10881
			#設置執行失敗
10882
			$result["status"]="false";
10883
 
10884
			#設置執行錯誤訊息
10885
			$result["error"]=$delStrAfterKeyWord;
10886
 
10887
			#回傳結果
10888
			return $result;
10889
 
10890
			}#if end
10891
 
10892
		#如果應該要存在的檔案名稱關鍵字不在
10893
		if($delStrAfterKeyWord["founded"]==="false"){
10894
 
10895
			#設置執行失敗
10896
			$result["status"]="false";
10897
 
10898
			#設置執行錯誤訊息
10899
			$result["error"]=$delStrAfterKeyWord;
10900
 
10901
			#回傳結果
10902
			return $result;
10903
 
10904
			}#if end
10905
 
10906
		#取得路徑
10907
		$result["path"]=$delStrAfterKeyWord["content"];
10908
 
10909
		#設置執行正常
10910
		$result["status"]="true";
10911
 
10912
		#回傳結果
10913
		return $result;
10914
 
10915
		}#function createTempFile end
10916
 
10917
	/*
10918
	#函式說明:
10919
	#分割檔案,分割出來的檔案名稱編號為aa, ab ac...ba, bb, bc...,zx, zy, zz的順序.
10920
	#回傳結果:
10921
	#$result["status"],"true"代表移除成功,"false"代表移除失敗.
10922
	#$result["error"],錯誤訊息陣列.
10923
	#$result["function"],當前執行的函數名稱.
10924
	#$result["cmd"],執行的指令.
10925
	#$result["content"],執行指令回傳的結果.
10926
	#必填參數:
10927
	#$conf["file"],字串,要分割的檔案名稱.
10928
	$conf["file"]="";	
10929
	#可省略參數:
10930
	#$conf["splitNameHead"],字串,分割成檔案的名稱開頭,預設為 $conf["file"]."-" .
10931
	#$conf["splitNameHead"]="";	
10932
	#$conf["partSize"],字串,分割檔的大小為多少?可以為XMB,XGB,XKB,可參見split指令的說明,預設為50MB.
10933
	#$conf["partSize"]="";
10934
	#參考資料:
10935
	#無.
10936
	#備註:
10937
	#需要有split指令
10938
	*/
10939
	public static function split(&$conf=array()){
10940
 
10941
		#初始化要回傳的結果
10942
		$result=array();
10943
 
10944
		#取得當前執行的函數名稱
10945
		$result["function"]=__FUNCTION__;
10946
 
10947
		#如果沒有參數
10948
		if(func_num_args()==0){
10949
 
10950
			#設置執行失敗
10951
			$result["status"]="false";
10952
 
10953
			#設置執行錯誤訊息
10954
			$result["error"]="函數".$result["function"]."需要參數";
10955
 
10956
			#回傳結果
10957
			return $result;
10958
 
10959
			}#if end
10960
 
10961
		#函式說明:
10962
		#判斷當前環境為web還是cmd
10963
		#回傳結果:
10964
		#$result,"web"或"cmd"
10965
		if(csInformation::getEnv()==="web"){
10966
 
10967
			#設置執行失敗
10968
			$result["status"]="false";
10969
 
10970
			#設置執行錯誤訊息
10971
			$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";
10972
 
10973
			#回傳結果
10974
			return $result;
10975
 
10976
			}#if end
10977
 
10978
		#取得參數
10979
		$result["argu"]=$conf;
10980
 
10981
		#如果 $conf 不為陣列
10982
		if(gettype($conf)!=="array"){
10983
 
10984
			#設置執行失敗
10985
			$result["status"]="false";
10986
 
10987
			#設置執行錯誤訊息
10988
			$result["error"][]="\$conf變數須為陣列形態";
10989
 
10990
			#如果傳入的參數為 null
10991
			if($conf===null){
10992
 
10993
				#設置執行錯誤訊息
10994
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
10995
 
10996
				}#if end
10997
 
10998
			#回傳結果
10999
			return $result;
11000
 
11001
			}#if end
11002
 
11003
		#檢查參數
11004
		#函式說明:
11005
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
11006
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11007
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
11008
		#$result["function"],當前執行的函式名稱.
11009
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
11010
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
11011
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
11012
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
11013
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
11014
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
11015
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
11016
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
11017
		#必填寫的參數:
11018
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
11019
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
11020
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
11021
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file");
11022
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
11023
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
11024
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
11025
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
11026
		#可以省略的參數:
11027
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
11028
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
11029
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
11030
		#$conf["canNotBeEmpty"]=array();
11031
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
11032
		#$conf["canBeEmpty"]=array();
11033
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
11034
		#$conf["skipableVariableCanNotBeEmpty"]=array();
11035
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
11036
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("splitNameHead","partSize");
11037
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
11038
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
11039
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]",若後面需要加上內容,則可以再補上\",後面再補上要串接的內容.
11040
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("\$conf[\"file\"]\"-","50MB");
11041
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
11042
		#$conf["arrayCountEqualCheck"][]=array();
11043
		#參考資料來源:
11044
		#array_keys=>http://php.net/manual/en/function.array-keys.php
11045
		#建議:
11046
		#增加可省略參數全部不能為空字串或空陣列的參數功能.
11047
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
11048
		unset($conf["variableCheck::checkArguments"]);
11049
 
11050
		#如果檢查參數失敗
11051
		if($checkArguments["status"]==="false"){
11052
 
11053
			#設置執行失敗
11054
			$result["status"]="false";
11055
 
11056
			#設置錯誤訊息
11057
			$result["error"]=$checkArguments;
11058
 
11059
			#回傳結果
11060
			return $result;
11061
 
11062
			}#if end
11063
 
11064
		#如果要分割的檔案存在
11065
		if(file_exists($conf["file"])){
11066
 
11067
			#取得執行的指令
11068
			$result["cmd"]="split -b ".$conf["partSize"]." '".$conf["file"]."' '".$conf["splitNameHead"]."'";
11069
 
11070
			#執行還原的指令
11071
			exec($result["cmd"],$output,$status);
11072
 
11073
			#取得執行後的輸出
11074
			$result["content"]=$output;
11075
 
11076
			}#if end
11077
 
11078
		#反之
11079
		else{
11080
 
11081
			#設置執行失敗
11082
			$result["status"]="false";
11083
 
11084
			#設置執行錯誤訊息
11085
			$result["error"][]="要分割的檔案「".$conf["file"]."」不存在";
11086
 
11087
			#回傳結果
11088
			return $result;
11089
 
11090
			}#else end
11091
 
11092
		#設置執行正常
11093
		$result["status"]="true";
11094
 
11095
		#回傳結果
11096
		return $result;
11097
 
11098
		}#function split end
11099
 
11100
	/*
11101
	#函式說明:
11102
	#合併檔案,檔案編號為aa, ab ac...ba, bb, bc...,zx, zy, zz的順序.
11103
	#回傳結果:
11104
	#$result["status"],"true"代表移除成功,"false"代表移除失敗.
11105
	#$result["error"],錯誤訊息陣列.
11106
	#$result["function"],當前執行的函數名稱.
11107
	#$result["cmd"],執行的指令.
11108
	#$result["content"],執行指令回傳的結果.
11109
	#必填參數:
11110
	#$conf["filePartHead"],字串,分割檔案的名稱開頭.
11111
	$conf["filePartHead"]="";
11112
	#$conf["oriFileName"],字串,合併後的檔案名稱.
11113
	$conf["oriFileName"]="";
11114
	#可省略參數:
11115
	#無
11116
	#參考資料:
11117
	#無.
11118
	#備註:
11119
	#需要有cat指令.
11120
	#僅能在命令列執行.
11121
	*/
11122
	public static function merge(&$conf=array()){
11123
 
11124
		#初始化要回傳的結果
11125
		$result=array();
11126
 
11127
		#取得當前執行的函數名稱
11128
		$result["function"]=__FUNCTION__;
11129
 
11130
		#如果沒有參數
11131
		if(func_num_args()==0){
11132
 
11133
			#設置執行失敗
11134
			$result["status"]="false";
11135
 
11136
			#設置執行錯誤訊息
11137
			$result["error"]="函數".$result["function"]."需要參數";
11138
 
11139
			#回傳結果
11140
			return $result;
11141
 
11142
			}#if end
11143
 
11144
		#函式說明:
11145
		#判斷當前環境為web還是cmd
11146
		#回傳結果:
11147
		#$result,"web"或"cmd"
11148
		if(csInformation::getEnv()==="web"){
11149
 
11150
			#設置執行失敗
11151
			$result["status"]="false";
11152
 
11153
			#設置執行錯誤訊息
11154
			$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";
11155
 
11156
			#回傳結果
11157
			return $result;
11158
 
11159
			}#if end
11160
 
11161
		#取得參數
11162
		$result["argu"]=$conf;
11163
 
11164
		#如果 $conf 不為陣列
11165
		if(gettype($conf)!=="array"){
11166
 
11167
			#設置執行失敗
11168
			$result["status"]="false";
11169
 
11170
			#設置執行錯誤訊息
11171
			$result["error"][]="\$conf變數須為陣列形態";
11172
 
11173
			#如果傳入的參數為 null
11174
			if($conf===null){
11175
 
11176
				#設置執行錯誤訊息
11177
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
11178
 
11179
				}#if end
11180
 
11181
			#回傳結果
11182
			return $result;
11183
 
11184
			}#if end
11185
 
11186
		#檢查參數
11187
		#函式說明:
11188
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
11189
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11190
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
11191
		#$result["function"],當前執行的函式名稱.
11192
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
11193
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
11194
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
11195
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
11196
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
11197
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
11198
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
11199
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
11200
		#必填寫的參數:
11201
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
11202
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
11203
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
11204
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("filePartHead","oriFileName");
11205
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
11206
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
11207
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
11208
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
11209
		#可以省略的參數:
11210
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
11211
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
11212
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
11213
		#$conf["canNotBeEmpty"]=array();
11214
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
11215
		#$conf["canBeEmpty"]=array();
11216
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
11217
		#$conf["skipableVariableCanNotBeEmpty"]=array();
11218
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
11219
		#$conf["skipableVariableName"]=array();
11220
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
11221
		#$conf["skipableVariableType"]=array();
11222
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
11223
		#$conf["skipableVarDefaultValue"]=array("");
11224
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
11225
		#$conf["arrayCountEqualCheck"][]=array();
11226
		#參考資料來源:
11227
		#array_keys=>http://php.net/manual/en/function.array-keys.php
11228
		#建議:
11229
		#增加可省略參數全部不能為空字串或空陣列的參數功能.
11230
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
11231
		unset($conf["variableCheck::checkArguments"]);
11232
 
11233
		#如果檢查參數失敗
11234
		if($checkArguments["status"]==="false"){
11235
 
11236
			#設置執行失敗
11237
			$result["status"]="false";
11238
 
11239
			#設置錯誤訊息
11240
			$result["error"]=$checkArguments;
11241
 
11242
			#回傳結果
11243
			return $result;
11244
 
11245
			}#if end
11246
 
11247
		#定義編號
11248
		$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");
11249
 
11250
		#定義分割檔案的前置字串
11251
		$filePartHead=$conf["filePartHead"];
11252
 
11253
		#要合併成的檔案名稱
11254
		$oriFileName=$conf["oriFileName"];
11255
 
11256
		#初始化要執行合併的語法
11257
		$restoreCmd="cat ";
11258
 
11259
		#有幾個編號就執行幾次
11260
		for($i=0;$i<count($charArray);$i++){
11261
 
11262
			#有幾個編號就執行幾次
11263
			for($j=0;$j<count($charArray);$j++){
11264
 
11265
				#如果該分割檔存在
11266
				if(file_exists($filePartHead.$charArray[$i].$charArray[$j])){
11267
 
11268
					#串接要還原的分割檔
11269
					$restoreCmd=$restoreCmd." '".$filePartHead.$charArray[$i].$charArray[$j]."'";
11270
 
11271
					}#if end
11272
 
11273
				#反之
11274
				else{
11275
 
11276
					#如果是第一個分割檔就找不到
11277
					if($i===0 && $j===0){
11278
 
11279
						#設置執行失敗
11280
						$result["status"]="false";
11281
 
11282
						#設置錯誤訊息
11283
						$result["error"][]="找不到第一個分割檔「".$filePartHead.$charArray[$i].$charArray[$j]."」";
11284
 
11285
						#回傳結果
11286
						return $result;
11287
 
11288
						}#if end
11289
 
11290
					#串接要還原成的檔案名稱
11291
					$restoreCmd=$restoreCmd." > '".$oriFileName."'";
11292
 
11293
					#取得執行的指令
11294
					$result["cmd"]=$restoreCmd;
11295
 
11296
					#執行還原的指令
11297
					exec($restoreCmd,$output,$status);
11298
 
11299
					#取得執行後的輸出
11300
					$result["content"]=$output;
11301
 
11302
					#結束回圈
11303
					break 2;
11304
 
11305
					}#else end
11306
 
11307
				}#for end
11308
 
11309
			}#for end
11310
 
11311
		#設置執行正常
11312
		$result["status"]="true";
11313
 
11314
		#回傳結果
11315
		return $result;
11316
 
11317
		}#function merge end
11318
 
11319
	/*
11320
	#函式說明:
11321
	#取得檔案的部分內容
11322
	#回傳結果:
11323
	#$result["status"],"true"代表移除成功,"false"代表移除失敗.
11324
	#$result["error"],錯誤訊息陣列.
11325
	#$result["function"],當前執行的函數名稱.
11326
	#$result["cmd"],執行的指令.
11327
	#$result["content"],取得的檔案內容.
11328
	#$result["length"],取得的內容長度.
11329
	#$result["EOF"],識別是否已經到檔案結尾,"true"代表是,"false"代表不是.
11330
	#$result["mimeType"],檔案的 mime type.
11331
	#必填參數:
11332
	#$conf["file"],字串,檔案的路徑與名稱.
11333
	$conf["file"]="";
11334
	#$conf["fileArgu"],字串,__FILE__的內容.
11335
	$conf["fileArgu"]=__FILE__;
11336
	#$conf["bytes"],整數字串,要讀取多少bytes.
11337
	$conf["bytes"]="";
11338
	#$conf["startIndex"],要從哪個bytes位置開始,起始點為0.
11339
	$conf["startIndex"]="";
11340
	#可省略參數:
11341
	#無
11342
	#參考資料:
11343
	#無.
11344
	#備註:
11345
	#無
11346
	*/
11347
	public static function getFilePart(&$conf){
11348
 
11349
		#初始化要回傳的結果
11350
		$result=array();
11351
 
11352
		#取得當前執行的函數名稱
11353
		$result["function"]=__FUNCTION__;
11354
 
11355
		#如果沒有參數
11356
		if(func_num_args()==0){
11357
 
11358
			#設置執行失敗
11359
			$result["status"]="false";
11360
 
11361
			#設置執行錯誤訊息
11362
			$result["error"]="函數".$result["function"]."需要參數";
11363
 
11364
			#回傳結果
11365
			return $result;
11366
 
11367
			}#if end
11368
 
11369
		#取得參數
11370
		$result["argu"]=$conf;
11371
 
11372
		#如果 $conf 不為陣列
11373
		if(gettype($conf)!=="array"){
11374
 
11375
			#設置執行失敗
11376
			$result["status"]="false";
11377
 
11378
			#設置執行錯誤訊息
11379
			$result["error"][]="\$conf變數須為陣列形態";
11380
 
11381
			#如果傳入的參數為 null
11382
			if(is_null($conf)){
11383
 
11384
				#設置執行錯誤訊息
11385
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
11386
 
11387
				}#if end
11388
 
11389
			#回傳結果
11390
			return $result;
11391
 
11392
			}#if end
11393
 
11394
		#函式說明:
11395
		#檢查多個檔案與資料夾是否存在.
11396
		#回傳的結果:
11397
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
11398
		#$result["error"],錯誤訊息陣列.
11399
		#$resutl["function"],當前執行的涵式名稱.
11400
		#$result["argu"],使用的參數.
11401
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
11402
		#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
11403
		#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
11404
		#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
11405
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
11406
		#必填參數:
11407
		#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
11408
		$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["file"]);
11409
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
11410
		$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=__FILE__;
11411
		#可省略參數:
11412
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
11413
		#$conf["disableWebSearch"]="false";
11414
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
11415
		#$conf["userDir"]="true";
11416
		#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false",預設為"true".
11417
		#$conf["web"]="true";
11418
		#參考資料:
11419
		#http://php.net/manual/en/function.file-exists.php
11420
		#http://php.net/manual/en/control-structures.foreach.php
11421
		#備註:
11422
		#函數file_exists檢查的路徑為檔案系統的路徑
11423
		#$result["varName"][$i]結果未實作
11424
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
11425
		unset($conf["fileAccess::checkMultiFileExist"]);
11426
 
11427
		#如果執行失敗
11428
		if($checkMultiFileExist["status"]==="false"){
11429
 
11430
			#設置執行失敗
11431
			$result["status"]="false";
11432
 
11433
			#設置執行錯誤訊息
11434
			$result["error"]=$checkMultiFileExist;
11435
 
11436
			#回傳結果
11437
			return $result;
11438
 
11439
			}#if end
11440
 
11441
		#如果檔案不存在
11442
		if($checkMultiFileExist["allExist"]==="false"){
11443
 
11444
			#設置執行失敗
11445
			$result["status"]="false";
11446
 
11447
			#設置執行錯誤訊息
11448
			$result["error"]=$checkMultiFileExist;
11449
 
11450
			#回傳結果
11451
			return $result;
11452
 
11453
			}#if end
11454
 
11455
		#取得mimetype
11456
		$mimetype=mime_content_type($conf["file"]);
11457
 
11458
		#取得檔案的 mime type
11459
		$result["mimeType"]=$mimetype;
11460
 
11461
		#透過 dd 指令,取得部分內容.
11462
		#函式說明:
11463
		#呼叫shell執行系統命令,並取得回傳的內容.
11464
		#回傳結果:
11465
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11466
		#$result["error"],錯誤訊息陣列.
11467
		#$result["function"],當前執行的函數名稱.
11468
		#$result["argu"],使用的參數.
11469
		#$result["cmd"],執行的指令內容.
11470
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
11471
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
11472
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
11473
		#$result["running"],是否還在執行.
11474
		#$result["pid"],pid.
11475
		#$result["statusCode"],執行結束後的代碼.
11476
		#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu")與兩者組合的一維陣列(key為"array").
11477
		#必填參數:
11478
		#$conf["command"],字串,要執行的指令.
11479
		$conf["external::callShell"]["command"]="dd";
11480
		#$conf["fileArgu"],字串,變數__FILE__的內容.
11481
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
11482
		#可省略參數:
11483
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
11484
		$conf["external::callShell"]["argu"]=array("if=".$conf["file"],"bs=".$conf["bytes"],"count=1","status=none");
11485
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
11486
		#$conf["arguIsAddr"]=array();
11487
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
11488
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
11489
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
11490
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
11491
		#$conf["enablePrintDescription"]="true";
11492
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
11493
		#$conf["printDescription"]="";
11494
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
11495
		#$conf["escapeshellarg"]="false";
11496
		#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
11497
		#$conf["thereIsShellVar"]=array();
11498
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
11499
		#$conf["username"]="";
11500
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
11501
		#$conf["password"]="";
11502
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
11503
		#$conf["useScript"]="";
11504
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
11505
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
11506
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
11507
		#$conf["inBackGround"]="";
11508
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
11509
		#$conf["getErr"]="false";
11510
		#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
11511
		#$conf["doNotRun"]="false";
11512
		#參考資料:
11513
		#exec=>http://php.net/manual/en/function.exec.php
11514
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
11515
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
11516
		#備註:
11517
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
11518
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
11519
		$callShell=external::callShell($conf["external::callShell"]);
11520
		unset($conf["external::callShell"]);
11521
 
11522
		#如果執行失敗
11523
		if($callShell["status"]==="false"){
11524
 
11525
			#設置執行失敗
11526
			$result["status"]="false";
11527
 
11528
			#設置執行錯誤訊息
11529
			$result["error"]=$callShell;
11530
 
11531
			#回傳結果
11532
			return $result;
11533
 
11534
			}#if end
11535
 
11536
		#取得結果
11537
		$result["content"]=$callShell["output"][0];
11538
 
11539
		#取得內容長度
11540
		$result["length"]=strlen($result["content"]);
11541
 
11542
		#預設尚未到檔案結尾 
11543
		$result["EOF"]="false";
11544
 
11545
		#如果取得的內容長度小於預期
11546
		if($result["length"]<$conf["bytes"]){
11547
 
11548
			#設置已經到檔案結尾了
11549
			$result["EOF"]="true";
11550
 
11551
			}#if end
11552
 
11553
		#設置執行正常
11554
		$result["status"]="true";
11555
 
11556
		#回傳結果
11557
		return $result;
11558
 
11559
		}#function getFilePart end
11560
 
11561
	/*
11562
	#函式說明:
11563
	#取得節點的資訊.
11564
	#回傳結果:
11565
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
11566
	#$result["error"],錯誤訊息陣列.
11567
	#$result["function"],函數名稱. 
11568
	#$result["content"],檔案資訊陣列.
11569
	#$result["content"]["is_folder"],是否為目錄,"true"代表是,"false"代表不是.	
11570
	#$result["content"]["ownerPerm"],檔案擁有者權限資訊.
11571
	#$result["content"]["groupPerm"],檔案歸屬群組權限資訊.
11572
	#$result["content"]["otherPerm"],檔案對於其他身份使用者的權限資訊.
11573
	#$result["content"]["subElementCount"],目錄底下的檔案目錄數量.
11574
	#$result["content"]["ownerName"],檔案擁有着資訊.
11575
	#$result["content"]["groupName"],檔案所屬擁有着資訊.
11576
	#$result["content"]["size"],檔案大小.
11577
	#$result["content"]["modifyDate"],檔案變更年月日.
11578
	#$result["content"]["modifyTime"],檔案變更時分秒.
11579
	#$result["content"]["modifyTimeFloat"],檔案變更時間秒的float數值.
11580
	#$result["content"]["timezone"],檔案變更時間的時區與UTC的差距.
11581
	#必填參數:
11582
	#$conf["fileArgu"],字串,當前檔案的位置亦即__FILE__的內容.
11583
	$conf["fileArgu"]=__FILE__;
11584
	#$conf["file"],字串,要查看擁有者資訊的檔案.
11585
	$conf["file"]="";
11586
	#可省略參數:
11587
	#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
11588
	#$conf["web"]="true";
11589
	#參考資料:
11590
	#fileowner=>http://php.net/manual/en/function.fileowner.php
11591
	#posix_getpwuid=>http://php.net/manual/en/function.posix-getpwuid.php
11592
	#備註:
11593
	#無.
11594
	*/
11595
	public static function fileInfo(&$conf=array()){
11596
 
11597
		#初始化要回傳的結果
11598
		$result=array();
11599
 
11600
		#取得當前執行的函數名稱
11601
		$result["function"]=__FUNCTION__;
11602
 
11603
		#如果沒有參數
11604
		if(func_num_args()==0){
11605
 
11606
			#設置執行失敗
11607
			$result["status"]="false";
11608
 
11609
			#設置執行錯誤訊息
11610
			$result["error"]="函數".$result["function"]."需要參數";
11611
 
11612
			#回傳結果
11613
			return $result;
11614
 
11615
			}#if end
11616
 
11617
		#取得參數
11618
		$result["argu"]=$conf;
11619
 
11620
		#如果 $conf 不為陣列
11621
		if(gettype($conf)!=="array"){
11622
 
11623
			#設置執行失敗
11624
			$result["status"]="false";
11625
 
11626
			#設置執行錯誤訊息
11627
			$result["error"][]="\$conf變數須為陣列形態";
11628
 
11629
			#如果傳入的參數為 null
11630
			if($conf===null){
11631
 
11632
				#設置執行錯誤訊息
11633
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
11634
 
11635
				}#if end
11636
 
11637
			#回傳結果
11638
			return $result;
11639
 
11640
			}#if end
11641
 
11642
		#檢查參數
11643
		#函式說明:
11644
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
11645
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11646
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
11647
		#$result["function"],當前執行的函式名稱.
11648
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
11649
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
11650
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
11651
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
11652
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
11653
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
11654
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
11655
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
11656
		#必填寫的參數:
11657
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
11658
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
11659
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
11660
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
11661
		#可以省略的參數:
11662
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
11663
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
11664
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
11665
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
11666
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
11667
		#$conf["canBeEmptyString"]="false";
11668
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
11669
		#$conf["ileAccess::checkArguments"]["canNotBeEmpty"]=array();
11670
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
11671
		#$conf["canBeEmpty"]=array();
11672
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
11673
		#$conf["skipableVariableCanNotBeEmpty"]=array();
11674
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
11675
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
11676
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
11677
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
11678
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
11679
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("true");
11680
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
11681
		#$conf["disallowAllSkipableVarIsEmpty"]="";
11682
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
11683
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
11684
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
11685
		#$conf["arrayCountEqualCheck"][]=array();
11686
		#參考資料來源:
11687
		#array_keys=>http://php.net/manual/en/function.array-keys.php
11688
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
11689
		unset($conf["variableCheck::checkArguments"]);
11690
 
11691
		#如果檢查參數失敗
11692
		if($checkArguments["status"]==="false"){
11693
 
11694
			#設置執行失敗
11695
			$result["status"]="false";
11696
 
11697
			#設置執行錯誤訊息
11698
			$result["error"]=$checkArguments;
11699
 
11700
			#回傳結果
11701
			return $result;
11702
 
11703
			}#if end
11704
 
11705
		#如果檢查參數不通過
11706
		if($checkArguments["passed"]==="false"){
11707
 
11708
			#設置執行失敗
11709
			$result["status"]="false";
11710
 
11711
			#設置執行錯誤訊息
11712
			$result["error"]=$checkArguments;
11713
 
11714
			#回傳結果
11715
			return $result;
11716
 
11717
			}#if end
11718
 
11719
		#函式說明:
11720
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
11721
		#回傳結果:
11722
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
11723
		#$result["error"],錯誤訊息陣列.
11724
		#$result["function"],函數名稱. 
11725
		#$result["argu"],使用的參數.
11726
		#$result["content"],網址,若是在命令列執行,則為"null".
11727
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
11728
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
11729
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
11730
		#必填參數:
11731
		#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
11732
		$conf["fileAccess::getInternetAddressV2"]["address"]=$conf["file"];
11733
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
11734
		$conf["fileAccess::getInternetAddressV2"]["fileArgu"]=$conf["fileArgu"];
11735
		#可省略參數:
11736
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
11737
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
11738
		#備註:
11739
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
11740
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
11741
		unset($conf["fileAccess::getInternetAddressV2"]);
11742
 
11743
		#如果取得位置失敗
11744
		if($getInternetAddressV2["status"]==="false"){
11745
 
11746
			#設置執行失敗
11747
			$result["status"]="false";
11748
 
11749
			#設置執行錯誤訊息
11750
			$result["error"]=$getInternetAddressV2;
11751
 
11752
			#回傳結果
11753
			return $result;
11754
 
11755
			}#if end
11756
 
11757
		#函式說明:
11758
		#檢查多個檔案與資料夾是否存在.
11759
		#回傳的結果:
11760
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
11761
		#$result["error"],錯誤訊息陣列.
11762
		#$resutl["function"],當前執行的涵式名稱.
11763
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
11764
		#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
11765
		#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱。
11766
		#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址
11767
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
11768
		#必填參數:
11769
		#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
11770
		$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($getInternetAddressV2["fileSystemAbsoulutePosition"]);
11771
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
11772
		$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
11773
		#可省略參數
11774
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
11775
		#$conf["disableWebSearch"]="false";
11776
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
11777
		#$conf["userDir"]="true";
11778
		#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
11779
		$conf["fileAccess::checkMultiFileExist"]["web"]="false";
11780
		#參考資料來源:
11781
		#http://php.net/manual/en/function.file-exists.php
11782
		#http://php.net/manual/en/control-structures.foreach.php
11783
		#備註:
11784
		#函數file_exists檢查的路徑為檔案系統的路徑
11785
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
11786
		unset($conf["fileAccess::checkMultiFileExist"]);
11787
 
11788
		#如果檢查檔案存在失敗
11789
		if($checkMultiFileExist["status"]==="false"){
11790
 
11791
			#設置執行失敗
11792
			$result["status"]="false";
11793
 
11794
			#設置執行錯誤訊息
11795
			$result["error"]=$checkMultiFileExist;
11796
 
11797
			#回傳結果
11798
			return $result;
11799
 
11800
			}#if end
11801
 
11802
		#如果檔案不存在
11803
		if($checkMultiFileExist["allExist"]==="false"){
11804
 
11805
			#設置執行失敗
11806
			$result["status"]="false";
11807
 
11808
			#設置執行錯誤訊息
11809
			$result["error"]=$checkMultiFileExist;
11810
 
11811
			#回傳結果
11812
			return $result;
11813
 
11814
			}#if end
11815
 
11816
		#透過ls指令取得檔案的資訊
11817
		#函式說明:
11818
		#呼叫shell執行系統命令,並取得回傳的內容.
11819
		#回傳的結果:
11820
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
11821
		#$result["error"],錯誤訊息陣列.
11822
		#$result["function"],當前執行的函數名稱.
11823
		#$result["cmd"],執行的指令內容.
11824
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
11825
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
11826
		#$result["tmpFileOutput"],儲存輸出的暫村檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
11827
		#$result["running"],是否還在執行.
11828
		#$result["pid"],pid
11829
		#必填的參數
11830
		#$conf["command"],字串,要執行的指令
11831
		$conf["external::callShell"]["command"]="ls";
11832
		#$conf["fileArgu"],字串,變數__FILE__的內容.
11833
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
11834
		#可省略參數:
11835
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
11836
		$conf["external::callShell"]["argu"]=array("-l","--full-time","-d",$conf["file"]);
11837
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
11838
		$conf["external::callShell"]["arguIsAddr"]=array("false","false","false","false");
11839
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
11840
		#$conf["enablePrintDescription"]="true";
11841
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
11842
		#$conf["printDescription"]="";
11843
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
11844
		$conf["external::callShell"]["escapeshellarg"]="true";
11845
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
11846
		#$conf["username"]="";
11847
		#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
11848
		#$conf["password"]="";
11849
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
11850
		#$conf["useScript"]="";
11851
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
11852
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
11853
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
11854
		#$conf["inBackGround"]="";
11855
		#備註:
11856
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
11857
		#參考資料:
11858
		#exec=>http://php.net/manual/en/function.exec.php
11859
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
11860
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
11861
		$callShell=external::callShell($conf["external::callShell"]);
11862
		unset($conf["external::callShell"]);
11863
 
11864
		#如果執行失敗
11865
		if($callShell["status"]==="false"){
11866
 
11867
			#設置執行失敗
11868
			$result["status"]="false";
11869
 
11870
			#設置執行錯誤訊息
11871
			$result["error"]=$callShell;
11872
 
11873
			#回傳結果
11874
			return $result;
11875
 
11876
			}#if end	
11877
 
11878
		#解析檔案資訊
11879
		#-rwxrwx--x. 1 apache apache 65K 2017-04-16 22:53:19.044545806 +0800 fileAccessT.php
11880
 
11881
		#取得權限資訊 -rwxrwx--x
11882
		$perm=substr($callShell["output"][0],0,strpos($callShell["output"][0],'.'));
11883
 
11884
		#如果是目錄
11885
		if(substr($perm,0,1)==="d"){
11886
 
11887
			#設定為目錄
11888
			$result["content"]["is_folder"]="true";
11889
 
11890
			}#if end
11891
 
11892
		#反之
11893
		else{
11894
 
11895
			#設定不為目錄
11896
			$result["content"]["is_folder"]="false";
11897
 
11898
			}#else end
11899
 
11900
		#解析檔案擁有者權限資訊
11901
		$result["content"]["ownerPerm"]=substr($perm,1,3);
11902
 
11903
		#如果檔案擁有者名稱為空
11904
		if(empty($result["content"]["ownerPerm"])){
11905
 
11906
			#設置執行失敗
11907
			$result["status"]="false";
11908
 
11909
			#設置執行錯誤訊息
11910
			$result["error"]=$callShell;
11911
 
11912
			#回傳結果
11913
			return $result;
11914
 
11915
			}#if end
11916
 
11917
		#解析檔案歸屬群組權限資訊
11918
		$result["content"]["groupPerm"]=substr($perm,4,3);
11919
 
11920
		#解析檔案對於其他身份使用者的權限資訊
11921
		$result["content"]["otherPerm"]=substr($perm,7,3);
11922
 
11923
		#取得目錄底下的檔案目錄數量起始點
11924
		$subElementStartPos=strpos($callShell["output"][0],' ');
11925
 
11926
		#取得目錄底下的檔案目錄數量結束點
11927
		$subElementEndPos=strpos($callShell["output"][0],' ',$subElementStartPos+1);
11928
 
11929
		#取得目錄底下的檔案目錄數量
11930
		$result["content"]["subElementCount"]=substr($callShell["output"][0],$subElementStartPos,$subElementEndPos-$subElementStartPos);
11931
 
11932
		#取得檔案擁有着資訊的起點
11933
		$ownerNameStrPos=strpos($callShell["output"][0],' ',$subElementEndPos)+1;
11934
 
11935
		#取得檔案擁有着資訊的結束點
11936
		$ownerNameEndPos=strpos($callShell["output"][0],' ',$ownerNameStrPos+1);
11937
 
11938
		#取得檔案擁有着資訊
11939
		$result["content"]["ownerName"]=substr($callShell["output"][0],$ownerNameStrPos,$ownerNameEndPos-$ownerNameStrPos);
11940
 
11941
		#取取得檔案群組擁有者資訊的起點
11942
		$groupNameStrPos=strpos($callShell["output"][0],' ',$ownerNameEndPos)+1;
11943
 
11944
		#取得檔案群組擁有者資訊的結束點
11945
		$groupNameEndPos=strpos($callShell["output"][0],' ',$groupNameStrPos);
11946
 
11947
		#取得檔案群組擁有者資訊
11948
		$result["content"]["groupName"]=substr($callShell["output"][0],$groupNameStrPos,$groupNameEndPos-$groupNameStrPos);
11949
 
11950
		#取得檔案大小的起點
11951
		$sizeStrPos=strpos($callShell["output"][0],' ',$groupNameEndPos)+1;
11952
 
11953
		#取得檔案大小的結束點
11954
		$sizeEndPos=strpos($callShell["output"][0],' ',$sizeStrPos);
11955
 
11956
		#取得檔案大小
11957
		$result["content"]["size"]=substr($callShell["output"][0],$sizeStrPos,$sizeEndPos-$sizeStrPos);
11958
 
11959
		#取得檔案變更年月日的起點
11960
		$modifyDateStrPos=strpos($callShell["output"][0],' ',$sizeEndPos)+1;
11961
 
11962
		#取得檔案變更年月日的結束點
11963
		$modifyDateEndPos=strpos($callShell["output"][0],' ',$modifyDateStrPos);
11964
 
11965
		#取得檔案變更年月日		
11966
		$result["content"]["modifyDate"]=substr($callShell["output"][0],$modifyDateStrPos,$modifyDateEndPos-$modifyDateStrPos);
11967
 
11968
		#取得檔案變更時分秒的起點
11969
		$modifyTimeStrPos=strpos($callShell["output"][0],' ',$modifyDateEndPos)+1;
11970
 
11971
		#取得檔案變更時分秒的結束點
11972
		$modifyTimeEndPos=strpos($callShell["output"][0],'.',$modifyTimeStrPos);
11973
 
11974
		#取得檔案變更時分秒
11975
		$result["content"]["modifyTime"]=substr($callShell["output"][0],$modifyTimeStrPos,$modifyTimeEndPos-$modifyTimeStrPos);
11976
 
11977
		#取得檔版變更時間秒的float數值起點
11978
		$modifyTimeFloatStrPos=strpos($callShell["output"][0],'.',$modifyTimeEndPos)+1;
11979
 
11980
		#取得檔版變更時間秒的float數值結束點
11981
		$modifyTimeFloatEndPos=strpos($callShell["output"][0],' ',$modifyTimeFloatStrPos);
11982
 
11983
		#取得檔版變更時間秒的float數值	
11984
		$result["content"]["modifyTimeFloat"]=substr($callShell["output"][0],$modifyTimeFloatStrPos,$modifyTimeFloatEndPos-$modifyTimeFloatStrPos);
11985
 
11986
		#取得時區起始點
11987
		$timezoneStrPos=strpos($callShell["output"][0],' ',$modifyTimeFloatEndPos)+1;
11988
 
11989
		#取得時區結束點
11990
		$timezoneEndPos=strpos($callShell["output"][0],' ',$timezoneStrPos)+1;	
11991
 
11992
		#取得檔案變更時間的時區與UTC的差距.
11993
		$result["content"]["timezone"]=substr($callShell["output"][0],$timezoneStrPos,$timezoneEndPos-$timezoneStrPos);			
11994
 
11995
		#設置執行正常
11996
		$result["status"]="true";
11997
 
11998
		#回傳結果
11999
		return $result;
12000
 
12001
		}#function fileInfo end
12002
 
12003
	/*
12004
	#函式說明:
12005
	#依據函數getListTree執行的結果,將其底下與其子目錄底下的特定檔案內容依據目錄層級輸出成html檔案 
12006
	#回傳結果:
12007
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
12008
	#$result["error"],錯誤訊息陣列.
12009
	#$result["function"],函數名稱. 
12010
	#$result["content"],html檔案輸出的位置與名稱.
12011
	#必填參數:
12012
	#$conf["getListTree"],陣列變數,函數getListTree執行的結果.
12013
	$conf["getListTree"]=$getListTree;
12014
	#可省略參數:
12015
	#$conf["fileToRead"],字串,要讀取的檔案名稱為何?預設為"help".
12016
	#$conf["fileToRead"]="help";
12017
	#$conf["output"],字串,輸出的網頁檔案位置與名稱,副檔名html會自動補上,預設為"help".
12018
	#$conf["output"]="help.html"; 
12019
	#參考資料:
12020
	#無.
12021
	#備註:
12022
	#建構中...
12023
	*/
12024
	public static function createHelpFile($conf){
12025
 
12026
		#初始化要回傳的結果
12027
		$result=array();
12028
 
12029
		#設置當其函數名稱
12030
		$result["function"]=__FUNCTION__;
12031
 
12032
		#如果 $conf 不為陣列
12033
		if(gettype($conf)!="array"){
12034
 
12035
			#設置執行失敗
12036
			$result["status"]="false";
12037
 
12038
			#設置執行錯誤訊息
12039
			$result["error"][]="\$conf變數須為陣列形態";
12040
 
12041
			#如果傳入的參數為 null
12042
			if($conf==null){
12043
 
12044
				#設置執行錯誤訊息
12045
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
12046
 
12047
				}#if end
12048
 
12049
			#回傳結果
12050
			return $result;
12051
 
12052
			}#if end
12053
 
12054
		#檢查參數
12055
		#函式說明:
12056
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
12057
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12058
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
12059
		#$result["function"],當前執行的函式名稱.
12060
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
12061
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
12062
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
12063
		#$result[$shouldBtCheckedVarName]["error"],每個參數設定的錯誤訊息
12064
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
12065
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
12066
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
12067
		#必填寫的參數:
12068
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
12069
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
12070
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
12071
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("getListTree");
12072
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
12073
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array");
12074
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
12075
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
12076
		#可以省略的參數:
12077
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
12078
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
12079
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
12080
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileToRead","output");
12081
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
12082
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string");
12083
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
12084
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("help","help");
12085
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
12086
		#$conf["variableCheck::checkArguments"]["arrayCountEqualCheck"][]=array("leaderWordArray","leaderWordOptionCountArray");
12087
		#參考資料來源:
12088
		#array_keys=>http://php.net/manual/en/function.array-keys.php
12089
		$checkResult=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
12090
		unset($conf["variableCheck::checkArguments"]);
12091
 
12092
		#如果 $checkResult["status"] 等於 "fasle"
12093
		if($checkResult["status"]=="false"){
12094
 
12095
			#設置錯誤識別
12096
			$result["status"]="false";
12097
 
12098
			#設置錯誤訊息
12099
			$result["error"]=$checkResult;
12100
 
12101
			#回傳結果
12102
			return $result;
12103
 
12104
			}#if end
12105
 
12106
		#如果 $checkResult["passed"] 等於 "fasle"
12107
		if($checkResult["passed"]=="false"){
12108
 
12109
			#設置錯誤識別
12110
			$result["status"]="false";
12111
 
12112
			#設置錯誤訊息
12113
			$result["error"]=$checkResult;
12114
 
12115
			#回傳結果
12116
			return $result;
12117
 
12118
			}#if end
12119
 
12120
		#如果 $conf["getListTree"]["status"] 不存在
12121
		if(!isset($conf["getListTree"]["status"])){
12122
 
12123
			#設置錯誤識別
12124
			$result["status"]="false";
12125
 
12126
			#設置錯誤訊息
12127
			$result["error"][]="getListTree參數必須為getListTree函數執行後的結果";
12128
 
12129
			#回傳結果
12130
			return $result;
12131
 
12132
			}#if end
12133
 
12134
		#如果 $conf["getListTree"] 執行失敗
12135
		if($conf["getListTree"]["status"]=="false"){
12136
 
12137
			#設置錯誤識別
12138
			$result["status"]="false";
12139
 
12140
			#設置錯誤訊息
12141
			$result["error"]=$conf["getListTree"];
12142
 
12143
			#回傳結果
12144
			return $result;
12145
 
12146
			}#if end
12147
 
12148
		#如果有目錄檔案
12149
		if(isset($conf["getListTree"]["content"])){
12150
 
12151
 
12152
 
12153
			}#if end
12154
 
12155
		}#function createHelpFile end
12156
 
12157
	/*
12158
	#函式說明:
12159
	#嵌入pdf檔案到網頁上面
12160
	#回傳結果:
12161
	#$result["status"],"true"爲建立成功,"false"爲建立失敗.
12162
	#$result["error"],錯誤訊息陣列.
12163
	#$result["function"],函數名稱. 
12164
	#$result["content"],嵌入pdf檔案的語法
12165
	#必填參數:
12166
	#$conf["fileArgu"],字串,當前檔案的位置亦即__FILE__的內容.
12167
	$conf["fileArgu"]=__FILE__;
12168
	#$conf["file"],字串,pdf檔案位置.
12169
	$conf["file"]="";
12170
	#可省略參數:
12171
	#$conf["type"],字串,要用"iframe"還是"object"的方式嵌入pdf檔案,預設為"iframe".
12172
	#$conf["type"]="iframe";
12173
	#參考資料:
12174
	#嵌入pdf到網頁=>https://stackoverflow.com/questions/14690000/embed-a-pdf-in-html5
12175
	#備註:
12176
	#如果是網址就會出錯.
12177
	*/
12178
	public static function embedPdf(&$conf=array()){
12179
 
12180
		#初始化要回傳的結果
12181
		$result=array();
12182
 
12183
		#取得當前執行的函數名稱
12184
		$result["function"]=__FUNCTION__;
12185
 
12186
		#如果沒有參數
12187
		if(func_num_args()==0){
12188
 
12189
			#設置執行失敗
12190
			$result["status"]="false";
12191
 
12192
			#設置執行錯誤訊息
12193
			$result["error"]="函數".$result["function"]."需要參數";
12194
 
12195
			#回傳結果
12196
			return $result;
12197
 
12198
			}#if end
12199
 
12200
		#取得參數
12201
		$result["argu"]=$conf;
12202
 
12203
		#如果 $conf 不為陣列
12204
		if(gettype($conf)!=="array"){
12205
 
12206
			#設置執行失敗
12207
			$result["status"]="false";
12208
 
12209
			#設置執行錯誤訊息
12210
			$result["error"][]="\$conf變數須為陣列形態";
12211
 
12212
			#如果傳入的參數為 null
12213
			if($conf===null){
12214
 
12215
				#設置執行錯誤訊息
12216
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
12217
 
12218
				}#if end
12219
 
12220
			#回傳結果
12221
			return $result;
12222
 
12223
			}#if end
12224
 
12225
		#檢查參數
12226
		#函式說明:
12227
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
12228
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12229
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
12230
		#$result["function"],當前執行的函式名稱.
12231
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
12232
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
12233
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
12234
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
12235
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
12236
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
12237
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
12238
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
12239
		#必填寫的參數:
12240
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
12241
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
12242
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
12243
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
12244
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
12245
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
12246
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
12247
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
12248
		#可以省略的參數:
12249
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
12250
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="true";
12251
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
12252
		#$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("function");
12253
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
12254
		#$conf["canBeEmpty"]=array();
12255
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
12256
		#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("width","height");
12257
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
12258
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("type");
12259
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
12260
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
12261
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
12262
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("iframe");
12263
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
12264
		#$conf["arrayCountEqualCheck"][]=array();
12265
		#參考資料來源:
12266
		#array_keys=>http://php.net/manual/en/function.array-keys.php
12267
		#建議:
12268
		#增加可省略參數全部不能為空字串或空陣列的參數功能.
12269
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
12270
		unset($conf["variableCheck::checkArguments"]);		
12271
 
12272
		#如果檢查參數失敗
12273
		if($checkArguments["status"]==="false"){
12274
 
12275
			#設置執行失敗
12276
			$result["status"]="false";
12277
 
12278
			#設置執行錯誤訊息
12279
			$result["error"]=$checkArguments;
12280
 
12281
			#回傳結果
12282
			return $result;
12283
 
12284
			}#if end
12285
 
12286
		#如果參數檢查不通過
12287
		if($checkArguments["passed"]==="false"){
12288
 
12289
			#設置執行失敗
12290
			$result["status"]="false";
12291
 
12292
			#設置執行錯誤訊息
12293
			$result["error"]=$checkArguments;
12294
 
12295
			#回傳結果
12296
			return $result;
12297
 
12298
			}#if end
12299
 
12300
		#檢查檔案是否存在
12301
		#函式說明:
12302
		#檢查多個檔案與資料夾是否存在.
12303
		#回傳的結果:
12304
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
12305
		#$result["error"],錯誤訊息陣列.
12306
		#$resutl["function"],當前執行的涵式名稱.
12307
		#$result["argu"],使用的參數.
12308
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
12309
		#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
12310
		#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱。
12311
		#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址
12312
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
12313
		#必填參數:
12314
		#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
12315
		$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["file"]);
12316
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
12317
		$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
12318
		#可省略參數
12319
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
12320
		$conf["fileAccess::checkMultiFileExist"]["disableWebSearch"]="false";
12321
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
12322
		#$conf["userDir"]="true";
12323
		#參考資料來源:
12324
		#http://php.net/manual/en/function.file-exists.php
12325
		#http://php.net/manual/en/control-structures.foreach.php
12326
		#備註:
12327
		#函數file_exists檢查的路徑為檔案系統的路徑
12328
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
12329
		unset($conf["fileAccess::checkMultiFileExist"]);
12330
 
12331
		#如果檢查檔案是否存在失敗
12332
		if($checkMultiFileExist["status"]==="false"){
12333
 
12334
			#設置執行失敗
12335
			$result["status"]="false";
12336
 
12337
			#設置執行錯誤訊息
12338
			$result["error"]=$checkMultiFileExist;
12339
 
12340
			#回傳結果
12341
			return $result;
12342
 
12343
			}#if end
12344
 
12345
		#如果檔案不存在
12346
		if($checkMultiFileExist["allExist"]==="false"){
12347
 
12348
			#設置執行失敗
12349
			$result["status"]="false";
12350
 
12351
			#設置執行錯誤訊息
12352
			$result["error"]=$checkMultiFileExist;
12353
 
12354
			#回傳結果
12355
			return $result;
12356
 
12357
			}#if end
12358
 
12359
		#產生 base64 的 pdf 編碼字串
12360
		$base64pdf=base64_encode(file_get_contents($conf["file"]));
12361
 
12362
		#產生 base64 的 pdf 編碼字串 data
12363
		$base64pdfData="data:application/pdf;base64,".$base64pdf;
12364
 
12365
		#判斷要用哪種方式嵌入pdf
12366
		switch($conf["type"]){
12367
 
12368
			#如果是用 object 方式
12369
			case "object":
12370
 
12371
				#產生嵌入的語法
12372
				$embedSyntax="<object style=\"width:100%;height:100%;\" data=\"".$base64pdfData."\"></object>";
12373
 
12374
				#取得語法
12375
				$result["content"]=&$embedSyntax;
12376
 
12377
				#跳出 switch
12378
				break;
12379
 
12380
			#預設
12381
			default:
12382
 
12383
				#產生嵌入的語法
12384
				$embedSyntax="<iframe style=\"width:100%;height:100%;\" src=\"".$base64pdfData."\"></iframe>";
12385
 
12386
				#取得語法
12387
				$result["content"]=&$embedSyntax;
12388
 
12389
			}#switch end
12390
 
12391
		#設置執行正常
12392
		$result["status"]="true";
12393
 
12394
		#回傳結果
12395
		return $result;
12396
 
12397
		}#function embedPdf end
12398
 
12399
	/*
12400
	#函式說明:
12401
	#用linux unzip去解壓縮zip檔案 
12402
	#回傳結果:
12403
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12404
	#$result["error"],錯誤訊息.
12405
	#$result["function"],當前執行的函數名稱.
12406
	#$result["content"]["each"],每個檔案的資訊.
12407
	#$result["content"]["each"]["Length"][$i],各別檔案目錄的原始長度.
12408
	#$result["content"]["each"]["Method"][$i],各別檔案目錄的壓縮方法.
12409
	#$result["content"]["each"]["Size"][$i],各別檔案目錄的壓縮後長度.
12410
	#$result["content"]["each"]["Cmpr"][$i],各別檔案目錄的壓縮率.
12411
	#$result["content"]["each"]["Date"][$i],各別檔案目錄的最後修改日期.
12412
	#$result["content"]["each"]["Time"][$i],各別檔案目錄的最後修改時間.
12413
	#$result["content"]["each"]["CRC-32"][$i],各別檔案目錄的CRC-32檢查碼.
12414
	#$result["content"]["each"]["Name"][$i],各別檔案目錄的路徑與名稱.
12415
	#$result["content"]["total"],統整的資訊.
12416
	#$result["content"]["Length"],總共的檔案長度.
12417
	#$result["content"]["Size"],壓縮後的檔案長度.
12418
	#$result["content"]["Cmpr"],平均壓縮率.
12419
	#$result["content"]["count"],壓縮檔裡面總共的檔案跟目錄數目.
12420
	#必填參數;
12421
	#$conf["zip"],字串,要解壓縮的zip檔案.
12422
	$conf["zip"]="";
12423
	#$conf["fileArgu"],字串,__FILE__的內容.
12424
	$conf["fileArgu"]=__FILE__;
12425
	#可省略參數:
12426
	#$conf["extract"],字串,要解壓縮到那個路徑,預設為當前位置"./".
12427
	#$conf["extract"]="";
12428
	#備註:
12429
	#建議加上特定邊碼的支援例如、單
12430
	*/
12431
	public static function unzip(&$conf=array()){
12432
 
12433
		#初始化要回傳的結果
12434
		$result=array();
12435
 
12436
		#取得當前執行的函數名稱
12437
		$result["function"]=__FUNCTION__;
12438
 
12439
		#如果沒有參數
12440
		if(func_num_args()==0){
12441
 
12442
			#設置執行失敗
12443
			$result["status"]="false";
12444
 
12445
			#設置執行錯誤訊息
12446
			$result["error"]="函數".$result["function"]."需要參數";
12447
 
12448
			#回傳結果
12449
			return $result;
12450
 
12451
			}#if end
12452
 
12453
		#取得參數
12454
		$result["argu"]=$conf;
12455
 
12456
		#如果 $conf 不為陣列
12457
		if(gettype($conf)!=="array"){
12458
 
12459
			#設置執行失敗
12460
			$result["status"]="false";
12461
 
12462
			#設置執行錯誤訊息
12463
			$result["error"][]="\$conf變數須為陣列形態";
12464
 
12465
			#如果傳入的參數為 null
12466
			if($conf===null){
12467
 
12468
				#設置執行錯誤訊息
12469
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
12470
 
12471
				}#if end
12472
 
12473
			#回傳結果
12474
			return $result;
12475
 
12476
			}#if end
12477
 
12478
		#檢查參數
12479
		#函式說明:
12480
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
12481
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12482
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
12483
		#$result["function"],當前執行的函式名稱.
12484
		#$result["argu"],設置給予的參數.
12485
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
12486
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
12487
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
12488
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
12489
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
12490
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
12491
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
12492
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
12493
		#必填寫的參數:
12494
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
12495
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
12496
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
12497
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
12498
		#可以省略的參數:
12499
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
12500
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("zip","fileArgu");
12501
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
12502
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
12503
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
12504
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
12505
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
12506
		$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("zip","fileArgu");
12507
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
12508
		#$conf["canBeEmpty"]=array();
12509
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
12510
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("extract");
12511
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
12512
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("extract");
12513
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
12514
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
12515
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
12516
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("./");
12517
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
12518
		#$conf["disallowAllSkipableVarIsEmpty"]="";
12519
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
12520
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
12521
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
12522
		#$conf["arrayCountEqualCheck"][]=array();
12523
		#參考資料來源:
12524
		#array_keys=>http://php.net/manual/en/function.array-keys.php
12525
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
12526
		unset($conf["variableCheck::checkArguments"]);
12527
 
12528
		#如果檢查參數失敗
12529
		if($checkArguments["status"]==="false"){
12530
 
12531
			#設置執行不正常
12532
			$result["status"]="false";
12533
 
12534
			#設置錯誤訊息
12535
			$result["error"]=$checkArguments;
12536
 
12537
			#回傳結果
12538
			return $result;
12539
 
12540
			}#if end
12541
 
12542
		#如果檢查參數不通過
12543
		if($checkArguments["passed"]==="false"){
12544
 
12545
			#設置執行不正常
12546
			$result["status"]="false";
12547
 
12548
			#設置錯誤訊息
12549
			$result["error"]=$checkArguments;
12550
 
12551
			#回傳結果
12552
			return $result;
12553
 
12554
			}#if end
12555
 
12556
		#檢查要解壓縮的檔案是否存在
12557
		#函式說明:
12558
		#檢查多個檔案與資料夾是否存在.
12559
		#回傳的結果:
12560
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
12561
		#$result["error"],錯誤訊息陣列.
12562
		#$resutl["function"],當前執行的涵式名稱.
12563
		#$result["argu"],使用的參數.
12564
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
12565
		#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
12566
		#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
12567
		#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址
12568
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
12569
		#必填參數:
12570
		#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
12571
		$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["zip"]);
12572
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
12573
		$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
12574
		#可省略參數
12575
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
12576
		#$conf["disableWebSearch"]="false";
12577
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
12578
		#$conf["userDir"]="true";
12579
		#參考資料來源:
12580
		#http://php.net/manual/en/function.file-exists.php
12581
		#http://php.net/manual/en/control-structures.foreach.php
12582
		#備註:
12583
		#函數file_exists檢查的路徑為檔案系統的路徑
12584
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
12585
		unset($conf["fileAccess::checkMultiFileExist"]);
12586
 
12587
		#如果檢查檔案是否存在失敗
12588
		if($checkMultiFileExist["status"]==="false"){
12589
 
12590
			#設置執行不正常
12591
			$result["status"]="false";
12592
 
12593
			#設置錯誤訊息
12594
			$result["error"]=$checkMultiFileExist;
12595
 
12596
			#回傳結果
12597
			return $result;
12598
 
12599
			}#if end
12600
 
12601
		#如果要解壓縮的檔案不存在
12602
		if($checkMultiFileExist["allExist"]==="false"){
12603
 
12604
			#設置執行不正常
12605
			$result["status"]="false";
12606
 
12607
			#設置錯誤訊息
12608
			$result["error"]=$checkMultiFileExist;
12609
 
12610
			#回傳結果
12611
			return $result;
12612
 
12613
			}#if end
12614
 
12615
		#函式說明:
12616
		#呼叫shell執行系統命令,並取得回傳的內容.
12617
		#回傳結果:
12618
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12619
		#$result["error"],錯誤訊息陣列.
12620
		#$result["function"],當前執行的函數名稱.
12621
		#$result["argu"],使用的參數.
12622
		#$result["cmd"],執行的指令內容.
12623
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
12624
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
12625
		#$result["tmpFileOutput"],儲存輸出的暫村檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
12626
		#$result["running"],是否還在執行.
12627
		#$result["pid"],pid
12628
		#必填參數:
12629
		#$conf["command"],字串,要執行的指令與.
12630
		$conf["external::callShell"]["command"]="unzip";
12631
		#$conf["fileArgu"],字串,變數__FILE__的內容.
12632
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
12633
		#可省略參數:
12634
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
12635
		$conf["external::callShell"]["argu"]=array("-d",$conf["extract"],"-o","-q",$conf["zip"]);
12636
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
12637
		#$conf["arguIsAddr"]=array();
12638
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
12639
		#$conf["enablePrintDescription"]="true";
12640
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
12641
		#$conf["printDescription"]="";
12642
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
12643
		$conf["external::callShell"]["escapeshellarg"]="true";
12644
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
12645
		#$conf["username"]="";
12646
		#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
12647
		#$conf["password"]="";
12648
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
12649
		#$conf["useScript"]="";
12650
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
12651
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
12652
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
12653
		#$conf["inBackGround"]="";
12654
		#備註:
12655
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
12656
		#參考資料:
12657
		#exec=>http://php.net/manual/en/function.exec.php
12658
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
12659
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
12660
		$callShell=external::callShell($conf["external::callShell"]);
12661
		unset($conf["external::callShell"]);
12662
 
12663
		#如果執行cmd失敗
12664
		if($callShell["status"]==="false"){
12665
 
12666
			#設置執行不正常
12667
			$result["status"]="false";
12668
 
12669
			#設置錯誤訊息
12670
			$result["error"]=$callShell;
12671
 
12672
			#回傳結果
12673
			return $result;
12674
 
12675
			}#if end
12676
 
12677
		#函式說明:
12678
		#呼叫shell執行系統命令,並取得回傳的內容.
12679
		#回傳的結果:
12680
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12681
		#$result["error"],錯誤訊息陣列.
12682
		#$result["function"],當前執行的函數名稱.
12683
		#$result["argu"],使用的參數.
12684
		#$result["cmd"],執行的指令內容.
12685
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
12686
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
12687
		#$result["tmpFileOutput"],儲存輸出的暫村檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
12688
		#$result["running"],是否還在執行.
12689
		#$result["pid"],pid
12690
		#必填的參數
12691
		#$conf["command"],字串,要執行的指令與.
12692
		$conf["external::callShell"]["command"]="unzip";
12693
		#$conf["fileArgu"],字串,變數__FILE__的內容.
12694
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
12695
		#可省略參數:
12696
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
12697
		$conf["external::callShell"]["argu"]=array("-v",$conf["zip"]);
12698
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
12699
		#$conf["arguIsAddr"]=array();
12700
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
12701
		#$conf["enablePrintDescription"]="true";
12702
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容.
12703
		#$conf["printDescription"]="";
12704
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
12705
		$conf["external::callShell"]["escapeshellarg"]="true";
12706
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
12707
		#$conf["username"]="";
12708
		#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
12709
		#$conf["password"]="";
12710
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
12711
		#$conf["useScript"]="";
12712
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
12713
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
12714
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
12715
		#$conf["inBackGround"]="";
12716
		#備註:
12717
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
12718
		#參考資料:
12719
		#exec=>http://php.net/manual/en/function.exec.php
12720
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
12721
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
12722
		$callShell=external::callShell($conf["external::callShell"]);
12723
		unset($conf["external::callShell"]);
12724
 
12725
		#如果執行cmd失敗
12726
		if($callShell["status"]==="false"){
12727
 
12728
			#設置執行不正常
12729
			$result["status"]="false";
12730
 
12731
			#設置錯誤訊息
12732
			$result["error"]=$callShell;
12733
 
12734
			#回傳結果
12735
			return $result;
12736
 
12737
			}#if end	
12738
 
12739
		#取得輸出的內容陣列
12740
		$unzipInfo=$callShell["output"];
12741
 
12742
		/*
12743
 
12744
		 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
12745
		--------  ------  ------- ---- ---------- ----- --------  ----
12746
		 4194304  Defl:X  2507269  40% 05-04-2002 17:30 9386a740  PS2 Bios 30004R V6 Pal.bin
12747
			   4  Defl:X        6 -50% 05-15-2005 06:45 054a6ec2  PS2 Bios 30004R V6 Pal.MEC
12748
			1024  Defl:X       22  98% 06-25-2005 14:55 3493bb06  PS2 Bios 30004R V6 Pal.NVM
12749
		  199680  Defl:X    70524  65% 06-02-2004 16:50 2c3bcd32  rom1.bin
12750
		 4194304  Defl:X  2637496  37% 02-20-2005 21:12 6f8e3c29  SCPH-70004_BIOS_V12_PAL_200.BIN
12751
		 3145728  Defl:X  3138427   0% 02-20-2005 21:12 bf3cbc65  SCPH-70004_BIOS_V12_PAL_200.EROM
12752
			1024  Defl:X      706  31% 02-20-2005 21:12 a8d51ead  SCPH-70004_BIOS_V12_PAL_200.NVM
12753
		  524288  Defl:X   149924  71% 02-20-2005 21:12 0e8797c0  SCPH-70004_BIOS_V12_PAL_200.ROM1
12754
		  524288  Defl:X   149924  71% 02-20-2005 21:12 0e8797c0  SCPH-70004_BIOS_V12_PAL_200.ROM2
12755
		 4194304  Defl:X  2213105  47% 10-18-2000 06:06 b7ef81a9  scph10000.bin
12756
			1024  Defl:X       11  99% 01-01-2005 00:42 efb5af2e  scph10000.NVM
12757
		 4194304  Defl:X  2511182  40% 06-27-2003 10:51 a19e0bf5  scph39001.bin
12758
			   4  Defl:X        6 -50% 05-14-2005 16:00 054a6ec2  scph39001.MEC
12759
			1024  Defl:X       20  98% 05-31-2005 16:09 e14a6cd6  scph39001.NVM
12760
		--------          -------  ---                            -------
12761
		21175304         13378622  37%                            14 files
12762
 
12763
		*/
12764
 
12765
		#取得行數
12766
		$lineCount=count($unzipInfo);
12767
 
12768
		#取得標題
12769
		#函式說明:
12770
		#將固定格式的字串分開,並回傳分開的結果。
12771
		#回傳結果:
12772
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12773
		#$result["error"],錯誤訊息陣列
12774
		#$result["function"],當前執行的函數名稱.
12775
		#$result["oriStr"],要分割的原始字串內容
12776
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
12777
		#$result["dataCounts"],爲總共分成幾段
12778
		#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
12779
		#必填參數:
12780
		$conf["stringProcess::spiltString"]["stringIn"]=$unzipInfo[1];#要處理的字串。
12781
		$conf["stringProcess::spiltString"]["spiltSymbol"]=" ";#爲以哪個符號作爲分割
12782
		#可省略參數:
12783
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
12784
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
12785
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
12786
		unset($conf["stringProcess::spiltString"]);
12787
 
12788
		#如果分割字串失敗
12789
		if($spiltString["status"]==="false"){
12790
 
12791
			#設置執行不正常
12792
			$result["status"]="false";
12793
 
12794
			#設置錯誤訊息
12795
			$result["error"]=$spiltString;
12796
 
12797
			#回傳結果
12798
			return $result;
12799
 
12800
			}#if end
12801
 
12802
		#如果沒有分割用的關鍵字
12803
		if($spiltString["found"]==="false"){
12804
 
12805
			#設置執行不正常
12806
			$result["status"]="false";
12807
 
12808
			#設置錯誤訊息
12809
			$result["error"]=$spiltString;
12810
 
12811
			#回傳結果
12812
			return $result;
12813
 
12814
			}#if end
12815
 
12816
		#取得標題欄位
12817
		$titles=$spiltString["dataArray"];	
12818
 
12819
		#取得標題欄位數目
12820
		$titleCount=$spiltString["dataCounts"];
12821
 
12822
		#針對每列輸出
12823
		for($i=3;$i<$lineCount-2;$i++){
12824
 
12825
			#取得各欄位的內容
12826
			#函式說明:
12827
			#將固定格式的字串分開,並回傳分開的結果。
12828
			#回傳結果:
12829
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12830
			#$result["error"],錯誤訊息陣列
12831
			#$result["function"],當前執行的函數名稱.
12832
			#$result["oriStr"],要分割的原始字串內容
12833
			#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
12834
			#$result["dataCounts"],爲總共分成幾段
12835
			#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
12836
			#必填參數:
12837
			$conf["stringProcess::spiltString"]["stringIn"]=$unzipInfo[$i];#要處理的字串。
12838
			$conf["stringProcess::spiltString"]["spiltSymbol"]=" ";#爲以哪個符號作爲分割
12839
			#可省略參數:
12840
			#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
12841
			$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
12842
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
12843
			unset($conf["stringProcess::spiltString"]);
12844
 
12845
			#如果分割字串失敗
12846
			if($spiltString["status"]==="false"){
12847
 
12848
				#設置執行不正常
12849
				$result["status"]="false";
12850
 
12851
				#設置錯誤訊息
12852
				$result["error"]=$spiltString;
12853
 
12854
				#回傳結果
12855
				return $result;
12856
 
12857
				}#if end
12858
 
12859
			#如果沒有分割用的關鍵字
12860
			if($spiltString["found"]==="false"){
12861
 
12862
				#設置執行不正常
12863
				$result["status"]="false";
12864
 
12865
				#設置錯誤訊息
12866
				$result["error"]=$spiltString;
12867
 
12868
				#回傳結果
12869
				return $result;
12870
 
12871
				}#if end
12872
 
12873
			#取得各欄位的內容
12874
			$cols=$spiltString["dataArray"];
12875
 
12876
			#取得欄位的數目
12877
			$colsCount=$spiltString["dataCounts"];
12878
 
12879
			#如果實際抓出的內容欄位數量大於標題欄位數量,代表檔案/目錄名稱含有空格
12880
			if($colsCount>$titleCount){
12881
 
12882
				#新的檔案名稱
12883
				$newFileName="";
12884
 
12885
				#針對每個多出的欄位
12886
				for($j=$titleCount;$j<$colsCount;$j++){
12887
 
12888
					#串接屬於檔案名稱的部分
12889
					$newFileName=$newFileName.$cols[$j];
12890
 
12891
					#如果不是最後一個項目
12892
					if($j!==$colsCount-1){
12893
 
12894
						#增加空格
12895
						$newFileName=$newFileName." ";
12896
 
12897
						}#if end
12898
 
12899
					}#for end
12900
 
12901
				#取代成對的檔案名稱
12902
				$cols[$titleCount-1]=$newFileName;
12903
 
12904
				}#if end
12905
 
12906
			#針對每個欄位
12907
			for($j=0;$j<$titleCount;$j++){
12908
 
12909
				#取得欄位內容
12910
				$result["content"]["each"][$titles[$j]][]=$cols[$j];
12911
 
12912
				}#for end
12913
 
12914
			}#for end
12915
 
12916
		#取得 total 的輸出內容
12917
		#函式說明:
12918
		#將固定格式的字串分開,並回傳分開的結果。
12919
		#回傳結果:
12920
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
12921
		#$result["error"],錯誤訊息陣列
12922
		#$result["function"],當前執行的函數名稱.
12923
		#$result["oriStr"],要分割的原始字串內容
12924
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
12925
		#$result["dataCounts"],爲總共分成幾段
12926
		#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
12927
		#必填參數:
12928
		$conf["stringProcess::spiltString"]["stringIn"]=$unzipInfo[$lineCount-1];#要處理的字串。
12929
		$conf["stringProcess::spiltString"]["spiltSymbol"]=" ";#爲以哪個符號作爲分割
12930
		#可省略參數:
12931
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
12932
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
12933
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
12934
		unset($conf["stringProcess::spiltString"]);
12935
 
12936
		#如果分割字串失敗
12937
		if($spiltString["status"]==="false"){
12938
 
12939
			#設置執行不正常
12940
			$result["status"]="false";
12941
 
12942
			#設置錯誤訊息
12943
			$result["error"]=$spiltString;
12944
 
12945
			#回傳結果
12946
			return $result;
12947
 
12948
			}#if end
12949
 
12950
		#如果沒有分割用的關鍵字
12951
		if($spiltString["found"]==="false"){
12952
 
12953
			#設置執行不正常
12954
			$result["status"]="false";
12955
 
12956
			#設置錯誤訊息
12957
			$result["error"]=$spiltString;
12958
 
12959
			#回傳結果
12960
			return $result;
12961
 
12962
			}#if end
12963
 
12964
		#取得各欄位的內容
12965
		$cols=$spiltString["dataArray"];
12966
 
12967
		#取得總共的檔案長度
12968
		$result["content"]["total"][$titles[0]]=$cols[0];
12969
 
12970
		#取得壓縮時的總共檔案長度
12971
		$result["content"]["total"][$titles[2]]=$cols[1];
12972
 
12973
		#取得壓縮時的總共檔案長度
12974
		$result["content"]["total"][$titles[3]]=$cols[2];
12975
 
12976
		#取得解壓縮出了多少檔案跟目錄
12977
		$result["content"]["total"]["count"]=explode(" ",$cols[3])[0];
12978
 
12979
		#設置執行正常
12980
		$result["status"]="true";
12981
 
12982
		#回傳結果
12983
		return $result;
12984
 
12985
		}#function unzip end
12986
 
12987
	/*
12988
	#函式說明:
12989
	#接收Range: bytes=0-499格式的header, 輸出檔案的片段或完整檔案.
12990
	#回傳結果:
12991
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
12992
	#$result["error"],錯誤訊息.
12993
	#$result["function"],當前執行的函式名稱.
12994
	#必填參數:
12995
	#$conf["filePath"],字串,檔案的路徑.
12996
	$conf["filePath"]="";
12997
	#可省略參數:
12998
	#$conf["fileName"],字串,顯示的檔案名稱,預設為basename($conf["filePath"]);
12999
	#$conf["fileName"]="";
13000
	#參考資料:
13001
	#https://gdfan1114.wordpress.com/2015/01/14/php-%E5%AF%A6%E4%BD%9C%E6%94%AF%E6%8F%B4-http-%E7%BA%8C%E5%82%B3%E5%8A%9F%E8%83%BD/
13002
	#http://php.net/manual/en/function.filemtime.php
13003
	#http://php.net/manual/en/function.connection-status.php
13004
	#http://php.net/manual/en/function.fread.php
13005
	#備註:
13006
	#請勿在運行該函式前印出任何內容,這是要給用戶端接收的內容.
13007
	*/
13008
	public static function partDownload(&$conf=array()){
13009
 
13010
		#初始化要回傳的結果
13011
		$result=array();
13012
 
13013
		#取得當前執行的函數名稱
13014
		$result["function"]=__FUNCTION__;
13015
 
13016
		#如果沒有參數
13017
		if(func_num_args()==0){
13018
 
13019
			#設置執行失敗
13020
			$result["status"]="false";
13021
 
13022
			#設置執行錯誤訊息
13023
			$result["error"]="函數".$result["function"]."需要參數";
13024
 
13025
			#回傳結果
13026
			return $result;
13027
 
13028
		}#if end
13029
 
13030
		#取得參數
13031
		$result["argu"]=$conf;
13032
 
13033
		#如果 $conf 不為陣列
13034
		if(gettype($conf)!=="array"){
13035
 
13036
			#設置執行失敗
13037
			$result["status"]="false";
13038
 
13039
			#設置執行錯誤訊息
13040
			$result["error"][]="\$conf變數須為陣列形態";
13041
 
13042
			#如果傳入的參數為 null
13043
			if($conf===null){
13044
 
13045
				#設置執行錯誤訊息
13046
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
13047
 
13048
				}#if end
13049
 
13050
			#回傳結果
13051
			return $result;
13052
 
13053
			}#if end
13054
 
13055
		#檢查參數
13056
		#函式說明:
13057
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
13058
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13059
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13060
		#$result["function"],當前執行的函式名稱.
13061
		#$result["argu"],設置給予的參數.
13062
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
13063
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
13064
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
13065
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
13066
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
13067
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
13068
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
13069
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
13070
		#必填寫的參數:
13071
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
13072
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
13073
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
13074
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
13075
		#可以省略的參數:
13076
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
13077
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("filePath");
13078
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
13079
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
13080
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
13081
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
13082
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
13083
		#$conf["canNotBeEmpty"]=array();
13084
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
13085
		#$conf["canBeEmpty"]=array();
13086
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
13087
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("fileName");
13088
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
13089
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("fileName");
13090
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
13091
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
13092
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
13093
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null);
13094
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
13095
		#$conf["disallowAllSkipableVarIsEmpty"]="";
13096
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
13097
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
13098
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
13099
		#$conf["arrayCountEqualCheck"][]=array();
13100
		#參考資料來源:
13101
		#array_keys=>http://php.net/manual/en/function.array-keys.php
13102
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
13103
		unset($conf["variableCheck::checkArguments"]);
13104
 
13105
		#如果檢查參數失敗
13106
		if($checkArguments["status"]==="false"){
13107
 
13108
			#設置執行失敗
13109
			$result["status"]="false";
13110
 
13111
			#設置執行錯誤
13112
			$result["error"]=$checkArguments;
13113
 
13114
			#回傳結果
13115
			return $result;
13116
 
13117
			}#if end
13118
 
13119
		#如果檢查參數不通過
13120
		if($checkArguments["passed"]==="false"){
13121
 
13122
			#設置執行失敗
13123
			$result["status"]="false";
13124
 
13125
			#設置執行錯誤
13126
			$result["error"]=$checkArguments;
13127
 
13128
			#回傳結果
13129
			return $result;
13130
 
13131
			}#if end
13132
 
13133
		#如果沒有設置 $conf["fileName"]
13134
		if(!isset($conf["fileName"])){
13135
 
13136
			#取得檔案名稱
13137
			$filename=basename($conf["filePath"]);
13138
 
13139
			}#if end
13140
 
13141
		#反之
13142
		else{
13143
 
13144
			#取得設定好的檔案名稱
13145
			$filename=&$conf["fileName"];
13146
 
13147
			}#else end
13148
 
13149
		#取得檔案路徑
13150
		$location=$conf["filePath"];
13151
 
13152
		#取得mimetype
13153
		$mimetype=mime_content_type($location);
13154
 
13155
		#如果檔案不存在
13156
		if(!file_exists($location)){
13157
 
13158
			#提示找不到檔案
13159
			header("HTTP/1.1 404 Not Found");
13160
 
13161
			#設置執行失敗
13162
			$result["status"]="false";
13163
 
13164
			#設置錯誤訊息
13165
			$result["error"][]="檔案 ".$location." 不存在.";
13166
 
13167
			#回傳結果
13168
			return $result;
13169
 
13170
			}#if end
13171
 
13172
		#取得檔案的bytes長度
13173
		$size  = filesize($location);
13174
 
13175
		#取得檔案的最後變更日期
13176
		$time  = date('r', filemtime($location));
13177
 
13178
		#讀取檔案的2元碼內容
13179
		$fm = @fopen($location, 'rb');
13180
 
13181
		#如果開啟檔案失敗
13182
		if(!$fm){
13183
 
13184
			#提示錯誤
13185
			header("HTTP/1.1 505 Internal server error");
13186
 
13187
			#設置執行失敗
13188
			$result["status"]="false";
13189
 
13190
			#設置錯誤訊息
13191
			$result["error"][]="開啟檔案 ".$location." 失敗.";
13192
 
13193
			#回傳結果
13194
			return $result;
13195
 
13196
			}#if end
13197
 
13198
		#初始化要提供的bytes長度起始點
13199
		$begin  = 0;
13200
 
13201
		#初始化要提供的bytes長度結束點
13202
		$end  = $size - 1;
13203
 
13204
		#如果有接收到 'HTTP_RANGE' 的 header 訊息
13205
		if(isset($_SERVER['HTTP_RANGE'])){
13206
 
13207
			#接收到的範例
13208
			#Range: bytes=0-499 
13209
 
13210
			#取得要求的bytes位置範圍
13211
			sscanf($_SERVER['HTTP_RANGE'], "bytes=%d-%d",$begin,$end);
13212
 
13213
			#如果 $begin 或 $end  有缺
13214
			if(!isset($begin) || !isset($end)){
13215
 
13216
				#設置執行失敗
13217
				$result["status"]="false";
13218
 
13219
				#設置錯誤訊息
13220
				$result["error"][]="header \"Range\" 的數值格式為 \"bytes=0-499\"";
13221
 
13222
				#回傳結果
13223
				return $result;
13224
 
13225
				}#if end
13226
 
13227
			#如果 $begin 沒有小於等於 $end
13228
			if(!($begin<=$end)){
13229
 
13230
				#設置執行失敗
13231
				$result["status"]="false";
13232
 
13233
				#設置錯誤訊息
13234
				$result["error"][]="header \"Range\" 的數值格式為 \"bytes=0-499\"";
13235
 
13236
				#回傳結果
13237
				return $result;
13238
 
13239
				}#if end
13240
 
13241
			}#if end
13242
 
13243
		#提示 200 ok
13244
		header('HTTP/1.1 200 OK');
13245
 
13246
		#提示 mimetype
13247
		header("Content-Type: $mimetype");
13248
 
13249
		#要先驗證cache中的資料,取得的內容放在快取的時間為0
13250
		header('Cache-Control: public, must-revalidate, max-age=0');
13251
 
13252
		#提示不要cache
13253
		header('Pragma: no-cache');  
13254
 
13255
		#提示接收的 Ranges 單位為 bytes
13256
		header('Accept-Ranges: bytes');
13257
 
13258
		#數值傳輸的內容長度為多少
13259
		header('Content-Length:' . (($end - $begin) + 1));
13260
 
13261
		#提示內容為檔案的哪邊到哪邊與總共的長度
13262
		header("Content-Range: bytes $begin-$end/$size");
13263
 
13264
		#提示檔案的名稱
13265
		header("Content-Disposition: inline; filename=$filename");
13266
 
13267
		#提示用2元碼傳輸
13268
		header("Content-Transfer-Encoding: binary");
13269
 
13270
		#提示檔案最後變更日期
13271
		header("Last-Modified: $time");
13272
 
13273
		#初始化當前位置
13274
		$cur  = $begin;
13275
 
13276
		#指定讀取的起始點為 $begin 
13277
		fseek($fm, $begin, 0);
13278
 
13279
		#讀取內容, 若不是檔案結尾, 且當前位置($cur)小於等於 本次要提供的長度結尾($end), 且connection_status為0
13280
		while(!feof($fm) && $cur<=$end && (connection_status()===0)){
13281
 
13282
			#一次最多印出 1024*16bytes 的長度,若剩下長度不足則只印出剩下的長度.
13283
			echo fread($fm, min(1024 * 16, ($end - $cur) + 1));
13284
 
13285
			#更改位置
13286
			$cur += 1024 * 16;
13287
 
13288
			}#while end
13289
 
13290
		}#function partDownload end
13291
 
13292
	/*
13293
	#函式說明:
13294
	#尋找檔案. 
13295
	#回傳結果:
13296
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13297
	#$result["error"],錯誤訊息.
13298
	#$result["warning"],警告訊息陣列.
13299
	#$result["function"],當前執行的函數名稱.
13300
	#$result["argu"],所使用的參數.
13301
	#$result["found"],是否有找到可以轉換的檔案,"true"代表有;"false"代表沒有.
13302
	#$result["content"],找到的檔案陣列.
13303
	#必填參數:
13304
	#$conf["keyWord"],字串,要搜尋的檔案關鍵字,可用"*"符號,例如"*.qcow2",就代表檔案名成為"qcow2"結尾的檔案.
13305
	$conf["keyWord"]="";
13306
	#$conf["path"],字串陣列,虛擬硬碟檔案的搜尋路徑,預設為當前路徑.
13307
	$conf["path"]=array();
13308
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
13309
	$conf["fileArgu"]=__FILE__;
13310
	#參考資料:
13311
	#http://php.net/manual/en/function.glob.php
13312
	#備註:
13313
	#無.
13314
	*/
13315
	public static function findFile(&$conf=array()){
13316
 
13317
		#初始化要回傳的結果
13318
		$result=array();
13319
 
13320
		#取得當前執行的函數名稱
13321
		$result["function"]=__FUNCTION__;
13322
 
13323
		#如果沒有參數
13324
		if(func_num_args()==0){
13325
 
13326
			#設置執行失敗
13327
			$result["status"]="false";
13328
 
13329
			#設置執行錯誤訊息
13330
			$result["error"]="函數".$result["function"]."需要參數";
13331
 
13332
			#回傳結果
13333
			return $result;
13334
 
13335
			}#if end		
13336
 
13337
		#取得參數
13338
		$result["argu"]=$conf;
13339
 
13340
		#如果 $conf 不為陣列
13341
		if(gettype($conf)!=="array"){
13342
 
13343
			#設置執行失敗
13344
			$result["status"]="false";
13345
 
13346
			#設置執行錯誤訊息
13347
			$result["error"][]="\$conf變數須為陣列形態";
13348
 
13349
			#如果傳入的參數為 null
13350
			if($conf===null){
13351
 
13352
				#設置執行錯誤訊息
13353
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
13354
 
13355
				}#if end
13356
 
13357
			#回傳結果
13358
			return $result;
13359
 
13360
			}#if end
13361
 
13362
		#函式說明:
13363
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
13364
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13365
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13366
		#$result["function"],當前執行的函式名稱.
13367
		#$result["argu"],設置給予的參數.
13368
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
13369
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
13370
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
13371
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
13372
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
13373
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
13374
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
13375
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
13376
		#必填寫的參數:
13377
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
13378
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
13379
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
13380
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
13381
		#可以省略的參數:
13382
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
13383
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path","keyWord","fileArgu");
13384
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
13385
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("array","string","string");
13386
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
13387
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
13388
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
13389
		#$conf["canNotBeEmpty"]=array();
13390
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
13391
		#$conf["canBeEmpty"]=array();
13392
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
13393
		#$conf["skipableVariableCanNotBeEmpty"]=array();
13394
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
13395
		#$conf["skipableVariableName"]=array();
13396
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
13397
		#$conf["skipableVariableType"]=array();
13398
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
13399
		#$conf["skipableVarDefaultValue"]=array("");
13400
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
13401
		#$conf["disallowAllSkipableVarIsEmpty"]="";
13402
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
13403
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
13404
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
13405
		#$conf["arrayCountEqualCheck"][]=array();
13406
		#參考資料來源:
13407
		#array_keys=>http://php.net/manual/en/function.array-keys.php
13408
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
13409
		unset($conf["variableCheck::checkArguments"]);
13410
 
13411
		#如果檢查參數失敗
13412
		if($checkArguments["status"]==="false"){
13413
 
13414
			#設置執行失敗
13415
			$result["status"]="false";
13416
 
13417
			#設置執行失敗訊息
13418
			$result["error"]=$checkArguments;
13419
 
13420
			#回傳結果
13421
			return $result;
13422
 
13423
			}#if end
13424
 
13425
		#如果檢查參數不通過
13426
		if($checkArguments["passed"]==="false"){
13427
 
13428
			#設置執行失敗
13429
			$result["status"]="false";
13430
 
13431
			#設置執行失敗訊息
13432
			$result["error"]=$checkArguments;
13433
 
13434
			#回傳結果
13435
			return $result;
13436
 
13437
			}#if end
13438
 
13439
		#檢查要搜尋的路徑是否都存在
13440
		#函式說明:
13441
		#s檢查多個檔案與資料夾是否存在.
13442
		#回傳的結果:
13443
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
13444
		#$result["error"],錯誤訊息陣列.
13445
		#$resutl["function"],當前執行的涵式名稱.
13446
		#$result["argu"],使用的參數.
13447
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
13448
		#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
13449
		#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
13450
		#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址
13451
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
13452
		#必填參數:
13453
		#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
13454
		$conf["self::checkMultiFileExist"]["fileArray"]=$conf["path"];
13455
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
13456
		$conf["self::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
13457
		#可省略參數
13458
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
13459
		#$conf["disableWebSearch"]="false";
13460
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
13461
		#$conf["userDir"]="true";
13462
		#參考資料來源:
13463
		#http://php.net/manual/en/function.file-exists.php
13464
		#http://php.net/manual/en/control-structures.foreach.php
13465
		#備註:
13466
		#函數file_exists檢查的路徑為檔案系統的路徑
13467
		$checkMultiFileExist=self::checkMultiFileExist($conf["self::checkMultiFileExist"]);
13468
		unset($conf["self::checkMultiFileExist"]);
13469
 
13470
		#如果檢查目錄存在失敗
13471
		if($checkMultiFileExist["status"]==="false"){
13472
 
13473
			#設置執行失敗
13474
			$result["status"]="false";
13475
 
13476
			#設置執行失敗訊息
13477
			$result["error"]=$checkMultiFileExist;
13478
 
13479
			#回傳結果
13480
			return $result;
13481
 
13482
			}#if end	
13483
 
13484
		#如果目錄不存在
13485
		if($checkMultiFileExist["status"]==="false"){
13486
 
13487
			#設置執行失敗
13488
			$result["status"]="false";
13489
 
13490
			#設置執行失敗訊息
13491
			$result["error"]=$checkMultiFileExist;
13492
 
13493
			#回傳結果
13494
			return $result;
13495
 
13496
			}#if end
13497
 
13498
		#如果有路徑不存在
13499
		if($checkMultiFileExist["allExist"]==="false"){
13500
 
13501
			#設置執行失敗
13502
			$result["status"]="false";
13503
 
13504
			#設置執行失敗訊息
13505
			$result["error"]=$checkMultiFileExist;
13506
 
13507
			#設置提示有路徑不存在的訊息
13508
			$result["warning"][]="參數path的路徑沒有每個都存在";
13509
 
13510
			#回傳結果
13511
			return $result;
13512
 
13513
			}#if end
13514
 
13515
		#預設沒有找到檔案
13516
		$result["found"]="false";	
13517
 
13518
		#針對每個要搜尋的路徑
13519
		foreach($conf["path"] as $path){
13520
 
13521
			#函式說明:
13522
			#用find指令尋找檔案
13523
			#回傳結果:
13524
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13525
			#$result["error"],錯誤訊息.
13526
			#$result["function"],當前執行的函數名稱.
13527
			#$result["argu"],所使用的參數.
13528
			#$result["found"],是否有找到符合的檔案,"true"代表有;"false"代表沒有.
13529
			#$result["content"],找到的檔案陣列.
13530
			#必填參數:
13531
			#$conf["keyWord"],字串,要搜尋的檔案關鍵字,可用"*"符號,例如"*.qcow2",就代表檔案名成為"qcow2"結尾的檔案.
13532
			$conf["cmd::find"]["keyWord"]=$conf["keyWord"];	
13533
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
13534
			$conf["cmd::find"]["fileArgu"]=$conf["fileArgu"];
13535
			#可省略參數:
13536
			#$conf["path"],字串,搜尋的路徑,預設為"/".
13537
			$conf["cmd::find"]["path"]=$path;
13538
			#$conf["fileOnly"],字串,"true"代表只要找檔案,"false"代表.
13539
			$conf["cmd::find"]["fileOnly"]="true";
13540
			#參考資料:
13541
			#http://php.net/manual/en/function.glob.php
13542
			$find=cmd::find($conf["cmd::find"]);
13543
			unset($conf["cmd::find"]);
13544
 
13545
			#如果尋找檔案失敗
13546
			if($find["status"]==="false"){
13547
 
13548
				#設置執行失敗
13549
				$result["status"]="false";
13550
 
13551
				#設置執行失敗訊息
13552
				$result["error"]=$find;
13553
 
13554
				#回傳結果
13555
				return $result;
13556
 
13557
				}#if end
13558
 
13559
			#如果有找到符合的檔案
13560
			if($find["found"]==="true"){
13561
 
13562
				#設置有找到檔案
13563
				$result["found"]="true";
13564
 
13565
				#針對每個找到的檔案
13566
				foreach($find["content"] as $filtedFile){
13567
 
13568
					#設置有找到的檔案
13569
					$result["content"][]=$filtedFile;
13570
 
13571
					}#foreach end
13572
 
13573
				}#if end
13574
 
13575
			}#foreach end		
13576
 
13577
		#設置執行正常
13578
		$result["status"]="true";
13579
 
13580
		#回傳結果
13581
		return $result;
13582
 
13583
		}#function findFile end
13584
 
13585
	/*
13586
	#函式說明:
13587
	#判斷檔案位於哪個分割區
13588
	#回傳結果:
13589
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13590
	#$result["error"],錯誤訊息.
13591
	#$result["function"],當前執行的函數名稱.
13592
	#$result["argu"],所使用的參數.
13593
	#$result["content"],找到的檔案所屬分割區資訊.
13594
	#必填參數:
13595
	#$conf["file"],字串,檔案的路徑與名稱.
13596
	$conf["file"]="";
13597
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
13598
	$conf["fileArgu"]=__FILE__;
13599
	#可省略參數:
13600
	#無.
13601
	#參考資料:
13602
	#無.
13603
	#備註:
13604
	#無.
13605
	*/
13606
	public static function addrInMountPoint(&$conf=array()){
13607
 
13608
		#初始化要回傳的結果
13609
		$result=array();
13610
 
13611
		#取得當前執行的函數名稱
13612
		$result["function"]=__FUNCTION__;
13613
 
13614
		#如果沒有參數
13615
		if(func_num_args()==0){
13616
 
13617
			#設置執行失敗
13618
			$result["status"]="false";
13619
 
13620
			#設置執行錯誤訊息
13621
			$result["error"]="函數".$result["function"]."需要參數";
13622
 
13623
			#回傳結果
13624
			return $result;
13625
 
13626
			}#if end		
13627
 
13628
		#取得參數
13629
		$result["argu"]=$conf;
13630
 
13631
		#如果 $conf 不為陣列
13632
		if(gettype($conf)!=="array"){
13633
 
13634
			#設置執行失敗
13635
			$result["status"]="false";
13636
 
13637
			#設置執行錯誤訊息
13638
			$result["error"][]="\$conf變數須為陣列形態";
13639
 
13640
			#如果傳入的參數為 null
13641
			if($conf===null){
13642
 
13643
				#設置執行錯誤訊息
13644
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
13645
 
13646
				}#if end
13647
 
13648
			#回傳結果
13649
			return $result;
13650
 
13651
			}#if end
13652
 
13653
		#函式說明:
13654
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
13655
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13656
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13657
		#$result["function"],當前執行的函式名稱.
13658
		#$result["argu"],設置給予的參數.
13659
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
13660
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
13661
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
13662
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
13663
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
13664
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
13665
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
13666
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
13667
		#必填寫的參數:
13668
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
13669
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
13670
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
13671
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
13672
		#可以省略的參數:
13673
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
13674
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
13675
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
13676
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
13677
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
13678
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
13679
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
13680
		#$conf["canNotBeEmpty"]=array();
13681
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
13682
		#$conf["canBeEmpty"]=array();
13683
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
13684
		#$conf["skipableVariableCanNotBeEmpty"]=array();
13685
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
13686
		#$conf["skipableVariableName"]=array();
13687
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
13688
		#$conf["skipableVariableType"]=array();
13689
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
13690
		#$conf["skipableVarDefaultValue"]=array("");
13691
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
13692
		#$conf["disallowAllSkipableVarIsEmpty"]="";
13693
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
13694
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
13695
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
13696
		#$conf["arrayCountEqualCheck"][]=array();
13697
		#參考資料來源:
13698
		#array_keys=>http://php.net/manual/en/function.array-keys.php
13699
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
13700
		unset($conf["variableCheck::checkArguments"]);
13701
 
13702
		#如果檢查參數失敗
13703
		if($checkArguments["status"]==="false"){
13704
 
13705
			#設置執行失敗
13706
			$result["status"]="false";
13707
 
13708
			#設置執行失敗訊息
13709
			$result["error"]=$checkArguments;
13710
 
13711
			#回傳結果
13712
			return $result;
13713
 
13714
			}#if end
13715
 
13716
		#如果檢查參數不通過
13717
		if($checkArguments["passed"]==="false"){
13718
 
13719
			#設置執行失敗
13720
			$result["status"]="false";
13721
 
13722
			#設置執行失敗訊息
13723
			$result["error"]=$checkArguments;
13724
 
13725
			#回傳結果
13726
			return $result;
13727
 
13728
			}#if end
13729
 
13730
		#函式說明:
13731
		#透過lsblk指令的輸出取得已經掛載的blk.
13732
		#回傳結果:
13733
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13734
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13735
		#$result["function"],當前執行的函式名稱.
13736
		#$result["content"],lsblk的輸出內容.
13737
		#必填參數:
13738
		#$conf["fileArgu"],字串,變數__FILE__的內容.
13739
		$conf["cmd::lsblk"]["fileArgu"]=$conf["fileArgu"];
13740
		#可省略參數:
13741
		#無.	
13742
		$lsblk=cmd::lsblk($conf["cmd::lsblk"]);
13743
		unset($conf["cmd::lsblk"]);
13744
 
13745
		#如果執行失敗
13746
		if($lsblk["status"]==="false"){
13747
 
13748
			#設置執行失敗
13749
			$result["status"]="false";
13750
 
13751
			#設置執行失敗訊息
13752
			$result["error"]=$lsblk;
13753
 
13754
			#回傳結果
13755
			return $result;
13756
 
13757
			}#if end
13758
 
13759
		#將 $conf["file"] 轉換成絕對路徑
13760
		#函式說明:
13761
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
13762
		#回傳結果:
13763
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
13764
		#$result["error"],錯誤訊息陣列.
13765
		#$result["function"],函數名稱. 
13766
		#$result["argu"],使用的參數.
13767
		#$result["content"],網址,若是在命令列執行,則為"null".
13768
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
13769
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「/」目錄開始的路徑.
13770
		#$result["fileSystemRelativePosition"],針對伺服器檔案系統的相對位置.
13771
		#必填參數:
13772
		#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
13773
		$conf["fileAccess::getInternetAddress"]["address"]=$conf["file"];
13774
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
13775
		$conf["fileAccess::getInternetAddress"]["fileArgu"]=$conf["fileArgu"];
13776
		#可省略參數:
13777
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
13778
		#$conf["userDir"]="true";
13779
		$getInternetAddress=fileAccess::getInternetAddress($conf["fileAccess::getInternetAddress"]);
13780
		unset($conf["fileAccess::getInternetAddress"]);
13781
 
13782
		#如果執行失敗
13783
		if($getInternetAddress["status"]==="false"){
13784
 
13785
			#設置執行失敗
13786
			$result["status"]="false";
13787
 
13788
			#設置執行失敗訊息
13789
			$result["error"]=$getInternetAddress;
13790
 
13791
			#回傳結果
13792
			return $result;
13793
 
13794
			}#if end	
13795
 
13796
		#使用絕對位置作為輸入字串
13797
		#函式說明:
13798
		#尋找字串是否存在對應的關鍵字,且符合的最常關鍵字為何?
13799
		#回傳結果:
13800
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13801
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13802
		#$result["function"],當前執行的函式名稱.
13803
		#$result["argu"],所使用的參數.
13804
		#$result["founded"],是否有找到關鍵字,"true"代表有找到,"false"代表沒有找到.
13805
		#$result["content"],最符合的字串完整內容.
13806
		#必填參數:
13807
		#$conf["input"],字串,要比對的字串陣列.
13808
		$conf["search::findLikelyStr"]["input"]=$getInternetAddress["fileSystemAbsoulutePosition"];
13809
		#$conf["keyWord"],字串陣列,要搜尋的關鍵字.
13810
		$conf["search::findLikelyStr"]["keyWord"]=$lsblk["content"]["MOUNTPOINT"];
13811
		$findLikelyStr=search::findLikelyStr($conf["search::findLikelyStr"]);
13812
		unset($conf["search::findLikelyStr"]);
13813
 
13814
		#如果執行失敗
13815
		if($findLikelyStr["status"]==="false"){
13816
 
13817
			#設置執行失敗
13818
			$result["status"]="false";
13819
 
13820
			#設置執行失敗訊息
13821
			$result["error"]=$findLikelyStr;
13822
 
13823
			#回傳結果
13824
			return $result;
13825
 
13826
			}#if end
13827
 
13828
		#如果找不到歸屬的分割區
13829
		if($findLikelyStr["found"]==="false"){
13830
 
13831
			#設置執行失敗
13832
			$result["status"]="false";
13833
 
13834
			#設置執行失敗訊息
13835
			$result["error"]=$findLikelyStr;
13836
 
13837
			#回傳結果
13838
			return $result;
13839
 
13840
			}#if end
13841
 
13842
		#設置歸屬的分割區資訊
13843
		$result["content"]=$findLikelyStr["content"];
13844
 
13845
		#設置執行正常
13846
		$result["status"]="true";
13847
 
13848
		#回傳結果
13849
		return $result;
13850
 
13851
		}#function addrInMountPoint end
13852
 
13853
	/*
13854
	#函式說明:
13855
	#取得檔案的副檔名
13856
	#回傳結果:
13857
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13858
	#$result["error"],錯誤訊息.
13859
	#$result["function"],當前執行的函數名稱.
13860
	#$result["argu"],所使用的參數.	
13861
	#$result["content"],副檔名.
13862
	#$result["name"],不含副檔的名稱.
13863
	#$result["fullName"],含副檔的名稱.
13864
	#$result["path"],檔案所處的路徑.
13865
	#必填參數:
13866
	#$conf["file"],字串,檔案的路徑與名稱.
13867
	$conf["file"]="";
13868
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
13869
	$conf["fileArgu"]=__FILE__;
13870
	#可省略參數:
13871
	#無.
13872
	#參考資料:
13873
	#無.
13874
	#備註:
13875
	#無.
13876
	*/
13877
	public static function getExtension(&$conf=array()){
13878
 
13879
		#初始化要回傳的結果
13880
		$result=array();
13881
 
13882
		#取得當前執行的函數名稱
13883
		$result["function"]=__FUNCTION__;
13884
 
13885
		#如果沒有參數
13886
		if(func_num_args()==0){
13887
 
13888
			#設置執行失敗
13889
			$result["status"]="false";
13890
 
13891
			#設置執行錯誤訊息
13892
			$result["error"]="函數".$result["function"]."需要參數";
13893
 
13894
			#回傳結果
13895
			return $result;
13896
 
13897
			}#if end		
13898
 
13899
		#取得參數
13900
		$result["argu"]=$conf;
13901
 
13902
		#如果 $conf 不為陣列
13903
		if(gettype($conf)!=="array"){
13904
 
13905
			#設置執行失敗
13906
			$result["status"]="false";
13907
 
13908
			#設置執行錯誤訊息
13909
			$result["error"][]="\$conf變數須為陣列形態";
13910
 
13911
			#如果傳入的參數為 null
13912
			if($conf===null){
13913
 
13914
				#設置執行錯誤訊息
13915
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
13916
 
13917
				}#if end
13918
 
13919
			#回傳結果
13920
			return $result;
13921
 
13922
			}#if end
13923
 
13924
		#函式說明:
13925
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
13926
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
13927
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
13928
		#$result["function"],當前執行的函式名稱.
13929
		#$result["argu"],設置給予的參數.
13930
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
13931
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
13932
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
13933
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
13934
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
13935
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
13936
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
13937
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
13938
		#必填寫的參數:
13939
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
13940
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
13941
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
13942
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
13943
		#可以省略的參數:
13944
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
13945
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
13946
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
13947
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
13948
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
13949
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
13950
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
13951
		#$conf["canNotBeEmpty"]=array();
13952
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
13953
		#$conf["canBeEmpty"]=array();
13954
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
13955
		#$conf["skipableVariableCanNotBeEmpty"]=array();
13956
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
13957
		#$conf["skipableVariableName"]=array();
13958
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
13959
		#$conf["skipableVariableType"]=array();
13960
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
13961
		#$conf["skipableVarDefaultValue"]=array("");
13962
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
13963
		#$conf["disallowAllSkipableVarIsEmpty"]="";
13964
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
13965
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
13966
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
13967
		#$conf["arrayCountEqualCheck"][]=array();
13968
		#參考資料來源:
13969
		#array_keys=>http://php.net/manual/en/function.array-keys.php
13970
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
13971
		unset($conf["variableCheck::checkArguments"]);
13972
 
13973
		#如果檢查參數失敗
13974
		if($checkArguments["status"]==="false"){
13975
 
13976
			#設置執行失敗
13977
			$result["status"]="false";
13978
 
13979
			#設置執行失敗訊息
13980
			$result["error"]=$checkArguments;
13981
 
13982
			#回傳結果
13983
			return $result;
13984
 
13985
			}#if end
13986
 
13987
		#如果檢查參數不通過
13988
		if($checkArguments["passed"]==="false"){
13989
 
13990
			#設置執行失敗
13991
			$result["status"]="false";
13992
 
13993
			#設置執行失敗訊息
13994
			$result["error"]=$checkArguments;
13995
 
13996
			#回傳結果
13997
			return $result;
13998
 
13999
			}#if end
14000
 
14001
		#初始化檔案的路徑
14002
		$result["path"]="./";
14003
 
14004
		#用 "/" 來分割字串
14005
		#函式說明:
14006
		#將固定格式的字串分開,並回傳分開的結果。
14007
		#回傳結果:
14008
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14009
		#$result["error"],錯誤訊息陣列
14010
		#$result["function"],當前執行的函數名稱.
14011
		#$result["oriStr"],要分割的原始字串內容
14012
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
14013
		#$result["dataCounts"],爲總共分成幾段
14014
		#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
14015
		#必填參數:
14016
		$conf["stringProcess::spiltString"]["stringIn"]=$conf["file"];#要處理的字串。
14017
		$conf["stringProcess::spiltString"]["spiltSymbol"]="/";#爲以哪個符號作爲分割
14018
		#可省略參數:
14019
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
14020
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
14021
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
14022
		unset($conf["stringProcess::spiltString"]);
14023
 
14024
		#如果檢查參數失敗
14025
		if($spiltString["status"]==="false"){
14026
 
14027
			#設置執行失敗
14028
			$result["status"]="false";
14029
 
14030
			#設置執行失敗訊息
14031
			$result["error"]=$spiltString;
14032
 
14033
			#回傳結果
14034
			return $result;
14035
 
14036
			}#if end
14037
 
14038
		#初始化含副檔名的檔案名稱
14039
		$result["fullName"]=$conf["file"];
14040
 
14041
		#如果有"/"存在
14042
		if($spiltString["found"]==="true"){
14043
 
14044
			#取得含副檔名的檔案名稱
14045
			$result["fullName"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
14046
 
14047
			#取得檔案的路徑
14048
			$result["path"]=substr($conf["file"],0,strlen($conf["file"])-strlen($result["fullName"]));
14049
 
14050
			}#if end
14051
 
14052
		#用 "." 來分割字串
14053
		#函式說明:
14054
		#將固定格式的字串分開,並回傳分開的結果。
14055
		#回傳結果:
14056
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14057
		#$result["error"],錯誤訊息陣列
14058
		#$result["function"],當前執行的函數名稱.
14059
		#$result["oriStr"],要分割的原始字串內容
14060
		#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
14061
		#$result["dataCounts"],爲總共分成幾段
14062
		#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
14063
		#必填參數:
14064
		$conf["stringProcess::spiltString"]["stringIn"]=$result["fullName"];#要處理的字串。
14065
		$conf["stringProcess::spiltString"]["spiltSymbol"]=".";#爲以哪個符號作爲分割
14066
		#可省略參數:
14067
		#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
14068
		$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
14069
		$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
14070
		unset($conf["stringProcess::spiltString"]);
14071
 
14072
		#如果檢查參數失敗
14073
		if($spiltString["status"]==="false"){
14074
 
14075
			#設置執行失敗
14076
			$result["status"]="false";
14077
 
14078
			#設置執行失敗訊息
14079
			$result["error"]=$spiltString;
14080
 
14081
			#回傳結果
14082
			return $result;
14083
 
14084
			}#if end
14085
 
14086
		#預設副檔名為 ""
14087
		$result["content"]="";
14088
 
14089
		#預設不含副檔名的檔案名稱
14090
		$result["name"]=$result["fullName"];
14091
 
14092
		#如果有"."存在
14093
		if($spiltString["found"]==="true"){
14094
 
14095
			#取得含副檔名
14096
			$result["content"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];
14097
 
14098
			#取得不含副檔名的檔案名稱
14099
			$result["name"]=substr($result["fullName"],0,strlen($result["fullName"])-strlen($result["content"])-1);	
14100
 
14101
			}#if end
14102
 
14103
		#設置執行正常
14104
		$result["status"]="true";
14105
 
14106
		#回傳結果
14107
		return $result;
14108
 
14109
		}#function getExtension end
14110
 
14111
	/*
14112
	#函式說明:
14113
	#從檔案尾部開始讀取
14114
	#回傳結果:
14115
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14116
	#$result["error"],錯誤訊息.
14117
	#$result["function"],當前執行的函數名稱.
14118
	#$result["argu"],所使用的參數.	
14119
	#$result["content"],讀取到的內容陣列.
14120
	#$result["totalLineCount"],檔案的總共行數.
14121
	#$result["lines"],取得輸出的行數.
14122
	#$result["lineNum"],取得當前行數.
14123
	#必填參數:
14124
	#$conf["file"],字串,檔案的路徑與名稱.
14125
	$conf["file"]="";
14126
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
14127
	$conf["fileArgu"]=__FILE__;
14128
	#可省略參數:
14129
	#$conf["web"],字串,"true"代表位網頁系統,"false"為檔案系統,預設為"false".
14130
	#$conf["web"]="false";
14131
	#$conf["line2start"],字串,從第幾列開始,預設為總行書減去linesPerTime+1.
14132
	#$conf["line2start"]="";
14133
	#$conf["linesPerTime"],字串,一次最多讀取幾列,預設爲10列.
14134
	#$conf["linesPerTime"]="10";	
14135
	#參考資料:
14136
	#無.
14137
	#備註:
14138
	#無.
14139
	*/
14140
	public static function tail(&$conf){
14141
 
14142
		#初始化要回傳的結果
14143
		$result=array();
14144
 
14145
		#取得當前執行的函數名稱
14146
		$result["function"]=__FUNCTION__;
14147
 
14148
		#如果沒有參數
14149
		if(func_num_args()==0){
14150
 
14151
			#設置執行失敗
14152
			$result["status"]="false";
14153
 
14154
			#設置執行錯誤訊息
14155
			$result["error"]="函數".$result["function"]."需要參數";
14156
 
14157
			#回傳結果
14158
			return $result;
14159
 
14160
			}#if end		
14161
 
14162
		#取得參數
14163
		$result["argu"]=$conf;
14164
 
14165
		#如果 $conf 不為陣列
14166
		if(gettype($conf)!=="array"){
14167
 
14168
			#設置執行失敗
14169
			$result["status"]="false";
14170
 
14171
			#設置執行錯誤訊息
14172
			$result["error"][]="\$conf變數須為陣列形態";
14173
 
14174
			#如果傳入的參數為 null
14175
			if($conf===null){
14176
 
14177
				#設置執行錯誤訊息
14178
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
14179
 
14180
				}#if end
14181
 
14182
			#回傳結果
14183
			return $result;
14184
 
14185
			}#if end
14186
 
14187
		#函式說明:
14188
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
14189
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14190
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
14191
		#$result["function"],當前執行的函式名稱.
14192
		#$result["argu"],設置給予的參數.
14193
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
14194
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
14195
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
14196
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
14197
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
14198
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
14199
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
14200
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
14201
		#必填寫的參數:
14202
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
14203
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
14204
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
14205
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
14206
		#可以省略的參數:
14207
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
14208
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu");
14209
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
14210
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
14211
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
14212
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
14213
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
14214
		$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("file","fileArgu");
14215
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
14216
		#$conf["canBeEmpty"]=array();
14217
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
14218
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web","line2start","linesPerTime");
14219
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
14220
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web","line2start","linesPerTime");
14221
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
14222
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
14223
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
14224
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false",null,"10");
14225
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
14226
		#$conf["disallowAllSkipableVarIsEmpty"]="";
14227
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
14228
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
14229
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
14230
		#$conf["arrayCountEqualCheck"][]=array();
14231
		#參考資料來源:
14232
		#array_keys=>http://php.net/manual/en/function.array-keys.php
14233
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
14234
		unset($conf["variableCheck::checkArguments"]);
14235
 
14236
		#如果檢查參數失敗
14237
		if($checkArguments["status"]==="false"){
14238
 
14239
			#設置執行失敗
14240
			$result["status"]="false";
14241
 
14242
			#設置執行失敗訊息
14243
			$result["error"]=$checkArguments;
14244
 
14245
			#回傳結果
14246
			return $result;
14247
 
14248
			}#if end
14249
 
14250
		#如果檢查參數不通過
14251
		if($checkArguments["passed"]==="false"){
14252
 
14253
			#設置執行失敗
14254
			$result["status"]="false";
14255
 
14256
			#設置執行失敗訊息
14257
			$result["error"]=$checkArguments;
14258
 
14259
			#回傳結果
14260
			return $result;
14261
 
14262
			}#if end
14263
 
14264
		#檢查檔案是否存在
14265
		#函式說明:
14266
		#檢查多個檔案與資料夾是否存在.
14267
		#回傳的結果:
14268
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
14269
		#$result["error"],錯誤訊息陣列.
14270
		#$resutl["function"],當前執行的涵式名稱.
14271
		#$result["argu"],使用的參數.
14272
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
14273
		#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
14274
		#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
14275
		#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址
14276
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
14277
		#必填參數:
14278
		#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
14279
		$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["file"]);
14280
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
14281
		$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
14282
		#可省略參數
14283
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
14284
		#$conf["disableWebSearch"]="false";
14285
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
14286
		#$conf["userDir"]="true";
14287
		#$conf["web"],字串,"true"代表位網頁系統,"false"為檔案系統,預設為"false".
14288
		$conf["fileAccess::checkMultiFileExist"]["web"]=$conf["web"];
14289
		#參考資料來源:
14290
		#http://php.net/manual/en/function.file-exists.php
14291
		#http://php.net/manual/en/control-structures.foreach.php
14292
		#備註:
14293
		#函數file_exists檢查的路徑為檔案系統的路徑
14294
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
14295
		unset($conf["fileAccess::checkMultiFileExist"]);
14296
 
14297
		#如果執行失敗
14298
		if($checkMultiFileExist["status"]==="false"){
14299
 
14300
			#設置執行失敗
14301
			$result["status"]="false";
14302
 
14303
			#設置執行失敗訊息
14304
			$result["error"]=$checkMultiFileExist;
14305
 
14306
			#回傳結果
14307
			return $result;
14308
 
14309
			}#if end
14310
 
14311
		#如果檔案無法存取
14312
		if($checkMultiFileExist["allExist"]==="false"){
14313
 
14314
			#設置執行失敗
14315
			$result["status"]="false";
14316
 
14317
			#設置執行失敗訊息
14318
			$result["error"]=$checkMultiFileExist;
14319
 
14320
			#回傳結果
14321
			return $result;
14322
 
14323
			}#if end
14324
 
14325
		#取得檔案的行數
14326
		#函式說明:
14327
		#呼叫shell執行系統命令,並取得回傳的內容.
14328
		#回傳的結果:
14329
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14330
		#$result["error"],錯誤訊息陣列.
14331
		#$result["function"],當前執行的函數名稱.
14332
		#$result["argu"],使用的參數.
14333
		#$result["cmd"],執行的指令內容.
14334
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
14335
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
14336
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
14337
		#$result["running"],是否還在執行.
14338
		#$result["pid"],pid.
14339
		#$result["statusCode"],執行結束後的代碼.
14340
		#必填的參數
14341
		#$conf["command"],字串,要執行的指令與.
14342
		$conf["external::callShell"]["command"]="cat";
14343
		#$conf["fileArgu"],字串,變數__FILE__的內容.
14344
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
14345
		#可省略參數:
14346
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
14347
		$conf["external::callShell"]["argu"]=array($conf["file"],"|","wc","-l");
14348
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
14349
		#$conf["arguIsAddr"]=array();	
14350
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
14351
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
14352
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
14353
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
14354
		#$conf["enablePrintDescription"]="true";
14355
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
14356
		#$conf["printDescription"]="";
14357
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
14358
		$conf["external::callShell"]["escapeshellarg"]="true";
14359
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
14360
		#$conf["username"]="";
14361
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
14362
		#$conf["password"]="";
14363
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
14364
		#$conf["useScript"]="";
14365
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
14366
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
14367
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
14368
		#$conf["inBackGround"]="";
14369
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
14370
		#$conf["getErr"]="false";
14371
		#備註:
14372
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
14373
		#參考資料:
14374
		#exec=>http://php.net/manual/en/function.exec.php
14375
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
14376
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
14377
		$callShell=external::callShell($conf["external::callShell"]);
14378
		unset($conf["external::callShell"]);
14379
 
14380
		#如果檢查參數失敗
14381
		if($callShell["status"]==="false"){
14382
 
14383
			#設置執行失敗
14384
			$result["status"]="false";
14385
 
14386
			#設置執行失敗訊息
14387
			$result["error"]=$callShell;
14388
 
14389
			#回傳結果
14390
			return $result;
14391
 
14392
			}#if end
14393
 
14394
		#取得檔案總行數
14395
		$result["totalLineCount"]=$callShell["output"][0];
14396
 
14397
		#如果未設置 $conf["line2start"]
14398
		if(!isset($conf["line2start"])){
14399
 
14400
			#$conf["line2start"]為總行數減去一次要看的行數減1
14401
			$conf["line2start"]=$result["totalLineCount"]-$conf["linesPerTime"]+1;
14402
 
14403
			}#if end	
14404
 
14405
		#如果開始行數小於1		
14406
		if($conf["line2start"]<1){
14407
 
14408
			#$conf["line2start"]為總行數減去一次要看的行數減1
14409
			$conf["line2start"]=$result["totalLineCount"]-$conf["linesPerTime"]+1;
14410
 
14411
			}#if end
14412
 
14413
		#如果開始行數小於1		
14414
		if($conf["line2start"]<1){
14415
 
14416
			#$conf["line2start"]為1
14417
			$conf["line2start"]=1;
14418
 
14419
			}#if end
14420
 
14421
		#取得指定範圍的行數
14422
		#取得檔案的行數
14423
		#函式說明:
14424
		#呼叫shell執行系統命令,並取得回傳的內容.
14425
		#回傳的結果:
14426
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14427
		#$result["error"],錯誤訊息陣列.
14428
		#$result["function"],當前執行的函數名稱.
14429
		#$result["argu"],使用的參數.
14430
		#$result["cmd"],執行的指令內容.
14431
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
14432
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
14433
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
14434
		#$result["running"],是否還在執行.
14435
		#$result["pid"],pid.
14436
		#$result["statusCode"],執行結束後的代碼.
14437
		#必填的參數
14438
		#$conf["command"],字串,要執行的指令與.
14439
		$conf["external::callShell"]["command"]="sed";
14440
		#$conf["fileArgu"],字串,變數__FILE__的內容.
14441
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];		
14442
		#可省略參數:
14443
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
14444
		$conf["external::callShell"]["argu"]=array("-n",$conf["line2start"].",".($conf["line2start"]+$conf["linesPerTime"]-1)."p",$conf["file"]);
14445
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
14446
		#$conf["arguIsAddr"]=array();	
14447
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
14448
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
14449
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
14450
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
14451
		#$conf["enablePrintDescription"]="true";
14452
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
14453
		#$conf["printDescription"]="";
14454
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".
14455
		$conf["external::callShell"]["escapeshellarg"]="true";
14456
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
14457
		#$conf["username"]="";
14458
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
14459
		#$conf["password"]="";
14460
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
14461
		#$conf["useScript"]="";
14462
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
14463
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
14464
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
14465
		#$conf["inBackGround"]="";
14466
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
14467
		#$conf["getErr"]="false";
14468
		#備註:
14469
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
14470
		#參考資料:
14471
		#exec=>http://php.net/manual/en/function.exec.php
14472
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
14473
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
14474
		$callShell=external::callShell($conf["external::callShell"]);
14475
		unset($conf["external::callShell"]);
14476
 
14477
		#如果檢查參數失敗
14478
		if($callShell["status"]==="false"){
14479
 
14480
			#設置執行失敗
14481
			$result["status"]="false";
14482
 
14483
			#設置執行失敗訊息
14484
			$result["error"]=$callShell;
14485
 
14486
			#回傳結果
14487
			return $result;
14488
 
14489
			}#if end
14490
 
14491
		#取得輸出的行數
14492
		$result["lines"]=count($callShell["output"]);
14493
 
14494
		#取得目前的輸出內容
14495
		$result["content"]=$callShell["output"];
14496
 
14497
		#取得當前行數
14498
		$result["lineNum"]=$conf["line2start"]+$result["lines"]-1;
14499
 
14500
		#如果當前行號小於總行數 
14501
		if($result["lineNum"]<$result["totalLineCount"]){
14502
 
14503
			#設置還有剩餘的內容
14504
			$result["left"]="true";
14505
 
14506
			}#if end
14507
 
14508
		#反之 
14509
		else{
14510
 
14511
			#設置無剩餘的內容
14512
			$result["left"]="false";
14513
 
14514
			}#else end
14515
 
14516
		#設置執行正常
14517
		$result["status"]="true";
14518
 
14519
		#回傳結果
14520
		return $result;
14521
 
14522
		}#function tail end
14523
 
14524
	/*
14525
	#函式說明:
14526
	#解析PHP檔案裡面的變數.
14527
	#回傳結果:
14528
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14529
	#$result["error"],錯誤訊息.
14530
	#$result["function"],當前執行的函數名稱.
14531
	#$result["argu"],所使用的參數.	
14532
	#$result["content"],找到的變數內容陣列,若有多個變數則會用array來表示.
14533
	#必填參數:
14534
	#$conf["file"],字串,檔案的路徑與名稱.
14535
	$conf["file"]="";
14536
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
14537
	$conf["fileArgu"]=__FILE__;
14538
	#$conf["varName"],字串陣列,要搜尋的變數名稱,例如要搜尋變數$email則輸入"email".
14539
	$conf["varName"]=array();
14540
	#可省略參數:
14541
	#$conf["web"],是要取得網路上的檔案則為"true";反之則為"false",預設為"false".
14542
	#$conf["web"]="true";
14543
	#參考資料:
14544
	#https://www.php.net/manual/en/function.parse-str.php
14545
	#備註:
14546
	#無.
14547
	*/
14548
	public static function parseVaraiableInPHPfile(&$conf){
14549
 
14550
		#初始化要回傳的結果
14551
		$result=array();
14552
 
14553
		#取得當前執行的函數名稱
14554
		$result["function"]=__FUNCTION__;
14555
 
14556
		#如果沒有參數
14557
		if(func_num_args()==0){
14558
 
14559
			#設置執行失敗
14560
			$result["status"]="false";
14561
 
14562
			#設置執行錯誤訊息
14563
			$result["error"]="函數".$result["function"]."需要參數";
14564
 
14565
			#回傳結果
14566
			return $result;
14567
 
14568
			}#if end		
14569
 
14570
		#取得參數
14571
		$result["argu"]=$conf;
14572
 
14573
		#如果 $conf 不為陣列
14574
		if(gettype($conf)!=="array"){
14575
 
14576
			#設置執行失敗
14577
			$result["status"]="false";
14578
 
14579
			#設置執行錯誤訊息
14580
			$result["error"][]="\$conf變數須為陣列形態";
14581
 
14582
			#如果傳入的參數為 null
14583
			if($conf===null){
14584
 
14585
				#設置執行錯誤訊息
14586
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
14587
 
14588
				}#if end
14589
 
14590
			#回傳結果
14591
			return $result;
14592
 
14593
			}#if end
14594
 
14595
		#函式說明:
14596
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
14597
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14598
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
14599
		#$result["function"],當前執行的函式名稱.
14600
		#$result["argu"],設置給予的參數.
14601
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
14602
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
14603
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
14604
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
14605
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
14606
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
14607
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
14608
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
14609
		#必填寫的參數:
14610
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
14611
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
14612
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
14613
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
14614
		#可以省略的參數:
14615
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
14616
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("file","fileArgu","varName");
14617
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
14618
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","array");
14619
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
14620
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
14621
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
14622
		$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("file","fileArgu","varName");
14623
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
14624
		#$conf["canBeEmpty"]=array();
14625
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
14626
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web");
14627
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
14628
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
14629
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
14630
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
14631
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
14632
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
14633
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
14634
		#$conf["disallowAllSkipableVarIsEmpty"]="";
14635
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
14636
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
14637
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
14638
		#$conf["arrayCountEqualCheck"][]=array();
14639
		#參考資料來源:
14640
		#array_keys=>http://php.net/manual/en/function.array-keys.php
14641
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
14642
		unset($conf["variableCheck::checkArguments"]);
14643
 
14644
		#如果檢查參數失敗
14645
		if($checkArguments["status"]==="false"){
14646
 
14647
			#設置執行失敗
14648
			$result["status"]="false";
14649
 
14650
			#設置執行失敗訊息
14651
			$result["error"]=$checkArguments;
14652
 
14653
			#回傳結果
14654
			return $result;
14655
 
14656
			}#if end
14657
 
14658
		#如果檢查參數不通過
14659
		if($checkArguments["passed"]==="false"){
14660
 
14661
			#設置執行失敗
14662
			$result["status"]="false";
14663
 
14664
			#設置執行失敗訊息
14665
			$result["error"]=$checkArguments;
14666
 
14667
			#回傳結果
14668
			return $result;
14669
 
14670
			}#if end
14671
 
14672
		#初始化儲存解析出來的變數內容
14673
		$result["content"]=array();
14674
 
14675
		#讀取檔案
14676
		#函式說明:
14677
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
14678
		#回傳的變數說明:
14679
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
14680
		#$result["error"],錯誤訊息提示.
14681
		#$result["warning"],警告訊息.
14682
		#$result["function"],當前執行的函數名稱.
14683
		#$result["fileContent"],爲檔案的內容陣列.
14684
		#$result["lineCount"],爲檔案內容總共的行數.
14685
		#$result["fullContent"],為檔案的完整內容.
14686
		#$result["base64data"],為檔案的base64內容.
14687
		#$result["mimeType"],為檔案的mime type.
14688
		#必填參數:
14689
		#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
14690
		$conf["ileAccess::getFileContent"]["filePositionAndName"]=$conf["file"];
14691
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
14692
		$conf["ileAccess::getFileContent"]["fileArgu"]=$conf["fileArgu"];
14693
		#可省略參數:
14694
		#$conf["web"],是要取得網路上的檔案則為"true";反之則為"false".
14695
		$conf["ileAccess::getFileContent"]["web"]=$conf["web"];
14696
		#參考資料:
14697
		#file(),取得檔案內容的行數.
14698
		#file=>http:#php.net/manual/en/function.file.php
14699
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
14700
		#filesize=>http://php.net/manual/en/function.filesize.php
14701
		$getFileContent=fileAccess::getFileContent($conf["ileAccess::getFileContent"]);
14702
		unset($conf["ileAccess::getFileContent"]);
14703
 
14704
		#如果讀取檔案失敗
14705
		if($getFileContent["status"]==="false"){
14706
 
14707
			#設置執行失敗
14708
			$result["status"]="false";
14709
 
14710
			#設置執行失敗訊息
14711
			$result["error"]=$getFileContent;
14712
 
14713
			#回傳結果
14714
			return $result;
14715
 
14716
			}#if end
14717
 
14718
		#針對每列檔案內容
14719
		foreach($getFileContent["fileContent"] as $line){
14720
 
14721
			#針對每個要搜尋的變數
14722
			foreach($conf["varName"] as $keyWord){
14723
 
14724
				#如果關鍵字小於被搜尋的字串長度
14725
				if( strlen($line) < strlen($keyWord)+1 ){
14726
 
14727
					#跳過
14728
					continue;
14729
 
14730
					}#if end
14731
 
14732
				#函式說明:
14733
				#取得符合特定字首與字尾的字串
14734
				#回傳結果:
14735
				#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
14736
				#$result["function"],當前執行的函數名稱.
14737
				#$result["error"],錯誤訊息陣列.
14738
				#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
14739
				#$result["returnString"],爲符合字首條件的字串內容。
14740
				#$result["argu"],使用的參數.
14741
				#必填參數:
14742
				#$conf["checkString"],字串,要檢查的字串.
14743
				$conf["search::getMeetConditionsString"]["checkString"]=$line;
14744
				#可省略參數:
14745
				#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
14746
				$conf["search::getMeetConditionsString"]["frontWord"]="$".$keyWord;
14747
				#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
14748
				$conf["search::getMeetConditionsString"]["tailWord"]=";";
14749
				#參考資料:
14750
				#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
14751
				$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
14752
				unset($conf["search::getMeetConditionsString"]);
14753
 
14754
				#如果失敗
14755
				if($getMeetConditionsString["status"]==="false"){
14756
 
14757
					#設置執行失敗
14758
					$result["status"]="false";
14759
 
14760
					#設置執行失敗訊息
14761
					$result["error"]=$getMeetConditionsString;
14762
 
14763
					#回傳結果
14764
					return $result;
14765
 
14766
					}#if end	
14767
 
14768
				#如果有找到關鍵字
14769
				if($getMeetConditionsString["founded"]==="true"){
14770
 
14771
					#剔除變數名稱
14772
					#函式說明:
14773
					#將字串特定關鍵字與其前面的內容剔除
14774
					#回傳結果:
14775
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14776
					#$result["error"],錯誤訊息陣列.
14777
					#$result["warning"],警告訊息鎮列.
14778
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
14779
					#$result["function"],當前執行的函數名稱.
14780
					#$result["oriStr"],要處理的原始字串內容.
14781
					#$result["content"],處理好的的字串內容.	
14782
					#必填參數:
14783
					#$conf["stringIn"],字串,要處理的字串.
14784
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$line;
14785
					#$conf["keyWord"],字串,特定字串.
14786
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="$".$keyWord;
14787
					#可省略參數:
14788
					#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,直到沒有關鍵字為止.
14789
					#$conf["recursive"]="true";
14790
					#參考資料:
14791
					#無.
14792
					#備註:
14793
					#無.
14794
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
14795
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
14796
 
14797
					#如果執行失敗
14798
					if($delStrBeforeKeyWord["status"]==="false"){
14799
 
14800
						#設置執行失敗
14801
						$result["status"]="false";
14802
 
14803
						#設置執行失敗訊息
14804
						$result["error"]=$delStrBeforeKeyWord;
14805
 
14806
						#回傳結果
14807
						return $result;
14808
 
14809
						}#if end
14810
 
14811
					#如果沒有找到應該存在的php變數
14812
					if($delStrBeforeKeyWord["founded"]==="false"){
14813
 
14814
						#設置執行失敗
14815
						$result["status"]="false";
14816
 
14817
						#設置執行失敗訊息
14818
						$result["error"]=$delStrBeforeKeyWord;
14819
 
14820
						#回傳結果
14821
						return $result;
14822
 
14823
						}#if end
14824
 
14825
					#剔除 "=" 前面的內容
14826
					#函式說明:
14827
					#將字串特定關鍵字與其前面的內容剔除
14828
					#回傳結果:
14829
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14830
					#$result["error"],錯誤訊息陣列.
14831
					#$result["warning"],警告訊息鎮列.
14832
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
14833
					#$result["function"],當前執行的函數名稱.
14834
					#$result["oriStr"],要處理的原始字串內容.
14835
					#$result["content"],處理好的的字串內容.	
14836
					#必填參數:
14837
					#$conf["stringIn"],字串,要處理的字串.
14838
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$delStrBeforeKeyWord["content"];
14839
					#$conf["keyWord"],字串,特定字串.
14840
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="=";
14841
					#可省略參數:
14842
					#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,直到沒有關鍵字為止.
14843
					#$conf["recursive"]="true";
14844
					#參考資料:
14845
					#無.
14846
					#備註:
14847
					#無.
14848
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
14849
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
14850
 
14851
					#如果執行失敗
14852
					if($delStrBeforeKeyWord["status"]==="false"){
14853
 
14854
						#設置執行失敗
14855
						$result["status"]="false";
14856
 
14857
						#設置執行失敗訊息
14858
						$result["error"]=$delStrBeforeKeyWord;
14859
 
14860
						#回傳結果
14861
						return $result;
14862
 
14863
						}#if end
14864
 
14865
					#如果沒有找“=”關鍵字
14866
					if($delStrBeforeKeyWord["founded"]==="false"){
14867
 
14868
						#跳過
14869
						continue;
14870
 
14871
						}#if end
14872
 
14873
					#剔除 value 前面的空白
14874
					#函式說明:
14875
					#將字串特定關鍵字與其前面的內容剔除
14876
					#回傳結果:
14877
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14878
					#$result["error"],錯誤訊息陣列.
14879
					#$result["warning"],警告訊息鎮列.
14880
					#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
14881
					#$result["function"],當前執行的函數名稱.
14882
					#$result["oriStr"],要處理的原始字串內容.
14883
					#$result["content"],處理好的的字串內容.	
14884
					#必填參數:
14885
					#$conf["stringIn"],字串,要處理的字串.
14886
					$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$delStrBeforeKeyWord["content"];
14887
					#$conf["keyWord"],字串,特定字串.
14888
					$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=" ";
14889
					#可省略參數:
14890
					#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,直到沒有關鍵字為止.
14891
					$conf["stringProcess::delStrBeforeKeyWord"]["recursive"]="true";
14892
					#參考資料:
14893
					#無.
14894
					#備註:
14895
					#無.
14896
					$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
14897
					unset($conf["stringProcess::delStrBeforeKeyWord"]);
14898
 
14899
					#如果執行失敗
14900
					if($delStrBeforeKeyWord["status"]==="false"){
14901
 
14902
						#設置執行失敗
14903
						$result["status"]="false";
14904
 
14905
						#設置執行失敗訊息
14906
						$result["error"]=$delStrBeforeKeyWord;
14907
 
14908
						#回傳結果
14909
						return $result;
14910
 
14911
						}#if end
14912
 
14913
					#取得找到的變數
14914
					eval("\$result[\"content\"][\"".$keyWord."\"][]=".$delStrBeforeKeyWord["content"]);
14915
 
14916
					}#if end
14917
 
14918
				}#foreach end
14919
 
14920
			}#foreach end
14921
 
14922
		#設置執行正常
14923
		$result["status"]="true";
14924
 
14925
		#回傳結果
14926
		return $result;
14927
 
14928
		}#function parseVaraiableInPHPfile end
14929
 
14930
	/*
14931
	#函式說明:
14932
	#開啟特定目錄,取得底下的檔案路徑清單.
14933
	#回傳結果:
14934
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
14935
	#$result["error"],錯誤訊息.
14936
	#$result["function"],當前執行的函數名稱.
14937
	#$result["argu"],所使用的參數.
14938
	#$result["content"],讀取到的內容陣列.
14939
	#$result["content"][$i],第$i+1個結果.
14940
	#$result["content"][$i]["name"],第$i+1個名稱.
14941
	#$result["content"][$i]["dir"],第$i+1個檔案是否為資料夾.
14942
	#$result["content"][$i]["info"],第$i+1個檔案的額外資訊.
14943
	#$result["content"][$i]["size"],第$i+1個檔案的大小(bytes).
14944
	#必填參數:
14945
	#$conf["path"],字串,要取得檔案資訊的所屬路徑.
14946
	$conf["path"]="";
14947
	#可省略參數:
14948
	#無.
14949
	#參考資料
14950
	#無.
14951
	#備註:
14952
	#無.
14953
	*/
14954
	public static function listInfo(&$conf){
14955
 
14956
		#初始化要回傳的結果
14957
		$result=array();
14958
 
14959
		#取得當前執行的函數名稱
14960
		$result["function"]=__FUNCTION__;
14961
 
14962
		#如果沒有參數
14963
		if(func_num_args()==0){
14964
 
14965
			#設置執行失敗
14966
			$result["status"]="false";
14967
 
14968
			#設置執行錯誤訊息
14969
			$result["error"]="函數".$result["function"]."需要參數";
14970
 
14971
			#回傳結果
14972
			return $result;
14973
 
14974
			}#if end		
14975
 
14976
		#取得參數
14977
		$result["argu"]=$conf;
14978
 
14979
		#如果 $conf 不為陣列
14980
		if(gettype($conf)!=="array"){
14981
 
14982
			#設置執行失敗
14983
			$result["status"]="false";
14984
 
14985
			#設置執行錯誤訊息
14986
			$result["error"][]="\$conf變數須為陣列形態";
14987
 
14988
			#如果傳入的參數為 null
14989
			if($conf===null){
14990
 
14991
				#設置執行錯誤訊息
14992
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
14993
 
14994
				}#if end
14995
 
14996
			#回傳結果
14997
			return $result;
14998
 
14999
			}#if end
15000
 
15001
		#函式說明:
15002
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
15003
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15004
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
15005
		#$result["function"],當前執行的函式名稱.
15006
		#$result["argu"],設置給予的參數.
15007
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
15008
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
15009
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
15010
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
15011
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
15012
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
15013
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
15014
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
15015
		#必填寫的參數:
15016
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
15017
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
15018
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
15019
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
15020
		#可以省略的參數:
15021
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
15022
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path");
15023
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
15024
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
15025
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
15026
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
15027
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
15028
		$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("file");
15029
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
15030
		#$conf["canBeEmpty"]=array();
15031
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
15032
		#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web");
15033
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
15034
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
15035
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
15036
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
15037
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
15038
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
15039
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
15040
		#$conf["disallowAllSkipableVarIsEmpty"]="";
15041
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
15042
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
15043
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
15044
		#$conf["arrayCountEqualCheck"][]=array();
15045
		#參考資料來源:
15046
		#array_keys=>http://php.net/manual/en/function.array-keys.php
15047
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
15048
		unset($conf["variableCheck::checkArguments"]);
15049
 
15050
		#如果檢查參數失敗
15051
		if($checkArguments["status"]==="false"){
15052
 
15053
			#設置執行失敗
15054
			$result["status"]="false";
15055
 
15056
			#設置執行失敗訊息
15057
			$result["error"]=$checkArguments;
15058
 
15059
			#回傳結果
15060
			return $result;
15061
 
15062
			}#if end
15063
 
15064
		#如果檢查參數不通過
15065
		if($checkArguments["passed"]==="false"){
15066
 
15067
			#設置執行失敗
15068
			$result["status"]="false";
15069
 
15070
			#設置執行失敗訊息
15071
			$result["error"]=$checkArguments;
15072
 
15073
			#回傳結果
15074
			return $result;
15075
 
15076
			}#if end
15077
 
15078
		#初始化儲存解析出來的變數內容
15079
		$result["content"]=array();
15080
 
15081
		#取得特定位置的資訊
15082
		$pathInfo=@dir($conf["path"]);
15083
 
15084
		#如果取得路徑資訊失敗
15085
		if($pathInfo===false){
15086
 
15087
			#設置執行失敗
15088
			$result["status"]="false";
15089
 
15090
			#設置執行失敗訊息
15091
			$result["error"][]="無法存取路徑(".$conf["path"].")";
15092
 
15093
			#回傳結果
15094
			return $result;
15095
 
15096
			}#if end
15097
 
15098
		#讀取底下一個檔案,暫存到 $tmpItem 裡面,且當結果不為 false 時進入迴圈.
15099
		while(false !== $tmpItem = $pathInfo->read()){
15100
 
15101
			#宣告儲存資訊的變數
15102
			$item=array();
15103
 
15104
			#儲存名稱
15105
			$item["name"]=$tmpItem;
15106
 
15107
			#預設不為資料夾
15108
			$item["dir"]="false";
15109
 
15110
			#若為資料夾
15111
			if(is_dir($conf["path"]."/".$tmpItem)){
15112
 
15113
				#設置為"true"
15114
				$item["dir"]="true";
15115
 
15116
				}#if end
15117
 
15118
			#取得檔案識別器
15119
			$finfo = finfo_open(FILEINFO_MIME);
15120
 
15121
			#取得 info
15122
			$item["info"]=@finfo_file($finfo,$conf["path"]."/".$tmpItem);
15123
 
15124
			#取得檔案大小
15125
			$item["size"]=filesize($conf["path"]."/".$tmpItem);
15126
 
15127
			#close connection
15128
			finfo_close($finfo);
15129
 
15130
			#記錄該檔案資訊
15131
			$result["content"][]=$item;
15132
 
15133
			}#while end
15134
 
15135
		#設置執行正常
15136
		$result["status"]="true";
15137
 
15138
		#回傳結果
15139
		return $result;
15140
 
15141
		}#function listInfo end
15142
 
15143
	/*
15144
	#函式說明:
15145
	#取得目錄底下的詳細資訊.
15146
	#回傳結果:
15147
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15148
	#$result["error"],錯誤訊息.
15149
	#$result["function"],當前執行的函數名稱.
15150
	#$result["size"],該清單的大小,單位為bytes.
15151
	#$result["dataCount"],該清單的長度.
15152
	#$result["path"],字串,檢視的路徑,必為"/"結尾.
15153
	#$result["content"],指定目錄底下的所有檔案資訊.
15154
	#$result["content"][$i]["nType&permission"],第$i個節點類型、權限.
15155
	#$result["content"][$i]["nType"],第$i個節點類型,"-"代表檔案,"d"代表資料夾.
15156
	#$result["content"][$i]["permission"],第$i個節點權限.
15157
	#$result["content"][$i]["ownByUser"],第$i個節點擁有者賬號.
15158
	#$result["content"][$i]["ownByGroup"],第$i個節點擁有者群組.
15159
	#$result["content"][$i]["bytes"],第$i個節點大小.
15160
	#$result["content"][$i]["date"],第$i個節點最後變更日期.
15161
	#$result["content"][$i]["time"],第$i個節點最後異動時間.
15162
	#$result["content"][$i]["timeDetail"],第$i個節點最後異動詳細時間.
15163
	#$result["content"][$i]["timezone"],第$i個節點的時區.
15164
	#$result["content"][$i]["name"],第$i個節點的名稱.
15165
	#$result["content"][$i]["secondName"],第$i個節點為檔案時,若有附檔名,會記錄在這.
15166
	#$result["content"][$i]["mimeType"],第$i個節點為檔案且可以讀取時,會有 mime type 可取得.
15167
	#必填參數:
15168
	#$conf["path"],字串,要檢視的路徑,若非"/"結尾,會自動補上.
15169
	$conf["path"]="";
15170
	#可省略參數:
15171
	#無.
15172
	#參考資料:
15173
	#https://www.businessweekly.com.tw/careers/Blog/14307
15174
	#備註:
15175
	#無.
15176
	*/
15177
	public static function ls(&$conf){
15178
 
15179
		#初始化要回傳的結果
15180
		$result=array();
15181
 
15182
		#取得當前執行的函數名稱
15183
		$result["function"]=__FUNCTION__;
15184
 
15185
		#如果沒有參數
15186
		if(func_num_args()==0){
15187
 
15188
			#設置執行失敗
15189
			$result["status"]="false";
15190
 
15191
			#設置執行錯誤訊息
15192
			$result["error"]="函數".$result["function"]."需要參數";
15193
 
15194
			#回傳結果
15195
			return $result;
15196
 
15197
			}#if end
15198
 
15199
		#取得參數
15200
		$result["argu"]=$conf;
15201
 
15202
		#如果 $conf 不為陣列
15203
		if(gettype($conf)!=="array"){
15204
 
15205
			#設置執行失敗
15206
			$result["status"]="false";
15207
 
15208
			#設置執行錯誤訊息
15209
			$result["error"][]="\$conf變數須為陣列形態";
15210
 
15211
			#如果傳入的參數為 null
15212
			if(is_null($conf)){
15213
 
15214
				#設置執行錯誤訊息
15215
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
15216
 
15217
				}#if end
15218
 
15219
			#回傳結果
15220
			return $result;
15221
 
15222
			}#if end
15223
 
15224
		#函式說明:
15225
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
15226
		#回傳結果:
15227
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15228
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
15229
		#$result["simpleError"],簡單表示的錯誤訊息.
15230
		#$result["function"],當前執行的函式名稱.
15231
		#$result["argu"],設置給予的參數.
15232
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
15233
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
15234
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
15235
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
15236
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
15237
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
15238
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
15239
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
15240
		#必填參數:
15241
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
15242
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
15243
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
15244
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
15245
		#可省略參數:
15246
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
15247
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("path");
15248
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
15249
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
15250
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
15251
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
15252
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
15253
		#$conf["canNotBeEmpty"]=array();
15254
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
15255
		#$conf["canBeEmpty"]=array();
15256
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
15257
		#$conf["skipableVariableCanNotBeEmpty"]=array();
15258
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
15259
		#$conf["skipableVariableName"]=array();
15260
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
15261
		#$conf["skipableVariableType"]=array();
15262
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
15263
		#$conf["skipableVarDefaultValue"]=array("");
15264
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
15265
		#$conf["disallowAllSkipableVarIsEmpty"]="";
15266
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
15267
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
15268
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
15269
		#$conf["arrayCountEqualCheck"][]=array();
15270
		#參考資料:
15271
		#array_keys=>http://php.net/manual/en/function.array-keys.php
15272
		#備註:
15273
		#無.
15274
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
15275
		unset($conf["variableCheck::checkArguments"]);
15276
 
15277
		#如果執行失敗
15278
		if($checkArguments["status"]==="false"){
15279
 
15280
			#設置執行錯誤
15281
			$result["status"]="false";
15282
 
15283
			#設置錯誤訊息
15284
			$result["error"]=$checkArguments;
15285
 
15286
			#回傳結果
15287
			return $result;
15288
 
15289
			}#if end
15290
 
15291
		#如果參數檢查不通過
15292
		if($checkArguments["passed"]==="false"){
15293
 
15294
			#設置執行錯誤
15295
			$result["status"]="false";
15296
 
15297
			#設置錯誤訊息
15298
			$result["error"]=$checkArguments;
15299
 
15300
			#回傳結果
15301
			return $result;
15302
 
15303
			}#if end
15304
 
15305
		#確認 $conf["path"] 是否為 "/" 結尾
15306
		#函式說明:
15307
		#取得符合特定字首與字尾的字串
15308
		#回傳結果:
15309
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
15310
		#$result["function"],當前執行的函數名稱.
15311
		#$result["error"],錯誤訊息陣列.
15312
		#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
15313
		#$result["content"],符合條件的字串,去掉字首字尾後的結果.
15314
		#$result["returnString"],爲符合字首字、尾條件的字串內容。
15315
		#$result["argu"],使用的參數.
15316
		#必填參數:
15317
		#$conf["checkString"],字串,要檢查的字串.
15318
		$conf["search::getMeetConditionsString"]["checkString"]=$conf["path"];
15319
		#可省略參數:
15320
		#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
15321
		#$conf["frontWord"]="";
15322
		#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
15323
		$conf["search::getMeetConditionsString"]["tailWord"]="/";
15324
		#參考資料:
15325
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
15326
		#備註:
15327
		#無.
15328
		$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
15329
		unset($conf["search::getMeetConditionsString"]);
15330
 
15331
		#如果執行失敗
15332
		if($getMeetConditionsString["status"]==="false"){
15333
 
15334
			#設置執行錯誤
15335
			$result["status"]="false";
15336
 
15337
			#設置錯誤訊息
15338
			$result["error"]=$getMeetConditionsString;
15339
 
15340
			#回傳結果
15341
			return $result;
15342
 
15343
			}#if end
15344
 
15345
		#如果沒有 "/" 結尾
15346
		if($getMeetConditionsString["founded"]==="false"){
15347
 
15348
			#於結尾加上 "/"
15349
			$conf["path"]=$conf["path"]."/";
15350
 
15351
			}#if end
15352
 
15353
		#記錄真正的路徑
15354
		$result["path"]=$conf["path"];
15355
 
15356
		#函式說明:
15357
		#呼叫shell執行系統命令,並取得回傳的內容.
15358
		#回傳結果:
15359
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15360
		#$result["error"],錯誤訊息陣列.
15361
		#$result["function"],當前執行的函數名稱.
15362
		#$result["argu"],使用的參數.
15363
		#$result["cmd"],執行的指令內容.
15364
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
15365
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
15366
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
15367
		#$result["running"],是否還在執行.
15368
		#$result["pid"],pid.
15369
		#$result["statusCode"],執行結束後的代碼.
15370
		#$result["escape"],陣列,儲存重新排序過且已經escape過的指令(key為"cmd")與參數(key為"argu").
15371
		#必填參數:
15372
		#$conf["command"],字串,要執行的指令.
15373
		$conf["external::callShell"]["command"]="ls";
15374
		#$conf["fileArgu"],字串,變數__FILE__的內容.
15375
		$conf["external::callShell"]["fileArgu"]=__FILE__;
15376
		#可省略參數:
15377
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
15378
		$conf["external::callShell"]["argu"]=array("-al","--full-time","-t","-B",$conf["path"]);
15379
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
15380
		#$conf["arguIsAddr"]=array();
15381
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
15382
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
15383
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
15384
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
15385
		#$conf["enablePrintDescription"]="true";
15386
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
15387
		#$conf["printDescription"]="";
15388
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
15389
		$conf["external::callShell"]["escapeshellarg"]="true";
15390
		#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
15391
		#$conf["thereIsShellVar"]=array();
15392
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
15393
		#$conf["username"]="";
15394
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
15395
		#$conf["password"]="";
15396
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
15397
		#$conf["useScript"]="";
15398
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
15399
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
15400
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
15401
		#$conf["inBackGround"]="";
15402
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
15403
		#$conf["getErr"]="false";
15404
		#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
15405
		#$conf["doNotRun"]="false";
15406
		#參考資料:
15407
		#exec=>http://php.net/manual/en/function.exec.php
15408
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
15409
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
15410
		#備註:
15411
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
15412
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
15413
		$callShell=external::callShell($conf["external::callShell"]);
15414
		unset($conf["external::callShell"]);
15415
 
15416
		#debug
15417
		#var_dump(__FILE__,__LINE__,$callShell);
15418
 
15419
		#如果執行失敗
15420
		if($callShell["status"]==="false"){
15421
 
15422
			#設置執行錯誤
15423
			$result["status"]="false";
15424
 
15425
			#設置錯誤訊息
15426
			$result["error"]=$callShell;
15427
 
15428
			#回傳結果
15429
			return $result;
15430
 
15431
			}#if end
15432
 
15433
		#初始化儲存檔案資訊為空
15434
		$result["content"]=array();
15435
 
15436
		#針對每行輸出
15437
		foreach($callShell["output"] as $index=>$line){
15438
 
15439
			#如果是第一筆
15440
			if($index===0){
15441
 
15442
				#取得資料筆數
15443
				$result["dataCount"]=explode(" ",$line)[0];
15444
 
15445
				#換下一輪
15446
				continue;
15447
 
15448
				}#if end
15449
 
15450
			#函式說明:
15451
			#將固定格式的字串分開,並回傳分開的結果.
15452
			#回傳結果:
15453
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15454
			#$result["error"],錯誤訊息陣列
15455
			#$result["function"],當前執行的函數名稱.
15456
			#$result["argu"],使用的參數.
15457
			#$result["oriStr"],要分割的原始字串內容
15458
			#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
15459
			#$result["dataCounts"],爲總共分成幾段
15460
			#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
15461
			#必填參數:
15462
			#$conf["stringIn"],字串,要處理的字串.
15463
			$conf["stringProcess::spiltString"]["stringIn"]=$line;
15464
			#$conf["spiltSymbol"],字串,爲以哪個符號作爲分割.
15465
			$conf["stringProcess::spiltString"]["spiltSymbol"]=" ";
15466
			#可省略參數:
15467
			#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
15468
			$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
15469
			#參考資料:
15470
			#無.
15471
			#備註:
15472
			#無.
15473
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
15474
			unset($conf["stringProcess::spiltString"]);
15475
 
15476
			#如果執行失敗
15477
			if($spiltString["status"]==="false"){
15478
 
15479
				#設置執行錯誤
15480
				$result["status"]="false";
15481
 
15482
				#設置錯誤訊息
15483
				$result["error"]=$spiltString;
15484
 
15485
				#回傳結果
15486
				return $result;
15487
 
15488
				}#if end
15489
 
15490
			#如果沒有分割用的" "
15491
			if($spiltString["found"]==="false"){
15492
 
15493
				#設置執行錯誤
15494
				$result["status"]="false";
15495
 
15496
				#設置錯誤訊息
15497
				$result["error"]=$spiltString;
15498
 
15499
				#回傳結果
15500
				return $result;
15501
 
15502
				}#if end
15503
 
15504
			#如果分割好的數量小於8
15505
			if($spiltString["dataCounts"]<8){
15506
 
15507
				#設置執行錯誤
15508
				$result["status"]="false";
15509
 
15510
				#設置錯誤訊息
15511
				$result["error"]=$spiltString;
15512
 
15513
				#回傳結果
15514
				return $result;
15515
 
15516
				}#if end
15517
 
15518
			#初始化要儲存的檔案資訊陣列
15519
			$fileInfo=array();
15520
 
15521
			#取得 節點類型、權限
15522
			$fileInfo["nType&permission"]=$spiltString["dataArray"][0];
15523
 
15524
			#剔除結尾的 "."
15525
			$fileInfo["nType&permission"]=substr($fileInfo["nType&permission"],0,strlen($fileInfo["nType&permission"])-1);
15526
 
15527
			#取得節點類型
15528
			$fileInfo["nType"]=$fileInfo["nType&permission"][0];
15529
 
15530
			#取得節點權限
15531
			$fileInfo["permission"]=substr($fileInfo["nType&permission"],1);
15532
 
15533
			#取得擁有者賬號
15534
			$fileInfo["ownByUser"]=$spiltString["dataArray"][2];
15535
 
15536
			#取得群組擁有者群組
15537
			$fileInfo["ownByGroup"]=$spiltString["dataArray"][3];
15538
 
15539
			#取得size
15540
			$fileInfo["bytes"]=$spiltString["dataArray"][4];
15541
 
15542
			#取得最後異動日期 
15543
			$fileInfo["date"]=$spiltString["dataArray"][5];
15544
 
15545
			#取得最後異動時間
15546
			$fileInfo["time"]=explode(".",$spiltString["dataArray"][6])[0];
15547
 
15548
			#取得最後異動的詳細時間
15549
			$fileInfo["timeDetail"]=$spiltString["dataArray"][6];
15550
 
15551
			#取得timezone資訊
15552
			$fileInfo["timezone"]=$spiltString["dataArray"][7];
15553
 
15554
			#函式說明:
15555
			#將固定格式的字串分開,並回傳分開的結果.
15556
			#回傳結果:
15557
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15558
			#$result["error"],錯誤訊息陣列
15559
			#$result["function"],當前執行的函數名稱.
15560
			#$result["argu"],使用的參數.
15561
			#$result["oriStr"],要分割的原始字串內容
15562
			#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
15563
			#$result["dataCounts"],爲總共分成幾段
15564
			#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
15565
			#必填參數:
15566
			#$conf["stringIn"],字串,要處理的字串.
15567
			$conf["stringProcess::spiltString"]["stringIn"]=$line;
15568
			#$conf["spiltSymbol"],字串,爲以哪個符號作爲分割.
15569
			$conf["stringProcess::spiltString"]["spiltSymbol"]=$fileInfo["date"]." ".$fileInfo["timeDetail"]." ".$fileInfo["timezone"];
15570
			#可省略參數:
15571
			#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
15572
			$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
15573
			#參考資料:
15574
			#無.
15575
			#備註:
15576
			#無.
15577
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
15578
			unset($conf["stringProcess::spiltString"]);
15579
 
15580
			#如果執行失敗
15581
			if($spiltString["status"]==="false"){
15582
 
15583
				#設置執行錯誤
15584
				$result["status"]="false";
15585
 
15586
				#設置錯誤訊息
15587
				$result["error"]=$spiltString;
15588
 
15589
				#回傳結果
15590
				return $result;
15591
 
15592
				}#if end
15593
 
15594
			#如果沒有分割用的" "
15595
			if($spiltString["found"]==="false"){
15596
 
15597
				#設置執行錯誤
15598
				$result["status"]="false";
15599
 
15600
				#設置錯誤訊息
15601
				$result["error"]=$spiltString;
15602
 
15603
				#回傳結果
15604
				return $result;
15605
 
15606
				}#if end
15607
 
15608
			#如果分割好的數量小於8
15609
			if($spiltString["dataCounts"]<2){
15610
 
15611
				#設置執行錯誤
15612
				$result["status"]="false";
15613
 
15614
				#設置錯誤訊息
15615
				$result["error"]=$spiltString;
15616
 
15617
				#回傳結果
15618
				return $result;
15619
 
15620
				}#if end
15621
 
15622
			#取得節點名稱,剔除開頭的空白.
15623
			$fileInfo["name"]=substr($spiltString["dataArray"][1],1);
15624
 
15625
			#排除 "." 跟 ".."
15626
			if($fileInfo["name"]==="." || $fileInfo["name"]===".."){
15627
 
15628
				#跳過
15629
				continue;
15630
 
15631
				}#if end
15632
 
15633
			#如果是檔案
15634
			if($fileInfo["nType"]==="-"){
15635
 
15636
				#取得mime type
15637
				$fileInfo["mimeType"]=@mime_content_type($conf["path"].$fileInfo["name"]);
15638
 
15639
				#如果讀取失敗
15640
				if($fileInfo["mimeType"]===false){
15641
 
15642
					#通常為沒有權限
15643
 
15644
					#跳過該檔案
15645
					continue;
15646
 
15647
					}#if end
15648
 
15649
				#確認檔案名稱中間含是否有 "."
15650
				#函式說明:
15651
				#取得關鍵字在字串的哪個位置(字首,字尾,中間)
15652
				#回傳結果:
15653
				#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
15654
				#$result["error"],錯誤訊息陣列.
15655
				#$result["function"],當前執行的函數名稱.
15656
				#$result["found"],是否有關鍵字存在,若為"true",代表存在;反之為"false".
15657
				#$result["argu"],傳入的參數.
15658
				#$result["head"],關鍵字是否在字串的開頭,"true"代表是,"false"代表不是.
15659
				#$result["tail"],關鍵字是否在字串的尾端,"true"代表是,"false"代表不是.
15660
				#$result["center"],關鍵字是否在字串的中間,"true"代表是,"false"代表不是.
15661
				#$result["indexS"],關鍵字在被搜尋字串的哪個位置開始.
15662
				#$result["indexE"],關鍵字在被搜尋字串的哪個位置結束.
15663
				#必填參數:
15664
				#$conf["inputStr"],字串,被搜尋的字串.
15665
				$conf["search::findKeyWordPosition"]["inputStr"]=$fileInfo["name"];
15666
				#$conf["keyWord"],字串,關鍵字.
15667
				$conf["search::findKeyWordPosition"]["keyWord"]=".";
15668
				#可省略參數:
15669
				#無.
15670
				#參考資料:
15671
				#http://php.net/manual/en/function.strpos.php
15672
				#備註:
15673
				#無.
15674
				$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
15675
				unset($conf["search::findKeyWordPosition"]);
15676
 
15677
				#如果執行失敗
15678
				if($findKeyWordPosition["status"]==="false"){
15679
 
15680
					#設置執行錯誤
15681
					$result["status"]="false";
15682
 
15683
					#設置錯誤訊息
15684
					$result["error"]=$spiltString;
15685
 
15686
					#回傳結果
15687
					return $result;
15688
 
15689
					}#if end
15690
 
15691
				#如果含有 "." 存在
15692
				if($findKeyWordPosition["found"]==="true"){
15693
 
15694
					#如果 "." 是在中間,不是在尾巴.
15695
					if($findKeyWordPosition["center"]==="true" && $findKeyWordPosition["tail"]==="false"){
15696
 
15697
						#取得 "." 之後的內容
15698
						#函式說明:
15699
						#將字串特定關鍵字與其前面的內容剔除
15700
						#回傳結果:
15701
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15702
						#$result["error"],錯誤訊息陣列.
15703
						#$result["warning"],警告訊息鎮列.
15704
						#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
15705
						#$result["function"],當前執行的函數名稱.
15706
						#$result["argu"],使用的參數.
15707
						#$result["oriStr"],要處理的原始字串內容.
15708
						#$result["content"],處理好的的字串內容.
15709
						#$result["deleted"],被移除的內容.
15710
						#必填參數:
15711
						#$conf["stringIn"],字串,要處理的字串.
15712
						$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$fileInfo["name"];
15713
						#$conf["keyWord"],字串,特定字串.
15714
						$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=".";
15715
						#可省略參數:
15716
						#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
15717
						$conf["stringProcess::delStrBeforeKeyWord"]["recursive"]="true";
15718
						#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
15719
						#$conf["lastResult"]=$delStrBeforeKeyWord;
15720
						#參考資料:
15721
						#無.
15722
						#備註:
15723
						#無.
15724
						$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
15725
						unset($conf["stringProcess::delStrBeforeKeyWord"]);
15726
 
15727
						#如果執行失敗
15728
						if($delStrBeforeKeyWord["status"]==="false"){
15729
 
15730
							#設置執行錯誤
15731
							$result["status"]="false";
15732
 
15733
							#設置錯誤訊息
15734
							$result["error"]=$spiltString;
15735
 
15736
							#回傳結果
15737
							return $result;
15738
 
15739
							}#if end
15740
 
15741
						#如果該存在的 "." 不存在
15742
						if($delStrBeforeKeyWord["founded"]==="false"){
15743
 
15744
							#設置執行錯誤
15745
							$result["status"]="false";
15746
 
15747
							#設置錯誤訊息
15748
							$result["error"]=$spiltString;
15749
 
15750
							#回傳結果
15751
							return $result;
15752
 
15753
							}#if end
15754
 
15755
						#取得附檔名
15756
						$fileInfo["secondName"]=$delStrBeforeKeyWord["content"];
15757
 
15758
						}#if end
15759
 
15760
					}#if end
15761
 
15762
				}#if end
15763
 
15764
			#儲存檔案資訊
15765
			$result["content"][]=$fileInfo;
15766
 
15767
			}#foreach end
15768
 
15769
		#設置清單的長度
15770
		$result["dataCount"]=count($result["content"]);
15771
 
15772
		#設置執行正常
15773
		$result["status"]="true";
15774
 
15775
		#回傳結果
15776
		return $result;
15777
 
15778
		}#function ls end
15779
 
15780
	/*
15781
	#函式說明:
15782
	#將 ~ 轉換為家目錄路徑
15783
	#回傳結果:
15784
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15785
	#$result["error"],錯誤訊息.
15786
	#$result["function"],當前執行的函數名稱.
15787
	#$result["content"],轉換好的內容.
15788
	#必填參數:
15789
	#$conf["fileArgu"],字串,變數__FILE__的內容.
15790
	$conf["fileArgu"]=__FILE__;
15791
	#可省略參數:
15792
	#無.
15793
	#參考資料:
15794
	#https://www.businessweekly.com.tw/careers/Blog/14307
15795
	#備註:
15796
	#無.
15797
	*/
15798
	public static function tildeToPath(&$conf){
15799
 
15800
		#初始化要回傳的結果
15801
		$result=array();
15802
 
15803
		#取得當前執行的函數名稱
15804
		$result["function"]=__FUNCTION__;
15805
 
15806
		#如果沒有參數
15807
		if(func_num_args()==0){
15808
 
15809
			#設置執行失敗
15810
			$result["status"]="false";
15811
 
15812
			#設置執行錯誤訊息
15813
			$result["error"]="函數".$result["function"]."需要參數";
15814
 
15815
			#回傳結果
15816
			return $result;
15817
 
15818
			}#if end		
15819
 
15820
		#取得參數
15821
		$result["argu"]=$conf;
15822
 
15823
		#如果 $conf 不為陣列
15824
		if(gettype($conf)!=="array"){
15825
 
15826
			#設置執行失敗
15827
			$result["status"]="false";
15828
 
15829
			#設置執行錯誤訊息
15830
			$result["error"][]="\$conf變數須為陣列形態";
15831
 
15832
			#如果傳入的參數為 null
15833
			if($conf===null){
15834
 
15835
				#設置執行錯誤訊息
15836
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
15837
 
15838
				}#if end
15839
 
15840
			#回傳結果
15841
			return $result;
15842
 
15843
			}#if end
15844
 
15845
		#函式說明:
15846
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
15847
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15848
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
15849
		#$result["function"],當前執行的函式名稱.
15850
		#$result["argu"],設置給予的參數.
15851
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
15852
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
15853
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
15854
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
15855
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
15856
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
15857
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
15858
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
15859
		#必填寫的參數:
15860
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
15861
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
15862
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
15863
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
15864
		#可以省略的參數:
15865
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
15866
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
15867
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
15868
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
15869
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
15870
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
15871
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
15872
		#$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("file");
15873
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
15874
		#$conf["canBeEmpty"]=array();
15875
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
15876
		#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("web");
15877
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
15878
		#$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
15879
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
15880
		#$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
15881
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
15882
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
15883
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
15884
		#$conf["disallowAllSkipableVarIsEmpty"]="";
15885
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
15886
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
15887
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
15888
		#$conf["arrayCountEqualCheck"][]=array();
15889
		#參考資料來源:
15890
		#array_keys=>http://php.net/manual/en/function.array-keys.php
15891
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
15892
		unset($conf["variableCheck::checkArguments"]);
15893
 
15894
		#如果檢查參數失敗
15895
		if($checkArguments["status"]==="false"){
15896
 
15897
			#設置執行失敗
15898
			$result["status"]="false";
15899
 
15900
			#設置執行失敗訊息
15901
			$result["error"]=$checkArguments;
15902
 
15903
			#回傳結果
15904
			return $result;
15905
 
15906
			}#if end
15907
 
15908
		#如果檢查參數不通過
15909
		if($checkArguments["passed"]==="false"){
15910
 
15911
			#設置執行失敗
15912
			$result["status"]="false";
15913
 
15914
			#設置執行失敗訊息
15915
			$result["error"]=$checkArguments;
15916
 
15917
			#回傳結果
15918
			return $result;
15919
 
15920
			}#if end
15921
 
15922
		#函式說明:
15923
		#呼叫shell執行系統命令,並取得回傳的內容.
15924
		#回傳結果:
15925
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
15926
		#$result["error"],錯誤訊息陣列.
15927
		#$result["function"],當前執行的函數名稱.
15928
		#$result["argu"],使用的參數.
15929
		#$result["cmd"],執行的指令內容.
15930
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
15931
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
15932
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
15933
		#$result["running"],是否還在執行.
15934
		#$result["pid"],pid.
15935
		#$result["statusCode"],執行結束後的代碼.
15936
		#必填參數:
15937
		#$conf["command"],字串,要執行的指令與.
15938
		$conf["external::callShell"]["command"]="echo";
15939
		#$conf["fileArgu"],字串,變數__FILE__的內容.
15940
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
15941
		#可省略參數:
15942
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
15943
		$conf["external::callShell"]["argu"]=array("~");
15944
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
15945
		#$conf["arguIsAddr"]=array();
15946
		#$conf["plainArgu"],字串陣列,哪幾個參數不要加上"",若為"true"則代表不用包;反之"false"則代表要包.
15947
		#$conf["plainArgu"]=array();
15948
		#$conf["useApostrophe"],字串陣列,如果有需要包住,則用「'」,而非「"」處理.前者為"true";後者為"false".
15949
		#$conf["useApostrophe"]=array();
15950
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
15951
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
15952
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
15953
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
15954
		#$conf["enablePrintDescription"]="true";
15955
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
15956
		#$conf["printDescription"]="";
15957
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
15958
		$conf["external::callShell"]["escapeshellarg"]="true";
15959
		#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
15960
		#$conf["thereIsShellVar"]=array();
15961
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
15962
		#$conf["username"]="";
15963
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
15964
		#$conf["password"]="";
15965
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
15966
		#$conf["useScript"]="";
15967
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
15968
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
15969
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
15970
		#$conf["inBackGround"]="";
15971
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
15972
		#$conf["getErr"]="false";
15973
		#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
15974
		#$conf["doNotRun"]="false";
15975
		#參考資料:
15976
		#exec=>http://php.net/manual/en/function.exec.php
15977
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
15978
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
15979
		#備註:
15980
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
15981
		$callShell=external::callShell($conf["external::callShell"]);
15982
		unset($conf["external::callShell"]);
15983
 
15984
		#如果執行失敗
15985
		if($callShell["status"]==="false"){
15986
 
15987
			#設置執行失敗
15988
			$result["status"]="false";
15989
 
15990
			#設置執行失敗訊息
15991
			$result["error"]=$callShell;
15992
 
15993
			#回傳結果
15994
			return $result;
15995
 
15996
			}#if end
15997
 
15998
		#如果沒有預期的輸出
15999
		if(!isset($callShell["output"][0])){
16000
 
16001
			#設置執行失敗
16002
			$result["status"]="false";
16003
 
16004
			#設置執行失敗訊息
16005
			$result["error"][]="沒有得到預期的輸出";
16006
 
16007
			#設置執行失敗訊息
16008
			$result["error"][]=$callShell;
16009
 
16010
			#回傳結果
16011
			return $result;
16012
 
16013
			}#if end
16014
 
16015
		#取得輸出
16016
		$result["content"]=$callShell["output"][0];
16017
 
16018
		#設置執行正常
16019
		$result["status"]="true";
16020
 
16021
		#回傳結果
16022
		return $result;
16023
 
16024
		}#function tildeToPath end
16025
 
16026
	/*
16027
	#函式說明:
16028
	#建立軟連結.
16029
	#回傳結果:
16030
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16031
	#$result["error"],錯誤訊息.
16032
	#$result["function"],當前執行的函數名稱.
16033
	#$result["content"],軟連結的資訊.
16034
	#$result["cmd"],執行的指令陣列.
16035
	#必填參數:
16036
	#$conf["fileArgu"],字串,變數__FILE__的內容.
16037
	$conf["fileArgu"]=__FILE__;
16038
	#$conf["linkTo"],字串,軟連結要指向哪邊.
16039
	$conf["linkTo"]="";
16040
	#可省略參數:
16041
	#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
16042
	#$conf["path"]="";
16043
	#$conf["name"],字串,軟連結的名稱,預設為 "linkTo" 參數的檔案或目錄名稱.
16044
	#$conf["name"]="";
16045
	#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
16046
	#$conf["overWrite"]="true";
16047
	#參考資料:
16048
	#無.
16049
	#備註:
16050
	#無.
16051
	*/
16052
	public static function createLink(&$conf){
16053
 
16054
		#初始化要回傳的結果
16055
		$result=array();
16056
 
16057
		#取得當前執行的函數名稱
16058
		$result["function"]=__FUNCTION__;
16059
 
16060
		#如果沒有參數
16061
		if(func_num_args()==0){
16062
 
16063
			#設置執行失敗
16064
			$result["status"]="false";
16065
 
16066
			#設置執行錯誤訊息
16067
			$result["error"]="函數".$result["function"]."需要參數";
16068
 
16069
			#回傳結果
16070
			return $result;
16071
 
16072
			}#if end		
16073
 
16074
		#取得參數
16075
		$result["argu"]=$conf;
16076
 
16077
		#如果 $conf 不為陣列
16078
		if(gettype($conf)!=="array"){
16079
 
16080
			#設置執行失敗
16081
			$result["status"]="false";
16082
 
16083
			#設置執行錯誤訊息
16084
			$result["error"][]="\$conf變數須為陣列形態";
16085
 
16086
			#如果傳入的參數為 null
16087
			if($conf===null){
16088
 
16089
				#設置執行錯誤訊息
16090
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
16091
 
16092
				}#if end
16093
 
16094
			#回傳結果
16095
			return $result;
16096
 
16097
			}#if end
16098
 
16099
		#函式說明:
16100
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
16101
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16102
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
16103
		#$result["function"],當前執行的函式名稱.
16104
		#$result["argu"],設置給予的參數.
16105
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
16106
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
16107
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
16108
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
16109
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
16110
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
16111
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
16112
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
16113
		#必填寫的參數:
16114
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
16115
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
16116
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
16117
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
16118
		#可以省略的參數:
16119
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
16120
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","linkTo");
16121
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
16122
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
16123
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
16124
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
16125
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
16126
		#$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("file");
16127
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
16128
		#$conf["canBeEmpty"]=array();
16129
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
16130
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("path","name","overWrite");
16131
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
16132
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("path","name","overWrite");
16133
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
16134
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
16135
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
16136
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,"false");
16137
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
16138
		#$conf["disallowAllSkipableVarIsEmpty"]="";
16139
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
16140
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
16141
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
16142
		#$conf["arrayCountEqualCheck"][]=array();
16143
		#參考資料來源:
16144
		#array_keys=>http://php.net/manual/en/function.array-keys.php
16145
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
16146
		unset($conf["variableCheck::checkArguments"]);
16147
 
16148
		#如果檢查參數失敗
16149
		if($checkArguments["status"]==="false"){
16150
 
16151
			#設置執行失敗
16152
			$result["status"]="false";
16153
 
16154
			#設置執行失敗訊息
16155
			$result["error"]=$checkArguments;
16156
 
16157
			#回傳結果
16158
			return $result;
16159
 
16160
			}#if end
16161
 
16162
		#如果檢查參數不通過
16163
		if($checkArguments["passed"]==="false"){
16164
 
16165
			#設置執行失敗
16166
			$result["status"]="false";
16167
 
16168
			#設置執行失敗訊息
16169
			$result["error"]=$checkArguments;
16170
 
16171
			#回傳結果
16172
			return $result;
16173
 
16174
			}#if end
16175
 
16176
		#如果是相對位置
16177
		if(!(strpos($conf["linkTo"],"/")===0)){
16178
 
16179
			#將 $conf["linkTo"] 轉換為針對產生位置的相對位置.
16180
			#函式說明:
16181
			#將多個路徑字串變成相對於當前路徑的相對路徑字串
16182
			#回傳結果:
16183
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
16184
			#$result["error"],錯誤訊息陣列.
16185
			#$result["function"],函數名稱. 
16186
			#$result["argu"],使用的參數.
16187
			#$result["content"],字串陣列,多個轉換好的相對路徑字串.
16188
			#必填參數:
16189
			#$conf["path"],陣列字串,要轉換成相對路徑的字串.;
16190
			$conf["fileAccess::getRelativePath"]["path"]=array($conf["linkTo"]);
16191
			#$conf["fileArgu"],字串,當前路徑.
16192
			$conf["fileAccess::getRelativePath"]["fileArgu"]=$conf["fileArgu"];
16193
			#可省略參數:
16194
			#$conf["baseFrom"],字串,指定要依據哪個位置為起點的起始位置,預設不指定,代表使用當前路徑.
16195
			$conf["fileAccess::getRelativePath"]["baseFrom"]=$conf["path"];
16196
			#參考資料:
16197
			#無.
16198
			#備註:
16199
			#無.
16200
			$getRelativePath=fileAccess::getRelativePath($conf["fileAccess::getRelativePath"]);
16201
			unset($conf["fileAccess::getRelativePath"]);
16202
 
16203
			#如果執行失敗
16204
			if($getRelativePath["status"]==="false"){
16205
 
16206
				#設置執行失敗
16207
				$result["status"]="false";
16208
 
16209
				#設置執行失敗訊息
16210
				$result["error"]=$getRelativePath;
16211
 
16212
				#回傳結果
16213
				return $result;
16214
 
16215
				}#if end
16216
 
16217
			/*
16218
			#break point
16219
			var_dump($conf);
16220
			var_dump($getRelativePath);
16221
			exit;
16222
			*/
16223
 
16224
			#取得執行的指令
16225
			$result["cmd"][]=$getRelativePath["cmd"];
16226
 
16227
			#取得正確的相對位置
16228
			$conf["linkTo"]=$getRelativePath["content"][0];
16229
 
16230
			}#if end
16231
 
16232
		#初始化給 ln 指令的參數
16233
		$paramsForLn=array("-s",$conf["linkTo"]);
16234
 
16235
		#函式說明:
16236
		#將字串特定關鍵字與其前面的內容剔除
16237
		#回傳結果:
16238
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16239
		#$result["error"],錯誤訊息陣列.
16240
		#$result["warning"],警告訊息鎮列.
16241
		#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
16242
		#$result["function"],當前執行的函數名稱.
16243
		#$result["oriStr"],要處理的原始字串內容.
16244
		#$result["content"],處理好的的字串內容.	
16245
		#必填參數:
16246
		#$conf["stringIn"],字串,要處理的字串.
16247
		$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$conf["linkTo"];
16248
		#$conf["keyWord"],字串,特定字串.
16249
		$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="/";
16250
		#可省略參數:
16251
		#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
16252
		$conf["stringProcess::delStrBeforeKeyWord"]["recursive"]="true";
16253
		#參考資料:
16254
		#無.
16255
		#備註:
16256
		#無.
16257
		$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
16258
		unset($conf["stringProcess::delStrBeforeKeyWord"]);
16259
 
16260
		#var_dump(__LINE__." ".print_r($delStrBeforeKeyWord,true));
16261
 
16262
		#如果執行失敗
16263
		if($delStrBeforeKeyWord["status"]==="false"){
16264
 
16265
			#設置執行失敗
16266
			$result["status"]="false";
16267
 
16268
			#設置執行失敗訊息
16269
			$result["error"]=$delStrBeforeKeyWord;
16270
 
16271
			#回傳結果
16272
			return $result;
16273
 
16274
			}#if end
16275
 
16276
		#如果沒有找到 "/"
16277
		if($delStrBeforeKeyWord["founded"]==="false"){
16278
 
16279
			#設置 預設的 軟連名稱
16280
			$softLink=$conf["linkTo"];
16281
 
16282
			}#if end
16283
 
16284
		#反之有 "/"
16285
		else{
16286
 
16287
			#設置 預設的 軟連結名稱
16288
			$softLink=$delStrBeforeKeyWord["content"];
16289
 
16290
			}#else end
16291
 
16292
		/*
16293
		#break point
16294
		var_dump(__LINE__." ".$softLink);
16295
		exit;
16296
		*/
16297
 
16298
		#預設欲建立的軟連結名稱
16299
		$createdSoftLink=$softLink;
16300
 
16301
		#如果有設置 path
16302
		if(isset($conf["path"])){
16303
 
16304
			#確認 path 存在
16305
			#函式說明:
16306
			#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
16307
			#回傳結果:
16308
			#$result["status"],"true"爲建立成功,"false"爲建立失敗.
16309
			#$result["error"],錯誤訊息陣列
16310
			#$result["warning"],警告訊息陣列
16311
			#必填參數:
16312
			#$conf["dirPositionAndName"]="";#新建的位置與名稱
16313
			$conf["fileAccess::createNewFolder"]["dirPositionAndName"]=$conf["path"];
16314
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
16315
			$conf["fileAccess::createNewFolder"]["fileArgu"]=$conf["fileArgu"];
16316
			#可省略參數:
16317
			#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
16318
			#$conf["dirPermission"]="";
16319
			#參考資料:
16320
			#mkdir=>http://php.net/manual/en/function.mkdir.php
16321
			#chmod=>http://php.net/manual/en/function.chmod.php
16322
			#參考資料:
16323
			#無.
16324
			#備註:
16325
			#同 function createFolderAfterCheck.
16326
			$createNewFolder=fileAccess::createNewFolder($conf["fileAccess::createNewFolder"]);
16327
			unset($conf["fileAccess::createNewFolder"]);
16328
 
16329
			#如果執行失敗
16330
			if($createNewFolder["status"]==="false"){
16331
 
16332
				#設置執行失敗
16333
				$result["status"]="false";
16334
 
16335
				#設置執行失敗訊息
16336
				$result["error"]=$createNewFolder;
16337
 
16338
				#回傳結果
16339
				return $result;
16340
 
16341
				}#if end
16342
 
16343
			#var_dump(__LINE__." ".print_r($conf,true));
16344
 
16345
			#預設要加 slash
16346
			$slash="/";
16347
 
16348
			#如果 path 為 "/" 結尾
16349
			if($conf["path"][strlen($conf["path"])-1]==="/"){
16350
 
16351
				#不用 slash
16352
				$slash="";
16353
 
16354
				}#if end
16355
 
16356
			#如果有設置 name
16357
			if(isset($conf["name"])){
16358
 
16359
				#指定軟連結要放在哪邊
16360
				$paramsForLn[]=$conf["path"].$slash.$conf["name"];
16361
 
16362
				#更新欲建立的軟連結名稱
16363
				$createdSoftLink=$conf["path"].$slash.$conf["name"];
16364
 
16365
				/*
16366
				#break point
16367
				var_dump($conf["path"],$softLink,$createdSoftLink);
16368
				exit;
16369
				*/
16370
 
16371
				}#if end
16372
 
16373
			#反之
16374
			else{
16375
 
16376
				#指定軟連結要放在哪邊
16377
				$paramsForLn[]=$conf["path"];
16378
 
16379
				#更新欲建立的軟連結名稱
16380
				$createdSoftLink=$conf["path"].$slash.$softLink;
16381
 
16382
				/*
16383
				#break point
16384
				var_dump($conf["path"],$softLink,$createdSoftLink);
16385
				exit;
16386
				*/
16387
 
16388
				}#else end
16389
 
16390
			#var_dump($createdSoftLink);
16391
 
16392
			}#if end
16393
 
16394
		#反之如果有設置 name
16395
		else if(isset($conf["name"])){
16396
 
16397
			#指定軟連結的名稱
16398
			$paramsForLn[]=$conf["name"];
16399
 
16400
			#更新欲建立的軟連結名稱
16401
			$createdSoftLink=$conf["name"];
16402
 
16403
			#var_dump(__LINE__." ".$createdSoftLink);
16404
 
16405
			}#if end
16406
 
16407
		/*
16408
		# break point
16409
		var_dump($createdSoftLink);
16410
		exit;
16411
		*/
16412
 
16413
		#如果要覆蓋既有的目標
16414
		if($conf["overWrite"]==="true"){
16415
 
16416
			#函式說明:
16417
			#移除檔案
16418
			#回傳結果:
16419
			#$result["status"],"true"代表移除成功,"false"代表移除失敗.
16420
			#$result["error"],錯誤訊息陣列
16421
			#$result["warning"],警告訊息陣列
16422
			#$result["function"],當前執行的函數名稱
16423
			#必填參數:
16424
			#$conf["fileAddress"],字串,要移除檔案的位置.
16425
			$conf["fileAccess::delFile"]["fileAddress"]=$createdSoftLink;
16426
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
16427
			$conf["fileAccess::delFile"]["fileArgu"]=$conf["fileArgu"];
16428
			#可省略參數:
16429
			#$conf["commentsArray"],字串陣列,提示的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
16430
			#$conf["commentsArray"]=array("");
16431
			#$conf["allowDelSymlink"],字串,預設為"false",不移除軟連結;"true"代表要移除軟連結.
16432
			$conf["fileAccess::delFile"]["allowDelSymlink"]="true";
16433
			#$conf["allowDelFolder"],字串,預設為"false",不移除目錄;"true"代表要移除目錄.
16434
			$conf["fileAccess::delFile"]["allowDelFolder"]="true";
16435
			#參考資料:
16436
			#無.
16437
			#備註:
16438
			#無.
16439
			$delFile=fileAccess::delFile($conf["fileAccess::delFile"]);
16440
			unset($conf["fileAccess::delFile"]);	
16441
 
16442
			/*
16443
			#break point
16444
			var_dump($delFile);
16445
			exit;
16446
			*/
16447
 
16448
			#如果執行失敗
16449
			if($delFile["status"]==="false"){
16450
 
16451
				#設置執行失敗
16452
				$result["status"]="false";
16453
 
16454
				#設置執行失敗訊息
16455
				$result["error"]=$delFile;
16456
 
16457
				#回傳結果
16458
				return $result;
16459
 
16460
				}#if end
16461
 
16462
			}#if end
16463
 
16464
		#函式說明:
16465
		#呼叫shell執行系統命令,並取得回傳的內容.
16466
		#回傳結果:
16467
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16468
		#$result["error"],錯誤訊息陣列.
16469
		#$result["function"],當前執行的函數名稱.
16470
		#$result["argu"],使用的參數.
16471
		#$result["cmd"],執行的指令內容.
16472
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
16473
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
16474
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
16475
		#$result["running"],是否還在執行.
16476
		#$result["pid"],pid.
16477
		#$result["statusCode"],執行結束後的代碼.
16478
		#必填參數:
16479
		#$conf["command"],字串,要執行的指令與.
16480
		$conf["external::callShell"]["command"]="ln";
16481
		#$conf["fileArgu"],字串,變數__FILE__的內容.
16482
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
16483
		#可省略參數:
16484
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
16485
		$conf["external::callShell"]["argu"]=$paramsForLn;
16486
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
16487
		#$conf["arguIsAddr"]=array();
16488
		#$conf["plainArgu"],字串陣列,哪幾個參數不要加上"",若為"true"則代表不用包;反之"false"則代表要包.
16489
		#$conf["plainArgu"]=array();
16490
		#$conf["useApostrophe"],字串陣列,如果有需要包住,則用「'」,而非「"」處理.前者為"true";後者為"false".
16491
		#$conf["useApostrophe"]=array();
16492
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
16493
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
16494
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
16495
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
16496
		#$conf["enablePrintDescription"]="true";
16497
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
16498
		#$conf["printDescription"]="";
16499
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
16500
		$conf["external::callShell"]["escapeshellarg"]="true";
16501
		#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
16502
		#$conf["thereIsShellVar"]=array();
16503
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
16504
		#$conf["username"]="";
16505
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
16506
		#$conf["password"]="";
16507
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
16508
		#$conf["useScript"]="";
16509
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
16510
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
16511
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
16512
		#$conf["inBackGround"]="";
16513
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
16514
		$conf["external::callShell"]["getErr"]="true";
16515
		#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
16516
		#$conf["doNotRun"]="false";
16517
		#參考資料:
16518
		#exec=>http://php.net/manual/en/function.exec.php
16519
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
16520
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
16521
		#備註:
16522
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
16523
		$callShell=external::callShell($conf["external::callShell"]);
16524
		unset($conf["external::callShell"]);
16525
 
16526
		#如果執行失敗
16527
		if($callShell["status"]==="false"){
16528
 
16529
			#設置執行失敗
16530
			$result["status"]="false";
16531
 
16532
			#設置執行失敗訊息
16533
			$result["error"]=$callShell;
16534
 
16535
			#回傳結果
16536
			return $result;
16537
 
16538
			}#if end
16539
 
16540
		#保存執行的指令
16541
		$result["cmd"][]=$callShell["cmd"];
16542
 
16543
		#初始化給 ls 指令的參數
16544
		$paramsForLs=array("-l",$paramsForLn[count($paramsForLn)-1]);
16545
 
16546
		#取得軟連結的資訊
16547
		#函式說明:
16548
		#呼叫shell執行系統命令,並取得回傳的內容.
16549
		#回傳結果:
16550
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16551
		#$result["error"],錯誤訊息陣列.
16552
		#$result["function"],當前執行的函數名稱.
16553
		#$result["argu"],使用的參數.
16554
		#$result["cmd"],執行的指令內容.
16555
		#$result["fullCmd"],如果參數 $conf["inBackGround"] 為 "true" 則會回傳該值.
16556
		#$result["output"],爲執行完二元碼後的輸出陣列,若 $conf["inBackGround"] 為 "true",則為當下的輸出.
16557
		#$result["tmpFileOutput"],儲存輸出的暫存檔案名稱,若 $conf["inBackGround"] 為 "true" 則會回傳該值.
16558
		#$result["running"],是否還在執行.
16559
		#$result["pid"],pid.
16560
		#$result["statusCode"],執行結束後的代碼.
16561
		#必填參數:
16562
		#$conf["command"],字串,要執行的指令與.
16563
		$conf["external::callShell"]["command"]="ls";
16564
		#$conf["fileArgu"],字串,變數__FILE__的內容.
16565
		$conf["external::callShell"]["fileArgu"]=$conf["fileArgu"];
16566
		#可省略參數:
16567
		#$conf["argu"],陣列字串,指令搭配的參數,預設為空陣列.
16568
		$conf["external::callShell"]["argu"]=$paramsForLs;
16569
		#$conf["arguIsAddr"],陣列字串,指令搭配的哪些參數為路徑,為路徑的參數會進行轉換以便符合呼叫當前函數的位置,預設不指定,若有3個參數,其中第3個參數為路徑,則表示為array("false","false","true").
16570
		#$conf["arguIsAddr"]=array();
16571
		#$conf["plainArgu"],字串陣列,哪幾個參數不要加上"",若為"true"則代表不用包;反之"false"則代表要包.
16572
		#$conf["plainArgu"]=array();
16573
		#$conf["useApostrophe"],字串陣列,如果有需要包住,則用「'」,而非「"」處理.前者為"true";後者為"false".
16574
		#$conf["useApostrophe"]=array();
16575
		#$conf["pre"],陣列,要在本指令前執行的每個指令與參數.
16576
		#$conf["pre"][$i]["cmd"],字串,要在本指令前執行的第$i+1個指令.
16577
		#$conf["pre"][$i]["param"],陣列字串,要在本指令前執行的第$i+1個指令的參數.
16578
		#$conf["enablePrintDescription"],字串,是否要印出$conf["printDescription"]的內容,"true"代表要,"false"代表不要,預設為"false".
16579
		#$conf["enablePrintDescription"]="true";
16580
		#$conf["printDescription"],字串,執行該外部程式前要印出來的的文字,預設為$conf["command"]的內容加上使用的$conf["argu"]參數.
16581
		#$conf["printDescription"]="";
16582
		#$conf["escapeshellarg"],字串,是否要啟用過濾參數,用了比較安全,但可能會出錯,"true"為啟用,"false"為不啟用,預設為"false".如果參數為"< 、<< 、> 、>> 、| 、2>&1"之一則不會過濾.
16583
		$conf["external::callShell"]["escapeshellarg"]="true";
16584
		#$conf["thereIsShellVar"],陣列字串,指令搭配的參數"argu",若含有「\'」,則取代為「"」.每個argu參數都要有對應的元素."true"代表要置換.
16585
		#$conf["thereIsShellVar"]=array();
16586
		#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
16587
		#$conf["username"]="";
16588
		#$conf["password"],字串,root的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
16589
		#$conf["password"]="";
16590
		#$conf["useScript"],字串,是否要啟用Linux的script指令來記錄輸出,"true"代表要,Fedora的selinux會擋住該操作;"false"代表不要,預設為"false".
16591
		#$conf["useScript"]="";
16592
		#$conf["logFilePath"],字串,當 $conf["useScript"] 為 "true" 時,輸出的內容要暫存到哪裡,預設為 "/tmp/.qbpwcf_tmp/external/callShell/".
16593
		#$conf["logFilePath"]=".qbpwcf_tmp/external/callShell/";
16594
		#$conf["inBackGround"],字串,是否要在背景執行,且不會等待程式執行結束再執行下一個指令,"true"代表是,"false"代表不要,預設為"false",如果$conf["command"]有用「;」區隔的多個指令將會出錯.
16595
		#$conf["inBackGround"]="";
16596
		#$conf["getErr"],字串,"true"代表將錯誤輸出變成標準輸出,反之"false"為不變動.
16597
		$conf["external::callShell"]["getErr"]="true";
16598
		#$conf["doNotRun"],字串,"true"代表不執行指令,預設為"false"會執行指令.
16599
		#$conf["doNotRun"]="false";
16600
		#參考資料:
16601
		#exec=>http://php.net/manual/en/function.exec.php
16602
		#escapeshellcmd=>http://php.net/manual/en/function.escapeshellcmd.php
16603
		#escapeshellarg=>http://php.net/manual/en/function.escapeshellarg.php
16604
		#備註:
16605
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
16606
		$callShell=external::callShell($conf["external::callShell"]);
16607
		unset($conf["external::callShell"]);
16608
 
16609
		#如果執行失敗
16610
		if($callShell["status"]==="false"){
16611
 
16612
			#設置執行失敗
16613
			$result["status"]="false";
16614
 
16615
			#設置執行失敗訊息
16616
			$result["error"]=$callShell;
16617
 
16618
			#回傳結果
16619
			return $result;
16620
 
16621
			}#if end
16622
 
16623
		#保存執行的指令
16624
		$result["cmd"][]=$callShell["cmd"];
16625
 
16626
		#取得軟連結的資訊
16627
		$result["content"]=$callShell["output"];
16628
 
16629
		#設置執行正常
16630
		$result["status"]="true";
16631
 
16632
		#回傳結果
16633
		return $result;
16634
 
16635
		}#function createLink end
16636
 
16637
	/*
16638
	#函式說明:
16639
	#針對特定目錄下的內容建立軟連結.
16640
	#回傳結果:
16641
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16642
	#$result["error"],錯誤訊息.
16643
	#$result["function"],當前執行的函數名稱.
16644
	#$result["content"],字串陣列,每個建立的軟連結資訊.
16645
	#必填參數:
16646
	#$conf["fileArgu"],字串,變數__FILE__的內容.
16647
	$conf["fileArgu"]=__FILE__;
16648
	#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
16649
	$conf["linkToDir"]="";
16650
	#可省略參數:
16651
	#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
16652
	#$conf["path"]="";
16653
	#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
16654
	#$conf["name"]=array(array("oriName","newName"));
16655
	#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
16656
	#$conf["overWrite"]="true";
16657
	#參考資料:
16658
	#無.
16659
	#備註:
16660
	#無.
16661
	*/
16662
	public static function createMultiLinkInDir(&$conf){
16663
 
16664
		#初始化要回傳的結果
16665
		$result=array();
16666
 
16667
		#取得當前執行的函數名稱
16668
		$result["function"]=__FUNCTION__;
16669
 
16670
		#如果沒有參數
16671
		if(func_num_args()==0){
16672
 
16673
			#設置執行失敗
16674
			$result["status"]="false";
16675
 
16676
			#設置執行錯誤訊息
16677
			$result["error"]="函數".$result["function"]."需要參數";
16678
 
16679
			#回傳結果
16680
			return $result;
16681
 
16682
			}#if end		
16683
 
16684
		#取得參數
16685
		$result["argu"]=$conf;
16686
 
16687
		#如果 $conf 不為陣列
16688
		if(gettype($conf)!=="array"){
16689
 
16690
			#設置執行失敗
16691
			$result["status"]="false";
16692
 
16693
			#設置執行錯誤訊息
16694
			$result["error"][]="\$conf變數須為陣列形態";
16695
 
16696
			#如果傳入的參數為 null
16697
			if($conf===null){
16698
 
16699
				#設置執行錯誤訊息
16700
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
16701
 
16702
				}#if end
16703
 
16704
			#回傳結果
16705
			return $result;
16706
 
16707
			}#if end
16708
 
16709
		#檢查參數
16710
		#函式說明:
16711
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
16712
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16713
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
16714
		#$result["function"],當前執行的函式名稱.
16715
		#$result["argu"],設置給予的參數.
16716
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
16717
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
16718
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
16719
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
16720
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
16721
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
16722
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
16723
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
16724
		#必填寫的參數:
16725
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
16726
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
16727
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
16728
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
16729
		#可以省略的參數:
16730
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
16731
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","linkToDir");
16732
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
16733
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
16734
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
16735
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
16736
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
16737
		#$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("file");
16738
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
16739
		#$conf["canBeEmpty"]=array();
16740
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
16741
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("path","name","overWrite");
16742
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
16743
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("path","name","overWrite");
16744
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
16745
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","array","string");
16746
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
16747
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(".",null,"false");
16748
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
16749
		#$conf["disallowAllSkipableVarIsEmpty"]="";
16750
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
16751
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
16752
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
16753
		#$conf["arrayCountEqualCheck"][]=array();
16754
		#參考資料來源:
16755
		#array_keys=>http://php.net/manual/en/function.array-keys.php
16756
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
16757
		unset($conf["variableCheck::checkArguments"]);
16758
 
16759
		#如果檢查參數失敗
16760
		if($checkArguments["status"]==="false"){
16761
 
16762
			#設置執行失敗
16763
			$result["status"]="false";
16764
 
16765
			#設置執行失敗訊息
16766
			$result["error"]=$checkArguments;
16767
 
16768
			#回傳結果
16769
			return $result;
16770
 
16771
			}#if end
16772
 
16773
		#如果檢查參數不通過
16774
		if($checkArguments["passed"]==="false"){
16775
 
16776
			#設置執行失敗
16777
			$result["status"]="false";
16778
 
16779
			#設置執行失敗訊息
16780
			$result["error"]=$checkArguments;
16781
 
16782
			#回傳結果
16783
			return $result;
16784
 
16785
			}#if end
16786
 
16787
		#函式說明:
16788
		#取得目錄底下所有目錄與檔案清單.
16789
		#回傳結果:
16790
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
16791
		#$result["error"],錯誤訊息陣列.
16792
		#$result["function"],函數名稱.
16793
		#$result["content"],陣列,目錄底下的檔案與子目錄.
16794
		#$result["content"][$i]["name"],字串,目錄底下的檔案與子目錄的名稱.
16795
		#$result["content"][$i]["folder"],字串,第$i+1個名稱為目錄還是檔案.
16796
		#$result["folder"],字串,當前目標為目錄還是檔案"true"代表為目錄,"false"代表為檔案.
16797
		#$result["position"],目前的位置.
16798
		#必填參數:
16799
		#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
16800
		$conf["fileAccess::getList"]["position"]=$conf["linkToDir"];
16801
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
16802
		$conf["fileAccess::getList"]["fileArgu"]=$conf["fileArgu"];
16803
		#可省略參數:
16804
		#無
16805
		#參考資料:
16806
		#opendir=>http://php.net/manual/en/function.opendir.php
16807
		#is_dir=>http://php.net/manual/en/function.is-dir.php
16808
		#備註:
16809
		#無.
16810
		$getList=fileAccess::getList($conf["fileAccess::getList"]);
16811
		unset($conf["fileAccess::getList"]);
16812
 
16813
		#如果檢查參數失敗
16814
		if($getList["status"]==="false"){
16815
 
16816
			#設置執行失敗
16817
			$result["status"]="false";
16818
 
16819
			#設置執行失敗訊息
16820
			$result["error"]=$getList;
16821
 
16822
			#回傳結果
16823
			return $result;
16824
 
16825
			}#if end
16826
 
16827
		#針對目標目錄底下的所有檔案
16828
		foreach($getList["content"] as $oriName){
16829
 
16830
			#如果有設定 $conf["name"]
16831
			if(isset($conf["name"])){
16832
 
16833
				#預設不指定新的軟連結名稱
16834
				unset($newSoftLinkName);
16835
 
16836
				#針對每個原始目標的名稱
16837
				foreach($conf["name"] as $customName){
16838
 
16839
					#如果是指定的目標
16840
					if($oriName["name"]===$customName[0]){
16841
 
16842
						#設置新的軟連結名稱
16843
						$newSoftLinkName=$customName[1];
16844
 
16845
						}#if end
16846
 
16847
					}#foreach end
16848
 
16849
				}#if end
16850
 
16851
			#建立軟連結
16852
			#函式說明:
16853
			#建立軟連結.
16854
			#回傳結果:
16855
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16856
			#$result["error"],錯誤訊息.
16857
			#$result["function"],當前執行的函數名稱.
16858
			#$result["content"],軟連結的資訊.
16859
			#必填參數:
16860
			#$conf["fileArgu"],字串,變數__FILE__的內容.
16861
			$conf["fileAccess::createLink"]["fileArgu"]=$conf["fileArgu"];
16862
			#$conf["linkTo"],字串,軟連結要指向哪邊.
16863
			$conf["fileAccess::createLink"]["linkTo"]=$conf["linkToDir"]."/".$oriName["name"];
16864
			#可省略參數:
16865
			#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
16866
			$conf["fileAccess::createLink"]["path"]=$conf["path"];
16867
 
16868
			#如果有新的軟連結名稱
16869
			if(isset($newSoftLinkName)){
16870
 
16871
				#$conf["name"],字串,軟連結的名稱,預設為 "linkTo" 參數的檔案或目錄名稱.
16872
				$conf["fileAccess::createLink"]["name"]=$newSoftLinkName;
16873
 
16874
				}#if end
16875
 
16876
			#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
16877
			$conf["fileAccess::createLink"]["overWrite"]=$conf["overWrite"];
16878
 
16879
			#參考資料:
16880
			#無.
16881
			#備註:
16882
			#無.
16883
			$createLink=fileAccess::createLink($conf["fileAccess::createLink"]);
16884
			unset($conf["fileAccess::createLink"]);
16885
 
16886
			#var_dump(__LINE__." ".print_r($createLink,true));
16887
 
16888
			#如果檢查參數失敗
16889
			if($createLink["status"]==="false"){
16890
 
16891
				#設置執行失敗
16892
				$result["status"]="false";
16893
 
16894
				#設置執行失敗訊息
16895
				$result["error"]=$createLink;
16896
 
16897
				#回傳結果
16898
				return $result;
16899
 
16900
				}#if end
16901
 
16902
			#儲存建立好的軟連結資訊
16903
			$result["content"][]=$createLink["content"];
16904
 
16905
			}#foreach end
16906
 
16907
		#設置執行正常
16908
		$result["status"]="true";
16909
 
16910
		#回傳結果
16911
		return $result;
16912
 
16913
		}#function createMultiLink end
16914
 
16915
	/*
16916
	#函式說明:
16917
	#更新檔案的內容.
16918
	#回傳結果:
16919
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16920
	#$result["error"],錯誤訊息.
16921
	#$result["function"],當前執行的函數名稱.
16922
	#$result["content"],軟連結的資訊.
16923
	#必填參數:
16924
	#$conf["fileArgu"],字串,變數__FILE__的內容.
16925
	$conf["fileArgu"]=__FILE__;
16926
	#$conf["file"],字串,要更新的檔案位置與名稱.
16927
	$conf["file"]="";
16928
	#可省略參數:
16929
	#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
16930
	#$conf["overWriteWith"]=array();
16931
	#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
16932
	#$conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
16933
	#$conf["replaceLike"],字串,預設為"false",代表要完全符合關鍵字才能進行整行替換;反之為"true".
16934
	#$conf["replaceLike"]="false";
16935
	#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
16936
	#$conf["addToTailWhenNoMatch"]="false";
16937
	#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
16938
	#$conf["addToTailBeforeThat"]="?\>";
16939
	#參考資料:
16940
	#無.
16941
	#備註:
16942
	#無.
16943
	*/
16944
	public static function updateFile(&$conf){
16945
 
16946
		#初始化要回傳的結果
16947
		$result=array();
16948
 
16949
		#取得當前執行的函數名稱
16950
		$result["function"]=__FUNCTION__;
16951
 
16952
		#如果沒有參數
16953
		if(func_num_args()==0){
16954
 
16955
			#設置執行失敗
16956
			$result["status"]="false";
16957
 
16958
			#設置執行錯誤訊息
16959
			$result["error"]="函數".$result["function"]."需要參數";
16960
 
16961
			#回傳結果
16962
			return $result;
16963
 
16964
			}#if end		
16965
 
16966
		#取得參數
16967
		$result["argu"]=$conf;
16968
 
16969
		#如果 $conf 不為陣列
16970
		if(gettype($conf)!=="array"){
16971
 
16972
			#設置執行失敗
16973
			$result["status"]="false";
16974
 
16975
			#設置執行錯誤訊息
16976
			$result["error"][]="\$conf變數須為陣列形態";
16977
 
16978
			#如果傳入的參數為 null
16979
			if($conf===null){
16980
 
16981
				#設置執行錯誤訊息
16982
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
16983
 
16984
				}#if end
16985
 
16986
			#回傳結果
16987
			return $result;
16988
 
16989
			}#if end
16990
 
16991
		#檢查參數
16992
		#函式說明:
16993
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
16994
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
16995
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
16996
		#$result["function"],當前執行的函式名稱.
16997
		#$result["argu"],設置給予的參數.
16998
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
16999
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
17000
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
17001
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
17002
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
17003
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
17004
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
17005
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
17006
		#必填寫的參數:
17007
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
17008
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;	
17009
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
17010
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
17011
		#可以省略的參數:
17012
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
17013
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","file");
17014
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
17015
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
17016
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
17017
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
17018
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
17019
		#$conf["variableCheck::checkArguments"]["canNotBeEmpty"]=array("file");
17020
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
17021
		#$conf["canBeEmpty"]=array();
17022
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
17023
		$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array("overWriteWith","replaceWith","addToTailWhenNoMatch","addToTailBeforeThat","replaceLike");
17024
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
17025
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("overWriteWith","replaceWith","addToTailWhenNoMatch","addToTailBeforeThat","replaceLike");
17026
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
17027
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","array","string","string","string");
17028
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
17029
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(null,null,"false",null,"false");
17030
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
17031
		#$conf["disallowAllSkipableVarIsEmpty"]="";
17032
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
17033
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
17034
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
17035
		#$conf["arrayCountEqualCheck"][]=array();
17036
		#參考資料來源:
17037
		#array_keys=>http://php.net/manual/en/function.array-keys.php
17038
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
17039
		unset($conf["variableCheck::checkArguments"]);
17040
 
17041
		#如果檢查參數失敗
17042
		if($checkArguments["status"]==="false"){
17043
 
17044
			#設置執行失敗
17045
			$result["status"]="false";
17046
 
17047
			#設置執行失敗訊息
17048
			$result["error"]=$checkArguments;
17049
 
17050
			#回傳結果
17051
			return $result;
17052
 
17053
			}#if end
17054
 
17055
		#如果檢查參數不通過
17056
		if($checkArguments["passed"]==="false"){
17057
 
17058
			#設置執行失敗
17059
			$result["status"]="false";
17060
 
17061
			#設置執行失敗訊息
17062
			$result["error"]=$checkArguments;
17063
 
17064
			#回傳結果
17065
			return $result;
17066
 
17067
			}#if end
17068
 
17069
		#檢查檔案是否存在
17070
		#函式說明:
17071
		#檢查多個檔案與資料夾是否存在.
17072
		#回傳的結果:
17073
		#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
17074
		#$result["error"],錯誤訊息陣列.
17075
		#$resutl["function"],當前執行的涵式名稱.
17076
		#$result["argu"],使用的參數.
17077
		#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
17078
		#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
17079
		#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
17080
		#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址
17081
		#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
17082
		#必填參數:
17083
		#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
17084
		$conf["fileAccess::checkMultiFileExist"]["fileArray"]=array($conf["file"]);
17085
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
17086
		$conf["fileAccess::checkMultiFileExist"]["fileArgu"]=$conf["fileArgu"];
17087
		#可省略參數:
17088
		#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
17089
		$conf["disableWebSearch"]="true";
17090
		#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
17091
		$conf["userDir"]="false";
17092
		#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false",預設為"true".
17093
		$conf["web"]="false";
17094
		#參考資料:
17095
		#http://php.net/manual/en/function.file-exists.php
17096
		#http://php.net/manual/en/control-structures.foreach.php
17097
		#備註:
17098
		#函數file_exists檢查的路徑為檔案系統的路徑
17099
		#$result["varName"][$i]結果未實作
17100
		$checkMultiFileExist=fileAccess::checkMultiFileExist($conf["fileAccess::checkMultiFileExist"]);
17101
		unset($conf["fileAccess::checkMultiFileExist"]);
17102
 
17103
		#如果檢查參數失敗
17104
		if($checkMultiFileExist["status"]==="false"){
17105
 
17106
			#設置執行失敗
17107
			$result["status"]="false";
17108
 
17109
			#設置執行失敗訊息
17110
			$result["error"]=$checkMultiFileExist;
17111
 
17112
			#回傳結果
17113
			return $result;
17114
 
17115
			}#if end
17116
 
17117
		#如果目標檔案不存在
17118
		if($checkMultiFileExist["allExist"]==="false"){
17119
 
17120
			#設置執行失敗
17121
			$result["status"]="false";
17122
 
17123
			#設置執行失敗訊息
17124
			$result["error"]=$checkMultiFileExist;
17125
 
17126
			#回傳結果
17127
			return $result;
17128
 
17129
			}#if end
17130
 
17131
		#如果有設置 overWriteWith
17132
		if(isset($conf["overWriteWith"])){
17133
 
17134
			#函式說明:
17135
			#將多行字串寫入到檔案
17136
			#回傳結果:
17137
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
17138
			#$result["error"],錯誤訊息陣列.
17139
			#$result["function"],當前執行函數的名稱.
17140
			#必填參數:
17141
			#$conf["fileName"],字串,爲要編輯的檔案名稱
17142
			$conf["fileAccess::writeMultiLine"]["fileName"]=$conf["file"];
17143
			#$conf["inputString"],字串陣列,爲要寫入到 $conf["fileName"] 裏面的內容. $conf["inputString"][$i] 代表第 $i+1 行。
17144
			$conf["fileAccess::writeMultiLine"]["inputString"]=$conf["overWriteWith"];
17145
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
17146
			$conf["fileAccess::writeMultiLine"]["fileArgu"]=$conf["fileArgu"];
17147
			#可省略參數:
17148
			#$conf["writeMethod"]="a";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
17149
			#參考資料:
17150
			#無.
17151
			#備註:
17152
			#無.
17153
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
17154
			unset($conf["fileAccess::writeMultiLine"]);
17155
 
17156
			#如果執行失敗
17157
			if($writeMultiLine["status"]==="false"){
17158
 
17159
				#設置執行失敗
17160
				$result["status"]="false";
17161
 
17162
				#設置執行失敗訊息
17163
				$result["error"]=$writeMultiLine;
17164
 
17165
				#回傳結果
17166
				return $result;
17167
 
17168
				}#if end
17169
 
17170
			}#if end
17171
 
17172
		#如果有設置 "replaceWith"
17173
		if(isset($conf["replaceWith"])){
17174
 
17175
			#取得檔案的內容
17176
			#函式說明:
17177
			#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
17178
			#回傳的變數說明:
17179
			#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
17180
			#$result["error"],錯誤訊息提示.
17181
			#$result["warning"],警告訊息.
17182
			#$result["function"],當前執行的函數名稱.
17183
			#$result["fileContent"],爲檔案的內容陣列.
17184
			#$result["lineCount"],爲檔案內容總共的行數.
17185
			#$result["fullContent"],為檔案的完整內容.
17186
			#$result["base64data"],為檔案的base64內容.
17187
			#$result["mimeType"],為檔案的mime type.
17188
			#必填參數:
17189
			#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
17190
			$conf["fileAccess::getFileContent"]["filePositionAndName"]=$conf["file"];
17191
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
17192
			$conf["fileAccess::getFileContent"]["fileArgu"]=$conf["fileArgu"];
17193
			#可省略參數:
17194
			#$conf["web"],是要取得網路上的檔案則為"true";反之則為"false".
17195
			$conf["fileAccess::getFileContent"]["web"]="false";
17196
			#參考資料:
17197
			#file(),取得檔案內容的行數.
17198
			#file=>http:#php.net/manual/en/function.file.php
17199
			#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
17200
			#filesize=>http://php.net/manual/en/function.filesize.php
17201
			#參考資料:
17202
			#無.
17203
			#備註:
17204
			#無.
17205
			$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
17206
			unset($conf["fileAccess::getFileContent"]);
17207
 
17208
			#如果執行失敗
17209
			if($getFileContent["status"]==="false"){
17210
 
17211
				#設置執行失敗
17212
				$result["status"]="false";
17213
 
17214
				#設置執行失敗訊息
17215
				$result["error"]=$getFileContent;
17216
 
17217
				#回傳結果
17218
				return $result;
17219
 
17220
				}#if end
17221
 
17222
			#取得原始檔案的每行內容
17223
			$oriFileContentByLine=&$getFileContent["fileContent"];
17224
 
17225
			#針對每個 replaceWith 條件
17226
			foreach($conf["replaceWith"] as $replaceInfo){
17227
 
17228
				#預設尚未找到符合的關鍵字
17229
				$foundKeyWord=false;
17230
 
17231
				#取得要替換的目標字串
17232
				$oriStr=$replaceInfo[0];
17233
 
17234
				#取得要替換成的字串內容
17235
				$newStr=$replaceInfo[1];
17236
 
17237
				#針對每行原始內容
17238
				foreach($oriFileContentByLine as $index => $line){
17239
 
17240
					#函式說明:
17241
					#檢查字串裡面有無指定的關鍵字
17242
					#回傳結果:
17243
					#$result["status"],"true"代表執行成功,"false"代表執行失敗。
17244
					#$result["error"],錯誤訊息
17245
					#$result["function"],當前執行的函數名稱.
17246
					#$result["argu"],使用的參數.
17247
					#$result["founded"],是否找到關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
17248
					#$result["keyWordCount"],找到的關鍵字數量.
17249
					#必填參數:
17250
					#$conf["keyWord"],字串,想要搜尋的關鍵字.
17251
					$conf["search::findKeyWord"]["keyWord"]=$oriStr;
17252
					#$conf["string"],字串,要被搜尋的字串內容
17253
					$conf["search::findKeyWord"]["string"]=$line;
17254
					#可省略參數:
17255
 
17256
					#如果要完全符合關鍵字
17257
					if($conf["replaceLike"]==="false"){
17258
 
17259
						#$conf["completeEqual"],字串,是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
17260
						$conf["search::findKeyWord"]["completeEqual"]="true";
17261
 
17262
						}#if end
17263
 
17264
					#參考資料:
17265
					#無.
17266
					#備註:
17267
					#無.
17268
					$findKeyWord=search::findKeyWord($conf["search::findKeyWord"]);
17269
					unset($conf["search::findKeyWord"]);
17270
 
17271
					#如果執行失敗
17272
					if($findKeyWord["status"]==="false"){
17273
 
17274
						#設置執行失敗
17275
						$result["status"]="false";
17276
 
17277
						#設置執行失敗訊息
17278
						$result["error"]=$findKeyWord;
17279
 
17280
						#回傳結果
17281
						return $result;
17282
 
17283
						}#if end
17284
 
17285
					#如果有找到關鍵字
17286
					if($findKeyWord["founded"]==="true"){
17287
 
17288
						#更新該行內容
17289
						$oriFileContentByLine[$index]=$newStr;
17290
 
17291
						#設置有找到符合的關鍵字
17292
						$foundKeyWord=true;
17293
 
17294
						}#if end
17295
 
17296
					}#foreach end
17297
 
17298
				#如果沒有找到關鍵字
17299
				if($foundKeyWord===false){
17300
 
17301
					#如果要新增內容
17302
					if($conf["addToTailWhenNoMatch"]==="true"){
17303
 
17304
						#如果有設置 addToTailBeforeThat
17305
						if(isset($conf["addToTailBeforeThat"])){
17306
 
17307
							#預設沒有找到符合的關鍵字
17308
							$foundKeyWord=false;
17309
 
17310
							#初始化要記錄要 append 回去的各行內容.
17311
							$linesToAppend=array();
17312
 
17313
							#倒敘,針對每行內容
17314
							for($i=count($oriFileContentByLine)-1;$i>=0;$i--){
17315
 
17316
								#儲存要 append 回去的行內容
17317
								$linesToAppend[]=$oriFileContentByLine[$i];
17318
 
17319
								#如果找到關鍵字了
17320
								if($oriFileContentByLine[$i]===$conf["addToTailBeforeThat"]){
17321
 
17322
									#設置有找到符合的關鍵字
17323
									$foundKeyWord=true;
17324
 
17325
									#更新該行內容
17326
									$oriFileContentByLine[$i]=$line;
17327
 
17328
									#倒敘陣列
17329
									$linesToAppend=array_reverse($linesToAppend);
17330
 
17331
									#針對每行要 append 回去的內容
17332
									foreach($linesToAppend as $lineToAppend){
17333
 
17334
										#append 行內容
17335
										$oriFileContentByLine[]=$lineToAppend;
17336
 
17337
										}#foreach end
17338
 
17339
									}#if end
17340
 
17341
								}#for end
17342
 
17343
							#如果沒有找到關鍵字
17344
							if($foundKeyWord===false){
17345
 
17346
								#設置執行失敗
17347
								$result["status"]="false";
17348
 
17349
								#設置錯誤訊息
17350
								$result["error"]="can't find \"".$conf["addToTailBeforeThat"]."\" to insert before it.";
17351
 
17352
								#回傳結果
17353
								return $result;
17354
 
17355
								}#if end
17356
 
17357
							}#if end
17358
 
17359
						}#if end
17360
 
17361
					}#if end
17362
 
17363
				}#foreach end
17364
 
17365
			#函式說明:
17366
			#將多行字串寫入到檔案
17367
			#回傳結果:
17368
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
17369
			#$result["error"],錯誤訊息陣列.
17370
			#$result["function"],當前執行函數的名稱.
17371
			#必填參數:
17372
			#$conf["fileName"],字串,爲要編輯的檔案名稱
17373
			$conf["fileAccess::writeMultiLine"]["fileName"]=$conf["file"];
17374
			#$conf["inputString"],字串陣列,爲要寫入到 $conf["fileName"] 裏面的內容. $conf["inputString"][$i] 代表第 $i+1 行。
17375
			$conf["fileAccess::writeMultiLine"]["inputString"]=$oriFileContentByLine;
17376
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
17377
			$conf["fileAccess::writeMultiLine"]["fileArgu"]=$conf["fileArgu"];
17378
			#可省略參數:
17379
			#$conf["fileAccess::writeMultiLine"]["writeMethod"]="w";#爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入。
17380
			#參考資料:
17381
			#無.
17382
			#備註:
17383
			#無.
17384
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
17385
			unset($conf["fileAccess::writeMultiLine"]);
17386
 
17387
			#如果執行失敗
17388
			if($writeMultiLine["status"]==="false"){
17389
 
17390
				#設置執行失敗
17391
				$result["status"]="false";
17392
 
17393
				#設置執行失敗訊息
17394
				$result["error"]=$writeMultiLine;
17395
 
17396
				#回傳結果
17397
				return $result;
17398
 
17399
				}#if end
17400
 
17401
			}#if end
17402
 
17403
		#設置執行正常
17404
		$result["status"]="true";
17405
 
17406
		#回傳結果
17407
		return $result;
17408
 
17409
		}#function updateFile end
17410
 
17411
	/*
17412
	#函式說明:
17413
	#輔助使用PHP內建的chmod函式.
17414
	#回傳結果:
17415
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17416
	#$result["error"],錯誤訊息.
17417
	#$result["function"],當前執行的函式名稱.
17418
	#$result["argu"],使用的參數.
17419
	#$result["cmd"],執行的指令.
17420
	#$result["content"],執行的結果陣列,如果參數 "recursive" 跟 "excludeSelf" 都有設定的話,就會回傳該結果.
17421
	#必填參數:
17422
	#$conf["mode"],字串,要變成什麼權限.
17423
	$conf["mode"]="";
17424
	#$conf["target"],字串,需要變更權限的目標.
17425
	$conf["target"]="";
17426
	#可省略參數:
17427
	#無.
17428
	#參考資料:
17429
	#無.
17430
	#備註:
17431
	#無.
17432
	*/
17433
	public static function chmod(&$conf){
17434
 
17435
		#初始化要回傳的結果
17436
		$result=array();
17437
 
17438
		#取得當前執行的函數名稱
17439
		$result["function"]=__FUNCTION__;
17440
 
17441
		#如果沒有參數
17442
		if(func_num_args()==0){
17443
 
17444
			#設置執行失敗
17445
			$result["status"]="false";
17446
 
17447
			#設置執行錯誤訊息
17448
			$result["error"]="函數".$result["function"]."需要參數";
17449
 
17450
			#回傳結果
17451
			return $result;
17452
 
17453
			}#if end
17454
 
17455
		#取得參數
17456
		$result["argu"]=$conf;
17457
 
17458
		#如果 $conf 不為陣列
17459
		if(gettype($conf)!=="array"){
17460
 
17461
			#設置執行失敗
17462
			$result["status"]="false";
17463
 
17464
			#設置執行錯誤訊息
17465
			$result["error"][]="\$conf變數須為陣列形態";
17466
 
17467
			#如果傳入的參數為 null
17468
			if(is_null($conf)){
17469
 
17470
				#設置執行錯誤訊息
17471
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
17472
 
17473
				}#if end
17474
 
17475
			#回傳結果
17476
			return $result;
17477
 
17478
			}#if end
17479
 
17480
		#函式說明:
17481
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
17482
		#回傳結果:
17483
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
17484
		#$result["error"],執行不正常結束的錯訊息陣列.
17485
		#$result["simpleError"],簡單表示的錯誤訊息.
17486
		#$result["function"],當前執行的函式名稱.
17487
		#$result["argu"],設置給予的參數.
17488
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
17489
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
17490
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
17491
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
17492
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
17493
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
17494
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
17495
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
17496
		#必填參數:
17497
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
17498
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
17499
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
17500
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
17501
		#可省略參數:
17502
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
17503
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("mode","target");
17504
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
17505
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
17506
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
17507
		#$conf["canBeEmptyString"]="false";
17508
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
17509
		#$conf["canNotBeEmpty"]=array();
17510
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
17511
		#$conf["canBeEmpty"]=array();
17512
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
17513
		#$conf["skipableVariableCanNotBeEmpty"]=array();
17514
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
17515
		#$conf["skipableVariableName"]=array();
17516
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
17517
		#$conf["skipableVariableType"]=array();
17518
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
17519
		#$conf["skipableVarDefaultValue"]=array("");
17520
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
17521
		#$conf["disallowAllSkipableVarIsEmpty"]="";
17522
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
17523
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
17524
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
17525
		#$conf["arrayCountEqualCheck"][]=array();
17526
		#參考資料:
17527
		#array_keys=>http://php.net/manual/en/function.array-keys.php
17528
		#備註:
17529
		#無.
17530
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
17531
		unset($conf["variableCheck::checkArguments"]);
17532
 
17533
		#如果檢查參數失敗
17534
		if($checkArguments["status"]==="false"){
17535
 
17536
			#設置執行失敗
17537
			$result["status"]="false";
17538
 
17539
			#設置錯誤資訊
17540
			$result["error"]=$checkArguments;
17541
 
17542
			#回傳結果
17543
			return $result;
17544
 
17545
			}#if end
17546
 
17547
		#如果檢查參數不通過
17548
		if($checkArguments["passed"]==="false"){
17549
 
17550
			#設置執行失敗
17551
			$result["status"]="false";
17552
 
17553
			#設置錯誤資訊
17554
			$result["error"]=$checkArguments;
17555
 
17556
			#回傳結果
17557
			return $result;
17558
 
17559
			}#if end
17560
 
17561
		#將$conf["mode"]轉換為10進位的整數
17562
		$conf["mode"]=(int)base_convert($conf["mode"],8,10);
17563
 
17564
		#變更 target 的檔案權限為代碼
17565
		$chmod=chmod($conf["target"],$conf["mode"]); 
17566
 
17567
		#如果改變檔案權限失敗
17568
		if($chmod===false){
17569
 
17570
			#設置執行失敗
17571
			$result["status"]="false";
17572
 
17573
			#設置錯誤訊息
17574
			$result["error"][]="改變 ".$conf["target"]." 檔案的權限資訊為 ".$conf["mode"]." 失敗,通常只有系統帳戶才能變更之.";
17575
 
17576
			#回傳結果
17577
			return $result;	
17578
 
17579
			}#if end
17580
 
17581
		#設置執行正常
17582
		$result["status"]="true";
17583
 
17584
		#回傳結果
17585
		return $result;
17586
 
17587
		}#function chmod end
17588
 
17589
	}#class fileAccess end
17590
 
17591
?>