Subversion Repositories php-qbpwcf

Rev

Rev 316 | 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.
239 liveuser 6
    Copyright (C) 2014~2026 MIN ZHI, CHEN
3 liveuser 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
備註:
226 liveuser 30
待所有函數類別與函數都標準化後,再來修改該函數會比較恰當.
3 liveuser 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){
226 liveuser 52
 
3 liveuser 53
		#取得當前執行的函式
54
		$result["function"]=__FUNCTION__;
226 liveuser 55
 
3 liveuser 56
		#設置執行不正常
57
		$result["status"]="false";
226 liveuser 58
 
3 liveuser 59
		#設置執行錯誤
60
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
226 liveuser 61
 
3 liveuser 62
		#設置所丟入的參數
63
		$result["error"][]=$arguments;
226 liveuser 64
 
3 liveuser 65
		#回傳結果
66
		return $result;
226 liveuser 67
 
3 liveuser 68
		}#function __call end
226 liveuser 69
 
3 liveuser 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){
226 liveuser 88
 
3 liveuser 89
		#取得當前執行的函式
90
		$result["function"]=__FUNCTION__;
226 liveuser 91
 
3 liveuser 92
		#設置執行不正常
93
		$result["status"]="false";
226 liveuser 94
 
3 liveuser 95
		#設置執行錯誤
96
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
226 liveuser 97
 
3 liveuser 98
		#設置所丟入的參數
99
		$result["error"][]=$arguments;
226 liveuser 100
 
3 liveuser 101
		#回傳結果
102
		return $result;
226 liveuser 103
 
3 liveuser 104
		}#function __callStatic end
105
 
106
	/*
107
	#函式說明:
108
	#取得目錄底下函式庫檔案清單
109
	#回傳結果:
110
	#$result["status"],"true"表示執行成功;"false"表示執行失敗
111
	#$result["error"],錯誤訊息.
112
	#$result["function"],當前執行的函數名稱.
113
	#$result["dataCount"],有幾筆符合的資料
226 liveuser 114
	#$result["neededList"],符合條件的檔案清單
3 liveuser 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"){
226 liveuser 140
 
3 liveuser 141
			#設置執行失敗
142
			$result["status"]="false";
226 liveuser 143
 
3 liveuser 144
			#設置執行錯誤訊息
145
			$result["error"][]="\$conf變數須為陣列形態";
146
 
147
			#如果傳入的參數為 null
148
			if($conf==null){
226 liveuser 149
 
3 liveuser 150
				#設置執行錯誤訊息
151
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
226 liveuser 152
 
3 liveuser 153
				}#if end
154
 
155
			#回傳結果
156
			return $result;
226 liveuser 157
 
3 liveuser 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
		#可以省略的參數:
226 liveuser 170
		$conf["variableCheck"]["isexistMuti"]["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double");
3 liveuser 171
		#$conf["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
172
		$checkResult=variableCheck::isexistMulti($conf["variableCheck"]["isexistMuti"]);
173
		unset($conf["variableCheck"]["isexistMuti"]);
174
 
226 liveuser 175
		#如果參數檢查有問題
3 liveuser 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"){
226 liveuser 236
 
3 liveuser 237
			#設置執行失敗識別
238
			$result["status"]="false";
226 liveuser 239
 
3 liveuser 240
			#設置執行失敗提示
241
			$result["error"]=$ls;
226 liveuser 242
 
3 liveuser 243
			#回傳結果
244
			return $result;
226 liveuser 245
 
3 liveuser 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"){
226 liveuser 292
 
3 liveuser 293
				#設置執行失敗識別
294
				$result["status"]="false";
226 liveuser 295
 
3 liveuser 296
				#設置執行失敗提示
297
				$result["error"]=$spiltString["error"];
226 liveuser 298
 
3 liveuser 299
				#回傳結果
300
				return $result;
226 liveuser 301
 
3 liveuser 302
				}#if end
303
 
226 liveuser 304
			#如果「.」後面有內容
3 liveuser 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"],錯誤訊息陣列.
226 liveuser 317
				#$result["argu"],使用的參數.
3 liveuser 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"]);
226 liveuser 326
 
3 liveuser 327
				#如果處理失敗
328
				if($correctCharacter["status"]==="false"){
226 liveuser 329
 
3 liveuser 330
					#設置執行失敗識別
331
					$result["status"]="false";
226 liveuser 332
 
3 liveuser 333
					#設置執行失敗提示
334
					$result["error"]=$correctCharacter;
226 liveuser 335
 
3 liveuser 336
					#回傳結果
337
					return $result;
226 liveuser 338
 
3 liveuser 339
					}#if end
226 liveuser 340
 
3 liveuser 341
				#var_dump($spiltStr["dataArray"][$spiltStr["dataCounts"]-1]);
342
				#var_dump($correctCharacter["content"]);
226 liveuser 343
 
3 liveuser 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"){
226 liveuser 366
 
3 liveuser 367
					#設置執行失敗識別
368
					$result["status"]="false";
226 liveuser 369
 
3 liveuser 370
					#設置執行失敗提示
371
					$result["error"]=$compareResult;
226 liveuser 372
 
3 liveuser 373
					#回傳結果
374
					return $result;
226 liveuser 375
 
3 liveuser 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"],錯誤訊息陣列.
226 liveuser 388
					#$result["argu"],使用的參數.
3 liveuser 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"])){
226 liveuser 403
 
3 liveuser 404
						#debug
405
						#var_dump(__FILE__,__LINE__,$correctCharacter["content"],$conf["excludeFile"]);
226 liveuser 406
 
3 liveuser 407
						#忽略之
408
						continue;
226 liveuser 409
 
3 liveuser 410
						}#if end
226 liveuser 411
 
412
					#針對每個要排除的項目
3 liveuser 413
					foreach($conf["excludeFile"] as $excludeFile){
226 liveuser 414
 
3 liveuser 415
						#如果檔案名稱包含"*",且為第一個字
416
						if(strpos($excludeFile,"*")===0){
226 liveuser 417
 
3 liveuser 418
							#取得要排除的關鍵字
419
							$excludeFileKeyWord=substr($excludeFile,1);
226 liveuser 420
 
3 liveuser 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"]);
226 liveuser 443
 
3 liveuser 444
							#如果執行失敗
445
							if($getMeetConditionsString["status"]==="false"){
226 liveuser 446
 
3 liveuser 447
								#如果不是檔案名稱過短的錯誤
448
								if($getMeetConditionsString["error"][0]!=="要尋找的字尾長度大於要檢查的字串長度"){
226 liveuser 449
 
3 liveuser 450
									#設置執行失敗識別
451
									$result["status"]="false";
226 liveuser 452
 
3 liveuser 453
									#設置執行失敗提示
454
									$result["error"]=$getMeetConditionsString["error"];
226 liveuser 455
 
3 liveuser 456
									#回傳結果
457
									return $result;
226 liveuser 458
 
3 liveuser 459
									}#if end
226 liveuser 460
 
3 liveuser 461
								#設置沒有找到結尾相同的
462
								$getMeetConditionsString["founded"]="false";
226 liveuser 463
 
3 liveuser 464
								}#if end
226 liveuser 465
 
3 liveuser 466
							#如果結尾相同
467
							if($getMeetConditionsString["founded"]==="true"){
226 liveuser 468
 
3 liveuser 469
								#跳過該檔案
470
								continue 2;
226 liveuser 471
 
3 liveuser 472
								}#if end
226 liveuser 473
 
3 liveuser 474
							}#if end
226 liveuser 475
 
3 liveuser 476
						}#foreach end
477
 
478
					#debug
479
					#var_dump(__FILE__,__LINE__,$node["name"]);
480
 
481
					#只接受檔案(排除軟連結、資料夾)
482
					if($node["nType"]==='-'){
226 liveuser 483
 
3 liveuser 484
						#將該檔案項目取出
485
						$result["neededList"][]=$node["name"];
226 liveuser 486
 
3 liveuser 487
						#將是否有符合條件的檔案的識別設爲 "true"
488
						$result["status"]="true";
226 liveuser 489
 
3 liveuser 490
						}#if end
226 liveuser 491
 
3 liveuser 492
					}#if end
226 liveuser 493
 
3 liveuser 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"){
226 liveuser 544
 
3 liveuser 545
			#設置執行失敗
546
			$result["status"]="false";
226 liveuser 547
 
3 liveuser 548
			#設置執行錯誤訊息
549
			$result["error"][]="\$conf變數須為陣列形態";
550
 
551
			#如果傳入的參數為 null
552
			if($conf==null){
226 liveuser 553
 
3 liveuser 554
				#設置執行錯誤訊息
555
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
226 liveuser 556
 
3 liveuser 557
				}#if end
558
 
559
			#回傳結果
560
			return $result;
226 liveuser 561
 
3 liveuser 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"){
226 liveuser 615
 
3 liveuser 616
			#設置執行錯誤的識別
617
			$result["status"]="fasle";
618
 
619
			#設置執行錯誤的訊息
620
			$result["error"]=$checkArguments;
226 liveuser 621
 
3 liveuser 622
			#回傳結果
623
			return $result;
226 liveuser 624
 
3 liveuser 625
			}#if end
626
 
627
		# 如果檢查不通過
628
		if($checkArguments["passed"]=="false"){
226 liveuser 629
 
3 liveuser 630
			#設置執行錯誤的識別
631
			$result["status"]="fasle";
632
 
633
			#設置執行錯誤的訊息
634
			$result["error"]=$checkArguments;
226 liveuser 635
 
3 liveuser 636
			#回傳結果
637
			return $result;
226 liveuser 638
 
3 liveuser 639
			}#if end
640
 
641
		#函數說明:
642
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
643
		#回傳結果:
644
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
645
		#$result["error"],錯誤訊息陣列.
226 liveuser 646
		#$result["function"],函數名稱.
3 liveuser 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"){
226 liveuser 666
 
3 liveuser 667
			#設置執行錯誤的識別
668
			$result["status"]="fasle";
669
 
670
			#設置執行錯誤的訊息
671
			$result["error"]=$checkArguments;
226 liveuser 672
 
3 liveuser 673
			#回傳結果
674
			return $result;
226 liveuser 675
 
3 liveuser 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"){
226 liveuser 702
 
3 liveuser 703
			#設置執行失敗的識別
704
			$result["status"]="false";
226 liveuser 705
 
3 liveuser 706
			#設置錯誤訊息
707
			$result["error"]=$fileContent["error"];
226 liveuser 708
 
3 liveuser 709
			return $result;
226 liveuser 710
 
3 liveuser 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");#想要搜尋的關鍵字
226 liveuser 725
		$conf["search"]["findManyKeyWordsFromManyString"]["stringArray"]=$fileContent["fileContent"];#要被搜尋的字串內容陣列
3 liveuser 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){
226 liveuser 733
 
3 liveuser 734
			#確認該行是否為命名空間的宣告行
735
			#函式說明:
736
			#檢查一個字串裡面是否沒有多個任何篩選字存在
737
			#回傳的結果:
738
			#$result["status"],執行是否成功的識別,"true"為執行成功;"false"為執行失敗
226 liveuser 739
			#$result["error"],錯誤訊息陣列
3 liveuser 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"]);
226 liveuser 746
 
3 liveuser 747
			#如果 $searchResult["filtered"] 等於 "fasle"
748
			if($searchResult["filtered"]=="false"){
226 liveuser 749
 
3 liveuser 750
				#代表是命名空間宣告的行
226 liveuser 751
 
3 liveuser 752
				#取得命名空間宣告的行
753
				$namespaceStr=$value;
226 liveuser 754
 
3 liveuser 755
				#函式說明:
756
				#處理字串避免網頁出錯
757
				#回傳的結果:
758
				#回傳結果:
759
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
760
				#$result["function"],當前執行的函數.
761
				#$result["content"],爲處理好的字串.
762
				#$result["error"],錯誤訊息陣列.
226 liveuser 763
				#$result["argu"],使用的參數.
3 liveuser 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"]);
226 liveuser 772
 
3 liveuser 773
				#如果執行失敗
774
				if($correctCharacter["status"]==="false"){
226 liveuser 775
 
3 liveuser 776
					#設置執行失敗的識別
777
					$result["status"]="false";
226 liveuser 778
 
3 liveuser 779
					#設置錯誤訊息
780
					$result["error"]=$correctCharacter["error"];
226 liveuser 781
 
3 liveuser 782
					return $result;
226 liveuser 783
 
3 liveuser 784
					}#if end
226 liveuser 785
 
3 liveuser 786
				#記錄取得的命名空間所在行數與名稱
787
				$result["namespace"][]=array("lineNo"=>$lineNo,"content"=>$correctCharacter["content"]);
226 liveuser 788
 
3 liveuser 789
				# 從 namespace 往前讀取對應的註解
790
				for($i=$lineNo-1;$i>0;$i--){
226 liveuser 791
 
3 liveuser 792
					#初始化 $temp
793
					$temp=$fileContent["fileContent"][$i];
226 liveuser 794
 
3 liveuser 795
					#如果該行內容不為空
796
					if(!empty($fileContent["fileContent"][$i])){
226 liveuser 797
 
3 liveuser 798
						#函式說明:
799
						#處理字串避免網頁出錯
800
						#回傳的結果:
801
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
802
						#$result["function"],當前執行的函數.
803
						#$result["content"],爲處理好的字串.
804
						#$result["error"],錯誤訊息陣列.
226 liveuser 805
						#$result["argu"],使用的參數.
3 liveuser 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"]);
226 liveuser 814
 
3 liveuser 815
						#如果處理失敗
816
						if($correctCharacter["status"]==="false"){
817
 
818
							#設置執行錯誤的識別
819
							$result["status"]="false";
820
 
821
							#設置執行錯誤的訊息
822
							$result["error"]=$correctCharacter;
226 liveuser 823
 
3 liveuser 824
							#回傳結果
825
							return $result;
226 liveuser 826
 
3 liveuser 827
							}#if end
226 liveuser 828
 
3 liveuser 829
						#取得處理好的內容列
830
						$temp=$correctCharacter["content"];
226 liveuser 831
 
3 liveuser 832
						}#if end
226 liveuser 833
 
3 liveuser 834
					#如果 $temp 為 「/*」
835
					if($temp==="/*"){
226 liveuser 836
 
3 liveuser 837
						#跳出for迴圈
838
						break;
226 liveuser 839
 
3 liveuser 840
						}#if end
226 liveuser 841
 
842
					#如果 $temp 為 「*/」
3 liveuser 843
					if($temp==="*/"){
226 liveuser 844
 
3 liveuser 845
						#跳到下一輪
846
						continue;
226 liveuser 847
 
3 liveuser 848
						}#if end
226 liveuser 849
 
3 liveuser 850
					#記錄namesapce的註解內容
851
					$result["commentForNamespace"][count($result["namespace"])-1][]=$temp;
226 liveuser 852
 
3 liveuser 853
					}#for end
226 liveuser 854
 
3 liveuser 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"]);
226 liveuser 867
 
3 liveuser 868
				#如果轉置失敗
869
				if($convertResult["status"]=="false"){
226 liveuser 870
 
3 liveuser 871
					#設置執行失敗的識別
872
					$result["status"]="false";
226 liveuser 873
 
3 liveuser 874
					#設置執行失敗的提示
875
					$result["error"]=$convertResult;
226 liveuser 876
 
3 liveuser 877
					#回傳結果
878
					return $result;
226 liveuser 879
 
880
					}#if end
881
 
3 liveuser 882
				#反之代表執行成功
883
				else{
226 liveuser 884
 
3 liveuser 885
					#將倒置後的元素存起來
886
					$result["commentForNamespace"][count($result["namespace"])-1]=$convertResult["convertArray"];
226 liveuser 887
 
888
					}#else
889
 
3 liveuser 890
				}#if end
226 liveuser 891
 
3 liveuser 892
			}#foreach end
226 liveuser 893
 
3 liveuser 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"]);
226 liveuser 911
 
3 liveuser 912
		#debug
913
		#var_dump($foundedClassStrArray["foundedTrueKey"]);
914
		#exit;
226 liveuser 915
 
3 liveuser 916
		#針對每個找到"class"的行編號
917
		foreach($foundedClassStrArray["foundedTrueKey"] as $lineNo => $value){
226 liveuser 918
 
3 liveuser 919
			#確認該行是否真的為類別宣告行。
920
			#函式說明:
921
			#檢查一個字串裡面是否沒有多個任何篩選字存在
922
			#回傳的結果:
923
			#$result["status"],執行是否成功的識別,"true"為執行成功;"false"為執行失敗
226 liveuser 924
			#$result["error"],錯誤訊息陣列
3 liveuser 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"]);
226 liveuser 931
 
3 liveuser 932
			#如果 $searchResult["filtered"] 等於 "fasle"
933
			if($searchResult["filtered"]=="false"){
226 liveuser 934
 
3 liveuser 935
				#代表是類別宣告的行
226 liveuser 936
 
3 liveuser 937
				#取得類別宣告的行
938
				$classStr=$value;
226 liveuser 939
 
3 liveuser 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"]);
226 liveuser 952
 
3 liveuser 953
				#如果執行失敗
954
				if($correctCharacter["status"]==="false"){
226 liveuser 955
 
3 liveuser 956
					#設置執行失敗的識別
957
					$result["status"]="false";
226 liveuser 958
 
3 liveuser 959
					#設置錯誤訊息
960
					$result["error"]=$correctCharacter["error"];
226 liveuser 961
 
3 liveuser 962
					return $result;
226 liveuser 963
 
3 liveuser 964
					}#if end
226 liveuser 965
 
3 liveuser 966
				#針對每個命名空間
967
				foreach($result["namespace"] as $nsArray){
226 liveuser 968
 
3 liveuser 969
					#如果該類別的行數是在該namespace之後
970
					if($lineNo>$nsArray["lineNo"]){
226 liveuser 971
 
3 liveuser 972
						#設定該類別所屬的命名空間
973
						$namespace=$nsArray["content"];
226 liveuser 974
 
3 liveuser 975
						}#if end
226 liveuser 976
 
3 liveuser 977
					#反之
978
					else{
226 liveuser 979
 
3 liveuser 980
						#跳出foreach
981
						break;
226 liveuser 982
 
3 liveuser 983
						}#else end
226 liveuser 984
 
3 liveuser 985
					}#foreach end
226 liveuser 986
 
3 liveuser 987
				#記錄取得的類別所在行數與名稱
988
				$result["class"][]=array("lineNo"=>$lineNo,"content"=>$correctCharacter["content"],"namespace"=>$namespace);
226 liveuser 989
 
3 liveuser 990
				# 從 class 往前讀取對應的註解
991
				for($i=$lineNo-1;$i>0;$i--){
226 liveuser 992
 
3 liveuser 993
					#初始化 $temp
994
					$temp=$fileContent["fileContent"][$i];
226 liveuser 995
 
3 liveuser 996
					#如果該行內容不為空
997
					if(!empty($fileContent["fileContent"][$i])){
226 liveuser 998
 
3 liveuser 999
						#函式說明:
1000
						#處理字串避免網頁出錯
1001
						#回傳的結果:
1002
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1003
						#$result["function"],當前執行的函數.
1004
						#$result["content"],爲處理好的字串.
1005
						#$result["error"],錯誤訊息陣列.
226 liveuser 1006
						#$result["argu"],使用的參數.
3 liveuser 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"]);
226 liveuser 1015
 
3 liveuser 1016
						#如果處理失敗
1017
						if($correctCharacter["status"]==="false"){
1018
 
1019
							#設置執行錯誤的識別
1020
							$result["status"]="false";
1021
 
1022
							#設置執行錯誤的訊息
1023
							$result["error"]=$correctCharacter;
226 liveuser 1024
 
3 liveuser 1025
							#回傳結果
1026
							return $result;
226 liveuser 1027
 
3 liveuser 1028
							}#if end
226 liveuser 1029
 
3 liveuser 1030
						#取得處理好的內容列
1031
						$temp=$correctCharacter["content"];
226 liveuser 1032
 
3 liveuser 1033
						}#if end
1034
 
1035
					#如果 $temp 為 「/*」
1036
					if($temp==="/*"){
226 liveuser 1037
 
3 liveuser 1038
						#跳出for迴圈
1039
						break;
226 liveuser 1040
 
3 liveuser 1041
						}#if end
226 liveuser 1042
 
1043
					#如果 $temp 為 「*/」
3 liveuser 1044
					if($temp==="*/"){
226 liveuser 1045
 
3 liveuser 1046
						#跳到下一輪
1047
						continue;
226 liveuser 1048
 
3 liveuser 1049
						}#if end
226 liveuser 1050
 
3 liveuser 1051
					#記錄namesapce的註解內容
1052
					$result["commentForClass"][count($result["class"])-1][]=$temp;
226 liveuser 1053
 
3 liveuser 1054
					}#for end
226 liveuser 1055
 
3 liveuser 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"]);
226 liveuser 1068
 
3 liveuser 1069
				#如果轉置失敗
1070
				if($convertResult["status"]=="false"){
226 liveuser 1071
 
3 liveuser 1072
					#設置執行失敗的識別
1073
					$result["status"]="false";
226 liveuser 1074
 
3 liveuser 1075
					#設置執行失敗的提示
1076
					$result["error"]=$convertResult;
226 liveuser 1077
 
3 liveuser 1078
					#回傳結果
1079
					return $result;
226 liveuser 1080
 
1081
					}#if end
1082
 
3 liveuser 1083
				#反之代表執行成功
1084
				else{
226 liveuser 1085
 
3 liveuser 1086
					#將倒置後的元素存起來
1087
					$result["commentForClass"][count($result["class"])-1]=$convertResult["convertArray"];
226 liveuser 1088
 
1089
					}#else
1090
 
3 liveuser 1091
				}#if end
226 liveuser 1092
 
3 liveuser 1093
			}#foreach end
226 liveuser 1094
 
3 liveuser 1095
		#針對每個要處理的命名空間註解陣列
1096
		foreach($result["commentForNamespace"] as $index => $cfn){
226 liveuser 1097
 
3 liveuser 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"]);
226 liveuser 1120
 
3 liveuser 1121
			#如果執行失敗
1122
			if($arrayToString["status"]==="false"){
226 liveuser 1123
 
3 liveuser 1124
				#設定執行錯誤識別
1125
				$result["status"]="false";
226 liveuser 1126
 
3 liveuser 1127
				#設定執行錯誤提示
1128
				$result["error"]=$arrayToString;
226 liveuser 1129
 
1130
				#回傳結果
3 liveuser 1131
				return $result;
226 liveuser 1132
 
3 liveuser 1133
				}#if end
1134
 
1135
			#轉存為字串
1136
			$result["commentForNamespace"][$index]=$arrayToString["content"];
226 liveuser 1137
 
3 liveuser 1138
			}#foreach end
226 liveuser 1139
 
3 liveuser 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"){
226 liveuser 1168
 
3 liveuser 1169
				#設定執行錯誤識別
1170
				$result["status"]="false";
226 liveuser 1171
 
3 liveuser 1172
				#設定執行錯誤提示
1173
				$result["error"]=$arrayToString;
226 liveuser 1174
 
1175
				#回傳結果
3 liveuser 1176
				return $result;
226 liveuser 1177
 
3 liveuser 1178
				}#if end
1179
 
1180
			#轉存為字串
226 liveuser 1181
			$result["commentForClass"][$index]=$arrayToString["content"];
1182
 
3 liveuser 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"]);
226 liveuser 1202
 
3 liveuser 1203
		#針對每個找到"function"的行編號
1204
		foreach($foundedFunctionStrArray["foundedTrueKey"] as $keyNo=>$keyContent){
226 liveuser 1205
 
3 liveuser 1206
			#確認該行是否真的為函式宣告行。
1207
			#函式說明:
1208
			#檢查一個字串裡面是否沒有多個任何篩選字存在
1209
			#回傳的結果:
1210
			#$result["status"],執行是否成功的識別,"true"為執行成功;"false"為執行失敗
226 liveuser 1211
			#$result["error"],錯誤訊息陣列
3 liveuser 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"]);
226 liveuser 1218
 
3 liveuser 1219
			#如果 $searchResult["filtered"] 等於 "fasle"
1220
			if($searchResult["filtered"]==="false"){
226 liveuser 1221
 
3 liveuser 1222
				#代表是宣告函式的行
226 liveuser 1223
 
3 liveuser 1224
				#取得類宣告函式的行
1225
				$functionStr=$keyContent;
226 liveuser 1226
 
3 liveuser 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"]);
226 liveuser 1239
 
3 liveuser 1240
				#如果執行失敗
1241
				if($correctCharacter["status"]==="false"){
226 liveuser 1242
 
3 liveuser 1243
					#設定執行錯誤識別
1244
					$result["status"]="false";
226 liveuser 1245
 
3 liveuser 1246
					#設定執行錯誤提示
1247
					$result["error"]=$correctCharacter;
226 liveuser 1248
 
1249
					#回傳結果
3 liveuser 1250
					return $result;
226 liveuser 1251
 
3 liveuser 1252
					}#if end
226 liveuser 1253
 
3 liveuser 1254
				#針對每個命名空間
1255
				foreach($result["namespace"] as $ni){
226 liveuser 1256
 
3 liveuser 1257
					#如果所在行數則在該命名空間之後
1258
					if($keyNo > $ni["lineNo"]){
226 liveuser 1259
 
3 liveuser 1260
						#設置該函式所屬的命名空間名稱
1261
						$namespaceOfFunc=$ni["content"];
226 liveuser 1262
 
3 liveuser 1263
						}#if end
226 liveuser 1264
 
3 liveuser 1265
					#反之
1266
					else{
226 liveuser 1267
 
3 liveuser 1268
						#結束 foreach end
1269
						break;
226 liveuser 1270
 
3 liveuser 1271
						}#else end
226 liveuser 1272
 
3 liveuser 1273
					}#foreach end
226 liveuser 1274
 
3 liveuser 1275
				#針對每個類別名稱
1276
				foreach($result["class"] as $ci){
226 liveuser 1277
 
3 liveuser 1278
					#如果所在行數則在該類別名稱之後
1279
					if($keyNo > $ci["lineNo"]){
226 liveuser 1280
 
3 liveuser 1281
						#設置該函式所屬的類別名稱
1282
						$classOfFunc=$ci["content"];
226 liveuser 1283
 
3 liveuser 1284
						}#if end
226 liveuser 1285
 
3 liveuser 1286
					#反之
1287
					else{
226 liveuser 1288
 
3 liveuser 1289
						#結束 foreach end
1290
						break;
226 liveuser 1291
 
3 liveuser 1292
						}#else end
226 liveuser 1293
 
3 liveuser 1294
					}#foreach end
226 liveuser 1295
 
3 liveuser 1296
				#儲存函式的資訊
1297
				$result["functions"][]=array("content"=>$correctCharacter["content"],"namespace"=>$namespaceOfFunc,"class"=>$classOfFunc);
226 liveuser 1298
 
3 liveuser 1299
				}#if end
226 liveuser 1300
 
3 liveuser 1301
			}#foreach end
226 liveuser 1302
 
3 liveuser 1303
		#取得命名空間的數量
1304
		$result["namesapceCount"]=count($result["namespace"]);
226 liveuser 1305
 
3 liveuser 1306
		#如果 $result["class"] 不存在
1307
		if(!isset($result["class"])){
226 liveuser 1308
 
3 liveuser 1309
			#設置為空陣列
1310
			$result["class"]=array();
226 liveuser 1311
 
3 liveuser 1312
			}#if end
