Subversion Repositories php-qbpwcf

Rev

Rev 66 | Rev 220 | Go to most recent revision | Details | Compare with Previous | 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) 2014~2025 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
管理QBPWCFW套件的類別.
29
備註:
30
待所有函數類別與函數都標準化後,再來修改該函數會比較恰當. 
31
*/
32
class phpLib{
33
 
34
	/*
35
	#函式說明:
36
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
37
	#回傳結果:
38
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
39
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
40
	#$result["function"],當前執行的函式名稱.
41
	#必填參數:
42
	#$method,物件,為物件實體或類別名稱,會自動置入該參數.
43
	#$arguments,陣列,為呼叫方法時所用的參數.
44
	#可省略參數:
45
	#無.
46
	#參考資料:
47
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
48
	#備註:
49
	#無.
50
	*/
51
	public function __call($method,$arguments){
52
 
53
		#取得當前執行的函式
54
		$result["function"]=__FUNCTION__;
55
 
56
		#設置執行不正常
57
		$result["status"]="false";
58
 
59
		#設置執行錯誤
60
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
61
 
62
		#設置所丟入的參數
63
		$result["error"][]=$arguments;
64
 
65
		#回傳結果
66
		return $result;
67
 
68
		}#function __call end
69
 
70
	/*
71
	#函式說明:
72
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
73
	#回傳結果:
74
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
75
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
76
	#$result["function"],當前執行的函式名稱.
77
	#必填參數:
78
	#$method,物件,為物件實體或類別名稱,會自動置入該參數.
79
	#$arguments,陣列,為呼叫方法時所用的參數.
80
	#可省略參數:
81
	#無.
82
	#參考資料:
83
	#__callStatic=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
84
	#備註:
85
	#無.
86
	*/
87
	public static function __callStatic($method,$arguments){
88
 
89
		#取得當前執行的函式
90
		$result["function"]=__FUNCTION__;
91
 
92
		#設置執行不正常
93
		$result["status"]="false";
94
 
95
		#設置執行錯誤
96
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
97
 
98
		#設置所丟入的參數
99
		$result["error"][]=$arguments;
100
 
101
		#回傳結果
102
		return $result;
103
 
104
		}#function __callStatic end
105
 
106
	/*
107
	#函式說明:
108
	#取得目錄底下函式庫檔案清單
109
	#回傳結果:
110
	#$result["status"],"true"表示執行成功;"false"表示執行失敗
111
	#$result["error"],錯誤訊息.
112
	#$result["function"],當前執行的函數名稱.
113
	#$result["dataCount"],有幾筆符合的資料
114
	#$result["neededList"],符合條件的檔案清單		
115
	#必填參數:
116
	#$conf["folderAddress"],字串,要讀取的函式庫目錄
117
	$conf["folderAddress"]="phpLib";
118
	#$conf["fileArgu"],字串,__FILE__的內容.
119
	$conf["fileArgu"]=__FILE__;
120
	#可省略參數:
121
	#$conf["readFileType"],陣列,要讀取具有該陣列底下副檔名的檔案
122
	#$conf["readFileType"]=array("php","js","css");
123
	#$conf["excludeFile"],陣列,要忽略的檔案,*-soap.php代表"-soap.php"結尾的檔案都不要.
124
	#$conf["excludeFile"]=array();
125
	#參考資料:
126
	#無.
127
	#備註:
128
	#無.
129
	*/
130
	public static function getLibFileList(&$conf){
131
 
132
		#初始化要回傳的內容
133
		$result=array();
134
 
135
		#取得當前函數的名稱
136
		$result["function"]=__FUNCTION__;
137
 
138
		#如果 $conf 不為陣列
139
		if(gettype($conf)!="array"){
140
 
141
			#設置執行失敗
142
			$result["status"]="false";
143
 
144
			#設置執行錯誤訊息
145
			$result["error"][]="\$conf變數須為陣列形態";
146
 
147
			#如果傳入的參數為 null
148
			if($conf==null){
149
 
150
				#設置執行錯誤訊息
151
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
152
 
153
				}#if end
154
 
155
			#回傳結果
156
			return $result;
157
 
158
			}#if end
159
 
160
		#函式說明:
161
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
162
		#回傳結果:
163
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
164
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
165
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
166
		#必填寫的參數:
167
		$conf["variableCheck"]["isexistMuti"]["varInput"]=$conf;#要檢查的陣列變數
168
		$conf["variableCheck"]["isexistMuti"]["variableCheck"]=array("folderAddress","fileArgu");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
169
		#可以省略的參數:
170
		$conf["variableCheck"]["isexistMuti"]["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
171
		#$conf["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
172
		$checkResult=variableCheck::isexistMulti($conf["variableCheck"]["isexistMuti"]);
173
		unset($conf["variableCheck"]["isexistMuti"]);
174
 
175
		#如果參數檢查有問題 
176
		if($checkResult["passed"]=="false"){
177
 
178
			#回傳檢查的結果
179
			return $checkResult;
180
 
181
			}#if end
182
 
183
		#如果 $conf["readFileType"] 沒有設置
184
		if(!isset($conf["readFileType"])){
185
 
186
			#套用預設數值
187
			$conf["readFileType"]=array("php","js","css");
188
 
189
			}#if end
190
 
191
		#如果 $conf["readFileType"] 沒有設置
192
		if(!isset($conf["excludeFile"])){
193
 
194
			#套用預設數值
195
			$conf["excludeFile"]=array("");
196
 
197
			}#if end
198
 
199
		#初始化要回傳的變數
200
		$result["status"]="false";
201
 
202
		#函式說明:
203
		#取得目錄底下的詳細資訊.
204
		#回傳結果:
205
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
206
		#$result["error"],錯誤訊息.
207
		#$result["function"],當前執行的函數名稱.
208
		#$result["size"],該清單的大小,單位為bytes.
209
		#$result["dataCount"],該清單的長度.
210
		#$result["content"],指定目錄底下的所有檔案資訊.
211
		#$result["content"][$i]["nType&permission"],第$i個節點類型、權限.
212
		#$result["content"][$i]["nType"],第$i個節點類型,"-"代表檔案,"d"代表資料夾.
213
		#$result["content"][$i]["permission"],第$i個節點權限.
214
		#$result["content"][$i]["ownByUser"],第$i個節點擁有者賬號.
215
		#$result["content"][$i]["ownByGroup"],第$i個節點擁有者群組.
216
		#$result["content"][$i]["bytes"],第$i個節點大小.
217
		#$result["content"][$i]["date"],第$i個節點最後變更日期.
218
		#$result["content"][$i]["time"],第$i個節點最後異動時間.
219
		#$result["content"][$i]["timeDetail"],第$i個節點最後異動詳細時間.
220
		#$result["content"][$i]["timezone"],第$i個節點的時區.
221
		#$result["content"][$i]["name"],第$i個節點的名稱.
222
		#必填參數:
223
		#$conf["path"],字串,要檢視的路徑.
224
		$conf["fileAccess::ls"]["path"]=$conf["folderAddress"];
225
		#可省略參數:
226
		#無.
227
		#參考資料:
228
		#https://www.businessweekly.com.tw/careers/Blog/14307
229
		#備註:
230
		#清單要不包含 "."開頭 跟 "~" 開頭
231
		$ls=fileAccess::ls($conf["fileAccess::ls"]);
232
		unset($conf["fileAccess::ls"]);
233
 
234
		#如果執行失敗
235
		if($ls["status"]==="false"){
236
 
237
			#設置執行失敗識別
238
			$result["status"]="false";
239
 
240
			#設置執行失敗提示
241
			$result["error"]=$ls;
242
 
243
			#回傳結果
244
			return $result;
245
 
246
			}#if end
247
 
248
		#debug
249
		#var_dump(__FILE__,__LINE__,$ls);
250
 
251
		#初始化需要的清單
252
		$result["neededList"]=array();
253
 
254
		#針對清單中每個項目
255
		foreach($ls["content"] as $node){
256
 
257
			#debug
258
			#var_dump(__FILE__,__LINE__,$node["name"]);
259
 
260
			#用 "." 分割節點名稱
261
			#函式說明:
262
			#將固定格式的字串分開,並回傳分開的結果.
263
			#回傳結果:
264
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
265
			#$result["error"],錯誤訊息陣列
266
			#$result["function"],當前執行的函數名稱.
267
			#$result["argu"],使用的參數.
268
			#$result["oriStr"],要分割的原始字串內容
269
			#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
270
			#$result["dataCounts"],爲總共分成幾段
271
			#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
272
			#必填參數:
273
			#$conf["stringIn"],字串,要處理的字串.
274
			$conf["stringProcess::spiltString"]["stringIn"]=$node["name"];
275
			#$conf["spiltSymbol"],字串,爲以哪個符號作爲分割.
276
			$conf["stringProcess::spiltString"]["spiltSymbol"]=".";
277
			#可省略參數:
278
			#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
279
			#$conf["allowEmptyStr"]="false";
280
			#參考資料:
281
			#無.
282
			#備註:
283
			#無.
284
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
285
			unset($conf["stringProcess::spiltString"]);
286
 
287
			#debug
288
			#var_dump(__FILE__,__LINE__,$spiltString);
289
 
290
			#如果執行失敗
291
			if($spiltString["status"]=="false"){
292
 
293
				#設置執行失敗識別
294
				$result["status"]="false";
295
 
296
				#設置執行失敗提示
297
				$result["error"]=$spiltString["error"];
298
 
299
				#回傳結果
300
				return $result;
301
 
302
				}#if end
303
 
304
			#如果「.」後面有內容 
305
			if($spiltString["dataCounts"]>1){
306
 
307
				#debug
308
				#var_dump($spiltStr);
309
 
310
				#涵式說明:
311
				#處理字串避免網頁出錯
312
				#回傳的結果:
313
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
314
				#$result["function"],當前執行的函數.
315
				#$result["content"],爲處理好的字串.
316
				#$result["error"],錯誤訊息陣列.
317
				#$result["argu"],使用的參數. 
318
				#必填參數:
319
				$conf["stringProcess"]["correctCharacter"]["stringIn"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];#爲要處理的字串
320
				#可省略的參數:
321
				$conf["stringProcess"]["correctCharacter"]["selectedCharacter"]=array("\r","\n","\r\n","\n\r");#爲被選擇要處理的字串/字元,須爲陣列值。
322
					#若不設定則預設爲要將這些字串作替換("<" ">" ";" "=" "//" "'" "$" "%" "&" "|" "#" "/*" "*\/")。
323
				#$conf["changeTo"]=array("","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
324
				$correctCharacter=stringProcess::correctCharacter($conf["stringProcess"]["correctCharacter"]);
325
				unset($conf["stringProcess"]["correctCharacter"]);
326
 
327
				#如果處理失敗
328
				if($correctCharacter["status"]==="false"){
329
 
330
					#設置執行失敗識別
331
					$result["status"]="false";
332
 
333
					#設置執行失敗提示
334
					$result["error"]=$correctCharacter;
335
 
336
					#回傳結果
337
					return $result;
338
 
339
					}#if end
340
 
341
				#var_dump($spiltStr["dataArray"][$spiltStr["dataCounts"]-1]);
342
				#var_dump($correctCharacter["content"]);
343
 
344
				#更新處理好的字串內容
345
				$spiltString["dataArray"][$spiltString["dataCounts"]-1]=$correctCharacter["content"];
346
 
347
				#對照其最後一個「.」後面的內容(副檔名)是否爲我們所需要的。
348
				#函式說明:
349
				#檢查一個數值是否與陣列裏面的元素相同
350
				#回傳結果:
351
				#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
352
				#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
353
				#$result["error"],錯誤訊息
354
				#$result["function"],當前執行的函數名稱
355
				#$result["argv"],使用的參數
356
				#$result["equalVarName"],相等的變數名稱或key.
357
				#$result["equalVarValue"],相等的變數數值內容.
358
				#必填參數:
359
				$conf["search"]["getEqualVar"]["conditionElement"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];#條件元素,要等於的元素內容。
360
				$conf["search"]["getEqualVar"]["compareElements"]=$conf["readFileType"];#要比對的陣列變數內容。
361
				$compareResult=search::getEqualVar($conf["search"]["getEqualVar"]);
362
				unset($conf["search"]["getEqualVar"]);
363
 
364
				#如果執行失敗
365
				if($compareResult["status"]==="false"){
366
 
367
					#設置執行失敗識別
368
					$result["status"]="false";
369
 
370
					#設置執行失敗提示
371
					$result["error"]=$compareResult;
372
 
373
					#回傳結果
374
					return $result;
375
 
376
					}#if end
377
 
378
				#如果有符合
379
				if($compareResult["founded"]==="true"){
380
 
381
					#函式說明:
382
					#處理字串避免網頁出錯
383
					#回傳結果:
384
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
385
					#$result["function"],當前執行的函數.
386
					#$result["content"],爲處理好的字串.
387
					#$result["error"],錯誤訊息陣列.
388
					#$result["argu"],使用的參數. 
389
					#必填參數:
390
					$conf["stringProcess"]["correctCharacter"]["stringIn"]=$spiltString["dataArray"][$spiltString["dataCounts"]-1];#爲要處理的字串
391
					#可省略的參數:
392
					$conf["stringProcess"]["correctCharacter"]["selectedCharacter"]=array("\r","\n","\r\n","\n\r");#爲被選擇要處理的字串/字元,須爲陣列值。
393
						#若不設定則預設爲要將這些字串作替換("<" ">" ";" "=" "//" "'" "$" "%" "&" "|" "#" "/*" "*\/")。
394
					#$conf["changeTo"]=array("","","","");#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
395
					$correctCharacter=stringProcess::correctCharacter($conf["stringProcess"]["correctCharacter"]);
396
					unset($conf["stringProcess"]["correctCharacter"]);
397
 
398
					#debug
399
					#var_dump(__FILE__,__LINE__,$correctCharacter);
400
 
401
					#如果檔案是要排除的
402
					if(in_array($correctCharacter["content"],$conf["excludeFile"])){
403
 
404
						#debug
405
						#var_dump(__FILE__,__LINE__,$correctCharacter["content"],$conf["excludeFile"]);
406
 
407
						#忽略之
408
						continue;
409
 
410
						}#if end
411
 
412
					#針對每個要排除的項目	
413
					foreach($conf["excludeFile"] as $excludeFile){
414
 
415
						#如果檔案名稱包含"*",且為第一個字
416
						if(strpos($excludeFile,"*")===0){
417
 
418
							#取得要排除的關鍵字
419
							$excludeFileKeyWord=substr($excludeFile,1);
420
 
421
							#檢查有無結尾一樣
422
							#涵式說明:
423
							#取得符合特定字首與字尾的字串
424
							#回傳的結果:
425
							#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
426
							#$result["function"],當前執行的函數名稱.
427
							#$result["error"],錯誤訊息陣列.
428
							#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
429
							#$result["returnString"],爲符合字首條件的字串內容。
430
							#$result["argu"],使用的參數.
431
							#必填參數:
432
							#$conf["checkString"],字串,要檢查的字串.
433
							$conf["search::getMeetConditionsString"]["checkString"]=$node["name"];
434
							#可省略參數:
435
							#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
436
							#$conf["frontWord"]="";
437
							#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
438
							$conf["search::getMeetConditionsString"]["tailWord"]=$excludeFileKeyWord;
439
							#參考資料:
440
							#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
441
							$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
442
							unset($conf["search::getMeetConditionsString"]);
443
 
444
							#如果執行失敗
445
							if($getMeetConditionsString["status"]==="false"){
446
 
447
								#如果不是檔案名稱過短的錯誤
448
								if($getMeetConditionsString["error"][0]!=="要尋找的字尾長度大於要檢查的字串長度"){
449
 
450
									#設置執行失敗識別
451
									$result["status"]="false";
452
 
453
									#設置執行失敗提示
454
									$result["error"]=$getMeetConditionsString["error"];
455
 
456
									#回傳結果
457
									return $result;
458
 
459
									}#if end
460
 
461
								#設置沒有找到結尾相同的
462
								$getMeetConditionsString["founded"]="false";
463
 
464
								}#if end
465
 
466
							#如果結尾相同
467
							if($getMeetConditionsString["founded"]==="true"){
468
 
469
								#跳過該檔案
470
								continue 2;
471
 
472
								}#if end
473
 
474
							}#if end
475
 
476
						}#foreach end
477
 
478
					#debug
479
					#var_dump(__FILE__,__LINE__,$node["name"]);
480
 
481
					#只接受檔案(排除軟連結、資料夾)
482
					if($node["nType"]==='-'){
483
 
484
						#將該檔案項目取出
485
						$result["neededList"][]=$node["name"];
486
 
487
						#將是否有符合條件的檔案的識別設爲 "true"
488
						$result["status"]="true";
489
 
490
						}#if end
491
 
492
					}#if end
493
 
494
				}#if end
495
 
496
			}#foreach end
497
 
498
		#取得總共有幾個檔案是我們要的
499
		$result["dataCount"]=count($result["neededList"]);
500
 
501
		#回傳結果
502
		return $result;
503
 
504
		}#function getLibFileContent end
505
 
506
	/*
507
	#函式說明:
508
	#取得php函式庫檔案裡面的結構.
509
	#回傳結果:
510
	#$result["status"],"true"表示取得成功;"false"表示取得失敗.
511
	#$result["error"],錯誤訊息.
512
	#$result["function"],當前執行的函數名稱.
513
	#$result["namesapceCount"],命名空間的筆數.
514
	#$result["classCount"],類別的筆數.
515
	#$result["functionsCount"],函式的筆數.
516
	#$result["namespace"],命名空間名稱的陣列,每個元素有"lineNo"記錄所在行數與"content"記錄名稱.
517
	#$result["commentForNamespace"],每個命令空間對應的註解.
518
	#$result["class"],類別的陣列,每個元素有"lineNo"記錄所在行數與"content"記錄名稱與"namespace"記錄所屬的命名空間名稱.
519
	#$result["commentForClass"],每個類別對應的註解.
520
	#$result["functions"],函式名稱資訊的陣列,每個元素有"namespace"記錄所屬的命名空間與"class"記錄所屬的類別名稱與"content"記錄名稱.
521
	#必填參數:
522
	#$conf["libFileAddress"]=,字串,要讀取的函式庫檔案位置
523
	$conf["libFileAddress"]=".php";
524
	#$conf["fileArgu"],字串,__FILE__的內容.
525
	$conf["fileArgu"]=__FILE__;
526
	#可省略參數:
527
	#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"false".
528
	#$conf["web"]="true";
529
	#參考資料:
530
	#無.
531
	#備註:
532
	#無.
533
	*/
534
	public static function getPhpLibConstruction(&$conf){
535
 
536
		#初始化要回傳的內容
537
		$result=array();
538
 
539
		#取得當前函數的名稱
540
		$result["function"]=__FUNCTION__;
541
 
542
		#如果 $conf 不為陣列
543
		if(gettype($conf)!="array"){
544
 
545
			#設置執行失敗
546
			$result["status"]="false";
547
 
548
			#設置執行錯誤訊息
549
			$result["error"][]="\$conf變數須為陣列形態";
550
 
551
			#如果傳入的參數為 null
552
			if($conf==null){
553
 
554
				#設置執行錯誤訊息
555
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
556
 
557
				}#if end
558
 
559
			#回傳結果
560
			return $result;
561
 
562
			}#if end
563
 
564
		#函式說明:
565
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
566
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
567
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
568
		#$result["function"],當前執行的函式名稱.
569
		#$result["argu"],設置給予的參數.
570
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
571
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
572
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
573
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
574
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
575
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
576
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
577
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
578
		#必填寫的參數:
579
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
580
		$conf["variable::checkArguments"]["varInput"]=&$conf;
581
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
582
		$conf["variable::checkArguments"]["referenceVarKey"]="variable::checkArguments";
583
		#可以省略的參數:
584
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
585
		$conf["variable::checkArguments"]["mustBeFilledVariableName"]=array("libFileAddress","fileArgu");
586
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
587
		$conf["variable::checkArguments"]["mustBeFilledVariableType"]=array("string","string");
588
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
589
		#$conf["canBeEmptyString"]="false";
590
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
591
		#$conf["canNotBeEmpty"]=array();
592
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
593
		#$conf["canBeEmpty"]=array();
594
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
595
		#$conf["skipableVariableCanNotBeEmpty"]=array();
596
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
597
		$conf["variable::checkArguments"]["skipableVariableName"]=array("web");
598
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
599
		$conf["variable::checkArguments"]["skipableVariableType"]=array("string");
600
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
601
		$conf["variable::checkArguments"]["skipableVarDefaultValue"]=array("false");
602
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
603
		#$conf["disallowAllSkipableVarIsEmpty"]="";
604
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
605
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
606
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
607
		#$conf["arrayCountEqualCheck"][]=array();
608
		#參考資料來源:
609
		#array_keys=>http://php.net/manual/en/function.array-keys.php
610
		$checkArguments=variableCheck::checkArguments($conf["variable::checkArguments"]);
611
		unset($conf["variable::checkArguments"]);
612
 
613
		# 如果檢查出錯
614
		if($checkArguments["status"]=="false"){
615
 
616
			#設置執行錯誤的識別
617
			$result["status"]="fasle";
618
 
619
			#設置執行錯誤的訊息
620
			$result["error"]=$checkArguments;
621
 
622
			#回傳結果
623
			return $result;
624
 
625
			}#if end
626
 
627
		# 如果檢查不通過
628
		if($checkArguments["passed"]=="false"){
629
 
630
			#設置執行錯誤的識別
631
			$result["status"]="fasle";
632
 
633
			#設置執行錯誤的訊息
634
			$result["error"]=$checkArguments;
635
 
636
			#回傳結果
637
			return $result;
638
 
639
			}#if end
640
 
641
		#函數說明:
642
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
643
		#回傳結果:
644
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
645
		#$result["error"],錯誤訊息陣列.
646
		#$result["function"],函數名稱. 
647
		#$result["argu"],使用的參數.
648
		#$result["content"],網址,若是在命令列執行,則為"null".
649
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
650
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
651
		#必填參數:
652
		#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
653
		$conf["fileAccess::getInternetAddressV2"]["address"]=$conf["libFileAddress"];
654
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
655
		$conf["fileAccess::getInternetAddressV2"]["fileArgu"]=$conf["fileArgu"];
656
		#可省略參數:
657
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
658
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
659
		#備註:
660
		#建構中,fileSystemRelativePosition尚未實作,檢查參數尚未實作.
661
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
662
		unset($conf["fileAccess::getInternetAddressV2"]);
663
 
664
		#如果取得網路位置出錯
665
		if($getInternetAddressV2["status"]=="false"){
666
 
667
			#設置執行錯誤的識別
668
			$result["status"]="fasle";
669
 
670
			#設置執行錯誤的訊息
671
			$result["error"]=$checkArguments;
672
 
673
			#回傳結果
674
			return $result;
675
 
676
			}#if end
677
 
678
		#取得檔案系統位置
679
		$conf["libFileAddress"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
680
 
681
		#函式說明:
682
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
683
		#回傳的變數說明:
684
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗。
685
		#$result["error"],錯誤訊息提示
686
		#$result["fileContent"],爲檔案的內容陣列
687
		#$result["lineCount"],爲檔案內容總共的行數
688
		#必填參數:
689
		$conf["fileAccess::getFileContent"]["filePositionAndName"]=$conf["libFileAddress"];#爲檔案的位置以及名稱
690
		$conf["fileAccess::getFileContent"]["fileArgu"]=$conf["fileArgu"];
691
		#可省略參數:
692
		#$conf["web"],是要取得網路上的檔案則為"true";反之則為"false".
693
		$conf["fileAccess::getFileContent"]["web"]="false";
694
		#參考資料:
695
		#file():取得檔案內容的行數
696
		#http://php.net/manual/en/function.file.php
697
		$fileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
698
		unset($conf["fileAccess::getFileContent"]);
699
 
700
		#如果 檔案取得失敗
701
		if($fileContent["status"]=="false"){
702
 
703
			#設置執行失敗的識別
704
			$result["status"]="false";
705
 
706
			#設置錯誤訊息
707
			$result["error"]=$fileContent["error"];
708
 
709
			return $result;
710
 
711
			}#if end
712
 
713
		#根據 $fileContent 來尋找總共有幾個命名空間
714
		#函式說明:
715
		#檢查一個字串裡面是否有多個關鍵字
716
		#回傳的結果:
717
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
718
		#$result[$i]["status"],第$i個字串搜尋是否成功,"true"代表執行成功,"false"代表執行失敗。
719
		#$result[$i]["error"],第$i個字串搜尋的錯誤訊息陣列
720
		#$result[$i]["founded"],第$i個字串搜尋,是否找到所有的關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
721
		#$result["foundedTrueKey"],["founded"]結果為"true"的元素key陣列。
722
		#$result["foundedFalseKey"],["founded"]結果為"false"的元素key陣列。
723
		#必填參數:
724
		$conf["search"]["findManyKeyWordsFromManyString"]["keyWords"]=array("namespace");#想要搜尋的關鍵字
725
		$conf["search"]["findManyKeyWordsFromManyString"]["stringArray"]=$fileContent["fileContent"];#要被搜尋的字串內容陣列		
726
		#可省略的參數:
727
		#$conf["search"]["findManyKeyWordsFromManyString"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
728
		$foundedNamespaceStrArray=search::findManyKeyWordsFromManyString($conf["search"]["findManyKeyWordsFromManyString"]);
729
		unset($conf["search"]["findManyKeyWordsFromManyString"]);
730
 
731
		#針對每個找到"namespace"的行編號
732
		foreach($foundedNamespaceStrArray["foundedTrueKey"] as $lineNo => $value){
733
 
734
			#確認該行是否為命名空間的宣告行
735
			#函式說明:
736
			#檢查一個字串裡面是否沒有多個任何篩選字存在
737
			#回傳的結果:
738
			#$result["status"],執行是否成功的識別,"true"為執行成功;"false"為執行失敗
739
			#$result["error"],錯誤訊息陣列			
740
			#$result["filtered"],該字串是否為要過濾掉的,"true"為要過濾掉的;"false"為不用過濾掉的
741
			#必填參數:
742
			$conf["search"]["filterString"]["inputStr"]=$value;#要過濾的字串
743
			$conf["search"]["filterString"]["filterWord"]=array("#","=","}","unset(","foreach(","var_dump(");#要過濾的字串不能含有該陣列元素之一
744
			$searchResult=search::filterString($conf["search"]["filterString"]);
745
			unset($conf["search"]["filterString"]);
746
 
747
			#如果 $searchResult["filtered"] 等於 "fasle"
748
			if($searchResult["filtered"]=="false"){
749
 
750
				#代表是命名空間宣告的行
751
 
752
				#取得命名空間宣告的行
753
				$namespaceStr=$value;
754
 
755
				#函式說明:
756
				#處理字串避免網頁出錯
757
				#回傳的結果:
758
				#回傳結果:
759
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
760
				#$result["function"],當前執行的函數.
761
				#$result["content"],爲處理好的字串.
762
				#$result["error"],錯誤訊息陣列.
763
				#$result["argu"],使用的參數. 
764
				#必填參數:
765
				$conf["stringProcess"]["correctCharacter"]["stringIn"]=$namespaceStr;#爲要處理的字串
766
				#可省略的參數:
767
				$conf["stringProcess"]["correctCharacter"]["selectedCharacter"]=array(" ","{","namespace","\n","\t",";");#爲被選擇要處理的字串/字元,須爲陣列值。
768
					#若不設定則預設爲要將這些字串作替換("<",">",";","=","//","'","$","%","&","|","/*","*\/","#")。
769
				#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
770
				$correctCharacter=stringProcess::correctCharacter($conf["stringProcess"]["correctCharacter"]);
771
				unset($conf["stringProcess"]["correctCharacter"]);
772
 
773
				#如果執行失敗
774
				if($correctCharacter["status"]==="false"){
775
 
776
					#設置執行失敗的識別
777
					$result["status"]="false";
778
 
779
					#設置錯誤訊息
780
					$result["error"]=$correctCharacter["error"];
781
 
782
					return $result;
783
 
784
					}#if end
785
 
786
				#記錄取得的命名空間所在行數與名稱
787
				$result["namespace"][]=array("lineNo"=>$lineNo,"content"=>$correctCharacter["content"]);
788
 
789
				# 從 namespace 往前讀取對應的註解
790
				for($i=$lineNo-1;$i>0;$i--){
791
 
792
					#初始化 $temp
793
					$temp=$fileContent["fileContent"][$i];
794
 
795
					#如果該行內容不為空
796
					if(!empty($fileContent["fileContent"][$i])){
797
 
798
						#函式說明:
799
						#處理字串避免網頁出錯
800
						#回傳的結果:
801
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
802
						#$result["function"],當前執行的函數.
803
						#$result["content"],爲處理好的字串.
804
						#$result["error"],錯誤訊息陣列.
805
						#$result["argu"],使用的參數. 
806
						#必填參數:
807
						$conf["stringProcess"]["correctCharacter"]["stringIn"]=$fileContent["fileContent"][$i];#爲要處理的字串
808
						#可省略的參數:
809
						$conf["stringProcess"]["correctCharacter"]["selectedCharacter"]=array("\n");#爲被選擇要處理的字串/字元,須爲陣列值。
810
							#若不設定則預設爲要將這些字串作替換("<",">",";","=","//","'","$","%","&","|","/*","*\/","#")。
811
						#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
812
						$correctCharacter=stringProcess::correctCharacter($conf["stringProcess"]["correctCharacter"]);
813
						unset($conf["stringProcess"]["correctCharacter"]);
814
 
815
						#如果處理失敗
816
						if($correctCharacter["status"]==="false"){
817
 
818
							#設置執行錯誤的識別
819
							$result["status"]="false";
820
 
821
							#設置執行錯誤的訊息
822
							$result["error"]=$correctCharacter;
823
 
824
							#回傳結果
825
							return $result;
826
 
827
							}#if end
828
 
829
						#取得處理好的內容列
830
						$temp=$correctCharacter["content"];
831
 
832
						}#if end
833
 
834
					#如果 $temp 為 「/*」
835
					if($temp==="/*"){
836
 
837
						#跳出for迴圈
838
						break;
839
 
840
						}#if end
841
 
842
					#如果 $temp 為 「*/」 
843
					if($temp==="*/"){
844
 
845
						#跳到下一輪
846
						continue;
847
 
848
						}#if end
849
 
850
					#記錄namesapce的註解內容
851
					$result["commentForNamespace"][count($result["namespace"])-1][]=$temp;
852
 
853
					}#for end
854
 
855
				#函式說明:
856
				#將陣列倒置
857
				#回傳的結果:
858
				#$result["status"],執行是否成功,"true"為執行成功;"false"為執行失敗
859
				#$result["error"],錯誤訊息陣列
860
				#$result["convertArray"],轉置後的陣列內容
861
				#必填參數:
862
				$conf["arrays"]["convertArray"]["inputArray"]=$result["commentForNamespace"][count($result["namespace"])-1];#要倒置的陣列
863
				#參考資料來源:
864
				#http://tw2.php.net/array_reverse => 陣列倒置的內建函式
865
				$convertResult=arrays::convertArray($conf["arrays"]["convertArray"]);
866
				unset($conf["arrays"]["convertArray"]);
867
 
868
				#如果轉置失敗
869
				if($convertResult["status"]=="false"){
870
 
871
					#設置執行失敗的識別
872
					$result["status"]="false";
873
 
874
					#設置執行失敗的提示
875
					$result["error"]=$convertResult;
876
 
877
					#回傳結果
878
					return $result;
879
 
880
					}#if end	
881
 
882
				#反之代表執行成功
883
				else{
884
 
885
					#將倒置後的元素存起來
886
					$result["commentForNamespace"][count($result["namespace"])-1]=$convertResult["convertArray"];
887
 
888
					}#else 	
889
 
890
				}#if end
891
 
892
			}#foreach end
893
 
894
		#根據 $fileContent 來尋找總共有幾個類別
895
		#函式說明:
896
		#檢查一個字串裡面是否有多個關鍵字
897
		#回傳的結果:
898
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
899
		#$result[$i]["status"],第$i個字串搜尋是否成功,"true"代表執行成功,"false"代表執行失敗。
900
		#$result[$i]["error"],第$i個字串搜尋的錯誤訊息陣列
901
		#$result[$i]["founded"],第$i個字串搜尋,是否找到所有的關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
902
		#$result["foundedTrueKey"],["founded"]結果為"true"的元素key陣列。
903
		#$result["foundedFalseKey"],["founded"]結果為"false"的元素key陣列。
904
		#必填參數:
905
		$conf["search"]["findManyKeyWordsFromManyString"]["keyWords"]=array("class");#想要搜尋的關鍵字
906
		$conf["search"]["findManyKeyWordsFromManyString"]["stringArray"]=$fileContent["fileContent"];#要被搜尋的字串內容陣列
907
		#可省略的參數:
908
		#$conf["search"]["findManyKeyWordsFromManyString"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
909
		$foundedClassStrArray=search::findManyKeyWordsFromManyString($conf["search"]["findManyKeyWordsFromManyString"]);
910
		unset($conf["search"]["findManyKeyWordsFromManyString"]);
911
 
912
		#debug
913
		#var_dump($foundedClassStrArray["foundedTrueKey"]);
914
		#exit;
915
 
916
		#針對每個找到"class"的行編號
917
		foreach($foundedClassStrArray["foundedTrueKey"] as $lineNo => $value){
918
 
919
			#確認該行是否真的為類別宣告行。
920
			#函式說明:
921
			#檢查一個字串裡面是否沒有多個任何篩選字存在
922
			#回傳的結果:
923
			#$result["status"],執行是否成功的識別,"true"為執行成功;"false"為執行失敗
924
			#$result["error"],錯誤訊息陣列			
925
			#$result["filtered"],該字串是否為要過濾掉的,"true"為要過濾掉的;"false"為不用過濾掉的
926
			#必填參數:
927
			$conf["search"]["filterString"]["inputStr"]=$value;#要過濾的字串
928
			$conf["search"]["filterString"]["filterWord"]=array("#","=","}","unset(","foreach(","var_dump(",";","(",")"," implements ");#要過濾的字串不能含有該陣列元素之一
929
			$searchResult=search::filterString($conf["search"]["filterString"]);
930
			unset($conf["search"]["filterString"]);
931
 
932
			#如果 $searchResult["filtered"] 等於 "fasle"
933
			if($searchResult["filtered"]=="false"){
934
 
935
				#代表是類別宣告的行
936
 
937
				#取得類別宣告的行
938
				$classStr=$value;
939
 
940
				#函式說明:
941
				#處理字串避免網頁出錯
942
				#回傳的結果:
943
				#$result,爲處理好的字串。
944
				#必填參數:
945
				$conf["stringProcess"]["correctCharacter"]["stringIn"]=$classStr;#爲要處理的字串
946
				#可省略的參數:
947
				$conf["stringProcess"]["correctCharacter"]["selectedCharacter"]=array(" ","{","class","\n","\t");#爲被選擇要處理的字串/字元,須爲陣列值。
948
					#若不設定則預設爲要將這些字串作替換("<",">",";","=","//","'","$","%","&","|","/*","*\/","#")。
949
				#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
950
				$correctCharacter=stringProcess::correctCharacter($conf["stringProcess"]["correctCharacter"]);
951
				unset($conf["stringProcess"]["correctCharacter"]);
952
 
953
				#如果執行失敗
954
				if($correctCharacter["status"]==="false"){
955
 
956
					#設置執行失敗的識別
957
					$result["status"]="false";
958
 
959
					#設置錯誤訊息
960
					$result["error"]=$correctCharacter["error"];
961
 
962
					return $result;
963
 
964
					}#if end
965
 
966
				#針對每個命名空間
967
				foreach($result["namespace"] as $nsArray){
968
 
969
					#如果該類別的行數是在該namespace之後
970
					if($lineNo>$nsArray["lineNo"]){
971
 
972
						#設定該類別所屬的命名空間
973
						$namespace=$nsArray["content"];
974
 
975
						}#if end
976
 
977
					#反之
978
					else{
979
 
980
						#跳出foreach
981
						break;
982
 
983
						}#else end
984
 
985
					}#foreach end
986
 
987
				#記錄取得的類別所在行數與名稱
988
				$result["class"][]=array("lineNo"=>$lineNo,"content"=>$correctCharacter["content"],"namespace"=>$namespace);
989
 
990
				# 從 class 往前讀取對應的註解
991
				for($i=$lineNo-1;$i>0;$i--){
992
 
993
					#初始化 $temp
994
					$temp=$fileContent["fileContent"][$i];
995
 
996
					#如果該行內容不為空
997
					if(!empty($fileContent["fileContent"][$i])){
998
 
999
						#函式說明:
1000
						#處理字串避免網頁出錯
1001
						#回傳的結果:
1002
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1003
						#$result["function"],當前執行的函數.
1004
						#$result["content"],爲處理好的字串.
1005
						#$result["error"],錯誤訊息陣列.
1006
						#$result["argu"],使用的參數. 
1007
						#必填參數:
1008
						$conf["stringProcess"]["correctCharacter"]["stringIn"]=$fileContent["fileContent"][$i];#爲要處理的字串
1009
						#可省略的參數:
1010
						$conf["stringProcess"]["correctCharacter"]["selectedCharacter"]=array(" ","\n","\t");#爲被選擇要處理的字串/字元,須爲陣列值。
1011
							#若不設定則預設爲要將這些字串作替換("<",">",";","=","//","'","$","%","&","|","/*","*\/","#")。
1012
						#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
1013
						$correctCharacter=stringProcess::correctCharacter($conf["stringProcess"]["correctCharacter"]);
1014
						unset($conf["stringProcess"]["correctCharacter"]);
1015
 
1016
						#如果處理失敗
1017
						if($correctCharacter["status"]==="false"){
1018
 
1019
							#設置執行錯誤的識別
1020
							$result["status"]="false";
1021
 
1022
							#設置執行錯誤的訊息
1023
							$result["error"]=$correctCharacter;
1024
 
1025
							#回傳結果
1026
							return $result;
1027
 
1028
							}#if end
1029
 
1030
						#取得處理好的內容列
1031
						$temp=$correctCharacter["content"];
1032
 
1033
						}#if end
1034
 
1035
					#如果 $temp 為 「/*」
1036
					if($temp==="/*"){
1037
 
1038
						#跳出for迴圈
1039
						break;
1040
 
1041
						}#if end
1042
 
1043
					#如果 $temp 為 「*/」 
1044
					if($temp==="*/"){
1045
 
1046
						#跳到下一輪
1047
						continue;
1048
 
1049
						}#if end
1050
 
1051
					#記錄namesapce的註解內容
1052
					$result["commentForClass"][count($result["class"])-1][]=$temp;
1053
 
1054
					}#for end
1055
 
1056
				#函式說明:
1057
				#將陣列倒置
1058
				#回傳的結果:
1059
				#$result["status"],執行是否成功,"true"為執行成功;"false"為執行失敗
1060
				#$result["error"],錯誤訊息陣列
1061
				#$result["convertArray"],轉置後的陣列內容
1062
				#必填參數:
1063
				$conf["arrays"]["convertArray"]["inputArray"]=$result["commentForClass"][count($result["class"])-1];#要倒置的陣列
1064
				#參考資料來源:
1065
				#http://tw2.php.net/array_reverse => 陣列倒置的內建函式
1066
				$convertResult=arrays::convertArray($conf["arrays"]["convertArray"]);
1067
				unset($conf["arrays"]["convertArray"]);
1068
 
1069
				#如果轉置失敗
1070
				if($convertResult["status"]=="false"){
1071
 
1072
					#設置執行失敗的識別
1073
					$result["status"]="false";
1074
 
1075
					#設置執行失敗的提示
1076
					$result["error"]=$convertResult;
1077
 
1078
					#回傳結果
1079
					return $result;
1080
 
1081
					}#if end	
1082
 
1083
				#反之代表執行成功
1084
				else{
1085
 
1086
					#將倒置後的元素存起來
1087
					$result["commentForClass"][count($result["class"])-1]=$convertResult["convertArray"];
1088
 
1089
					}#else 	
1090
 
1091
				}#if end
1092
 
1093
			}#foreach end
1094
 
1095
		#針對每個要處理的命名空間註解陣列
1096
		foreach($result["commentForNamespace"] as $index => $cfn){
1097
 
1098
			#函式說明:
1099
			#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
1100
			#回傳的結果:
1101
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1102
			#$result["function"],當前執行的function名稱
1103
			#$result["error"],錯誤訊息陣列.
1104
			#$result["content"],處理好的字串.
1105
			#$result["argu"],使用的參數.
1106
			#必填參數:
1107
			#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.
1108
			$conf["arrays::arrayToString"]["inputArray"]=$cfn;
1109
			#可省略參數:
1110
			#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;
1111
			$conf["arrays::arrayToString"]["spiltSymbol"]=PHP_EOL;
1112
			#$conf["skipEnd"],字串,結尾是否不要加上符號,預設為"false",要加上符號,"true"代表不要加上符號。
1113
			$conf["arrays::arrayToString"]["skipEnd"]="true";
1114
			#參考資料:
1115
			#無.
1116
			#備註:
1117
			#無.
1118
			$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
1119
			unset($conf["arrays::arrayToString"]);
1120
 
1121
			#如果執行失敗
1122
			if($arrayToString["status"]==="false"){
1123
 
1124
				#設定執行錯誤識別
1125
				$result["status"]="false";
1126
 
1127
				#設定執行錯誤提示
1128
				$result["error"]=$arrayToString;
1129
 
1130
				#回傳結果 
1131
				return $result;
1132
 
1133
				}#if end
1134
 
1135
			#轉存為字串
1136
			$result["commentForNamespace"][$index]=$arrayToString["content"];
1137
 
1138
			}#foreach end
1139
 
1140
		#針對每個要處理的類別註解陣列
1141
		foreach($result["commentForClass"] as $index => $cfc){
1142
 
1143
			#函式說明:
1144
			#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
1145
			#回傳的結果:
1146
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1147
			#$result["function"],當前執行的function名稱
1148
			#$result["error"],錯誤訊息陣列.
1149
			#$result["content"],處理好的字串.
1150
			#$result["argu"],使用的參數.
1151
			#必填參數:
1152
			#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.
1153
			$conf["arrays::arrayToString"]["inputArray"]=$cfc;
1154
			#可省略參數:
1155
			#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;
1156
			$conf["arrays::arrayToString"]["spiltSymbol"]=PHP_EOL;
1157
			#$conf["skipEnd"],字串,結尾是否不要加上符號,預設為"false",要加上符號,"true"代表不要加上符號。
1158
			$conf["arrays::arrayToString"]["skipEnd"]="true";
1159
			#參考資料:
1160
			#無.
1161
			#備註:
1162
			#無.
1163
			$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
1164
			unset($conf["arrays::arrayToString"]);
1165
 
1166
			#如果執行失敗
1167
			if($arrayToString["status"]==="false"){
1168
 
1169
				#設定執行錯誤識別
1170
				$result["status"]="false";
1171
 
1172
				#設定執行錯誤提示
1173
				$result["error"]=$arrayToString;
1174
 
1175
				#回傳結果 
1176
				return $result;
1177
 
1178
				}#if end
1179
 
1180
			#轉存為字串
1181
			$result["commentForClass"][$index]=$arrayToString["content"];	
1182
 
1183
			}#foreach end
1184
 
1185
		#根據 $fileContent 來尋找總共有幾個 function
1186
		#函式說明:
1187
		#檢查一個字串裡面是否有多個關鍵字
1188
		#回傳的結果:
1189
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
1190
		#$result[$i]["status"],第$i個字串搜尋是否成功,"true"代表執行成功,"false"代表執行失敗。
1191
		#$result[$i]["error"],第$i個字串搜尋的錯誤訊息陣列
1192
		#$result[$i]["founded"],第$i個字串搜尋,是否找到所有的關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
1193
		#$result["foundedTrueKey"],["founded"]結果為"true"的元素key陣列。
1194
		#$result["foundedFalseKey"],["founded"]結果為"false"的元素key陣列。
1195
		#必填參數:
1196
		$conf["search"]["findManyKeyWordsFromManyString"]["keyWords"]=array("public static function");#想要搜尋的關鍵字
1197
		$conf["search"]["findManyKeyWordsFromManyString"]["stringArray"]=$fileContent["fileContent"];#要被搜尋的字串內容陣列
1198
		#可省略的參數:
1199
		#$conf["search"]["findManyKeyWordsFromManyString"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
1200
		$foundedFunctionStrArray=search::findManyKeyWordsFromManyString($conf["search"]["findManyKeyWordsFromManyString"]);
1201
		unset($conf["search"]["findManyKeyWordsFromManyString"]);
1202
 
1203
		#針對每個找到"function"的行編號
1204
		foreach($foundedFunctionStrArray["foundedTrueKey"] as $keyNo=>$keyContent){
1205
 
1206
			#確認該行是否真的為函式宣告行。
1207
			#函式說明:
1208
			#檢查一個字串裡面是否沒有多個任何篩選字存在
1209
			#回傳的結果:
1210
			#$result["status"],執行是否成功的識別,"true"為執行成功;"false"為執行失敗
1211
			#$result["error"],錯誤訊息陣列			
1212
			#$result["filtered"],該字串是否為要過濾掉的,"true"為要過濾掉的;"false"為不用過濾掉的
1213
			#必填參數:
1214
			$conf["search"]["filterString"]["inputStr"]=$keyContent;#要過濾的字串
1215
			$conf["search"]["filterString"]["filterWord"]=array("__call","__callStatic","#","=","}","unset(","foreach(","var_dump(",";","(function","ckeditor.on","-",".","/","!",":",",","onResponseresponse(");#要過濾的字串不能含有該陣列元素之一
1216
			$searchResult=search::filterString($conf["search"]["filterString"]);
1217
			unset($conf["search"]["filterString"]);
1218
 
1219
			#如果 $searchResult["filtered"] 等於 "fasle"
1220
			if($searchResult["filtered"]==="false"){
1221
 
1222
				#代表是宣告函式的行
1223
 
1224
				#取得類宣告函式的行
1225
				$functionStr=$keyContent;
1226
 
1227
				#函式說明:
1228
				#處理字串避免網頁出錯
1229
				#回傳的結果:
1230
				#$result,爲處理好的字串。
1231
				#必填參數:
1232
				$conf["stringProcess"]["correctCharacter"]["stringIn"]=$functionStr;#爲要處理的字串
1233
				#可省略的參數:
1234
				$conf["stringProcess"]["correctCharacter"]["selectedCharacter"]=array(",&\$argu","public static"," ","{","function","\$conf","(",")","&","\n","\t");#爲被選擇要處理的字串/字元,須爲陣列值。
1235
					#若不設定則預設爲要將這些字串作替換("<",">",";","=","//","'","$","%","&","|","/*","*\/","#")。
1236
				#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
1237
				$correctCharacter=stringProcess::correctCharacter($conf["stringProcess"]["correctCharacter"]);
1238
				unset($conf["stringProcess"]["correctCharacter"]);
1239
 
1240
				#如果執行失敗
1241
				if($correctCharacter["status"]==="false"){
1242
 
1243
					#設定執行錯誤識別
1244
					$result["status"]="false";
1245
 
1246
					#設定執行錯誤提示
1247
					$result["error"]=$correctCharacter;
1248
 
1249
					#回傳結果 
1250
					return $result;
1251
 
1252
					}#if end
1253
 
1254
				#針對每個命名空間
1255
				foreach($result["namespace"] as $ni){
1256
 
1257
					#如果所在行數則在該命名空間之後
1258
					if($keyNo > $ni["lineNo"]){
1259
 
1260
						#設置該函式所屬的命名空間名稱
1261
						$namespaceOfFunc=$ni["content"];
1262
 
1263
						}#if end
1264
 
1265
					#反之
1266
					else{
1267
 
1268
						#結束 foreach end
1269
						break;
1270
 
1271
						}#else end
1272
 
1273
					}#foreach end
1274
 
1275
				#針對每個類別名稱
1276
				foreach($result["class"] as $ci){
1277
 
1278
					#如果所在行數則在該類別名稱之後
1279
					if($keyNo > $ci["lineNo"]){
1280
 
1281
						#設置該函式所屬的類別名稱
1282
						$classOfFunc=$ci["content"];
1283
 
1284
						}#if end
1285
 
1286
					#反之
1287
					else{
1288
 
1289
						#結束 foreach end
1290
						break;
1291
 
1292
						}#else end
1293
 
1294
					}#foreach end
1295
 
1296
				#儲存函式的資訊
1297
				$result["functions"][]=array("content"=>$correctCharacter["content"],"namespace"=>$namespaceOfFunc,"class"=>$classOfFunc);
1298
 
1299
				}#if end
1300
 
1301
			}#foreach end
1302
 
1303
		#取得命名空間的數量
1304
		$result["namesapceCount"]=count($result["namespace"]);
1305
 
1306
		#如果 $result["class"] 不存在
1307
		if(!isset($result["class"])){
1308
 
1309
			#設置為空陣列
1310
			$result["class"]=array();
1311
 
1312
			}#if end
1313
 
1314
		#取得類別的數量
1315
		$result["classCount"]=count($result["class"]);
1316
 
1317
		#如果 $result["class"] 不存在
1318
		if(!isset($result["functions"])){
1319
 
1320
			#設置為空陣列
1321
			$result["functions"]=array();
1322
 
1323
			}#if end
1324
 
1325
		#取得函式的數量
1326
		$result["functionCount"]=count($result["functions"]);
1327
 
1328
		#值行到這邊執行成功
1329
		$result["status"]="true";
1330
 
1331
		#回傳節果
1332
		return $result;
1333
 
1334
		}#function getPhpLibContent end
1335
 
1336
	/*
1337
	#函式說明:
1338
	#取得函式的結構
1339
	#回傳結果:
1340
	#$result["status"],執行是否成功"true"代表執行成功,"false"代表執行失敗
1341
	#$result["error"],錯誤訊息陣列
1342
	#$result["function"],當前執行的函數名稱.
1343
	#$result["functionComment"],函式的註解全文.
1344
	#$result["content"],函式的程式內容字串.
1345
	#$result["comment"],函式說明
1346
	#$result["argvType"],傳入參數的型態,""表示不用參數
1347
	#$result["returnVarType"],回傳的變數型態,目前尚無法判斷其型態為string、int、float、double、boolean的哪一個,所以先一律視為"string"
1348
	#$result["return"]["name"],回傳的變數名稱
1349
	#$result["return"]["comment"],回傳的變數註解
1350
	#$result["mustBeFilled"]["dataCount"],不可省略的參數陣列元素數量 
1351
	#$result["optionalFilled"]["dataCount"],可省略的參數陣列元素數量
1352
	#$result["mustBeFilled"]["name"],不可省略的參數陣列
1353
	#$result["mustBeFilled"]["comment"],不可省略的參數註解陣列
1354
	#$result["optionalFilled"]["name"],可省略的參數陣列
1355
	#$result["optionalFilled"]["comment"],可省略的參數註解陣列
1356
	#$result["reference"]["addr"],參考資料的網址
1357
	#$result["reference"]["comment"],參考資料的說明
1358
	#必填參數:
1359
	#$conf["phpFileAddress"],字串,含有函式內容的php檔案位置與名稱
1360
	$conf["phpFileAddress"]="";
1361
	#$conf["functionName"],字串,函式的名稱
1362
	$conf["functionName"]="";
1363
	#$conf["fileArgu"],字串,__FILE__的內容.
1364
	$conf["fileArgu"]=__FILE__;
1365
	#可省略參數:
1366
	#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"false".
1367
	#$conf["web"]="false";
1368
	#參考資料:
1369
	#無.
1370
	#備註:
1371
	#無.
1372
	*/
1373
	public static function getFunctionConstruction(&$conf){
1374
 
1375
		#初始化要回傳的內容
1376
		$result=array();
1377
 
1378
		#取得當前函數的名稱
1379
		$result["function"]=__FUNCTION__;
1380
 
1381
		#如果 $conf 不為陣列
1382
		if(gettype($conf)!="array"){
1383
 
1384
			#設置執行失敗
1385
			$result["status"]="false";
1386
 
1387
			#設置執行錯誤訊息
1388
			$result["error"][]="\$conf變數須為陣列形態";
1389
 
1390
			#如果傳入的參數為 null
1391
			if($conf==null){
1392
 
1393
				#設置執行錯誤訊息
1394
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1395
 
1396
				}#if end
1397
 
1398
			#回傳結果
1399
			return $result;
1400
 
1401
			}#if end
1402
 
1403
		#函式說明:
1404
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
1405
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1406
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
1407
		#$result["function"],當前執行的函式名稱.
1408
		#$result["argu"],設置給予的參數.
1409
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
1410
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
1411
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
1412
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
1413
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
1414
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
1415
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
1416
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
1417
		#必填寫的參數:
1418
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
1419
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
1420
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
1421
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
1422
		#可以省略的參數:
1423
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
1424
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("phpFileAddress","functionName","fileArgu");
1425
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
1426
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
1427
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
1428
		#$conf["canBeEmptyString"]="false";
1429
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
1430
		#$conf["canNotBeEmpty"]=array();
1431
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
1432
		#$conf["canBeEmpty"]=array();
1433
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
1434
		#$conf["skipableVariableCanNotBeEmpty"]=array();
1435
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1436
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("web");
1437
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
1438
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
1439
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1440
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("false");
1441
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
1442
		#$conf["disallowAllSkipableVarIsEmpty"]="";
1443
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
1444
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
1445
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1446
		#$conf["arrayCountEqualCheck"][]=array();
1447
		#參考資料來源:
1448
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1449
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1450
		unset($conf["variableCheck::checkArguments"]);
1451
 
1452
		# 如果檢查出錯
1453
		if($checkArguments["status"]==="false"){
1454
 
1455
			#設置執行錯誤的識別
1456
			$result["status"]="false";
1457
 
1458
			#設置執行錯誤的訊息
1459
			$result["error"]=$checkArguments;
1460
 
1461
			#回傳結果
1462
			return $result;
1463
 
1464
			}#if end
1465
 
1466
		# 如果檢查不通過
1467
		if($checkArguments["passed"]==="false"){
1468
 
1469
			#設置執行錯誤的識別
1470
			$result["status"]="false";
1471
 
1472
			#設置執行錯誤的訊息
1473
			$result["error"]=$checkArguments;
1474
 
1475
			#回傳結果
1476
			return $result;
1477
 
1478
			}#if end
1479
 
1480
		#函數說明:
1481
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
1482
		#回傳結果:
1483
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1484
		#$result["error"],錯誤訊息陣列.
1485
		#$result["function"],函數名稱. 
1486
		#$result["argu"],使用的參數.
1487
		#$result["content"],網址,若是在命令列執行,則為"null".
1488
		#$result["webPathFromRoot"],相對於網頁根目錄的路徑.
1489
		#$result["fileSystemAbsoulutePosition"],針對伺服器端的絕對位置,亦即從網頁「document_root」目錄開始的路徑.
1490
		#必填參數:
1491
		#$conf["address"],字串,檔案的相對位置,若為絕對位置則會自動轉換成相對位置.
1492
		$conf["fileAccess::getInternetAddressV2"]["address"]=$conf["phpFileAddress"];
1493
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
1494
		$conf["fileAccess::getInternetAddressV2"]["fileArgu"]=$conf["fileArgu"];
1495
		#可省略參數:
1496
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"true".
1497
		$conf["fileAccess::getInternetAddressV2"]["web"]=$conf["web"];
1498
		#備註:
1499
		#建構中,fileSystemRelativePosition尚未實作
1500
		$getInternetAddressV2=fileAccess::getInternetAddressV2($conf["fileAccess::getInternetAddressV2"]);
1501
		unset($conf["fileAccess::getInternetAddressV2"]);
1502
 
1503
		#如果執行出錯
1504
		if($getInternetAddressV2["status"]==="false"){
1505
 
1506
			#設置執行錯誤的識別
1507
			$result["status"]="false";
1508
 
1509
			#設置執行錯誤的訊息
1510
			$result["error"]=$getInternetAddressV2;
1511
 
1512
			#回傳結果
1513
			return $result;
1514
 
1515
			}#if end	
1516
 
1517
		#取得檔案的絕對位置
1518
		$conf["phpFileAddress"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
1519
 
1520
		#取得php檔案的內容
1521
		#函式說明:
1522
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
1523
		#回傳的變數說明:
1524
		#$result["fileContent"],爲檔案的內容陣列
1525
		#$result["lineCount"],爲檔案內容總共的行數
1526
		#必填參數:
1527
		$conf["fileAccess"]["getFileContent"]["filePositionAndName"]=$conf["phpFileAddress"];#爲檔案的位置以及名稱
1528
		$conf["fileAccess"]["getFileContent"]["fileArgu"]=$conf["fileArgu"];
1529
		#$conf["web"],字串,"true"代表檔案是放在web環境;"false"是代表在檔案系統環境,預設為"false".
1530
		$conf["fileAccess"]["getFileContent"]["web"]="false";
1531
		#參考資料:
1532
		#file():取得檔案內容的行數
1533
		#http:#php.net/manual/en/function.file.php
1534
		$fileContent=fileAccess::getFileContent($conf["fileAccess"]["getFileContent"]);
1535
		unset($conf["fileAccess"]["getFileContent"]);
1536
 
1537
		#如果執行出錯
1538
		if($fileContent["status"]==="false"){
1539
 
1540
			#設置執行錯誤的識別
1541
			$result["status"]="false";
1542
 
1543
			#設置執行錯誤的訊息
1544
			$result["error"]=$fileContent;
1545
 
1546
			#回傳結果
1547
			return $result;
1548
 
1549
			}#if end
1550
 
1551
		#尋找函式定義的位置.
1552
		#函式說明:
1553
		#檢查一個字串裡面是否有多個關鍵字
1554
		#回傳的結果:
1555
		#$result["status"],整體來說,執行是否成功,"true"代表執行成功,"false"代表執行失敗。
1556
		#$result[$i]["status"],第$i個字串搜尋是否成功,"true"代表執行成功,"false"代表執行失敗。
1557
		#$result[$i]["error"],第$i個字串搜尋的錯誤訊息陣列
1558
		#$result[$i]["founded"],第$i個字串搜尋,是否找到所有的關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
1559
		#$result["foundedTrueKey"],["founded"]結果為"true"的元素key陣列。
1560
		#$result["foundedFalseKey"],["founded"]結果為"false"的元素key陣列。
1561
		#必填參數:
1562
		$conf["search"]["findManyKeyWordsFromManyString"]["keyWords"]=array("function ".$conf["functionName"]."(");#想要搜尋的關鍵字
1563
		$conf["search"]["findManyKeyWordsFromManyString"]["stringArray"]=$fileContent["fileContent"];#要被搜尋的字串內容陣列
1564
		#可省略的參數:
1565
		#$conf["search"]["findManyKeyWordsFromManyString"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
1566
		$foundedFunctionStrArray=search::findManyKeyWordsFromManyString($conf["search"]["findManyKeyWordsFromManyString"]);
1567
		unset($conf["search"]["findManyKeyWordsFromManyString"]);
1568
 
1569
		#取得可能為函式宣告的陣列元素key
1570
		$maybeAfunctionDefineLine=$foundedFunctionStrArray["foundedTrueKey"];		
1571
 
1572
		#有抓到錯誤的函式名稱,需要剔除
1573
		#針對每個抓到的function行
1574
		foreach($foundedFunctionStrArray["foundedTrueKey"] as $maybeAfunctinKeyNo){
1575
 
1576
			#如果該行內容含有「=」則代表為錯誤的函式行
1577
			#函式說明:
1578
			#檢查字串裡面有無指定的關鍵字
1579
			#回傳的結果:
1580
			#$result["status"],"true"代表執行成功,"false"代表執行失敗。
1581
			#$result["error"],錯誤訊息
1582
			#$result["founded"],是否找到關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
1583
			#必填參數:
1584
			$conf["search"]["findKeyWord"]["keyWord"]="=";#想要搜尋的關鍵字
1585
			$conf["search"]["findKeyWord"]["string"]=$maybeAfunctinKeyNo;#要被搜尋的字串內容
1586
			#可省略的參數:
1587
			#$conf["search"]["findKeyWord"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
1588
			$searchResult=search::findKeyWord($conf["search"]["findKeyWord"]);
1589
			unset($conf["search"]["findKeyWord"]);
1590
 
1591
			#如果 $searchResult["founded"] 等於 "true" 則代表該行不是真的函式宣告
1592
			if($searchResult["founded"]=="true"){
1593
 
1594
				#涵式說明:
1595
				#將陣列中特定元素剔除
1596
				#回傳的結果:
1597
				#剔除掉特地元素的陣列
1598
				#必填參數:
1599
				$conf["arrays"]["eraseElement"]["rawInputArray"]=$maybeAfunctionDefineLine;#要處理的原始數字陣列
1600
				$conf["arrays"]["eraseElement"]["eraseElementKey"]=$maybeAfunctinKeyNo;#要移除的元素key值  
1601
				$maybeAfunctionDefineLine=arrays::eraseElement($conf["arrays"]["eraseElement"]);
1602
				unset($conf["arrays"]["eraseElement"]);
1603
 
1604
				}#if end
1605
 
1606
			}#foreach end
1607
 
1608
		#更新可能為函式宣告的行key
1609
		$foundedFunctionStrArray["foundedTrueKey"]=$maybeAfunctionDefineLine;
1610
 
1611
		#針對每個找到"function"的行編號
1612
		foreach($foundedFunctionStrArray["foundedTrueKey"] as $index=>$keyNum){
1613
 
1614
			#判斷該行是否為註解
1615
			#函式說明:
1616
			#檢查一個字串裡面是否有多個關鍵字
1617
			#回傳的結果:
1618
			#$result["status"],"true"代表執行成功,"false"代表執行失敗。
1619
			#$result["error"],錯誤訊息
1620
			#$result["founded"],是否找到所有的關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
1621
			#必填參數:
1622
			$conf["search"]["findManyKeyWords"]["keyWords"]=array("#");#想要搜尋的關鍵字
1623
			$conf["search"]["findManyKeyWords"]["string"]=$keyNum;#要被搜尋的字串內容
1624
			#可省略的參數:
1625
			#$conf["search"]["findManyKeyWords"]["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
1626
			$searchResult=search::findManyKeyWords($conf["search"]["findManyKeyWords"]);
1627
			unset($conf["search"]["findManyKeyWords"]);	
1628
 
1629
			#如果沒有「#」關鍵字
1630
			if($searchResult["founded"]==="false"){
1631
 
1632
				#代表是宣告函式的行
1633
 
1634
				#取得函式結構結束的key(檔案內容每行的key)
1635
				$result["functionStructionEndPoint"]=$index;
1636
 
1637
				}#if end
1638
 
1639
			}#foreach end
1640
 
1641
		#如果找不到函數宣告的行數
1642
		if(!isset($result["functionStructionEndPoint"])){
1643
 
1644
			#設置執行錯誤的識別
1645
			$result["status"]="false";
1646
 
1647
			#設置執行錯誤的訊息
1648
			$result["error"]=$foundedFunctionStrArray;
1649
 
1650
			#回傳結果
1651
			return $result;
1652
 
1653
			}#if end
1654
 
1655
		#從 $result["functionStructionEndPoint"] 元素往前讀,直到讀到「/*」為止。
1656
		for($i=$result["functionStructionEndPoint"]-1;$i>=0;$i--){
1657
 
1658
			#函式說明:
1659
			#處理字串避免網頁出錯
1660
			#回傳的結果:
1661
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1662
			#$result["function"],當前執行的函數.
1663
			#$result["content"],爲處理好的字串.
1664
			#$result["error"],錯誤訊息陣列.
1665
			#$result["argu"],使用的參數. 
1666
			#必填參數:
1667
			$conf["stringProcess"]["correctCharacter"]["stringIn"]=$fileContent["fileContent"][$i];#爲要處理的字串
1668
			#可省略的參數:
1669
			$conf["stringProcess"]["correctCharacter"]["selectedCharacter"]=array(" ","\n","\t");#爲被選擇要處理的字串/字元,須爲陣列值。
1670
				#若不設定則預設爲要將這些字串作替換("<",">",";","=","//","'","$","%","&","|","/*","*\/","#")。
1671
			#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
1672
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess"]["correctCharacter"]);
1673
			unset($conf["stringProcess"]["correctCharacter"]);
1674
 
1675
			#如果處理失敗
1676
			if($correctCharacter["status"]==="false"){
1677
 
1678
				#設置執行錯誤的識別
1679
				$result["status"]="false";
1680
 
1681
				#設置執行錯誤的訊息
1682
				$result["error"]=$correctCharacter;
1683
 
1684
				#回傳結果
1685
				return $result;
1686
 
1687
				}#if end
1688
 
1689
			#取得處理號的內容列
1690
			$temp=$correctCharacter["content"];
1691
 
1692
			#如果 $temp 為 「/*」
1693
			if($temp==="/*"){
1694
 
1695
				#跳出for迴圈
1696
				break;
1697
 
1698
				}#if end
1699
 
1700
			#如果 $temp 為 「*/」 
1701
			if($temp==="*/"){
1702
 
1703
				#跳到下一輪
1704
				continue;
1705
 
1706
				}#if end
1707
 
1708
			#取得涵式宣告的內容
1709
			$result["functionComment"][]=$fileContent["fileContent"][$i];	
1710
 
1711
			}#for end
1712
 
1713
		#函式說明:
1714
		#將陣列倒置
1715
		#回傳的結果:
1716
		#$result["status"],執行是否成功,"true"為執行成功;"false"為執行失敗
1717
		#$result["error"],錯誤訊息陣列
1718
		#$result["convertArray"],轉置後的陣列內容
1719
		#必填參數:
1720
		$conf["arrays"]["convertArray"]["inputArray"]=$result["functionComment"];#要倒置的陣列
1721
		#參考資料來源:
1722
		#http://tw2.php.net/array_reverse => 陣列倒置的內建函式
1723
		$convertResult=arrays::convertArray($conf["arrays"]["convertArray"]);
1724
		unset($conf["arrays"]["convertArray"]);
1725
 
1726
		#如果轉置失敗
1727
		if($convertResult["status"]=="false"){
1728
 
1729
			#設置執行失敗的識別
1730
			$result["status"]="false";
1731
 
1732
			#設置執行失敗的提示
1733
			$result["error"]=$convertResult;
1734
 
1735
			#回傳結果
1736
			return $result;
1737
 
1738
			}#if end	
1739
 
1740
		#反之代表執行成功
1741
		else{
1742
 
1743
			#將倒置後的元素存起來
1744
			$result["functionComment"]=$convertResult["convertArray"];
1745
 
1746
			}#else 
1747
 
1748
		#將多餘的字元剔除
1749
		#函式說明:
1750
		#處理多個字串避免網頁出錯
1751
		#回傳的結果:
1752
		#$result["status"],"true"代表執行成功,"false"代表執行失敗。
1753
		#$result["error"],錯誤訊息
1754
		#$result["processedStrArray"],處理好的字串陣列
1755
		#必填參數:
1756
		$conf["stringProcess"]["correctMutiStrCharacter"]["stringIn"]=$result["functionComment"];#爲要處理的字串陣列
1757
		#可省略的參數:
1758
		$conf["stringProcess"]["correctMutiStrCharacter"]["selectedCharacter"]=array(" ","\t","\n");#爲被選擇要處理的字串/字元,須爲陣列值。
1759
			#若不設定則預設爲要將這些字串作替換("<",">",";","=","//","'","$","%","&","|","/*","*\/","#")。
1760
			#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
1761
		#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
1762
		$strProcessedResult=stringProcess::correctMutiStrCharacter($conf["stringProcess"]["correctMutiStrCharacter"]);
1763
		unset($conf["stringProcess"]["correctMutiStrCharacter"]);
1764
 
1765
		#如果 $strProcessedResult["status"]為"false"
1766
		if($strProcessedResult["status"]=="false"){
1767
 
1768
			#設定執行錯誤識別
1769
			$result["status"]="false";
1770
 
1771
			#設定執行錯誤提示
1772
			$result["error"]=$strProcessedResult;
1773
 
1774
			#回傳結果 
1775
			return $result;
1776
 
1777
			}#if end
1778
 
1779
		#反之代表執行成功
1780
		else{
1781
 
1782
			$result["functionComment"]=$strProcessedResult["processedStrArray"];
1783
 
1784
			}#else end
1785
 
1786
		#取得涵式宣告的那一行	
1787
		$functionDefineLine=$fileContent["fileContent"][$result["functionStructionEndPoint"]];	
1788
 
1789
		#如果 $functionDefineLine 中有「()」則代表沒有要傳入的參數
1790
		#函式說明:
1791
		#檢查字串裡面有無指定的關鍵字
1792
		#回傳的結果:
1793
		#$result["status"],"true"代表執行成功,"false"代表執行失敗。
1794
		#$result["error"],錯誤訊息
1795
		#$result["founded"],是否找到關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字。
1796
		#必填參數:
1797
		$conf["search"]["findKeyWord"]["keyWord"]="()";#想要搜尋的關鍵字
1798
		$conf["search"]["findKeyWord"]["string"]=$functionDefineLine;#要被搜尋的字串內容
1799
		#可省略的參數:
1800
		#$conf["completeEqual"]="true";#是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合。
1801
		$searchResult=search::findKeyWord($conf["search"]["findKeyWord"]);
1802
		unset($conf["search"]["findKeyWord"]);
1803
 
1804
		#如果 $searchResult["founded"]為"true"
1805
		if($searchResult["founded"]=="true"){
1806
 
1807
			#代表不須要傳入參數
1808
			$result["argvType"]="";
1809
 
1810
			}#if end
1811
 
1812
		#反之代表有傳入參數
1813
		else{
1814
 
1815
			#用「(」來分割
1816
			#涵式說明:
1817
			#將固定格式的字串分開,並回傳分開的結果。
1818
			#回傳的參數:
1819
			#$result["oriStr"],要分割的原始字串內容
1820
			#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
1821
			#$result["dataCounts"],爲總共分成幾段
1822
			#必填參數:
1823
			$conf["stringProcess"]["spiltString"]["stringIn"]=$functionDefineLine;#要處理的字串。
1824
			$conf["stringProcess"]["spiltString"]["spiltSymbol"]="(";#爲以哪個符號作爲分割
1825
			$spiltedStr=stringProcess::spiltString($conf["stringProcess"]["spiltString"]);
1826
			unset($conf["stringProcess"]["spiltString"]);
1827
 
1828
			#如果執行失敗
1829
			if($spiltedStr["status"]==="false"){
1830
 
1831
				#設定執行錯誤識別
1832
				$result["status"]="false";
1833
 
1834
				#設定執行錯誤提示
1835
				$result["error"]=$spiltedStr;
1836
 
1837
				#回傳結果 
1838
				return $result;
1839
 
1840
				}#if end	
1841
 
1842
			#如果切割出來小於2段
1843
			if($spiltedStr["dataCounts"]<2){
1844
 
1845
				#設定執行錯誤識別
1846
				$result["status"]="false";
1847
 
1848
				#設定執行錯誤提示
1849
				$result["error"][]=$spiltedStr;
1850
 
1851
				#設定執行錯誤提示
1852
				$result["error"][]="dataCounts 應該要大於等於 2";
1853
 
1854
				#回傳結果 
1855
				return $result;
1856
 
1857
				}#if end
1858
 
1859
			#用「)」來分割
1860
			#涵式說明:
1861
			#將固定格式的字串分開,並回傳分開的結果。
1862
			#回傳的參數:
1863
			#$result["oriStr"],要分割的原始字串內容
1864
			#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
1865
			#$result["dataCounts"],爲總共分成幾段
1866
			#必填參數:
1867
			$conf["stringProcess"]["spiltString"]["stringIn"]=$spiltedStr["dataArray"][1];#要處理的字串。
1868
			$conf["stringProcess"]["spiltString"]["spiltSymbol"]=")";#爲以哪個符號作爲分割
1869
			$spiltedStr=stringProcess::spiltString($conf["stringProcess"]["spiltString"]);
1870
			unset($conf["stringProcess"]["spiltString"]);				
1871
 
1872
			#取得參數內容
1873
			$argvName=$spiltedStr["dataArray"][0];
1874
 
1875
			#如果要傳入的參數為 "$conf"
1876
			if($argvName=="&\$conf"){
1877
 
1878
				#則為array型態
1879
				$result["argvType"]="array";
1880
 
1881
				}#if end
1882
 
1883
			#反之
1884
			else{
1885
 
1886
				#則未知型態
1887
				$result["argvType"]="unknow";
1888
 
1889
				}#else end
1890
 
1891
			}#else end
1892
 
1893
		#取得函式說明的元素key
1894
		#函式說明:
1895
		#檢查一個數值是否與陣列裏面的元素相同
1896
		#回傳的結果:
1897
		#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
1898
		#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
1899
		#$result["error"],錯誤訊息
1900
		#$result["function"],當前執行的函數名稱
1901
		#$result["argv"],使用的參數
1902
		#$result["equalVarName"],相等的變數名稱或key.
1903
		#$result["equalVarValue"],相等的變數數值內容.
1904
		#必填參數:
1905
		$conf["search"]["getEqualVar"]["conditionElement"]="#函式說明:";#條件元素,要等於的元素內容。
1906
		$conf["search"]["getEqualVar"]["compareElements"]=$result["functionComment"];#要比對的陣列變數內容。
1907
		$searchResult=search::getEqualVar($conf["search"]["getEqualVar"]);
1908
		unset($conf["search"]["getEqualVar"]);
1909
 
1910
		#debug
1911
		#var_dump($searchResult);
1912
 
1913
		#如果執行失敗
1914
		if($searchResult["status"]==="false"){
1915
 
1916
			#設定執行錯誤識別
1917
			$result["status"]="false";
1918
 
1919
			#設定執行錯誤提示
1920
			$result["error"]=$searchResult;
1921
 
1922
			#回傳結果 
1923
			return $result;
1924
 
1925
			}#if end
1926
 
1927
		#如果沒有找到
1928
		if($searchResult["founded"]==="false"){
1929
 
1930
			#設定執行錯誤識別
1931
			$result["status"]="false";
1932
 
1933
			#設定執行錯誤提示
1934
			$result["error"]=$searchResult;
1935
 
1936
			#回傳結果 
1937
			return $result;
1938
 
1939
			}#if end
1940
 
1941
		#函式說明起始點的key
1942
		$functionCommentStartKey=$searchResult["equalVarName"];
1943
 
1944
		#取得涵式說明內容:
1945
		$result["comment"]=$result["functionComment"][$functionCommentStartKey+1];
1946
 
1947
		#卸除暫存變數
1948
		unset($functionCommentStartKey);
1949
 
1950
		#取得回傳結果的陣列...
1951
		#依據開頭為 $result 來判斷...
1952
 
1953
		#涵式說明:
1954
		#取得多個字首一樣的字串,並回傳其字串。
1955
		#回傳的結果:
1956
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
1957
		#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
1958
		#$result["function"],當前執行的函數名稱.
1959
		#$result["returnString"],爲符合字首條件的字串陣列內容.
1960
		#$result["foundedKey"],找到的內容位於原本的哪一個元素.
1961
		#$result["argu"],使用的參數.
1962
		#必填參數:
1963
		$conf["search"]["getMeetConditionsStringMuti"]["checkString"]=$result["functionComment"];#要檢查的字串陣列
1964
		$conf["search"]["getMeetConditionsStringMuti"]["frontWord"]="#\$result";#用來檢查字首應該要有什麼字串
1965
		#用到的涵式:
1966
		#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
1967
		$returnVar=search::getMeetConditionsStringMulti($conf["search"]["getMeetConditionsStringMuti"]);
1968
		unset($conf["search"]["getMeetConditionsStringMuti"]);
1969
 
1970
		#如果執行失敗
1971
		if($returnVar["status"]==="false"){
1972
 
1973
			#設定執行錯誤識別
1974
			$result["status"]="false";
1975
 
1976
			#設定執行錯誤提示
1977
			$result["error"]=$returnVar;
1978
 
1979
			#回傳結果 
1980
			return $result;
1981
 
1982
			}#if end
1983
 
1984
		#如果有符合的關鍵字
1985
		if($returnVar["founded"]==="true"){
1986
 
1987
			#用「,」區隔回傳變數名稱與註解
1988
			#涵式說明:
1989
			#將多個固定格式的字串分開,並回傳分開的結果
1990
			#回傳的參數:
1991
			#$result[status],執行成功與否,若爲0,代表執行成功,若爲1代表執失敗。
1992
			#$result["spiltString"][$i]["oriStr"],爲第i個字串的原始內容
1993
			#$result["spiltString"][$i]["dataArray"],爲第($i+1)個字串分割後的字串陣列
1994
			#$result["spiltString"][$i]["dataArray"][$j],爲第($i+1)的分割好的字串的第($j)段內容
1995
			#$result["spiltString"][$i]["dataCounts"],爲第($i+1)個字串分割後總共分成幾段
1996
			#必填參數:
1997
			$conf["stringProcess"]["spiltMutiString"]["stringIn"]=$returnVar["returnString"];#要處理的字串陣列。
1998
			$conf["stringProcess"]["spiltMutiString"]["spiltSymbol"]=",";#爲要以哪個符號作爲分割。
1999
			$spiltedVarNameAndComment=stringProcess::spiltMutiString($conf["stringProcess"]["spiltMutiString"]);
2000
			unset($conf["stringProcess"]["spiltMutiString"]);
2001
 
2002
			#如果執行失敗
2003
			if($spiltedVarNameAndComment["status"]==="false"){
2004
 
2005
				#設定執行錯誤識別
2006
				$result["status"]="false";
2007
 
2008
				#設定執行錯誤提示
2009
				$result["error"]=$spiltedVarNameAndComment;
2010
 
2011
				#回傳結果 
2012
				return $result;
2013
 
2014
				}
2015
 
2016
			#針對每行分割的回傳變數名稱
2017
			for($i=0;$i<count($spiltedVarNameAndComment["spiltString"]);$i++){
2018
 
2019
				#將「#」符號剔除
2020
				#涵式說明:
2021
				#處理多個字串避免網頁出錯
2022
				#回傳的結果:
2023
				#$result["status"],"true"代表執行成功,"false"代表執行失敗。
2024
				#$result["error"],錯誤訊息
2025
				#$result["processedStrArray"],處理好的字串陣列
2026
				#必填參數:
2027
				$conf["stringProcess"]["correctMutiStrCharacter"]["stringIn"]=array($spiltedVarNameAndComment["spiltString"][$i]["dataArray"][0]);#爲要處理的字串陣列
2028
				#可省略的參數:
2029
				$conf["stringProcess"]["correctMutiStrCharacter"]["selectedCharacter"]=array("#");#爲被選擇要處理的字串/字元,須爲陣列值。
2030
					#若不設定則預設爲要將這些字串作替換("<",">",";","=","//","'","$","%","&","|","/*","*\/","#")。
2031
					#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
2032
				#$conf["stringProcess"]["correctMutiStrCharacter"]["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
2033
				$processedStr=stringProcess::correctMutiStrCharacter($conf["stringProcess"]["correctMutiStrCharacter"]);
2034
				unset($conf["stringProcess"]["correctMutiStrCharacter"]);
2035
 
2036
				#取得沒有 # 的內容
2037
				$spiltedVarNameAndComment["spiltString"][$i]["dataArray"][0]=$processedStr["processedStrArray"][0];	
2038
 
2039
				}#for end
2040
 
2041
			#將回傳變數名稱與註解紀錄起來
2042
			foreach($spiltedVarNameAndComment["spiltString"] as $returnVar){
2043
 
2044
				#取得回傳的變數名稱
2045
				$result["return"]["name"][]=$returnVar["dataArray"][0];
2046
 
2047
				if(isset($returnVar["dataArray"][1])){
2048
 
2049
					#取得回傳的變數註解
2050
					$result["return"]["comment"][]=$returnVar["dataArray"][1];
2051
 
2052
					}#if end
2053
 
2054
				}#foreach end
2055
 
2056
			#依據回傳變數說明來判斷回傳的型態
2057
 
2058
			#如果回傳的變數名稱數量大於1
2059
			if(count($result["return"]["name"])>1){
2060
 
2061
				#則代表回傳的結果為array
2062
				$result["returnVarType"]="array";
2063
 
2064
				}#if end
2065
 
2066
			#反之其回傳的結果可能為string、int、float、double、boolean,目前先一律視為"string"
2067
			else{
2068
 
2069
				$result["returnVarType"]="string";
2070
 
2071
				}#else end
2072
 
2073
			}#if end
2074
 
2075
		#取得必填參數陣列...
2076
		#依據開頭為 #必填參數 來判斷...
2077
 
2078
		#涵式說明:
2079
		#取得多個字首一樣的字串,並回傳其字串。
2080
		#回傳的結果:
2081
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
2082
		#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
2083
		#$result["function"],當前執行的函數名稱.
2084
		#$result["returnString"],爲符合字首條件的字串陣列內容.
2085
		#$result["foundedKey"],找到的內容位於原本的哪一個元素.
2086
		#必填參數:
2087
		$conf["search"]["getMeetConditionsStringMuti"]["checkString"]=$result["functionComment"];#要檢查的字串陣列
2088
		#可省略參數:
2089
		#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
2090
		$conf["search"]["getMeetConditionsStringMuti"]["frontWord"]="#必填參數";
2091
		#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
2092
		#$conf["tailWord"]="";
2093
		$returnVar=search::getMeetConditionsStringMulti($conf["search"]["getMeetConditionsStringMuti"]);
2094
		unset($conf["search"]["getMeetConditionsStringMuti"]);
2095
 
2096
		#如果執行失敗
2097
		if($returnVar["status"]==="false"){
2098
 
2099
			#設定執行錯誤識別
2100
			$result["status"]="false";
2101
 
2102
			#設定執行錯誤提示
2103
			$result["error"]=$returnVar;
2104
 
2105
			#回傳結果 
2106
			return $result;
2107
 
2108
			}#if end
2109
 
2110
		#如果有找到必填參數的列
2111
		if($returnVar["founded"]==="false")
2112
		{
2113
			#設定執行錯誤識別
2114
			$result["status"]="false";
2115
 
2116
			#設定執行錯誤提示
2117
			$result["error"]=$returnVar;
2118
 
2119
			#回傳結果 
2120
			return $result;
2121
		}
2122
 
2123
		#必填變數的開始行
2124
		$mustBeFilledVarKeyStartPoint=$returnVar["foundedKey"][0];
2125
 
2126
		/*
2127
		#debug		
2128
		var_dump($mustBeFilledVarKeyStartPoint);
2129
		var_dump($result["functionComment"]);
2130
		exit;
2131
		*/ 
2132
 
2133
		#取得可省略的參數陣列...
2134
		#依據開頭為 #可省略參數 來判斷...
2135
 
2136
		#涵式說明:
2137
		#取得多個字首一樣的字串,並回傳其字串。
2138
		#回傳的結果:
2139
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
2140
		#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
2141
		#$result["function"],當前執行的函數名稱.
2142
		#$result["returnString"],爲符合字首條件的字串陣列內容.
2143
		#$result["foundedKey"],找到的內容位於原本的哪一個元素.
2144
		#必填參數:
2145
		$conf["search"]["getMeetConditionsStringMuti"]["checkString"]=$result["functionComment"];#要檢查的字串陣列
2146
		#可省略參數:
2147
		#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
2148
		$conf["search"]["getMeetConditionsStringMuti"]["frontWord"]="#可省略參數";
2149
		#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
2150
		#$conf["tailWord"]="";
2151
		$returnVar=search::getMeetConditionsStringMulti($conf["search"]["getMeetConditionsStringMuti"]);
2152
		unset($conf["search"]["getMeetConditionsStringMuti"]);
2153
 
2154
		#如果執行失敗
2155
		if($returnVar["status"]==="false"){
2156
 
2157
			#設定執行錯誤識別
2158
			$result["status"]="false";
2159
 
2160
			#設定執行錯誤提示
2161
			$result["error"]=$returnVar;
2162
 
2163
			#回傳結果 
2164
			return $result;
2165
 
2166
			}#if end
2167
 
2168
		#如果有找到必填參數的列
2169
		if($returnVar["founded"]==="false"){
2170
 
2171
			#設定執行錯誤識別
2172
			$result["status"]="false";
2173
 
2174
			#設定執行錯誤提示
2175
			$result["error"]=$returnVar;
2176
 
2177
			#回傳結果 
2178
			return $result;
2179
 
2180
			}#if end
2181
 
2182
		#可省略參數的開始行
2183
		$skipableVarKeyStartPoint=$returnVar["foundedKey"][0];	
2184
 
2185
		#取得參考資料來源
2186
		#依據開頭為 #參考資料: 來判斷...
2187
 
2188
		#涵式說明:
2189
		#取得多個字首一樣的字串,並回傳其字串。
2190
		#回傳的結果:
2191
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
2192
		#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
2193
		#$result["function"],當前執行的函數名稱.
2194
		#$result["returnString"],爲符合字首條件的字串陣列內容.
2195
		#$result["foundedKey"],找到的內容位於原本的哪一個元素.
2196
		#必填參數:
2197
		$conf["search"]["getMeetConditionsStringMuti"]["checkString"]=$result["functionComment"];#要檢查的字串陣列
2198
		#可省略參數:
2199
		#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
2200
		$conf["search"]["getMeetConditionsStringMuti"]["frontWord"]="#參考資料";
2201
		#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
2202
		#$conf["tailWord"]="";
2203
		$getMeetConditionsStringMulti=search::getMeetConditionsStringMulti($conf["search"]["getMeetConditionsStringMuti"]);
2204
		unset($conf["search"]["getMeetConditionsStringMuti"]);
2205
 
2206
		#debug
2207
		#var_dump($getMeetConditionsStringMulti);
2208
		#exit;
2209
 
2210
		#如果執行失敗
2211
		if($getMeetConditionsStringMulti["status"]==="false"){
2212
 
2213
			#設定執行錯誤識別
2214
			$result["status"]="false";
2215
 
2216
			#設定執行錯誤提示
2217
			$result["error"]=$getMeetConditionsStringMulti;
2218
 
2219
			#回傳結果 
2220
			return $result;
2221
 
2222
			}#if end
2223
 
2224
		#如果沒有找到備註的列
2225
		if($getMeetConditionsStringMulti["founded"]==="false"){
2226
 
2227
			#設定執行錯誤識別
2228
			$result["status"]="false";
2229
 
2230
			#設定執行錯誤提示
2231
			$result["error"]=$getMeetConditionsStringMulti;
2232
 
2233
			#回傳結果 
2234
			return $result;
2235
 
2236
			}#if end
2237
 
2238
		#參考資料的開始行
2239
		$referenceVarKeyStartPoint=$getMeetConditionsStringMulti["foundedKey"][0];
2240
 
2241
		#取得備註陣列
2242
		#依據開頭為 #備註: 來判斷...
2243
 
2244
		#涵式說明:
2245
		#取得多個字首一樣的字串,並回傳其字串。
2246
		#回傳的結果:
2247
		#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
2248
		#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
2249
		#$result["function"],當前執行的函數名稱.
2250
		#$result["returnString"],爲符合字首條件的字串陣列內容.
2251
		#$result["foundedKey"],找到的內容位於原本的哪一個元素.
2252
		#必填參數:
2253
		$conf["search"]["getMeetConditionsStringMuti"]["checkString"]=$result["functionComment"];#要檢查的字串陣列
2254
		#可省略參數:
2255
		#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
2256
		$conf["search"]["getMeetConditionsStringMuti"]["frontWord"]="#備註";
2257
		#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
2258
		#$conf["tailWord"]="";
2259
		$getMeetConditionsStringMulti=search::getMeetConditionsStringMulti($conf["search"]["getMeetConditionsStringMuti"]);
2260
		unset($conf["search"]["getMeetConditionsStringMuti"]);
2261
 
2262
		#debug
2263
		#var_dump($getMeetConditionsStringMulti);
2264
		#exit;
2265
 
2266
		#如果執行失敗
2267
		if($getMeetConditionsStringMulti["status"]==="false"){
2268
 
2269
			#設定執行錯誤識別
2270
			$result["status"]="false";
2271
 
2272
			#設定執行錯誤提示
2273
			$result["error"]=$getMeetConditionsStringMulti;
2274
 
2275
			#回傳結果 
2276
			return $result;
2277
 
2278
			}#if end
2279
 
2280
		#如果沒有找到備註的列
2281
		if($getMeetConditionsStringMulti["founded"]==="false"){
2282
 
2283
			#設定執行錯誤識別
2284
			$result["status"]="false";
2285
 
2286
			#設定執行錯誤提示
2287
			$result["error"]=$getMeetConditionsStringMulti;
2288
 
2289
			#回傳結果 
2290
			return $result;
2291
 
2292
			}#if end
2293
 
2294
		#備註的開始行
2295
		$noteVarKeyStartPoint=$getMeetConditionsStringMulti["foundedKey"][0];
2296
 
2297
		#取得必填參數的內容
2298
 
2299
		#初始化必填參數的列
2300
		$mustBeFilledVar=array();	
2301
 
2302
		#從 $result["functionStructionEndPoint"] 元素往前讀,只讀取必填參數.
2303
		for($i=$mustBeFilledVarKeyStartPoint;$i<$skipableVarKeyStartPoint;$i++){
2304
 
2305
			#針對每個必填參數行,檢查是否為"#"開頭
2306
			$line=$result["functionComment"][$i];
2307
 
2308
			#涵式說明:
2309
			#取得多個字首一樣的字串,並回傳其字串。
2310
			#回傳的結果:
2311
			#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
2312
			#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
2313
			#$result["function"],當前執行的函數名稱.
2314
			#$result["returnString"],爲符合字首條件的字串陣列內容.
2315
			#$result["foundedKey"],找到的內容位於原本的哪一個元素.
2316
			#必填參數:
2317
			$conf["search"]["getMeetConditionsStringMuti"]["checkString"]=array($line);#要檢查的字串陣列
2318
			#可省略參數:
2319
			#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
2320
			$conf["search"]["getMeetConditionsStringMuti"]["frontWord"]="#";
2321
			#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
2322
			#$conf["tailWord"]="";
2323
			$returnVar=search::getMeetConditionsStringMulti($conf["search"]["getMeetConditionsStringMuti"]);
2324
			unset($conf["search"]["getMeetConditionsStringMuti"]);
2325
 
2326
			#如果執行失敗
2327
			if($returnVar["status"]==="false"){
2328
 
2329
				#設定執行錯誤識別
2330
				$result["status"]="false";
2331
 
2332
				#設定執行錯誤提示
2333
				$result["error"]=$returnVar;
2334
 
2335
				#回傳結果 
2336
				return $result;
2337
 
2338
				}#if end
2339
 
2340
			#如果沒有找到必填參數的列
2341
			if($returnVar["founded"]==="false"){
2342
 
2343
				#跳到下一個迴圈
2344
				continue;
2345
 
2346
				}#if end
2347
 
2348
			#取得必填參數名稱與解說的列
2349
			$mustBeFilledVar[]=$returnVar["returnString"][0];
2350
 
2351
			}#for end
2352
 
2353
		#針對每一列
2354
		foreach($mustBeFilledVar as $key=>$line){
2355
 
2356
			#剔除開頭的 "#"
2357
			#涵式說明:
2358
			#處理字串避免網頁出錯
2359
			#回傳的結果:
2360
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2361
			#$result["function"],當前執行的函數.
2362
			#$result["content"],爲處理好的字串.
2363
			#$result["error"],錯誤訊息陣列.
2364
			#$result["argu"],使用的參數. 
2365
			#必填參數:
2366
			$conf["stringProcess::correctCharacter"]["stringIn"]=$line;#爲要處理的字串
2367
			#可省略的參數:
2368
			$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("#");#爲被選擇要處理的字串/字元,須爲陣列值。
2369
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
2370
				#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
2371
			#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
2372
			#備註:
2373
			#無.
2374
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
2375
			unset($conf["stringProcess::correctCharacter"]);
2376
 
2377
			#如果執行失敗
2378
			if($correctCharacter["status"]==="false"){
2379
 
2380
				#設定執行錯誤識別
2381
				$result["status"]="false";
2382
 
2383
				#設定執行錯誤提示
2384
				$result["error"]=$correctCharacter;
2385
 
2386
				#回傳結果 
2387
				return $result;
2388
 
2389
				}#if end
2390
 
2391
 
2392
			#取得剔除開頭 # 的內容列
2393
			$mustBeFilledVar[$key]=$correctCharacter["content"];
2394
 
2395
			}#foreach end
2396
 
2397
		#針對每一列
2398
		foreach($mustBeFilledVar as $key=>$line){
2399
 
2400
			#涵式說明:
2401
			#將固定格式的字串分開,並回傳分開的結果。
2402
			#回傳結果:
2403
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2404
			#$result["error"],錯誤訊息陣列
2405
			#$result["function"],當前執行的函數名稱.
2406
			#$result["argu"],使用的參數.
2407
			#$result["oriStr"],要分割的原始字串內容
2408
			#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
2409
			#$result["dataCounts"],爲總共分成幾段
2410
			#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
2411
			#必填參數:
2412
			$conf["stringProcess::spiltString"]["stringIn"]=$line;#要處理的字串。
2413
			$conf["stringProcess::spiltString"]["spiltSymbol"]=",";#爲以哪個符號作爲分割
2414
			#可省略參數:
2415
			#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
2416
			$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
2417
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
2418
			unset($conf["stringProcess::spiltString"]);
2419
 
2420
			#如果執行失敗
2421
			if($spiltString["status"]==="false"){
2422
 
2423
				#設定執行錯誤識別
2424
				$result["status"]="false";
2425
 
2426
				#設定執行錯誤提示
2427
				$result["error"]=$spiltString;
2428
 
2429
				#回傳結果 
2430
				return $result;
2431
 
2432
				}#if end
2433
 
2434
			#如果執行失敗
2435
			if($spiltString["found"]==="false"){
2436
 
2437
				#移除之
2438
				unset($mustBeFilledVar[$key]);
2439
 
2440
				#換下一列
2441
				continue;
2442
 
2443
				}#if end
2444
 
2445
			#取得名稱屬性跟備註
2446
			$mustBeFilledVar[$key]=array();
2447
			$mustBeFilledVar[$key]["name"]=$spiltString["dataArray"][0];
2448
			$mustBeFilledVar[$key]["type"]=$spiltString["dataArray"][1];
2449
 
2450
			#如果沒有備註
2451
			if(!isset($spiltString["dataArray"][2]))
2452
			{
2453
				#設置為空字串
2454
				$spiltString["dataArray"][2]="";
2455
 
2456
			}#if end
2457
 
2458
			$mustBeFilledVar[$key]["note"]=$spiltString["dataArray"][2];
2459
 
2460
			#debug
2461
			if(!isset($spiltString["dataArray"][2])){
2462
 
2463
				#初始化結果
2464
				$result=array();
2465
 
2466
				#設置執行錯誤
2467
				$result["status"]="false";
2468
 
2469
				#設置錯誤訊息
2470
				$result["error"]=$line;
2471
 
2472
				#設置錯誤訊息
2473
				$result["error"][]="未按照「參數名稱,參數形態,參數說明」的格式撰寫";
2474
 
2475
				#回傳結果
2476
				return $result;
2477
 
2478
				}#if end
2479
 
2480
			#針對後面的說明
2481
			for($i=3;$i<$spiltString["dataCounts"];$i++){
2482
 
2483
				#傳接起來
2484
				$mustBeFilledVar[$key]["note"]=$mustBeFilledVar[$key]["note"].",".$spiltString["dataArray"][$i];
2485
 
2486
				}#for end
2487
 
2488
			}#foreach end
2489
 
2490
		/*
2491
		#debug
2492
		var_dump($mustBeFilledVar);
2493
		exit;
2494
		*/
2495
 
2496
		#取得必填的參數
2497
		$result["mustBeFilledVar"]=$mustBeFilledVar;
2498
 
2499
		#初始化儲存可省略的參數
2500
		$skipableVar=array();
2501
 
2502
		/*
2503
		#debug
2504
		var_dump($skipableVarKeyStartPoint);
2505
		var_dump($noteVarKeyStartPoint);		
2506
		exit;
2507
		*/
2508
 
2509
		#從 $skipableVarKeyStartPoint 元素往後讀,只讀取可省略參數.
2510
		for($i=$skipableVarKeyStartPoint;$i<$referenceVarKeyStartPoint;$i++){
2511
 
2512
			#另存每個可省略參數行
2513
			$skipableVar[]=$result["functionComment"][$i];
2514
 
2515
			}#for end
2516
 
2517
		#debug
2518
		#var_dump($skipableVar);
2519
		#exit;
2520
 
2521
		#暫存真的可省略變數與解說
2522
		$newSkipableVar=array();
2523
 
2524
		#針對每個可略變數與解說
2525
		for($i=1;$i<count($skipableVar);$i=$i+2){
2526
 
2527
			#取得真的可省略變數與名稱
2528
			$newSkipableVar[]=$skipableVar[$i];
2529
 
2530
			}#for end
2531
 
2532
		#置換內容
2533
		$skipableVar=$newSkipableVar;
2534
 
2535
		/*
2536
		#debug
2537
		var_dump($skipableVar);
2538
		exit;
2539
		*/
2540
 
2541
		#針對每一列
2542
		foreach($skipableVar as $key=>$line){
2543
 
2544
			#剔除開頭的 "#"
2545
			#涵式說明:
2546
			#處理字串避免網頁出錯
2547
			#回傳的結果:
2548
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2549
			#$result["function"],當前執行的函數.
2550
			#$result["content"],爲處理好的字串.
2551
			#$result["error"],錯誤訊息陣列.
2552
			#$result["argu"],使用的參數. 
2553
			#必填參數:
2554
			$conf["stringProcess::correctCharacter"]["stringIn"]=$line;#爲要處理的字串
2555
			#可省略的參數:
2556
			$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("#");#爲被選擇要處理的字串/字元,須爲陣列值。
2557
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
2558
				#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
2559
			#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
2560
			#備註:
2561
			#無.
2562
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
2563
			unset($conf["stringProcess::correctCharacter"]);
2564
 
2565
			#如果執行失敗
2566
			if($correctCharacter["status"]==="false"){
2567
 
2568
				#設定執行錯誤識別
2569
				$result["status"]="false";
2570
 
2571
				#設定執行錯誤提示
2572
				$result["error"]=$correctCharacter;
2573
 
2574
				#回傳結果 
2575
				return $result;
2576
 
2577
				}#if end
2578
 
2579
 
2580
			#取得剔除開頭 # 的內容列
2581
			$skipableVar[$key]=$correctCharacter["content"];
2582
 
2583
			}#foreach end	
2584
 
2585
		#debug
2586
		#var_dump($skipableVar);
2587
		#exit;	
2588
 
2589
		#針對每一列
2590
		foreach($skipableVar as $key=>$line){
2591
 
2592
			#涵式說明:
2593
			#將固定格式的字串分開,並回傳分開的結果。
2594
			#回傳結果:
2595
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2596
			#$result["error"],錯誤訊息陣列
2597
			#$result["function"],當前執行的函數名稱.
2598
			#$result["argu"],使用的參數.
2599
			#$result["oriStr"],要分割的原始字串內容
2600
			#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
2601
			#$result["dataCounts"],爲總共分成幾段
2602
			#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
2603
			#必填參數:
2604
			$conf["stringProcess::spiltString"]["stringIn"]=$line;#要處理的字串。
2605
			$conf["stringProcess::spiltString"]["spiltSymbol"]=",";#爲以哪個符號作爲分割
2606
			#可省略參數:
2607
			#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
2608
			$conf["stringProcess::spiltString"]["allowEmptyStr"]="false";
2609
			$spiltString=stringProcess::spiltString($conf["stringProcess::spiltString"]);
2610
			unset($conf["stringProcess::spiltString"]);
2611
 
2612
			#如果執行失敗
2613
			if($spiltString["status"]==="false"){
2614
 
2615
				#設定執行錯誤識別
2616
				$result["status"]="false";
2617
 
2618
				#設定執行錯誤提示
2619
				$result["error"]=$spiltString;
2620
 
2621
				#回傳結果 
2622
				return $result;
2623
 
2624
				}#if end
2625
 
2626
			#如果執行失敗
2627
			if($spiltString["found"]==="false"){
2628
 
2629
				#移除之
2630
				unset($mustBeFilledVar[$key]);
2631
 
2632
				#換下一列
2633
				continue;
2634
 
2635
				}#if end
2636
 
2637
			#如果缺乏參數名稱位或屬性
2638
			if(!isset($spiltString["dataArray"][0]) || !isset($spiltString["dataArray"][1])){
2639
 
2640
				#設定執行錯誤識別
2641
				$result["status"]="false";
2642
 
2643
				#設定執行錯誤提示
2644
				$result["error"]=$spiltString;
2645
 
2646
				#回傳結果 
2647
				return $result;
2648
 
2649
				}#if end
2650
 
2651
			#取得名稱屬性跟備註
2652
			$skipableVar[$key]=array();
2653
			$skipableVar[$key]["name"]=$spiltString["dataArray"][0];
2654
			$skipableVar[$key]["type"]=$spiltString["dataArray"][1];
2655
 
2656
			#如果沒有備註
2657
			if(!isset($spiltString["dataArray"][2]))
2658
			{
2659
				#設置為空字串.
2660
				$spiltString["dataArray"][2]="";
2661
			}
2662
 
2663
			$skipableVar[$key]["note"]=$spiltString["dataArray"][2];
2664
 
2665
			#針對後面的說明
2666
			for($i=3;$i<$spiltString["dataCounts"];$i++){
2667
 
2668
				#串接起來
2669
				$skipableVar[$key]["note"]=$skipableVar[$key]["note"].",".$spiltString["dataArray"][$i];
2670
 
2671
				}#for end
2672
 
2673
			}#foreach end
2674
 
2675
		#debug
2676
		#var_dump($skipableVar);
2677
		#exit;	
2678
 
2679
		#取得可省略參數的內容
2680
		$result["skipableVar"]=$skipableVar;
2681
 
2682
		#初始化儲存參考資料的陣列
2683
		$reference=array();
2684
 
2685
		#從 $result["referenceVarKeyStartPoint"] 元素往後讀,只讀取備註.
2686
		for($i=$referenceVarKeyStartPoint+1;$i<$noteVarKeyStartPoint;$i++){
2687
 
2688
			#另存每個可省略參數行
2689
			$reference[]=$result["functionComment"][$i];
2690
 
2691
			}#for end
2692
 
2693
		#針對每一列
2694
		foreach($reference as $key=>$line){
2695
 
2696
			#剔除開頭的 "#"
2697
			#涵式說明:
2698
			#處理字串避免網頁出錯
2699
			#回傳的結果:
2700
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2701
			#$result["function"],當前執行的函數.
2702
			#$result["content"],爲處理好的字串.
2703
			#$result["error"],錯誤訊息陣列.
2704
			#$result["argu"],使用的參數. 
2705
			#必填參數:
2706
			$conf["stringProcess::correctCharacter"]["stringIn"]=$line;#爲要處理的字串
2707
			#可省略的參數:
2708
			$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("#");#爲被選擇要處理的字串/字元,須爲陣列值。
2709
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
2710
				#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
2711
			#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
2712
			#備註:
2713
			#無.
2714
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
2715
			unset($conf["stringProcess::correctCharacter"]);
2716
 
2717
			#如果執行失敗
2718
			if($correctCharacter["status"]==="false"){
2719
 
2720
				#設定執行錯誤識別
2721
				$result["status"]="false";
2722
 
2723
				#設定執行錯誤提示
2724
				$result["error"]=$correctCharacter;
2725
 
2726
				#回傳結果 
2727
				return $result;
2728
 
2729
				}#if end
2730
 
2731
 
2732
			#取得剔除開頭 # 的內容列
2733
			$reference[$key]=$correctCharacter["content"];
2734
 
2735
			}#foreach end	
2736
 
2737
		#取得備註的內容
2738
		$result["reference"]=$reference;
2739
 
2740
		#初始化儲存備註的陣列
2741
		$note=array();
2742
 
2743
		#從 $result["noteVarKeyStartPoint"] 元素往後讀,只讀取備註.
2744
		for($i=$noteVarKeyStartPoint+1;$i<count($result["functionComment"])-1;$i++){
2745
 
2746
			#另存每個可省略參數行
2747
			$note[]=$result["functionComment"][$i];
2748
 
2749
			}#for end
2750
 
2751
		#將 $result["functionComment"] 陣列變成字串.
2752
		#函式說明:
2753
		#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
2754
		#回傳的結果:
2755
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2756
		#$result["function"],當前執行的function名稱
2757
		#$result["error"],錯誤訊息陣列.
2758
		#$result["content"],處理好的字串.
2759
		#$result["argu"],使用的參數.
2760
		#必填參數:
2761
		#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.
2762
		$conf["arrays::arrayToString"]["inputArray"]=$result["functionComment"];
2763
		#可省略參數:
2764
		#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;
2765
		$conf["arrays::arrayToString"]["spiltSymbol"]=PHP_EOL;
2766
		#$conf["skipEnd"],字串,結尾是否不要加上符號,預設為"false",要加上符號,"true"代表不要加上符號。
2767
		#$conf["skipEnd"]="";
2768
		#參考資料:
2769
		#無.
2770
		#備註:
2771
		#無.
2772
		$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
2773
		unset($conf["arrays::arrayToString"]);
2774
 
2775
		#如果執行失敗
2776
		if($arrayToString["status"]==="false"){
2777
 
2778
			#設定執行錯誤識別
2779
			$result["status"]="false";
2780
 
2781
			#設定執行錯誤提示
2782
			$result["error"]=$arrayToString;
2783
 
2784
			#回傳結果 
2785
			return $result;
2786
 
2787
			}#if end
2788
 
2789
		#轉存為字串
2790
		$result["functionComment"]=$arrayToString["content"];
2791
 
2792
		#針對每一列
2793
		foreach($note as $key=>$line){
2794
 
2795
			#剔除開頭的 "#"
2796
			#涵式說明:
2797
			#處理字串避免網頁出錯
2798
			#回傳的結果:
2799
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2800
			#$result["function"],當前執行的函數.
2801
			#$result["content"],爲處理好的字串.
2802
			#$result["error"],錯誤訊息陣列.
2803
			#$result["argu"],使用的參數. 
2804
			#必填參數:
2805
			$conf["stringProcess::correctCharacter"]["stringIn"]=$line;#爲要處理的字串
2806
			#可省略的參數:
2807
			$conf["stringProcess::correctCharacter"]["selectedCharacter"]=array("#");#爲被選擇要處理的字串/字元,須爲陣列值。
2808
				#若不設定則預設爲要將這些字串作替換 ("<",">","=","//","'","$","%","&","|","/*","*","#","\"").
2809
				#特殊字元,「\n」代表換行,「\t」代表tab鍵的間隔
2810
			#$conf["changeTo"]=array();#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串).
2811
			#備註:
2812
			#無.
2813
			$correctCharacter=stringProcess::correctCharacter($conf["stringProcess::correctCharacter"]);
2814
			unset($conf["stringProcess::correctCharacter"]);
2815
 
2816
			#如果執行失敗
2817
			if($correctCharacter["status"]==="false"){
2818
 
2819
				#設定執行錯誤識別
2820
				$result["status"]="false";
2821
 
2822
				#設定執行錯誤提示
2823
				$result["error"]=$correctCharacter;
2824
 
2825
				#回傳結果 
2826
				return $result;
2827
 
2828
				}#if end
2829
 
2830
 
2831
			#取得剔除開頭 # 的內容列
2832
			$note[$key]=$correctCharacter["content"];
2833
 
2834
			}#foreach end	
2835
 
2836
		#取得備註的內容
2837
		$result["note"]=$note;
2838
 
2839
		#初始化函式的程式內容.
2840
		$result["content"]="";
2841
 
2842
		#針對函式的定義開始行,往後逐行執行.
2843
		for($i=$result["functionStructionEndPoint"];$i<$fileContent["lineCount"];$i++){
2844
 
2845
			#暫存該行程式的內容
2846
			$line=$fileContent["fileContent"][$i];
2847
 
2848
			#如果無任何內容
2849
			if(empty($line)){
2850
 
2851
				#串接程式的內容
2852
				$result["content"]=$result["content"].$line;
2853
 
2854
				#換下一行
2855
				continue;
2856
 
2857
				}#if end
2858
 
2859
			#判斷是否為函式定義的結束.
2860
			#函式說明:
2861
			#取得符合特定字首與字尾的字串
2862
			#回傳結果:
2863
			#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
2864
			#$result["function"],當前執行的函數名稱.
2865
			#$result["error"],錯誤訊息陣列.
2866
			#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
2867
			#$result["returnString"],爲符合字首條件的字串內容。
2868
			#$result["argu"],使用的參數.
2869
			#必填參數:
2870
			#$conf["checkString"],字串,要檢查的字串.
2871
			$conf["search::getMeetConditionsString"]["checkString"]=$line;
2872
			#可省略參數:
2873
			#$conf["frontWord"],字串,用來檢查字首應該要有什麼字串,預設不指定.
2874
			$conf["search::getMeetConditionsString"]["frontWord"]="\t\t}#function";
2875
			#$conf["tailWord"],字串,用來檢查字尾應該要有什麼字串,預設不指定.
2876
			#$conf["tailWord"]="";
2877
			#參考資料:
2878
			#str_spilt(),可以將字串依照字母分割成一個個陣列字串。
2879
			#備註:
2880
			#無.
2881
			$getMeetConditionsString=search::getMeetConditionsString($conf["search::getMeetConditionsString"]);
2882
			unset($conf["search::getMeetConditionsString"]);
2883
 
2884
			#如果處理失敗
2885
			if($getMeetConditionsString["status"]==="false"){
2886
 
2887
				#設置執行錯誤的識別
2888
				$result["status"]="false";
2889
 
2890
				#設置執行錯誤的訊息
2891
				$result["error"]=$getMeetConditionsString;
2892
 
2893
				#回傳結果
2894
				return $result;
2895
 
2896
				}#if end
2897
 
2898
			#串接程式的內容
2899
			$result["content"]=$result["content"].$line;
2900
 
2901
			#如果找到函式的結尾
2902
			if($getMeetConditionsString["founded"]==="true"){
2903
 
2904
				#跳出迴圈
2905
				break;
2906
 
2907
				}#if end
2908
 
2909
			}#for end
2910
 
2911
		#值行到這邊執行成功
2912
		$result["status"]="true";
2913
 
2914
		#回傳節果
2915
		return $result;
2916
 
2917
		}#function getFunctionConstruction end
2918
 
2919
	/*
2920
	#函式說明:
2921
	#取得多個函式的結構
2922
	#回傳結果:
2923
	#$result["status"],執行是否成功"true"代表執行成功,"false"代表執行失敗
2924
	#$result["error"],錯誤訊息陣列
2925
	#$result["function"],當前執行的函數名稱.
2926
	#$result["comment"],每個函式說明的陣列
2927
	#$result["argvType"],每個函式傳入參數型態的陣列,""表示不用參數
2928
	#$result["returnVarType"],每個函式回傳變數型態的陣列,目前尚無法判斷其型態為string、int、float、double、boolean的哪一個,所以先一律視為"string"
2929
	#$result["return"]["name"][$i],第$i+1個函式回傳變數名稱的陣列
2930
	#$result["return"]["comment"][$i],第$i+1個函式回傳變數註解的陣列
2931
	#$result["mustBeFilled"]["dataCount"][$j],第j+1個函式不可省略參數數量的陣列 
2932
	#$result["optionalFilled"]["dataCount"][$k],第$k+1每個函式可省略參數數量的陣列
2933
	#$result["mustBeFilled"]["name"][$j],第$j+1個函式不可省略參數的陣列
2934
	#$result["mustBeFilled"]["comment"][$j],第$j+1個函式不可省略參數註解的陣列
2935
	#$result["optionalFilled"]["name"][$k],第$k+1個函式可省略參數的陣列
2936
	#$result["optionalFilled"]["comment"][$k],第$k+1個函式可省略參數註解的陣列
2937
	#$result["reference"]["addr"][$l],第$l+1個函式參考資料網址的陣列
2938
	#$result["reference"]["comment"][$l],第$l+1個函式參考資料說明的陣列
2939
	#必填參數:
2940
	#$conf["phpFileAddress"],字串,含有函式內容的php檔案位置與名稱
2941
	$conf["phpFileAddress"]="";
2942
	#$conf["functionName"],字串陣列,函式的名稱陣列.
2943
	$conf["functionName"]="array("");
2944
	#$conf["fileArgu"],字串,__FILE__的內容.
2945
	$conf["fileArgu"]=__FILE__;
2946
	#可省略參數:
2947
	#無.
2948
	#參考資料:
2949
	#無.
2950
	#備註:
2951
	#目前尚未開發完畢.
2952
	*/
2953
	public static function getMutiFunctionConstruction(&$conf){
2954
 
2955
		#初始化要回傳的內容
2956
		$result=array();
2957
 
2958
		#取得當前函數的名稱
2959
		$result["function"]=__FUNCTION__;
2960
 
2961
		#如果 $conf 不為陣列
2962
		if(gettype($conf)!="array"){
2963
 
2964
			#設置執行失敗
2965
			$result["status"]="false";
2966
 
2967
			#設置執行錯誤訊息
2968
			$result["error"][]="\$conf變數須為陣列形態";
2969
 
2970
			#如果傳入的參數為 null
2971
			if($conf==null){
2972
 
2973
				#設置執行錯誤訊息
2974
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
2975
 
2976
				}#if end
2977
 
2978
			#回傳結果
2979
			return $result;
2980
 
2981
			}#if end
2982
 
2983
		#檢查參數
2984
		#函式說明:
2985
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
2986
		#回傳結果:
2987
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
2988
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
2989
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
2990
		#必填寫的參數:
2991
		$conf["variableCheck"]["isexistMuti"]["varInput"]=$conf;#要檢查的陣列變數
2992
		$conf["variableCheck"]["isexistMuti"]["variableCheck"]=array("phpFileAddress","functionName","fileArgu");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
2993
		#可以省略的參數:
2994
		$conf["variableCheck"]["isexistMuti"]["variableType"]=array("string","array","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
2995
		$conf["variableCheck"]["isexistMuti"]["canBeEmptyString"]="true";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
2996
		$checkResult=variableCheck::isexistMulti($conf["variableCheck"]["isexistMuti"]);
2997
		unset($conf["variableCheck"]["isexistMuti"]);
2998
 
2999
		# 如果 $checkResult["status"] 為 "fasle"
3000
		if($checkResult["status"]=="false"){
3001
 
3002
			#設置執行錯誤的識別
3003
			$result["status"]="false";
3004
 
3005
			#設置執行錯誤的訊息
3006
			$result["error"]=$checkResult;
3007
 
3008
			#回傳結果
3009
			return $result;
3010
 
3011
			}#if end
3012
 
3013
		# 如果 $checkResult["passed"] 為 "fasle"
3014
		if($checkResult["passed"]=="false"){
3015
 
3016
			#設置執行錯誤的識別
3017
			$result["status"]="false";
3018
 
3019
			#設置執行錯誤的訊息
3020
			$result["error"]=$checkResult;
3021
 
3022
			#回傳結果
3023
			return $result;
3024
 
3025
			}#if end
3026
 
3027
		#針對每個要解析的函式
3028
		foreach($conf["functionName"] as $functionName){
3029
 
3030
			#debug
3031
			#var_dump($functionName);
3032
 
3033
			#如果涵式名稱是 "empty"
3034
			if($functionName==="empty"){
3035
 
3036
				#跳過
3037
				continue;
3038
 
3039
				}#if end
3040
 
3041
			#函式說明:
3042
			#取得函式的結構
3043
			#回傳的結果:
3044
			#$result["status"],執行是否成功"true"代表執行成功,"false"代表執行失敗
3045
			#$result["error"],錯誤訊息陣列
3046
			#$result["comment"],函式說明
3047
			#$result["argvType"],傳入參數的型態,null表示不用參數
3048
			#$result["returnVarType"],回傳的變數型態,目前尚無法判斷其型態為string、int、float、double、boolean的哪一個,所以先一律視為"string"
3049
			#$result["return"]["name"],回傳的變數名稱
3050
			#$result["return"]["comment"],回傳的變數註解
3051
			#$result["mustBeFilled"]["dataCount"],不可省略的參數陣列元素數量 
3052
			#$result["optionalFilled"]["dataCount"],可省略的參數陣列元素數量
3053
			#$result["mustBeFilled"]["name"],不可省略的參數陣列
3054
			#$result["mustBeFilled"]["comment"],不可省略的參數註解陣列
3055
			#$result["optionalFilled"]["name"],可省略的參數陣列
3056
			#$result["optionalFilled"]["comment"],可省略的參數註解陣列
3057
			#$result["reference"]["addr"],參考資料的網址
3058
			#$result["reference"]["comment"],參考資料的說明
3059
			#必填參數:
3060
			$conf["phpLib"]["getFunctionConstruction"]["phpFileAddress"]=$conf["phpFileAddress"];#含有函式內容的php檔案位置與名稱
3061
			$conf["phpLib"]["getFunctionConstruction"]["functionName"]=$functionName;#函式的名稱
3062
			$conf["phpLib"]["getFunctionConstruction"]["fileArgu"]=$conf["fileArgu"];#函式的名稱
3063
			#備註:目前尚未開發完畢
3064
			$functionConstruction=phpLib::getFunctionConstruction($conf["phpLib"]["getFunctionConstruction"]);
3065
			#var_dump($conf["phpLib"]["getFunctionConstruction"]);
3066
			unset($conf["phpLib"]["getFunctionConstruction"]);
3067
 
3068
			#如果執行失敗
3069
			if($functionConstruction["status"]==="false"){
3070
 
3071
				#設置執行錯誤的識別
3072
				$result["status"]="false";
3073
 
3074
				#設置執行錯誤的訊息
3075
				$result["error"]=$functionConstruction;
3076
 
3077
				#回傳結果
3078
				return $result;
3079
 
3080
				}#if end
3081
 
3082
			#debug
3083
			#var_dump($functionConstruction);
3084
			#exit;
3085
 
3086
			#取得函式說明
3087
			$result["comment"][]=$functionConstruction["comment"];
3088
 
3089
			#取得函式傳入參數型態
3090
			$result["argvType"][]=$functionConstruction["argvType"];
3091
 
3092
			#取得函式回傳變數型態
3093
			$result["returnVarType"][]=$functionConstruction["returnVarType"];
3094
 
3095
			#取得函式回傳變數名稱陣列
3096
			$result["return"]["name"][]=$functionConstruction["return"]["name"];
3097
 
3098
			#取得函式回傳變數註解陣列
3099
			$result["return"]["comment"][]=$functionConstruction["return"]["comment"];
3100
 
3101
			}#foreach end		
3102
 
3103
		#執行到這邊代表執行成功
3104
 
3105
		#設置執行成功的識別
3106
		$result["status"]="true";
3107
 
3108
		#回傳結果
3109
		return $result;
3110
 
3111
		}#function getMutiFunctionConstruction end
3112
 
3113
	/*
3114
	#函式說明:
3115
	#提供將含有類別宣告的php檔案轉成類別圖的功能
3116
	#回傳結果:
3117
	#$result["status"],執行是否成功,"true"代表執行成功;"false"代表執行失敗。
3118
	#$result["error"],錯誤訊息陣列.
3119
	#$result["error"]["noFunction"],若為"true"則代表檔案裡面沒有涵式.
3120
	#$result["function"],當前執行的函數名稱.
3121
	#$result["diagramCode"],類別圖的網頁code
3122
	#必填參數:
3123
	#$conf["phpFileAddress"],字串,含有宣告類別的php檔案
3124
	$conf["phpFileAddress"]="";
3125
	#$conf["fileArgu"],字串,__FILE__的內容.
3126
	$conf["fileArgu"]=__FILE__;
3127
	#可省略參數:
3128
	#無.
3129
	#參考資料:
3130
	#無.
3131
	#備註:
3132
	#無.
3133
	*/
3134
	public static function classDiagramMaker(&$conf){
3135
 
3136
		#初始化要回傳的內容
3137
		$result=array();
3138
 
3139
		#取得當前函數的名稱
3140
		$result["function"]=__FUNCTION__;
3141
 
3142
		#如果 $conf 不為陣列
3143
		if(gettype($conf)!="array"){
3144
 
3145
			#設置執行失敗
3146
			$result["status"]="false";
3147
 
3148
			#設置執行錯誤訊息
3149
			$result["error"][]="\$conf變數須為陣列形態";
3150
 
3151
			#如果傳入的參數為 null
3152
			if($conf==null){
3153
 
3154
				#設置執行錯誤訊息
3155
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3156
 
3157
				}#if end
3158
 
3159
			#回傳結果
3160
			return $result;
3161
 
3162
			}#if end
3163
 
3164
		#初始化要暫存的函式結構陣列
3165
		$functionConstruction=array();
3166
 
3167
		#參數檢查
3168
		#檢查參數
3169
		#函式說明:
3170
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
3171
		#回傳結果:
3172
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
3173
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
3174
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
3175
		#必填寫的參數:
3176
		$conf["variableCheck"]["isexistMuti"]["varInput"]=$conf;#要檢查的陣列變數
3177
		$conf["variableCheck"]["isexistMuti"]["variableCheck"]=array("phpFileAddress","fileArgu");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
3178
		#可以省略的參數:
3179
		$conf["variableCheck"]["isexistMuti"]["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
3180
		$conf["variableCheck"]["isexistMuti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
3181
		$checkResult=variableCheck::isexistMulti($conf["variableCheck"]["isexistMuti"]);
3182
		unset($conf["variableCheck"]["isexistMuti"]);
3183
 
3184
		#如果 $checkResult["status"] 為 "fasle"
3185
		if($checkResult["status"]==="false"){
3186
 
3187
			#設置執行錯誤的識別
3188
			$result["status"]="false";
3189
 
3190
			#設置執行錯誤的訊息
3191
			$result["error"]=$checkResult;
3192
 
3193
			#回傳結果
3194
			return $result;
3195
 
3196
			}#if end
3197
 
3198
		#如果 $checkResult["passed"] 為 "fasle"
3199
		if($checkResult["passed"]==="false"){
3200
 
3201
			#設置執行錯誤的識別
3202
			$result["status"]="false";
3203
 
3204
			#設置執行錯誤的訊息
3205
			$result["error"]=$checkResult;
3206
 
3207
			#回傳結果
3208
			return $result;
3209
 
3210
			}#if end
3211
 
3212
		#函數說明:
3213
		#延長php的執行時間,每呼叫一次會初始化執行時間爲0,然後設定下次可以執行多久.
3214
		#回傳結果:
3215
		#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
3216
		#$result["error"],錯誤訊息陣列.
3217
		#$result["function"],當前執行的函數名稱.
3218
		#必填參數:
3219
		#$conf["sec"],整數,要延長多少執行時間,單位爲秒
3220
		$conf["config::delayRunTimeExectionMax"]["sec"]=300;
3221
		#參考資料:
3222
		#http://php.net/manual/en/function.set-time-limit.php
3223
		$delayRunTimeExectionMax=config::delayRunTimeExectionMax($conf["config::delayRunTimeExectionMax"]);
3224
		unset($conf["config::delayRunTimeExectionMax"]);
3225
 
3226
		#如果執行失敗
3227
		if($delayRunTimeExectionMax["status"]==="false"){
3228
 
3229
			#設定類別圖繪製失敗
3230
			$result["status"]="false";			
3231
 
3232
			#設定該檔案的類別圖繪製失敗提示
3233
			$result["error"]=$delayRunTimeExectionMax;
3234
 
3235
			#回傳結果
3236
			return $result;
3237
 
3238
			}#if end		
3239
 
3240
		#函式說明:
3241
		#取得php函式庫檔案裡面的結構
3242
		#回傳的結果:
3243
		#$result["status"],0表示取得成功;1表示取得失敗
3244
		#$result["namesapceCount"],命名空間的筆數
3245
		#$result["classCount"],類別的筆數
3246
		#$result["functionCount"],函式的筆數
3247
		#$result["namespace"],命名空間陣列 
3248
		#$result["class"],類別的陣列
3249
		#$result["function"],函式的陣列
3250
		#必填參數:
3251
		$conf["phpLib"]["getPhpLibConstruction"]["libFileAddress"]=$conf["phpFileAddress"];#要讀取的函式庫檔案位置
3252
		$conf["phpLib"]["getPhpLibConstruction"]["fileArgu"]=$conf["fileArgu"];
3253
		$classConstruction=phpLib::getPhpLibConstruction($conf["phpLib"]["getPhpLibConstruction"]);
3254
		unset($conf["phpLib"]["getPhpLibConstruction"]);
3255
 
3256
		#如果 $classConstruction["status"] 為 "fasle"
3257
		if($classConstruction["status"]==="false"){
3258
 
3259
			#設置執行錯誤的識別
3260
			$result["status"]="false";
3261
 
3262
			#設置執行錯誤的訊息
3263
			$result["error"]=$classConstruction;
3264
 
3265
			#回傳結果
3266
			return $result;
3267
 
3268
			}#if end			
3269
 
3270
		#如果裡面沒有函式
3271
		if($classConstruction["functionCount"]===0){
3272
 
3273
			#設置只有一個叫做emtpy的函數
3274
			$classConstruction["functions"][]["content"]="empty";
3275
 
3276
			}#if end
3277
 
3278
		#初始化記錄所有函數名稱
3279
		$funcs=array();
3280
 
3281
		#針對每個既有的函數名稱
3282
		foreach($classConstruction["functions"] as $funcStr){
3283
 
3284
			#記錄函數名稱
3285
			$funcs[]=$funcStr["content"];
3286
 
3287
			}#foreach end		
3288
 
3289
		#取得每個函式的結構
3290
		#函式說明:
3291
		#取得多個函式的結構
3292
		#回傳的結果:
3293
		#$result["status"],執行是否成功"true"代表執行成功,"false"代表執行失敗
3294
		#$result["error"],錯誤訊息陣列
3295
		#$result["comment"],每個函式說明的陣列
3296
		#$result["argvType"],每個函式傳入參數型態的陣列,null表示不用參數
3297
		#$result["returnVarType"],每個函式回傳變數型態的陣列,目前尚無法判斷其型態為string、int、float、double、boolean的哪一個,所以先一律視為"string"
3298
		#$result["return"]["name"][$i],第$i+1個函式回傳變數名稱的陣列
3299
		#$result["return"]["comment"][$i],第$i+1個函式回傳變數註解的陣列
3300
		#$result["mustBeFilled"]["dataCount"][$j],第j+1個函式不可省略參數數量的陣列 
3301
		#$result["optionalFilled"]["dataCount"][$k],第$k+1每個函式可省略參數數量的陣列
3302
		#$result["mustBeFilled"]["name"][$j],第$j+1個函式不可省略參數的陣列
3303
		#$result["mustBeFilled"]["comment"][$j],第$j+1個函式不可省略參數註解的陣列
3304
		#$result["optionalFilled"]["name"][$k],第$k+1個函式可省略參數的陣列
3305
		#$result["optionalFilled"]["comment"][$k],第$k+1個函式可省略參數註解的陣列
3306
		#$result["reference"]["addr"][$l],第$l+1個函式參考資料網址的陣列
3307
		#$result["reference"]["comment"][$l],第$l+1個函式參考資料說明的陣列
3308
		#必填參數:
3309
		$conf["phpLib"]["getMutiFunctionConstruction"]["phpFileAddress"]=$conf["phpFileAddress"];#含有函式內容的php檔案位置與名稱
3310
		$conf["phpLib"]["getMutiFunctionConstruction"]["functionName"]=$funcs;#函式的名稱
3311
		$conf["phpLib"]["getMutiFunctionConstruction"]["fileArgu"]=$conf["fileArgu"];
3312
		#備註:目前尚未開發完畢
3313
		$functionConstruction=phpLib::getMutiFunctionConstruction($conf["phpLib"]["getMutiFunctionConstruction"]);
3314
 
3315
		#如果 $classConstruction["status"] 為 "fasle"
3316
		if($functionConstruction["status"]==="false"){
3317
 
3318
			#設置執行錯誤的識別
3319
			$result["status"]="false";
3320
 
3321
			#設置執行錯誤的訊息
3322
			$result["error"]=$functionConstruction;
3323
 
3324
			#回傳結果
3325
			return $result;
3326
 
3327
			}#if end		
3328
 
3329
		#debug
3330
		#var_dump($functionConstruction); 
3331
 
3332
		#由於每個函式都沒有指定屬性,所以都為public的函式
3333
 
3334
		#函式說明:
3335
		#建立一個陣列,可以指派陣列的內容,然後回傳
3336
		#回傳的結果:
3337
		#$result,爲陣列變數內容
3338
		#必填參數:
3339
		$conf["arrays"]["create"]["arrayContent"]=array("+");#陣列元素的內容,須爲陣列值。
3340
		#可省略的參數:
3341
		$conf["arrays"]["create"]["arrayCounts"]=count($classConstruction["functions"]);#爲陣列的元素有幾個,若沒設定,則數量爲$conf["arrayContent"]裏的元素數量
3342
		$conf["arrays"]["create"]["theSameAs"]="true";#若設爲"true",則所有元素內容都跟第一個元素內容相同
3343
		$functionTypeArray=arrays::create($conf["arrays"]["create"]);
3344
		unset($conf["arrays"]["create"]);
3345
 
3346
		#var_dump($functionTypeArray);
3347
		#var_dump($classConstruction["class"][0]);
3348
		#exit;
3349
 
3350
		#如果不存在 $classConstruction["class"][0]
3351
		if(!isset($classConstruction["class"][0])){
3352
 
3353
			#設置為 "empty"
3354
			$classConstruction["class"][0]["content"]="empty";
3355
 
3356
			}#if end
3357
 
3358
		#如果不存在 $functionConstruction["argvType"]
3359
		if(!isset($functionConstruction["argvType"])){
3360
 
3361
			#設置為 "array"
3362
			$functionConstruction["argvType"][0]="array";
3363
 
3364
			}#if end
3365
 
3366
		#如果不存在 $functionConstruction["returnVarType"]
3367
		if(!isset($functionConstruction["returnVarType"])){
3368
 
3369
			#設置為 "array"
3370
			$functionConstruction["returnVarType"][0]="array";
3371
 
3372
			}#if end
3373
 
3374
		#var_dump($classConstruction["functions"]);
3375
		#exit;
3376
 
3377
		#建立類別圖表格
3378
		#函式說明:
3379
		#依據類別的名稱、裡面的函式存限制、函式名稱、函式參數、函式回傳型態來建立類別圖表格
3380
		#回傳結果:
3381
		#$result["status"],執行是否成功,"true"代表執行成功;"false"代表執行失敗。
3382
		#$result["error"],錯誤訊息陣列
3383
		#$result["classDiagramTable"],類別圖的網頁code
3384
		#必填參數:
3385
		$conf["table"]["classDiagramTable"]["className"]=$classConstruction["class"][0]["content"];#類別的名稱
3386
		$conf["table"]["classDiagramTable"]["functionOpenAccessType"]=$functionTypeArray;#函式存取的限制,每個元素代表一個函式的設定,"+"代表開放存取
3387
		$conf["table"]["classDiagramTable"]["functionName"]=$classConstruction["functions"];#各函式的名稱,每個元素代表一個函式的名稱
3388
		$conf["table"]["classDiagramTable"]["functionArgv"]=$functionConstruction["argvType"];#各函式的傳入參數型態,每個元素代表一個函式的入參數型態,""代表沒有傳入參數;
3389
		$conf["table"]["classDiagramTable"]["functionReturnType"]=$functionConstruction["returnVarType"];#各函式回傳的型態,每個元素代表一個函式回傳的型態,"void"代表沒有回傳變數
3390
		$createClassDiagramTableResult=table::classDiagramTable($conf["table"]["classDiagramTable"]);
3391
		unset($conf["table"]["classDiagramTable"]);
3392
 
3393
		#如果類別圖表格建立失敗
3394
		if($createClassDiagramTableResult["status"]==="false"){
3395
 
3396
			#設置執行錯誤的識別
3397
			$result["status"]="false";
3398
 
3399
			#設置錯誤訊息提示
3400
			$result["error"]=$createClassDiagramTableResult["error"];
3401
 
3402
			#回傳結果
3403
			return $result;
3404
 
3405
			}#if end
3406
 
3407
		#取得類別圖的html內容	
3408
		$result["diagramCode"]=$createClassDiagramTableResult["classDiagramTable"];
3409
 
3410
		#執行到這邊代表執行成功
3411
		$result["status"]="true";
3412
 
3413
		#回傳結果 
3414
		return $result;
3415
 
3416
		}#function classDiagramMaker end
3417
 
3418
	/*
3419
	#函式說明:
3420
	#提供將目標目錄裡的所有php檔案轉成類別圖的功能
3421
	#回傳結果:
3422
	#$result["status"],執行是否成功,"true"代表執行成功;"false"代表執行失敗。
3423
	#$result["error"],錯誤訊息陣列
3424
	#$result["function"],當前執行的函數名稱.
3425
	#$result["diagramCode"][$i],第$i+1個類別圖的網頁code
3426
	#必填參數:
3427
	#$conf["phpDirAddress"],字串,含有宣告類別的php檔案目錄,""代表當前目錄。
3428
	$conf["phpDirAddress"]="";
3429
	#$conf["fileArgu"],字串,__FILE__的內容.
3430
	$conf["fileArgu"]=__FILE__;
3431
	#可省略參數:
3432
	#無.
3433
	#參考資料:
3434
	#無.
3435
	#備註:
3436
	#有bug...
3437
	*/
3438
	public static function classDiagramsMaker(&$conf){
3439
 
3440
		#初始化要回傳的內容
3441
		$result=array();
3442
 
3443
		#取得當前函數的名稱
3444
		$result["function"]=__FUNCTION__;
3445
 
3446
		#如果 $conf 不為陣列
3447
		if(gettype($conf)!="array"){
3448
 
3449
			#設置執行失敗
3450
			$result["status"]="false";
3451
 
3452
			#設置執行錯誤訊息
3453
			$result["error"][]="\$conf變數須為陣列形態";
3454
 
3455
			#如果傳入的參數為 null
3456
			if($conf==null){
3457
 
3458
				#設置執行錯誤訊息
3459
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3460
 
3461
				}#if end
3462
 
3463
			#回傳結果
3464
			return $result;
3465
 
3466
			}#if end
3467
 
3468
		#參數檢查
3469
		#檢查參數
3470
		#函式說明:
3471
		#檢查陣列裡面的特定元素是否存在以及其變數型態是否正確,如果沒有設定則回傳提示訊息。
3472
		#回傳結果:
3473
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
3474
		#$result[$shouldBtCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
3475
		#$result[$shouldBtCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
3476
		#必填寫的參數:
3477
		$conf["variableCheck"]["isexistMuti"]["varInput"]=$conf;#要檢查的陣列變數
3478
		$conf["variableCheck"]["isexistMuti"]["variableCheck"]=array("phpDirAddress","fileArgu");#要檢查的變數名稱陣列,形態爲陣列變數,例如: $conf["variableCheck"] = array("id","account","password");
3479
		#可以省略的參數:
3480
		$conf["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double"); 
3481
		$conf["variableCheck"]["isexistMuti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
3482
		$checkResult=variableCheck::isexistMulti($conf["variableCheck"]["isexistMuti"]);
3483
		unset($conf["variableCheck"]["isexistMuti"]);
3484
 
3485
		#如果 $checkResult["status"] 為 "fasle"
3486
		if($checkResult["status"]=="false"){
3487
 
3488
			#設置執行錯誤的識別
3489
			$result["status"]="false";
3490
 
3491
			#設置執行錯誤的訊息
3492
			$result["error"]=$checkResult;
3493
 
3494
			#回傳結果
3495
			return $result;
3496
 
3497
			}#if end
3498
 
3499
		#如果 $checkResult["passed"] 為 "fasle"
3500
		if($checkResult["passed"]=="false"){
3501
 
3502
			#設置執行錯誤的識別
3503
			$result["status"]="false";
3504
 
3505
			#設置執行錯誤的訊息
3506
			$result["error"]=$checkResult;
3507
 
3508
			#回傳結果
3509
			return $result;
3510
 
3511
			}#if end
3512
 
3513
		#取得目標目錄底下的php檔案
3514
		#函式說明:
3515
		#取得目錄底下函式庫檔案清單
3516
		#回傳的結果:
3517
		#$result["status"],0表示有清單;1表示沒有清單
3518
		#$result["dataCount"],有幾筆符合的資料
3519
		#$result["neededList"],符合條件的檔案清單		
3520
		#必填參數:
3521
		$conf["phpLib"]["getLibFileList"]["folderAddress"]=$conf["phpDirAddress"];#要讀取的函式庫目錄
3522
		#$conf["fileArgu"],字串__FILE__的內容.
3523
		$conf["phpLib"]["getLibFileList"]["fileArgu"]=$conf["fileArgu"];
3524
		#可省略的參數:
3525
		$conf["phpLib"]["getLibFileList"]["readFileType"]=array("php");#要讀取具有該陣列底下副檔名的檔案
3526
		#$conf["excludeFile"],陣列,要忽略的檔案.
3527
		$conf["phpLib"]["getLibFileList"]["excludeFile"]=array("allInOne.php");
3528
		$phpLib_getLibFileList=phpLib::getLibFileList($conf["phpLib"]["getLibFileList"]);
3529
		unset($conf["phpLib"]["getLibFileList"]);
3530
 
3531
		#debug
3532
		#var_dump($phpLib_getLibFileList);
3533
		#exit;
3534
 
3535
		#如果執行失敗
3536
		if($phpLib_getLibFileList["status"]==="false"){
3537
 
3538
			#設定執行失敗
3539
			$result["status"]="false";
3540
 
3541
			#設置錯誤訊息
3542
			$result["error"]="目標目錄下沒有任何php檔案";
3543
 
3544
			#回傳結果
3545
			return $result;
3546
 
3547
			}#if end
3548
 
3549
		#如果 $phpLib_getLibFileList["dataCount"] 等於 0,則代表目標目錄底下沒有php檔案。
3550
		if($phpLib_getLibFileList["dataCount"]===0){
3551
 
3552
			#設定執行失敗
3553
			$result["status"]="false";
3554
 
3555
			#設置錯誤訊息
3556
			$result["error"]="目標目錄下沒有任何php檔案";
3557
 
3558
			#回傳結果
3559
			return $result;
3560
 
3561
			}#if end
3562
 
3563
		#var_dump($phpLib_getLibFileList);
3564
 
3565
		#根據每個php檔案
3566
		for($i=0;$i<$phpLib_getLibFileList["dataCount"];$i++){
3567
 
3568
			#取得其類別函式結構
3569
			#函式說明:
3570
			#提供將含有類別宣告的php檔案轉成類別圖的功能
3571
			#回傳結果:
3572
			#$result["status"],執行是否成功,"true"代表執行成功;"false"代表執行失敗。
3573
			#$result["error"],錯誤訊息陣列
3574
			#$result["diagramCode"],類別圖的網頁code
3575
			#必填參數:
3576
			$conf["phpLib"]["classDiagramMaker"]["phpFileAddress"]=$conf["phpDirAddress"].$phpLib_getLibFileList["neededList"][$i];#含有宣告類別的php檔案
3577
			$conf["phpLib"]["classDiagramMaker"]["fileArgu"]=$conf["fileArgu"];
3578
			$classDiagram["diagramCode"][$i]=phpLib::classDiagramMaker($conf["phpLib"]["classDiagramMaker"]);
3579
			unset($conf["phpLib"]["classDiagramMaker"]);
3580
 
3581
			#如果該檔案的類別圖取得失敗
3582
			if($classDiagram["diagramCode"][$i]["status"]=="false"){
3583
 
3584
				#設定類別圖繪製失敗
3585
				$result["status"]="false";
3586
 
3587
				#設定錯誤訊息
3588
				$result["error"]=$classDiagram;
3589
 
3590
				#設定該檔案的類別圖繪製失敗提示
3591
				$result["error"][]="無法正確取得".$phpLib_getLibFileList["neededList"][$i]."檔案裡面的類別結構或該檔案非類別檔案";
3592
 
3593
				#回傳結果
3594
				return $result;
3595
 
3596
				}#if end
3597
 
3598
			#取得類別圖表格htmlCode
3599
			$result["diagramCode"][]=$classDiagram["diagramCode"][$i]["diagramCode"];	
218 liveuser 3600
 
3 liveuser 3601
			}#for end
3602
 
3603
		#執行到這邊代表執行成功
3604
		$result["status"]="true";
3605
 
3606
		#回傳結果
3607
		return $result;	
3608
 
3609
		}#function classDiagramsMaker end
3610
 
3611
	/*
3612
	#函式說明:
218 liveuser 3613
	#更新程式檔案開頭版權宣告的年份,以及作者清單.
3 liveuser 3614
	#回傳結果:
3615
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3616
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
3617
	#$result["function"],當前執行的函式名稱.
218 liveuser 3618
	#$result["argu"],本函式使用的參數.
3 liveuser 3619
	#$result["content"],有更新的檔案清單,其元素有被取代的檔案路徑與名稱跟replacedInfo,其中replacedInfo為陣列,其key為要變動的行號(從0開始算),其數值有"from"代表要被取代的原始內容,"to"代表要置換成的新內容.
3620
	#$result["scannedFile"],陣列,有檢查過的檔案清單其完整路徑與檔案名稱.
3621
	#必填參數:
3622
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
3623
	$conf["fileArgu"]=__FILE__;
3624
	#可省略參數:
3625
	#$conf["replaceFrom"],陣列,目標關鍵字,每個元素代表一行的內容,預設內容可參照本檔案開頭的版權宣告文字.
3626
	#$conf["replaceFrom"]=array();
3627
	#$conf["yearFrom],字串,起始年份,預設為西元"2014"年.
3628
	#$conf["yearFrom"]="2014";
3629
	#$conf["yearTo],字串,結束年份,預設為西元"gmdate('Y')"年.
3630
	#$conf["yearTo"]=gmdate('Y');
218 liveuser 3631
	#$conf["Authors"],陣列,該套件的參與者,預設為array("MIN-ZHI, CHEN");
3632
	#$conf["Authors"]=array("MIN-ZHI, CHEN");
3 liveuser 3633
	#$conf["searchPath"],陣列,要搜尋哪些地方的檔案要更新版權宣告年份,預設為使用中的本套件位置.
3634
	#$conf["searchPath"]=array("");
3635
	#$conf["skipHiddenFolder"],字串,要略過隱藏的資料夾,預設為"true";反之為"false";
3636
	#$conf["skipHiddenFolder"]="true";
3637
	#$conf["includeHiddenFolder"],陣列,符合名稱的隱藏資料夾會存取,預設不指定;
3638
	#$conf["includeHiddenFolder"]=array("");
3639
	#$conf["excludeDirName"],陣列,哪些目錄名稱要忽略,預設有"free-lib"、"no-free-lib"、"composer".
3640
	#$conf["excludeDirName"]=array("free-lib","no-free-lib","composer");
3641
	#$conf["excludeMineType"],陣列,哪些檔案類型要忽略,預設有"image/*"、"video/*"、"audio/*"、"media/*"、"application/*".
3642
	#$conf["excludeMineType"]=array("image/*","video/*","audio/*","media/*","application/*");
3643
	#$conf["excludeSecondName"],陣列,哪些附檔名的檔案要忽略,預設有"log"、"csv"、"sql"、"js"、"css"、"html".
3644
	#$conf["excludeSecondName"]=array("log"、,"csv","sql","js","css","html");
3645
	#$conf["multiThread"],字串,是否要啟用多執行序,預設為"false",反之為"true".
3646
	#$conf["multiThread"]="false";
3647
	#$conf["threadType"],字串,當"multiThread"參數為"true"時,要使用的threas類型,預設為"socket",其他可能有"proc".
3648
	#$conf["threadType"]="socket";
3649
	#$conf["socket"],字串,unix domain socket 的位置與名稱,預設為 qbpwcf_usock_path;
3650
	#$conf["socket"]=qbpwcf_usock_path;
3651
	#$conf["log"],字串,log的檔案位置與名稱,預設不使用.
3652
	#$conf["log"]="";
3653
	#參考資料:
3654
	#無.
3655
	#備註:
218 liveuser 3656
	#建構中...
3 liveuser 3657
	*/
3658
	public static function updateCopyRightYear(&$conf){
3659
 
3660
		#初始化要回傳的結果
3661
		$result=array();
3662
 
3663
		#取得當前執行的函數名稱
3664
		$result["function"]=__FUNCTION__;
3665
 
3666
		#如果沒有參數
3667
		if(func_num_args()==0){
3668
 
3669
			#設置執行失敗
3670
			$result["status"]="false";
3671
 
3672
			#設置執行錯誤訊息
3673
			$result["error"]="函數".$result["function"]."需要參數";
3674
 
3675
			#回傳結果
3676
			return $result;
3677
 
3678
			}#if end
3679
 
3680
		#取得參數
3681
		$result["argu"]=$conf;
218 liveuser 3682
 
3683
		#debug,break point.
3684
		#var_dump(__LINE__,$result);exit(1);
3 liveuser 3685
 
3686
		#如果 $conf 不為陣列
3687
		if(gettype($conf)!=="array"){
3688
 
3689
			#設置執行失敗
3690
			$result["status"]="false";
3691
 
3692
			#設置執行錯誤訊息
3693
			$result["error"][]="\$conf變數須為陣列形態";
3694
 
3695
			#如果傳入的參數為 null
3696
			if(is_null($conf)){
3697
 
3698
				#設置執行錯誤訊息
3699
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3700
 
3701
				}#if end
3702
 
3703
			#回傳結果
3704
			return $result;
3705
 
3706
			}#if end
3707
 
3708
		#函式說明:
3709
		#取得檔案路徑字串的路徑與檔案的名稱與檔案副檔名
3710
		#回傳的結果:
3711
		#$result["status"],執行是否正常,"true"正常,"false"代表不正常.
3712
		#$result["error"],錯誤訊息.
3713
		#$result["function"],當前執行的函式名稱.
3714
		#$result["filePath"],路徑字串.
3715
		#$result["fileName"],檔案名稱字串.
3716
		#$result["fileExtention"],檔案的副檔名.
3717
		#$result["fullFileName"],含副檔名的檔案名稱.
3718
		#$result["fullFilePathAndName"],完整的檔案路徑(含副檔名).
3719
		#必填參數:
3720
		#$conf["fileAddressAndName"],字串,檔案名稱與其路徑.
3721
		$conf["fileAccess::getFileAddressAndNameAndFileExtention"]["fileAddressAndName"]=__FILE__;
3722
		#可省略參數:
3723
		#無.
3724
		#參考資料:
3725
		#無.
3726
		#備註:
3727
		#無.
3728
		$getFileAddressAndNameAndFileExtention=fileAccess::getFileAddressAndNameAndFileExtention($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
3729
		unset($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
3730
 
218 liveuser 3731
		#debug,break point.
3732
		#var_dump(__LINE__,$getFileAddressAndNameAndFileExtention);exit;
3 liveuser 3733
 
3734
		#如果執行失敗
3735
		if($getFileAddressAndNameAndFileExtention["status"]==="false"){
3736
 
3737
			#設置錯誤識別
3738
			$result["status"]="false";
3739
 
3740
			#設置錯誤訊息
3741
			$result["error"]=$getFileAddressAndNameAndFileExtention;
3742
 
3743
			#回傳結果
3744
			return $result;
3745
 
3746
			}#if end
3747
 
3748
		#初始化有異動的檔案清單
3749
		$result["content"]=array();
3750
 
3751
		#取得當前使用套件的路徑
218 liveuser 3752
		$libPath=$getFileAddressAndNameAndFileExtention["filePath"]."../../../";
3 liveuser 3753
 
218 liveuser 3754
		#debug,break point.
3755
		#var_dump(__LINE__,$libPath);exit(1);
3756
 
3 liveuser 3757
		#函式說明:
3758
		#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
3759
		#回傳結果:
3760
		#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
3761
		#$result["function"],當前執行的函數.
3762
		#$result["error"],錯誤訊息陣列.
3763
		#$result["argu"],使用者參數.
3764
		#$result["changedPath"],處理完後回傳的目錄字串.
3765
		#$result["oriPath"],原始的路徑字串
3766
		#必填參數:
3767
		#$conf["dirStr"],字串,要處理的檔案目錄字串.
3768
		$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"]=$libPath;
3769
		#可省略參數:
3770
		#無.
3771
		#參考資料:
3772
		#無.
3773
		#備註:
3774
		#考慮用realpath取代
3775
		$changeDirByDotDotSolidus=stringProcess::changeDirByDotDotSolidus($conf["stringProcess::changeDirByDotDotSolidus"]);
3776
		unset($conf["stringProcess::changeDirByDotDotSolidus"]);
3777
 
3778
		#如果執行失敗
3779
		if($changeDirByDotDotSolidus["status"]==="false"){
3780
 
3781
			#設置錯誤識別
3782
			$result["status"]="false";
3783
 
3784
			#設置錯誤訊息
3785
			$result["error"]=$changeDirByDotDotSolidus;
3786
 
3787
			#回傳結果
3788
			return $result;
3789
 
3790
			}#if end
3791
 
3792
		#取得直觀的絕對路徑
3793
		$libPath=$changeDirByDotDotSolidus["changedPath"];
3794
 
218 liveuser 3795
		#debug
3796
		#var_dump(__LINE__,$libPath);exit(1);
3797
 
3 liveuser 3798
		#設置要取代的內容關鍵字陣列 - start
3799
 
3800
		$replaceFromArray=array();
3801
 
3802
		$replaceFromArray[]="        QBPWCF, Quick Build PHP website Component base on Fedora Linux.";
3803
 
3804
		$replaceFromArray[]="    Copyright (C) \${yearFrom}~\${yearTo} \${Authors}";
3805
 
3806
		$replaceFromArray[]="";
3807
 
3808
		$replaceFromArray[]="    This file is part of QBPWCF.";
3809
 
3810
		$replaceFromArray[]="";
3811
 
3812
		$replaceFromArray[]="    QBPWCF is free software: you can redistribute it and/or modify";
3813
 
3814
		$replaceFromArray[]="    it under the terms of the GNU General Public License as published by";
3815
 
3816
		$replaceFromArray[]="    the Free Software Foundation, either version 3 of the License, or";
3817
 
3818
		$replaceFromArray[]="    (at your option) any later version.";
3819
 
3820
		$replaceFromArray[]="";
3821
 
3822
		$replaceFromArray[]="    QBPWCF is distributed in the hope that it will be useful,";
3823
 
3824
		$replaceFromArray[]="    but WITHOUT ANY WARRANTY; without even the implied warranty of";
3825
 
3826
		$replaceFromArray[]="    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the";
3827
 
3828
		$replaceFromArray[]="    GNU General Public License for more details.";
3829
 
3830
		$replaceFromArray[]="";
3831
 
3832
		$replaceFromArray[]="    You should have received a copy of the GNU General Public License";
3833
 
3834
		$replaceFromArray[]="    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.";
3835
 
3836
		#設置要取代的內容關鍵字陣列 - end
3837
 
3838
		#函式說明:
3839
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
3840
		#回傳結果:
3841
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3842
		#$result["error"],執行不正常結束的錯訊息陣列.
3843
		#$result["simpleError"],簡單表示的錯誤訊息.
3844
		#$result["function"],當前執行的函式名稱.
3845
		#$result["argu"],設置給予的參數.
3846
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
3847
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
3848
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
3849
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
3850
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
3851
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
3852
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
3853
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
3854
		#必填參數:
3855
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
3856
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
3857
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
3858
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
3859
		#可省略參數:
3860
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
3861
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
3862
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".
3863
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
3864
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
3865
		#$conf["canBeEmptyString"]="false";
3866
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
3867
		#$conf["canNotBeEmpty"]=array();
3868
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
3869
		#$conf["canBeEmpty"]=array();
3870
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
3871
		#$conf["variableCheck::checkArguments"]["skipableVariableCanNotBeEmpty"]=array();
3872
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
3873
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("replaceFrom","yearFrom","yearTo","Authors","searchPath","skipHiddenFolder","includeHiddenFolder","excludeDirName","excludeMineType","excludeSecondName","multiThread","log","threadType","socket");
3874
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
3875
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string","array","array","string","array","array","array","array","string","string","string","string");
3876
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
218 liveuser 3877
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array($replaceFromArray,"2014",gmdate("Y"),array("MIN-ZHI, CHEN"),array($libPath),"true",null,array("free-lib","non-free-lib","composer"),array("image/*","video/*","audio/*","media/*","application/*"),array("log","csv","sql","js","css","html"),"false",null,"socket",qbpwcf_usock_path);
3 liveuser 3878
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
3879
		#$conf["variableCheck::checkArguments"]["disallowAllSkipableVarIsEmpty"]="true";
3880
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
3881
		#$conf["variableCheck::checkArguments"]["disallowAllSkipableVarIsEmptyArray"]="true";
3882
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
3883
		#$conf["disallowAllSkipableVarNotExist"]="";
3884
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3885
		#$conf["arrayCountEqualCheck"][]=array();
3886
		#參考資料:
3887
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3888
		#備註:
3889
		#無.
3890
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3891
		unset($conf["variableCheck::checkArguments"]);
3892
 
3893
		#如果執行失敗
3894
		if($checkArguments["status"]==="false"){
3895
 
3896
			#設置錯誤識別
3897
			$result["status"]="false";
3898
 
3899
			#設置錯誤訊息
3900
			$result["error"]=$checkArguments;
3901
 
3902
			#回傳結果
3903
			return $result;
3904
 
3905
			}#if end
3906
 
3907
		#如果檢查不通過
3908
		if($checkArguments["passed"]==="false"){
3909
 
3910
			#設置錯誤識別
3911
			$result["status"]="false";
3912
 
3913
			#設置錯誤訊息
3914
			$result["error"]=$checkArguments;
3915
 
3916
			#回傳結果
3917
			return $result;
3918
 
3919
			}#if end
3920
 
3921
		#函式說明:
3922
		#使用 linux 的 uuid 指令來產生 uuid 字串
3923
		#回傳結果:
3924
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3925
		#$result["error"],錯誤訊息.
3926
		#$result["function"],當前執行的函式名稱.
3927
		#$result["content"],uuid.
3928
		#必填參數:
3929
		#無.
3930
		#可省略參數:
3931
		#無.
3932
		#參考資料:
3933
		#無.
3934
		#備註:
3935
		#無.
3936
		$uuid=cmd::uuid();
3937
 
3938
		#如果執行失敗
3939
		if($uuid["status"]==="false"){
3940
 
3941
			#debug
3942
			var_dump($uuid);
3943
 
3944
			#結束執行回傳代碼1給shell
3945
			exit(1);
3946
 
3947
			}#if end
3948
 
3949
		#取得 uuid
3950
		$uuid=$uuid["content"];
3951
 
3952
		#針對 $conf["searchPath"] 的每個路徑
3953
		foreach($conf["searchPath"] as $path){
3954
 
218 liveuser 3955
			#debug
3956
			var_dump(__LINE__,"searching path:".$path);
3957
 
3 liveuser 3958
			#取得 $path 底下的所有檔案.
3959
			#函式說明:
3960
			#取得目錄底下的詳細資訊.
3961
			#回傳結果:
3962
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3963
			#$result["error"],錯誤訊息.
3964
			#$result["function"],當前執行的函數名稱.
3965
			#$result["size"],該清單的大小,單位為bytes.
3966
			#$result["dataCount"],該清單的長度.
3967
			#$result["content"],指定目錄底下的所有檔案資訊.
3968
			#$result["content"][$i]["nType&permission"],第$i個節點類型、權限.
3969
			#$result["content"][$i]["nType"],第$i個節點類型,"-"代表檔案,"d"代表資料夾.
3970
			#$result["content"][$i]["permission"],第$i個節點權限.
3971
			#$result["content"][$i]["ownByUser"],第$i個節點擁有者賬號.
3972
			#$result["content"][$i]["ownByGroup"],第$i個節點擁有者群組.
3973
			#$result["content"][$i]["bytes"],第$i個節點大小.
3974
			#$result["content"][$i]["date"],第$i個節點最後變更日期.
3975
			#$result["content"][$i]["time"],第$i個節點最後異動時間.
3976
			#$result["content"][$i]["timeDetail"],第$i個節點最後異動詳細時間.
3977
			#$result["content"][$i]["timezone"],第$i個節點的時區.
3978
			#$result["content"][$i]["secondName"],第$i個節點為檔案時,若有附檔名,會記錄在這.
3979
			#$result["content"][$i]["name"],第$i個節點的名稱.
3980
			#$result["content"][$i]["mimeType"],第$i個節點為檔案且可以讀取時,會有 mime type 可取得.
3981
			#必填參數:
3982
			#$conf["path"],字串,要檢視的路徑,若非"/"結尾,會自動補上.
3983
			$conf["fileAccess::ls"]["path"]=$path;
3984
			#可省略參數:
3985
			#無.
3986
			#參考資料:
3987
			#https://www.businessweekly.com.tw/careers/Blog/14307
3988
			#備註:
3989
			#無.
3990
			$ls=fileAccess::ls($conf["fileAccess::ls"]);
3991
			unset($conf["fileAccess::ls"]);
3992
 
3993
			#如果執行失敗
3994
			if($ls["status"]==="false"){
3995
 
3996
				#設置錯誤識別
3997
				$result["status"]="false";
3998
 
3999
				#設置錯誤訊息
4000
				$result["error"]=$ls;
4001
 
4002
				#回傳結果
4003
				return $result;
4004
 
4005
				}#if end
4006
 
4007
			#如果沒資料
4008
			if($ls["dataCount"]===0){
4009
 
4010
				#跳過
4011
				continue;
4012
 
4013
				}#if end
4014
 
4015
			#針對每個節點
4016
			foreach($ls["content"] as $node){
4017
 
4018
				#取得節點的路徑與名稱
4019
				$NodePathAndName=$ls["path"].$node["name"];
4020
 
4021
				#儲存該節點需要取代的行號相關資訊
4022
				$replacedInfo=array();
4023
 
4024
				#預設該節點檔案不需要更新
4025
				$shouldReplace="false";
4026
 
4027
				#debug
4028
				#var_dump(__LINE__,$node);
4029
 
4030
				#如果是資料夾
4031
				if($node["nType"]==="d"){
4032
 
4033
					#如果要忽略隱藏資料夾
4034
					if($conf["skipHiddenFolder"]==="true"){
4035
 
4036
						#如果開頭為 "."
4037
						if(strpos($node["name"],".")===0){
4038
 
4039
							#如果有設定要包含特定的隱藏目錄
4040
							if(isset($conf["includeHiddenFolder"])){
4041
 
4042
								#如果不是需要的特定隱藏目錄
4043
								if(!(in_array($node["name"],$conf["includeHiddenFolder"]))){
4044
 
4045
									#跳過
4046
									continue;
4047
 
4048
									}#if end
4049
 
4050
								}#if end
4051
 
4052
							#反之
4053
							else{
4054
 
4055
								#跳過
4056
								continue;
4057
 
4058
								}#else end
4059
 
4060
							}#if end
4061
 
4062
						}#if end
4063
 
4064
					#如果是要跳過的資料夾名稱
4065
					if(in_array($node["name"],$conf["excludeDirName"])){
4066
 
4067
						#跳過
4068
						continue;
4069
 
4070
						}#if end
4071
 
4072
					#跳過 
4073
					#continue;
4074
 
4075
					#如果為單執行序
4076
					if($conf["multiThread"]==="false"){
4077
 
4078
						#繼承本函式參數
4079
						$conf["self::updateCopyRightYear"]=$conf;
4080
 
4081
						#置換要執行的路徑
4082
						$conf["self::updateCopyRightYear"]["searchPath"]=array($NodePathAndName);
4083
 
4084
						#遞迴呼叫
4085
						$updateCopyRightYear=self::updateCopyRightYear($conf["self::updateCopyRightYear"]);
4086
 
4087
						#移除參數,避免出錯.
4088
						unset($conf["self::updateCopyRightYear"]);
4089
 
4090
						#如果執行失敗
4091
						if($updateCopyRightYear["status"]==="false"){
4092
 
4093
							#設置錯誤識別
4094
							$result["status"]="false";
4095
 
4096
							#設置錯誤訊息
4097
							$result["error"]=$updateCopyRightYear;
4098
 
4099
							#回傳結果
4100
							return $result;
4101
 
4102
							}#if end
4103
 
4104
						#記錄有掃描的資料夾路徑與名稱 
4105
						$result["scannedFile"][]=$NodePathAndName;
4106
 
218 liveuser 4107
						#debug
4108
						var_dump(__LINE__,"seartched node:".$NodePathAndName);
4109
 
3 liveuser 4110
						#合併 content - start
4111
 
4112
						#函式說明:
4113
						#將多個一維陣列串聯起來,key從0開始排序.
4114
						#回傳的結果:
4115
						#$result["status"],"true"表執行正常,"false"代表執行不正常.
4116
						#$result["error"],錯誤訊息陣列.
4117
						#$result["function"],當前執行的函數.
4118
						#$result["content"],合併好的一維陣列.
4119
						#必填參數
4120
						#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
4121
						$conf["arrays::mergeArray"]["inputArray"]=array($result["content"],$updateCopyRightYear["content"]);
4122
						#可省略參數:
4123
						#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
4124
						#$conf["allowRepeat"]="true";
4125
						#參考資料:
4126
						#無.
4127
						#備註:
4128
						#無.
4129
						$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
4130
						unset($conf["arrays::mergeArray"]);
4131
 
4132
						#如果執行失敗
4133
						if($mergeArray["status"]==="false"){
4134
 
4135
							#設置錯誤識別
4136
							$result["status"]="false";
4137
 
4138
							#設置錯誤訊息
4139
							$result["error"]=$mergeArray;
4140
 
4141
							#回傳結果
4142
							return $result;
4143
 
4144
							}#if end
4145
 
4146
						#取得合併好的有異動檔案結果
4147
						$result["content"]=$mergeArray["content"];
4148
 
4149
						#合併 content - end
4150
 
4151
						#合併 scannedFile - start
4152
 
4153
						if(isset($updateCopyRightYear["scannedFile"])){
4154
 
4155
							#函式說明:
4156
							#將多個一維陣列串聯起來,key從0開始排序.
4157
							#回傳的結果:
4158
							#$result["status"],"true"表執行正常,"false"代表執行不正常.
4159
							#$result["error"],錯誤訊息陣列.
4160
							#$result["function"],當前執行的函數.
4161
							#$result["content"],合併好的一維陣列.
4162
							#必填參數
4163
							#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
4164
							$conf["arrays::mergeArray"]["inputArray"]=array($result["scannedFile"],$updateCopyRightYear["scannedFile"]);
4165
							#可省略參數:
4166
							#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
4167
							#$conf["allowRepeat"]="true";
4168
							#參考資料:
4169
							#無.
4170
							#備註:
4171
							#無.
4172
							$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
4173
							unset($conf["arrays::mergeArray"]);
4174
 
4175
							#如果執行失敗
4176
							if($mergeArray["status"]==="false"){
4177
 
4178
								#設置錯誤識別
4179
								$result["status"]="false";
4180
 
4181
								#設置錯誤訊息
4182
								$result["error"]=$mergeArray;
4183
 
4184
								#回傳結果
4185
								return $result;
4186
 
4187
								}#if end
4188
 
4189
							#取得合併好的有異動檔案結果
4190
							$result["scannedFile"]=$mergeArray["content"];
4191
 
4192
							}#if end
4193
 
4194
						#合併 scannedFile - end
4195
 
4196
						}#if end
4197
 
4198
					#反之為多執行程
4199
					else{
4200
 
4201
						/* 
4202
 
4203
						預想的程式 - start
4204
 
4205
						#繼承本函式參數
4206
						$conf["self::updateCopyRightYear"]=$conf;
4207
 
4208
						#置換要執行的路徑
4209
						$conf["self::updateCopyRightYear"]["searchPath"]=array($NodePathAndName);
4210
 
4211
						#遞迴呼叫
4212
						$updateCopyRightYear=self::updateCopyRightYear($conf["self::updateCopyRightYear"]);
4213
 
4214
						預想的程式 - end
4215
 
4216
						*/
4217
 
4218
						#要執行的php程式內容
4219
						$cmdString=<<<'PHP'
4220
/*
4221
 
4222
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
4223
    Copyright (C) 2014~2025 Min-Jhin,Chen
4224
 
4225
    This file is part of QBPWCF.
4226
 
4227
    QBPWCF is free software: you can redistribute it and/or modify
4228
    it under the terms of the GNU General Public License as published by
4229
    the Free Software Foundation, either version 3 of the License, or
4230
    (at your option) any later version.
4231
 
4232
    QBPWCF is distributed in the hope that it will be useful,
4233
    but WITHOUT ANY WARRANTY; without even the implied warranty of
4234
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4235
    GNU General Public License for more details.
4236
 
4237
    You should have received a copy of the GNU General Public License
4238
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
4239
 
4240
*/
4241
 
4242
#使用命名空間qbpwcf
4243
namespace qbpwcf;
4244
 
4245
#匯入套件
218 liveuser 4246
PHP;
3 liveuser 4247
 
218 liveuser 4248
						#匯入套件的路徑
4249
						$cmdString=$cmdString.PHP_EOL."require_once(\"".$libPath."/qbpwcf/allInOne.php\");";
4250
 
4251
						#要執行的php程式內容,設定建議的 log 位置.
4252
						$cmdString=$cmdString.PHP_EOL.<<<'PHP'
4253
 
3 liveuser 4254
#建議的log位置
4255
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
4256
 
4257
PHP;
4258
 
4259
						#要執行的php程式內容,繼承本函式參數
4260
						$cmdString=$cmdString.PHP_EOL."\$conf=(array)(json_decode(urldecode(base64_decode(\"".base64_encode(urlencode(json_encode($conf)))."\"))));";
4261
 
4262
						#要執行的php程式內容,置換要執行的路徑
4263
						$cmdString=$cmdString.PHP_EOL."\$conf[\"searchPath\"]=array(\"".$NodePathAndName."\");";
4264
 
4265
						#要執行的php程式內容
4266
						$cmdString=$cmdString.PHP_EOL.<<<'PHP'
4267
 
4268
#函式說明:
4269
#更新程式檔案開頭版權宣告的年份
4270
#回傳結果:
4271
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4272
#$reuslt["error"],執行不正常結束的錯訊息陣列.
4273
#$result["function"],當前執行的函式名稱.
4274
#$result["content"],有更新的檔案清單,其元素有被取代的檔案路徑與名稱跟replacedInfo,其中replacedInfo為陣列,其key為要變動的行號(從0開始算),其數值有"from"代表要被取代的原始內容,"to"代表要置換成的新內容.
4275
#$result["scannedFile"],陣列,有檢查過的檔案清單其完整路徑與檔案名稱.
4276
#必填參數:
4277
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4278
#$conf["fileArgu"]=__FILE__;
4279
#可省略參數:
4280
#$conf["replaceFrom"],陣列,目標關鍵字,每個元素代表一行的內容,預設內容可參照本檔案開頭的版權宣告文字.
4281
#$conf["replaceFrom"]=array();
4282
#$conf["yearFrom],字串,起始年份,預設為西元"2014"年.
4283
#$conf["yearFrom"]="2014";
4284
#$conf["yearTo],字串,結束年份,預設為西元"gmdate('Y')"年.
4285
#$conf["yearTo"]=gmdate('Y');
4286
#$conf["Authors"],陣列,該套件的參與者,預設為array("Min-Jhin,Chen");
4287
#$conf["Authors"]=array("Min-Jhin,Chen");
4288
#$conf["searchPath"],陣列,要搜尋哪些地方的檔案要更新版權宣告年份,預設為使用中的本套件位置.
4289
#$conf["searchPath"]=array("");
4290
#$conf["skipHiddenFolder"],字串,要略過隱藏的資料夾,預設為"true";反之為"false";
4291
#$conf["skipHiddenFolder"]="true";
4292
#$conf["includeHiddenFolder"],陣列,符合名稱的隱藏資料夾會存取,預設不指定;
4293
#$conf["includeHiddenFolder"]=array("");
4294
#$conf["excludeDirName"],陣列,哪些目錄名稱要忽略,預設有"free-lib"、"no-free-lib"、"composer".
4295
#$conf["excludeDirName"]=array("free-lib","no-free-lib","composer");
4296
#$conf["excludeMineType"],陣列,哪些檔案類型要忽略,預設有"image/*"、"video/*"、"audio/*"、"media/*"、"application/*".
4297
#$conf["excludeMineType"]=array("image/*","video/*","audio/*","media/*","application/*");
4298
#$conf["excludeSecondName"],陣列,哪些附檔名的檔案要忽略,預設有"log"、"csv"、"sql"、"js"、"css"、"html".
4299
#$conf["excludeSecondName"]=array("log"、,"csv","sql","js","css","html");
4300
#$conf["multiThread"],字串,是否要啟用多執行序,預設為"false",反之為"true".
4301
#$conf["multiThread"]="false";
4302
#參考資料:
4303
#無.
4304
#備註:
4305
#無.
4306
$updateCopyRightYear=phpLib::updateCopyRightYear($conf);
4307
unset($conf);
4308
 
4309
#輸出json結果
4310
echo json_encode($updateCopyRightYear);
4311
PHP;
4312
 
4313
						#設置多執行序的類型
4314
						$threadType=$conf["threadType"];
4315
 
218 liveuser 4316
						#debug,break point
4317
						var_dump(__LINE__,$threadType);exit(1);
4318
 
3 liveuser 4319
						#判斷多執行序的類型
4320
						switch($threadType){
4321
 
4322
							#若是直接用 proc
4323
							case "proc":
4324
 
4325
								#函式說明:
4326
								#透過proc來多執行序運作.
4327
								#回傳結果:
4328
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4329
								#$reuslt["error"],執行不正常結束的錯訊息陣列.
4330
								#$result["function"],當前執行的函式名稱.
4331
								#$result["argu"],使用的參數.
4332
								#$result["content"],陣列,每個元素為其指令執行的結果訊息陣列,key為"status"代表執行是否正常的識別;key為"statusCode"代表程式結束後回傳給對應executeBy程式的數值;key為"output"代表標準輸出,若為resource,則代表為pipe;key為"error"代表非標準輸出,若為resource,則代表為pipe;key為"input"代表成功輸入的指令;key為"process"代表該程序經proc_open後的process source;key為"proc_get_status"代表程序的資訊.
4333
								#必填參數:
4334
								#$conf["cmds"],字串陣列,每個元素代表要執行的指令與參數.
4335
								$conf["threads::proc"]["cmds"]=array("php -r ".escapeshellarg($cmdString));
4336
								#可省略參數:
4337
								#$conf["wait"],字串,是否需要等待所有程序結束,預設為"true"要等待;反之為"false"不要等待.
4338
								$conf["threads::proc"]["wait"]="false";
4339
								#$conf["workingDir"],字串陣列,個別程式執行時的家目錄,預設不指定.
4340
								$conf["threads::proc"]["workingDir"]=array($NodePathAndName);
4341
								#$conf["envs"],2維字串陣列,每個元素代表個別程式執行時的指定環境變數,key變數名稱;value為變數內容.預設為array("QBPWCF" => "Quick Build PHP Website Componment base on Fedora Linux");
4342
								#$conf["envs"]=array(array("key"=>"value"));
4343
								#$conf["executeBy"],字串陣列,每個元素代表個別指令要用什麼程式執行,預設為"bash".
4344
								#$conf["threads::proc"]["executeBy"]=array("php");
4345
								#參考資料:
4346
								#https://www.php.net/manual/en/function.proc-open.php
4347
								#https://www.php.net/manual/en/function.proc-get-status.php
4348
								#備註:
4349
								#無.
4350
								$proc=threads::proc($conf["threads::proc"]);
4351
								unset($conf["threads::proc"]);
4352
 
4353
								#如果執行失敗
4354
								if($proc["status"]==="false"){
4355
 
4356
									#設置錯誤識別
4357
									$result["status"]="false";
4358
 
4359
									#設置錯誤訊息
4360
									$result["error"]=$proc;
4361
 
4362
									#回傳結果
4363
									return $result;
4364
 
4365
									}#if end
4366
 
4367
								#如果有開啟 log
4368
								if(isset($conf["log"])){
4369
 
4370
									#函式說明:
4371
									#撰寫log
4372
									#回傳結果:
4373
									#$result["status"],狀態,"true"或"false".
4374
									#$result["error"],錯誤訊息陣列.
4375
									#$result["function"],當前函式的名稱.
4376
									#$result["argu"],使用的參數.
4377
									#必填參數:
4378
									#$conf["path"],字串,log檔案的路徑與名稱.
4379
									$conf["logs::record"]["path"]=$conf["log"];
4380
									#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4381
									$conf["logs::record"]["content"]=$proc;
4382
									#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4383
									$conf["logs::record"]["fileArgu"]=$conf["fileArgu"];
4384
									#可省略參數:
4385
									#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4386
									#$conf["rewrite"]="false";
4387
									#參考資料:
4388
									#無.
4389
									#備註:
4390
									#無.
4391
									$record=logs::record($conf["logs::record"]);
4392
									unset($conf["logs::record"]);
4393
 
4394
									#如果出錯
4395
									if($record["status"]==="false"){
4396
 
4397
										#設置錯誤識別
4398
										$result["status"]="false";
4399
 
4400
										#設置錯誤訊息
4401
										$result["error"]=$record;
4402
 
4403
										#印出json
4404
										echo json_encode($result);
4405
 
4406
										#結束執行,回傳1給shell,代表異常,
4407
										exit(1);
4408
 
4409
										}#if end
4410
 
4411
									}#if end
4412
 
4413
								#儲存要執行的程序
4414
								$procs[]=$proc;
4415
 
4416
								#結束 switch
4417
								break;
4418
 
4419
							#如果是要透過 socket 來執行
4420
							case "socket":
4421
 
4422
								#函式說明:
4423
								#透過 unix socket 來多執行序運作.
4424
								#回傳結果:
4425
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4426
								#$reuslt["error"],執行不正常結束的錯訊息陣列.
4427
								#$result["function"],當前執行的函式名稱.
4428
								#$result["argu"],使用的參數.
4429
								#$result["content"],陣列,每個元素為cmds參數中個別元素其指令傳送後得到的uuid,可透過sock::getProcInfo來查詢結果.
4430
								#必填參數:
4431
								#$conf["cmds"],字串陣列,每個元素代表要執行的指令與參數.
4432
								$conf["threads::socket"]["cmds"]=array("php -r ".escapeshellarg($cmdString));
4433
								#可省略參數:
4434
								#$conf["sock"],字串,要連線的 usr/bin/qbpwcf-sock.php 所產生的 unix domain socket 路徑與名稱,預設為 qbpwcf_usock_path.
4435
								$conf["threads::socket"]["sock"]=$conf["socket"];
4436
								#參考資料:
4437
								#無
4438
								#備註:
4439
								#需要透過sock::unixDomainSockServer來運行.
4440
								$socket=threads::socket($conf["threads::socket"]);
4441
								unset($conf["threads::socket"]);
4442
 
4443
								#如果執行失敗
4444
								if($socket["status"]==="false"){
4445
 
4446
									#設置錯誤識別
4447
									$result["status"]="false";
4448
 
4449
									#設置錯誤訊息
218 liveuser 4450
									$result["error"]=$socket;
3 liveuser 4451
 
4452
									#回傳結果
4453
									return $result;
4454
 
4455
									}#if end
4456
 
4457
								#如果有開啟 log
4458
								if(isset($conf["log"])){
4459
 
4460
									#函式說明:
4461
									#撰寫log
4462
									#回傳結果:
4463
									#$result["status"],狀態,"true"或"false".
4464
									#$result["error"],錯誤訊息陣列.
4465
									#$result["function"],當前函式的名稱.
4466
									#$result["argu"],使用的參數.
4467
									#必填參數:
4468
									#$conf["path"],字串,log檔案的路徑與名稱.
4469
									$conf["logs::record"]["path"]=$conf["log"];
4470
									#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4471
									$conf["logs::record"]["content"]=$socket;
4472
									#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4473
									$conf["logs::record"]["fileArgu"]=$conf["fileArgu"];
4474
									#可省略參數:
4475
									#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4476
									#$conf["rewrite"]="false";
4477
									#參考資料:
4478
									#無.
4479
									#備註:
4480
									#無.
4481
									$record=logs::record($conf["logs::record"]);
4482
									unset($conf["logs::record"]);
4483
 
4484
									#如果出錯
4485
									if($record["status"]==="false"){
4486
 
4487
										#設置錯誤識別
4488
										$result["status"]="false";
4489
 
4490
										#設置錯誤訊息
4491
										$result["error"]=$record;
4492
 
4493
										#印出json
4494
										echo json_encode($result);
4495
 
4496
										#結束執行,回傳1給shell,代表異常,
4497
										exit(1);
4498
 
4499
										}#if end
4500
 
4501
									}#if end
4502
 
4503
								#儲存要執行的程序
4504
								$procs[]=$socket;
4505
 
4506
								#結束 switch
4507
								break;
4508
 
4509
							#其他類型
4510
							default:
4511
 
4512
								#設置錯誤識別
4513
								$result["status"]="false";
4514
 
4515
								#設置錯誤訊息
4516
								$result["error"][]="not supported multi threads type ".$threadType;
4517
 
4518
								#印出json
4519
								echo json_encode($result);
4520
 
4521
								#結束執行,回傳1給shell,代表異常,
4522
								exit(1);
4523
 
4524
							}#switch end
4525
 
4526
						}#else end
4527
 
4528
					}#if end
4529
 
4530
				#反之如果是檔案
4531
				else if($node["nType"]==="-"){
4532
 
4533
					#針對每個要忽略的 mime type
4534
					foreach($conf["excludeMineType"] as $mimeType){
4535
 
4536
						#取得 "/*" 的位置
4537
						$positionOfSlashStar=strpos($mimeType,"/*");
4538
 
4539
						#如果是含有 "/*" 的廣義 mime 類型
4540
						if($positionOfSlashStar!==false){
4541
 
4542
							#取得 廣義類型的內容
4543
							$ignoredWileMimeTypeWithSlash=substr($mimeType,0,$positionOfSlashStar+1);
4544
 
4545
							#debug
4546
							#var_dump(__LINE__,$ignoredWileMimeTypeWithSlash);
4547
 
4548
							#如果是要忽略的 廣義類型內容
4549
							if(strpos($node["mimeType"],$ignoredWileMimeTypeWithSlash)===0){
4550
 
4551
								#跳過之
4552
								continue 2;
4553
 
4554
								}#if end
4555
 
4556
							}#if end
4557
 
4558
						#反之
4559
						else{
4560
 
4561
							#如果是要忽略的 mime 類型
4562
							if($mimeType===$node["mimeType"]){
4563
 
4564
								#跳過之
4565
								continue 2;
4566
 
4567
								}#if end
4568
 
4569
							}#else end
4570
 
4571
						}#foreach end
4572
 
4573
					#如果有副檔案名存在
4574
					if(isset($node["secondName"])){
4575
 
4576
						#如果是要忽略的附檔名
4577
						if(in_array($node["secondName"],$conf["excludeSecondName"])){
4578
 
4579
							#跳過檔案
4580
							continue;
4581
 
4582
							}#if end
4583
 
4584
						}#if end
4585
 
4586
					#記錄有掃描的檔案路徑與名稱 
4587
					$result["scannedFile"][]=$NodePathAndName;
4588
 
218 liveuser 4589
					#debug
4590
					var_dump(__LINE__,"found file:".$NodePathAndName." mimeType:".$node["mimeType"]);
3 liveuser 4591
 
218 liveuser 4592
					#如果沒有用多執行序
4593
					if($conf["multiThread"]==="false"){
3 liveuser 4594
 
218 liveuser 4595
						#取得檔案的內容
4596
						#函式說明:
4597
						#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
4598
						#回傳的變數說明:
4599
						#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
4600
						#$result["error"],錯誤訊息提示.
4601
						#$result["warning"],警告訊息.
4602
						#$result["function"],當前執行的函數名稱.
4603
						#$result["fileContent"],爲檔案的內容陣列.
4604
						#$result["lineCount"],爲檔案內容總共的行數.
4605
						#$result["fullContent"],為檔案的完整內容.
4606
						#$result["base64data"],為檔案的base64內容.
4607
						#$result["mimeType"],為檔案的mime type.
4608
						#必填參數:
4609
						#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
4610
						$conf["fileAccess::getFileContent"]["filePositionAndName"]=$NodePathAndName;
4611
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4612
						$conf["fileAccess::getFileContent"]["fileArgu"]=$conf["fileArgu"];
4613
						#可省略參數:
4614
						#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
4615
						#$conf["web"]="true";
4616
						#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
4617
						#$conf["createIfnotExist"]="false";
4618
						#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
4619
						#$conf["autoDeleteSpaceOnEachLineStart"]="false";
4620
						#參考資料:
4621
						#file(),取得檔案內容的行數.
4622
						#file=>http:#php.net/manual/en/function.file.php
4623
						#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
4624
						#filesize=>http://php.net/manual/en/function.filesize.php
4625
						#參考資料:
4626
						#無.
4627
						#備註:
4628
						#無.
4629
						$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
4630
						unset($conf["fileAccess::getFileContent"]);
3 liveuser 4631
 
218 liveuser 4632
						#如果執行失敗
4633
						if($getFileContent["status"]==="false"){
4634
 
4635
							#設置錯誤識別
4636
							$result["status"]="false";
3 liveuser 4637
 
218 liveuser 4638
							#設置錯誤訊息
4639
							$result["error"]=$getFileContent;
3 liveuser 4640
 
218 liveuser 4641
							#回傳結果
4642
							return $result;
3 liveuser 4643
 
4644
							}#if end
4645
 
218 liveuser 4646
						#關鍵字行搜尋的索引預設數值為0
4647
						$keyWordLineIndex=0;
4648
 
4649
						#針對檔案每行原始內容
4650
						for($oriLineContentIndex=0;$oriLineContentIndex<$getFileContent["lineCount"];$oriLineContentIndex++){
3 liveuser 4651
 
218 liveuser 4652
							#取得原始內容行
4653
							$oriLineContent=$getFileContent["fileContent"][$oriLineContentIndex];
3 liveuser 4654
 
218 liveuser 4655
							#預設調整後的原始內容跟原本一樣
4656
							$modifiedOriLineContent=$oriLineContent;
3 liveuser 4657
 
4658
							#如果要log
4659
							if(isset($conf["log"])){
4660
 
218 liveuser 4661
								#提示正在比對哪個檔案的第幾行
4662
								$log="比對 檔案(".$path.$node["name"].") 的第 ".($oriLineContentIndex+1)." 行...".PHP_EOL;
4663
 
4664
								#提示原始內容
4665
								$log=$log."原始內容為:".PHP_EOL;
4666
 
4667
								#印出原始內容
4668
								$log=$log.$oriLineContent.PHP_EOL;
4669
 
3 liveuser 4670
								#log的路徑與名稱
218 liveuser 4671
								$logPath="/tmp/".basename($conf["log"]).":".$uuid.":".$node["name"].".log";
3 liveuser 4672
 
4673
								#函式說明:
4674
								#撰寫log
4675
								#回傳結果:
4676
								#$result["status"],狀態,"true"或"false".
4677
								#$result["error"],錯誤訊息陣列.
4678
								#$result["function"],當前函式的名稱.
4679
								#$result["argu"],使用的參數.
4680
								#必填參數:
4681
								#$conf["path"],字串,log檔案的路徑與名稱.
218 liveuser 4682
								$conf["logs::record"]["path"]=$logPath;
3 liveuser 4683
								#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4684
								$conf["logs::record"]["content"]=$log;
4685
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4686
								$conf["logs::record"]["fileArgu"]=__FILE__;
4687
								#可省略參數:
4688
								#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4689
								#$conf["rewrite"]="false";
4690
								#參考資料:
4691
								#無.
4692
								#備註:
4693
								#無.
4694
								$record=logs::record($conf["logs::record"]);
4695
								unset($conf["logs::record"]);
4696
 
4697
								#如果出錯
4698
								if($record["status"]==="false"){
4699
 
4700
									#設置錯誤識別
4701
									$result["status"]="false";
4702
 
4703
									#設置錯誤訊息
4704
									$result["error"]=$getFileContent;
4705
 
4706
									#回傳結果
4707
									return $result;
4708
 
4709
									}#if end
4710
 
4711
								}#if end
4712
 
4713
							#無窮迴圈
4714
							while(true){
4715
 
218 liveuser 4716
								#嘗試移除開頭的 空格 跟 \t
4717
 
3 liveuser 4718
								#函式說明:
4719
								#取得符合多個特定字首與字尾的字串
4720
								#回傳結果:
4721
								#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
4722
								#$result["function"],當前執行的函數名稱.
4723
								#$result["error"],錯誤訊息陣列.
4724
								#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
4725
								#$result["content"],符合條件的字串,去掉字首字尾後的結果.
4726
								#$result["returnString"],爲符合字首字、尾條件的字串內容.
4727
								#$result["meetConditions"],為符合的條件,會是$conf["keyWord"]中的其中一個元素.
4728
								#$result["argu"],使用的參數.
4729
								#必填參數:
4730
								#$conf["checkString"],字串,要檢查的字串.
218 liveuser 4731
								$conf["search::getMeetMultiConditionsString"]["checkString"]=$modifiedOriLineContent;
3 liveuser 4732
								#$conf["keyWord"],字串陣列,用來檢查字首、字尾應該要有哪些字串之一,每個元素代表一個可能的條件,key為front者代表開頭的關鍵字,key為tail為代表結尾的官關鍵字.
4733
								$conf["search::getMeetMultiConditionsString"]["keyWord"]=array(array("front"=>" "),array("front"=>"\t"));
4734
								#可省略參數:
4735
								#無.
4736
								#參考資料:
4737
								#無.
4738
								#備註:
4739
								#無.
4740
								$getMeetMultiConditionsString=search::getMeetMultiConditionsString($conf["search::getMeetMultiConditionsString"]);
4741
								unset($conf["search::getMeetMultiConditionsString"]);
4742
 
4743
								#debug
4744
								#var_dump(__LINE__,$getMeetMultiConditionsString);
4745
 
4746
								#如果執行失敗
4747
								if($getMeetMultiConditionsString["status"]==="false"){
4748
 
4749
									#設置錯誤識別
4750
									$result["status"]="false";
4751
 
4752
									#設置錯誤訊息
4753
									$result["error"]=$getMeetMultiConditionsString;
4754
 
4755
									#回傳結果
4756
									return $result;
4757
 
4758
									}#if end
4759
 
4760
								#如果有關鍵字存在
4761
								if($getMeetMultiConditionsString["founded"]==="true"){
4762
 
218 liveuser 4763
									#取得已經移開頭空格跟\t後的內容
4764
									$modifiedOriLineContent=$getMeetMultiConditionsString["content"];
4765
 
3 liveuser 4766
									#繼續檢查
4767
									continue;
218 liveuser 4768
 
3 liveuser 4769
									}#if end
218 liveuser 4770
 
3 liveuser 4771
								#到這表代表已經移除開頭的 空格 跟 \t
218 liveuser 4772
 
3 liveuser 4773
								#結束 while
4774
								break;
218 liveuser 4775
 
3 liveuser 4776
								}#while end
4777
 
218 liveuser 4778
							#針對每個關鍵字
4779
							for(;$keyWordLineIndex<count($conf["replaceFrom"]);$keyWordLineIndex++){
3 liveuser 4780
 
218 liveuser 4781
								#取得關鍵字行的內容
4782
								$keyWordLine=$conf["replaceFrom"][$keyWordLineIndex];
3 liveuser 4783
 
218 liveuser 4784
								#如果要log
4785
								if(isset($conf["log"])){
3 liveuser 4786
 
218 liveuser 4787
									#提示期望的內容格式
4788
									$log="期望的第 ".($keyWordLineIndex+1)." 個行內容格式為:".PHP_EOL;
3 liveuser 4789
 
218 liveuser 4790
									#提示期望的內容
4791
									$log=$log.$keyWordLine.PHP_EOL;
3 liveuser 4792
 
218 liveuser 4793
									#log的路徑與名稱
4794
									$logPath="/tmp/".basename($conf["log"]).":".$uuid.":".$node["name"].".log";
3 liveuser 4795
 
4796
									#函式說明:
218 liveuser 4797
									#撰寫log
3 liveuser 4798
									#回傳結果:
218 liveuser 4799
									#$result["status"],狀態,"true"或"false".
3 liveuser 4800
									#$result["error"],錯誤訊息陣列.
218 liveuser 4801
									#$result["function"],當前函式的名稱.
3 liveuser 4802
									#$result["argu"],使用的參數.
4803
									#必填參數:
218 liveuser 4804
									#$conf["path"],字串,log檔案的路徑與名稱.
4805
									$conf["logs::record"]["path"]=$logPath;
4806
									#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4807
									$conf["logs::record"]["content"]=$log;
4808
									#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4809
									$conf["logs::record"]["fileArgu"]=__FILE__;
3 liveuser 4810
									#可省略參數:
218 liveuser 4811
									#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4812
									#$conf["rewrite"]="false";
3 liveuser 4813
									#參考資料:
4814
									#無.
4815
									#備註:
4816
									#無.
218 liveuser 4817
									$record=logs::record($conf["logs::record"]);
4818
									unset($conf["logs::record"]);
4819
 
4820
									#如果出錯
4821
									if($record["status"]==="false"){
4822
 
3 liveuser 4823
										#設置錯誤識別
4824
										$result["status"]="false";
4825
 
4826
										#設置錯誤訊息
218 liveuser 4827
										$result["error"]=$getFileContent;
3 liveuser 4828
 
4829
										#回傳結果
4830
										return $result;
4831
 
4832
										}#if end
218 liveuser 4833
 
4834
									}#if end
4835
 
4836
								#調整過的關鍵字內容行預設跟原始關鍵行內容一樣
4837
								$modifiedKeyWordLine=$keyWordLine;
4838
 
4839
								#初始化關鍵字前面的內容(可能有為多個空格或tab)
4840
								$keyWordContentOfHead="";
4841
 
4842
								#無窮迴圈
4843
								while(true){
4844
 
4845
									#嘗試剔除開頭的 空格 跟 "\t"
4846
 
3 liveuser 4847
									#函式說明:
218 liveuser 4848
									#取得符合多個特定字首與字尾的字串
3 liveuser 4849
									#回傳結果:
218 liveuser 4850
									#$result["status"],若爲"true"則代表執行正常;若爲"false"則代表執行失敗。
4851
									#$result["function"],當前執行的函數名稱.
3 liveuser 4852
									#$result["error"],錯誤訊息陣列.
218 liveuser 4853
									#$result["founded"],若為"true"則代表有找到符合字首條件的結果;若爲"false"則代表沒有找到。
4854
									#$result["content"],符合條件的字串,去掉字首字尾後的結果.
4855
									#$result["returnString"],爲符合字首字、尾條件的字串內容.
4856
									#$result["meetConditions"],為符合的條件,會是$conf["keyWord"]中的其中一個元素.
3 liveuser 4857
									#$result["argu"],使用的參數.
4858
									#必填參數:
218 liveuser 4859
									#$conf["checkString"],字串,要檢查的字串.
4860
									$conf["search::getMeetMultiConditionsString"]["checkString"]=$modifiedKeyWordLine;
4861
									#$conf["keyWord"],字串陣列,用來檢查字首、字尾應該要有哪些字串之一,每個元素代表一個可能的條件,key為front者代表開頭的關鍵字,key為tail為代表結尾的官關鍵字.
4862
									$conf["search::getMeetMultiConditionsString"]["keyWord"]=array(array("front"=>" "),array("front"=>"\t"));
3 liveuser 4863
									#可省略參數:
218 liveuser 4864
									#無.
3 liveuser 4865
									#參考資料:
4866
									#無.
4867
									#備註:
4868
									#無.
218 liveuser 4869
									$getMeetMultiConditionsString=search::getMeetMultiConditionsString($conf["search::getMeetMultiConditionsString"]);
4870
									unset($conf["search::getMeetMultiConditionsString"]);
3 liveuser 4871
 
4872
									#debug
218 liveuser 4873
									#var_dump(__LINE__,$getMeetMultiConditionsString);
3 liveuser 4874
 
4875
									#如果執行失敗
218 liveuser 4876
									if($getMeetMultiConditionsString["status"]==="false"){
3 liveuser 4877
 
4878
										#設置錯誤識別
4879
										$result["status"]="false";
4880
 
4881
										#設置錯誤訊息
218 liveuser 4882
										$result["error"]=$getMeetMultiConditionsString;
3 liveuser 4883
 
4884
										#回傳結果
4885
										return $result;
4886
 
4887
										}#if end
4888
 
218 liveuser 4889
									#如果有關鍵字存在
4890
									if($getMeetMultiConditionsString["founded"]==="true"){
3 liveuser 4891
 
218 liveuser 4892
										#取得移除開頭 空格 跟 \t 後的內容
4893
										$modifiedKeyWordLine=$getMeetMultiConditionsString["content"];
3 liveuser 4894
 
218 liveuser 4895
										#取得關鍵字前面的內容
4896
										$keyWordContentOfHead=substr($keyWordLine,0,strlen($keyWordLine)-strlen($modifiedKeyWordLine));
3 liveuser 4897
 
218 liveuser 4898
										#繼續檢查
4899
										continue;
4900
 
3 liveuser 4901
										}#if end
218 liveuser 4902
 
4903
									#到這表代表已經移除開頭的 空格 跟 \t
4904
 
4905
									#結束 while
4906
									break;
3 liveuser 4907
 
218 liveuser 4908
									}#while end
4909
 
4910
								#debug
4911
								#var_dump(__LINE__,$modifiedOriLineContent,$modifiedKeyWordLine);
4912
 
4913
								#預設分段的關鍵字為空
4914
								$keyWordPart=array();
4915
 
4916
								#預設該行的變數為空
4917
								$varPart=array();
4918
 
4919
								#關鍵字行的結構順序
4920
								$OderOfPartInLine=array();
4921
 
4922
								#無窮迴圈
4923
								while(true){
4924
 
4925
									#判斷是否含有 "${"、"}" 關鍵字
3 liveuser 4926
									#函式說明:
218 liveuser 4927
									#檢查一個字串裡面是否有多個關鍵字
3 liveuser 4928
									#回傳結果:
218 liveuser 4929
									#$result["status"],"true"代表執行成功,"false"代表執行失敗.
4930
									#$result["error"],錯誤訊息.
3 liveuser 4931
									#$result["function"],當前執行的函數名稱.
218 liveuser 4932
									#$result["founded"],是否有找到的關鍵字,"true"代表有找到關鍵字;"false"代表沒有找到關鍵字.
4933
									#$result["foundedKeyWords"],找到的關鍵字.
4934
									#$result["foundedAll"],是否有找到全部的關鍵字,"true"代表有;"false"代表沒有.
3 liveuser 4935
									#$result["argu"],使用的參數.
4936
									#必填參數:
218 liveuser 4937
									#$conf["keyWords"],字串陣列,想要搜尋的關鍵字.
4938
									$conf["search::findManyKeyWords"]["keyWords"]=array("\${","}");
4939
									#$conf["string"],字串,要被搜尋的字串內容.
4940
									$conf["search::findManyKeyWords"]["string"]=$modifiedKeyWordLine;
3 liveuser 4941
									#可省略參數:
218 liveuser 4942
									#$conf["completeEqual"],字串,是否內容要完全符合,不能多出任何不符合的內容,預設為不需要完全符合.
4943
									#$conf["completeEqual"]="true";
3 liveuser 4944
									#參考資料:
4945
									#無.
4946
									#備註:
4947
									#無.
218 liveuser 4948
									$findManyKeyWords=search::findManyKeyWords($conf["search::findManyKeyWords"]);
4949
									unset($conf["search::findManyKeyWords"]);
3 liveuser 4950
 
4951
									#如果執行失敗
218 liveuser 4952
									if($findManyKeyWords["status"]==="false"){
3 liveuser 4953
 
4954
										#設置錯誤識別
4955
										$result["status"]="false";
4956
 
4957
										#設置錯誤訊息
218 liveuser 4958
										$result["error"]=$findManyKeyWords;
3 liveuser 4959
 
4960
										#回傳結果
4961
										return $result;
4962
 
4963
										}#if end
4964
 
218 liveuser 4965
									#如果有 "${"、"}" 存在
4966
									if($findManyKeyWords["foundedAll"]==="true"){
3 liveuser 4967
 
218 liveuser 4968
										#debug
4969
										#var_dump(__LINE__,$findManyKeyWords);
4970
 
4971
										#取得 ${... 前面的部分
4972
										#函式說明:
4973
										#將字串特定關鍵字與其後面的內容剔除
4974
										#回傳結果:
4975
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4976
										#$result["error"],錯誤訊息陣列.
4977
										#$result["warning"],警告訊息鎮列.
4978
										#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
4979
										#$result["function"],當前執行的函數名稱.
4980
										#$result["oriStr"],要處理的原始字串內容.
4981
										#$result["content"],處理好的的字串內容.
4982
										#$result["argu"],使用的參數.
4983
										#必填參數:
4984
										#$conf["stringIn"],字串,要處理的字串.
4985
										$conf["stringProcess::delStrAfterKeyWord"]["stringIn"]=$modifiedKeyWordLine;
4986
										#$conf["keyWord"],字串,特定字串.
4987
										$conf["stringProcess::delStrAfterKeyWord"]["keyWord"]="\${";
4988
										#可省略參數:
4989
										#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
4990
										#$conf["deleteLastRepeatedOne"]="";
4991
										#參考資料:
4992
										#無.
4993
										#備註:
4994
										#無.
4995
										$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
4996
										unset($conf["stringProcess::delStrAfterKeyWord"]);
3 liveuser 4997
 
218 liveuser 4998
										#debug
4999
										#var_dump(__LINE__,$delStrAfterKeyWord);
3 liveuser 5000
 
218 liveuser 5001
										#如果執行失敗
5002
										if($delStrAfterKeyWord["status"]==="false"){
5003
 
5004
											#設置錯誤識別
5005
											$result["status"]="false";
5006
 
5007
											#設置錯誤訊息
5008
											$result["error"]=$delStrAfterKeyWord;
5009
 
5010
											#回傳結果
5011
											return $result;
5012
 
5013
											}#if end
5014
 
5015
										#如果要有關鍵字找不到
5016
										if($delStrAfterKeyWord["founded"]==="false"){
5017
 
5018
											#設置錯誤識別
5019
											$result["status"]="false";
5020
 
5021
											#設置錯誤訊息
5022
											$result["error"]=$delStrAfterKeyWord;
5023
 
5024
											#回傳結果
5025
											return $result;
5026
 
5027
											}#if end
5028
 
5029
										#如果前面有內容
5030
										if($delStrAfterKeyWord["content"]!==""){
5031
 
5032
											#儲存該行的關鍵字之一
5033
											$keyWordPart[]=$delStrAfterKeyWord["content"];
5034
 
5035
											#暫存的關鍵字資訊
5036
											$tmp=array("name"=>"keyWordPart","index"=>count($keyWordPart)-1,"value"=>$keyWordPart[count($keyWordPart)-1]);
5037
 
5038
											#設置順序資訊
5039
											$OderOfPartInLine[]=$tmp;
5040
 
5041
											}#if end
5042
 
5043
										#取得 }... 前面的部分
5044
										#函式說明:
5045
										#將字串特定關鍵字與其後面的內容剔除
5046
										#回傳結果:
5047
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5048
										#$result["error"],錯誤訊息陣列.
5049
										#$result["warning"],警告訊息鎮列.
5050
										#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
5051
										#$result["function"],當前執行的函數名稱.
5052
										#$result["oriStr"],要處理的原始字串內容.
5053
										#$result["content"],處理好的的字串內容.
5054
										#$result["argu"],使用的參數.
5055
										#必填參數:
5056
										#$conf["stringIn"],字串,要處理的字串.
5057
										$conf["stringProcess::delStrAfterKeyWord"]["stringIn"]=$delStrAfterKeyWord["deleted"];
5058
										#$conf["keyWord"],字串,特定字串.
5059
										$conf["stringProcess::delStrAfterKeyWord"]["keyWord"]="}";
5060
										#可省略參數:
5061
										#$conf["deleteLastRepeatedOne"],字串,預設為"false";若為"true"則代表連續遇到同 $conf["keyWord"] 的內容,要將移除內容的起點往後移動到為後一個 $conf["keyWord"].
5062
										#$conf["deleteLastRepeatedOne"]="";
5063
										#參考資料:
5064
										#無.
5065
										#備註:
5066
										#無.
5067
										$delStrAfterKeyWord=stringProcess::delStrAfterKeyWord($conf["stringProcess::delStrAfterKeyWord"]);
5068
										unset($conf["stringProcess::delStrAfterKeyWord"]);
5069
 
5070
										#debug
5071
										#var_dump(__LINE__,$delStrAfterKeyWord);
5072
 
5073
										#如果執行失敗
5074
										if($delStrAfterKeyWord["status"]==="false"){
5075
 
5076
											#設置錯誤識別
5077
											$result["status"]="false";
5078
 
5079
											#設置錯誤訊息
5080
											$result["error"]=$delStrAfterKeyWord;
5081
 
5082
											#回傳結果
5083
											return $result;
5084
 
5085
											}#if end
5086
 
5087
										#如果要有關鍵字找不到
5088
										if($delStrAfterKeyWord["founded"]==="false"){
5089
 
5090
											#設置錯誤識別
5091
											$result["status"]="false";
5092
 
5093
											#設置錯誤訊息
5094
											$result["error"]=$delStrAfterKeyWord;
5095
 
5096
											#回傳結果
5097
											return $result;
5098
 
5099
											}#if end
5100
 
5101
										#儲存該行的變數名稱之一
5102
										$varPart[]=$delStrAfterKeyWord["content"]."}";
5103
 
5104
										#移除 "}" 其面的內容
5105
										#函式說明:
5106
										#將字串特定關鍵字與其前面的內容剔除
5107
										#回傳結果:
5108
										#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5109
										#$result["error"],錯誤訊息陣列.
5110
										#$result["warning"],警告訊息鎮列.
5111
										#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
5112
										#$result["function"],當前執行的函數名稱.
5113
										#$result["argu"],使用的參數.
5114
										#$result["oriStr"],要處理的原始字串內容.
5115
										#$result["content"],處理好的的字串內容.
5116
										#$result["deleted"],被移除的內容.
5117
										#必填參數:
5118
										#$conf["stringIn"],字串,要處理的字串.
5119
										$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedKeyWordLine;
5120
										#$conf["keyWord"],字串,特定字串.
5121
										$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]="}";
5122
										#可省略參數:
5123
										#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
5124
										#$conf["recursive"]="true";
5125
										#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
5126
										#$conf["lastResult"]=$delStrBeforeKeyWord;
5127
										#參考資料:
5128
										#無.
5129
										#備註:
5130
										#無.
5131
										$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
5132
										unset($conf["stringProcess::delStrBeforeKeyWord"]);
5133
 
5134
										#如果執行失敗
5135
										if($delStrBeforeKeyWord["status"]==="false"){
5136
 
5137
											#設置錯誤識別
5138
											$result["status"]="false";
5139
 
5140
											#設置錯誤訊息
5141
											$result["error"]=$delStrBeforeKeyWord;
5142
 
5143
											#回傳結果
5144
											return $result;
5145
 
5146
											}#if end
5147
 
5148
										#如果要有關鍵字找不到
5149
										if($delStrBeforeKeyWord["founded"]==="false"){
5150
 
5151
											#設置錯誤識別
5152
											$result["status"]="false";
5153
 
5154
											#設置錯誤訊息
5155
											$result["error"]=$delStrBeforeKeyWord;
5156
 
5157
											#回傳結果
5158
											return $result;
5159
 
5160
											}#if end
5161
 
5162
										#取得剩下的部分
5163
										$modifiedKeyWordLine=$delStrBeforeKeyWord["content"];
5164
 
5165
										#暫存的關鍵字資訊
5166
										$tmp=array("name"=>"varPart","index"=>count($varPart)-1,"value"=>$varPart[count($varPart)-1]);
5167
 
5168
										#設置順序資訊
5169
										$OderOfPartInLine[]=$tmp;
5170
 
5171
										#下一輪檢查有無變數關鍵字
5172
										continue;
5173
 
3 liveuser 5174
										}#if end
5175
 
5176
									#debug
5177
									#var_dump(__LINE__,$OderOfPartInLine);
5178
 
218 liveuser 5179
									#如果有關鍵字片段與變數的順序存在
5180
									if( count($OderOfPartInLine)>0 ){
3 liveuser 5181
 
5182
										#debug
218 liveuser 5183
										#var_dump(__LINE__,$OderOfPartInLine);
3 liveuser 5184
 
218 liveuser 5185
										#針對每個資訊
5186
										foreach($OderOfPartInLine as $index=>$condition){
3 liveuser 5187
 
218 liveuser 5188
											#debug
5189
											#var_dump(__LINE__,$index,$condition);
3 liveuser 5190
 
218 liveuser 5191
											#判斷資訊
5192
											switch($condition["name"]){
3 liveuser 5193
 
218 liveuser 5194
												#如果是 "keyWordPart"
5195
												case "keyWordPart":
3 liveuser 5196
 
218 liveuser 5197
													#確認是否開頭有符合
3 liveuser 5198
 
218 liveuser 5199
													#函式說明:
5200
													#取得關鍵字在字串的哪個位置(字首,字尾,中間)
5201
													#回傳結果:
5202
													#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
5203
													#$result["error"],錯誤訊息陣列.
5204
													#$result["function"],當前執行的函數名稱.
5205
													#$result["found"],是否有關鍵字存在,若為"true",代表存在;反之為"false".
5206
													#$result["argu"],傳入的參數.
5207
													#$result["head"],關鍵字是否在字串的開頭,"true"代表是,"false"代表不是.
5208
													#$result["tail"],關鍵字是否在字串的尾端,"true"代表是,"false"代表不是.
5209
													#$result["center"],關鍵字是否在字串的中間,"true"代表是,"false"代表不是.
5210
													#$result["indexS"],關鍵字在被搜尋字串的哪個位置開始.
5211
													#$result["indexE"],關鍵字在被搜尋字串的哪個位置結束.
5212
													#必填參數:
5213
													#$conf["inputStr"],字串,被搜尋的字串.
5214
													$conf["search::findKeyWordPosition"]["inputStr"]=$modifiedOriLineContent;
5215
													#$conf["keyWord"],字串,關鍵字.
5216
													$conf["search::findKeyWordPosition"]["keyWord"]=$condition["value"];
5217
													#可省略參數:
5218
													#無.
5219
													#參考資料:
5220
													#http://php.net/manual/en/function.strpos.php
5221
													#備註:
5222
													#無.
5223
													$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
5224
													unset($conf["search::findKeyWordPosition"]);
3 liveuser 5225
 
218 liveuser 5226
													#debug
5227
													#var_dump(__LINE__,$findKeyWordPosition);
3 liveuser 5228
 
218 liveuser 5229
													#如果執行失敗
5230
													if($findKeyWordPosition["status"]==="false"){
3 liveuser 5231
 
218 liveuser 5232
														#設置錯誤識別
5233
														$result["status"]="false";
5234
 
5235
														#設置錯誤訊息
5236
														$result["error"]=$findKeyWordPosition;
5237
 
5238
														#回傳結果
5239
														return $result;
3 liveuser 5240
 
218 liveuser 5241
														}#if end
5242
 
5243
													#如果沒有符合
5244
													if($findKeyWordPosition["found"]==="false"){
3 liveuser 5245
 
218 liveuser 5246
														#初始化關鍵字行
5247
														$keyWordLineIndex=0;
5248
 
5249
														#換下行原始內容
5250
														continue 5;
3 liveuser 5251
 
218 liveuser 5252
														}#if end
5253
 
5254
													#如果關鍵字不在開頭
5255
													if($findKeyWordPosition["head"]==="false"){
3 liveuser 5256
 
218 liveuser 5257
														#初始化關鍵字行
5258
														$keyWordLineIndex=0;
5259
 
5260
														#換下行原始內容
5261
														continue 5;
3 liveuser 5262
 
218 liveuser 5263
														}#if end
3 liveuser 5264
 
218 liveuser 5265
													#函式說明:
5266
													#將字串特定關鍵字與其前面的內容剔除
5267
													#回傳結果:
5268
													#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5269
													#$result["error"],錯誤訊息陣列.
5270
													#$result["warning"],警告訊息鎮列.
5271
													#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
5272
													#$result["function"],當前執行的函數名稱.
5273
													#$result["argu"],使用的參數.
5274
													#$result["oriStr"],要處理的原始字串內容.
5275
													#$result["content"],處理好的的字串內容.
5276
													#$result["deleted"],被移除的內容.
5277
													#必填參數:
5278
													#$conf["stringIn"],字串,要處理的字串.
5279
													$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedOriLineContent;
5280
													#$conf["keyWord"],字串,特定字串.
5281
													$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$condition["value"];
5282
													#可省略參數:
5283
													#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
5284
													#$conf["recursive"]="true";
5285
													#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
5286
													#$conf["lastResult"]=$delStrBeforeKeyWord;
5287
													#參考資料:
5288
													#無.
5289
													#備註:
5290
													#無.
5291
													$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
5292
													unset($conf["stringProcess::delStrBeforeKeyWord"]);
3 liveuser 5293
 
218 liveuser 5294
													#debug
5295
													#var_dump(__LINE__,$delStrBeforeKeyWord);
3 liveuser 5296
 
218 liveuser 5297
													#如果執行失敗
5298
													if($delStrBeforeKeyWord["status"]==="false"){
3 liveuser 5299
 
218 liveuser 5300
														#設置錯誤識別
5301
														$result["status"]="false";
5302
 
5303
														#設置錯誤訊息
5304
														$result["error"]=$delStrBeforeKeyWord;
5305
 
5306
														#回傳結果
5307
														return $result;
3 liveuser 5308
 
218 liveuser 5309
														}#if end
5310
 
5311
													#如果沒有符合
5312
													if($delStrBeforeKeyWord["founded"]==="false"){
3 liveuser 5313
 
218 liveuser 5314
														#初始化關鍵字行
5315
														$keyWordLineIndex=0;
3 liveuser 5316
 
218 liveuser 5317
														#換下行原始內容
5318
														continue 5;
3 liveuser 5319
 
218 liveuser 5320
														}#if end
3 liveuser 5321
 
218 liveuser 5322
													#執行到這邊代表有符合
3 liveuser 5323
 
218 liveuser 5324
													#取得剩下未判斷是否符合的項目
5325
													$modifiedOriLineContent=$delStrBeforeKeyWord["content"];
3 liveuser 5326
 
218 liveuser 5327
													#換找下個資訊有無符合
5328
													continue 2;
3 liveuser 5329
 
218 liveuser 5330
													#結束 switch
5331
													break;
5332
 
5333
												#如果是 "varPart"
5334
												case "varPart":
5335
 
5336
													#判斷變數名稱
5337
													switch($OderOfPartInLine[($index)]["value"]){
3 liveuser 5338
 
218 liveuser 5339
														#如果為 起始年份
5340
														case "\${yearFrom}":
3 liveuser 5341
 
218 liveuser 5342
														#或如果為 結束年份
5343
														case "\${yearTo}":
3 liveuser 5344
 
218 liveuser 5345
															#取得變數名稱,亦即去掉開頭的 "${" 跟結尾的 "}"
5346
															$varName=substr($OderOfPartInLine[($index)]["value"],2,strlen($OderOfPartInLine[($index)]["value"])-3);
5347
 
5348
															#取得變數實際數值
5349
															$varVal=$conf[$varName];
5350
 
5351
															#轉換成 keyWordPart
5352
															$OderOfPartInLine[($index)]["name"]="keyWordPart";
5353
 
5354
															#轉換成期望的數值
5355
															$OderOfPartInLine[($index)]["value"]=$varVal;
3 liveuser 5356
 
218 liveuser 5357
															#跳出 switch
5358
															break;
3 liveuser 5359
 
218 liveuser 5360
														#或如果為作者資訊
5361
														case "\${Authors}":
3 liveuser 5362
 
218 liveuser 5363
															#取得變數名稱,亦即去掉開頭的 "${" 跟結尾的 "}"
5364
															$varName=substr($OderOfPartInLine[($index)]["value"],2,strlen($OderOfPartInLine[($index)]["value"])-3);
3 liveuser 5365
 
218 liveuser 5366
															#取得變數實際數值
5367
															$varVal=$conf[$varName];
3 liveuser 5368
 
218 liveuser 5369
															#轉換成 keyWordPart
5370
															$OderOfPartInLine[($index)]["name"]="keyWordPart";
5371
 
5372
															#初始化作者清單
5373
															$authorNameList="";
5374
 
5375
															#針對每個作者
5376
															foreach($varVal as $authorNameIndex=>$authorName){
5377
 
5378
																#預設的間隔內容
5379
																$comma=" | ";
5380
 
5381
																#如果是第一個作者
5382
																if($authorNameIndex===0){
5383
 
5384
																	#不需要間隔內容
5385
																	$comma="";
5386
 
5387
																	}#if end
5388
 
5389
																#串接間隔與作者名字
5390
																$authorNameList=$authorNameList.$comma.$authorName;
5391
 
5392
																}#foreach end
5393
 
5394
															#轉換成期望的數值
5395
															$OderOfPartInLine[($index)]["value"]=$authorNameList;
5396
 
5397
															#跳出 switch
5398
															break;
3 liveuser 5399
 
218 liveuser 5400
														#其他變數
5401
														default:
3 liveuser 5402
 
218 liveuser 5403
															#請定義實際內容要如何產生
5404
															#...
5405
 
5406
														}#switch end
5407
 
5408
													#如果後面沒有 $OderOfPartInLine 了
5409
													if(!isset($OderOfPartInLine[($index+1)])){
5410
 
5411
														#代表有符合所有條件
3 liveuser 5412
 
218 liveuser 5413
														#輪到下個關鍵字行
5414
														$keyWordLineIndex++;
3 liveuser 5415
 
218 liveuser 5416
														#結束 switch
3 liveuser 5417
														break;
5418
 
218 liveuser 5419
														}#if end
5420
 
5421
													#debug
5422
													#var_dump(__LINE__,$OderOfPartInLine[($index+1)]);
5423
 
5424
													#執行到這邊代表後面還有 $OderOfPartInLine
3 liveuser 5425
 
218 liveuser 5426
													#如果後面的內容不是 keyWordPart
5427
													if($OderOfPartInLine[($index+1)]["name"]!=="keyWordPart"){
5428
 
5429
														#設置錯誤識別
5430
														$result["status"]="false";
5431
 
5432
														#設置錯誤訊息
5433
														$result["error"][]="multi continued varName not supported";
5434
 
5435
														#回傳結果
5436
														return $result;
5437
 
5438
														}#if end
5439
 
5440
													#執行到這邊代表為 varPart
5441
 
5442
													#函式說明:
5443
													#取得關鍵字在字串的哪個位置(字首,字尾,中間)
5444
													#回傳結果:
5445
													#$result["status"],執行成功與否,若爲"true",代表執行成功,若爲"false"代表執失敗。
5446
													#$result["error"],錯誤訊息陣列.
5447
													#$result["function"],當前執行的函數名稱.
5448
													#$result["found"],是否有關鍵字存在,若為"true",代表存在;反之為"false".
5449
													#$result["argu"],傳入的參數.
5450
													#$result["head"],關鍵字是否在字串的開頭,"true"代表是,"false"代表不是.
5451
													#$result["tail"],關鍵字是否在字串的尾端,"true"代表是,"false"代表不是.
5452
													#$result["center"],關鍵字是否在字串的中間,"true"代表是,"false"代表不是.
5453
													#$result["indexS"],關鍵字在被搜尋字串的哪個位置開始.
5454
													#$result["indexE"],關鍵字在被搜尋字串的哪個位置結束.
5455
													#必填參數:
5456
													#$conf["inputStr"],字串,被搜尋的字串.
5457
													$conf["search::findKeyWordPosition"]["inputStr"]=$modifiedOriLineContent;
5458
													#$conf["keyWord"],字串,關鍵字.
5459
													$conf["search::findKeyWordPosition"]["keyWord"]=$OderOfPartInLine[($index+1)]["value"];
5460
													#可省略參數:
5461
													#無.
5462
													#參考資料:
5463
													#http://php.net/manual/en/function.strpos.php
5464
													#備註:
5465
													#無.
5466
													$findKeyWordPosition=search::findKeyWordPosition($conf["search::findKeyWordPosition"]);
5467
													unset($conf["search::findKeyWordPosition"]);
3 liveuser 5468
 
218 liveuser 5469
													#debug
5470
													#var_dump(__LINE__,$findKeyWordPosition);
3 liveuser 5471
 
218 liveuser 5472
													#如果執行失敗
5473
													if($findKeyWordPosition["status"]==="false"){
3 liveuser 5474
 
218 liveuser 5475
														#設置錯誤識別
5476
														$result["status"]="false";
5477
 
5478
														#設置錯誤訊息
5479
														$result["error"]=$findKeyWordPosition;
5480
 
5481
														#回傳結果
5482
														return $result;
3 liveuser 5483
 
218 liveuser 5484
														}#if end
5485
 
5486
													#如果沒有符合
5487
													if($findKeyWordPosition["found"]==="false"){
3 liveuser 5488
 
218 liveuser 5489
														#初始化關鍵字行
5490
														$keyWordLineIndex=0;
5491
 
5492
														#換下行原始內容
5493
														continue 5;
3 liveuser 5494
 
218 liveuser 5495
														}#if end
3 liveuser 5496
 
218 liveuser 5497
													#執行到這邊代表有符合
3 liveuser 5498
 
218 liveuser 5499
													#函式說明:
5500
													#將字串特定關鍵字與其前面的內容剔除
5501
													#回傳結果:
5502
													#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5503
													#$result["error"],錯誤訊息陣列.
5504
													#$result["warning"],警告訊息鎮列.
5505
													#$result["founded"],有無找到定字串"true"代表有,"false"代表沒有.
5506
													#$result["function"],當前執行的函數名稱.
5507
													#$result["argu"],使用的參數.
5508
													#$result["oriStr"],要處理的原始字串內容.
5509
													#$result["content"],處理好的的字串內容.
5510
													#$result["deleted"],被移除的內容.
5511
													#必填參數:
5512
													#$conf["stringIn"],字串,要處理的字串.
5513
													$conf["stringProcess::delStrBeforeKeyWord"]["stringIn"]=$modifiedOriLineContent;
5514
													#$conf["keyWord"],字串,特定字串.
5515
													$conf["stringProcess::delStrBeforeKeyWord"]["keyWord"]=$OderOfPartInLine[($index+1)]["value"];
5516
													#可省略參數:
5517
													#$conf["recursive"],字串,預設為"false"代表找到一個關鍵字就會停止;"true"代表會即重複執行,知道沒有關鍵字為止.
5518
													#$conf["recursive"]="true";
5519
													#$conf["lastResult"],陣列,本函式前次執行的結果,若沒有找到關鍵字,則會改回傳該內容.
5520
													#$conf["lastResult"]=$delStrBeforeKeyWord;
5521
													#參考資料:
5522
													#無.
5523
													#備註:
5524
													#無.
5525
													$delStrBeforeKeyWord=stringProcess::delStrBeforeKeyWord($conf["stringProcess::delStrBeforeKeyWord"]);
5526
													unset($conf["stringProcess::delStrBeforeKeyWord"]);
3 liveuser 5527
 
218 liveuser 5528
													#debug
5529
													#var_dump(__LINE__,$delStrBeforeKeyWord);
3 liveuser 5530
 
218 liveuser 5531
													#如果執行失敗
5532
													if($delStrBeforeKeyWord["status"]==="false"){
3 liveuser 5533
 
218 liveuser 5534
														#設置錯誤識別
5535
														$result["status"]="false";
5536
 
5537
														#設置錯誤訊息
5538
														$result["error"]=$delStrBeforeKeyWord;
5539
 
5540
														#回傳結果
5541
														return $result;
3 liveuser 5542
 
218 liveuser 5543
														}#if end
5544
 
5545
													#如果該存在的關鍵字不在
5546
													if($delStrBeforeKeyWord["founded"]==="false"){
3 liveuser 5547
 
218 liveuser 5548
														#初始化關鍵字行
5549
														$keyWordLineIndex=0;
5550
 
5551
														#換下行原始內容
5552
														continue 5;
5553
 
5554
														}#if end
5555
 
5556
													#取得剩下未判斷是否符合的項目
5557
													$modifiedOriLineContent=$OderOfPartInLine[($index+1)]["value"].$delStrBeforeKeyWord["content"];
5558
 
5559
													#debug
5560
													#var_dump(__LINE__,$modifiedOriLineContent);
5561
 
5562
													#換找下個資訊有無符合
5563
													continue 2;
3 liveuser 5564
 
218 liveuser 5565
													break;
3 liveuser 5566
 
218 liveuser 5567
												#其他狀況
5568
												default:
3 liveuser 5569
 
5570
													#設置錯誤識別
5571
													$result["status"]="false";
5572
 
5573
													#設置錯誤訊息
218 liveuser 5574
													$result["error"][]="unexpected name value";
3 liveuser 5575
 
218 liveuser 5576
													#設置錯誤訊息
5577
													$result["error"][]=$condition;
5578
 
3 liveuser 5579
													#回傳結果
5580
													return $result;
5581
 
218 liveuser 5582
												}#switch end
3 liveuser 5583
 
218 liveuser 5584
											}#foreach end
3 liveuser 5585
 
218 liveuser 5586
										#執行到這邊代表該行有符合關鍵字的結構
3 liveuser 5587
 
218 liveuser 5588
										#初始化期望的關鍵字內容
5589
										$fixedKeyWordVal="";
3 liveuser 5590
 
218 liveuser 5591
										#debug
5592
										#var_dump(__LINE__,$OderOfPartInLine);
3 liveuser 5593
 
218 liveuser 5594
										#針對關鍵字的每個字串段落
5595
										foreach($OderOfPartInLine as $indexOfOderOfPartInLine => $keyWordStrPart){
5596
 
5597
											#串接之
5598
											$fixedKeyWordVal=$fixedKeyWordVal.$OderOfPartInLine[$indexOfOderOfPartInLine]["value"];
5599
 
5600
											}#foreach end
5601
 
5602
										#debug
5603
										#var_dump(__LINE__,$oriLineContent,$fixedKeyWordVal);
5604
 
5605
										#補上關鍵字前面的tab或空格
5606
										$fixedKeyWordVal=$keyWordContentOfHead.$fixedKeyWordVal;
5607
 
5608
										#如果內容有差
5609
										if($oriLineContent!=$fixedKeyWordVal){
5610
 
5611
											#debug
5612
											#var_dump(__LINE__,$oriLineContent,$fixedKeyWordVal);
5613
 
5614
											#設置要取代的暫存資訊
5615
											$detailRepaceddInfo=array();
5616
 
5617
											#設置暫存的取代詳細資訊,包含取代的行(從0開始算),原始內容,新內容.
5618
											$detailRepaceddInfo[$oriLineContentIndex]=array("from"=>$oriLineContent,"to"=>$fixedKeyWordVal);
5619
 
5620
											#debug
5621
											#var_dump(__LINE__,$detailRepaceddInfo);
5622
 
5623
											#儲存要取代的資訊
5624
											$replacedInfo[]=$detailRepaceddInfo;
5625
 
5626
											}#if end
5627
 
5628
										#取代期望的關鍵字
5629
										$modifiedKeyWordLine=$fixedKeyWordVal;
5630
 
5631
										#換看下行內容有無符合關鍵字,會執行for迴圈的 $keyWordLineIndex++
5632
										continue 3;
5633
 
5634
										}#if end
3 liveuser 5635
 
218 liveuser 5636
									#結束 while
5637
									break;
3 liveuser 5638
 
218 liveuser 5639
									}#while end
5640
 
5641
								#若原始內容沒有符合關鍵字
5642
								if($modifiedOriLineContent!==$modifiedKeyWordLine){
5643
 
3 liveuser 5644
									#debug
218 liveuser 5645
									#var_dump(__LINE__,$modifiedOriLineContent,$modifiedKeyWordLine);
3 liveuser 5646
 
218 liveuser 5647
									#初始化關鍵字行
5648
									$keyWordLineIndex=0;
3 liveuser 5649
 
218 liveuser 5650
									#換下行原始內容
5651
									continue 2;
5652
 
5653
									}#if end
3 liveuser 5654
 
218 liveuser 5655
								#反之代表內容有符合
5656
								else{
5657
 
3 liveuser 5658
									#debug
218 liveuser 5659
									#var_dump(__LINE__,"第 ".($keyWordLineIndex+1)." 個關鍵字有符合,總關鍵行有 ".count($conf["replaceFrom"])." 個");
5660
 
3 liveuser 5661
									#如果內容有差
218 liveuser 5662
									if($oriLineContent!=$conf["replaceFrom"][$keyWordLineIndex]){
3 liveuser 5663
 
5664
										#debug
218 liveuser 5665
										#var_dump(__LINE__,$oriLineContent,$conf["replaceFrom"][$keyWordLineIndex]);
3 liveuser 5666
 
5667
										#設置要取代的暫存資訊
5668
										$detailRepaceddInfo=array();
5669
 
5670
										#設置暫存的取代詳細資訊,包含取代的行(從0開始算),原始內容,新內容.
218 liveuser 5671
										$detailRepaceddInfo[$oriLineContentIndex]=array("from"=>$oriLineContent,"to"=>$conf["replaceFrom"][$keyWordLineIndex]);
3 liveuser 5672
 
5673
										#儲存要取代的資訊
5674
										$replacedInfo[]=$detailRepaceddInfo;
5675
 
5676
										}#if end
5677
 
218 liveuser 5678
									#若為最後一個關鍵行.
5679
									if( count($conf["replaceFrom"])===($keyWordLineIndex+1) ){
3 liveuser 5680
 
218 liveuser 5681
										#代表符合要取代的條件
5682
										$shouldReplace="true";
5683
 
5684
										#debug
5685
										#var_dump(__LINE__,$result["content"]);
5686
 
5687
										#如果沒有既有的記錄
5688
										if(!isset($result["content"][$NodePathAndName])){
5689
 
5690
											#記錄有更新的檔案路徑與名稱與其次數為1
5691
											$result["content"][$NodePathAndName]["time"]=1;
5692
 
5693
											}#if end
5694
 
5695
										#反之
5696
										else{
5697
 
5698
											#記錄有更新的檔案路徑與名稱與的次數+1
5699
											$result["content"][$NodePathAndName]["time"]++;
5700
 
5701
											}#else end
5702
 
5703
										#記錄要更新的相關資訊
5704
										$result["content"][$NodePathAndName]["replacedInfo"]=$replacedInfo;
5705
 
5706
										#debug
5707
										#var_dump(__LINE__,$result["content"]);
5708
 
5709
										#關鍵字行初始化
5710
										$keyWordLineIndex=0;
5711
 
3 liveuser 5712
										}#if end
5713
 
5714
									#反之
5715
									else{
5716
 
218 liveuser 5717
										#輪到下個關鍵字行
5718
										$keyWordLineIndex++;
3 liveuser 5719
 
5720
										}#else end
5721
 
218 liveuser 5722
									#換找下個行內容有無符合關鍵字
5723
									continue 2;
5724
 
3 liveuser 5725
									}#else end
5726
 
218 liveuser 5727
								}#for end
5728
 
5729
							}#for end
3 liveuser 5730
 
218 liveuser 5731
						}#if end
5732
 
5733
					#如果有需要更新檔案內容的識別
5734
					if($shouldReplace==="true"){
3 liveuser 5735
 
218 liveuser 5736
						#更新檔案內容
5737
						#...
5738
 
5739
						}#if end
5740
 
5741
						}#if end
3 liveuser 5742
 
218 liveuser 5743
					#反之為多執行序
5744
					else{
3 liveuser 5745
 
218 liveuser 5746
						#...
5747
						#待實作
3 liveuser 5748
 
218 liveuser 5749
						}#else end
5750
 
3 liveuser 5751
				}#foreach end
5752
 
5753
			}#foreach end
5754
 
5755
		#debug
5756
		#var_dump(__FUNCTION__,__LINE__,print_r($conf,true));exit;
5757
 
5758
		#如果有啟用多執行序
5759
		if($conf["multiThread"]==="true"){
5760
 
5761
			#debug
5762
			#var_dump($conf);exit;
5763
 
5764
			#如果有執行的程序要確認回饋
5765
			if(isset($procs)){
5766
 
5767
				#debug
5768
				#var_dump($procs);exit;
5769
 
5770
				#如果有要log
5771
				if(isset($conf["log"])){
5772
 
5773
					#log for run time of start and end info
5774
					$logPathForRunTimeOfStartAndEnd="/tmp/".basename($conf["log"]).":".$uuid."-runTimeOfStartAndEnd.log";
5775
 
5776
					#函式說明:
5777
					#撰寫log
5778
					#回傳結果:
5779
					#$result["status"],狀態,"true"或"false".
5780
					#$result["error"],錯誤訊息陣列.
5781
					#$result["function"],當前函式的名稱.
5782
					#$result["argu"],使用的參數.
5783
					#必填參數:
5784
					#$conf["path"],字串,log檔案的路徑與名稱.
5785
					$conf["logs::record"]["path"]=$logPathForRunTimeOfStartAndEnd;
5786
					#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
5787
					$conf["logs::record"]["content"]="start at ".gmdate("Y-m-d H:i:s");
5788
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5789
					$conf["logs::record"]["fileArgu"]=__FILE__;
5790
					#可省略參數:
5791
					#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
5792
					#$conf["rewrite"]="false";
5793
					#參考資料:
5794
					#無.
5795
					#備註:
5796
					#無.
5797
					$record=logs::record($conf["logs::record"]);
5798
					unset($conf["logs::record"]);
5799
 
5800
					#如果出錯
5801
					if($record["status"]==="false"){
5802
 
5803
						#設置錯誤識別
5804
						$result["status"]="false";
5805
 
5806
						#設置錯誤訊息
5807
						$result["error"]=$record;
5808
 
5809
						#印出json
5810
						echo json_encode($result);
5811
 
5812
						#結束執行,回傳1給shell,代表異常,
5813
						exit(1);
5814
 
5815
						}#if end
5816
 
5817
					}#if end
5818
 
5819
				#無窮迴圈
5820
				while(true){
5821
 
5822
					#如果有開啟 log
5823
					if(isset($conf["log"])){
5824
 
5825
						#要記錄的log
5826
						$log="There are ".count($procs)." process under path of ".$conf["searchPath"][0]." unend.".PHP_EOL;
5827
 
5828
						#log的路徑與名稱
5829
						$path="/tmp/".basename($conf["log"]).":".$uuid.".log";
5830
 
5831
						#log for latest running 的路徑與名稱
5832
						$logPathForLatestRunning="/tmp/".basename($conf["log"]).":".$uuid."-latest.log";
5833
 
5834
						#函式說明:
5835
						#撰寫log
5836
						#回傳結果:
5837
						#$result["status"],狀態,"true"或"false".
5838
						#$result["error"],錯誤訊息陣列.
5839
						#$result["function"],當前函式的名稱.
5840
						#$result["argu"],使用的參數.
5841
						#必填參數:
5842
						#$conf["path"],字串,log檔案的路徑與名稱.
5843
						$conf["logs::record"]["path"]=$path;
5844
						#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
5845
						$conf["logs::record"]["content"]=$log;
5846
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5847
						$conf["logs::record"]["fileArgu"]=__FILE__;
5848
						#可省略參數:
5849
						#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
5850
						#$conf["rewrite"]="false";
5851
						#參考資料:
5852
						#無.
5853
						#備註:
5854
						#無.
5855
						$record=logs::record($conf["logs::record"]);
5856
						unset($conf["logs::record"]);
5857
 
5858
						#如果出錯
5859
						if($record["status"]==="false"){
5860
 
5861
							#設置錯誤識別
5862
							$result["status"]="false";
5863
 
5864
							#設置錯誤訊息
5865
							$result["error"]=$record;
5866
 
5867
							#印出json
5868
							echo json_encode($result);
5869
 
5870
							#結束執行,回傳1給shell,代表異常,
5871
							exit(1);
5872
 
5873
							}#if end
5874
 
5875
						}#if end
5876
 
5877
					#針對每個要確認的程序
5878
					foreach($procs as $procIndex => $procValue){
5879
 
5880
						#判斷多執行序的類型
5881
						switch($threadType){
5882
 
5883
							#如果是直接透過 proc
5884
							case "proc":
5885
 
5886
								#函式說明:
5887
								#更新透過proc執行的多程序資訊.
5888
								#回傳結果:
5889
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5890
								#$reuslt["error"],執行不正常結束的錯訊息陣列.
5891
								#$result["function"],當前執行的函式名稱.
5892
								#$result["argu"],使用的參數.
5893
								#$result["content"],陣列,每個元素為其指令執行的結果訊息陣列,key為"status"代表執行是否正常的識別;key為"statusCode"代表程式結束後回傳給對應executeBy程式的數值;key為"output"代表標準輸出,若為resource,則代表為pipe;key為"error"代表非標準輸出,若為resource,則代表為pipe;key為"input"代表成功輸入的指令;key為"process"代表該程序經proc_open後的process source;key為"proc_get_status"代表程序的資訊.
5894
								#必填參數:
5895
								#$conf["procs"],陣列,運行self::proc後回傳的content.
5896
								$conf["threads::proc_update"]["procs"]=$procValue["content"];
5897
								#可省略參數:
5898
								#無.
5899
								#參考資料:
5900
								#無.
5901
								#備註:
5902
								#無.
5903
								$proc_update=threads::proc_update($conf["threads::proc_update"]);
5904
								unset($conf["threads::proc_update"]);
5905
 
5906
								#如果執行失敗
5907
								if($proc_update["status"]==="false"){
5908
 
5909
									#關閉程序
5910
									proc_close($procs[$procIndex]["content"][0]["process"]);
5911
 
5912
									#設置錯誤識別
5913
									$result["status"]="false";
5914
 
5915
									#設置錯誤訊息
5916
									$result["error"]=$procValue;
5917
 
5918
									#印出json
5919
									echo json_encode($result);
5920
 
5921
									#卸除異常的程序
5922
									unset($procs[$procIndex]);
5923
 
5924
									#結束執行,回傳1給shell,代表異常,
5925
									exit(1);
5926
 
5927
									}#if end
5928
 
5929
								#debug
5930
								#var_dump($procValue["content"][0]["statusCode"]);exit;
5931
 
5932
								#如果執行失敗
5933
								if($procValue["content"][0]["status"]==="false"){
5934
 
5935
									#關閉程序
5936
									proc_close($procs[$procIndex]["content"][0]["process"]);
5937
 
5938
									#設置錯誤識別
5939
									$result["status"]="false";
5940
 
5941
									#設置錯誤訊息
5942
									$result["error"]=$procValue;
5943
 
5944
									#印出json
5945
									echo json_encode($result);
5946
 
5947
									#卸除異常的程序
5948
									unset($procs[$procIndex]);
5949
 
5950
									#結束執行,回傳1給shell,代表異常,
5951
									exit(1);
5952
 
5953
									}#if end
5954
 
5955
								#如果可能尚在執行中
5956
								if($procValue["content"][0]["statusCode"]==="?"){
5957
 
5958
									#debug
5959
									#var_dump($procValue["content"][0]["statusCode"]);exit(1);
5960
 
5961
									#如果有要log
5962
									if(isset($conf["log"])){
5963
 
5964
										#要記錄的log
5965
										$log=$procValue["content"][0];
5966
 
5967
										#函式說明:
5968
										#撰寫log
5969
										#回傳結果:
5970
										#$result["status"],狀態,"true"或"false".
5971
										#$result["error"],錯誤訊息陣列.
5972
										#$result["function"],當前函式的名稱.
5973
										#$result["argu"],使用的參數.
5974
										#必填參數:
5975
										#$conf["path"],字串,log檔案的路徑與名稱.
5976
										$conf["logs::record"]["path"]=$logPathForLatestRunning;
5977
										#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
5978
										$conf["logs::record"]["content"]=$log;
5979
										#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5980
										$conf["logs::record"]["fileArgu"]=__FILE__;
5981
										#可省略參數:
5982
										#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
5983
										$conf["logs::record"]["rewrite"]="true";
5984
										#參考資料:
5985
										#無.
5986
										#備註:
5987
										#無.
5988
										$record=logs::record($conf["logs::record"]);
5989
										unset($conf["logs::record"]);
5990
 
5991
										#如果出錯
5992
										if($record["status"]==="false"){
5993
 
5994
											#關閉程序
5995
											proc_close($procs[$procIndex]["content"][0]["process"]);
5996
 
5997
											#卸除異常的程序
5998
											unset($procs[$procIndex]);
5999
 
6000
											#設置錯誤識別
6001
											$result["status"]="false";
6002
 
6003
											#設置錯誤訊息
6004
											$result["error"]=$record;
6005
 
6006
											#印出json
6007
											echo json_encode($result);
6008
 
6009
											#結束執行,回傳1給shell,代表異常,
6010
											exit(1);
6011
 
6012
											}#if end
6013
 
6014
										}#if end
6015
 
6016
									#$result["content"],陣列,每個元素為其指令執行的結果訊息陣列,key為"status"代表執行是否正常的識別;key為"statusCode"代表程式結束後回傳給對應executeBy程式的數值;key為"output"代表標準輸出,若為resource,則代表為pipe;key為"error"代表非標準輸出,若為resource,則代表為pipe;key為"input"代表成功輸入的指令;key為"process"代表該程序經proc_open後的process source;key為"proc_get_status"代表程序的資訊.
6017
 
6018
									#如果錯誤訊息目前為resource,亦即pipe
6019
									if(gettype($procValue["content"][0]["error"])==="resource"){
6020
 
6021
										#取得錯誤輸出
6022
										$stderr=stream_get_contents($procValue["content"][0]["error"]);
6023
 
6024
										#如果有錯誤訊息存在
6025
										if(!empty($stderr)){
6026
 
6027
											#如果有要log
6028
											if(isset($conf["log"])){
6029
 
6030
												#要記錄的log
6031
												$log=$stderr;
6032
 
6033
												#函式說明:
6034
												#撰寫log
6035
												#回傳結果:
6036
												#$result["status"],狀態,"true"或"false".
6037
												#$result["error"],錯誤訊息陣列.
6038
												#$result["function"],當前函式的名稱.
6039
												#$result["argu"],使用的參數.
6040
												#必填參數:
6041
												#$conf["path"],字串,log檔案的路徑與名稱.
6042
												$conf["logs::record"]["path"]=$conf["log"];
6043
												#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
6044
												$conf["logs::record"]["content"]=$log;
6045
												#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6046
												$conf["logs::record"]["fileArgu"]=__FILE__;
6047
												#可省略參數:
6048
												#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
6049
												#$conf["rewrite"]="false";
6050
												#參考資料:
6051
												#無.
6052
												#備註:
6053
												#無.
6054
												$record=logs::record($conf["logs::record"]);
6055
												unset($conf["logs::record"]);
6056
 
6057
												#如果出錯
6058
												if($record["status"]==="false"){
6059
 
6060
													#關閉程序
6061
													proc_close($procs[$procIndex]["content"][0]["process"]);
6062
 
6063
													#設置錯誤識別
6064
													$result["status"]="false";
6065
 
6066
													#設置錯誤訊息
6067
													$result["error"]=$record;
6068
 
6069
													#印出json
6070
													echo json_encode($result);
6071
 
6072
													#卸除異常的程序
6073
													unset($procs[$procIndex]);
6074
 
6075
													#結束執行,回傳1給shell,代表異常,
6076
													exit(1);
6077
 
6078
													}#if end
6079
 
6080
												#關閉程序
6081
												proc_close($procs[$procIndex]["content"][0]["process"]);
6082
 
6083
												#設置錯誤識別
6084
												$result["status"]="false";
6085
 
6086
												#設置錯誤訊息
6087
												$result["error"][]=$record;
6088
 
6089
												#設置錯誤訊息
6090
												$result["error"][]=$stderr;
6091
 
6092
												#印出json
6093
												echo json_encode($result);
6094
 
6095
												#卸除異常的程序
6096
												unset($procs[$procIndex]);
6097
 
6098
												#結束執行,回傳1給shell,代表異常,
6099
												exit(1);
6100
 
6101
												}#if end
6102
 
6103
											}#if ene
6104
 
6105
										}#if end
6106
 
6107
									#反之為字串
6108
									else{
6109
 
6110
										#取得錯誤輸出
6111
										$stderr=$procValue["content"][0]["error"];
6112
 
6113
										#如果有錯誤訊息存在
6114
										if(!empty($stderr)){
6115
 
6116
											#如果有要log
6117
											if(isset($conf["log"])){
6118
 
6119
												#要記錄的log
6120
												$log=$stderr;
6121
 
6122
												#函式說明:
6123
												#撰寫log
6124
												#回傳結果:
6125
												#$result["status"],狀態,"true"或"false".
6126
												#$result["error"],錯誤訊息陣列.
6127
												#$result["function"],當前函式的名稱.
6128
												#$result["argu"],使用的參數.
6129
												#必填參數:
6130
												#$conf["path"],字串,log檔案的路徑與名稱.
6131
												$conf["logs::record"]["path"]=$conf["log"];
6132
												#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
6133
												$conf["logs::record"]["content"]=$log;
6134
												#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6135
												$conf["logs::record"]["fileArgu"]=__FILE__;
6136
												#可省略參數:
6137
												#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
6138
												#$conf["rewrite"]="false";
6139
												#參考資料:
6140
												#無.
6141
												#備註:
6142
												#無.
6143
												$record=logs::record($conf["logs::record"]);
6144
												unset($conf["logs::record"]);
6145
 
6146
												#如果出錯
6147
												if($record["status"]==="false"){
6148
 
6149
													#關閉程序
6150
													proc_close($procs[$procIndex]["content"][0]["process"]);
6151
 
6152
													#設置錯誤識別
6153
													$result["status"]="false";
6154
 
6155
													#設置錯誤訊息
6156
													$result["error"]=$record;
6157
 
6158
													#印出json
6159
													echo json_encode($result);
6160
 
6161
													#卸除異常的程序
6162
													unset($procs[$procIndex]);
6163
 
6164
													#結束執行,回傳1給shell,代表異常,
6165
													exit(1);
6166
 
6167
													}#if end
6168
 
6169
												#關閉程序
6170
												proc_close($procs[$procIndex]["content"][0]["process"]);
6171
 
6172
												#設置錯誤識別
6173
												$result["status"]="false";
6174
 
6175
												#設置錯誤訊息
6176
												$result["error"][]=$record;
6177
 
6178
												#設置錯誤訊息
6179
												$result["error"][]=$stderr;
6180
 
6181
												#印出json
6182
												echo json_encode($result);
6183
 
6184
												#卸除異常的程序
6185
												unset($procs[$procIndex]);
6186
 
6187
												#結束執行,回傳1給shell,代表異常,
6188
												exit(1);
6189
 
6190
												}#if end
6191
 
6192
											}#if ene
6193
 
6194
										}#else end
6195
 
6196
									#跳過該子程序
6197
									continue 2;
6198
 
6199
									}#if end
6200
 
6201
								#反之可能為執行結束了,且執行異常
6202
								else if($procValue["content"][0]["statusCode"]!==0){
6203
 
6204
									#關閉程序
6205
									proc_close($procs[$procIndex]["content"][0]["process"]);
6206
 
6207
									#設置錯誤識別
6208
									$result["status"]="false";
6209
 
6210
									#設置錯誤訊息
6211
									$result["error"]=$procValue;
6212
 
6213
									#印出json
6214
									echo json_encode($result);
6215
 
6216
									#卸除異常的程序
6217
									unset($procs[$procIndex]);
6218
 
6219
									#結束執行,回傳1給shell,代表異常,
6220
									exit(1);
6221
 
6222
									}#if end
6223
 
6224
								#反之執行正常
6225
								else{
6226
 
6227
									#debug
6228
									#var_dump($procValue["content"][0]["statusCode"]);
6229
 
6230
									#儲存程序執行的標準輸出
6231
									$threadStdOut=$procValue["content"][0]["content"];
6232
 
6233
									#如果標準輸出不是json
6234
									if(json_validate($threadStdOut)===false){
6235
 
6236
										#關閉程序
6237
										proc_close($procs[$procIndex]["content"][0]["process"]);
6238
 
6239
										#設置錯誤識別
6240
										$result["status"]="false";
6241
 
6242
										#設置錯誤訊息
6243
										$result["error"]=$procValue;
6244
 
6245
										#印出json
6246
										echo json_encode($result);
6247
 
6248
										#卸除異常的程序
6249
										unset($procs[$procIndex]);
6250
 
6251
										#結束執行,回傳1給shell,代表異常,
6252
										exit(1);
6253
 
6254
										}#if end
6255
 
6256
									#取得解析的json
6257
									$updateCopyRightYear=(array)(json_decode($threadStdOut));
6258
 
6259
									#如果執行失敗
6260
									if($updateCopyRightYear["status"]==="false"){
6261
 
6262
										#關閉程序
6263
										proc_close($procs[$procIndex]["content"][0]["process"]);
6264
 
6265
										#設置錯誤識別
6266
										$result["status"]="false";
6267
 
6268
										#設置錯誤訊息
6269
										$result["error"]=$updateCopyRightYear;
6270
 
6271
										#印出json
6272
										echo json_encode($result);
6273
 
6274
										#卸除異常的程序
6275
										unset($procs[$procIndex]);
6276
 
6277
										#結束執行,回傳1給shell,代表異常,
6278
										exit(1);
6279
 
6280
										}#if end
6281
 
6282
									#記錄有掃描的資料夾路徑與名稱 
6283
									$result["scannedFile"][]=$NodePathAndName;
6284
 
6285
									#合併 content - start
6286
 
6287
									#函式說明:
6288
									#將多個一維陣列串聯起來,key從0開始排序.
6289
									#回傳的結果:
6290
									#$result["status"],"true"表執行正常,"false"代表執行不正常.
6291
									#$result["error"],錯誤訊息陣列.
6292
									#$result["function"],當前執行的函數.
6293
									#$result["content"],合併好的一維陣列.
6294
									#必填參數
6295
									#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
6296
									$conf["arrays::mergeArray"]["inputArray"]=array($result["content"],$updateCopyRightYear["content"]);
6297
									#可省略參數:
6298
									#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
6299
									#$conf["allowRepeat"]="true";
6300
									#參考資料:
6301
									#無.
6302
									#備註:
6303
									#無.
6304
									$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
6305
									unset($conf["arrays::mergeArray"]);
6306
 
6307
									#如果執行失敗
6308
									if($mergeArray["status"]==="false"){
6309
 
6310
										#關閉程序
6311
										proc_close($procs[$procIndex]["content"][0]["process"]);
6312
 
6313
										#設置錯誤識別
6314
										$result["status"]="false";
6315
 
6316
										#設置錯誤訊息
6317
										$result["error"]=$mergeArray;
6318
 
6319
										#印出json
6320
										echo json_encode($result);
6321
 
6322
										#卸除異常的程序
6323
										unset($procs[$procIndex]);
6324
 
6325
										#結束執行,回傳1給shell,代表異常,
6326
										exit(1);
6327
 
6328
										}#if end
6329
 
6330
									#取得合併好的有異動檔案結果
6331
									$result["content"]=$mergeArray["content"];
6332
 
6333
									#合併 content - end
6334
 
6335
									#合併 scannedFile - start
6336
 
6337
									if(isset($updateCopyRightYear["scannedFile"])){
6338
 
6339
										#函式說明:
6340
										#將多個一維陣列串聯起來,key從0開始排序.
6341
										#回傳的結果:
6342
										#$result["status"],"true"表執行正常,"false"代表執行不正常.
6343
										#$result["error"],錯誤訊息陣列.
6344
										#$result["function"],當前執行的函數.
6345
										#$result["content"],合併好的一維陣列.
6346
										#必填參數
6347
										#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
6348
										$conf["arrays::mergeArray"]["inputArray"]=array($result["scannedFile"],$updateCopyRightYear["scannedFile"]);
6349
										#可省略參數:
6350
										#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
6351
										#$conf["allowRepeat"]="true";
6352
										#參考資料:
6353
										#無.
6354
										#備註:
6355
										#無.
6356
										$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
6357
										unset($conf["arrays::mergeArray"]);
6358
 
6359
										#如果執行失敗
6360
										if($mergeArray["status"]==="false"){
6361
 
6362
											#關閉程序
6363
											proc_close($procs[$procIndex]["content"][0]["process"]);
6364
 
6365
											#設置錯誤識別
6366
											$result["status"]="false";
6367
 
6368
											#設置錯誤訊息
6369
											$result["error"]=$mergeArray;
6370
 
6371
											#印出json
6372
											echo json_encode($result);
6373
 
6374
											#卸除異常的程序
6375
											unset($procs[$procIndex]);
6376
 
6377
											#結束執行,回傳1給shell,代表異常,
6378
											exit(1);
6379
 
6380
											}#if end
6381
 
6382
										#取得合併好的有異動檔案結果
6383
										$result["scannedFile"]=$mergeArray["content"];
6384
 
6385
										}#if end
6386
 
6387
									#合併 scannedFile - end
6388
 
6389
									#關閉程序
6390
									proc_close($procs[$procIndex]["content"][0]["process"]);
6391
 
6392
									#卸除做好的程序
6393
									unset($procs[$procIndex]);
6394
 
6395
									}#else end
6396
 
6397
								#end switch
6398
								break;
6399
 
6400
							#如果是透過socket
6401
							case "socket":
6402
 
6403
								#取得  proc 的 uuid
6404
								$procUuid=$procValue["content"][0]["content"];
6405
 
6406
								#函式說明:
6407
								#詢問透過 sock::unixDomainSockServer 執行的程序狀況
6408
								#回傳結果:
6409
								#$result["status"],"true"代表執行正常;"false"代表執行不正常.
6410
								#$result["error"],錯誤訊息陣列.
6411
								#$result["function"],當前執行的函式名稱.
6412
								#$result["argu"],使用的參數.
6413
								#$result["content"],陣列,程序的資訊.
6414
								#$result["content"]["pid"],字串,程序的pid.
6415
								#$result["content"]["running"],字串,是否正常執行中.
6416
								#$result["content"]["statusCode"],字串,回傳給 shell 的代碼.
6417
								#$result["content"]["input"],字串,輸入的內容.
6418
								#$result["content"]["output"],字串,標準輸出的內容.
6419
								#$result["content"]["error"],字串,錯誤輸出的內容.
6420
								#必填參數:
6421
								#$conf["uuid"],字串,proc的uuid.
6422
								$conf["sock::getProcInfo"]["uuid"]=$procUuid;
6423
								#可省略參數:
6424
								#$conf["sock"],字串,要連線的 usr/bin/qbpwcf-sock.php(sock::unixDomainSockServer) 所產生的 unix domain socket 路徑與名稱,預設為 qbpwcf_usock_path.
6425
								$conf["sock::getProcInfo"]["sock"]=$conf["socket"];
6426
								#參考資料:
6427
								#無.
6428
								#備註:
6429
								#無.
6430
								$getProcInfo=sock::getProcInfo($conf["sock::getProcInfo"]);
6431
								unset($conf["sock::getProcInfo"]);
6432
 
6433
								#debug
6434
								if($getProcInfo["status"]==="false"){
6435
 
6436
									#設置錯誤識別
6437
									$result["status"]="false";
6438
 
6439
									#設置錯誤訊息
6440
									$result["error"][]="get process info by uuid failed";
6441
 
6442
									#設置錯誤訊息
6443
									$result["error"][]=$getProcInfo;
6444
 
6445
									#印出json
6446
									echo json_encode($result);
6447
 
6448
									}#if end
6449
 
6450
								#如果已經停止運行
6451
								if($getProcInfo["content"]["running"]==="false"){
6452
 
6453
									#儲存程序執行的標準輸出
6454
									$threadStdOut=$getProcInfo["content"]["output"];
6455
 
6456
									#如果標準輸出不是json
6457
									if(json_validate($threadStdOut)===false){
6458
 
6459
										#設置錯誤識別
6460
										$result["status"]="false";
6461
 
6462
										#設置錯誤訊息
6463
										$result["error"]=$procValue;
6464
 
6465
										#印出json
6466
										echo json_encode($result);
6467
 
6468
										#卸除異常的程序
6469
										unset($procs[$procIndex]);
6470
 
6471
										#結束執行,回傳1給shell,代表異常,
6472
										exit(1);
6473
 
6474
										}#if end
6475
 
6476
									#取得解析的json
6477
									$updateCopyRightYear=(array)(json_decode($threadStdOut));
6478
 
6479
									#如果執行失敗
6480
									if($updateCopyRightYear["status"]==="false"){
6481
 
6482
										#設置錯誤識別
6483
										$result["status"]="false";
6484
 
6485
										#設置錯誤訊息
6486
										$result["error"]=$updateCopyRightYear;
6487
 
6488
										#印出json
6489
										echo json_encode($result);
6490
 
6491
										#卸除異常的程序
6492
										unset($procs[$procIndex]);
6493
 
6494
										#結束執行,回傳1給shell,代表異常,
6495
										exit(1);
6496
 
6497
										}#if end
6498
 
6499
									#記錄有掃描的資料夾路徑與名稱 
6500
									$result["scannedFile"][]=$NodePathAndName;
6501
 
6502
									#合併 content - start
6503
 
6504
									#函式說明:
6505
									#將多個一維陣列串聯起來,key從0開始排序.
6506
									#回傳的結果:
6507
									#$result["status"],"true"表執行正常,"false"代表執行不正常.
6508
									#$result["error"],錯誤訊息陣列.
6509
									#$result["function"],當前執行的函數.
6510
									#$result["content"],合併好的一維陣列.
6511
									#必填參數
6512
									#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
6513
									$conf["arrays::mergeArray"]["inputArray"]=array($result["content"],$updateCopyRightYear["content"]);
6514
									#可省略參數:
6515
									#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
6516
									#$conf["allowRepeat"]="true";
6517
									#參考資料:
6518
									#無.
6519
									#備註:
6520
									#無.
6521
									$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
6522
									unset($conf["arrays::mergeArray"]);
6523
 
6524
									#如果執行失敗
6525
									if($mergeArray["status"]==="false"){
6526
 
6527
										#設置錯誤識別
6528
										$result["status"]="false";
6529
 
6530
										#設置錯誤訊息
6531
										$result["error"]=$mergeArray;
6532
 
6533
										#印出json
6534
										echo json_encode($result);
6535
 
6536
										#卸除異常的程序
6537
										unset($procs[$procIndex]);
6538
 
6539
										#結束執行,回傳1給shell,代表異常,
6540
										exit(1);
6541
 
6542
										}#if end
6543
 
6544
									#取得合併好的有異動檔案結果
6545
									$result["content"]=$mergeArray["content"];
6546
 
6547
									#合併 content - end
6548
 
6549
									#合併 scannedFile - start
6550
 
6551
									if(isset($updateCopyRightYear["scannedFile"])){
6552
 
6553
										#函式說明:
6554
										#將多個一維陣列串聯起來,key從0開始排序.
6555
										#回傳的結果:
6556
										#$result["status"],"true"表執行正常,"false"代表執行不正常.
6557
										#$result["error"],錯誤訊息陣列.
6558
										#$result["function"],當前執行的函數.
6559
										#$result["content"],合併好的一維陣列.
6560
										#必填參數
6561
										#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
6562
										$conf["arrays::mergeArray"]["inputArray"]=array($result["scannedFile"],$updateCopyRightYear["scannedFile"]);
6563
										#可省略參數:
6564
										#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
6565
										#$conf["allowRepeat"]="true";
6566
										#參考資料:
6567
										#無.
6568
										#備註:
6569
										#無.
6570
										$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
6571
										unset($conf["arrays::mergeArray"]);
6572
 
6573
										#如果執行失敗
6574
										if($mergeArray["status"]==="false"){
6575
 
6576
											#設置錯誤識別
6577
											$result["status"]="false";
6578
 
6579
											#設置錯誤訊息
6580
											$result["error"]=$mergeArray;
6581
 
6582
											#印出json
6583
											echo json_encode($result);
6584
 
6585
											#卸除異常的程序
6586
											unset($procs[$procIndex]);
6587
 
6588
											#結束執行,回傳1給shell,代表異常,
6589
											exit(1);
6590
 
6591
											}#if end
6592
 
6593
										#取得合併好的有異動檔案結果
6594
										$result["scannedFile"]=$mergeArray["content"];
6595
 
6596
										}#if end
6597
 
6598
									#合併 scannedFile - end
6599
 
6600
									#卸除做好的程序
6601
									unset($procs[$procIndex]);
6602
 
6603
									}#if end
6604
 
6605
								#end switch
6606
								break;
6607
 
6608
							#其他類型
6609
							default:
6610
 
6611
								#設置錯誤識別
6612
								$result["status"]="false";
6613
 
6614
								#設置錯誤訊息
6615
								$result["error"][]="not supported multi threads type ".$threadType;
6616
 
6617
								#印出json
6618
								echo json_encode($result);
6619
 
6620
								#結束執行,回傳1給shell,代表異常,
6621
								exit(1);
6622
 
6623
							}#switch end
6624
 
6625
						}#foreach end
6626
 
6627
					#如果已經執行完所有子程序
6628
					if(empty($procs)){
6629
 
6630
						#如果有要log
6631
						if(isset($conf["log"])){
6632
 
6633
							#函式說明:
6634
							#撰寫log
6635
							#回傳結果:
6636
							#$result["status"],狀態,"true"或"false".
6637
							#$result["error"],錯誤訊息陣列.
6638
							#$result["function"],當前函式的名稱.
6639
							#$result["argu"],使用的參數.
6640
							#必填參數:
6641
							#$conf["path"],字串,log檔案的路徑與名稱.
6642
							$conf["logs::record"]["path"]=$logPathForRunTimeOfStartAndEnd;
6643
							#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
6644
							$conf["logs::record"]["content"]="end at ".gmdate("Y-m-d H:i:s");
6645
							#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6646
							$conf["logs::record"]["fileArgu"]=__FILE__;
6647
							#可省略參數:
6648
							#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
6649
							#$conf["rewrite"]="false";
6650
							#參考資料:
6651
							#無.
6652
							#備註:
6653
							#無.
6654
							$record=logs::record($conf["logs::record"]);
6655
							unset($conf["logs::record"]);
6656
 
6657
							#如果出錯
6658
							if($record["status"]==="false"){
6659
 
6660
								#設置錯誤識別
6661
								$result["status"]="false";
6662
 
6663
								#設置錯誤訊息
6664
								$result["error"]=$record;
6665
 
6666
								#印出json
6667
								echo json_encode($result);
6668
 
6669
								#結束執行,回傳1給shell,代表異常,
6670
								exit(1);
6671
 
6672
								}#if end
6673
 
6674
							}#if end
6675
 
6676
						#結束子程序的檢查
6677
						break;
6678
 
6679
						}#if end
6680
 
6681
					#執行到這邊,代表尚有程序再執行.
6682
 
6683
					#如果要log
6684
					if(isset($conf["log"])){
6685
 
6686
 
6687
 
6688
						}#if end
6689
 
6690
					#休息1秒鐘
6691
					sleep(1);
6692
 
6693
					}#while end
6694
 
6695
				}#if end
6696
 
6697
			}#if end
6698
 
6699
		#設置執行正常
6700
		$result["status"]="true";
6701
 
6702
		#如果是透過多執行序執行
6703
		if($conf["multiThread"]==="true"){
6704
 
6705
			#印出json結果
6706
			echo json_encode($result);
6707
 
6708
			}#if end
6709
 
6710
		#反之
6711
		else{
6712
 
6713
			#回傳結果
6714
			return $result;
6715
 
6716
			}#else end
6717
 
6718
		}#function updateCopyRightYear end
218 liveuser 6719
 
6720
	/*
6721
	#函式說明:
6722
	#置換檔案內容中符合的內容.
6723
	#回傳結果:
6724
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6725
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
6726
	#$result["function"],當前執行的函式名稱.
6727
	#$result["argu"],本函式使用的參數.
6728
	#$result["content"],更新後的檔案內容陣列.每個元素代表一行的內容.
6729
	#$result["found"],字串,是否有找到符合條件需要置換的內容.
6730
	#$result["relaceInfo"],陣列,記錄需要置換的行資訊,元素的key為需要置換的行號,第 $i 行用 $i+1 表示.
6731
	#$result["relaceInfo"][$i]["ori"],字串,第 $i+1 行原始的內容.
6732
	#$result["relaceInfo"][$i]["new"],字串,第 $i+1 行要置換成的內容.
6733
	#$result["content"],陣列,替換完後的每行內容.
6734
	#必填參數:
6735
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6736
	$conf["fileArgu"]=__FILE__;
6737
	#$conf["file"],字串,要置換內容的檔案路徑與名稱.
6738
	$conf["file"]="";
6739
	#$conf["formats"],陣列,連續的關鍵字字串.
6740
	$conf["formats"]=array();
6741
	#$conf["replaceTo"],陣列,原始內容要如何置換,每個元素的索引對應到formats參數的每個元素,若其索引不存在則代表對應的行不異動.
6742
	$conf["replaceTo"]=array();
6743
	#可省略參數:
6744
	#無.
6745
	#參考資料:
6746
	#無.
6747
	#備註:
6748
	#參數設定 $conf["replaceTo"][$i]=$replaceStr; 代表符合格式的連續字串中的 $i+1 行內容要置換成 $replaceStr.
6749
	#參數設定 $conf["replaceTo"][$i]=array("varName1"=>$replaceStr1,"varName2"=>$replaceStr2); 代表符合格式的連續字串中的 $i+1 行內容中的變數 varName1 要置換成 $replaceStr1;變數 varName2 要置換成 $replaceStr2.
6750
	*/
6751
	public static function replaceMatchContent(&$conf){
6752
 
6753
		#初始化要回傳的結果
6754
		$result=array();
6755
 
6756
		#取得當前執行的函數名稱
6757
		$result["function"]=__FUNCTION__;
6758
 
6759
		#如果沒有參數
6760
		if(func_num_args()==0){
6761
 
6762
			#設置執行失敗
6763
			$result["status"]="false";
6764
 
6765
			#設置執行錯誤訊息
6766
			$result["error"]="函數".$result["function"]."需要參數";
6767
 
6768
			#回傳結果
6769
			return $result;
6770
 
6771
			}#if end
6772
 
6773
		#取得參數
6774
		$result["argu"]=$conf;
6775
 
6776
		#如果 $conf 不為陣列
6777
		if(gettype($conf)!=="array"){
6778
 
6779
			#設置執行失敗
6780
			$result["status"]="false";
6781
 
6782
			#設置執行錯誤訊息
6783
			$result["error"][]="\$conf變數須為陣列形態";
6784
 
6785
			#如果傳入的參數為 null
6786
			if(is_null($conf)){
6787
 
6788
				#設置執行錯誤訊息
6789
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6790
 
6791
				}#if end
6792
 
6793
			#回傳結果
6794
			return $result;
6795
 
6796
			}#if end
6797
 
6798
		#參數檢查
6799
		#函式說明:
6800
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
6801
		#回傳結果:
6802
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6803
		#$result["error"],執行不正常結束的錯訊息陣列.
6804
		#$result["simpleError"],簡單表示的錯誤訊息.
6805
		#$result["function"],當前執行的函式名稱.
6806
		#$result["argu"],設置給予的參數.
6807
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
6808
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
6809
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
6810
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
6811
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
6812
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
6813
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
6814
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
6815
		#必填參數:
6816
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
6817
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
6818
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
6819
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
6820
		#可省略參數:
6821
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
6822
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","file","formats","replaceTo");
6823
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".
6824
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","array","array");
6825
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
6826
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
6827
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
6828
		#$conf["canNotBeEmpty"]=array();
6829
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
6830
		#$conf["canBeEmpty"]=array();
6831
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
6832
		#$conf["skipableVariableCanNotBeEmpty"]=array();
6833
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
6834
		#$conf["skipableVariableName"]=array();
6835
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
6836
		#$conf["skipableVariableType"]=array();
6837
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
6838
		#$conf["skipableVarDefaultValue"]=array("");
6839
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
6840
		#$conf["disallowAllSkipableVarIsEmpty"]="";
6841
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
6842
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
6843
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
6844
		#$conf["disallowAllSkipableVarNotExist"]="";
6845
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
6846
		#$conf["arrayCountEqualCheck"][]=array();
6847
		#參考資料:
6848
		#array_keys=>http://php.net/manual/en/function.array-keys.php
6849
		#備註:
6850
		#無.
6851
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
6852
		unset($conf["variableCheck::checkArguments"]);
6853
 
6854
		#如果執行失敗
6855
		if($checkArguments["status"]==="false"){
6856
 
6857
			#設置錯誤識別
6858
			$result["status"]="false";
6859
 
6860
			#設置錯誤訊息
6861
			$result["error"]=$checkArguments;
6862
 
6863
			#回傳結果
6864
			return $result;
6865
 
6866
			}#if end
6867
 
6868
		#如果檢查參數不通過
6869
		if($checkArguments["passed"]==="false"){
6870
 
6871
			#設置錯誤識別
6872
			$result["status"]="false";
6873
 
6874
			#設置錯誤訊息
6875
			$result["error"]=$checkArguments;
6876
 
6877
			#回傳結果
6878
			return $result;
6879
 
6880
			}#if end
6881
 
6882
		#取得檔案的內容
6883
		#函式說明:
6884
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
6885
		#回傳的變數說明:
6886
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
6887
		#$result["error"],錯誤訊息提示.
6888
		#$result["warning"],警告訊息.
6889
		#$result["function"],當前執行的函數名稱.
6890
		#$result["fileContent"],爲檔案的內容陣列.
6891
		#$result["lineCount"],爲檔案內容總共的行數.
6892
		#$result["fullContent"],為檔案的完整內容.
6893
		#$result["base64data"],為檔案的base64內容.
6894
		#$result["mimeType"],為檔案的mime type.
6895
		#必填參數:
6896
		#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
6897
		$conf["fileAccess::getFileContent"]["filePositionAndName"]=$conf["file"];
6898
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6899
		$conf["fileAccess::getFileContent"]["fileArgu"]=$conf["fileArgu"];
6900
		#可省略參數:
6901
		#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
6902
		#$conf["web"]="true";
6903
		#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
6904
		#$conf["createIfnotExist"]="false";
6905
		#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
6906
		#$conf["autoDeleteSpaceOnEachLineStart"]="false";
6907
		#參考資料:
6908
		#file(),取得檔案內容的行數.
6909
		#file=>http:#php.net/manual/en/function.file.php
6910
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
6911
		#filesize=>http://php.net/manual/en/function.filesize.php
6912
		#參考資料:
6913
		#無.
6914
		#備註:
6915
		#無.
6916
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
6917
		unset($conf["fileAccess::getFileContent"]);
66 liveuser 6918
 
218 liveuser 6919
		#如果執行失敗
6920
		if($getFileContent["status"]==="false"){
6921
 
6922
			#設置錯誤識別
6923
			$result["status"]="false";
6924
 
6925
			#設置錯誤訊息
6926
			$result["error"]=$getFileContent;
6927
 
6928
			#回傳結果
6929
			return $result;
6930
 
6931
			}#if end
6932
 
6933
		#尋找連續的多行字串是否依順含有符合格式的內容,且回傳解析好的變數數值.
6934
		#回傳結果:
6935
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6936
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
6937
		#$result["function"],當前執行的函式名稱.
6938
		#$result["argu"],所使用的參數.
6939
		#$result["found"],是否有找到符合格式的連續字串內容,"true"代表有找到,"false"代表沒有找到.
6940
		#$result["content"],陣列,每段符合格式的段落資訊.
6941
		#$result["content"][$i]["lineS"],字串,為第 $i+1 個符合格式的段落起始行數.
6942
		#$result["content"][$i]["ori"],字串,為第 $i+1 個符合格式的段落每行原始內容資訊.
6943
		#$result["content"][$i]["deletedHead"],字串,為第 $i+1 個符合格式的段落每行原始內容被剔除的開頭資訊.
6944
		#$result["content"][$i]["new"],字串,為第 $i+1 個符合格式的段落每行關鍵字內容.
6945
		#$result["content"][$i]["vars"],陣列,為第 $i+1 個符合格式的段落每行變數解析的結果.
6946
		#必填參數:
6947
		#$conf["input"],字串陣列,要檢查的每行字串.
6948
		$conf["search::findConMatchStrs"]["input"]=$getFileContent["fileContent"];
6949
		#$conf["format"],格式字串陣列,要尋找的每行格式字串集合.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
6950
		$conf["search::findConMatchStrs"]["formats"]=$conf["formats"];
6951
		#可省略參數:
6952
		#無.
6953
		#參考資料:
6954
		#無.
6955
		#備註:
6956
		#回傳結果 $result["content"][$i]["ori"][$j]=array("index"=>$oriLineIndex,"value"=>$oriLineContent) 代表第 $i+1 個符合格式的段落中第 $j+1 個原始內容對應的行數($oriLineIndex+1),其原始內容為 $oriLineContent.
6957
		$findConMatchStrs=search::findConMatchStrs($conf["search::findConMatchStrs"]);
6958
		unset($conf["search::findConMatchStrs"]);
6959
 
6960
		#如果執行失敗
6961
		if($findConMatchStrs["status"]==="false"){
6962
 
6963
			#設置錯誤識別
6964
			$result["status"]="false";
6965
 
6966
			#設置錯誤訊息
6967
			$result["error"]=$findConMatchStrs;
6968
 
6969
			#回傳結果
6970
			return $result;
6971
 
6972
			}#if end
6973
 
6974
		#如果沒有符合的連續字串格式
6975
		if($findConMatchStrs["found"]==="false"){
6976
 
6977
			#設置執行正常的識別
6978
			$result["status"]="true";
6979
 
6980
			#設置沒有找到符合格式內容
6981
			$result["found"]="false";
6982
 
6983
			#回傳結果
6984
			return $result;
6985
 
6986
			}#if end
6987
 
6988
		#初始化儲存內容置換資訊的變數
6989
		$result["relaceInfo"]=array();
6990
 
6991
		#debug
6992
		#var_dump(__LINE__,$findConMatchStrs["content"]);exit;
6993
 
6994
		#執行到這邊代表有遇到符合的連續字串格式
6995
		foreach($findConMatchStrs["content"] as $matchSectionIndex => $sInfo){
6996
 
6997
			#針對符合的每行內容
6998
			foreach($sInfo["ori"] as $index => $lInfo){
6999
 
7000
				#取得對應的原始行索引
7001
				$oriLineNo=$lInfo["index"];
7002
 
7003
				#取得對應的原始行內容
7004
				$oriLineContent=$lInfo["value"];
7005
 
7006
				#儲存被剔除的開頭部分
7007
				$deletedOriHead=$lInfo["deletedHead"];
7008
 
7009
				#如果沒有對應的要取代格式
7010
				if(!isset($conf["replaceTo"][$index])){
7011
 
7012
					#不處理
7013
					continue;
7014
 
7015
					}#if end
7016
 
7017
				#如果解析的結果有變數
7018
				if(empty($sInfo["vars"][$index])){
7019
 
7020
					#debug
7021
					#var_dump(__LINE__,$index,$sInfo["vars"][$index]);
7022
 
7023
					#執行到這邊代表有對應的要取代格式
7024
 
7025
					#debug
7026
					#var_dump(__LINE__,$index,gettype($conf["replaceTo"][$index]),$conf["replaceTo"]);
7027
 
7028
					#如果取代格式不為字串
7029
					if(gettype($conf["replaceTo"][$index])!=="string"){
7030
 
7031
						#設置執行不正常的識別
7032
						$result["status"]="false";
7033
 
7034
						#設置錯誤訊息
7035
						$result["error"]="參數 formats 跟 replaceTo 的對應有錯誤.";
7036
 
7037
						#回傳結果
7038
						return $result;
7039
 
7040
						}#if end
7041
 
7042
					#執行到這邊代表檢查通過
7043
 
7044
					#記錄取代的資訊
7045
					$result["relaceInfo"][$oriLineNo]=array("deletedOriHead"=>$deletedOriHead,"ori"=>$oriLineContent,"new"=>$conf["replaceTo"][$index]);
7046
 
7047
					}#if end
7048
 
7049
				#反之代表有解析出變數
7050
				else{
7051
 
7052
					#debug
7053
					#var_dump(__LINE__,gettype($conf["replaceTo"][$index]));
7054
 
7055
					#如果取代格式不為陣列
7056
					if(gettype($conf["replaceTo"][$index])!=="array"){
7057
 
7058
						#設置執行不正常的識別
7059
						$result["status"]="false";
7060
 
7061
						#設置錯誤訊息
7062
						$result["error"]="參數 formats 跟 replaceTo 的對應有錯誤.";
7063
 
7064
						#回傳結果
7065
						return $result;
7066
 
7067
						}#if end
7068
 
7069
					#執行到這邊代表檢查通過
7070
 
7071
					#初始化替換好的內容
7072
					$newLineContent=$oriLineContent;
7073
 
7074
					#針對每個解析出來的變數
7075
					foreach($conf["replaceTo"][$index] as $varName => $newVal){
7076
 
7077
						#取得原始解析出來的內容
7078
						$oriVal=$sInfo["vars"][$index][$varName][0];
7079
 
7080
						#將關鍵字取代
7081
						#函式說明:
7082
						#將字串中的特定內容取代.
7083
						#回傳結果:
7084
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
7085
						#$result["function"],當前執行的函數.
7086
						#$result["content"],爲處理好的字串.
7087
						#$result["error"],錯誤訊息陣列.
7088
						#$result["argu"],使用的參數. 
7089
						#必填參數:
7090
						#$conf["stringIn"],字串,爲要處理的字串
7091
						$conf["stringProcess::replaceOnce"]["stringIn"]=$newLineContent;
7092
						#$conf["selectedCharacter"],字串,爲被選擇要處理的字串/字元,\n」代表換行,「\t」代表tab鍵的間隔.
7093
						$conf["stringProcess::replaceOnce"]["selectedCharacter"]=$oriVal;
7094
						#$conf["changeTo"],字串,爲被選擇的字元要換成什麼字串/字元.
7095
						$conf["stringProcess::replaceOnce"]["changeTo"]=$newVal;
7096
						#參考資料:
7097
						#無.
7098
						#備註:
7099
						#無.
7100
						$replaceOnce=stringProcess::replaceOnce($conf["stringProcess::replaceOnce"]);
7101
						unset($conf["stringProcess::replaceOnce"]);
7102
 
7103
						#debug
7104
						#var_dump(__LINE__,$replaceOnce);
7105
 
7106
						#如果執行失敗
7107
						if($replaceOnce["status"]==="false"){
7108
 
7109
							#設置錯誤識別
7110
							$result["status"]="false";
7111
 
7112
							#設置錯誤訊息
7113
							$result["error"]=$replaceOnce;
7114
 
7115
							#回傳結果
7116
							return $result;
7117
 
7118
							}#if end
7119
 
7120
						#儲存該階段替換好的內容
7121
						$newLineContent=$replaceOnce["content"];
7122
 
7123
						}#foreach end
7124
 
7125
					#記錄取代的資訊
7126
					$result["relaceInfo"][$oriLineNo]=array("deletedOriHead"=>$deletedOriHead,"ori"=>$oriLineContent,"new"=>$newLineContent);
7127
 
7128
					}#else end
7129
 
7130
				}#foreach end
7131
 
7132
			}#foreach end
7133
 
7134
		#初始化替換好的內容為原始內容
7135
		$result["content"]=$getFileContent["fileContent"];
7136
 
7137
		#依照內容替代的資訊
7138
		foreach($result["relaceInfo"] as $lineIndex =>$info){
7139
 
7140
			#儲存新的行內容
7141
			$newLine=$info["new"];
7142
 
7143
			#儲存被剔除的開頭字串
7144
			$deletedOriHead=$info["deletedOriHead"];
7145
 
7146
			#儲存置換好的行
7147
			$result["content"][$lineIndex]=$deletedOriHead.$newLine;
7148
 
7149
			}#foreach end
7150
 
7151
		#設置執行正常
7152
		$result["status"]="true";
7153
 
7154
		#回傳結果
7155
		return $result;
7156
 
7157
		}#function replaceMatchContent end
7158
 
3 liveuser 7159
	}#class phpLib end
7160
 
7161
?>