226 liveuser 1313
 
3 liveuser 1314
		#取得類別的數量
1315
		$result["classCount"]=count($result["class"]);
1316
 
1317
		#如果 $result["class"] 不存在
1318
		if(!isset($result["functions"])){
226 liveuser 1319
 
3 liveuser 1320
			#設置為空陣列
1321
			$result["functions"]=array();
226 liveuser 1322
 
3 liveuser 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
226 liveuser 1335
 
3 liveuser 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"],回傳的變數註解
226 liveuser 1350
	#$result["mustBeFilled"]["dataCount"],不可省略的參數陣列元素數量
3 liveuser 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){
226 liveuser 1374
 
3 liveuser 1375
		#初始化要回傳的內容
1376
		$result=array();
1377
 
1378
		#取得當前函數的名稱
1379
		$result["function"]=__FUNCTION__;
1380
 
1381
		#如果 $conf 不為陣列
1382
		if(gettype($conf)!="array"){
226 liveuser 1383
 
3 liveuser 1384
			#設置執行失敗
1385
			$result["status"]="false";
226 liveuser 1386
 
3 liveuser 1387
			#設置執行錯誤訊息
1388
			$result["error"][]="\$conf變數須為陣列形態";
1389
 
1390
			#如果傳入的參數為 null
1391
			if($conf==null){
226 liveuser 1392
 
3 liveuser 1393
				#設置執行錯誤訊息
1394
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
226 liveuser 1395
 
3 liveuser 1396
				}#if end
1397
 
1398
			#回傳結果
1399
			return $result;
226 liveuser 1400
 
3 liveuser 1401
			}#if end
226 liveuser 1402
 
3 liveuser 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"]);
226 liveuser 1451
 
3 liveuser 1452
		# 如果檢查出錯
1453
		if($checkArguments["status"]==="false"){
226 liveuser 1454
 
3 liveuser 1455
			#設置執行錯誤的識別
1456
			$result["status"]="false";
1457
 
1458
			#設置執行錯誤的訊息
1459
			$result["error"]=$checkArguments;
226 liveuser 1460
 
3 liveuser 1461
			#回傳結果
1462
			return $result;
226 liveuser 1463
 
3 liveuser 1464
			}#if end
226 liveuser 1465
 
3 liveuser 1466
		# 如果檢查不通過
1467
		if($checkArguments["passed"]==="false"){
226 liveuser 1468
 
3 liveuser 1469
			#設置執行錯誤的識別
1470
			$result["status"]="false";
1471
 
1472
			#設置執行錯誤的訊息
1473
			$result["error"]=$checkArguments;
226 liveuser 1474
 
3 liveuser 1475
			#回傳結果
1476
			return $result;
226 liveuser 1477
 
3 liveuser 1478
			}#if end
226 liveuser 1479
 
3 liveuser 1480
		#函數說明:
1481
		#將檔案的位置名稱變成網址,也可以取得檔案位於伺服器上檔案系統的絕對位置.
1482
		#回傳結果:
1483
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1484
		#$result["error"],錯誤訊息陣列.
226 liveuser 1485
		#$result["function"],函數名稱.
3 liveuser 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"]);
226 liveuser 1502
 
3 liveuser 1503
		#如果執行出錯
1504
		if($getInternetAddressV2["status"]==="false"){
226 liveuser 1505
 
3 liveuser 1506
			#設置執行錯誤的識別
1507
			$result["status"]="false";
1508
 
1509
			#設置執行錯誤的訊息
1510
			$result["error"]=$getInternetAddressV2;
226 liveuser 1511
 
3 liveuser 1512
			#回傳結果
1513
			return $result;
226 liveuser 1514
 
1515
			}#if end
1516
 
3 liveuser 1517
		#取得檔案的絕對位置
1518
		$conf["phpFileAddress"]=$getInternetAddressV2["fileSystemAbsoulutePosition"];
226 liveuser 1519
 
3 liveuser 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"){
226 liveuser 1539
 
3 liveuser 1540
			#設置執行錯誤的識別
1541
			$result["status"]="false";
1542
 
1543
			#設置執行錯誤的訊息
1544
			$result["error"]=$fileContent;
226 liveuser 1545
 
3 liveuser 1546
			#回傳結果
1547
			return $result;
226 liveuser 1548
 
3 liveuser 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"]);
226 liveuser 1568
 
3 liveuser 1569
		#取得可能為函式宣告的陣列元素key
226 liveuser 1570
		$maybeAfunctionDefineLine=$foundedFunctionStrArray["foundedTrueKey"];
1571
 
3 liveuser 1572
		#有抓到錯誤的函式名稱,需要剔除
1573
		#針對每個抓到的function行
1574
		foreach($foundedFunctionStrArray["foundedTrueKey"] as $maybeAfunctinKeyNo){
226 liveuser 1575
 
3 liveuser 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"]);
226 liveuser 1590
 
3 liveuser 1591
			#如果 $searchResult["founded"] 等於 "true" 則代表該行不是真的函式宣告
1592
			if($searchResult["founded"]=="true"){
226 liveuser 1593
 
3 liveuser 1594
				#涵式說明:
1595
				#將陣列中特定元素剔除
1596
				#回傳的結果:
1597
				#剔除掉特地元素的陣列
1598
				#必填參數:
1599
				$conf["arrays"]["eraseElement"]["rawInputArray"]=$maybeAfunctionDefineLine;#要處理的原始數字陣列
226 liveuser 1600
				$conf["arrays"]["eraseElement"]["eraseElementKey"]=$maybeAfunctinKeyNo;#要移除的元素key值
3 liveuser 1601
				$maybeAfunctionDefineLine=arrays::eraseElement($conf["arrays"]["eraseElement"]);
1602
				unset($conf["arrays"]["eraseElement"]);
226 liveuser 1603
 
3 liveuser 1604
				}#if end
226 liveuser 1605
 
3 liveuser 1606
			}#foreach end
226 liveuser 1607
 
3 liveuser 1608
		#更新可能為函式宣告的行key
1609
		$foundedFunctionStrArray["foundedTrueKey"]=$maybeAfunctionDefineLine;
226 liveuser 1610
 
3 liveuser 1611
		#針對每個找到"function"的行編號
1612
		foreach($foundedFunctionStrArray["foundedTrueKey"] as $index=>$keyNum){
226 liveuser 1613
 
3 liveuser 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"]);
226 liveuser 1627
			unset($conf["search"]["findManyKeyWords"]);
1628
 
3 liveuser 1629
			#如果沒有「#」關鍵字
1630
			if($searchResult["founded"]==="false"){
226 liveuser 1631
 
3 liveuser 1632
				#代表是宣告函式的行
226 liveuser 1633
 
3 liveuser 1634
				#取得函式結構結束的key(檔案內容每行的key)
1635
				$result["functionStructionEndPoint"]=$index;
226 liveuser 1636
 
3 liveuser 1637
				}#if end
226 liveuser 1638
 
3 liveuser 1639
			}#foreach end
226 liveuser 1640
 
3 liveuser 1641
		#如果找不到函數宣告的行數
1642
		if(!isset($result["functionStructionEndPoint"])){
226 liveuser 1643
 
3 liveuser 1644
			#設置執行錯誤的識別
1645
			$result["status"]="false";
1646
 
1647
			#設置執行錯誤的訊息
1648
			$result["error"]=$foundedFunctionStrArray;
226 liveuser 1649
 
3 liveuser 1650
			#回傳結果
1651
			return $result;
226 liveuser 1652
 
3 liveuser 1653
			}#if end
226 liveuser 1654
 
3 liveuser 1655
		#從 $result["functionStructionEndPoint"] 元素往前讀,直到讀到「/*」為止。
1656
		for($i=$result["functionStructionEndPoint"]-1;$i>=0;$i--){
226 liveuser 1657
 
3 liveuser 1658
			#函式說明:
1659
			#處理字串避免網頁出錯
1660
			#回傳的結果:
1661
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1662
			#$result["function"],當前執行的函數.
1663
			#$result["content"],爲處理好的字串.
1664
			#$result["error"],錯誤訊息陣列.
226 liveuser 1665
			#$result["argu"],使用的參數.
3 liveuser 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"]);
226 liveuser 1674
 
3 liveuser 1675
			#如果處理失敗
1676
			if($correctCharacter["status"]==="false"){
1677
 
1678
				#設置執行錯誤的識別
1679
				$result["status"]="false";
1680
 
1681
				#設置執行錯誤的訊息
1682
				$result["error"]=$correctCharacter;
226 liveuser 1683
 
3 liveuser 1684
				#回傳結果
1685
				return $result;
226 liveuser 1686
 
3 liveuser 1687
				}#if end
226 liveuser 1688
 
3 liveuser 1689
			#取得處理號的內容列
1690
			$temp=$correctCharacter["content"];
1691
 
1692
			#如果 $temp 為 「/*」
1693
			if($temp==="/*"){
226 liveuser 1694
 
3 liveuser 1695
				#跳出for迴圈
1696
				break;
226 liveuser 1697
 
3 liveuser 1698
				}#if end
226 liveuser 1699
 
1700
			#如果 $temp 為 「*/」
3 liveuser 1701
			if($temp==="*/"){
226 liveuser 1702
 
3 liveuser 1703
				#跳到下一輪
1704
				continue;
226 liveuser 1705
 
3 liveuser 1706
				}#if end
226 liveuser 1707
 
3 liveuser 1708
			#取得涵式宣告的內容
226 liveuser 1709
			$result["functionComment"][]=$fileContent["fileContent"][$i];
1710
 
3 liveuser 1711
			}#for end
226 liveuser 1712
 
3 liveuser 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"]);
226 liveuser 1725
 
3 liveuser 1726
		#如果轉置失敗
1727
		if($convertResult["status"]=="false"){
226 liveuser 1728
 
3 liveuser 1729
			#設置執行失敗的識別
1730
			$result["status"]="false";
226 liveuser 1731
 
3 liveuser 1732
			#設置執行失敗的提示
1733
			$result["error"]=$convertResult;
226 liveuser 1734
 
3 liveuser 1735
			#回傳結果
1736
			return $result;
226 liveuser 1737
 
1738
			}#if end
1739
 
3 liveuser 1740
		#反之代表執行成功
1741
		else{
226 liveuser 1742
 
3 liveuser 1743
			#將倒置後的元素存起來
1744
			$result["functionComment"]=$convertResult["convertArray"];
226 liveuser 1745
 
1746
			}#else
1747
 
3 liveuser 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"]);
226 liveuser 1764
 
3 liveuser 1765
		#如果 $strProcessedResult["status"]為"false"
1766
		if($strProcessedResult["status"]=="false"){
226 liveuser 1767
 
3 liveuser 1768
			#設定執行錯誤識別
1769
			$result["status"]="false";
226 liveuser 1770
 
3 liveuser 1771
			#設定執行錯誤提示
1772
			$result["error"]=$strProcessedResult;
226 liveuser 1773
 
1774
			#回傳結果
3 liveuser 1775
			return $result;
226 liveuser 1776
 
3 liveuser 1777
			}#if end
226 liveuser 1778
 
3 liveuser 1779
		#反之代表執行成功
1780
		else{
226 liveuser 1781
 
3 liveuser 1782
			$result["functionComment"]=$strProcessedResult["processedStrArray"];
226 liveuser 1783
 
3 liveuser 1784
			}#else end
226 liveuser 1785
 
1786
		#取得涵式宣告的那一行
1787
		$functionDefineLine=$fileContent["fileContent"][$result["functionStructionEndPoint"]];
1788
 
3 liveuser 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"]);
226 liveuser 1803
 
3 liveuser 1804
		#如果 $searchResult["founded"]為"true"
1805
		if($searchResult["founded"]=="true"){
226 liveuser 1806
 
3 liveuser 1807
			#代表不須要傳入參數
1808
			$result["argvType"]="";
226 liveuser 1809
 
3 liveuser 1810
			}#if end
226 liveuser 1811
 
3 liveuser 1812
		#反之代表有傳入參數
1813
		else{
226 liveuser 1814
 
3 liveuser 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"]);
226 liveuser 1827
 
3 liveuser 1828
			#如果執行失敗
1829
			if($spiltedStr["status"]==="false"){
226 liveuser 1830
 
3 liveuser 1831
				#設定執行錯誤識別
1832
				$result["status"]="false";
226 liveuser 1833
 
3 liveuser 1834
				#設定執行錯誤提示
1835
				$result["error"]=$spiltedStr;
226 liveuser 1836
 
1837
				#回傳結果
3 liveuser 1838
				return $result;
226 liveuser 1839
 
1840
				}#if end
1841
 
3 liveuser 1842
			#如果切割出來小於2段
1843
			if($spiltedStr["dataCounts"]<2){
226 liveuser 1844
 
3 liveuser 1845
				#設定執行錯誤識別
1846
				$result["status"]="false";
226 liveuser 1847
 
3 liveuser 1848
				#設定執行錯誤提示
1849
				$result["error"][]=$spiltedStr;
226 liveuser 1850
 
3 liveuser 1851
				#設定執行錯誤提示
1852
				$result["error"][]="dataCounts 應該要大於等於 2";
226 liveuser 1853
 
1854
				#回傳結果
3 liveuser 1855
				return $result;
226 liveuser 1856
 
3 liveuser 1857
				}#if end
226 liveuser 1858
 
3 liveuser 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"]);
226 liveuser 1870
			unset($conf["stringProcess"]["spiltString"]);
1871
 
3 liveuser 1872
			#取得參數內容
1873
			$argvName=$spiltedStr["dataArray"][0];
226 liveuser 1874
 
3 liveuser 1875
			#如果要傳入的參數為 "$conf"
1876
			if($argvName=="&\$conf"){
226 liveuser 1877
 
3 liveuser 1878
				#則為array型態
1879
				$result["argvType"]="array";
226 liveuser 1880
 
3 liveuser 1881
				}#if end
226 liveuser 1882
 
3 liveuser 1883
			#反之
1884
			else{
226 liveuser 1885
 
3 liveuser 1886
				#則未知型態
1887
				$result["argvType"]="unknow";
226 liveuser 1888
 
3 liveuser 1889
				}#else end
226 liveuser 1890
 
3 liveuser 1891
			}#else end
226 liveuser 1892
 
3 liveuser 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"]);
226 liveuser 1909
 
3 liveuser 1910
		#debug
1911
		#var_dump($searchResult);
226 liveuser 1912
 
3 liveuser 1913
		#如果執行失敗
1914
		if($searchResult["status"]==="false"){
226 liveuser 1915
 
3 liveuser 1916
			#設定執行錯誤識別
1917
			$result["status"]="false";
226 liveuser 1918
 
3 liveuser 1919
			#設定執行錯誤提示
1920
			$result["error"]=$searchResult;
226 liveuser 1921
 
1922
			#回傳結果
3 liveuser 1923
			return $result;
226 liveuser 1924
 
3 liveuser 1925
			}#if end
226 liveuser 1926
 
3 liveuser 1927
		#如果沒有找到
1928
		if($searchResult["founded"]==="false"){
226 liveuser 1929
 
3 liveuser 1930
			#設定執行錯誤識別
1931
			$result["status"]="false";
226 liveuser 1932
 
3 liveuser 1933
			#設定執行錯誤提示
1934
			$result["error"]=$searchResult;
226 liveuser 1935
 
1936
			#回傳結果
3 liveuser 1937
			return $result;
226 liveuser 1938
 
3 liveuser 1939
			}#if end
226 liveuser 1940
 
3 liveuser 1941
		#函式說明起始點的key
1942
		$functionCommentStartKey=$searchResult["equalVarName"];
226 liveuser 1943
 
3 liveuser 1944
		#取得涵式說明內容:
1945
		$result["comment"]=$result["functionComment"][$functionCommentStartKey+1];
226 liveuser 1946
 
3 liveuser 1947
		#卸除暫存變數
1948
		unset($functionCommentStartKey);
226 liveuser 1949
 
3 liveuser 1950
		#取得回傳結果的陣列...
1951
		#依據開頭為 $result 來判斷...
226 liveuser 1952
 
3 liveuser 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"]);
226 liveuser 1969
 
3 liveuser 1970
		#如果執行失敗
1971
		if($returnVar["status"]==="false"){
226 liveuser 1972
 
3 liveuser 1973
			#設定執行錯誤識別
1974
			$result["status"]="false";
226 liveuser 1975
 
3 liveuser 1976
			#設定執行錯誤提示
1977
			$result["error"]=$returnVar;
226 liveuser 1978
 
1979
			#回傳結果
3 liveuser 1980
			return $result;
226 liveuser 1981
 
3 liveuser 1982
			}#if end
226 liveuser 1983
 
3 liveuser 1984
		#如果有符合的關鍵字
1985
		if($returnVar["founded"]==="true"){
226 liveuser 1986
 
3 liveuser 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"]);
226 liveuser 2001
 
3 liveuser 2002
			#如果執行失敗
2003
			if($spiltedVarNameAndComment["status"]==="false"){
226 liveuser 2004
 
3 liveuser 2005
				#設定執行錯誤識別
2006
				$result["status"]="false";
226 liveuser 2007
 
3 liveuser 2008
				#設定執行錯誤提示
2009
				$result["error"]=$spiltedVarNameAndComment;
226 liveuser 2010
 
2011
				#回傳結果
3 liveuser 2012
				return $result;
226 liveuser 2013
 
3 liveuser 2014
				}
226 liveuser 2015
 
3 liveuser 2016
			#針對每行分割的回傳變數名稱
2017
			for($i=0;$i<count($spiltedVarNameAndComment["spiltString"]);$i++){
226 liveuser 2018
 
3 liveuser 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"]);
226 liveuser 2035
 
3 liveuser 2036
				#取得沒有 # 的內容
226 liveuser 2037
				$spiltedVarNameAndComment["spiltString"][$i]["dataArray"][0]=$processedStr["processedStrArray"][0];
2038
 
3 liveuser 2039
				}#for end
226 liveuser 2040
 
3 liveuser 2041
			#將回傳變數名稱與註解紀錄起來
2042
			foreach($spiltedVarNameAndComment["spiltString"] as $returnVar){
226 liveuser 2043
 
3 liveuser 2044
				#取得回傳的變數名稱
2045
				$result["return"]["name"][]=$returnVar["dataArray"][0];
226 liveuser 2046
 
3 liveuser 2047
				if(isset($returnVar["dataArray"][1])){
226 liveuser 2048
 
3 liveuser 2049
					#取得回傳的變數註解
2050
					$result["return"]["comment"][]=$returnVar["dataArray"][1];
226 liveuser 2051
 
3 liveuser 2052
					}#if end
226 liveuser 2053
 
3 liveuser 2054
				}#foreach end
226 liveuser 2055
 
3 liveuser 2056
			#依據回傳變數說明來判斷回傳的型態
226 liveuser 2057
 
3 liveuser 2058
			#如果回傳的變數名稱數量大於1
2059
			if(count($result["return"]["name"])>1){
226 liveuser 2060
 
3 liveuser 2061
				#則代表回傳的結果為array
2062
				$result["returnVarType"]="array";
226 liveuser 2063
 
3 liveuser 2064
				}#if end
226 liveuser 2065
 
3 liveuser 2066
			#反之其回傳的結果可能為string、int、float、double、boolean,目前先一律視為"string"
2067
			else{
226 liveuser 2068
 
3 liveuser 2069
				$result["returnVarType"]="string";
226 liveuser 2070
 
3 liveuser 2071
				}#else end
226 liveuser 2072
 
3 liveuser 2073
			}#if end
226 liveuser 2074
 
3 liveuser 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"]);
226 liveuser 2095
 
3 liveuser 2096
		#如果執行失敗
2097
		if($returnVar["status"]==="false"){
226 liveuser 2098
 
3 liveuser 2099
			#設定執行錯誤識別
2100
			$result["status"]="false";
226 liveuser 2101
 
3 liveuser 2102
			#設定執行錯誤提示
2103
			$result["error"]=$returnVar;
226 liveuser 2104
 
2105
			#回傳結果
3 liveuser 2106
			return $result;
226 liveuser 2107
 
3 liveuser 2108
			}#if end
2109
 
2110
		#如果有找到必填參數的列
2111
		if($returnVar["founded"]==="false")
2112
		{
2113
			#設定執行錯誤識別
2114
			$result["status"]="false";
226 liveuser 2115
 
3 liveuser 2116
			#設定執行錯誤提示
2117
			$result["error"]=$returnVar;
226 liveuser 2118
 
2119
			#回傳結果
3 liveuser 2120
			return $result;
2121
		}
2122
 
2123
		#必填變數的開始行
2124
		$mustBeFilledVarKeyStartPoint=$returnVar["foundedKey"][0];
2125
 
2126
		/*
226 liveuser 2127
		#debug
3 liveuser 2128
		var_dump($mustBeFilledVarKeyStartPoint);
2129
		var_dump($result["functionComment"]);
2130
		exit;
226 liveuser 2131
		*/
3 liveuser 2132
 
2133
		#取得可省略的參數陣列...
2134
		#依據開頭為 #可省略參數 來判斷...
226 liveuser 2135
 
3 liveuser 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"]);
226 liveuser 2153
 
3 liveuser 2154
		#如果執行失敗
2155
		if($returnVar["status"]==="false"){
226 liveuser 2156
 
3 liveuser 2157
			#設定執行錯誤識別
2158
			$result["status"]="false";
226 liveuser 2159
 
3 liveuser 2160
			#設定執行錯誤提示
2161
			$result["error"]=$returnVar;
226 liveuser 2162
 
2163
			#回傳結果
3 liveuser 2164
			return $result;
226 liveuser 2165
 
3 liveuser 2166
			}#if end
2167
 
2168
		#如果有找到必填參數的列
2169
		if($returnVar["founded"]==="false"){
2170
 
2171
			#設定執行錯誤識別
2172
			$result["status"]="false";
226 liveuser 2173
 
3 liveuser 2174
			#設定執行錯誤提示
2175
			$result["error"]=$returnVar;
226 liveuser 2176
 
2177
			#回傳結果
3 liveuser 2178
			return $result;
2179
 
2180
			}#if end
2181
 
2182
		#可省略參數的開始行
226 liveuser 2183
		$skipableVarKeyStartPoint=$returnVar["foundedKey"][0];
3 liveuser 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"]);
226 liveuser 2205
 
3 liveuser 2206
		#debug
2207
		#var_dump($getMeetConditionsStringMulti);
2208
		#exit;
2209
 
2210
		#如果執行失敗
2211
		if($getMeetConditionsStringMulti["status"]==="false"){
226 liveuser 2212
 
3 liveuser 2213
			#設定執行錯誤識別
2214
			$result["status"]="false";
226 liveuser 2215
 
3 liveuser 2216
			#設定執行錯誤提示
2217
			$result["error"]=$getMeetConditionsStringMulti;
226 liveuser 2218
 
2219
			#回傳結果
3 liveuser 2220
			return $result;
226 liveuser 2221
 
3 liveuser 2222
			}#if end
2223
 
2224
		#如果沒有找到備註的列
2225
		if($getMeetConditionsStringMulti["founded"]==="false"){
2226
 
2227
			#設定執行錯誤識別
2228
			$result["status"]="false";
226 liveuser 2229
 
3 liveuser 2230
			#設定執行錯誤提示
2231
			$result["error"]=$getMeetConditionsStringMulti;
226 liveuser 2232
 
2233
			#回傳結果
3 liveuser 2234
			return $result;
2235
 
2236
			}#if end
2237
 
2238
		#參考資料的開始行
2239
		$referenceVarKeyStartPoint=$getMeetConditionsStringMulti["foundedKey"][0];
2240
 
2241
		#取得備註陣列
2242
		#依據開頭為 #備註: 來判斷...
226 liveuser 2243
 
3 liveuser 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"]);
226 liveuser 2261
 
3 liveuser 2262
		#debug
2263
		#var_dump($getMeetConditionsStringMulti);
2264
		#exit;
2265
 
2266
		#如果執行失敗
2267
		if($getMeetConditionsStringMulti["status"]==="false"){
226 liveuser 2268
 
3 liveuser 2269
			#設定執行錯誤識別
2270
			$result["status"]="false";
226 liveuser 2271
 
3 liveuser 2272
			#設定執行錯誤提示
2273
			$result["error"]=$getMeetConditionsStringMulti;
226 liveuser 2274
 
2275
			#回傳結果
3 liveuser 2276
			return $result;
226 liveuser 2277
 
3 liveuser 2278
			}#if end
2279
 
2280
		#如果沒有找到備註的列
2281
		if($getMeetConditionsStringMulti["founded"]==="false"){
2282
 
2283
			#設定執行錯誤識別
2284
			$result["status"]="false";
226 liveuser 2285
 
3 liveuser 2286
			#設定執行錯誤提示
2287
			$result["error"]=$getMeetConditionsStringMulti;
226 liveuser 2288
 
2289
			#回傳結果
3 liveuser 2290
			return $result;
2291
 
2292
			}#if end
2293
 
2294
		#備註的開始行
2295
		$noteVarKeyStartPoint=$getMeetConditionsStringMulti["foundedKey"][0];
2296
 
2297
		#取得必填參數的內容
226 liveuser 2298
 
3 liveuser 2299
		#初始化必填參數的列
226 liveuser 2300
		$mustBeFilledVar=array();
3 liveuser 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"]);
226 liveuser 2325
 
3 liveuser 2326
			#如果執行失敗
2327
			if($returnVar["status"]==="false"){
226 liveuser 2328
 
3 liveuser 2329
				#設定執行錯誤識別
2330
				$result["status"]="false";
226 liveuser 2331
 
3 liveuser 2332
				#設定執行錯誤提示
2333
				$result["error"]=$returnVar;
226 liveuser 2334
 
2335
				#回傳結果
3 liveuser 2336
				return $result;
226 liveuser 2337
 
3 liveuser 2338
				}#if end
2339
 
2340
			#如果沒有找到必填參數的列
2341
			if($returnVar["founded"]==="false"){
2342
 
2343
				#跳到下一個迴圈
2344
				continue;
226 liveuser 2345
 
3 liveuser 2346
				}#if end
2347
 
2348
			#取得必填參數名稱與解說的列
2349
			$mustBeFilledVar[]=$returnVar["returnString"][0];
226 liveuser 2350
 
3 liveuser 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"],錯誤訊息陣列.
226 liveuser 2364
			#$result["argu"],使用的參數.
3 liveuser 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"){
226 liveuser 2379
 
3 liveuser 2380
				#設定執行錯誤識別
2381
				$result["status"]="false";
226 liveuser 2382
 
3 liveuser 2383
				#設定執行錯誤提示
2384
				$result["error"]=$correctCharacter;
226 liveuser 2385
 
2386
				#回傳結果
3 liveuser 2387
				return $result;
226 liveuser 2388
 
3 liveuser 2389
				}#if end
2390
 
226 liveuser 2391
 
3 liveuser 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"){
226 liveuser 2422
 
3 liveuser 2423
				#設定執行錯誤識別
2424
				$result["status"]="false";
226 liveuser 2425
 
3 liveuser 2426
				#設定執行錯誤提示
2427
				$result["error"]=$spiltString;
226 liveuser 2428
 
2429
				#回傳結果
3 liveuser 2430
				return $result;
226 liveuser 2431
 
3 liveuser 2432
				}#if end
2433
 
2434
			#如果執行失敗
2435
			if($spiltString["found"]==="false"){
226 liveuser 2436
 
3 liveuser 2437
				#移除之
2438
				unset($mustBeFilledVar[$key]);
2439
 
2440
				#換下一列
2441
				continue;
226 liveuser 2442
 
3 liveuser 2443
				}#if end
2444
 
2445
			#取得名稱屬性跟備註
2446
			$mustBeFilledVar[$key]=array();
2447
			$mustBeFilledVar[$key]["name"]=$spiltString["dataArray"][0];
2448
			$mustBeFilledVar[$key]["type"]=$spiltString["dataArray"][1];
226 liveuser 2449
 
3 liveuser 2450
			#如果沒有備註
2451
			if(!isset($spiltString["dataArray"][2]))
2452
			{
2453
				#設置為空字串
2454
				$spiltString["dataArray"][2]="";
226 liveuser 2455
 
3 liveuser 2456
			}#if end
226 liveuser 2457
 
3 liveuser 2458
			$mustBeFilledVar[$key]["note"]=$spiltString["dataArray"][2];
226 liveuser 2459
 
3 liveuser 2460
			#debug
2461
			if(!isset($spiltString["dataArray"][2])){
226 liveuser 2462
 
3 liveuser 2463
				#初始化結果
2464
				$result=array();
226 liveuser 2465
 
3 liveuser 2466
				#設置執行錯誤
2467
				$result["status"]="false";
226 liveuser 2468
 
3 liveuser 2469
				#設置錯誤訊息
2470
				$result["error"]=$line;
226 liveuser 2471
 
3 liveuser 2472
				#設置錯誤訊息
2473
				$result["error"][]="未按照「參數名稱,參數形態,參數說明」的格式撰寫";
226 liveuser 2474
 
3 liveuser 2475
				#回傳結果
2476
				return $result;
226 liveuser 2477
 
3 liveuser 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);
226 liveuser 2505
		var_dump($noteVarKeyStartPoint);
3 liveuser 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
226 liveuser 2531
 
3 liveuser 2532
		#置換內容
2533
		$skipableVar=$newSkipableVar;
226 liveuser 2534
 
3 liveuser 2535
		/*
2536
		#debug
2537
		var_dump($skipableVar);
2538
		exit;
2539
		*/
226 liveuser 2540
 
3 liveuser 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"],錯誤訊息陣列.
226 liveuser 2552
			#$result["argu"],使用的參數.
3 liveuser 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"){
226 liveuser 2567
 
3 liveuser 2568
				#設定執行錯誤識別
2569
				$result["status"]="false";
226 liveuser 2570
 
3 liveuser 2571
				#設定執行錯誤提示
2572
				$result["error"]=$correctCharacter;
226 liveuser 2573
 
2574
				#回傳結果
3 liveuser 2575
				return $result;
226 liveuser 2576
 
3 liveuser 2577
				}#if end
2578
 
226 liveuser 2579
 
3 liveuser 2580
			#取得剔除開頭 # 的內容列
2581
			$skipableVar[$key]=$correctCharacter["content"];
2582
 
226 liveuser 2583
			}#foreach end
3 liveuser 2584
 
2585
		#debug
2586
		#var_dump($skipableVar);
226 liveuser 2587
		#exit;
3 liveuser 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"){
226 liveuser 2614
 
3 liveuser 2615
				#設定執行錯誤識別
2616
				$result["status"]="false";
226 liveuser 2617
 
3 liveuser 2618
				#設定執行錯誤提示
2619
				$result["error"]=$spiltString;
226 liveuser 2620
 
2621
				#回傳結果
3 liveuser 2622
				return $result;
226 liveuser 2623
 
3 liveuser 2624
				}#if end
2625
 
2626
			#如果執行失敗
2627
			if($spiltString["found"]==="false"){
226 liveuser 2628
 
3 liveuser 2629
				#移除之
2630
				unset($mustBeFilledVar[$key]);
2631
 
2632
				#換下一列
2633
				continue;
226 liveuser 2634
 
3 liveuser 2635
				}#if end
2636
 
2637
			#如果缺乏參數名稱位或屬性
2638
			if(!isset($spiltString["dataArray"][0]) || !isset($spiltString["dataArray"][1])){
226 liveuser 2639
 
3 liveuser 2640
				#設定執行錯誤識別
2641
				$result["status"]="false";
226 liveuser 2642
 
3 liveuser 2643
				#設定執行錯誤提示
2644
				$result["error"]=$spiltString;
226 liveuser 2645
 
2646
				#回傳結果
3 liveuser 2647
				return $result;
226 liveuser 2648
 
3 liveuser 2649
				}#if end
2650
 
2651
			#取得名稱屬性跟備註
2652
			$skipableVar[$key]=array();
2653
			$skipableVar[$key]["name"]=$spiltString["dataArray"][0];
2654
			$skipableVar[$key]["type"]=$spiltString["dataArray"][1];
226 liveuser 2655
 
3 liveuser 2656
			#如果沒有備註
2657
			if(!isset($spiltString["dataArray"][2]))
2658
			{
2659
				#設置為空字串.
2660
				$spiltString["dataArray"][2]="";
2661
			}
226 liveuser 2662
 
3 liveuser 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);
226 liveuser 2677
		#exit;
3 liveuser 2678
 
2679
		#取得可省略參數的內容
2680
		$result["skipableVar"]=$skipableVar;
226 liveuser 2681
 
3 liveuser 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"],錯誤訊息陣列.
226 liveuser 2704
			#$result["argu"],使用的參數.
3 liveuser 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"){
226 liveuser 2719
 
3 liveuser 2720
				#設定執行錯誤識別
2721
				$result["status"]="false";
226 liveuser 2722
 
3 liveuser 2723
				#設定執行錯誤提示
2724
				$result["error"]=$correctCharacter;
226 liveuser 2725
 
2726
				#回傳結果
3 liveuser 2727
				return $result;
226 liveuser 2728
 
3 liveuser 2729
				}#if end
2730
 
226 liveuser 2731
 
3 liveuser 2732
			#取得剔除開頭 # 的內容列
2733
			$reference[$key]=$correctCharacter["content"];
2734
 
226 liveuser 2735
			}#foreach end
3 liveuser 2736
 
2737
		#取得備註的內容
2738
		$result["reference"]=$reference;
226 liveuser 2739
 
3 liveuser 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"]);
226 liveuser 2774
 
3 liveuser 2775
		#如果執行失敗
2776
		if($arrayToString["status"]==="false"){
226 liveuser 2777
 
3 liveuser 2778
			#設定執行錯誤識別
2779
			$result["status"]="false";
226 liveuser 2780
 
3 liveuser 2781
			#設定執行錯誤提示
2782
			$result["error"]=$arrayToString;
226 liveuser 2783
 
2784
			#回傳結果
3 liveuser 2785
			return $result;
226 liveuser 2786
 
3 liveuser 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"],錯誤訊息陣列.
226 liveuser 2803
			#$result["argu"],使用的參數.
3 liveuser 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"){
226 liveuser 2818
 
3 liveuser 2819
				#設定執行錯誤識別
2820
				$result["status"]="false";
226 liveuser 2821
 
3 liveuser 2822
				#設定執行錯誤提示
2823
				$result["error"]=$correctCharacter;
226 liveuser 2824
 
2825
				#回傳結果
3 liveuser 2826
				return $result;
226 liveuser 2827
 
3 liveuser 2828
				}#if end
2829
 
226 liveuser 2830
 
3 liveuser 2831
			#取得剔除開頭 # 的內容列
2832
			$note[$key]=$correctCharacter["content"];
2833
 
226 liveuser 2834
			}#foreach end
3 liveuser 2835
 
2836
		#取得備註的內容
2837
		$result["note"]=$note;
2838
 
2839
		#初始化函式的程式內容.
2840
		$result["content"]="";
226 liveuser 2841
 
3 liveuser 2842
		#針對函式的定義開始行,往後逐行執行.
2843
		for($i=$result["functionStructionEndPoint"];$i<$fileContent["lineCount"];$i++){
226 liveuser 2844
 
3 liveuser 2845
			#暫存該行程式的內容
2846
			$line=$fileContent["fileContent"][$i];
226 liveuser 2847
 
3 liveuser 2848
			#如果無任何內容
2849
			if(empty($line)){
226 liveuser 2850
 
3 liveuser 2851
				#串接程式的內容
2852
				$result["content"]=$result["content"].$line;
226 liveuser 2853
 
3 liveuser 2854
				#換下一行
2855
				continue;
226 liveuser 2856
 
3 liveuser 2857
				}#if end
226 liveuser 2858
 
3 liveuser 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"]);
226 liveuser 2883
 
3 liveuser 2884
			#如果處理失敗
2885
			if($getMeetConditionsString["status"]==="false"){
2886
 
2887
				#設置執行錯誤的識別
2888
				$result["status"]="false";
2889
 
2890
				#設置執行錯誤的訊息
2891
				$result["error"]=$getMeetConditionsString;
226 liveuser 2892
 
3 liveuser 2893
				#回傳結果
2894
				return $result;
226 liveuser 2895
 
3 liveuser 2896
				}#if end
226 liveuser 2897
 
3 liveuser 2898
			#串接程式的內容
2899
			$result["content"]=$result["content"].$line;
226 liveuser 2900
 
3 liveuser 2901
			#如果找到函式的結尾
2902
			if($getMeetConditionsString["founded"]==="true"){
2903
 
2904
				#跳出迴圈
2905
				break;
226 liveuser 2906
 
3 liveuser 2907
				}#if end
226 liveuser 2908
 
3 liveuser 2909
			}#for end
226 liveuser 2910
 
3 liveuser 2911
		#值行到這邊執行成功
2912
		$result["status"]="true";
2913
 
2914
		#回傳節果
2915
		return $result;
226 liveuser 2916
 
3 liveuser 2917
		}#function getFunctionConstruction end
226 liveuser 2918
 
3 liveuser 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個函式回傳變數註解的陣列
226 liveuser 2931
	#$result["mustBeFilled"]["dataCount"][$j],第j+1個函式不可省略參數數量的陣列
3 liveuser 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){
226 liveuser 2954
 
3 liveuser 2955
		#初始化要回傳的內容
2956
		$result=array();
2957
 
2958
		#取得當前函數的名稱
2959
		$result["function"]=__FUNCTION__;
2960
 
2961
		#如果 $conf 不為陣列
2962
		if(gettype($conf)!="array"){
226 liveuser 2963
 
3 liveuser 2964
			#設置執行失敗
2965
			$result["status"]="false";
226 liveuser 2966
 
3 liveuser 2967
			#設置執行錯誤訊息
2968
			$result["error"][]="\$conf變數須為陣列形態";
2969
 
2970
			#如果傳入的參數為 null
2971
			if($conf==null){
226 liveuser 2972
 
3 liveuser 2973
				#設置執行錯誤訊息
2974
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
226 liveuser 2975
 
3 liveuser 2976
				}#if end
2977
 
2978
			#回傳結果
2979
			return $result;
226 liveuser 2980
 
3 liveuser 2981
			}#if end
226 liveuser 2982
 
3 liveuser 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
		#可以省略的參數:
226 liveuser 2994
		$conf["variableCheck"]["isexistMuti"]["variableType"]=array("string","array","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double");
3 liveuser 2995
		$conf["variableCheck"]["isexistMuti"]["canBeEmptyString"]="true";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
2996
		$checkResult=variableCheck::isexistMulti($conf["variableCheck"]["isexistMuti"]);
2997
		unset($conf["variableCheck"]["isexistMuti"]);
226 liveuser 2998
 
3 liveuser 2999
		# 如果 $checkResult["status"] 為 "fasle"
3000
		if($checkResult["status"]=="false"){
226 liveuser 3001
 
3 liveuser 3002
			#設置執行錯誤的識別
3003
			$result["status"]="false";
3004
 
3005
			#設置執行錯誤的訊息
3006
			$result["error"]=$checkResult;
226 liveuser 3007
 
3 liveuser 3008
			#回傳結果
3009
			return $result;
226 liveuser 3010
 
3 liveuser 3011
			}#if end
226 liveuser 3012
 
3 liveuser 3013
		# 如果 $checkResult["passed"] 為 "fasle"
3014
		if($checkResult["passed"]=="false"){
226 liveuser 3015
 
3 liveuser 3016
			#設置執行錯誤的識別
3017
			$result["status"]="false";
3018
 
3019
			#設置執行錯誤的訊息
3020
			$result["error"]=$checkResult;
226 liveuser 3021
 
3 liveuser 3022
			#回傳結果
3023
			return $result;
226 liveuser 3024
 
3 liveuser 3025
			}#if end
226 liveuser 3026
 
3 liveuser 3027
		#針對每個要解析的函式
3028
		foreach($conf["functionName"] as $functionName){
226 liveuser 3029
 
3 liveuser 3030
			#debug
3031
			#var_dump($functionName);
226 liveuser 3032
 
3 liveuser 3033
			#如果涵式名稱是 "empty"
3034
			if($functionName==="empty"){
226 liveuser 3035
 
3 liveuser 3036
				#跳過
3037
				continue;
226 liveuser 3038
 
3 liveuser 3039
				}#if end
226 liveuser 3040
 
3 liveuser 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"],回傳的變數註解
226 liveuser 3051
			#$result["mustBeFilled"]["dataCount"],不可省略的參數陣列元素數量
3 liveuser 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"]);
226 liveuser 3067
 
3 liveuser 3068
			#如果執行失敗
3069
			if($functionConstruction["status"]==="false"){
226 liveuser 3070
 
3 liveuser 3071
				#設置執行錯誤的識別
3072
				$result["status"]="false";
3073
 
3074
				#設置執行錯誤的訊息
3075
				$result["error"]=$functionConstruction;
226 liveuser 3076
 
3 liveuser 3077
				#回傳結果
3078
				return $result;
226 liveuser 3079
 
3 liveuser 3080
				}#if end
226 liveuser 3081
 
3 liveuser 3082
			#debug
3083
			#var_dump($functionConstruction);
3084
			#exit;
226 liveuser 3085
 
3 liveuser 3086
			#取得函式說明
3087
			$result["comment"][]=$functionConstruction["comment"];
226 liveuser 3088
 
3 liveuser 3089
			#取得函式傳入參數型態
3090
			$result["argvType"][]=$functionConstruction["argvType"];
226 liveuser 3091
 
3 liveuser 3092
			#取得函式回傳變數型態
3093
			$result["returnVarType"][]=$functionConstruction["returnVarType"];
226 liveuser 3094
 
3 liveuser 3095
			#取得函式回傳變數名稱陣列
3096
			$result["return"]["name"][]=$functionConstruction["return"]["name"];
226 liveuser 3097
 
3 liveuser 3098
			#取得函式回傳變數註解陣列
3099
			$result["return"]["comment"][]=$functionConstruction["return"]["comment"];
226 liveuser 3100
 
3101
			}#foreach end
3102
 
3 liveuser 3103
		#執行到這邊代表執行成功
226 liveuser 3104
 
3 liveuser 3105
		#設置執行成功的識別
3106
		$result["status"]="true";
226 liveuser 3107
 
3 liveuser 3108
		#回傳結果
3109
		return $result;
226 liveuser 3110
 
3 liveuser 3111
		}#function getMutiFunctionConstruction end
226 liveuser 3112
 
3 liveuser 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){
226 liveuser 3135
 
3 liveuser 3136
		#初始化要回傳的內容
3137
		$result=array();
3138
 
3139
		#取得當前函數的名稱
3140
		$result["function"]=__FUNCTION__;
3141
 
3142
		#如果 $conf 不為陣列
3143
		if(gettype($conf)!="array"){
226 liveuser 3144
 
3 liveuser 3145
			#設置執行失敗
3146
			$result["status"]="false";
226 liveuser 3147
 
3 liveuser 3148
			#設置執行錯誤訊息
3149
			$result["error"][]="\$conf變數須為陣列形態";
3150
 
3151
			#如果傳入的參數為 null
3152
			if($conf==null){
226 liveuser 3153
 
3 liveuser 3154
				#設置執行錯誤訊息
3155
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
226 liveuser 3156
 
3 liveuser 3157
				}#if end
3158
 
3159
			#回傳結果
3160
			return $result;
226 liveuser 3161
 
3 liveuser 3162
			}#if end
226 liveuser 3163
 
3 liveuser 3164
		#初始化要暫存的函式結構陣列
3165
		$functionConstruction=array();
226 liveuser 3166
 
3 liveuser 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
		#可以省略的參數:
226 liveuser 3179
		$conf["variableCheck"]["isexistMuti"]["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double");
3 liveuser 3180
		$conf["variableCheck"]["isexistMuti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
3181
		$checkResult=variableCheck::isexistMulti($conf["variableCheck"]["isexistMuti"]);
3182
		unset($conf["variableCheck"]["isexistMuti"]);
226 liveuser 3183
 
3 liveuser 3184
		#如果 $checkResult["status"] 為 "fasle"
3185
		if($checkResult["status"]==="false"){
226 liveuser 3186
 
3 liveuser 3187
			#設置執行錯誤的識別
3188
			$result["status"]="false";
3189
 
3190
			#設置執行錯誤的訊息
3191
			$result["error"]=$checkResult;
226 liveuser 3192
 
3 liveuser 3193
			#回傳結果
3194
			return $result;
226 liveuser 3195
 
3 liveuser 3196
			}#if end
226 liveuser 3197
 
3 liveuser 3198
		#如果 $checkResult["passed"] 為 "fasle"
3199
		if($checkResult["passed"]==="false"){
226 liveuser 3200
 
3 liveuser 3201
			#設置執行錯誤的識別
3202
			$result["status"]="false";
3203
 
3204
			#設置執行錯誤的訊息
3205
			$result["error"]=$checkResult;
226 liveuser 3206
 
3 liveuser 3207
			#回傳結果
3208
			return $result;
226 liveuser 3209
 
3 liveuser 3210
			}#if end
226 liveuser 3211
 
3 liveuser 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"]);
226 liveuser 3225
 
3 liveuser 3226
		#如果執行失敗
3227
		if($delayRunTimeExectionMax["status"]==="false"){
226 liveuser 3228
 
3 liveuser 3229
			#設定類別圖繪製失敗
226 liveuser 3230
			$result["status"]="false";
3231
 
3 liveuser 3232
			#設定該檔案的類別圖繪製失敗提示
3233
			$result["error"]=$delayRunTimeExectionMax;
226 liveuser 3234
 
3 liveuser 3235
			#回傳結果
3236
			return $result;
226 liveuser 3237
 
3238
			}#if end
3239
 
3 liveuser 3240
		#函式說明:
3241
		#取得php函式庫檔案裡面的結構
3242
		#回傳的結果:
3243
		#$result["status"],0表示取得成功;1表示取得失敗
3244
		#$result["namesapceCount"],命名空間的筆數
3245
		#$result["classCount"],類別的筆數
3246
		#$result["functionCount"],函式的筆數
226 liveuser 3247
		#$result["namespace"],命名空間陣列
3 liveuser 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"]);
226 liveuser 3255
 
3 liveuser 3256
		#如果 $classConstruction["status"] 為 "fasle"
3257
		if($classConstruction["status"]==="false"){
226 liveuser 3258
 
3 liveuser 3259
			#設置執行錯誤的識別
3260
			$result["status"]="false";
3261
 
3262
			#設置執行錯誤的訊息
3263
			$result["error"]=$classConstruction;
226 liveuser 3264
 
3 liveuser 3265
			#回傳結果
3266
			return $result;
226 liveuser 3267
 
3268
			}#if end
3269
 
3 liveuser 3270
		#如果裡面沒有函式
3271
		if($classConstruction["functionCount"]===0){
226 liveuser 3272
 
3 liveuser 3273
			#設置只有一個叫做emtpy的函數
3274
			$classConstruction["functions"][]["content"]="empty";
226 liveuser 3275
 
3 liveuser 3276
			}#if end
226 liveuser 3277
 
3 liveuser 3278
		#初始化記錄所有函數名稱
3279
		$funcs=array();
226 liveuser 3280
 
3 liveuser 3281
		#針對每個既有的函數名稱
3282
		foreach($classConstruction["functions"] as $funcStr){
226 liveuser 3283
 
3 liveuser 3284
			#記錄函數名稱
3285
			$funcs[]=$funcStr["content"];
226 liveuser 3286
 
3287
			}#foreach end
3288
 
3 liveuser 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個函式回傳變數註解的陣列
226 liveuser 3300
		#$result["mustBeFilled"]["dataCount"][$j],第j+1個函式不可省略參數數量的陣列
3 liveuser 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"]);
226 liveuser 3314
 
3 liveuser 3315
		#如果 $classConstruction["status"] 為 "fasle"
3316
		if($functionConstruction["status"]==="false"){
226 liveuser 3317
 
3 liveuser 3318
			#設置執行錯誤的識別
3319
			$result["status"]="false";
3320
 
3321
			#設置執行錯誤的訊息
3322
			$result["error"]=$functionConstruction;
226 liveuser 3323
 
3 liveuser 3324
			#回傳結果
3325
			return $result;
226 liveuser 3326
 
3327
			}#if end
3328
 
3 liveuser 3329
		#debug
226 liveuser 3330
		#var_dump($functionConstruction);
3331
 
3 liveuser 3332
		#由於每個函式都沒有指定屬性,所以都為public的函式
226 liveuser 3333
 
3 liveuser 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"]);
226 liveuser 3345
 
3 liveuser 3346
		#var_dump($functionTypeArray);
3347
		#var_dump($classConstruction["class"][0]);
3348
		#exit;
226 liveuser 3349
 
3 liveuser 3350
		#如果不存在 $classConstruction["class"][0]
3351
		if(!isset($classConstruction["class"][0])){
226 liveuser 3352
 
3 liveuser 3353
			#設置為 "empty"
3354
			$classConstruction["class"][0]["content"]="empty";
226 liveuser 3355
 
3 liveuser 3356
			}#if end
226 liveuser 3357
 
3 liveuser 3358
		#如果不存在 $functionConstruction["argvType"]
3359
		if(!isset($functionConstruction["argvType"])){
226 liveuser 3360
 
3 liveuser 3361
			#設置為 "array"
3362
			$functionConstruction["argvType"][0]="array";
226 liveuser 3363
 
3 liveuser 3364
			}#if end
3365
 
3366
		#如果不存在 $functionConstruction["returnVarType"]
3367
		if(!isset($functionConstruction["returnVarType"])){
226 liveuser 3368
 
3 liveuser 3369
			#設置為 "array"
3370
			$functionConstruction["returnVarType"][0]="array";
226 liveuser 3371
 
3 liveuser 3372
			}#if end
226 liveuser 3373
 
3 liveuser 3374
		#var_dump($classConstruction["functions"]);
3375
		#exit;
226 liveuser 3376
 
3 liveuser 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"]);
226 liveuser 3392
 
3 liveuser 3393
		#如果類別圖表格建立失敗
3394
		if($createClassDiagramTableResult["status"]==="false"){
3395
 
3396
			#設置執行錯誤的識別
3397
			$result["status"]="false";
226 liveuser 3398
 
3 liveuser 3399
			#設置錯誤訊息提示
3400
			$result["error"]=$createClassDiagramTableResult["error"];
226 liveuser 3401
 
3 liveuser 3402
			#回傳結果
3403
			return $result;
226 liveuser 3404
 
3 liveuser 3405
			}#if end
226 liveuser 3406
 
3407
		#取得類別圖的html內容
3 liveuser 3408
		$result["diagramCode"]=$createClassDiagramTableResult["classDiagramTable"];
226 liveuser 3409
 
3 liveuser 3410
		#執行到這邊代表執行成功
3411
		$result["status"]="true";
226 liveuser 3412
 
3413
		#回傳結果
3 liveuser 3414
		return $result;
226 liveuser 3415
 
3 liveuser 3416
		}#function classDiagramMaker end
226 liveuser 3417
 
3 liveuser 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){
226 liveuser 3439
 
3 liveuser 3440
		#初始化要回傳的內容
3441
		$result=array();
3442
 
3443
		#取得當前函數的名稱
3444
		$result["function"]=__FUNCTION__;
3445
 
3446
		#如果 $conf 不為陣列
3447
		if(gettype($conf)!="array"){
226 liveuser 3448
 
3 liveuser 3449
			#設置執行失敗
3450
			$result["status"]="false";
226 liveuser 3451
 
3 liveuser 3452
			#設置執行錯誤訊息
3453
			$result["error"][]="\$conf變數須為陣列形態";
3454
 
3455
			#如果傳入的參數為 null
3456
			if($conf==null){
226 liveuser 3457
 
3 liveuser 3458
				#設置執行錯誤訊息
3459
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
226 liveuser 3460
 
3 liveuser 3461
				}#if end
3462
 
3463
			#回傳結果
3464
			return $result;
226 liveuser 3465
 
3 liveuser 3466
			}#if end
226 liveuser 3467
 
3 liveuser 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
		#可以省略的參數:
226 liveuser 3480
		$conf["variableType"]=array("string","string");#要檢查的陣列變數內的元素應該爲何種變數形態,形態爲陣列 例如: $conf[variableType] = array("string","int","double");
3 liveuser 3481
		$conf["variableCheck"]["isexistMuti"]["canBeEmptyString"]="false";#變數內容如果是空字串就不能算是有設置的話,請設為"false",預設為也算是有設置。
3482
		$checkResult=variableCheck::isexistMulti($conf["variableCheck"]["isexistMuti"]);
3483
		unset($conf["variableCheck"]["isexistMuti"]);
226 liveuser 3484
 
3 liveuser 3485
		#如果 $checkResult["status"] 為 "fasle"
3486
		if($checkResult["status"]=="false"){
226 liveuser 3487
 
3 liveuser 3488
			#設置執行錯誤的識別
3489
			$result["status"]="false";
3490
 
3491
			#設置執行錯誤的訊息
3492
			$result["error"]=$checkResult;
226 liveuser 3493
 
3 liveuser 3494
			#回傳結果
3495
			return $result;
226 liveuser 3496
 
3 liveuser 3497
			}#if end
226 liveuser 3498
 
3 liveuser 3499
		#如果 $checkResult["passed"] 為 "fasle"
3500
		if($checkResult["passed"]=="false"){
226 liveuser 3501
 
3 liveuser 3502
			#設置執行錯誤的識別
3503
			$result["status"]="false";
3504
 
3505
			#設置執行錯誤的訊息
3506
			$result["error"]=$checkResult;
226 liveuser 3507
 
3 liveuser 3508
			#回傳結果
3509
			return $result;
226 liveuser 3510
 
3 liveuser 3511
			}#if end
226 liveuser 3512
 
3 liveuser 3513
		#取得目標目錄底下的php檔案
3514
		#函式說明:
3515
		#取得目錄底下函式庫檔案清單
3516
		#回傳的結果:
3517
		#$result["status"],0表示有清單;1表示沒有清單
3518
		#$result["dataCount"],有幾筆符合的資料
226 liveuser 3519
		#$result["neededList"],符合條件的檔案清單
3 liveuser 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"]);
226 liveuser 3530
 
3 liveuser 3531
		#debug
3532
		#var_dump($phpLib_getLibFileList);
3533
		#exit;
226 liveuser 3534
 
3 liveuser 3535
		#如果執行失敗
3536
		if($phpLib_getLibFileList["status"]==="false"){
226 liveuser 3537
 
3 liveuser 3538
			#設定執行失敗
3539
			$result["status"]="false";
226 liveuser 3540
 
3 liveuser 3541
			#設置錯誤訊息
3542
			$result["error"]="目標目錄下沒有任何php檔案";
226 liveuser 3543
 
3 liveuser 3544
			#回傳結果
3545
			return $result;
226 liveuser 3546
 
3 liveuser 3547
			}#if end
226 liveuser 3548
 
3 liveuser 3549
		#如果 $phpLib_getLibFileList["dataCount"] 等於 0,則代表目標目錄底下沒有php檔案。
3550
		if($phpLib_getLibFileList["dataCount"]===0){
226 liveuser 3551
 
3 liveuser 3552
			#設定執行失敗
3553
			$result["status"]="false";
226 liveuser 3554
 
3 liveuser 3555
			#設置錯誤訊息
3556
			$result["error"]="目標目錄下沒有任何php檔案";
226 liveuser 3557
 
3 liveuser 3558
			#回傳結果
3559
			return $result;
226 liveuser 3560
 
3 liveuser 3561
			}#if end
226 liveuser 3562
 
3 liveuser 3563
		#var_dump($phpLib_getLibFileList);
226 liveuser 3564
 
3 liveuser 3565
		#根據每個php檔案
3566
		for($i=0;$i<$phpLib_getLibFileList["dataCount"];$i++){
226 liveuser 3567
 
3 liveuser 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"]);
226 liveuser 3580
 
3 liveuser 3581
			#如果該檔案的類別圖取得失敗
3582
			if($classDiagram["diagramCode"][$i]["status"]=="false"){
226 liveuser 3583
 
3 liveuser 3584
				#設定類別圖繪製失敗
3585
				$result["status"]="false";
226 liveuser 3586
 
3 liveuser 3587
				#設定錯誤訊息
3588
				$result["error"]=$classDiagram;
226 liveuser 3589
 
3 liveuser 3590
				#設定該檔案的類別圖繪製失敗提示
3591
				$result["error"][]="無法正確取得".$phpLib_getLibFileList["neededList"][$i]."檔案裡面的類別結構或該檔案非類別檔案";
226 liveuser 3592
 
3 liveuser 3593
				#回傳結果
3594
				return $result;
226 liveuser 3595
 
3 liveuser 3596
				}#if end
226 liveuser 3597
 
3 liveuser 3598
			#取得類別圖表格htmlCode
226 liveuser 3599
			$result["diagramCode"][]=$classDiagram["diagramCode"][$i]["diagramCode"];
3600
 
3 liveuser 3601
			}#for end
226 liveuser 3602
 
3 liveuser 3603
		#執行到這邊代表執行成功
3604
		$result["status"]="true";
226 liveuser 3605
 
3 liveuser 3606
		#回傳結果
226 liveuser 3607
		return $result;
3608
 
3 liveuser 3609
		}#function classDiagramsMaker end
226 liveuser 3610
 
3 liveuser 3611
	/*
3612
	#函式說明:
220 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/*");
316 liveuser 3643
	#$conf["excludeSecondName"],陣列,哪些附檔名的檔案要忽略,預設有"log"、"csv"、"sql"、"js"、"css"、"html"、"key"、"crt"、"pem".
3 liveuser 3644
	#$conf["excludeSecondName"]=array("log"、,"csv","sql","js","css","html");
230 liveuser 3645
	#$conf["multiThread"],字串,是否要啟用多執行序,預設為"false",反之為"true",目前尚未支援.
3 liveuser 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"]="";
220 liveuser 3653
	#$conf["outputPath"],字串,更新後的檔案內容要存放到哪個路徑低下,預設為 /tmp 底下.
3654
	#$conf["outputPath"]="";
3 liveuser 3655
	#參考資料:
3656
	#無.
3657
	#備註:
230 liveuser 3658
	#目前尚未支援參數 multiThread 為 true 的設置.
3 liveuser 3659
	*/
3660
	public static function updateCopyRightYear(&$conf){
226 liveuser 3661
 
3 liveuser 3662
		#初始化要回傳的結果
3663
		$result=array();
3664
 
3665
		#取得當前執行的函數名稱
3666
		$result["function"]=__FUNCTION__;
3667
 
3668
		#如果沒有參數
3669
		if(func_num_args()==0){
3670
 
3671
			#設置執行失敗
3672
			$result["status"]="false";
3673
 
3674
			#設置執行錯誤訊息
3675
			$result["error"]="函數".$result["function"]."需要參數";
3676
 
3677
			#回傳結果
3678
			return $result;
3679
 
3680
			}#if end
3681
 
3682
		#取得參數
3683
		$result["argu"]=$conf;
226 liveuser 3684
 
218 liveuser 3685
		#debug,break point.
3686
		#var_dump(__LINE__,$result);exit(1);
3 liveuser 3687
 
3688
		#如果 $conf 不為陣列
3689
		if(gettype($conf)!=="array"){
3690
 
3691
			#設置執行失敗
3692
			$result["status"]="false";
3693
 
3694
			#設置執行錯誤訊息
3695
			$result["error"][]="\$conf變數須為陣列形態";
3696
 
3697
			#如果傳入的參數為 null
3698
			if(is_null($conf)){
3699
 
3700
				#設置執行錯誤訊息
3701
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3702
 
3703
				}#if end
3704
 
3705
			#回傳結果
3706
			return $result;
3707
 
3708
			}#if end
226 liveuser 3709
 
220 liveuser 3710
		#設置要取代的內容關鍵字陣列 - start
226 liveuser 3711
 
220 liveuser 3712
		$replaceFromArray=array();
226 liveuser 3713
 
220 liveuser 3714
		$replaceFromArray[]="        QBPWCF, Quick Build PHP website Component base on Fedora Linux.";
226 liveuser 3715
 
220 liveuser 3716
		$replaceFromArray[]="    Copyright (C) \${yearFrom}~\${yearTo} \${Authors}";
226 liveuser 3717
 
220 liveuser 3718
		$replaceFromArray[]="";
226 liveuser 3719
 
220 liveuser 3720
		$replaceFromArray[]="    This file is part of QBPWCF.";
226 liveuser 3721
 
220 liveuser 3722
		$replaceFromArray[]="";
226 liveuser 3723
 
220 liveuser 3724
		$replaceFromArray[]="    QBPWCF is free software: you can redistribute it and/or modify";
226 liveuser 3725
 
220 liveuser 3726
		$replaceFromArray[]="    it under the terms of the GNU General Public License as published by";
226 liveuser 3727
 
220 liveuser 3728
		$replaceFromArray[]="    the Free Software Foundation, either version 3 of the License, or";
226 liveuser 3729
 
220 liveuser 3730
		$replaceFromArray[]="    (at your option) any later version.";
3731
 
3732
		$replaceFromArray[]="";
226 liveuser 3733
 
220 liveuser 3734
		$replaceFromArray[]="    QBPWCF is distributed in the hope that it will be useful,";
226 liveuser 3735
 
220 liveuser 3736
		$replaceFromArray[]="    but WITHOUT ANY WARRANTY; without even the implied warranty of";
226 liveuser 3737
 
220 liveuser 3738
		$replaceFromArray[]="    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the";
3739
 
3740
		$replaceFromArray[]="    GNU General Public License for more details.";
226 liveuser 3741
 
220 liveuser 3742
		$replaceFromArray[]="";
226 liveuser 3743
 
220 liveuser 3744
		$replaceFromArray[]="    You should have received a copy of the GNU General Public License";
226 liveuser 3745
 
220 liveuser 3746
		$replaceFromArray[]="    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.";
226 liveuser 3747
 
220 liveuser 3748
		#設置要取代的內容關鍵字陣列 - end
226 liveuser 3749
 
3 liveuser 3750
		#函式說明:
3751
		#取得檔案路徑字串的路徑與檔案的名稱與檔案副檔名
3752
		#回傳的結果:
3753
		#$result["status"],執行是否正常,"true"正常,"false"代表不正常.
3754
		#$result["error"],錯誤訊息.
3755
		#$result["function"],當前執行的函式名稱.
3756
		#$result["filePath"],路徑字串.
3757
		#$result["fileName"],檔案名稱字串.
3758
		#$result["fileExtention"],檔案的副檔名.
3759
		#$result["fullFileName"],含副檔名的檔案名稱.
3760
		#$result["fullFilePathAndName"],完整的檔案路徑(含副檔名).
3761
		#必填參數:
3762
		#$conf["fileAddressAndName"],字串,檔案名稱與其路徑.
3763
		$conf["fileAccess::getFileAddressAndNameAndFileExtention"]["fileAddressAndName"]=__FILE__;
3764
		#可省略參數:
3765
		#無.
3766
		#參考資料:
3767
		#無.
3768
		#備註:
3769
		#無.
3770
		$getFileAddressAndNameAndFileExtention=fileAccess::getFileAddressAndNameAndFileExtention($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
3771
		unset($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
226 liveuser 3772
 
3 liveuser 3773
		#如果執行失敗
3774
		if($getFileAddressAndNameAndFileExtention["status"]==="false"){
226 liveuser 3775
 
3 liveuser 3776
			#設置錯誤識別
3777
			$result["status"]="false";
226 liveuser 3778
 
3 liveuser 3779
			#設置錯誤訊息
3780
			$result["error"]=$getFileAddressAndNameAndFileExtention;
226 liveuser 3781
 
3 liveuser 3782
			#回傳結果
3783
			return $result;
226 liveuser 3784
 
3 liveuser 3785
			}#if end
226 liveuser 3786
 
3 liveuser 3787
		#取得當前使用套件的路徑
218 liveuser 3788
		$libPath=$getFileAddressAndNameAndFileExtention["filePath"]."../../../";
226 liveuser 3789
 
218 liveuser 3790
		#debug,break point.
3791
		#var_dump(__LINE__,$libPath);exit(1);
226 liveuser 3792
 
3 liveuser 3793
		#函式說明:
3794
		#將檔案目錄的絕對位置中的 "../" 剔除變成直觀的路徑.
3795
		#回傳結果:
3796
		#$result["status"],執行是否成功,"true"代表執行成功,"false"代表執行失敗.
3797
		#$result["function"],當前執行的函數.
3798
		#$result["error"],錯誤訊息陣列.
3799
		#$result["argu"],使用者參數.
3800
		#$result["changedPath"],處理完後回傳的目錄字串.
3801
		#$result["oriPath"],原始的路徑字串
3802
		#必填參數:
3803
		#$conf["dirStr"],字串,要處理的檔案目錄字串.
3804
		$conf["stringProcess::changeDirByDotDotSolidus"]["dirStr"]=$libPath;
3805
		#可省略參數:
3806
		#無.
3807
		#參考資料:
3808
		#無.
3809
		#備註:
3810
		#考慮用realpath取代
3811
		$changeDirByDotDotSolidus=stringProcess::changeDirByDotDotSolidus($conf["stringProcess::changeDirByDotDotSolidus"]);
3812
		unset($conf["stringProcess::changeDirByDotDotSolidus"]);
226 liveuser 3813
 
3 liveuser 3814
		#如果執行失敗
3815
		if($changeDirByDotDotSolidus["status"]==="false"){
226 liveuser 3816
 
3 liveuser 3817
			#設置錯誤識別
3818
			$result["status"]="false";
226 liveuser 3819
 
3 liveuser 3820
			#設置錯誤訊息
3821
			$result["error"]=$changeDirByDotDotSolidus;
226 liveuser 3822
 
3 liveuser 3823
			#回傳結果
3824
			return $result;
226 liveuser 3825
 
3 liveuser 3826
			}#if end
226 liveuser 3827
 
3 liveuser 3828
		#取得直觀的絕對路徑
220 liveuser 3829
		$libRootPath=$changeDirByDotDotSolidus["changedPath"];
226 liveuser 3830
 
220 liveuser 3831
		#取得 lib folder
3832
		exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../bin/libexec/folderOfUsrLib.php"),$output,$status);
3 liveuser 3833
 
220 liveuser 3834
		#如果執行失敗
3835
		if($status!==0){
3836
 
3837
			#debug
3838
			var_dump(__LINE__,$output);
3839
 
3840
			#結束執行,回傳shell 1.
3841
			exit(1);
3842
 
3843
			}#if end
3844
 
3845
		#儲存 lib folder
3846
		$folderOfUsrLib=$output[0];
226 liveuser 3847
 
220 liveuser 3848
		#儲存 lib path
221 liveuser 3849
		#$libPath=$libRootPath."/usr/".$folderOfUsrLib;
226 liveuser 3850
 
220 liveuser 3851
		#debug
3852
		#var_dump(__LINE__,$libPath);exit(1);
226 liveuser 3853
 
220 liveuser 3854
		#函式說明:
3855
		#使用 linux 的 uuid 指令來產生 uuid 字串
3856
		#回傳結果:
3857
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3858
		#$result["error"],錯誤訊息.
3859
		#$result["function"],當前執行的函式名稱.
3860
		#$result["content"],uuid.
3861
		#必填參數:
3862
		#無.
3863
		#可省略參數:
3864
		#無.
3865
		#參考資料:
3866
		#無.
3867
		#備註:
3868
		#無.
3869
		$uuid=cmd::uuid();
3 liveuser 3870
 
220 liveuser 3871
		#如果執行失敗
3872
		if($uuid["status"]==="false"){
3873
 
3874
			#debug
3875
			var_dump($uuid);
226 liveuser 3876
 
220 liveuser 3877
			#結束執行回傳代碼1給shell
3878
			exit(1);
3879
 
3880
			}#if end
226 liveuser 3881
 
220 liveuser 3882
		#預設的輸出目錄
3883
		$outputPath="/tmp/".$uuid["content"]."-phpLib::updateCopyRightYear/";
226 liveuser 3884
 
220 liveuser 3885
		#檢查參數
3 liveuser 3886
		#函式說明:
3887
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
3888
		#回傳結果:
3889
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3890
		#$result["error"],執行不正常結束的錯訊息陣列.
3891
		#$result["simpleError"],簡單表示的錯誤訊息.
3892
		#$result["function"],當前執行的函式名稱.
3893
		#$result["argu"],設置給予的參數.
3894
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
3895
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
3896
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
3897
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
3898
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
3899
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
3900
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
3901
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
3902
		#必填參數:
3903
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
3904
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
3905
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
3906
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
3907
		#可省略參數:
3908
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
3909
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
3910
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".
3911
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
3912
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
220 liveuser 3913
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
3 liveuser 3914
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
3915
		#$conf["canNotBeEmpty"]=array();
3916
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
3917
		#$conf["canBeEmpty"]=array();
3918
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
220 liveuser 3919
		#$conf["skipableVariableCanNotBeEmpty"]=array();
3 liveuser 3920
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
220 liveuser 3921
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("replaceFrom","yearFrom","yearTo","Authors","searchPath","skipHiddenFolder","includeHiddenFolder","excludeDirName","excludeMineType","excludeSecondName","multiThread","threadType","socket","log","outputPath");
3 liveuser 3922
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
220 liveuser 3923
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("array","string","string","array","array","string","array","array","array","array","string","string","string","string","string");
3 liveuser 3924
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
316 liveuser 3925
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array($replaceFromArray,"2014",gmdate("Y"),array("MIN ZHI, CHEN"),array($libRootPath),"true",null,array("free-lib","no-free-lib","composer"),array("image/*","video/*","audio/*","media/*","application/*"),array("log","csv","sql","js","css","html","key","crt","pem"),"false","socket",qbpwcf_usock_path,null,$outputPath);
3 liveuser 3926
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
220 liveuser 3927
		#$conf["disallowAllSkipableVarIsEmpty"]="";
3 liveuser 3928
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
220 liveuser 3929
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
3 liveuser 3930
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
3931
		#$conf["disallowAllSkipableVarNotExist"]="";
3932
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
3933
		#$conf["arrayCountEqualCheck"][]=array();
3934
		#參考資料:
3935
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3936
		#備註:
3937
		#無.
3938
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3939
		unset($conf["variableCheck::checkArguments"]);
226 liveuser 3940
 
220 liveuser 3941
		#如果執行異常
3 liveuser 3942
		if($checkArguments["status"]==="false"){
226 liveuser 3943
 
3 liveuser 3944
			#設置錯誤識別
3945
			$result["status"]="false";
226 liveuser 3946
 
3 liveuser 3947
			#設置錯誤訊息
3948
			$result["error"]=$checkArguments;
226 liveuser 3949
 
3 liveuser 3950
			#回傳結果
3951
			return $result;
226 liveuser 3952
 
3 liveuser 3953
			}#if end
226 liveuser 3954
 
220 liveuser 3955
		#如果參數檢查不通過
3 liveuser 3956
		if($checkArguments["passed"]==="false"){
226 liveuser 3957
 
3 liveuser 3958
			#設置錯誤識別
3959
			$result["status"]="false";
226 liveuser 3960
 
3 liveuser 3961
			#設置錯誤訊息
3962
			$result["error"]=$checkArguments;
226 liveuser 3963
 
3 liveuser 3964
			#回傳結果
3965
			return $result;
226 liveuser 3966
 
220 liveuser 3967
			}#if end
226 liveuser 3968
 
220 liveuser 3969
		#函式說明:
3970
		#取得檔案路徑字串的路徑與檔案的名稱與檔案副檔名
3971
		#回傳的結果:
3972
		#$result["status"],執行是否正常,"true"正常,"false"代表不正常.
3973
		#$result["error"],錯誤訊息.
3974
		#$result["function"],當前執行的函式名稱.
3975
		#$result["filePath"],路徑字串.
3976
		#$result["fileName"],檔案名稱字串.
3977
		#$result["fileExtention"],檔案的副檔名.
3978
		#$result["fullFileName"],含副檔名的檔案名稱.
3979
		#$result["fullFilePathAndName"],完整的檔案路徑(含副檔名).
3980
		#必填參數:
3981
		#$conf["fileAddressAndName"],字串,檔案名稱與其路徑.
3982
		$conf["fileAccess::getFileAddressAndNameAndFileExtention"]["fileAddressAndName"]=__FILE__;
3983
		#可省略參數:
3984
		#無.
3985
		#參考資料:
3986
		#無.
3987
		#備註:
3988
		#無.
3989
		$getFileAddressAndNameAndFileExtention=fileAccess::getFileAddressAndNameAndFileExtention($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
3990
		unset($conf["fileAccess::getFileAddressAndNameAndFileExtention"]);
226 liveuser 3991
 
220 liveuser 3992
		#debug,break point.
3993
		#var_dump(__LINE__,$getFileAddressAndNameAndFileExtention);exit;
226 liveuser 3994
 
220 liveuser 3995
		#如果執行失敗
3996
		if($getFileAddressAndNameAndFileExtention["status"]==="false"){
226 liveuser 3997
 
220 liveuser 3998
			#設置錯誤識別
3999
			$result["status"]="false";
226 liveuser 4000
 
220 liveuser 4001
			#設置錯誤訊息
4002
			$result["error"]=$getFileAddressAndNameAndFileExtention;
226 liveuser 4003
 
220 liveuser 4004
			#回傳結果
4005
			return $result;
226 liveuser 4006
 
3 liveuser 4007
			}#if end
226 liveuser 4008
 
220 liveuser 4009
		#初始化有異動的檔案清單
4010
		$result["content"]=array();
226 liveuser 4011
 
3 liveuser 4012
		#函式說明:
4013
		#使用 linux 的 uuid 指令來產生 uuid 字串
4014
		#回傳結果:
4015
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4016
		#$result["error"],錯誤訊息.
4017
		#$result["function"],當前執行的函式名稱.
4018
		#$result["content"],uuid.
4019
		#必填參數:
4020
		#無.
4021
		#可省略參數:
4022
		#無.
4023
		#參考資料:
4024
		#無.
4025
		#備註:
4026
		#無.
4027
		$uuid=cmd::uuid();
4028
 
4029
		#如果執行失敗
4030
		if($uuid["status"]==="false"){
4031
 
4032
			#debug
4033
			var_dump($uuid);
226 liveuser 4034
 
3 liveuser 4035
			#結束執行回傳代碼1給shell
4036
			exit(1);
4037
 
4038
			}#if end
226 liveuser 4039
 
3 liveuser 4040
		#取得 uuid
4041
		$uuid=$uuid["content"];
226 liveuser 4042
 
3 liveuser 4043
		#針對 $conf["searchPath"] 的每個路徑
4044
		foreach($conf["searchPath"] as $path){
226 liveuser 4045
 
316 liveuser 4046
			#如果有開啟 log
4047
			if(isset($conf["log"])){
226 liveuser 4048
 
316 liveuser 4049
				#函式說明:
4050
				#撰寫log
4051
				#回傳結果:
4052
				#$result["status"],狀態,"true"或"false".
4053
				#$result["error"],錯誤訊息陣列.
4054
				#$result["function"],當前函式的名稱.
4055
				#$result["argu"],使用的參數.
4056
				#必填參數:
4057
				#$conf["path"],字串,log檔案的路徑與名稱.
4058
				$conf["logs::record"]["path"]=$conf["log"];
4059
				#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4060
				$conf["logs::record"]["content"]="searching path:".$path.PHP_EOL;
4061
				#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4062
				$conf["logs::record"]["fileArgu"]=$conf["fileArgu"];
4063
				#可省略參數:
4064
				#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4065
				#$conf["rewrite"]="false";
4066
				#參考資料:
4067
				#無.
4068
				#備註:
4069
				#無.
4070
				$record=logs::record($conf["logs::record"]);
4071
				unset($conf["logs::record"]);
4072
 
4073
				#如果出錯
4074
				if($record["status"]==="false"){
4075
 
4076
					#設置錯誤識別
4077
					$result["status"]="false";
4078
 
4079
					#設置錯誤訊息
4080
					$result["error"]=$record;
4081
 
4082
					#印出json
4083
					echo json_encode($result);
4084
 
4085
					#結束執行,回傳1給shell,代表異常,
4086
					exit(1);
4087
 
4088
					}#if end
4089
 
4090
				}#if end
4091
 
3 liveuser 4092
			#取得 $path 底下的所有檔案.
4093
			#函式說明:
4094
			#取得目錄底下的詳細資訊.
4095
			#回傳結果:
4096
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4097
			#$result["error"],錯誤訊息.
4098
			#$result["function"],當前執行的函數名稱.
4099
			#$result["size"],該清單的大小,單位為bytes.
4100
			#$result["dataCount"],該清單的長度.
4101
			#$result["content"],指定目錄底下的所有檔案資訊.
4102
			#$result["content"][$i]["nType&permission"],第$i個節點類型、權限.
4103
			#$result["content"][$i]["nType"],第$i個節點類型,"-"代表檔案,"d"代表資料夾.
4104
			#$result["content"][$i]["permission"],第$i個節點權限.
4105
			#$result["content"][$i]["ownByUser"],第$i個節點擁有者賬號.
4106
			#$result["content"][$i]["ownByGroup"],第$i個節點擁有者群組.
4107
			#$result["content"][$i]["bytes"],第$i個節點大小.
4108
			#$result["content"][$i]["date"],第$i個節點最後變更日期.
4109
			#$result["content"][$i]["time"],第$i個節點最後異動時間.
4110
			#$result["content"][$i]["timeDetail"],第$i個節點最後異動詳細時間.
4111
			#$result["content"][$i]["timezone"],第$i個節點的時區.
4112
			#$result["content"][$i]["secondName"],第$i個節點為檔案時,若有附檔名,會記錄在這.
4113
			#$result["content"][$i]["name"],第$i個節點的名稱.
4114
			#$result["content"][$i]["mimeType"],第$i個節點為檔案且可以讀取時,會有 mime type 可取得.
4115
			#必填參數:
4116
			#$conf["path"],字串,要檢視的路徑,若非"/"結尾,會自動補上.
4117
			$conf["fileAccess::ls"]["path"]=$path;
4118
			#可省略參數:
4119
			#無.
4120
			#參考資料:
4121
			#https://www.businessweekly.com.tw/careers/Blog/14307
4122
			#備註:
4123
			#無.
4124
			$ls=fileAccess::ls($conf["fileAccess::ls"]);
4125
			unset($conf["fileAccess::ls"]);
226 liveuser 4126
 
3 liveuser 4127
			#如果執行失敗
4128
			if($ls["status"]==="false"){
226 liveuser 4129
 
3 liveuser 4130
				#設置錯誤識別
4131
				$result["status"]="false";
226 liveuser 4132
 
3 liveuser 4133
				#設置錯誤訊息
4134
				$result["error"]=$ls;
226 liveuser 4135
 
3 liveuser 4136
				#回傳結果
4137
				return $result;
226 liveuser 4138
 
3 liveuser 4139
				}#if end
226 liveuser 4140
 
3 liveuser 4141
			#如果沒資料
4142
			if($ls["dataCount"]===0){
226 liveuser 4143
 
3 liveuser 4144
				#跳過
4145
				continue;
226 liveuser 4146
 
3 liveuser 4147
				}#if end
226 liveuser 4148
 
3 liveuser 4149
			#針對每個節點
4150
			foreach($ls["content"] as $node){
226 liveuser 4151
 
3 liveuser 4152
				#取得節點的路徑與名稱
4153
				$NodePathAndName=$ls["path"].$node["name"];
226 liveuser 4154
 
3 liveuser 4155
				#儲存該節點需要取代的行號相關資訊
4156
				$replacedInfo=array();
226 liveuser 4157
 
3 liveuser 4158
				#預設該節點檔案不需要更新
4159
				$shouldReplace="false";
226 liveuser 4160
 
316 liveuser 4161
				#如果有開啟 log
4162
				if(isset($conf["log"])){
226 liveuser 4163
 
316 liveuser 4164
					#函式說明:
4165
					#撰寫log
4166
					#回傳結果:
4167
					#$result["status"],狀態,"true"或"false".
4168
					#$result["error"],錯誤訊息陣列.
4169
					#$result["function"],當前函式的名稱.
4170
					#$result["argu"],使用的參數.
4171
					#必填參數:
4172
					#$conf["path"],字串,log檔案的路徑與名稱.
4173
					$conf["logs::record"]["path"]=$conf["log"];
4174
					#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4175
					$conf["logs::record"]["content"]="processing node:".$NodePathAndName.PHP_EOL;
4176
					#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4177
					$conf["logs::record"]["fileArgu"]=$conf["fileArgu"];
4178
					#可省略參數:
4179
					#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4180
					#$conf["rewrite"]="false";
4181
					#參考資料:
4182
					#無.
4183
					#備註:
4184
					#無.
4185
					$record=logs::record($conf["logs::record"]);
4186
					unset($conf["logs::record"]);
4187
 
4188
					#如果出錯
4189
					if($record["status"]==="false"){
4190
 
4191
						#設置錯誤識別
4192
						$result["status"]="false";
4193
 
4194
						#設置錯誤訊息
4195
						$result["error"]=$record;
4196
 
4197
						#印出json
4198
						echo json_encode($result);
4199
 
4200
						#結束執行,回傳1給shell,代表異常,
4201
						exit(1);
4202
 
4203
						}#if end
4204
 
4205
					}#if end
4206
 
3 liveuser 4207
				#如果是資料夾
4208
				if($node["nType"]==="d"){
226 liveuser 4209
 
3 liveuser 4210
					#如果要忽略隱藏資料夾
4211
					if($conf["skipHiddenFolder"]==="true"){
226 liveuser 4212
 
3 liveuser 4213
						#如果開頭為 "."
4214
						if(strpos($node["name"],".")===0){
226 liveuser 4215
 
3 liveuser 4216
							#如果有設定要包含特定的隱藏目錄
4217
							if(isset($conf["includeHiddenFolder"])){
226 liveuser 4218
 
3 liveuser 4219
								#如果不是需要的特定隱藏目錄
4220
								if(!(in_array($node["name"],$conf["includeHiddenFolder"]))){
226 liveuser 4221
 
3 liveuser 4222
									#跳過
4223
									continue;
226 liveuser 4224
 
3 liveuser 4225
									}#if end
226 liveuser 4226
 
3 liveuser 4227
								}#if end
226 liveuser 4228
 
3 liveuser 4229
							#反之
4230
							else{
226 liveuser 4231
 
3 liveuser 4232
								#跳過
4233
								continue;
226 liveuser 4234
 
3 liveuser 4235
								}#else end
226 liveuser 4236
 
3 liveuser 4237
							}#if end
226 liveuser 4238
 
3 liveuser 4239
						}#if end
226 liveuser 4240
 
3 liveuser 4241
					#如果是要跳過的資料夾名稱
4242
					if(in_array($node["name"],$conf["excludeDirName"])){
226 liveuser 4243
 
3 liveuser 4244
						#跳過
4245
						continue;
226 liveuser 4246
 
3 liveuser 4247
						}#if end
226 liveuser 4248
 
4249
					#跳過
3 liveuser 4250
					#continue;
226 liveuser 4251
 
3 liveuser 4252
					#如果為單執行序
4253
					if($conf["multiThread"]==="false"){
226 liveuser 4254
 
3 liveuser 4255
						#繼承本函式參數
4256
						$conf["self::updateCopyRightYear"]=$conf;
226 liveuser 4257
 
3 liveuser 4258
						#置換要執行的路徑
4259
						$conf["self::updateCopyRightYear"]["searchPath"]=array($NodePathAndName);
226 liveuser 4260
 
3 liveuser 4261
						#遞迴呼叫
4262
						$updateCopyRightYear=self::updateCopyRightYear($conf["self::updateCopyRightYear"]);
226 liveuser 4263
 
3 liveuser 4264
						#移除參數,避免出錯.
4265
						unset($conf["self::updateCopyRightYear"]);
226 liveuser 4266
 
3 liveuser 4267
						#如果執行失敗
4268
						if($updateCopyRightYear["status"]==="false"){
226 liveuser 4269
 
3 liveuser 4270
							#設置錯誤識別
4271
							$result["status"]="false";
226 liveuser 4272
 
3 liveuser 4273
							#設置錯誤訊息
4274
							$result["error"]=$updateCopyRightYear;
226 liveuser 4275
 
3 liveuser 4276
							#回傳結果
4277
							return $result;
226 liveuser 4278
 
3 liveuser 4279
							}#if end
226 liveuser 4280
 
4281
						#記錄有掃描的資料夾路徑與名稱
3 liveuser 4282
						$result["scannedFile"][]=$NodePathAndName;
226 liveuser 4283
 
316 liveuser 4284
						#如果有開啟 log
4285
						if(isset($conf["log"])){
226 liveuser 4286
 
316 liveuser 4287
							#函式說明:
4288
							#撰寫log
4289
							#回傳結果:
4290
							#$result["status"],狀態,"true"或"false".
4291
							#$result["error"],錯誤訊息陣列.
4292
							#$result["function"],當前函式的名稱.
4293
							#$result["argu"],使用的參數.
4294
							#必填參數:
4295
							#$conf["path"],字串,log檔案的路徑與名稱.
4296
							$conf["logs::record"]["path"]=$conf["log"];
4297
							#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4298
							$conf["logs::record"]["content"]="recored searched node path and name:".$NodePathAndName.PHP_EOL;
4299
							#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4300
							$conf["logs::record"]["fileArgu"]=$conf["fileArgu"];
4301
							#可省略參數:
4302
							#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4303
							#$conf["rewrite"]="false";
4304
							#參考資料:
4305
							#無.
4306
							#備註:
4307
							#無.
4308
							$record=logs::record($conf["logs::record"]);
4309
							unset($conf["logs::record"]);
4310
 
4311
							#如果出錯
4312
							if($record["status"]==="false"){
4313
 
4314
								#設置錯誤識別
4315
								$result["status"]="false";
4316
 
4317
								#設置錯誤訊息
4318
								$result["error"]=$record;
4319
 
4320
								#印出json
4321
								echo json_encode($result);
4322
 
4323
								#結束執行,回傳1給shell,代表異常,
4324
								exit(1);
4325
 
4326
								}#if end
4327
 
4328
							}#if end
4329
 
3 liveuser 4330
						#合併 content - start
226 liveuser 4331
 
3 liveuser 4332
						#函式說明:
4333
						#將多個一維陣列串聯起來,key從0開始排序.
4334
						#回傳的結果:
4335
						#$result["status"],"true"表執行正常,"false"代表執行不正常.
4336
						#$result["error"],錯誤訊息陣列.
4337
						#$result["function"],當前執行的函數.
4338
						#$result["content"],合併好的一維陣列.
4339
						#必填參數
4340
						#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
4341
						$conf["arrays::mergeArray"]["inputArray"]=array($result["content"],$updateCopyRightYear["content"]);
4342
						#可省略參數:
4343
						#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
4344
						#$conf["allowRepeat"]="true";
4345
						#參考資料:
4346
						#無.
4347
						#備註:
4348
						#無.
4349
						$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
4350
						unset($conf["arrays::mergeArray"]);
226 liveuser 4351
 
3 liveuser 4352
						#如果執行失敗
4353
						if($mergeArray["status"]==="false"){
226 liveuser 4354
 
3 liveuser 4355
							#設置錯誤識別
4356
							$result["status"]="false";
226 liveuser 4357
 
3 liveuser 4358
							#設置錯誤訊息
4359
							$result["error"]=$mergeArray;
226 liveuser 4360
 
3 liveuser 4361
							#回傳結果
4362
							return $result;
226 liveuser 4363
 
3 liveuser 4364
							}#if end
226 liveuser 4365
 
3 liveuser 4366
						#取得合併好的有異動檔案結果
4367
						$result["content"]=$mergeArray["content"];
226 liveuser 4368
 
3 liveuser 4369
						#合併 content - end
226 liveuser 4370
 
3 liveuser 4371
						#合併 scannedFile - start
226 liveuser 4372
 
316 liveuser 4373
						#如果已經有已經掃描過的檔案了
3 liveuser 4374
						if(isset($updateCopyRightYear["scannedFile"])){
226 liveuser 4375
 
3 liveuser 4376
							#函式說明:
4377
							#將多個一維陣列串聯起來,key從0開始排序.
4378
							#回傳的結果:
4379
							#$result["status"],"true"表執行正常,"false"代表執行不正常.
4380
							#$result["error"],錯誤訊息陣列.
4381
							#$result["function"],當前執行的函數.
4382
							#$result["content"],合併好的一維陣列.
4383
							#必填參數
4384
							#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
4385
							$conf["arrays::mergeArray"]["inputArray"]=array($result["scannedFile"],$updateCopyRightYear["scannedFile"]);
4386
							#可省略參數:
4387
							#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
4388
							#$conf["allowRepeat"]="true";
4389
							#參考資料:
4390
							#無.
4391
							#備註:
4392
							#無.
4393
							$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
4394
							unset($conf["arrays::mergeArray"]);
226 liveuser 4395
 
3 liveuser 4396
							#如果執行失敗
4397
							if($mergeArray["status"]==="false"){
226 liveuser 4398
 
3 liveuser 4399
								#設置錯誤識別
4400
								$result["status"]="false";
226 liveuser 4401
 
3 liveuser 4402
								#設置錯誤訊息
4403
								$result["error"]=$mergeArray;
226 liveuser 4404
 
3 liveuser 4405
								#回傳結果
4406
								return $result;
226 liveuser 4407
 
3 liveuser 4408
								}#if end
226 liveuser 4409
 
3 liveuser 4410
							#取得合併好的有異動檔案結果
4411
							$result["scannedFile"]=$mergeArray["content"];
226 liveuser 4412
 
3 liveuser 4413
							}#if end
226 liveuser 4414
 
3 liveuser 4415
						#合併 scannedFile - end
226 liveuser 4416
 
3 liveuser 4417
						}#if end
226 liveuser 4418
 
3 liveuser 4419
					#反之為多執行程
4420
					else{
226 liveuser 4421
 
4422
						/*
4423
 
3 liveuser 4424
						預想的程式 - start
226 liveuser 4425
 
3 liveuser 4426
						#繼承本函式參數
4427
						$conf["self::updateCopyRightYear"]=$conf;
226 liveuser 4428
 
3 liveuser 4429
						#置換要執行的路徑
4430
						$conf["self::updateCopyRightYear"]["searchPath"]=array($NodePathAndName);
226 liveuser 4431
 
3 liveuser 4432
						#遞迴呼叫
4433
						$updateCopyRightYear=self::updateCopyRightYear($conf["self::updateCopyRightYear"]);
226 liveuser 4434
 
3 liveuser 4435
						預想的程式 - end
226 liveuser 4436
 
3 liveuser 4437
						*/
226 liveuser 4438
 
3 liveuser 4439
						#要執行的php程式內容
4440
						$cmdString=<<<'PHP'
4441
/*
4442
 
4443
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
239 liveuser 4444
    Copyright (C) 2014~2026 MIN ZHI, CHEN
3 liveuser 4445
 
4446
    This file is part of QBPWCF.
4447
 
4448
    QBPWCF is free software: you can redistribute it and/or modify
4449
    it under the terms of the GNU General Public License as published by
4450
    the Free Software Foundation, either version 3 of the License, or
4451
    (at your option) any later version.
4452
 
4453
    QBPWCF is distributed in the hope that it will be useful,
4454
    but WITHOUT ANY WARRANTY; without even the implied warranty of
4455
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4456
    GNU General Public License for more details.
4457
 
4458
    You should have received a copy of the GNU General Public License
4459
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
4460
 
4461
*/
4462
 
4463
#使用命名空間qbpwcf
4464
namespace qbpwcf;
4465
 
4466
#匯入套件
218 liveuser 4467
PHP;
3 liveuser 4468
 
218 liveuser 4469
						#匯入套件的路徑
4470
						$cmdString=$cmdString.PHP_EOL."require_once(\"".$libPath."/qbpwcf/allInOne.php\");";
4471
 
4472
						#要執行的php程式內容,設定建議的 log 位置.
4473
						$cmdString=$cmdString.PHP_EOL.<<<'PHP'
4474
 
3 liveuser 4475
#建議的log位置
4476
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
4477
 
4478
PHP;
4479
 
4480
						#要執行的php程式內容,繼承本函式參數
4481
						$cmdString=$cmdString.PHP_EOL."\$conf=(array)(json_decode(urldecode(base64_decode(\"".base64_encode(urlencode(json_encode($conf)))."\"))));";
4482
 
4483
						#要執行的php程式內容,置換要執行的路徑
4484
						$cmdString=$cmdString.PHP_EOL."\$conf[\"searchPath\"]=array(\"".$NodePathAndName."\");";
4485
 
4486
						#要執行的php程式內容
4487
						$cmdString=$cmdString.PHP_EOL.<<<'PHP'
4488
 
4489
#函式說明:
4490
#更新程式檔案開頭版權宣告的年份
4491
#回傳結果:
4492
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4493
#$reuslt["error"],執行不正常結束的錯訊息陣列.
4494
#$result["function"],當前執行的函式名稱.
4495
#$result["content"],有更新的檔案清單,其元素有被取代的檔案路徑與名稱跟replacedInfo,其中replacedInfo為陣列,其key為要變動的行號(從0開始算),其數值有"from"代表要被取代的原始內容,"to"代表要置換成的新內容.
4496
#$result["scannedFile"],陣列,有檢查過的檔案清單其完整路徑與檔案名稱.
4497
#必填參數:
4498
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4499
#$conf["fileArgu"]=__FILE__;
4500
#可省略參數:
4501
#$conf["replaceFrom"],陣列,目標關鍵字,每個元素代表一行的內容,預設內容可參照本檔案開頭的版權宣告文字.
4502
#$conf["replaceFrom"]=array();
4503
#$conf["yearFrom],字串,起始年份,預設為西元"2014"年.
4504
#$conf["yearFrom"]="2014";
4505
#$conf["yearTo],字串,結束年份,預設為西元"gmdate('Y')"年.
4506
#$conf["yearTo"]=gmdate('Y');
220 liveuser 4507
#$conf["Authors"],陣列,該套件的參與者,預設為array("MIN-ZHI, CHEN");
4508
#$conf["Authors"]=array("MIN-ZHI, CHEN");
3 liveuser 4509
#$conf["searchPath"],陣列,要搜尋哪些地方的檔案要更新版權宣告年份,預設為使用中的本套件位置.
4510
#$conf["searchPath"]=array("");
4511
#$conf["skipHiddenFolder"],字串,要略過隱藏的資料夾,預設為"true";反之為"false";
4512
#$conf["skipHiddenFolder"]="true";
4513
#$conf["includeHiddenFolder"],陣列,符合名稱的隱藏資料夾會存取,預設不指定;
4514
#$conf["includeHiddenFolder"]=array("");
4515
#$conf["excludeDirName"],陣列,哪些目錄名稱要忽略,預設有"free-lib"、"no-free-lib"、"composer".
4516
#$conf["excludeDirName"]=array("free-lib","no-free-lib","composer");
4517
#$conf["excludeMineType"],陣列,哪些檔案類型要忽略,預設有"image/*"、"video/*"、"audio/*"、"media/*"、"application/*".
4518
#$conf["excludeMineType"]=array("image/*","video/*","audio/*","media/*","application/*");
4519
#$conf["excludeSecondName"],陣列,哪些附檔名的檔案要忽略,預設有"log"、"csv"、"sql"、"js"、"css"、"html".
4520
#$conf["excludeSecondName"]=array("log"、,"csv","sql","js","css","html");
4521
#$conf["multiThread"],字串,是否要啟用多執行序,預設為"false",反之為"true".
4522
#$conf["multiThread"]="false";
4523
#參考資料:
4524
#無.
4525
#備註:
4526
#無.
4527
$updateCopyRightYear=phpLib::updateCopyRightYear($conf);
4528
unset($conf);
4529
 
4530
#輸出json結果
4531
echo json_encode($updateCopyRightYear);
4532
PHP;
226 liveuser 4533
 
3 liveuser 4534
						#設置多執行序的類型
4535
						$threadType=$conf["threadType"];
226 liveuser 4536
 
218 liveuser 4537
						#debug,break point
220 liveuser 4538
						#var_dump(__LINE__,$threadType);exit(1);
226 liveuser 4539
 
3 liveuser 4540
						#判斷多執行序的類型
4541
						switch($threadType){
226 liveuser 4542
 
3 liveuser 4543
							#若是直接用 proc
4544
							case "proc":
226 liveuser 4545
 
3 liveuser 4546
								#函式說明:
4547
								#透過proc來多執行序運作.
4548
								#回傳結果:
4549
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4550
								#$reuslt["error"],執行不正常結束的錯訊息陣列.
4551
								#$result["function"],當前執行的函式名稱.
4552
								#$result["argu"],使用的參數.
4553
								#$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"代表程序的資訊.
4554
								#必填參數:
4555
								#$conf["cmds"],字串陣列,每個元素代表要執行的指令與參數.
4556
								$conf["threads::proc"]["cmds"]=array("php -r ".escapeshellarg($cmdString));
4557
								#可省略參數:
4558
								#$conf["wait"],字串,是否需要等待所有程序結束,預設為"true"要等待;反之為"false"不要等待.
4559
								$conf["threads::proc"]["wait"]="false";
4560
								#$conf["workingDir"],字串陣列,個別程式執行時的家目錄,預設不指定.
4561
								$conf["threads::proc"]["workingDir"]=array($NodePathAndName);
4562
								#$conf["envs"],2維字串陣列,每個元素代表個別程式執行時的指定環境變數,key變數名稱;value為變數內容.預設為array("QBPWCF" => "Quick Build PHP Website Componment base on Fedora Linux");
4563
								#$conf["envs"]=array(array("key"=>"value"));
4564
								#$conf["executeBy"],字串陣列,每個元素代表個別指令要用什麼程式執行,預設為"bash".
4565
								#$conf["threads::proc"]["executeBy"]=array("php");
4566
								#參考資料:
4567
								#https://www.php.net/manual/en/function.proc-open.php
4568
								#https://www.php.net/manual/en/function.proc-get-status.php
4569
								#備註:
4570
								#無.
4571
								$proc=threads::proc($conf["threads::proc"]);
4572
								unset($conf["threads::proc"]);
226 liveuser 4573
 
3 liveuser 4574
								#如果執行失敗
4575
								if($proc["status"]==="false"){
226 liveuser 4576
 
3 liveuser 4577
									#設置錯誤識別
4578
									$result["status"]="false";
226 liveuser 4579
 
3 liveuser 4580
									#設置錯誤訊息
4581
									$result["error"]=$proc;
226 liveuser 4582
 
3 liveuser 4583
									#回傳結果
4584
									return $result;
226 liveuser 4585
 
3 liveuser 4586
									}#if end
226 liveuser 4587
 
3 liveuser 4588
								#如果有開啟 log
4589
								if(isset($conf["log"])){
226 liveuser 4590
 
3 liveuser 4591
									#函式說明:
4592
									#撰寫log
4593
									#回傳結果:
4594
									#$result["status"],狀態,"true"或"false".
4595
									#$result["error"],錯誤訊息陣列.
4596
									#$result["function"],當前函式的名稱.
4597
									#$result["argu"],使用的參數.
4598
									#必填參數:
4599
									#$conf["path"],字串,log檔案的路徑與名稱.
4600
									$conf["logs::record"]["path"]=$conf["log"];
4601
									#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4602
									$conf["logs::record"]["content"]=$proc;
4603
									#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4604
									$conf["logs::record"]["fileArgu"]=$conf["fileArgu"];
4605
									#可省略參數:
4606
									#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4607
									#$conf["rewrite"]="false";
4608
									#參考資料:
4609
									#無.
4610
									#備註:
4611
									#無.
4612
									$record=logs::record($conf["logs::record"]);
4613
									unset($conf["logs::record"]);
226 liveuser 4614
 
3 liveuser 4615
									#如果出錯
4616
									if($record["status"]==="false"){
226 liveuser 4617
 
3 liveuser 4618
										#設置錯誤識別
4619
										$result["status"]="false";
226 liveuser 4620
 
3 liveuser 4621
										#設置錯誤訊息
4622
										$result["error"]=$record;
226 liveuser 4623
 
3 liveuser 4624
										#印出json
4625
										echo json_encode($result);
226 liveuser 4626
 
3 liveuser 4627
										#結束執行,回傳1給shell,代表異常,
4628
										exit(1);
226 liveuser 4629
 
3 liveuser 4630
										}#if end
226 liveuser 4631
 
3 liveuser 4632
									}#if end
226 liveuser 4633
 
3 liveuser 4634
								#儲存要執行的程序
4635
								$procs[]=$proc;
226 liveuser 4636
 
3 liveuser 4637
								#結束 switch
4638
								break;
226 liveuser 4639
 
3 liveuser 4640
							#如果是要透過 socket 來執行
4641
							case "socket":
226 liveuser 4642
 
3 liveuser 4643
								#函式說明:
4644
								#透過 unix socket 來多執行序運作.
4645
								#回傳結果:
4646
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4647
								#$reuslt["error"],執行不正常結束的錯訊息陣列.
4648
								#$result["function"],當前執行的函式名稱.
4649
								#$result["argu"],使用的參數.
4650
								#$result["content"],陣列,每個元素為cmds參數中個別元素其指令傳送後得到的uuid,可透過sock::getProcInfo來查詢結果.
4651
								#必填參數:
4652
								#$conf["cmds"],字串陣列,每個元素代表要執行的指令與參數.
4653
								$conf["threads::socket"]["cmds"]=array("php -r ".escapeshellarg($cmdString));
4654
								#可省略參數:
4655
								#$conf["sock"],字串,要連線的 usr/bin/qbpwcf-sock.php 所產生的 unix domain socket 路徑與名稱,預設為 qbpwcf_usock_path.
4656
								$conf["threads::socket"]["sock"]=$conf["socket"];
4657
								#參考資料:
4658
								#無
4659
								#備註:
4660
								#需要透過sock::unixDomainSockServer來運行.
4661
								$socket=threads::socket($conf["threads::socket"]);
4662
								unset($conf["threads::socket"]);
226 liveuser 4663
 
3 liveuser 4664
								#如果執行失敗
4665
								if($socket["status"]==="false"){
226 liveuser 4666
 
3 liveuser 4667
									#設置錯誤識別
4668
									$result["status"]="false";
226 liveuser 4669
 
3 liveuser 4670
									#設置錯誤訊息
218 liveuser 4671
									$result["error"]=$socket;
226 liveuser 4672
 
3 liveuser 4673
									#回傳結果
4674
									return $result;
226 liveuser 4675
 
3 liveuser 4676
									}#if end
226 liveuser 4677
 
3 liveuser 4678
								#如果有開啟 log
4679
								if(isset($conf["log"])){
226 liveuser 4680
 
3 liveuser 4681
									#函式說明:
4682
									#撰寫log
4683
									#回傳結果:
4684
									#$result["status"],狀態,"true"或"false".
4685
									#$result["error"],錯誤訊息陣列.
4686
									#$result["function"],當前函式的名稱.
4687
									#$result["argu"],使用的參數.
4688
									#必填參數:
4689
									#$conf["path"],字串,log檔案的路徑與名稱.
4690
									$conf["logs::record"]["path"]=$conf["log"];
4691
									#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4692
									$conf["logs::record"]["content"]=$socket;
4693
									#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4694
									$conf["logs::record"]["fileArgu"]=$conf["fileArgu"];
4695
									#可省略參數:
4696
									#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4697
									#$conf["rewrite"]="false";
4698
									#參考資料:
4699
									#無.
4700
									#備註:
4701
									#無.
4702
									$record=logs::record($conf["logs::record"]);
4703
									unset($conf["logs::record"]);
226 liveuser 4704
 
3 liveuser 4705
									#如果出錯
4706
									if($record["status"]==="false"){
226 liveuser 4707
 
3 liveuser 4708
										#設置錯誤識別
4709
										$result["status"]="false";
226 liveuser 4710
 
3 liveuser 4711
										#設置錯誤訊息
4712
										$result["error"]=$record;
226 liveuser 4713
 
3 liveuser 4714
										#印出json
4715
										echo json_encode($result);
226 liveuser 4716
 
3 liveuser 4717
										#結束執行,回傳1給shell,代表異常,
4718
										exit(1);
226 liveuser 4719
 
3 liveuser 4720
										}#if end
226 liveuser 4721
 
3 liveuser 4722
									}#if end
226 liveuser 4723
 
3 liveuser 4724
								#儲存要執行的程序
4725
								$procs[]=$socket;
226 liveuser 4726
 
3 liveuser 4727
								#結束 switch
4728
								break;
226 liveuser 4729
 
3 liveuser 4730
							#其他類型
4731
							default:
226 liveuser 4732
 
3 liveuser 4733
								#設置錯誤識別
4734
								$result["status"]="false";
226 liveuser 4735
 
3 liveuser 4736
								#設置錯誤訊息
4737
								$result["error"][]="not supported multi threads type ".$threadType;
226 liveuser 4738
 
3 liveuser 4739
								#印出json
4740
								echo json_encode($result);
226 liveuser 4741
 
3 liveuser 4742
								#結束執行,回傳1給shell,代表異常,
4743
								exit(1);
226 liveuser 4744
 
3 liveuser 4745
							}#switch end
226 liveuser 4746
 
3 liveuser 4747
						}#else end
226 liveuser 4748
 
3 liveuser 4749
					}#if end
226 liveuser 4750
 
3 liveuser 4751
				#反之如果是檔案
4752
				else if($node["nType"]==="-"){
226 liveuser 4753
 
3 liveuser 4754
					#針對每個要忽略的 mime type
4755
					foreach($conf["excludeMineType"] as $mimeType){
226 liveuser 4756
 
3 liveuser 4757
						#取得 "/*" 的位置
4758
						$positionOfSlashStar=strpos($mimeType,"/*");
226 liveuser 4759
 
3 liveuser 4760
						#如果是含有 "/*" 的廣義 mime 類型
4761
						if($positionOfSlashStar!==false){
226 liveuser 4762
 
3 liveuser 4763
							#取得 廣義類型的內容
4764
							$ignoredWileMimeTypeWithSlash=substr($mimeType,0,$positionOfSlashStar+1);
226 liveuser 4765
 
3 liveuser 4766
							#debug
4767
							#var_dump(__LINE__,$ignoredWileMimeTypeWithSlash);
226 liveuser 4768
 
3 liveuser 4769
							#如果是要忽略的 廣義類型內容
4770
							if(strpos($node["mimeType"],$ignoredWileMimeTypeWithSlash)===0){
226 liveuser 4771
 
3 liveuser 4772
								#跳過之
4773
								continue 2;
226 liveuser 4774
 
3 liveuser 4775
								}#if end
226 liveuser 4776
 
3 liveuser 4777
							}#if end
226 liveuser 4778
 
3 liveuser 4779
						#反之
4780
						else{
226 liveuser 4781
 
3 liveuser 4782
							#如果是要忽略的 mime 類型
4783
							if($mimeType===$node["mimeType"]){
226 liveuser 4784
 
3 liveuser 4785
								#跳過之
4786
								continue 2;
226 liveuser 4787
 
3 liveuser 4788
								}#if end
226 liveuser 4789
 
3 liveuser 4790
							}#else end
226 liveuser 4791
 
3 liveuser 4792
						}#foreach end
226 liveuser 4793
 
3 liveuser 4794
					#如果有副檔案名存在
4795
					if(isset($node["secondName"])){
226 liveuser 4796
 
3 liveuser 4797
						#如果是要忽略的附檔名
4798
						if(in_array($node["secondName"],$conf["excludeSecondName"])){
226 liveuser 4799
 
3 liveuser 4800
							#跳過檔案
4801
							continue;
226 liveuser 4802
 
3 liveuser 4803
							}#if end
226 liveuser 4804
 
3 liveuser 4805
						}#if end
226 liveuser 4806
 
4807
					#記錄有掃描的檔案路徑與名稱
3 liveuser 4808
					$result["scannedFile"][]=$NodePathAndName;
226 liveuser 4809
 
218 liveuser 4810
					#debug
220 liveuser 4811
					#var_dump(__LINE__,"found file:".$NodePathAndName." mimeType:".$node["mimeType"]);
226 liveuser 4812
 
240 liveuser 4813
					#設置起始年份
4814
					$replaceTo[1]["yearFrom"]=$conf["yearFrom"];
226 liveuser 4815
 
240 liveuser 4816
					#設置到的年份
4817
					$replaceTo[1]["yearTo"]=$conf["yearTo"];
226 liveuser 4818
 
240 liveuser 4819
					#將作者陣列變成字串.
4820
					#函式說明:
4821
					#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
4822
					#回傳的結果:
4823
					#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4824
					#$result["function"],當前執行的function名稱
4825
					#$result["error"],錯誤訊息陣列.
4826
					#$result["content"],處理好的字串.
4827
					#$result["argu"],使用的參數.
4828
					#必填參數:
4829
					#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.
4830
					$conf["arrays::arrayToString"]["inputArray"]=$conf["Authors"];
4831
					#可省略參數:
4832
					#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;
4833
					$conf["arrays::arrayToString"]["spiltSymbol"]=", ";
4834
					#$conf["skipEnd"],字串,結尾是否不要加上符號,預設為"false",要加上符號,"true"代表不要加上符號.
4835
					$conf["arrays::arrayToString"]["skipEnd"]="true";
4836
					#$conf["spiltSymbolAtStart"],字串,是否要在開頭加上spiltSymbol,預設為"false",代表不要;反之為“true”.
4837
					#$conf["spiltSymbolAtStart"]="";
4838
					#參考資料:
4839
					#無.
4840
					#備註:
4841
					#無.
4842
					$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
4843
					unset($conf["arrays::arrayToString"]);
226 liveuser 4844
 
240 liveuser 4845
					#如果執行異常
4846
					if($arrayToString["status"]==="false"){
226 liveuser 4847
 
240 liveuser 4848
						#設置執行異常的識別
4849
						$result["status"]="false";
226 liveuser 4850
 
240 liveuser 4851
						#設置執行錯誤訊息
4852
						$result["error"]=$arrayToString;
226 liveuser 4853
 
240 liveuser 4854
						#回傳結果
4855
						return $result;
226 liveuser 4856
 
240 liveuser 4857
						}#if end
226 liveuser 4858
 
240 liveuser 4859
					#設置作者清單字串
4860
					$replaceTo[1]["Authors"]=$arrayToString["content"];
226 liveuser 4861
 
240 liveuser 4862
					#如果沒有用多執行序
4863
					if($conf["multiThread"]==="false"){
226 liveuser 4864
 
316 liveuser 4865
						#如果有開啟 log
4866
						if(isset($conf["log"])){
4867
 
4868
							#函式說明:
4869
							#撰寫log
4870
							#回傳結果:
4871
							#$result["status"],狀態,"true"或"false".
4872
							#$result["error"],錯誤訊息陣列.
4873
							#$result["function"],當前函式的名稱.
4874
							#$result["argu"],使用的參數.
4875
							#必填參數:
4876
							#$conf["path"],字串,log檔案的路徑與名稱.
4877
							$conf["logs::record"]["path"]=$conf["log"];
4878
							#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4879
							$conf["logs::record"]["content"]="checking file:".$NodePathAndName.PHP_EOL;
4880
							#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4881
							$conf["logs::record"]["fileArgu"]=$conf["fileArgu"];
4882
							#可省略參數:
4883
							#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4884
							#$conf["rewrite"]="false";
4885
							#參考資料:
4886
							#無.
4887
							#備註:
4888
							#無.
4889
							$record=logs::record($conf["logs::record"]);
4890
							unset($conf["logs::record"]);
4891
 
4892
							#如果出錯
4893
							if($record["status"]==="false"){
4894
 
4895
								#設置錯誤識別
4896
								$result["status"]="false";
4897
 
4898
								#設置錯誤訊息
4899
								$result["error"]=$record;
4900
 
4901
								#印出json
4902
								echo json_encode($result);
4903
 
4904
								#結束執行,回傳1給shell,代表異常,
4905
								exit(1);
4906
 
4907
								}#if end
4908
 
4909
							}#if end
4910
 
220 liveuser 4911
						#函式說明:
4912
						#置換檔案內容中符合的內容.
4913
						#回傳結果:
4914
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
4915
						#$reuslt["error"],執行不正常結束的錯訊息陣列.
4916
						#$result["function"],當前執行的函式名稱.
4917
						#$result["argu"],本函式使用的參數.
4918
						#$result["content"],更新後的檔案內容陣列.每個元素代表一行的內容.
4919
						#$result["found"],字串,是否有找到符合條件需要置換的內容.
4920
						#$result["relaceInfo"],陣列,記錄需要置換的行資訊,元素的key為需要置換的行號,第 $i 行用 $i+1 表示.
4921
						#$result["relaceInfo"][$i]["ori"],字串,第 $i+1 行原始的內容.
4922
						#$result["relaceInfo"][$i]["new"],字串,第 $i+1 行要置換成的內容.
4923
						#$result["content"],陣列,替換完後的每行內容.
4924
						#必填參數:
4925
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4926
						$conf["phpLib::replaceMatchContent"]["fileArgu"]=__FILE__;
4927
						#$conf["file"],字串,要置換內容的檔案路徑與名稱.
4928
						$conf["phpLib::replaceMatchContent"]["file"]=$NodePathAndName;
4929
						#$conf["formats"],陣列,連續的關鍵字字串.
4930
						$conf["phpLib::replaceMatchContent"]["formats"]=$conf["replaceFrom"];
4931
						#$conf["replaceTo"],陣列,原始內容要如何置換,每個元素的索引對應到formats參數的每個元素,若其索引不存在則代表對應的行不異動.
4932
						$conf["phpLib::replaceMatchContent"]["replaceTo"]=$replaceTo;
4933
						#可省略參數:
4934
						#無.
4935
						#參考資料:
4936
						#無.
4937
						#備註:
4938
						#參數設定 $conf["replaceTo"][$i]=$replaceStr; 代表符合格式的連續字串中的 $i+1 行內容要置換成 $replaceStr.
4939
						#參數設定 $conf["replaceTo"][$i]=array("varName1"=>$replaceStr1,"varName2"=>$replaceStr2); 代表符合格式的連續字串中的 $i+1 行內容中的變數 varName1 要置換成 $replaceStr1;變數 varName2 要置換成 $replaceStr2.
4940
						$replaceMatchContent=phpLib::replaceMatchContent($conf["phpLib::replaceMatchContent"]);
4941
						unset($conf["phpLib::replaceMatchContent"]);
226 liveuser 4942
 
220 liveuser 4943
						#如果執行異常
4944
						if($replaceMatchContent["status"]==="false"){
226 liveuser 4945
 
220 liveuser 4946
							#設置執行異常的識別
4947
							$result["status"]="false";
226 liveuser 4948
 
220 liveuser 4949
							#設置執行錯誤訊息
4950
							$result["error"]=$replaceMatchContent;
226 liveuser 4951
 
220 liveuser 4952
							#回傳結果
4953
							return $result;
226 liveuser 4954
 
220 liveuser 4955
							}#if end
226 liveuser 4956
 
220 liveuser 4957
						#如果有需要更新檔案內容的識別
4958
						if($replaceMatchContent["found"]==="true"){
226 liveuser 4959
 
220 liveuser 4960
							#$replaceMatchContent["relaceInfo"][$i]["new"],第 $i+1 行的新內容.
226 liveuser 4961
 
220 liveuser 4962
							#初始化給予 fileAccess::updateFile 的參數
4963
							$replaceSpecifyLine=array();
226 liveuser 4964
 
220 liveuser 4965
							#針對每個要更新的行
4966
							foreach($replaceMatchContent["relaceInfo"] as $lineIndex => $info){
226 liveuser 4967
 
220 liveuser 4968
								#設置給予 fileAccess::updateFile 的參數
4969
								$replaceSpecifyLine[$lineIndex]=$info["new"];
226 liveuser 4970
 
220 liveuser 4971
								}#foreach end
226 liveuser 4972
 
316 liveuser 4973
							#如果有開啟 log
4974
							if(isset($conf["log"])){
4975
 
4976
								#函式說明:
4977
								#撰寫log
4978
								#回傳結果:
4979
								#$result["status"],狀態,"true"或"false".
4980
								#$result["error"],錯誤訊息陣列.
4981
								#$result["function"],當前函式的名稱.
4982
								#$result["argu"],使用的參數.
4983
								#必填參數:
4984
								#$conf["path"],字串,log檔案的路徑與名稱.
4985
								$conf["logs::record"]["path"]=$conf["log"];
4986
								#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
4987
								$conf["logs::record"]["content"]="updating file:".$NodePathAndName.PHP_EOL;
4988
								#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
4989
								$conf["logs::record"]["fileArgu"]=$conf["fileArgu"];
4990
								#可省略參數:
4991
								#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
4992
								#$conf["rewrite"]="false";
4993
								#參考資料:
4994
								#無.
4995
								#備註:
4996
								#無.
4997
								$record=logs::record($conf["logs::record"]);
4998
								unset($conf["logs::record"]);
4999
 
5000
								#如果出錯
5001
								if($record["status"]==="false"){
5002
 
5003
									#設置錯誤識別
5004
									$result["status"]="false";
5005
 
5006
									#設置錯誤訊息
5007
									$result["error"]=$record;
5008
 
5009
									#印出json
5010
									echo json_encode($result);
5011
 
5012
									#結束執行,回傳1給shell,代表異常,
5013
									exit(1);
5014
 
5015
									}#if end
5016
 
5017
								}#if end
5018
 
220 liveuser 5019
							#更新檔案內容
5020
							#函式說明:
5021
							#更新檔案的內容.
5022
							#回傳結果:
5023
							#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5024
							#$result["error"],錯誤訊息.
5025
							#$result["function"],當前執行的函數名稱.
5026
							#$result["content"],更新的資訊.
5027
							#必填參數:
5028
							#$conf["fileArgu"],字串,變數__FILE__的內容.
5029
							$conf["fileAccess::updateFile"]["fileArgu"]=__FILE__;
5030
							#$conf["file"],字串,要更新的檔案位置與名稱.
5031
							$conf["fileAccess::updateFile"]["file"]=$NodePathAndName;
5032
							#可省略參數:
5033
							#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
5034
							$conf["fileAccess::updateFile"]["overWriteWith"]=$replaceMatchContent["content"];
5035
							#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
5036
							#$conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
5037
							#$conf["replaceLike"],字串,預設為"false",代表要完全符合關鍵字才能進行整行替換;反之為"true".
5038
							#$conf["replaceLike"]="false";
5039
							#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
5040
							#$conf["addToTailWhenNoMatch"]="false";
5041
							#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
5042
							#$conf["addToTailBeforeThat"]="?\>";
5043
							#$conf["replaceSpecifyLine"],字串陣列,將指定的行取代成指定的內容,元素的key為原始檔案的行索引,若key為$i+1,則代表第$i行;元素的數值就為該行的新內容.
5044
							#$conf["fileAccess::updateFile"]["replaceSpecifyLine"]=$replaceSpecifyLine;
5045
							#$conf["outputPath"],字串,檔案要輸出到哪個位置,預設不指定,直接取代原始檔案的內容.
221 liveuser 5046
							$conf["fileAccess::updateFile"]["outputPath"]=$conf["outputPath"];
220 liveuser 5047
							#參考資料:
5048
							#無.
5049
							#備註:
5050
							#無.
5051
							$updateFile=fileAccess::updateFile($conf["fileAccess::updateFile"]);
5052
							unset($conf["fileAccess::updateFile"]);
226 liveuser 5053
 
220 liveuser 5054
							#如果出錯
5055
							if($updateFile["status"]==="false"){
226 liveuser 5056
 
220 liveuser 5057
								#設置錯誤識別
5058
								$result["status"]="false";
226 liveuser 5059
 
220 liveuser 5060
								#設置錯誤訊息
5061
								$result["error"]=$updateFile;
226 liveuser 5062
 
220 liveuser 5063
								#回傳結果
5064
								return $result;
226 liveuser 5065
 
220 liveuser 5066
								}#if end
226 liveuser 5067
 
220 liveuser 5068
							#如果沒有既有的記錄
5069
							if(!isset($result["content"][$NodePathAndName])){
226 liveuser 5070
 
220 liveuser 5071
								#記錄有更新的檔案路徑與名稱與其次數為1
5072
								$result["content"][$NodePathAndName]["time"]=1;
226 liveuser 5073
 
220 liveuser 5074
								}#if end
226 liveuser 5075
 
220 liveuser 5076
							#反之
5077
							else{
226 liveuser 5078
 
220 liveuser 5079
								#記錄有更新的檔案路徑與名稱與的次數+1
5080
								$result["content"][$NodePathAndName]["time"]++;
226 liveuser 5081
 
220 liveuser 5082
								}#else end
226 liveuser 5083
 
220 liveuser 5084
							#記錄更新的相關資訊,用太多記憶體.
5085
							#$result["content"][$NodePathAndName]["replacedInfo"]=$updateFile["content"];
226 liveuser 5086
 
220 liveuser 5087
							}#if end
226 liveuser 5088
 
218 liveuser 5089
						}#if end
226 liveuser 5090
 
218 liveuser 5091
					#反之為多執行序
5092
					else{
226 liveuser 5093
 
240 liveuser 5094
						#要執行的php程式內容
5095
						$cmdString=<<<'PHP'
5096
/*
226 liveuser 5097
 
240 liveuser 5098
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
5099
    Copyright (C) 2014~2026 MIN ZHI, CHEN
226 liveuser 5100
 
240 liveuser 5101
    This file is part of QBPWCF.
226 liveuser 5102
 
240 liveuser 5103
    QBPWCF is free software: you can redistribute it and/or modify
5104
    it under the terms of the GNU General Public License as published by
5105
    the Free Software Foundation, either version 3 of the License, or
5106
    (at your option) any later version.
226 liveuser 5107
 
240 liveuser 5108
    QBPWCF is distributed in the hope that it will be useful,
5109
    but WITHOUT ANY WARRANTY; without even the implied warranty of
5110
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5111
    GNU General Public License for more details.
226 liveuser 5112
 
240 liveuser 5113
    You should have received a copy of the GNU General Public License
5114
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
226 liveuser 5115
 
240 liveuser 5116
*/
226 liveuser 5117
 
240 liveuser 5118
#使用命名空間qbpwcf
5119
namespace qbpwcf;
226 liveuser 5120
 
240 liveuser 5121
#匯入套件
5122
PHP;
226 liveuser 5123
 
240 liveuser 5124
						#匯入套件的路徑
5125
						$cmdString=$cmdString.PHP_EOL."require_once(\"".$libPath."/qbpwcf/allInOne.php\");";
226 liveuser 5126
 
240 liveuser 5127
						#要執行的php程式內容,設定建議的 log 位置.
5128
						$cmdString=$cmdString.PHP_EOL.<<<'PHP'
226 liveuser 5129
 
240 liveuser 5130
#建議的log位置
5131
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
226 liveuser 5132
 
240 liveuser 5133
PHP;
226 liveuser 5134
 
240 liveuser 5135
#$NodePathAndName
5136
$cmdString=$cmdString.PHP_EOL."\$NodePathAndName=".$NodePathAndName.";";
226 liveuser 5137
 
240 liveuser 5138
#$replaceFrom
5139
$cmdString=$cmdString.PHP_EOL."\$replaceFrom=".$conf["replaceFrom"].";";
226 liveuser 5140
 
240 liveuser 5141
#replaceTo
5142
$cmdString=$cmdString.PHP_EOL."\$replaceTo=".$replaceTo.";";
226 liveuser 5143
 
240 liveuser 5144
#要執行的php程式內容
5145
$cmdString=$cmdString.PHP_EOL.<<<'PHP'
226 liveuser 5146
 
240 liveuser 5147
#函式說明:
5148
#置換檔案內容中符合的內容.
5149
#回傳結果:
5150
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5151
#$reuslt["error"],執行不正常結束的錯訊息陣列.
5152
#$result["function"],當前執行的函式名稱.
5153
#$result["argu"],本函式使用的參數.
5154
#$result["content"],更新後的檔案內容陣列.每個元素代表一行的內容.
5155
#$result["found"],字串,是否有找到符合條件需要置換的內容.
5156
#$result["relaceInfo"],陣列,記錄需要置換的行資訊,元素的key為需要置換的行號,第 $i 行用 $i+1 表示.
5157
#$result["relaceInfo"][$i]["ori"],字串,第 $i+1 行原始的內容.
5158
#$result["relaceInfo"][$i]["new"],字串,第 $i+1 行要置換成的內容.
5159
#$result["content"],陣列,替換完後的每行內容.
5160
#必填參數:
5161
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5162
$conf["phpLib::replaceMatchContent"]["fileArgu"]=__FILE__;
5163
#$conf["file"],字串,要置換內容的檔案路徑與名稱.
5164
$conf["phpLib::replaceMatchContent"]["file"]=$NodePathAndName;
5165
#$conf["formats"],陣列,連續的關鍵字字串.
5166
$conf["phpLib::replaceMatchContent"]["formats"]=$replaceFrom;
5167
#$conf["replaceTo"],陣列,原始內容要如何置換,每個元素的索引對應到formats參數的每個元素,若其索引不存在則代表對應的行不異動.
5168
$conf["phpLib::replaceMatchContent"]["replaceTo"]=$replaceTo;
5169
#可省略參數:
5170
#無.
5171
#參考資料:
5172
#無.
5173
#備註:
5174
#參數設定 $conf["replaceTo"][$i]=$replaceStr; 代表符合格式的連續字串中的 $i+1 行內容要置換成 $replaceStr.
5175
#參數設定 $conf["replaceTo"][$i]=array("varName1"=>$replaceStr1,"varName2"=>$replaceStr2); 代表符合格式的連續字串中的 $i+1 行內容中的變數 varName1 要置換成 $replaceStr1;變數 varName2 要置換成 $replaceStr2.
5176
$replaceMatchContent=phpLib::replaceMatchContent($conf["phpLib::replaceMatchContent"]);
5177
unset($conf["phpLib::replaceMatchContent"]);
226 liveuser 5178
 
240 liveuser 5179
#如果執行異常
5180
if($replaceMatchContent["status"]==="false"){
226 liveuser 5181
 
240 liveuser 5182
	#設置執行異常的識別
5183
	$result["status"]="false";
5184
 
5185
	#設置執行錯誤訊息
5186
	$result["error"]=$replaceMatchContent;
5187
 
5188
	#回傳結果
5189
	return $result;
5190
 
5191
	}#if end
5192
 
5193
PHP;
5194
 
5195
#$outputPath
5196
$cmdString=$cmdString.PHP_EOL."\$outputPath\"=".$conf["outputPath"].";";
5197
 
5198
<<<'PHP'
5199
 
5200
#如果有需要更新檔案內容的識別
5201
if($replaceMatchContent["found"]==="true"){
5202
 
5203
	#$replaceMatchContent["relaceInfo"][$i]["new"],第 $i+1 行的新內容.
5204
 
5205
	#初始化給予 fileAccess::updateFile 的參數
5206
	$replaceSpecifyLine=array();
5207
 
5208
	#針對每個要更新的行
5209
	foreach($replaceMatchContent["relaceInfo"] as $lineIndex => $info){
5210
 
5211
		#設置給予 fileAccess::updateFile 的參數
5212
		$replaceSpecifyLine[$lineIndex]=$info["new"];
5213
 
5214
		}#foreach end
5215
 
5216
	#更新檔案內容
5217
	#函式說明:
5218
	#更新檔案的內容.
5219
	#回傳結果:
5220
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5221
	#$result["error"],錯誤訊息.
5222
	#$result["function"],當前執行的函數名稱.
5223
	#$result["content"],更新的資訊.
5224
	#必填參數:
5225
	#$conf["fileArgu"],字串,變數__FILE__的內容.
5226
	$conf["fileAccess::updateFile"]["fileArgu"]=__FILE__;
5227
	#$conf["file"],字串,要更新的檔案位置與名稱.
5228
	$conf["fileAccess::updateFile"]["file"]=$NodePathAndName;
5229
	#可省略參數:
5230
	#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
5231
	$conf["fileAccess::updateFile"]["overWriteWith"]=$replaceMatchContent["content"];
5232
	#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
5233
	#$conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
5234
	#$conf["replaceLike"],字串,預設為"false",代表要完全符合關鍵字才能進行整行替換;反之為"true".
5235
	#$conf["replaceLike"]="false";
5236
	#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
5237
	#$conf["addToTailWhenNoMatch"]="false";
5238
	#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
5239
	#$conf["addToTailBeforeThat"]="?\>";
5240
	#$conf["replaceSpecifyLine"],字串陣列,將指定的行取代成指定的內容,元素的key為原始檔案的行索引,若key為$i+1,則代表第$i行;元素的數值就為該行的新內容.
5241
	#$conf["fileAccess::updateFile"]["replaceSpecifyLine"]=$replaceSpecifyLine;
5242
	#$conf["outputPath"],字串,檔案要輸出到哪個位置,預設不指定,直接取代原始檔案的內容.
5243
	$conf["fileAccess::updateFile"]["outputPath"]=$outputPath;
5244
	#參考資料:
5245
	#無.
5246
	#備註:
5247
	#無.
5248
	$updateFile=fileAccess::updateFile($conf["fileAccess::updateFile"]);
5249
	unset($conf["fileAccess::updateFile"]);
5250
 
5251
	#如果出錯
5252
	if($updateFile["status"]==="false"){
5253
 
5254
		#設置錯誤識別
5255
		$result["status"]="false";
5256
 
5257
		#設置錯誤訊息
5258
		$result["error"]=$updateFile;
5259
 
5260
		#回傳結果
5261
		return $result;
5262
 
5263
		}#if end
5264
 
5265
	#輸出json結果
5266
	echo json_encode($updateFile["content"]);
5267
 
5268
	}#if end
5269
 
5270
PHP;
5271
 
5272
						#要多執行序執行的程式
5273
						#$cmdString
5274
 
5275
						#函式說明:
5276
						#透過 unix socket 來多執行序運作.
5277
						#回傳結果:
5278
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5279
						#$reuslt["error"],執行不正常結束的錯訊息陣列.
5280
						#$result["function"],當前執行的函式名稱.
5281
						#$result["argu"],使用的參數.
5282
						#$result["content"],陣列,每個元素為cmds參數中個別元素其指令傳送後得到的uuid,可透過sock::getProcInfo來查詢結果.
5283
						#必填參數:
5284
						#$conf["cmds"],字串陣列,每個元素代表要執行的指令與參數.
5285
						$conf["threads::socket"]["cmds"][]=array("php","-r",$cmdString);
5286
						#可省略參數:
5287
						#$conf["sock"],字串,要連線的 usr/bin/qbpwcf-sock.php 所產生的 unix domain socket 路徑與名稱,預設為 qbpwcf_usock_path.
5288
						#$conf["sock"]=qbpwcf_usock_path;
5289
						#參考資料:
5290
						#無
5291
						#備註:
5292
						#需要透過sock::unixDomainSockServer來運行.
5293
						$socket=threads::socket($conf["threads::socket"]);
5294
						unset($conf["threads::socket"]);
5295
 
5296
						#如果出錯
5297
						if($socket["status"]==="false"){
5298
 
5299
							#設置錯誤識別
5300
							$result["status"]="false";
5301
 
5302
							#設置錯誤訊息
5303
							$result["error"]=$socket;
5304
 
5305
							#印出json
5306
							echo json_encode($result);
5307
 
5308
							#結束執行,回傳1給shell,代表異常,
5309
							exit(1);
5310
 
5311
							}#if end
5312
 
5313
						#儲存要查看運行狀況的程序
5314
						$procs[]=$socket["content"][0];
5315
 
5316
						}#else end
5317
 
3 liveuser 5318
					}#if end
226 liveuser 5319
 
240 liveuser 5320
				}#foreach end
5321
 
5322
			}#foreach end
5323
 
5324
		#debug
5325
		#var_dump(__FUNCTION__,__LINE__,print_r($conf,true));exit;
5326
 
5327
		#如果有啟用多執行序
5328
		if($conf["multiThread"]==="true"){
5329
 
5330
			#如果有執行的程序要確認回饋
5331
			if(isset($procs)){
5332
 
3 liveuser 5333
				#無窮迴圈
5334
				while(true){
226 liveuser 5335
 
3 liveuser 5336
					#如果有開啟 log
5337
					if(isset($conf["log"])){
226 liveuser 5338
 
3 liveuser 5339
						#要記錄的log
5340
						$log="There are ".count($procs)." process under path of ".$conf["searchPath"][0]." unend.".PHP_EOL;
226 liveuser 5341
 
3 liveuser 5342
						#log的路徑與名稱
5343
						$path="/tmp/".basename($conf["log"]).":".$uuid.".log";
226 liveuser 5344
 
3 liveuser 5345
						#log for latest running 的路徑與名稱
5346
						$logPathForLatestRunning="/tmp/".basename($conf["log"]).":".$uuid."-latest.log";
226 liveuser 5347
 
3 liveuser 5348
						#函式說明:
5349
						#撰寫log
5350
						#回傳結果:
5351
						#$result["status"],狀態,"true"或"false".
5352
						#$result["error"],錯誤訊息陣列.
5353
						#$result["function"],當前函式的名稱.
5354
						#$result["argu"],使用的參數.
5355
						#必填參數:
5356
						#$conf["path"],字串,log檔案的路徑與名稱.
5357
						$conf["logs::record"]["path"]=$path;
5358
						#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
316 liveuser 5359
						$conf["logs::record"]["content"]=$log.PHP_EOL;
3 liveuser 5360
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5361
						$conf["logs::record"]["fileArgu"]=__FILE__;
5362
						#可省略參數:
5363
						#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
5364
						#$conf["rewrite"]="false";
5365
						#參考資料:
5366
						#無.
5367
						#備註:
5368
						#無.
5369
						$record=logs::record($conf["logs::record"]);
5370
						unset($conf["logs::record"]);
226 liveuser 5371
 
3 liveuser 5372
						#如果出錯
5373
						if($record["status"]==="false"){
226 liveuser 5374
 
3 liveuser 5375
							#設置錯誤識別
5376
							$result["status"]="false";
226 liveuser 5377
 
3 liveuser 5378
							#設置錯誤訊息
5379
							$result["error"]=$record;
226 liveuser 5380
 
3 liveuser 5381
							#印出json
5382
							echo json_encode($result);
226 liveuser 5383
 
3 liveuser 5384
							#結束執行,回傳1給shell,代表異常,
5385
							exit(1);
226 liveuser 5386
 
3 liveuser 5387
							}#if end
226 liveuser 5388
 
3 liveuser 5389
						}#if end
226 liveuser 5390
 
3 liveuser 5391
					#針對每個要確認的程序
5392
					foreach($procs as $procIndex => $procValue){
226 liveuser 5393
 
3 liveuser 5394
						#判斷多執行序的類型
5395
						switch($threadType){
226 liveuser 5396
 
3 liveuser 5397
							#如果是直接透過 proc
5398
							case "proc":
226 liveuser 5399
 
3 liveuser 5400
								#函式說明:
5401
								#更新透過proc執行的多程序資訊.
5402
								#回傳結果:
5403
								#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
5404
								#$reuslt["error"],執行不正常結束的錯訊息陣列.
5405
								#$result["function"],當前執行的函式名稱.
5406
								#$result["argu"],使用的參數.
5407
								#$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"代表程序的資訊.
5408
								#必填參數:
5409
								#$conf["procs"],陣列,運行self::proc後回傳的content.
5410
								$conf["threads::proc_update"]["procs"]=$procValue["content"];
5411
								#可省略參數:
5412
								#無.
5413
								#參考資料:
5414
								#無.
5415
								#備註:
5416
								#無.
5417
								$proc_update=threads::proc_update($conf["threads::proc_update"]);
5418
								unset($conf["threads::proc_update"]);
226 liveuser 5419
 
3 liveuser 5420
								#如果執行失敗
5421
								if($proc_update["status"]==="false"){
226 liveuser 5422
 
3 liveuser 5423
									#關閉程序
5424
									proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5425
 
3 liveuser 5426
									#設置錯誤識別
5427
									$result["status"]="false";
226 liveuser 5428
 
3 liveuser 5429
									#設置錯誤訊息
5430
									$result["error"]=$procValue;
226 liveuser 5431
 
3 liveuser 5432
									#印出json
5433
									echo json_encode($result);
226 liveuser 5434
 
3 liveuser 5435
									#卸除異常的程序
5436
									unset($procs[$procIndex]);
226 liveuser 5437
 
3 liveuser 5438
									#結束執行,回傳1給shell,代表異常,
5439
									exit(1);
226 liveuser 5440
 
3 liveuser 5441
									}#if end
226 liveuser 5442
 
3 liveuser 5443
								#debug
5444
								#var_dump($procValue["content"][0]["statusCode"]);exit;
226 liveuser 5445
 
3 liveuser 5446
								#如果執行失敗
5447
								if($procValue["content"][0]["status"]==="false"){
226 liveuser 5448
 
3 liveuser 5449
									#關閉程序
5450
									proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5451
 
3 liveuser 5452
									#設置錯誤識別
5453
									$result["status"]="false";
226 liveuser 5454
 
3 liveuser 5455
									#設置錯誤訊息
5456
									$result["error"]=$procValue;
226 liveuser 5457
 
3 liveuser 5458
									#印出json
5459
									echo json_encode($result);
226 liveuser 5460
 
3 liveuser 5461
									#卸除異常的程序
5462
									unset($procs[$procIndex]);
226 liveuser 5463
 
3 liveuser 5464
									#結束執行,回傳1給shell,代表異常,
5465
									exit(1);
226 liveuser 5466
 
3 liveuser 5467
									}#if end
226 liveuser 5468
 
3 liveuser 5469
								#如果可能尚在執行中
5470
								if($procValue["content"][0]["statusCode"]==="?"){
226 liveuser 5471
 
3 liveuser 5472
									#debug
5473
									#var_dump($procValue["content"][0]["statusCode"]);exit(1);
226 liveuser 5474
 
3 liveuser 5475
									#如果有要log
5476
									if(isset($conf["log"])){
226 liveuser 5477
 
3 liveuser 5478
										#要記錄的log
5479
										$log=$procValue["content"][0];
226 liveuser 5480
 
3 liveuser 5481
										#函式說明:
5482
										#撰寫log
5483
										#回傳結果:
5484
										#$result["status"],狀態,"true"或"false".
5485
										#$result["error"],錯誤訊息陣列.
5486
										#$result["function"],當前函式的名稱.
5487
										#$result["argu"],使用的參數.
5488
										#必填參數:
5489
										#$conf["path"],字串,log檔案的路徑與名稱.
5490
										$conf["logs::record"]["path"]=$logPathForLatestRunning;
5491
										#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
316 liveuser 5492
										$conf["logs::record"]["content"]=$log.PHP_EOL;
3 liveuser 5493
										#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5494
										$conf["logs::record"]["fileArgu"]=__FILE__;
5495
										#可省略參數:
5496
										#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
5497
										$conf["logs::record"]["rewrite"]="true";
5498
										#參考資料:
5499
										#無.
5500
										#備註:
5501
										#無.
5502
										$record=logs::record($conf["logs::record"]);
5503
										unset($conf["logs::record"]);
226 liveuser 5504
 
3 liveuser 5505
										#如果出錯
5506
										if($record["status"]==="false"){
226 liveuser 5507
 
3 liveuser 5508
											#關閉程序
5509
											proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5510
 
3 liveuser 5511
											#卸除異常的程序
5512
											unset($procs[$procIndex]);
226 liveuser 5513
 
3 liveuser 5514
											#設置錯誤識別
5515
											$result["status"]="false";
226 liveuser 5516
 
3 liveuser 5517
											#設置錯誤訊息
5518
											$result["error"]=$record;
226 liveuser 5519
 
3 liveuser 5520
											#印出json
5521
											echo json_encode($result);
226 liveuser 5522
 
3 liveuser 5523
											#結束執行,回傳1給shell,代表異常,
5524
											exit(1);
226 liveuser 5525
 
3 liveuser 5526
											}#if end
226 liveuser 5527
 
3 liveuser 5528
										}#if end
226 liveuser 5529
 
3 liveuser 5530
									#$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"代表程序的資訊.
226 liveuser 5531
 
3 liveuser 5532
									#如果錯誤訊息目前為resource,亦即pipe
5533
									if(gettype($procValue["content"][0]["error"])==="resource"){
226 liveuser 5534
 
3 liveuser 5535
										#取得錯誤輸出
5536
										$stderr=stream_get_contents($procValue["content"][0]["error"]);
226 liveuser 5537
 
3 liveuser 5538
										#如果有錯誤訊息存在
5539
										if(!empty($stderr)){
226 liveuser 5540
 
3 liveuser 5541
											#如果有要log
5542
											if(isset($conf["log"])){
226 liveuser 5543
 
3 liveuser 5544
												#要記錄的log
5545
												$log=$stderr;
226 liveuser 5546
 
3 liveuser 5547
												#函式說明:
5548
												#撰寫log
5549
												#回傳結果:
5550
												#$result["status"],狀態,"true"或"false".
5551
												#$result["error"],錯誤訊息陣列.
5552
												#$result["function"],當前函式的名稱.
5553
												#$result["argu"],使用的參數.
5554
												#必填參數:
5555
												#$conf["path"],字串,log檔案的路徑與名稱.
5556
												$conf["logs::record"]["path"]=$conf["log"];
5557
												#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
316 liveuser 5558
												$conf["logs::record"]["content"]=$log.PHP_EOL;
3 liveuser 5559
												#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5560
												$conf["logs::record"]["fileArgu"]=__FILE__;
5561
												#可省略參數:
5562
												#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
5563
												#$conf["rewrite"]="false";
5564
												#參考資料:
5565
												#無.
5566
												#備註:
5567
												#無.
5568
												$record=logs::record($conf["logs::record"]);
5569
												unset($conf["logs::record"]);
226 liveuser 5570
 
3 liveuser 5571
												#如果出錯
5572
												if($record["status"]==="false"){
226 liveuser 5573
 
3 liveuser 5574
													#關閉程序
5575
													proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5576
 
3 liveuser 5577
													#設置錯誤識別
5578
													$result["status"]="false";
226 liveuser 5579
 
3 liveuser 5580
													#設置錯誤訊息
5581
													$result["error"]=$record;
226 liveuser 5582
 
3 liveuser 5583
													#印出json
5584
													echo json_encode($result);
226 liveuser 5585
 
3 liveuser 5586
													#卸除異常的程序
5587
													unset($procs[$procIndex]);
226 liveuser 5588
 
3 liveuser 5589
													#結束執行,回傳1給shell,代表異常,
5590
													exit(1);
226 liveuser 5591
 
3 liveuser 5592
													}#if end
226 liveuser 5593
 
3 liveuser 5594
												#關閉程序
5595
												proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5596
 
3 liveuser 5597
												#設置錯誤識別
5598
												$result["status"]="false";
226 liveuser 5599
 
3 liveuser 5600
												#設置錯誤訊息
5601
												$result["error"][]=$record;
226 liveuser 5602
 
3 liveuser 5603
												#設置錯誤訊息
5604
												$result["error"][]=$stderr;
226 liveuser 5605
 
3 liveuser 5606
												#印出json
5607
												echo json_encode($result);
226 liveuser 5608
 
3 liveuser 5609
												#卸除異常的程序
5610
												unset($procs[$procIndex]);
226 liveuser 5611
 
3 liveuser 5612
												#結束執行,回傳1給shell,代表異常,
5613
												exit(1);
226 liveuser 5614
 
3 liveuser 5615
												}#if end
226 liveuser 5616
 
3 liveuser 5617
											}#if ene
226 liveuser 5618
 
3 liveuser 5619
										}#if end
226 liveuser 5620
 
3 liveuser 5621
									#反之為字串
5622
									else{
226 liveuser 5623
 
3 liveuser 5624
										#取得錯誤輸出
5625
										$stderr=$procValue["content"][0]["error"];
226 liveuser 5626
 
3 liveuser 5627
										#如果有錯誤訊息存在
5628
										if(!empty($stderr)){
226 liveuser 5629
 
3 liveuser 5630
											#如果有要log
5631
											if(isset($conf["log"])){
226 liveuser 5632
 
3 liveuser 5633
												#要記錄的log
5634
												$log=$stderr;
226 liveuser 5635
 
3 liveuser 5636
												#函式說明:
5637
												#撰寫log
5638
												#回傳結果:
5639
												#$result["status"],狀態,"true"或"false".
5640
												#$result["error"],錯誤訊息陣列.
5641
												#$result["function"],當前函式的名稱.
5642
												#$result["argu"],使用的參數.
5643
												#必填參數:
5644
												#$conf["path"],字串,log檔案的路徑與名稱.
5645
												$conf["logs::record"]["path"]=$conf["log"];
5646
												#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
316 liveuser 5647
												$conf["logs::record"]["content"]=$log.PHP_EOL;
3 liveuser 5648
												#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
5649
												$conf["logs::record"]["fileArgu"]=__FILE__;
5650
												#可省略參數:
5651
												#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
5652
												#$conf["rewrite"]="false";
5653
												#參考資料:
5654
												#無.
5655
												#備註:
5656
												#無.
5657
												$record=logs::record($conf["logs::record"]);
5658
												unset($conf["logs::record"]);
226 liveuser 5659
 
3 liveuser 5660
												#如果出錯
5661
												if($record["status"]==="false"){
226 liveuser 5662
 
3 liveuser 5663
													#關閉程序
5664
													proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5665
 
3 liveuser 5666
													#設置錯誤識別
5667
													$result["status"]="false";
226 liveuser 5668
 
3 liveuser 5669
													#設置錯誤訊息
5670
													$result["error"]=$record;
226 liveuser 5671
 
3 liveuser 5672
													#印出json
5673
													echo json_encode($result);
226 liveuser 5674
 
3 liveuser 5675
													#卸除異常的程序
5676
													unset($procs[$procIndex]);
226 liveuser 5677
 
3 liveuser 5678
													#結束執行,回傳1給shell,代表異常,
5679
													exit(1);
226 liveuser 5680
 
3 liveuser 5681
													}#if end
226 liveuser 5682
 
3 liveuser 5683
												#關閉程序
5684
												proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5685
 
3 liveuser 5686
												#設置錯誤識別
5687
												$result["status"]="false";
226 liveuser 5688
 
3 liveuser 5689
												#設置錯誤訊息
5690
												$result["error"][]=$record;
226 liveuser 5691
 
3 liveuser 5692
												#設置錯誤訊息
5693
												$result["error"][]=$stderr;
226 liveuser 5694
 
3 liveuser 5695
												#印出json
5696
												echo json_encode($result);
226 liveuser 5697
 
3 liveuser 5698
												#卸除異常的程序
5699
												unset($procs[$procIndex]);
226 liveuser 5700
 
3 liveuser 5701
												#結束執行,回傳1給shell,代表異常,
5702
												exit(1);
226 liveuser 5703
 
3 liveuser 5704
												}#if end
226 liveuser 5705
 
3 liveuser 5706
											}#if ene
226 liveuser 5707
 
3 liveuser 5708
										}#else end
226 liveuser 5709
 
3 liveuser 5710
									#跳過該子程序
5711
									continue 2;
226 liveuser 5712
 
3 liveuser 5713
									}#if end
226 liveuser 5714
 
3 liveuser 5715
								#反之可能為執行結束了,且執行異常
5716
								else if($procValue["content"][0]["statusCode"]!==0){
226 liveuser 5717
 
3 liveuser 5718
									#關閉程序
5719
									proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5720
 
3 liveuser 5721
									#設置錯誤識別
5722
									$result["status"]="false";
226 liveuser 5723
 
3 liveuser 5724
									#設置錯誤訊息
5725
									$result["error"]=$procValue;
226 liveuser 5726
 
3 liveuser 5727
									#印出json
5728
									echo json_encode($result);
226 liveuser 5729
 
3 liveuser 5730
									#卸除異常的程序
5731
									unset($procs[$procIndex]);
226 liveuser 5732
 
3 liveuser 5733
									#結束執行,回傳1給shell,代表異常,
5734
									exit(1);
226 liveuser 5735
 
3 liveuser 5736
									}#if end
226 liveuser 5737
 
3 liveuser 5738
								#反之執行正常
5739
								else{
226 liveuser 5740
 
3 liveuser 5741
									#debug
5742
									#var_dump($procValue["content"][0]["statusCode"]);
226 liveuser 5743
 
3 liveuser 5744
									#儲存程序執行的標準輸出
5745
									$threadStdOut=$procValue["content"][0]["content"];
226 liveuser 5746
 
3 liveuser 5747
									#如果標準輸出不是json
5748
									if(json_validate($threadStdOut)===false){
226 liveuser 5749
 
3 liveuser 5750
										#關閉程序
5751
										proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5752
 
3 liveuser 5753
										#設置錯誤識別
5754
										$result["status"]="false";
226 liveuser 5755
 
3 liveuser 5756
										#設置錯誤訊息
5757
										$result["error"]=$procValue;
226 liveuser 5758
 
3 liveuser 5759
										#印出json
5760
										echo json_encode($result);
226 liveuser 5761
 
3 liveuser 5762
										#卸除異常的程序
5763
										unset($procs[$procIndex]);
226 liveuser 5764
 
3 liveuser 5765
										#結束執行,回傳1給shell,代表異常,
5766
										exit(1);
226 liveuser 5767
 
3 liveuser 5768
										}#if end
226 liveuser 5769
 
3 liveuser 5770
									#取得解析的json
5771
									$updateCopyRightYear=(array)(json_decode($threadStdOut));
226 liveuser 5772
 
3 liveuser 5773
									#如果執行失敗
5774
									if($updateCopyRightYear["status"]==="false"){
226 liveuser 5775
 
3 liveuser 5776
										#關閉程序
5777
										proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5778
 
3 liveuser 5779
										#設置錯誤識別
5780
										$result["status"]="false";
226 liveuser 5781
 
3 liveuser 5782
										#設置錯誤訊息
5783
										$result["error"]=$updateCopyRightYear;
226 liveuser 5784
 
3 liveuser 5785
										#印出json
5786
										echo json_encode($result);
226 liveuser 5787
 
3 liveuser 5788
										#卸除異常的程序
5789
										unset($procs[$procIndex]);
226 liveuser 5790
 
3 liveuser 5791
										#結束執行,回傳1給shell,代表異常,
5792
										exit(1);
226 liveuser 5793
 
3 liveuser 5794
										}#if end
226 liveuser 5795
 
5796
									#記錄有掃描的資料夾路徑與名稱
3 liveuser 5797
									$result["scannedFile"][]=$NodePathAndName;
226 liveuser 5798
 
3 liveuser 5799
									#合併 content - start
226 liveuser 5800
 
3 liveuser 5801
									#函式說明:
5802
									#將多個一維陣列串聯起來,key從0開始排序.
5803
									#回傳的結果:
5804
									#$result["status"],"true"表執行正常,"false"代表執行不正常.
5805
									#$result["error"],錯誤訊息陣列.
5806
									#$result["function"],當前執行的函數.
5807
									#$result["content"],合併好的一維陣列.
5808
									#必填參數
5809
									#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
5810
									$conf["arrays::mergeArray"]["inputArray"]=array($result["content"],$updateCopyRightYear["content"]);
5811
									#可省略參數:
5812
									#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
5813
									#$conf["allowRepeat"]="true";
5814
									#參考資料:
5815
									#無.
5816
									#備註:
5817
									#無.
5818
									$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
5819
									unset($conf["arrays::mergeArray"]);
226 liveuser 5820
 
3 liveuser 5821
									#如果執行失敗
5822
									if($mergeArray["status"]==="false"){
226 liveuser 5823
 
3 liveuser 5824
										#關閉程序
5825
										proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5826
 
3 liveuser 5827
										#設置錯誤識別
5828
										$result["status"]="false";
226 liveuser 5829
 
3 liveuser 5830
										#設置錯誤訊息
5831
										$result["error"]=$mergeArray;
226 liveuser 5832
 
3 liveuser 5833
										#印出json
5834
										echo json_encode($result);
226 liveuser 5835
 
3 liveuser 5836
										#卸除異常的程序
5837
										unset($procs[$procIndex]);
226 liveuser 5838
 
3 liveuser 5839
										#結束執行,回傳1給shell,代表異常,
5840
										exit(1);
226 liveuser 5841
 
3 liveuser 5842
										}#if end
226 liveuser 5843
 
3 liveuser 5844
									#取得合併好的有異動檔案結果
5845
									$result["content"]=$mergeArray["content"];
226 liveuser 5846
 
3 liveuser 5847
									#合併 content - end
226 liveuser 5848
 
3 liveuser 5849
									#合併 scannedFile - start
226 liveuser 5850
 
3 liveuser 5851
									if(isset($updateCopyRightYear["scannedFile"])){
226 liveuser 5852
 
3 liveuser 5853
										#函式說明:
5854
										#將多個一維陣列串聯起來,key從0開始排序.
5855
										#回傳的結果:
5856
										#$result["status"],"true"表執行正常,"false"代表執行不正常.
5857
										#$result["error"],錯誤訊息陣列.
5858
										#$result["function"],當前執行的函數.
5859
										#$result["content"],合併好的一維陣列.
5860
										#必填參數
5861
										#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
5862
										$conf["arrays::mergeArray"]["inputArray"]=array($result["scannedFile"],$updateCopyRightYear["scannedFile"]);
5863
										#可省略參數:
5864
										#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
5865
										#$conf["allowRepeat"]="true";
5866
										#參考資料:
5867
										#無.
5868
										#備註:
5869
										#無.
5870
										$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
5871
										unset($conf["arrays::mergeArray"]);
226 liveuser 5872
 
3 liveuser 5873
										#如果執行失敗
5874
										if($mergeArray["status"]==="false"){
226 liveuser 5875
 
3 liveuser 5876
											#關閉程序
5877
											proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5878
 
3 liveuser 5879
											#設置錯誤識別
5880
											$result["status"]="false";
226 liveuser 5881
 
3 liveuser 5882
											#設置錯誤訊息
5883
											$result["error"]=$mergeArray;
226 liveuser 5884
 
3 liveuser 5885
											#印出json
5886
											echo json_encode($result);
226 liveuser 5887
 
3 liveuser 5888
											#卸除異常的程序
5889
											unset($procs[$procIndex]);
226 liveuser 5890
 
3 liveuser 5891
											#結束執行,回傳1給shell,代表異常,
5892
											exit(1);
226 liveuser 5893
 
3 liveuser 5894
											}#if end
226 liveuser 5895
 
3 liveuser 5896
										#取得合併好的有異動檔案結果
5897
										$result["scannedFile"]=$mergeArray["content"];
226 liveuser 5898
 
3 liveuser 5899
										}#if end
226 liveuser 5900
 
3 liveuser 5901
									#合併 scannedFile - end
226 liveuser 5902
 
3 liveuser 5903
									#關閉程序
5904
									proc_close($procs[$procIndex]["content"][0]["process"]);
226 liveuser 5905
 
3 liveuser 5906
									#卸除做好的程序
5907
									unset($procs[$procIndex]);
226 liveuser 5908
 
3 liveuser 5909
									}#else end
226 liveuser 5910
 
3 liveuser 5911
								#end switch
5912
								break;
226 liveuser 5913
 
3 liveuser 5914
							#如果是透過socket
5915
							case "socket":
226 liveuser 5916
 
220 liveuser 5917
								#取得 proc 的 uuid
240 liveuser 5918
								$procUuid=$procValue;
226 liveuser 5919
 
3 liveuser 5920
								#函式說明:
5921
								#詢問透過 sock::unixDomainSockServer 執行的程序狀況
5922
								#回傳結果:
5923
								#$result["status"],"true"代表執行正常;"false"代表執行不正常.
5924
								#$result["error"],錯誤訊息陣列.
5925
								#$result["function"],當前執行的函式名稱.
5926
								#$result["argu"],使用的參數.
5927
								#$result["content"],陣列,程序的資訊.
5928
								#$result["content"]["pid"],字串,程序的pid.
5929
								#$result["content"]["running"],字串,是否正常執行中.
5930
								#$result["content"]["statusCode"],字串,回傳給 shell 的代碼.
5931
								#$result["content"]["input"],字串,輸入的內容.
5932
								#$result["content"]["output"],字串,標準輸出的內容.
5933
								#$result["content"]["error"],字串,錯誤輸出的內容.
5934
								#必填參數:
5935
								#$conf["uuid"],字串,proc的uuid.
5936
								$conf["sock::getProcInfo"]["uuid"]=$procUuid;
5937
								#可省略參數:
5938
								#$conf["sock"],字串,要連線的 usr/bin/qbpwcf-sock.php(sock::unixDomainSockServer) 所產生的 unix domain socket 路徑與名稱,預設為 qbpwcf_usock_path.
5939
								$conf["sock::getProcInfo"]["sock"]=$conf["socket"];
5940
								#參考資料:
5941
								#無.
5942
								#備註:
5943
								#無.
5944
								$getProcInfo=sock::getProcInfo($conf["sock::getProcInfo"]);
5945
								unset($conf["sock::getProcInfo"]);
5946
 
5947
								#debug
5948
								if($getProcInfo["status"]==="false"){
5949
 
5950
									#設置錯誤識別
5951
									$result["status"]="false";
226 liveuser 5952
 
3 liveuser 5953
									#設置錯誤訊息
5954
									$result["error"][]="get process info by uuid failed";
226 liveuser 5955
 
3 liveuser 5956
									#設置錯誤訊息
5957
									$result["error"][]=$getProcInfo;
226 liveuser 5958
 
3 liveuser 5959
									#印出json
5960
									echo json_encode($result);
5961
 
5962
									}#if end
226 liveuser 5963
 
3 liveuser 5964
								#如果已經停止運行
5965
								if($getProcInfo["content"]["running"]==="false"){
226 liveuser 5966
 
3 liveuser 5967
									#儲存程序執行的標準輸出
5968
									$threadStdOut=$getProcInfo["content"]["output"];
226 liveuser 5969
 
3 liveuser 5970
									#如果標準輸出不是json
5971
									if(json_validate($threadStdOut)===false){
226 liveuser 5972
 
3 liveuser 5973
										#設置錯誤識別
5974
										$result["status"]="false";
226 liveuser 5975
 
3 liveuser 5976
										#設置錯誤訊息
5977
										$result["error"]=$procValue;
226 liveuser 5978
 
3 liveuser 5979
										#印出json
5980
										echo json_encode($result);
226 liveuser 5981
 
3 liveuser 5982
										#卸除異常的程序
5983
										unset($procs[$procIndex]);
226 liveuser 5984
 
3 liveuser 5985
										#結束執行,回傳1給shell,代表異常,
5986
										exit(1);
226 liveuser 5987
 
3 liveuser 5988
										}#if end
226 liveuser 5989
 
3 liveuser 5990
									#取得解析的json
5991
									$updateCopyRightYear=(array)(json_decode($threadStdOut));
226 liveuser 5992
 
3 liveuser 5993
									#如果執行失敗
5994
									if($updateCopyRightYear["status"]==="false"){
226 liveuser 5995
 
3 liveuser 5996
										#設置錯誤識別
5997
										$result["status"]="false";
226 liveuser 5998
 
3 liveuser 5999
										#設置錯誤訊息
6000
										$result["error"]=$updateCopyRightYear;
226 liveuser 6001
 
3 liveuser 6002
										#印出json
6003
										echo json_encode($result);
226 liveuser 6004
 
3 liveuser 6005
										#卸除異常的程序
6006
										unset($procs[$procIndex]);
226 liveuser 6007
 
3 liveuser 6008
										#結束執行,回傳1給shell,代表異常,
6009
										exit(1);
226 liveuser 6010
 
3 liveuser 6011
										}#if end
226 liveuser 6012
 
6013
									#記錄有掃描的資料夾路徑與名稱
3 liveuser 6014
									$result["scannedFile"][]=$NodePathAndName;
226 liveuser 6015
 
3 liveuser 6016
									#合併 content - start
226 liveuser 6017
 
3 liveuser 6018
									#函式說明:
6019
									#將多個一維陣列串聯起來,key從0開始排序.
6020
									#回傳的結果:
6021
									#$result["status"],"true"表執行正常,"false"代表執行不正常.
6022
									#$result["error"],錯誤訊息陣列.
6023
									#$result["function"],當前執行的函數.
6024
									#$result["content"],合併好的一維陣列.
6025
									#必填參數
6026
									#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
6027
									$conf["arrays::mergeArray"]["inputArray"]=array($result["content"],$updateCopyRightYear["content"]);
6028
									#可省略參數:
6029
									#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
6030
									#$conf["allowRepeat"]="true";
6031
									#參考資料:
6032
									#無.
6033
									#備註:
6034
									#無.
6035
									$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
6036
									unset($conf["arrays::mergeArray"]);
226 liveuser 6037
 
3 liveuser 6038
									#如果執行失敗
6039
									if($mergeArray["status"]==="false"){
226 liveuser 6040
 
3 liveuser 6041
										#設置錯誤識別
6042
										$result["status"]="false";
226 liveuser 6043
 
3 liveuser 6044
										#設置錯誤訊息
6045
										$result["error"]=$mergeArray;
226 liveuser 6046
 
3 liveuser 6047
										#印出json
6048
										echo json_encode($result);
226 liveuser 6049
 
3 liveuser 6050
										#卸除異常的程序
6051
										unset($procs[$procIndex]);
226 liveuser 6052
 
220 liveuser 6053
										#結束執行,回傳1給shell,代表異常.
3 liveuser 6054
										exit(1);
226 liveuser 6055
 
3 liveuser 6056
										}#if end
226 liveuser 6057
 
3 liveuser 6058
									#取得合併好的有異動檔案結果
6059
									$result["content"]=$mergeArray["content"];
226 liveuser 6060
 
3 liveuser 6061
									#合併 content - end
226 liveuser 6062
 
3 liveuser 6063
									#合併 scannedFile - start
226 liveuser 6064
 
3 liveuser 6065
									if(isset($updateCopyRightYear["scannedFile"])){
226 liveuser 6066
 
3 liveuser 6067
										#函式說明:
6068
										#將多個一維陣列串聯起來,key從0開始排序.
6069
										#回傳的結果:
6070
										#$result["status"],"true"表執行正常,"false"代表執行不正常.
6071
										#$result["error"],錯誤訊息陣列.
6072
										#$result["function"],當前執行的函數.
6073
										#$result["content"],合併好的一維陣列.
6074
										#必填參數
6075
										#$conf["inputArray"],陣列,要合併的一維陣列變數,例如:=array($array1,$array2);
6076
										$conf["arrays::mergeArray"]["inputArray"]=array($result["scannedFile"],$updateCopyRightYear["scannedFile"]);
6077
										#可省略參數:
6078
										#$conf["allowRepeat"],字串,預設為"true",允許重複的結果;若為"false"則不會出現重複的元素內容.
6079
										#$conf["allowRepeat"]="true";
6080
										#參考資料:
6081
										#無.
6082
										#備註:
6083
										#無.
6084
										$mergeArray=arrays::mergeArray($conf["arrays::mergeArray"]);
6085
										unset($conf["arrays::mergeArray"]);
226 liveuser 6086
 
3 liveuser 6087
										#如果執行失敗
6088
										if($mergeArray["status"]==="false"){
226 liveuser 6089
 
3 liveuser 6090
											#設置錯誤識別
6091
											$result["status"]="false";
226 liveuser 6092
 
3 liveuser 6093
											#設置錯誤訊息
6094
											$result["error"]=$mergeArray;
226 liveuser 6095
 
3 liveuser 6096
											#印出json
6097
											echo json_encode($result);
226 liveuser 6098
 
3 liveuser 6099
											#卸除異常的程序
6100
											unset($procs[$procIndex]);
226 liveuser 6101
 
3 liveuser 6102
											#結束執行,回傳1給shell,代表異常,
6103
											exit(1);
226 liveuser 6104
 
3 liveuser 6105
											}#if end
226 liveuser 6106
 
3 liveuser 6107
										#取得合併好的有異動檔案結果
6108
										$result["scannedFile"]=$mergeArray["content"];
226 liveuser 6109
 
3 liveuser 6110
										}#if end
226 liveuser 6111
 
3 liveuser 6112
									#合併 scannedFile - end
226 liveuser 6113
 
3 liveuser 6114
									#卸除做好的程序
6115
									unset($procs[$procIndex]);
226 liveuser 6116
 
3 liveuser 6117
									}#if end
226 liveuser 6118
 
3 liveuser 6119
								#end switch
6120
								break;
226 liveuser 6121
 
3 liveuser 6122
							#其他類型
6123
							default:
226 liveuser 6124
 
3 liveuser 6125
								#設置錯誤識別
6126
								$result["status"]="false";
226 liveuser 6127
 
3 liveuser 6128
								#設置錯誤訊息
6129
								$result["error"][]="not supported multi threads type ".$threadType;
226 liveuser 6130
 
3 liveuser 6131
								#印出json
6132
								echo json_encode($result);
226 liveuser 6133
 
3 liveuser 6134
								#結束執行,回傳1給shell,代表異常,
6135
								exit(1);
226 liveuser 6136
 
3 liveuser 6137
							}#switch end
226 liveuser 6138
 
3 liveuser 6139
						}#foreach end
226 liveuser 6140
 
3 liveuser 6141
					#如果已經執行完所有子程序
6142
					if(empty($procs)){
226 liveuser 6143
 
3 liveuser 6144
						#如果有要log
6145
						if(isset($conf["log"])){
226 liveuser 6146
 
3 liveuser 6147
							#函式說明:
6148
							#撰寫log
6149
							#回傳結果:
6150
							#$result["status"],狀態,"true"或"false".
6151
							#$result["error"],錯誤訊息陣列.
6152
							#$result["function"],當前函式的名稱.
6153
							#$result["argu"],使用的參數.
6154
							#必填參數:
6155
							#$conf["path"],字串,log檔案的路徑與名稱.
6156
							$conf["logs::record"]["path"]=$logPathForRunTimeOfStartAndEnd;
6157
							#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
316 liveuser 6158
							$conf["logs::record"]["content"]="end at ".gmdate("Y-m-d H:i:s").PHP_EOL;
3 liveuser 6159
							#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6160
							$conf["logs::record"]["fileArgu"]=__FILE__;
6161
							#可省略參數:
6162
							#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
6163
							#$conf["rewrite"]="false";
6164
							#參考資料:
6165
							#無.
6166
							#備註:
6167
							#無.
6168
							$record=logs::record($conf["logs::record"]);
6169
							unset($conf["logs::record"]);
226 liveuser 6170
 
3 liveuser 6171
							#如果出錯
6172
							if($record["status"]==="false"){
226 liveuser 6173
 
3 liveuser 6174
								#設置錯誤識別
6175
								$result["status"]="false";
226 liveuser 6176
 
3 liveuser 6177
								#設置錯誤訊息
6178
								$result["error"]=$record;
226 liveuser 6179
 
3 liveuser 6180
								#印出json
6181
								echo json_encode($result);
226 liveuser 6182
 
3 liveuser 6183
								#結束執行,回傳1給shell,代表異常,
6184
								exit(1);
226 liveuser 6185
 
3 liveuser 6186
								}#if end
226 liveuser 6187
 
3 liveuser 6188
							}#if end
226 liveuser 6189
 
3 liveuser 6190
						#結束子程序的檢查
6191
						break;
226 liveuser 6192
 
3 liveuser 6193
						}#if end
226 liveuser 6194
 
3 liveuser 6195
					#執行到這邊,代表尚有程序再執行.
226 liveuser 6196
 
316 liveuser 6197
					#如果有開啟 log
3 liveuser 6198
					if(isset($conf["log"])){
226 liveuser 6199
 
316 liveuser 6200
						#函式說明:
6201
						#撰寫log
6202
						#回傳結果:
6203
						#$result["status"],狀態,"true"或"false".
6204
						#$result["error"],錯誤訊息陣列.
6205
						#$result["function"],當前函式的名稱.
6206
						#$result["argu"],使用的參數.
6207
						#必填參數:
6208
						#$conf["path"],字串,log檔案的路徑與名稱.
6209
						$conf["logs::record"]["path"]=$conf["log"];
6210
						#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
6211
						$conf["logs::record"]["content"]="waiting sub process.".PHP_EOL;
6212
						#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6213
						$conf["logs::record"]["fileArgu"]=$conf["fileArgu"];
6214
						#可省略參數:
6215
						#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
6216
						#$conf["rewrite"]="false";
6217
						#參考資料:
6218
						#無.
6219
						#備註:
6220
						#無.
6221
						$record=logs::record($conf["logs::record"]);
6222
						unset($conf["logs::record"]);
226 liveuser 6223
 
316 liveuser 6224
						#如果出錯
6225
						if($record["status"]==="false"){
226 liveuser 6226
 
316 liveuser 6227
							#設置錯誤識別
6228
							$result["status"]="false";
6229
 
6230
							#設置錯誤訊息
6231
							$result["error"]=$record;
6232
 
6233
							#印出json
6234
							echo json_encode($result);
6235
 
6236
							#結束執行,回傳1給shell,代表異常,
6237
							exit(1);
6238
 
6239
							}#if end
6240
 
3 liveuser 6241
						}#if end
226 liveuser 6242
 
3 liveuser 6243
					#休息1秒鐘
6244
					sleep(1);
226 liveuser 6245
 
3 liveuser 6246
					}#while end
226 liveuser 6247
 
3 liveuser 6248
				}#if end
226 liveuser 6249
 
3 liveuser 6250
			}#if end
226 liveuser 6251
 
3 liveuser 6252
		#設置執行正常
6253
		$result["status"]="true";
226 liveuser 6254
 
3 liveuser 6255
		#如果是透過多執行序執行
6256
		if($conf["multiThread"]==="true"){
226 liveuser 6257
 
3 liveuser 6258
			#印出json結果
6259
			echo json_encode($result);
226 liveuser 6260
 
3 liveuser 6261
			}#if end
226 liveuser 6262
 
3 liveuser 6263
		#反之
6264
		else{
226 liveuser 6265
 
3 liveuser 6266
			#回傳結果
6267
			return $result;
226 liveuser 6268
 
3 liveuser 6269
			}#else end
226 liveuser 6270
 
3 liveuser 6271
		}#function updateCopyRightYear end
226 liveuser 6272
 
218 liveuser 6273
	/*
6274
	#函式說明:
6275
	#置換檔案內容中符合的內容.
6276
	#回傳結果:
6277
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6278
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
6279
	#$result["function"],當前執行的函式名稱.
6280
	#$result["argu"],本函式使用的參數.
240 liveuser 6281
	#$result["content"],更新後的檔案內容陣列,每個元素代表一行的內容.
218 liveuser 6282
	#$result["found"],字串,是否有找到符合條件需要置換的內容.
6283
	#$result["relaceInfo"],陣列,記錄需要置換的行資訊,元素的key為需要置換的行號,第 $i 行用 $i+1 表示.
220 liveuser 6284
	#$result["relaceInfo"][$i]["deletedOriHead"],字串,第 $i+1 行原始的內容,前面的空白或tab.
6285
	#$result["relaceInfo"][$i]["ori"],字串,第 $i+1 行剔除前面的空白或tab後的原始內容.
6286
	#$result["relaceInfo"][$i]["new"],字串,第 $i+1 行剔除前面的空白或tab後的要置換成的內容.
218 liveuser 6287
	#必填參數:
6288
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6289
	$conf["fileArgu"]=__FILE__;
6290
	#$conf["file"],字串,要置換內容的檔案路徑與名稱.
6291
	$conf["file"]="";
6292
	#$conf["formats"],陣列,連續的關鍵字字串.
6293
	$conf["formats"]=array();
6294
	#$conf["replaceTo"],陣列,原始內容要如何置換,每個元素的索引對應到formats參數的每個元素,若其索引不存在則代表對應的行不異動.
6295
	$conf["replaceTo"]=array();
6296
	#可省略參數:
6297
	#無.
6298
	#參考資料:
6299
	#無.
6300
	#備註:
6301
	#參數設定 $conf["replaceTo"][$i]=$replaceStr; 代表符合格式的連續字串中的 $i+1 行內容要置換成 $replaceStr.
6302
	#參數設定 $conf["replaceTo"][$i]=array("varName1"=>$replaceStr1,"varName2"=>$replaceStr2); 代表符合格式的連續字串中的 $i+1 行內容中的變數 varName1 要置換成 $replaceStr1;變數 varName2 要置換成 $replaceStr2.
6303
	*/
6304
	public static function replaceMatchContent(&$conf){
226 liveuser 6305
 
218 liveuser 6306
		#初始化要回傳的結果
6307
		$result=array();
6308
 
6309
		#取得當前執行的函數名稱
6310
		$result["function"]=__FUNCTION__;
6311
 
6312
		#如果沒有參數
6313
		if(func_num_args()==0){
6314
 
6315
			#設置執行失敗
6316
			$result["status"]="false";
6317
 
6318
			#設置執行錯誤訊息
6319
			$result["error"]="函數".$result["function"]."需要參數";
6320
 
6321
			#回傳結果
6322
			return $result;
6323
 
6324
			}#if end
6325
 
6326
		#取得參數
6327
		$result["argu"]=$conf;
226 liveuser 6328
 
218 liveuser 6329
		#如果 $conf 不為陣列
6330
		if(gettype($conf)!=="array"){
6331
 
6332
			#設置執行失敗
6333
			$result["status"]="false";
6334
 
6335
			#設置執行錯誤訊息
6336
			$result["error"][]="\$conf變數須為陣列形態";
6337
 
6338
			#如果傳入的參數為 null
6339
			if(is_null($conf)){
6340
 
6341
				#設置執行錯誤訊息
6342
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
6343
 
6344
				}#if end
6345
 
6346
			#回傳結果
6347
			return $result;
6348
 
6349
			}#if end
226 liveuser 6350
 
218 liveuser 6351
		#參數檢查
6352
		#函式說明:
6353
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
6354
		#回傳結果:
6355
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6356
		#$result["error"],執行不正常結束的錯訊息陣列.
6357
		#$result["simpleError"],簡單表示的錯誤訊息.
6358
		#$result["function"],當前執行的函式名稱.
6359
		#$result["argu"],設置給予的參數.
6360
		#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
6361
		#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
6362
		#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
6363
		#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
6364
		#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
6365
		#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
6366
		#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
6367
		#$result["notNeedVar"],字串陣列,多餘的參數名稱.
6368
		#必填參數:
6369
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
6370
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
6371
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
6372
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
6373
		#可省略參數:
6374
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
6375
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","file","formats","replaceTo");
6376
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null、any代表不指定變數形態.其中 resource也包含"resource (closed)".
6377
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","array","array");
6378
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
6379
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
6380
		#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
6381
		#$conf["canNotBeEmpty"]=array();
6382
		#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
6383
		#$conf["canBeEmpty"]=array();
6384
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
6385
		#$conf["skipableVariableCanNotBeEmpty"]=array();
6386
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
6387
		#$conf["skipableVariableName"]=array();
6388
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
6389
		#$conf["skipableVariableType"]=array();
6390
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
6391
		#$conf["skipableVarDefaultValue"]=array("");
6392
		#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
6393
		#$conf["disallowAllSkipableVarIsEmpty"]="";
6394
		#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
6395
		#$conf["disallowAllSkipableVarIsEmptyArray"]="";
6396
		#$conf["disallowAllSkipableVarNotExist"],字串,是否不允許每個可省略參數都不存在,預設為"false"代表允許,反之為"true".
6397
		#$conf["disallowAllSkipableVarNotExist"]="";
6398
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
6399
		#$conf["arrayCountEqualCheck"][]=array();
6400
		#參考資料:
6401
		#array_keys=>http://php.net/manual/en/function.array-keys.php
6402
		#備註:
6403
		#無.
6404
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
6405
		unset($conf["variableCheck::checkArguments"]);
226 liveuser 6406
 
218 liveuser 6407
		#如果執行失敗
6408
		if($checkArguments["status"]==="false"){
226 liveuser 6409
 
218 liveuser 6410
			#設置錯誤識別
6411
			$result["status"]="false";
226 liveuser 6412
 
218 liveuser 6413
			#設置錯誤訊息
6414
			$result["error"]=$checkArguments;
226 liveuser 6415
 
218 liveuser 6416
			#回傳結果
6417
			return $result;
226 liveuser 6418
 
218 liveuser 6419
			}#if end
226 liveuser 6420
 
218 liveuser 6421
		#如果檢查參數不通過
6422
		if($checkArguments["passed"]==="false"){
226 liveuser 6423
 
218 liveuser 6424
			#設置錯誤識別
6425
			$result["status"]="false";
226 liveuser 6426
 
218 liveuser 6427
			#設置錯誤訊息
6428
			$result["error"]=$checkArguments;
226 liveuser 6429
 
218 liveuser 6430
			#回傳結果
6431
			return $result;
226 liveuser 6432
 
218 liveuser 6433
			}#if end
226 liveuser 6434
 
218 liveuser 6435
		#取得檔案的內容
6436
		#函式說明:
6437
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
6438
		#回傳的變數說明:
6439
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
6440
		#$result["error"],錯誤訊息提示.
6441
		#$result["warning"],警告訊息.
6442
		#$result["function"],當前執行的函數名稱.
6443
		#$result["fileContent"],爲檔案的內容陣列.
6444
		#$result["lineCount"],爲檔案內容總共的行數.
6445
		#$result["fullContent"],為檔案的完整內容.
6446
		#$result["base64data"],為檔案的base64內容.
6447
		#$result["mimeType"],為檔案的mime type.
6448
		#必填參數:
6449
		#$conf["filePositionAndName"],字串,爲檔案的位置以及名稱.
6450
		$conf["fileAccess::getFileContent"]["filePositionAndName"]=$conf["file"];
6451
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
6452
		$conf["fileAccess::getFileContent"]["fileArgu"]=$conf["fileArgu"];
6453
		#可省略參數:
6454
		#$conf["web"],是要取得網路上的檔案則為"true";反之預設為"false".
6455
		#$conf["web"]="true";
6456
		#$conf["createIfnotExist"],字串,預設為"false"代表檔案不存在也不需要建立;反之為"true".
6457
		#$conf["createIfnotExist"]="false";
6458
		#$conf["autoDeleteSpaceOnEachLineStart"],字串,預設為"false",不做額外處理;反之為"true"
6459
		#$conf["autoDeleteSpaceOnEachLineStart"]="false";
6460
		#參考資料:
6461
		#file(),取得檔案內容的行數.
6462
		#file=>http:#php.net/manual/en/function.file.php
6463
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
6464
		#filesize=>http://php.net/manual/en/function.filesize.php
6465
		#參考資料:
6466
		#無.
6467
		#備註:
6468
		#無.
6469
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
6470
		unset($conf["fileAccess::getFileContent"]);
226 liveuser 6471
 
218 liveuser 6472
		#如果執行失敗
6473
		if($getFileContent["status"]==="false"){
226 liveuser 6474
 
218 liveuser 6475
			#設置錯誤識別
6476
			$result["status"]="false";
226 liveuser 6477
 
218 liveuser 6478
			#設置錯誤訊息
6479
			$result["error"]=$getFileContent;
226 liveuser 6480
 
218 liveuser 6481
			#回傳結果
6482
			return $result;
226 liveuser 6483
 
218 liveuser 6484
			}#if end
226 liveuser 6485
 
218 liveuser 6486
		#尋找連續的多行字串是否依順含有符合格式的內容,且回傳解析好的變數數值.
6487
		#回傳結果:
6488
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6489
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
6490
		#$result["function"],當前執行的函式名稱.
6491
		#$result["argu"],所使用的參數.
6492
		#$result["found"],是否有找到符合格式的連續字串內容,"true"代表有找到,"false"代表沒有找到.
6493
		#$result["content"],陣列,每段符合格式的段落資訊.
6494
		#$result["content"][$i]["lineS"],字串,為第 $i+1 個符合格式的段落起始行數.
6495
		#$result["content"][$i]["ori"],字串,為第 $i+1 個符合格式的段落每行原始內容資訊.
6496
		#$result["content"][$i]["deletedHead"],字串,為第 $i+1 個符合格式的段落每行原始內容被剔除的開頭資訊.
6497
		#$result["content"][$i]["new"],字串,為第 $i+1 個符合格式的段落每行關鍵字內容.
6498
		#$result["content"][$i]["vars"],陣列,為第 $i+1 個符合格式的段落每行變數解析的結果.
6499
		#必填參數:
6500
		#$conf["input"],字串陣列,要檢查的每行字串.
6501
		$conf["search::findConMatchStrs"]["input"]=$getFileContent["fileContent"];
6502
		#$conf["format"],格式字串陣列,要尋找的每行格式字串集合.格式為固定的字串("fixedStr format")與變數("${keyWordVarName}")組成.
6503
		$conf["search::findConMatchStrs"]["formats"]=$conf["formats"];
6504
		#可省略參數:
6505
		#無.
6506
		#參考資料:
6507
		#無.
6508
		#備註:
6509
		#回傳結果 $result["content"][$i]["ori"][$j]=array("index"=>$oriLineIndex,"value"=>$oriLineContent) 代表第 $i+1 個符合格式的段落中第 $j+1 個原始內容對應的行數($oriLineIndex+1),其原始內容為 $oriLineContent.
6510
		$findConMatchStrs=search::findConMatchStrs($conf["search::findConMatchStrs"]);
6511
		unset($conf["search::findConMatchStrs"]);
226 liveuser 6512
 
218 liveuser 6513
		#如果執行失敗
6514
		if($findConMatchStrs["status"]==="false"){
226 liveuser 6515
 
218 liveuser 6516
			#設置錯誤識別
6517
			$result["status"]="false";
226 liveuser 6518
 
218 liveuser 6519
			#設置錯誤訊息
6520
			$result["error"]=$findConMatchStrs;
226 liveuser 6521
 
218 liveuser 6522
			#回傳結果
6523
			return $result;
226 liveuser 6524
 
218 liveuser 6525
			}#if end
226 liveuser 6526
 
218 liveuser 6527
		#如果沒有符合的連續字串格式
6528
		if($findConMatchStrs["found"]==="false"){
226 liveuser 6529
 
218 liveuser 6530
			#設置執行正常的識別
6531
			$result["status"]="true";
226 liveuser 6532
 
218 liveuser 6533
			#設置沒有找到符合格式內容
6534
			$result["found"]="false";
226 liveuser 6535
 
218 liveuser 6536
			#回傳結果
6537
			return $result;
226 liveuser 6538
 
218 liveuser 6539
			}#if end
226 liveuser 6540
 
218 liveuser 6541
		#初始化儲存內容置換資訊的變數
6542
		$result["relaceInfo"]=array();
226 liveuser 6543
 
218 liveuser 6544
		#debug
6545
		#var_dump(__LINE__,$findConMatchStrs["content"]);exit;
226 liveuser 6546
 
218 liveuser 6547
		#執行到這邊代表有遇到符合的連續字串格式
6548
		foreach($findConMatchStrs["content"] as $matchSectionIndex => $sInfo){
226 liveuser 6549
 
218 liveuser 6550
			#針對符合的每行內容
6551
			foreach($sInfo["ori"] as $index => $lInfo){
226 liveuser 6552
 
218 liveuser 6553
				#取得對應的原始行索引
6554
				$oriLineNo=$lInfo["index"];
226 liveuser 6555
 
218 liveuser 6556
				#取得對應的原始行內容
6557
				$oriLineContent=$lInfo["value"];
226 liveuser 6558
 
218 liveuser 6559
				#儲存被剔除的開頭部分
6560
				$deletedOriHead=$lInfo["deletedHead"];
226 liveuser 6561
 
218 liveuser 6562
				#如果沒有對應的要取代格式
6563
				if(!isset($conf["replaceTo"][$index])){
226 liveuser 6564
 
218 liveuser 6565
					#不處理
6566
					continue;
226 liveuser 6567
 
218 liveuser 6568
					}#if end
226 liveuser 6569
 
218 liveuser 6570
				#如果解析的結果有變數
6571
				if(empty($sInfo["vars"][$index])){
226 liveuser 6572
 
218 liveuser 6573
					#debug
6574
					#var_dump(__LINE__,$index,$sInfo["vars"][$index]);
226 liveuser 6575
 
218 liveuser 6576
					#執行到這邊代表有對應的要取代格式
226 liveuser 6577
 
218 liveuser 6578
					#debug
6579
					#var_dump(__LINE__,$index,gettype($conf["replaceTo"][$index]),$conf["replaceTo"]);
226 liveuser 6580
 
218 liveuser 6581
					#如果取代格式不為字串
6582
					if(gettype($conf["replaceTo"][$index])!=="string"){
226 liveuser 6583
 
218 liveuser 6584
						#設置執行不正常的識別
6585
						$result["status"]="false";
226 liveuser 6586
 
218 liveuser 6587
						#設置錯誤訊息
6588
						$result["error"]="參數 formats 跟 replaceTo 的對應有錯誤.";
226 liveuser 6589
 
218 liveuser 6590
						#回傳結果
6591
						return $result;
226 liveuser 6592
 
218 liveuser 6593
						}#if end
226 liveuser 6594
 
218 liveuser 6595
					#執行到這邊代表檢查通過
226 liveuser 6596
 
218 liveuser 6597
					#記錄取代的資訊
6598
					$result["relaceInfo"][$oriLineNo]=array("deletedOriHead"=>$deletedOriHead,"ori"=>$oriLineContent,"new"=>$conf["replaceTo"][$index]);
226 liveuser 6599
 
218 liveuser 6600
					}#if end
226 liveuser 6601
 
218 liveuser 6602
				#反之代表有解析出變數
6603
				else{
226 liveuser 6604
 
218 liveuser 6605
					#debug
6606
					#var_dump(__LINE__,gettype($conf["replaceTo"][$index]));
226 liveuser 6607
 
218 liveuser 6608
					#如果取代格式不為陣列
6609
					if(gettype($conf["replaceTo"][$index])!=="array"){
226 liveuser 6610
 
218 liveuser 6611
						#設置執行不正常的識別
6612
						$result["status"]="false";
226 liveuser 6613
 
218 liveuser 6614
						#設置錯誤訊息
6615
						$result["error"]="參數 formats 跟 replaceTo 的對應有錯誤.";
226 liveuser 6616
 
218 liveuser 6617
						#回傳結果
6618
						return $result;
226 liveuser 6619
 
218 liveuser 6620
						}#if end
226 liveuser 6621
 
218 liveuser 6622
					#執行到這邊代表檢查通過
226 liveuser 6623
 
218 liveuser 6624
					#初始化替換好的內容
6625
					$newLineContent=$oriLineContent;
226 liveuser 6626
 
218 liveuser 6627
					#針對每個解析出來的變數
6628
					foreach($conf["replaceTo"][$index] as $varName => $newVal){
226 liveuser 6629
 
218 liveuser 6630
						#取得原始解析出來的內容
6631
						$oriVal=$sInfo["vars"][$index][$varName][0];
226 liveuser 6632
 
218 liveuser 6633
						#將關鍵字取代
6634
						#函式說明:
6635
						#將字串中的特定內容取代.
6636
						#回傳結果:
6637
						#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
6638
						#$result["function"],當前執行的函數.
6639
						#$result["content"],爲處理好的字串.
6640
						#$result["error"],錯誤訊息陣列.
226 liveuser 6641
						#$result["argu"],使用的參數.
218 liveuser 6642
						#必填參數:
6643
						#$conf["stringIn"],字串,爲要處理的字串
6644
						$conf["stringProcess::replaceOnce"]["stringIn"]=$newLineContent;
6645
						#$conf["selectedCharacter"],字串,爲被選擇要處理的字串/字元,\n」代表換行,「\t」代表tab鍵的間隔.
6646
						$conf["stringProcess::replaceOnce"]["selectedCharacter"]=$oriVal;
6647
						#$conf["changeTo"],字串,爲被選擇的字元要換成什麼字串/字元.
6648
						$conf["stringProcess::replaceOnce"]["changeTo"]=$newVal;
6649
						#參考資料:
6650
						#無.
6651
						#備註:
6652
						#無.
6653
						$replaceOnce=stringProcess::replaceOnce($conf["stringProcess::replaceOnce"]);
6654
						unset($conf["stringProcess::replaceOnce"]);
226 liveuser 6655
 
218 liveuser 6656
						#debug
6657
						#var_dump(__LINE__,$replaceOnce);
226 liveuser 6658
 
218 liveuser 6659
						#如果執行失敗
6660
						if($replaceOnce["status"]==="false"){
226 liveuser 6661
 
218 liveuser 6662
							#設置錯誤識別
6663
							$result["status"]="false";
226 liveuser 6664
 
218 liveuser 6665
							#設置錯誤訊息
6666
							$result["error"]=$replaceOnce;
226 liveuser 6667
 
218 liveuser 6668
							#回傳結果
6669
							return $result;
226 liveuser 6670
 
218 liveuser 6671
							}#if end
226 liveuser 6672
 
218 liveuser 6673
						#儲存該階段替換好的內容
6674
						$newLineContent=$replaceOnce["content"];
226 liveuser 6675
 
218 liveuser 6676
						}#foreach end
226 liveuser 6677
 
218 liveuser 6678
					#記錄取代的資訊
6679
					$result["relaceInfo"][$oriLineNo]=array("deletedOriHead"=>$deletedOriHead,"ori"=>$oriLineContent,"new"=>$newLineContent);
226 liveuser 6680
 
218 liveuser 6681
					}#else end
226 liveuser 6682
 
218 liveuser 6683
				}#foreach end
226 liveuser 6684
 
218 liveuser 6685
			}#foreach end
226 liveuser 6686
 
218 liveuser 6687
		#初始化替換好的內容為原始內容
6688
		$result["content"]=$getFileContent["fileContent"];
226 liveuser 6689
 
218 liveuser 6690
		#依照內容替代的資訊
6691
		foreach($result["relaceInfo"] as $lineIndex =>$info){
226 liveuser 6692
 
218 liveuser 6693
			#儲存新的行內容
6694
			$newLine=$info["new"];
226 liveuser 6695
 
218 liveuser 6696
			#儲存被剔除的開頭字串
6697
			$deletedOriHead=$info["deletedOriHead"];
226 liveuser 6698
 
220 liveuser 6699
			#debug
6700
			#var_dump(__FILE__,__LINE__,$lineIndex,$deletedOriHead,$newLine);
226 liveuser 6701
 
218 liveuser 6702
			#儲存置換好的行
6703
			$result["content"][$lineIndex]=$deletedOriHead.$newLine;
226 liveuser 6704
 
218 liveuser 6705
			}#foreach end
226 liveuser 6706
 
220 liveuser 6707
		#設置有找到要取代的內容
6708
		$result["found"]="true";
226 liveuser 6709
 
218 liveuser 6710
		#設置執行正常
6711
		$result["status"]="true";
226 liveuser 6712
 
218 liveuser 6713
		#回傳結果
6714
		return $result;
226 liveuser 6715
 
218 liveuser 6716
		}#function replaceMatchContent end
226 liveuser 6717
 
3 liveuser 6718
	}#class phpLib end
6719
 
226 liveuser 6720
?>