Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 678 | Rev 767 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
402 liveuser 1
#!/usr/bin/php
2
<?php
3
 
4
/*
5
 
615 liveuser 6
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
7
    Copyright (C) 2015~2024 Min-Jhin,Chen
402 liveuser 8
 
9
    This file is part of QBPWCF.
10
 
11
    QBPWCF is free software: you can redistribute it and/or modify
12
    it under the terms of the GNU General Public License as published by
13
    the Free Software Foundation, either version 3 of the License, or
14
    (at your option) any later version.
15
 
16
    QBPWCF is distributed in the hope that it will be useful,
17
    but WITHOUT ANY WARRANTY; without even the implied warranty of
18
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
    GNU General Public License for more details.
20
 
21
    You should have received a copy of the GNU General Public License
22
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
23
 
24
*/
25
 
26
#使用 qbpwcf 命名空間
27
namespace qbpwcf;
28
 
755 liveuser 29
#以該檔案的實際位置的 lib path 為 include path 首位
30
exec("cd ".pathinfo(__FILE__)["dirname"]."/qbpwcf;pwd;",$output,$status);
31
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
32
 
402 liveuser 33
#匯入套件
755 liveuser 34
require_once("allInOne.php");
402 liveuser 35
 
36
#建議的log位置
37
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
38
 
39
#該指令的 help 文件
40
function help(){
41
 
42
	#help
43
	echo basename($_SERVER["PHP_SELF"])." is a program to install QBPWCF.".PHP_EOL;
44
	echo basename($_SERVER["PHP_SELF"])." usage:".PHP_EOL;
45
	echo "If run it without any argument, QBPWCF will be install defaultly".PHP_EOL;
46
	echo "--rootPath path where QBPWCF to put. Default is /usr/lib/".PHP_EOL;
47
	echo "--name folder name where QBPWCF to put inside. Default is qbpwcf".PHP_EOL;
48
	echo "--mode cp/link, default is link".PHP_EOL;
49
	echo "\tcp means copy and overwrite to installation path".PHP_EOL;
50
	echo "\tlink means create a softlink from current path to installation path".PHP_EOL;
564 liveuser 51
	echo "--configUrl ur, specify url to get config, default is https://config.qbpwcf.org".PHP_EOL;
554 liveuser 52
	echo "--getIpUrl url, specify url to get www ip, default is https://ip.qbpwcf.org".PHP_EOL;
402 liveuser 53
	echo "--ip ip address, specify self ip address, if need.".PHP_EOL;
54
	echo "--dbAddr MariaDb service address, default is \"localhost\"".PHP_EOL;
55
	echo "--dbAcct MariaDb service account, default is \"root\"".PHP_EOL;
56
	echo "--dbPass MariaDb service password, default is output of uuid command".PHP_EOL;
57
	echo "--dbName MariaDb service database name, default is test".PHP_EOL;
58
	echo "--dbPort MariaDb service port, default is 3306".PHP_EOL;
550 liveuser 59
	echo "--sshAddrAndPort ssh service address, example: 0.0.0.0:22".PHP_EOL;
405 liveuser 60
	echo "--headless true/false, default is false. If true, it means link allInOneForCI.php to allInOne.php".PHP_EOL;
668 liveuser 61
	echo "--whiteIp, outsite ip which will not auto block forever".PHP_EOL;
402 liveuser 62
	exit;
63
 
64
	}#function help end
65
 
66
#函式說明:
67
#解析參數.
68
#回傳結果:
69
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
70
#$reuslt["error"],執行不正常結束的錯訊息陣列.
71
#$result["function"],當前執行的函式名稱.
72
#$result["content"],解析好的參數陣列.
73
#$result["content"][$key][$i],參數 $key 的 $i+1 個參數數值內容.
74
#$result["program"],字串,執行的程式名稱.
75
#必填參數:
76
#無.
77
#可省略參數:
78
#$conf["helpFunc"],如果解析的參數不成對,則要執行的函式名稱.
79
$conf["helpFunc"]="help";
80
#參考資料:
81
#無.
82
#備註:
83
#僅能在命令列底下執行.
84
#以後可將參數 --a--b 的名稱與後面的數值 $value 存成 $result["a"]["b"][$i]=$value .
85
$parseArgu=cmd::parseArgu($conf);
86
unset($conf);
87
 
88
#如果執行失敗
89
if($parseArgu["status"]==="false"){
90
 
91
	#函式說明:
92
	#撰寫log
93
	#回傳結果:
94
	#$result["status"],狀態,"true"或"false".
95
	#$result["error"],錯誤訊息陣列.
96
	#$result["function"],當前函式的名稱.
97
	#$result["argu"],使用的參數.
98
	#必填參數:
99
	#$conf["path"],字串,log檔案的路徑與名稱.
100
	$conf["path"]=$logFile;
101
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
102
	$conf["content"]=$parseArgu;
103
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
104
	$conf["fileArgu"]=__FILE__;
105
	#可省略參數:
106
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
107
	#$conf["rewrite"]="false";
108
	#參考資料:
109
	#無.
110
	#備註:
111
	#無.
112
	$record=logs::record($conf);
113
 
114
	#如果執行失敗
115
	if($record["status"]==="false"){
116
 
117
		#印出結果
118
		var_dump($record);
119
 
120
		}#if end
121
 
409 liveuser 122
	#異常結束執行
123
	exit(1);
124
 
402 liveuser 125
	}#if end
126
 
127
#函式說明:
128
#使用 linux 的 uuid 指令來產生 uuid 字串
129
#回傳結果:
130
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
131
#$result["error"],錯誤訊息.
132
#$result["function"],當前執行的函式名稱.
133
#必填參數:
134
#無.
135
#可省略參數:
136
#無.
137
#參考資料:
138
#無.
139
#備註:
140
#無.
141
$uuid=cmd::uuid();
142
 
143
#如果執行失敗
144
if($uuid["status"]==="false"){
145
 
146
	#函式說明:
147
	#撰寫log
148
	#回傳結果:
149
	#$result["status"],狀態,"true"或"false".
150
	#$result["error"],錯誤訊息陣列.
151
	#$result["function"],當前函式的名稱.
152
	#$result["argu"],使用的參數.
153
	#必填參數:
154
	#$conf["path"],字串,log檔案的路徑與名稱.
155
	$conf["path"]=$logFile;
156
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
157
	$conf["content"]=$uuid;
158
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
159
	$conf["fileArgu"]=__FILE__;
160
	#可省略參數:
161
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
162
	#$conf["rewrite"]="false";
163
	#參考資料:
164
	#無.
165
	#備註:
166
	#無.
167
	$record=logs::record($conf);
168
 
169
	#如果執行失敗
170
	if($record["status"]==="false"){
171
 
172
		#印出結果
173
		var_dump($record);
174
 
175
		}#if end
409 liveuser 176
 
177
	#異常結束執行
178
	exit(1);
402 liveuser 179
 
180
	}#if end
181
 
182
#預設的套件安裝位置
183
$rootPath="/usr/lib/";
184
 
185
#預設的套件資料夾名稱
186
$name="qbpwcf";
187
 
188
#預設運作模式為 "link" 亦即建立軟連結
189
$mode="link";
190
 
564 liveuser 191
#預設取得設定檔服務的網址
192
$configUrl="https://config.qbpwcf.org";
193
 
554 liveuser 194
#預設取得自己對外ip的服務網址
195
$getIpUrl="https://ip.qbpwcf.org";
196
 
402 liveuser 197
#預設不指定自己的IP
198
$ip="";
199
 
200
#預設的資料庫連線帳號
201
$dbAcct="root";
202
 
203
#預設的資料庫連線密碼
204
$dbPass=$uuid["content"];
205
 
206
#預設的資料庫名稱
207
$dbName="test";
208
 
209
#預設到資料庫位置
210
$dbAddr="localhost";
211
 
212
#預設的資料庫port
213
$dbPort="3306";
214
 
550 liveuser 215
#預設的 sshd 設定檔案
216
$defaultSshdConfigAddr="qbpwcf/etc/sshd_config.php";
217
 
218
#預設要要確保ssh服務有運行的ip與port
219
$sshAddrAndPort=array();
220
 
405 liveuser 221
#預設要有自動輸出的內容
222
$headless="false";
223
 
668 liveuser 224
#預設的白名單ip清單
225
$whiteIp=array();
226
 
402 liveuser 227
#檢查參數
228
#函式說明:
229
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
230
#回傳結果:
231
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
232
#$reuslt["error"],執行不正常結束的錯訊息陣列.
233
#$result["function"],當前執行的函式名稱.
234
#$result["argu"],設置給予的參數.
235
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
236
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
237
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
238
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
239
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
240
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
241
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
242
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
243
#必填參數:
244
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
245
$conf["varInput"]=&$parseArgu["content"];
246
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
247
$conf["referenceVarKey"]="variableCheck::checkArguments";
248
#可省略參數:
249
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
250
#$conf["mustBeFilledVariableName"]=array("");
251
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
252
#$conf["mustBeFilledVariableType"]=array();
253
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
254
#$conf["canBeEmptyString"]="false";
255
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
256
#$conf["canNotBeEmpty"]=array();
257
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
258
#$conf["canBeEmpty"]=array();
259
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
668 liveuser 260
$conf["skipableVariableCanNotBeEmpty"]=array("rootPath","name","mode","configUrl","getIpUrl","ip","dbAcct","dbPass","dbName","dbAddr","dbPort","sshAddrAndPort","headless","whiteIp");
402 liveuser 261
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
668 liveuser 262
$conf["skipableVariableName"]=array("rootPath","name","mode","configUrl","getIpUrl","ip","dbAcct","dbPass","dbName","dbAddr","dbPort","sshAddrAndPort","headless","whiteIp");
402 liveuser 263
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
668 liveuser 264
$conf["skipableVariableType"]=array("array","array","array","array","array","array","array","array","array","array","array","array","array","array");
402 liveuser 265
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
564 liveuser 266
$conf["skipableVarDefaultValue"]=array(null,null,null,null,null,null,null,null,null,null,null,null,null);
402 liveuser 267
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
268
#$conf["disallowAllSkipableVarIsEmpty"]="";
269
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
270
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
271
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
564 liveuser 272
$conf["arrayCountEqualCheck"][]=array("rootPath","name","mode","configUrl","getIpUrl","ip","dbAcct","dbPass","dbName","dbAddr","dbPort","headless");
402 liveuser 273
#參考資料:
274
#array_keys=>http://php.net/manual/en/function.array-keys.php
275
#備註:
276
#無.
277
$checkArguments=variableCheck::checkArguments($conf);
278
unset($conf);
279
 
280
#如果有設置參數
281
if(count($parseArgu["content"])>0){
282
 
283
	#如果有 rootPath 參數
284
	if(isset($parseArgu["content"]["rootPath"])){
285
 
286
		#如果有 rootPath 參數存在
287
		if(isset($parseArgu["content"]["rootPath"][0])){
288
 
289
			#更新套件的安裝位置
290
			$rootPath=$parseArgu["content"]["rootPath"][0];
291
 
292
			}#if end
293
 
294
		}#if enf
295
 
296
	#如果有 name 參數
297
	if(isset($parseArgu["content"]["name"])){
298
 
299
		#如果有 name 參數存在
300
		if(isset($parseArgu["content"]["name"][0])){
301
 
302
			#更新套件的資料夾名稱
303
			$name=$parseArgu["content"]["name"][0];
304
 
305
			}#if end
306
 
307
		}#if end
308
 
309
	#如果有 mode 參數
310
	if(isset($parseArgu["content"]["mode"])){
311
 
312
		#如果有 mode 參數存在
313
		if(isset($parseArgu["content"]["mode"][0])){
314
 
315
			#更新運作模式
316
			$mode=$parseArgu["content"]["mode"][0];
317
 
318
			}#if end
319
 
320
		}#if end
321
 
322
	#如果有 ip 參數
323
	if(isset($parseArgu["content"]["ip"])){
324
 
325
		#如果有 ip 參數存在
326
		if(isset($parseArgu["content"]["ip"][0])){
327
 
328
			#更新ip
329
			$ip=$parseArgu["content"]["ip"][0];
330
 
331
			}#if end
332
 
333
		}#if end
334
 
554 liveuser 335
	#如果有 getIpUrl 參數
336
	if(isset($parseArgu["content"]["getIpUrl"])){
337
 
338
		#如果有 getIpUrl 參數存在
339
		if(isset($parseArgu["content"]["getIpUrl"][0])){
340
 
341
			#更新 getIpUrl
342
			$getIpUrl=$parseArgu["content"]["getIpUrl"][0];
343
 
344
			}#if end
345
 
346
		}#if end
347
 
564 liveuser 348
	#如果有 configUrl 參數
349
	if(isset($parseArgu["content"]["configUrl"])){
350
 
351
		#如果有 configUrl 參數存在
352
		if(isset($parseArgu["content"]["configUrl"][0])){
353
 
354
			#更新 configUrl
355
			$configUrl=$parseArgu["content"]["configUrl"][0];
356
 
357
			}#if end
358
 
359
		}#if end
360
 
402 liveuser 361
	#如果有 dbAcct 參數
362
	if(isset($parseArgu["content"]["dbAcct"])){
363
 
364
		#如果有 dbAcct 參數存在
365
		if(isset($parseArgu["content"]["dbAcct"][0])){
366
 
367
			#更新 dbAcct
368
			$dbAcct=$parseArgu["content"]["dbAcct"][0];
369
 
370
			}#if end
371
 
372
		}#if end
373
 
374
	#如果有 dbPass 參數
375
	if(isset($parseArgu["content"]["dbPass"])){
376
 
377
		#如果有 dbPass 參數存在
378
		if(isset($parseArgu["content"]["dbPass"][0])){
379
 
380
			#更新 dbPass
381
			$dbPass=$parseArgu["content"]["dbPass"][0];
382
 
383
			}#if end
384
 
385
		}#if end
386
 
387
	#如果有 dbName 參數
388
	if(isset($parseArgu["content"]["dbName"])){
389
 
390
		#如果有 dbName 參數存在
391
		if(isset($parseArgu["content"]["dbName"][0])){
392
 
393
			#更新 dbName
394
			$dbName=$parseArgu["content"]["dbName"][0];
395
 
396
			}#if end
397
 
398
		}#if end
399
 
400
	#如果有 dbAddr 參數
401
	if(isset($parseArgu["content"]["dbAddr"])){
402
 
403
		#如果有 dbAddr 參數存在
404
		if(isset($parseArgu["content"]["dbAddr"][0])){
405
 
406
			#更新 dbAddr
407
			$dbAddr=$parseArgu["content"]["dbAddr"][0];
408
 
409
			}#if end
410
 
411
		}#if end
412
 
413
	#如果有 dbPort 參數
414
	if(isset($parseArgu["content"]["dbPort"])){
415
 
416
		#如果有 dbPort 參數存在
417
		if(isset($parseArgu["content"]["dbPort"][0])){
418
 
419
			#更新 dbPort
420
			$dbPort=$parseArgu["content"]["dbPort"][0];
421
 
422
			}#if end
423
 
424
		}#if end
550 liveuser 425
 
426
	#如果有 sshAddrAndPort 參數
427
	if(isset($parseArgu["content"]["sshAddrAndPort"])){
428
 
429
		#如果有 sshAddrAndPort 參數存在
430
		if(isset($parseArgu["content"]["sshAddrAndPort"][0])){
405 liveuser 431
 
550 liveuser 432
			#新增 sshAddrAndPort
433
			$sshAddrAndPort[]=$parseArgu["content"]["sshAddrAndPort"][0];
434
 
435
			}#if end
436
 
437
		}#if end
438
 
405 liveuser 439
	#如果有 headless 參數
440
	if(isset($parseArgu["content"]["headless"])){
441
 
442
		#如果有 headless 參數存在
443
		if(isset($parseArgu["content"]["headless"][0])){
444
 
445
			#更新 headless
446
			$headless=$parseArgu["content"]["headless"][0];
447
 
448
			}#if end
449
 
450
		}#if end
668 liveuser 451
 
452
	#如果有 whiteIp 參數
453
	if(isset($parseArgu["content"]["whiteIp"])){
454
 
455
		#針對每個白名單ip
456
		foreach($parseArgu["content"]["whiteIp"] as $ip){
457
 
458
			#儲存起來
459
			$whiteIp[]=$ip;
460
 
461
			}#foreach end
462
 
463
		}#if end
402 liveuser 464
 
465
	}#if end
466
 
405 liveuser 467
#如果要使用不自動輸出內容的 allInOneForCI.php 檔案
468
if($headless==="true"){
469
 
470
	#函式說明:
471
	#建立軟連結.
472
	#回傳結果:
473
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
474
	#$result["error"],錯誤訊息.
475
	#$result["function"],當前執行的函數名稱.
476
	#$result["content"],軟連結的資訊.
477
	#必填參數:
478
	#$conf["fileArgu"],字串,變數__FILE__的內容.
479
	$conf["fileArgu"]=__FILE__;
480
	#$conf["linkTo"],字串,軟連結要指向哪邊.
481
	$conf["linkTo"]="qbpwcf/allInOneForCI.php";
482
	#可省略參數:
483
	#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
484
	$conf["path"]="qbpwcf";
485
	#$conf["name"],字串,軟連結的名稱,預設為 "linkTo" 參數的檔案或目錄名稱.
486
	$conf["name"]="allInOne.php";
414 liveuser 487
	#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
488
	$conf["overWrite"]="true";
405 liveuser 489
	#參考資料:
490
	#無.
491
	#備註:
492
	#無.
493
	$createLink=fileAccess::createLink($conf);
494
	unset($conf);
495
 
414 liveuser 496
	#var_dump($createLink);
497
 
405 liveuser 498
	#如果執行失敗
499
	if($createLink["status"]==="false"){
500
 
501
		#函式說明:
502
		#撰寫log
503
		#回傳結果:
504
		#$result["status"],狀態,"true"或"false".
505
		#$result["error"],錯誤訊息陣列.
506
		#$result["function"],當前函式的名稱.
507
		#$result["argu"],使用的參數.
508
		#必填參數:
509
		#$conf["path"],字串,log檔案的路徑與名稱.
510
		$conf["path"]=$logFile;
511
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
512
		$conf["content"]=$createLink;
513
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
514
		$conf["fileArgu"]=__FILE__;
515
		#可省略參數:
516
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
517
		#$conf["rewrite"]="false";
518
		#參考資料:
519
		#無.
520
		#備註:
521
		#無.
522
		$record=logs::record($conf);
523
 
524
		#如果執行失敗
525
		if($record["status"]==="false"){
526
 
527
			#印出結果
528
			var_dump($record);
529
 
530
			}#if end
409 liveuser 531
 
532
		#異常結束執行
533
		exit(1);
405 liveuser 534
 
535
		}#if end
536
 
537
	}#if end
538
 
402 liveuser 539
#讓 "qbpwcf/usr/bin" 底下的所有檔案為可執行. 
540
#函式說明:
541
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
542
#回傳結果:
543
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
544
#$result["error"],錯誤訊息.
545
#$result["function"],當前執行的函式名稱.
546
#必填參數:
547
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
548
$conf["mode"]="+x";
549
#$conf["target"],字串,需要變更權限的目標.
550
$conf["target"]="qbpwcf/usr/bin";
551
#可省略參數:
552
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
553
$conf["recursive"]="true";
554
#參考資料:
555
#無.
556
#備註:
557
#無.
558
$chmod=cmd::chmod($conf);
559
unset($conf);
560
 
561
#如果執行失敗
409 liveuser 562
if($chmod["status"]==="false"){
402 liveuser 563
 
564
	#函式說明:
565
	#撰寫log
566
	#回傳結果:
567
	#$result["status"],狀態,"true"或"false".
568
	#$result["error"],錯誤訊息陣列.
569
	#$result["function"],當前函式的名稱.
570
	#$result["argu"],使用的參數.
571
	#必填參數:
572
	#$conf["path"],字串,log檔案的路徑與名稱.
573
	$conf["path"]=$logFile;
574
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
575
	$conf["content"]=$chmod;
576
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
577
	$conf["fileArgu"]=__FILE__;
578
	#可省略參數:
579
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
580
	#$conf["rewrite"]="false";
581
	#參考資料:
582
	#無.
583
	#備註:
584
	#無.
585
	$record=logs::record($conf);
586
 
587
	#如果執行失敗
588
	if($record["status"]==="false"){
589
 
590
		#印出結果
591
		var_dump($record);
592
 
593
		}#if end
409 liveuser 594
 
595
	#異常結束執行
596
	exit(1);
402 liveuser 597
 
598
	}#if end
599
 
488 liveuser 600
/*
601
#break point
602
var_dump($chmod);
603
exit;
604
*/
605
 
402 liveuser 606
#讓 "qbpwcf/db" 可以被大家使用.
607
#函式說明:
608
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
609
#回傳結果:
610
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
611
#$result["error"],錯誤訊息.
612
#$result["function"],當前執行的函式名稱.
613
#必填參數:
614
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
615
$conf["mode"]="777";
616
#$conf["target"],字串,需要變更權限的目標.
617
$conf["target"]="qbpwcf/db";
618
#可省略參數:
619
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
620
#$conf["recursive"]="";
621
#參考資料:
622
#無.
623
#備註:
624
#無.
625
$chmod=cmd::chmod($conf);
626
unset($conf);
627
 
628
#如果執行失敗
629
if($chmod["status"]==="false"){
630
 
631
	#函式說明:
632
	#撰寫log
633
	#回傳結果:
634
	#$result["status"],狀態,"true"或"false".
635
	#$result["error"],錯誤訊息陣列.
636
	#$result["function"],當前函式的名稱.
637
	#$result["argu"],使用的參數.
638
	#必填參數:
639
	#$conf["path"],字串,log檔案的路徑與名稱.
640
	$conf["path"]=$logFile;
641
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
642
	$conf["content"]=$chmod;
643
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
644
	$conf["fileArgu"]=__FILE__;
645
	#可省略參數:
646
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
647
	#$conf["rewrite"]="false";
648
	#參考資料:
649
	#無.
650
	#備註:
651
	#無.
652
	$record=logs::record($conf);
653
 
654
	#如果執行失敗
655
	if($record["status"]==="false"){
656
 
657
		#印出結果
658
		var_dump($record);
659
 
660
		}#if end
409 liveuser 661
 
662
	#異常結束執行
663
	exit(1);
402 liveuser 664
 
665
	}#if end
488 liveuser 666
 
667
/*
668
#break point
669
var_dump($chmod);
670
exit;
671
*/
402 liveuser 672
 
554 liveuser 673
#依照參數設定 $rootPath.$name."/etc/config.php
674
#函式說明:
675
#建立軟連結.
676
#回傳結果:
677
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
678
#$result["error"],錯誤訊息.
679
#$result["function"],當前執行的函數名稱.
680
#$result["content"],軟連結的資訊.
681
#必填參數:
682
#$conf["fileArgu"],字串,變數__FILE__的內容.
683
$conf["fileArgu"]=__FILE__;
684
#$conf["file"],字串,要更新的檔案位置與名稱.
685
$conf["file"]="qbpwcf/etc/config.php";
686
#可省略參數:
687
#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
688
$conf["overWriteWith"][]="<?php";
689
$conf["overWriteWith"][]="";
690
$conf["overWriteWith"][]="#specify host ip";
691
$conf["overWriteWith"][]="\$myIp="."\"".$ip."\";";
692
$conf["overWriteWith"][]="";
693
$conf["overWriteWith"][]="#specify url to get self www ip";
694
$conf["overWriteWith"][]="\$getIpUrl=\"".$getIpUrl."\";";
695
$conf["overWriteWith"][]="";
564 liveuser 696
$conf["overWriteWith"][]="#specify url to get config";
697
$conf["overWriteWith"][]="\$configUrl=\"".$configUrl."\";";
698
$conf["overWriteWith"][]="";
554 liveuser 699
$conf["overWriteWith"][]="?\>";
700
#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
701
#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
702
#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
703
#$conf["addToTailWhenNoMatch"]="false";
704
#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
705
#$conf["addToTailBeforeThat"]="?\>";
706
#參考資料:
707
#無.
708
#備註:
709
#無.
710
$updateFile=fileAccess::updateFile($conf);
711
unset($conf);
402 liveuser 712
 
554 liveuser 713
#如果執行失敗
714
if($updateFile["status"]==="false"){
715
 
402 liveuser 716
	#函式說明:
554 liveuser 717
	#撰寫log
402 liveuser 718
	#回傳結果:
554 liveuser 719
	#$result["status"],狀態,"true"或"false".
720
	#$result["error"],錯誤訊息陣列.
721
	#$result["function"],當前函式的名稱.
722
	#$result["argu"],使用的參數.
402 liveuser 723
	#必填參數:
554 liveuser 724
	#$conf["path"],字串,log檔案的路徑與名稱.
725
	$conf["path"]=$logFile;
726
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
727
	$conf["content"]=$updateFile;
728
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
402 liveuser 729
	$conf["fileArgu"]=__FILE__;
730
	#可省略參數:
554 liveuser 731
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
732
	#$conf["rewrite"]="false";
402 liveuser 733
	#參考資料:
734
	#無.
735
	#備註:
736
	#無.
554 liveuser 737
	$record=logs::record($conf);
738
 
402 liveuser 739
	#如果執行失敗
554 liveuser 740
	if($record["status"]==="false"){
741
 
742
		#印出結果
743
		var_dump($record);
402 liveuser 744
 
554 liveuser 745
		}#if end
402 liveuser 746
 
554 liveuser 747
	#異常結束執行
748
	exit(1);
402 liveuser 749
 
554 liveuser 750
	}#if end
751
 
752
#讓 "qbpwcf/etc/config.php" 可以被大家使用.
753
#函式說明:
754
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
755
#回傳結果:
756
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
757
#$result["error"],錯誤訊息.
758
#$result["function"],當前執行的函式名稱.
759
#必填參數:
760
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
761
$conf["mode"]="777";
762
#$conf["target"],字串,需要變更權限的目標.
763
$conf["target"]="qbpwcf/etc/config.php";
764
#可省略參數:
765
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
766
#$conf["recursive"]="";
767
#參考資料:
768
#無.
769
#備註:
770
#無.
771
$chmod=cmd::chmod($conf);
772
unset($conf);
773
 
774
#如果執行失敗
775
if($chmod["status"]==="false"){
776
 
431 liveuser 777
	#函式說明:
554 liveuser 778
	#撰寫log
431 liveuser 779
	#回傳結果:
554 liveuser 780
	#$result["status"],狀態,"true"或"false".
781
	#$result["error"],錯誤訊息陣列.
782
	#$result["function"],當前函式的名稱.
783
	#$result["argu"],使用的參數.
431 liveuser 784
	#必填參數:
554 liveuser 785
	#$conf["path"],字串,log檔案的路徑與名稱.
786
	$conf["path"]=$logFile;
787
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
788
	$conf["content"]=$chmod;
789
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
790
	$conf["fileArgu"]=__FILE__;
431 liveuser 791
	#可省略參數:
554 liveuser 792
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
793
	#$conf["rewrite"]="false";
431 liveuser 794
	#參考資料:
795
	#無.
796
	#備註:
797
	#無.
554 liveuser 798
	$record=logs::record($conf);
799
 
431 liveuser 800
	#如果執行失敗
554 liveuser 801
	if($record["status"]==="false"){
802
 
803
		#印出結果
804
		var_dump($record);
805
 
806
		}#if end
431 liveuser 807
 
554 liveuser 808
	#異常結束執行
809
	exit(1);
431 liveuser 810
 
402 liveuser 811
	}#if end
812
 
813
#依照參數設定 "qbpwcf/usr/local/etc/backupDb.conf"
814
#函式說明:
815
#建立軟連結.
816
#回傳結果:
817
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
818
#$result["error"],錯誤訊息.
819
#$result["function"],當前執行的函數名稱.
820
#$result["content"],軟連結的資訊.
821
#必填參數:
822
#$conf["fileArgu"],字串,變數__FILE__的內容.
823
$conf["fileArgu"]=__FILE__;
824
#$conf["file"],字串,要更新的檔案位置與名稱.
825
$conf["file"]="qbpwcf/usr/local/etc/backupDb.conf";
826
#可省略參數:
827
#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
828
$conf["overWriteWith"]=array();
829
$conf["overWriteWith"][]="<?php";
830
$conf["overWriteWith"][]="#資料庫連線帳號";
831
$conf["overWriteWith"][]="\$dbAcct=\"".$dbAcct."\";";
832
$conf["overWriteWith"][]="";
833
$conf["overWriteWith"][]="#資料庫連線密碼";
834
$conf["overWriteWith"][]="\$dbPass=\"".$dbPass."\";";
835
$conf["overWriteWith"][]="";
836
$conf["overWriteWith"][]="#資料庫名稱";
837
$conf["overWriteWith"][]="\$dbName=\"".$dbName."\";";
838
$conf["overWriteWith"][]="";
839
$conf["overWriteWith"][]="#資料庫位置";
840
$conf["overWriteWith"][]="\$dbAddr=\"".$dbAddr."\";";
841
$conf["overWriteWith"][]="";
842
$conf["overWriteWith"][]="#資料庫port";
843
$conf["overWriteWith"][]="\$dbPort=\"".$dbPort."\";";
844
#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
845
#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
846
#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
847
#$conf["addToTailWhenNoMatch"]="false";
848
#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
849
#$conf["addToTailBeforeThat"]="?\>";
850
#參考資料:
851
#無.
852
#備註:
853
#無.
409 liveuser 854
$updateFile=fileAccess::updateFile($conf);
402 liveuser 855
unset($conf);
856
 
857
#如果執行失敗
858
if($updateFile["status"]==="false"){
859
 
860
	#函式說明:
861
	#撰寫log
862
	#回傳結果:
863
	#$result["status"],狀態,"true"或"false".
864
	#$result["error"],錯誤訊息陣列.
865
	#$result["function"],當前函式的名稱.
866
	#$result["argu"],使用的參數.
867
	#必填參數:
868
	#$conf["path"],字串,log檔案的路徑與名稱.
869
	$conf["path"]=$logFile;
870
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
871
	$conf["content"]=$updateFile;
872
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
873
	$conf["fileArgu"]=__FILE__;
874
	#可省略參數:
875
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
876
	#$conf["rewrite"]="false";
877
	#參考資料:
878
	#無.
879
	#備註:
880
	#無.
881
	$record=logs::record($conf);
882
 
883
	#如果執行失敗
884
	if($record["status"]==="false"){
885
 
886
		#印出結果
887
		var_dump($record);
888
 
889
		}#if end
409 liveuser 890
 
891
	#異常結束執行
892
	exit(1);
402 liveuser 893
 
894
	}#if end
895
 
896
#重新建置 qbpwcf/usr/local/etc/qbpwcf.conf.xml
897
#函式說明:
550 liveuser 898
#更新檔案內容.
402 liveuser 899
#回傳結果:
900
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
901
#$result["error"],錯誤訊息.
902
#$result["function"],當前執行的函數名稱.
903
#$result["content"],軟連結的資訊.
904
#必填參數:
905
#$conf["fileArgu"],字串,變數__FILE__的內容.
906
$conf["fileArgu"]=__FILE__;
907
#$conf["file"],字串,要更新的檔案位置與名稱.
908
$conf["file"]="qbpwcf/usr/local/etc/qbpwcf.conf.xml";
909
#可省略參數:
910
#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
911
$conf["overWriteWith"]=array();
912
$conf["overWriteWith"][]="<?xml version=\"1.0\"?>";
913
$conf["overWriteWith"][]="<root></root>";
914
#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
915
#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
916
#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
917
#$conf["addToTailWhenNoMatch"]="false";
918
#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
919
#$conf["addToTailBeforeThat"]="?\>";
920
#參考資料:
921
#無.
922
#備註:
923
#無.
409 liveuser 924
$updateFile=fileAccess::updateFile($conf);
402 liveuser 925
unset($conf);
926
 
927
#如果執行失敗
928
if($updateFile["status"]==="false"){
929
 
930
	#函式說明:
931
	#撰寫log
932
	#回傳結果:
933
	#$result["status"],狀態,"true"或"false".
934
	#$result["error"],錯誤訊息陣列.
935
	#$result["function"],當前函式的名稱.
936
	#$result["argu"],使用的參數.
937
	#必填參數:
938
	#$conf["path"],字串,log檔案的路徑與名稱.
939
	$conf["path"]=$logFile;
940
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
941
	$conf["content"]=$updateFile;
942
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
943
	$conf["fileArgu"]=__FILE__;
944
	#可省略參數:
945
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
946
	#$conf["rewrite"]="false";
947
	#參考資料:
948
	#無.
949
	#備註:
950
	#無.
951
	$record=logs::record($conf);
952
 
953
	#如果執行失敗
954
	if($record["status"]==="false"){
955
 
956
		#印出結果
957
		var_dump($record);
958
 
959
		}#if end
409 liveuser 960
 
961
	#異常結束執行
962
	exit(1);
402 liveuser 963
 
964
	}#if end
965
 
966
#讓 "qbpwcf/usr/local/etc/qbpwcf.conf.xml" 可以被大家使用.
967
#函式說明:
968
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
969
#回傳結果:
970
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
971
#$result["error"],錯誤訊息.
972
#$result["function"],當前執行的函式名稱.
973
#必填參數:
974
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
975
$conf["mode"]="777";
976
#$conf["target"],字串,需要變更權限的目標.
977
$conf["target"]="qbpwcf/usr/local/etc/qbpwcf.conf.xml";
978
#可省略參數:
979
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
980
#$conf["recursive"]="";
981
#參考資料:
982
#無.
983
#備註:
984
#無.
985
$chmod=cmd::chmod($conf);
986
unset($conf);
987
 
988
#如果執行失敗
989
if($chmod["status"]==="false"){
990
 
991
	#函式說明:
992
	#撰寫log
993
	#回傳結果:
994
	#$result["status"],狀態,"true"或"false".
995
	#$result["error"],錯誤訊息陣列.
996
	#$result["function"],當前函式的名稱.
997
	#$result["argu"],使用的參數.
998
	#必填參數:
999
	#$conf["path"],字串,log檔案的路徑與名稱.
1000
	$conf["path"]=$logFile;
1001
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1002
	$conf["content"]=$chmod;
1003
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1004
	$conf["fileArgu"]=__FILE__;
1005
	#可省略參數:
1006
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1007
	#$conf["rewrite"]="false";
1008
	#參考資料:
1009
	#無.
1010
	#備註:
1011
	#無.
1012
	$record=logs::record($conf);
1013
 
1014
	#如果執行失敗
1015
	if($record["status"]==="false"){
1016
 
1017
		#印出結果
1018
		var_dump($record);
1019
 
1020
		}#if end
409 liveuser 1021
 
1022
	#異常結束執行
1023
	exit(1);
402 liveuser 1024
 
1025
	}#if end
1026
 
488 liveuser 1027
/*
1028
#break point
1029
var_dump($chmod);
1030
exit;
1031
*/
1032
 
550 liveuser 1033
#若有要指定 ssh addr 與 port
1034
if(count($sshAddrAndPort)>0){
1035
 
1036
	#建立 $defaultSshdConfigAddr 檔案
1037
	#函式說明:
1038
	#將字串寫入到檔案
1039
	#回傳結果:
1040
	#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
1041
	#$result["error"],錯誤訊息陣列.
1042
	#$result["function"],當前執行的函數名稱.
1043
	#$result["fileInfo"],實際上寫入的檔案資訊陣列.
1044
	#$result["fileInfo"]["createdFileName"],建立好的檔案名稱.
1045
	#$result["fileInfo"]["createdFilePath"],檔案建立的路徑.
1046
	#$result["fileInfo"]["createdFilePathAndName"].建立好的檔案名稱與路徑.
1047
	#$result["argu"],使用的參數.
1048
	#必填參數:
1049
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1050
	$conf["fileArgu"]=__FILE__;
1051
	#可省略參數:
1052
	#$conf["fileName"],字串,爲要編輯的檔案名稱,預設為隨機產生的檔案名稱.
1053
	$conf["fileName"]=$defaultSshdConfigAddr;
1054
	#$conf["inputString"],字串,爲要寫入到裏面的內容,若要每筆資料寫入後換行,則可以在字串內容後面加上 \r\n 即可,預設為"".
1055
	#$conf["inputString"]=$testToWrite;	
1056
	#$conf["writeMethod"],字串,爲檔案撰寫的方式,可省略,是複寫'a'還是,重新寫入'w',預設爲'w',重新寫入.
1057
	#$conf["writeMethod"]="a";
1058
	#$conf["checkRepeat"],字串,"true"代表建立檔案之前要先檢查檔案是否存在,若存在則在原名稱後面加上從(1)開始的編號.
1059
	#$conf["checkRepeat"]="";
1060
	#$conf["filenameExtensionStartPoint"],字串,檔案的副檔名是從倒數第幾個小數點(dot)開始,預設為"1",最後一個小數點,必須與$conf["checkRepeat"]搭配才會生效.
1061
	#$conf["filenameExtensionStartPoint"]="";
1062
	#$conf["repeatNameRule"],字串,遇到相同名稱的檔案要如何加上識別的編號,編號用「\$i」表示,預設為"(\$i)",必須與$conf["checkRepeat"]搭配才會生效.
1063
	#$conf["repeatNameRule"]="";
1064
	#$conf["web"],檔案是否位於網站上"true",若是在檔案系統則為"false",預設為"true".
1065
	$conf["web"]="false";
1066
	#參考資料:
1067
	#無.
1068
	#備註:
1069
	#無.
1070
	$writeTextIntoFile=fileAccess::writeTextIntoFile($conf);
1071
	unset($conf);
1072
 
1073
	#如果執行失敗
1074
	if($writeTextIntoFile["status"]==="false"){
1075
 
1076
		#印出結果
1077
		var_dump($writeTextIntoFile);
1078
 
1079
		#結束執行
1080
		exit;
1081
 
1082
		}#if end
1083
 
1084
	#要覆寫的內容
1085
	$overWriteWith=array("<?php".PHP_EOL);
1086
 
553 liveuser 1087
	#debug
1088
	#$overWriteWith[]="\$reportOnly=\"true\";";
1089
 
1090
	#get some verbose info
1091
	$overWriteWith[]="\$verbose=\"true\";";
1092
 
550 liveuser 1093
	#針對每個為了確保ssh服務有運行的設定
1094
	foreach($sshAddrAndPort as $ipAndPort){
1095
 
1096
		#串接設定
553 liveuser 1097
		$overWriteWith[]="\$ipAndPort=\"".$ipAndPort."\";";
550 liveuser 1098
 
1099
		}#foreach end
1100
 
1101
	#要覆寫的內容
553 liveuser 1102
	$overWriteWith[]=PHP_EOL."?>";
550 liveuser 1103
 
1104
	#函式說明:
1105
	#更新檔案的內容.
1106
	#回傳結果:
1107
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1108
	#$result["error"],錯誤訊息.
1109
	#$result["function"],當前執行的函數名稱.
1110
	#$result["content"],軟連結的資訊.
1111
	#必填參數:
1112
	#$conf["fileArgu"],字串,變數__FILE__的內容.
1113
	$conf["fileArgu"]=__FILE__;
1114
	#$conf["file"],字串,要更新的檔案位置與名稱.
553 liveuser 1115
	$conf["file"]=$defaultSshdConfigAddr;
550 liveuser 1116
	#可省略參數:
1117
	#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
1118
	$conf["overWriteWith"]=$overWriteWith;
1119
	#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
1120
	#$conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
1121
	#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
1122
	#$conf["addToTailWhenNoMatch"]="false";
1123
	#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
1124
	#$conf["addToTailBeforeThat"]="?\>";
1125
	#參考資料:
1126
	#無.
1127
	#備註:
1128
	#無.
553 liveuser 1129
	$updateFile=fileAccess::updateFile($conf);
550 liveuser 1130
	unset($conf);
1131
 
1132
	#如果執行失敗
1133
	if($updateFile["status"]==="false"){
1134
 
1135
		#印出結果
1136
		var_dump($updateFile);
1137
 
1138
		#結束執行
1139
		exit;
1140
 
1141
		}#if end
1142
 
1143
	}#if end
1144
 
419 liveuser 1145
#移除 qbpwcf/usr/lib/systemd/system 底下服務設定檔的執行權限
1146
#函式說明:
1147
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
1148
#回傳結果:
1149
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1150
#$result["error"],錯誤訊息.
1151
#$result["function"],當前執行的函式名稱.
1152
#必填參數:
1153
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
469 liveuser 1154
$conf["mode"]="640";
419 liveuser 1155
#$conf["target"],字串,需要變更權限的目標.
1156
$conf["target"]="qbpwcf/usr/lib/systemd/system";
1157
#可省略參數:
1158
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
1159
$conf["recursive"]="true";
1160
#$conf["excludeSelf"],字串,預設為"false"代表不處理;若為"true"則會排除目標自己(資料夾).
1161
$conf["excludeSelf"]="true";
1162
#參考資料:
1163
#無.
1164
#備註:
1165
#無.
1166
$chmod=cmd::chmod($conf);
1167
unset($conf);
1168
 
1169
#如果執行失敗
1170
if($chmod["status"]==="false"){
1171
 
1172
	#函式說明:
1173
	#撰寫log
1174
	#回傳結果:
1175
	#$result["status"],狀態,"true"或"false".
1176
	#$result["error"],錯誤訊息陣列.
1177
	#$result["function"],當前函式的名稱.
1178
	#$result["argu"],使用的參數.
1179
	#必填參數:
1180
	#$conf["path"],字串,log檔案的路徑與名稱.
1181
	$conf["path"]=$logFile;
1182
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1183
	$conf["content"]=$chmod;
1184
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1185
	$conf["fileArgu"]=__FILE__;
1186
	#可省略參數:
1187
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1188
	#$conf["rewrite"]="false";
1189
	#參考資料:
1190
	#無.
1191
	#備註:
1192
	#無.
1193
	$record=logs::record($conf);
1194
 
1195
	#如果執行失敗
1196
	if($record["status"]==="false"){
1197
 
1198
		#印出結果
1199
		var_dump($record);
1200
 
1201
		}#if end
1202
 
1203
	#異常結束執行
1204
	exit(1);
1205
 
1206
	}#if end
1207
 
488 liveuser 1208
/*
1209
#break point
1210
var_dump($chmod);
1211
exit;
1212
*/
1213
 
402 liveuser 1214
#判斷 $mode
1215
switch($mode){
1216
 
1217
	#如果是 "cp" mode
1218
	case "cp":
1219
 
1220
		#函式說明:
1221
		#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
1222
		#回傳結果:
1223
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1224
		#$result["error"],錯誤訊息陣列
1225
		#$result["warning"],警告訊息陣列
1226
		#$result["argu"],使用的參數.
1227
		#$result["content"],建立的目錄路徑.
1228
		#必填參數:
1229
		#$conf["dirPositionAndName"]="";#新建的位置與名稱
1230
		$conf["dirPositionAndName"]=$rootPath.$name;
1231
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1232
		$conf["fileArgu"]=__FILE__;
1233
		#可省略參數:
1234
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
1235
		#$conf["dirPermission"]="";
1236
		#$conf["web"],"false"代表在檔案系統環境,"true"代表在網頁稀系統環境.
1237
		#$conf["web"]="false";
1238
		#參考資料:
1239
		#mkdir=>http://php.net/manual/en/function.mkdir.php
1240
		#chmod=>http://php.net/manual/en/function.chmod.php
1241
		#備註:
1242
		#無.
1243
		$createFolderAfterCheck=fileAccess::createFolderAfterCheck($conf);
1244
		unset($conf);
1245
 
1246
		#如果執行失敗
1247
		if($createFolderAfterCheck["status"]==="false"){
1248
 
1249
			#函式說明:
1250
			#撰寫log
1251
			#回傳結果:
1252
			#$result["status"],狀態,"true"或"false".
1253
			#$result["error"],錯誤訊息陣列.
1254
			#$result["function"],當前函式的名稱.
1255
			#$result["argu"],使用的參數.
1256
			#必填參數:
1257
			#$conf["path"],字串,log檔案的路徑與名稱.
1258
			$conf["path"]=$logFile;
1259
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1260
			$conf["content"]=$createFolderAfterCheck;
1261
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1262
			$conf["fileArgu"]=__FILE__;
1263
			#可省略參數:
1264
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1265
			#$conf["rewrite"]="false";
1266
			#參考資料:
1267
			#無.
1268
			#備註:
1269
			#無.
1270
			$record=logs::record($conf);
1271
 
1272
			#如果執行失敗
1273
			if($record["status"]==="false"){
1274
 
1275
				#印出結果
1276
				var_dump($record);
1277
 
1278
				}#if end
409 liveuser 1279
 
1280
			#異常結束執行
1281
			exit(1);
402 liveuser 1282
 
1283
			}#if end
1284
 
1285
		#複製套件
1286
		#函式說明:
1287
		#複製檔案、資料夾.
1288
		#回傳結果:
1289
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1290
		#$result["error"],錯誤訊息.
1291
		#$result["function"],當前執行的函式名稱.
1292
		#$result["content"],複製好的檔案路徑與名稱.
1293
		#必填參數:
1294
		#$conf["file"],字串,檔案的位置與名稱.
1295
		$conf["file"]="../";
1296
		#$conf["to"],字串,檔案要複製到哪裡.
1297
		$conf["to"]=$rootPath.$name;
1298
		#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
1299
		$conf["fileArgu"]=__FILE__;
1300
		#可省略參數:
1301
		#$conf["username"],字串,要以哪個使用者來執行,預設為執行該php程式的使用者.
1302
		#$conf["username"]="";
1303
		#$conf["password"],字串,使用者對應的密碼,預設不使用.
1304
		#$conf["password"]="";
1305
		#參考資料:
1306
		#無.
1307
		#備註:
1308
		#僅能在命令列環境下運行
1309
		$cp=cmd::cp($conf);
1310
		unset($conf);
1311
 
1312
		#如果執行失敗
1313
		if($cp["status"]==="false"){
1314
 
1315
			#函式說明:
1316
			#撰寫log
1317
			#回傳結果:
1318
			#$result["status"],狀態,"true"或"false".
1319
			#$result["error"],錯誤訊息陣列.
1320
			#$result["function"],當前函式的名稱.
1321
			#$result["argu"],使用的參數.
1322
			#必填參數:
1323
			#$conf["path"],字串,log檔案的路徑與名稱.
1324
			$conf["path"]=$logFile;
1325
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1326
			$conf["content"]=$cp;
1327
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1328
			$conf["fileArgu"]=__FILE__;
1329
			#可省略參數:
1330
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1331
			#$conf["rewrite"]="false";
1332
			#參考資料:
1333
			#無.
1334
			#備註:
1335
			#無.
1336
			$record=logs::record($conf);
1337
 
1338
			#如果執行失敗
1339
			if($record["status"]==="false"){
1340
 
1341
				#印出結果
1342
				var_dump($record);
1343
 
1344
				}#if end
1345
 
409 liveuser 1346
			#異常結束執行
1347
			exit(1);
1348
 
402 liveuser 1349
			}#if end
1350
 
1351
		break;
1352
 
1353
	#如果是 "link" mode
1354
	case "link":
1355
 
1356
		#函式說明:
1357
		#建立軟連結.
1358
		#回傳結果:
1359
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1360
		#$result["error"],錯誤訊息.
1361
		#$result["function"],當前執行的函數名稱.
1362
		#$result["content"],軟連結的資訊.
1363
		#必填參數:
1364
		#$conf["fileArgu"],字串,變數__FILE__的內容.
1365
		$conf["fileArgu"]=__FILE__;
1366
		#$conf["linkTo"],字串,軟連結要指向哪邊.
409 liveuser 1367
		$conf["linkTo"]="qbpwcf";
402 liveuser 1368
		#可省略參數:
1369
		#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
409 liveuser 1370
		$conf["path"]=$rootPath;
402 liveuser 1371
		#$conf["name"],字串,軟連結的名稱,預設為 "linkTo" 參數的檔案或目錄名稱.
409 liveuser 1372
		$conf["name"]=$name;
1373
		#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1374
		$conf["overWrite"]="true";
402 liveuser 1375
		#參考資料:
1376
		#無.
1377
		#備註:
1378
		#無.
1379
		$createLink=fileAccess::createLink($conf);
1380
		unset($conf);
1381
 
1382
		#如果執行失敗
1383
		if($createLink["status"]==="false"){
1384
 
1385
			#函式說明:
1386
			#撰寫log
1387
			#回傳結果:
1388
			#$result["status"],狀態,"true"或"false".
1389
			#$result["error"],錯誤訊息陣列.
1390
			#$result["function"],當前函式的名稱.
1391
			#$result["argu"],使用的參數.
1392
			#必填參數:
1393
			#$conf["path"],字串,log檔案的路徑與名稱.
1394
			$conf["path"]=$logFile;
1395
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1396
			$conf["content"]=$createLink;
1397
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1398
			$conf["fileArgu"]=__FILE__;
1399
			#可省略參數:
1400
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1401
			#$conf["rewrite"]="false";
1402
			#參考資料:
1403
			#無.
1404
			#備註:
1405
			#無.
1406
			$record=logs::record($conf);
1407
 
1408
			#如果執行失敗
1409
			if($record["status"]==="false"){
1410
 
1411
				#印出結果
1412
				var_dump($record);
1413
 
1414
				}#if end
409 liveuser 1415
 
1416
			#異常結束執行
1417
			exit(1);
402 liveuser 1418
 
1419
			}#if end
1420
 
488 liveuser 1421
		/*
1422
		#break point
1423
		var_dump($createLink);
1424
		exit;
1425
		*/
1426
 
402 liveuser 1427
		break;
1428
 
1429
	default:
1430
 
1431
		#函式說明:
1432
		#撰寫log
1433
		#回傳結果:
1434
		#$result["status"],狀態,"true"或"false".
1435
		#$result["error"],錯誤訊息陣列.
1436
		#$result["function"],當前函式的名稱.
1437
		#$result["argu"],使用的參數.
1438
		#必填參數:
1439
		#$conf["path"],字串,log檔案的路徑與名稱.
1440
		$conf["path"]=$logFile;
1441
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1442
		$conf["content"]="mode \"".$mode."\" not supported!";
1443
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1444
		$conf["fileArgu"]=__FILE__;
1445
		#可省略參數:
1446
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1447
		#$conf["rewrite"]="false";
1448
		#參考資料:
1449
		#無.
1450
		#備註:
1451
		#無.
1452
		$record=logs::record($conf);
1453
 
1454
		#如果執行失敗
1455
		if($record["status"]==="false"){
1456
 
1457
			#印出結果
1458
			var_dump($record);
1459
 
1460
			}#if end
409 liveuser 1461
 
1462
		#異常結束執行
1463
		exit(1);
402 liveuser 1464
 
1465
	}#switch end
1466
 
1467
#於 /usr/bin 底下建立 $rootPath.$name."/usr/bin" 底下所有檔案的軟連結.
1468
#函式說明:
1469
#針對特定目錄下的內容建立軟連結.
1470
#回傳結果:
1471
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1472
#$result["error"],錯誤訊息.
1473
#$result["function"],當前執行的函數名稱.
1474
#$result["content"],字串陣列,每個建立的軟連結資訊.
1475
#必填參數:
1476
#$conf["fileArgu"],字串,變數__FILE__的內容.
1477
$conf["fileArgu"]=__FILE__;
1478
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
1479
$conf["linkToDir"]=$rootPath.$name."/usr/bin";
1480
#可省略參數:
1481
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
1482
$conf["path"]="/usr/bin";
1483
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
1484
#$conf["name"]=array(array("oriName","newName"));
1485
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1486
$conf["overWrite"]="true";
1487
#參考資料:
1488
#無.
1489
#備註:
1490
#無.
1491
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
1492
unset($conf);
1493
 
1494
#如果執行失敗
1495
if($createMultiLinkInDir["status"]==="false"){
1496
 
1497
	#函式說明:
1498
	#撰寫log
1499
	#回傳結果:
1500
	#$result["status"],狀態,"true"或"false".
1501
	#$result["error"],錯誤訊息陣列.
1502
	#$result["function"],當前函式的名稱.
1503
	#$result["argu"],使用的參數.
1504
	#必填參數:
1505
	#$conf["path"],字串,log檔案的路徑與名稱.
1506
	$conf["path"]=$logFile;
1507
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1508
	$conf["content"]=$createMultiLinkInDir;
1509
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1510
	$conf["fileArgu"]=__FILE__;
1511
	#可省略參數:
1512
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1513
	#$conf["rewrite"]="false";
1514
	#參考資料:
1515
	#無.
1516
	#備註:
1517
	#無.
1518
	$record=logs::record($conf);
1519
 
1520
	#如果執行失敗
1521
	if($record["status"]==="false"){
1522
 
1523
		#印出結果
1524
		var_dump($record);
1525
 
1526
		}#if end
409 liveuser 1527
 
1528
	#異常結束執行
1529
	exit(1);
402 liveuser 1530
 
1531
	}#if end
1532
 
668 liveuser 1533
#如果 $whiteIp 不為空
1534
if(count($whiteIp)>0){
1535
 
1536
	#如果有 ip-blockerd.service 存在
671 liveuser 1537
	#函式說明:
1538
	#檢查多個檔案與資料夾是否存在.
1539
	#回傳的結果:
1540
	#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
1541
	#$result["error"],錯誤訊息陣列.
1542
	#$resutl["function"],當前執行的涵式名稱.
1543
	#$result["argu"],使用的參數.
1544
	#$result["allExist"],所有檔案皆存在的識別,"true"代表皆存在,"false"代表沒有全部都存在.
1545
	#$result["varName"][$i],爲第$i個資料夾或檔案的路徑與名稱。
1546
	#$result["varNameFullPath"][$i],爲第$i個資料夾或檔案的完整檔案系統路徑與名稱,如果不存在則代表路徑是網址.
1547
	#$result["varNameWebPath"][$i],為第$i個資料夾或檔案的網址,若"web"參數為"true",才會有該內容.
1548
	#$result["varExist"][$i],爲第$i個資料夾或檔案是否存在,"true"代表存在,"false"代表不存在。
1549
	#必填參數:
1550
	#$conf["fileArray"],陣列字串,要檢查是否存在的檔案有哪些,須爲一維陣列數值。
1551
	$conf["fileArray"]=array("./qbpwcf/usr/lib/systemd/system/ip-blockerd.service");
1552
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1553
	$conf["fileArgu"]=__FILE__;
1554
	#可省略參數:
1555
	#$conf["disableWebSearch"],"字串",是否取消「當檔案找不到時,改用catchWebContent類別的wget函數來檢查檔案是否存在於網路上」的功能,"false"不取消,若要取消該功能請設為"true",若抓到的內容為空字串則會視為檔案不存在,預設為"true".
674 liveuser 1556
	$conf["disableWebSearch"]="true";
671 liveuser 1557
	#$conf["userDir"],字串,網頁是否置放於家目錄底下,"true"為是,"false"為不是,預設為"true".
1558
	$conf["userDir"]="false";
1559
	#$conf["web"],字串,檔案是放在web就是"true",反之為檔案系統"false",預設為"true".
1560
	$conf["web"]="false";
1561
	#參考資料:
1562
	#http://php.net/manual/en/function.file-exists.php
1563
	#http://php.net/manual/en/control-structures.foreach.php
1564
	#備註:
1565
	#函數file_exists檢查的路徑為檔案系統的路徑
1566
	#$result["varName"][$i]結果未實作
1567
	$checkMultiFileExist=fileAccess::checkMultiFileExist($conf);
1568
	unset($conf);
668 liveuser 1569
 
671 liveuser 1570
	#如果執行失敗
1571
	if($checkMultiFileExist["status"]==="false"){
1572
 
1573
		#函式說明:
1574
		#撰寫log
1575
		#回傳結果:
1576
		#$result["status"],狀態,"true"或"false".
1577
		#$result["error"],錯誤訊息陣列.
1578
		#$result["function"],當前函式的名稱.
1579
		#$result["argu"],使用的參數.
1580
		#必填參數:
1581
		#$conf["path"],字串,log檔案的路徑與名稱.
1582
		$conf["path"]=$logFile;
1583
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1584
		$conf["content"]=$createMultiLinkInDir;
1585
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1586
		$conf["fileArgu"]=__FILE__;
1587
		#可省略參數:
1588
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1589
		#$conf["rewrite"]="false";
1590
		#參考資料:
1591
		#無.
1592
		#備註:
1593
		#無.
1594
		$record=logs::record($conf);
1595
 
1596
		#如果執行失敗
1597
		if($record["status"]==="false"){
1598
 
1599
			#印出結果
1600
			var_dump($record);
1601
 
1602
			}#if end
1603
 
1604
		#異常結束執行
1605
		exit(1);
668 liveuser 1606
 
671 liveuser 1607
		}#if end
1608
 
1609
	#如果存在
1610
	if($checkMultiFileExist["allExist"]==="true"){
1611
 
1612
		#啟動服務的關鍵字
1613
		$serviceStartKeyWord="ExecStart=/usr/bin/ipBlockerd.php";
1614
 
1615
		#重新啟動服務的關鍵字
1616
		$serviceRestartKeyWord="ExecReload=killall ipBlockerd.php; sleep 10; ipBlockerd.php";
1617
 
1618
		#函式說明:
1619
		#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
1620
		#回傳的結果:
1621
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1622
		#$result["function"],當前執行的function名稱
1623
		#$result["error"],錯誤訊息陣列.
1624
		#$result["content"],處理好的字串.
1625
		#$result["argu"],使用的參數.
1626
		#必填參數:
1627
		#$conf["inputArray"],字串陣列,要轉成字串的一維陣列.
1628
		$conf["inputArray"]=$whiteIp;
1629
		#可省略參數:
1630
		#$conf["spiltSymbol"],字串,用來區隔字串的符號,預設為;
1631
		$conf["spiltSymbol"]=" --exclude ";
1632
		#$conf["skipEnd"],字串,結尾是否不要加上符號,預設為"false",要加上符號,"true"代表不要加上符號。
1633
		$conf["skipEnd"]="true";
1634
		#$conf["spiltSymbolAtStart"],字串,是否要在開頭加上spiltSymbol,預設為"false",代表不要;反之為“true”.
1635
		$conf["spiltSymbolAtStart"]="true";
1636
		#參考資料:
1637
		#無.
1638
		#備註:
1639
		#無.
1640
		$arrayToString=arrays::arrayToString($conf);
1641
		unset($conf);
1642
 
1643
		#如果執行出錯
1644
		if($arrayToString["status"]==="false"){
1645
 
1646
			#函式說明:
1647
			#撰寫log
1648
			#回傳結果:
1649
			#$result["status"],狀態,"true"或"false".
1650
			#$result["error"],錯誤訊息陣列.
1651
			#$result["function"],當前函式的名稱.
1652
			#$result["argu"],使用的參數.
1653
			#必填參數:
1654
			#$conf["path"],字串,log檔案的路徑與名稱.
1655
			$conf["path"]=$logFile;
1656
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1657
			$conf["content"]=$arrayToString;
1658
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1659
			$conf["fileArgu"]=__FILE__;
1660
			#可省略參數:
1661
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1662
			#$conf["rewrite"]="false";
1663
			#參考資料:
1664
			#無.
1665
			#備註:
1666
			#無.
1667
			$record=logs::record($conf);
1668
 
1669
			#如果執行失敗
1670
			if($record["status"]==="false"){
1671
 
1672
				#印出結果
1673
				var_dump($record);
1674
 
1675
				}#if end
1676
 
1677
			#異常結束執行
1678
			exit(1);
1679
 
1680
			}#if end
1681
 
1682
		#啟動服務的新內容
1683
		$serviceStartNewContent=$serviceStartKeyWord.$arrayToString["content"];
1684
 
1685
		#重新啟動服務的新內容
1686
		$serviceRestartNewContent=$serviceRestartKeyWord.$arrayToString["content"];
1687
 
1688
		#設置白名單ip
1689
		#函式說明:
1690
		#更新檔案的內容.
1691
		#回傳結果:
1692
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1693
		#$result["error"],錯誤訊息.
1694
		#$result["function"],當前執行的函數名稱.
1695
		#$result["content"],軟連結的資訊.
1696
		#必填參數:
1697
		#$conf["fileArgu"],字串,變數__FILE__的內容.
1698
		$conf["fileArgu"]=__FILE__;
1699
		#$conf["file"],字串,要更新的檔案位置與名稱.
673 liveuser 1700
		$conf["file"]="./qbpwcf/usr/lib/systemd/system/ip-blockerd.service";
671 liveuser 1701
		#可省略參數:
1702
		#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
1703
		#$conf["overWriteWith"]=array();
1704
		#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
1705
		$conf["replaceWith"]=array(array($serviceStartKeyWord,$serviceStartNewContent),array($serviceRestartKeyWord,$serviceRestartNewContent));
678 liveuser 1706
		#$conf["replaceLike"],字串,預設為"false",代表要完全符合關鍵字才能進行整行替換;反之為"true".
1707
		$conf["replaceLike"]="true";
671 liveuser 1708
		#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
1709
		#$conf["addToTailWhenNoMatch"]="false";
1710
		#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
1711
		#$conf["addToTailBeforeThat"]="?\>";
1712
		#參考資料:
1713
		#無.
1714
		#備註:
1715
		#無.
1716
		$updateFile=fileAccess::updateFile($conf);
1717
		unset($conf);
1718
 
1719
		#如果執行出錯
1720
		if($updateFile["status"]==="false"){
1721
 
1722
			#函式說明:
1723
			#撰寫log
1724
			#回傳結果:
1725
			#$result["status"],狀態,"true"或"false".
1726
			#$result["error"],錯誤訊息陣列.
1727
			#$result["function"],當前函式的名稱.
1728
			#$result["argu"],使用的參數.
1729
			#必填參數:
1730
			#$conf["path"],字串,log檔案的路徑與名稱.
1731
			$conf["path"]=$logFile;
1732
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1733
			$conf["content"]=$updateFile;
1734
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1735
			$conf["fileArgu"]=__FILE__;
1736
			#可省略參數:
1737
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1738
			#$conf["rewrite"]="false";
1739
			#參考資料:
1740
			#無.
1741
			#備註:
1742
			#無.
1743
			$record=logs::record($conf);
1744
 
1745
			#如果執行失敗
1746
			if($record["status"]==="false"){
1747
 
1748
				#印出結果
1749
				var_dump($record);
1750
 
1751
				}#if end
1752
 
1753
			#異常結束執行
1754
			exit(1);
1755
 
1756
			}#if end
1757
 
1758
		}#if end
1759
 
668 liveuser 1760
	}#if end
1761
 
402 liveuser 1762
#於 /etc/systemd/system 底下建立 $rootPath.$name."/usr/lib/systemd/system" 底下所有服務檔案的軟連結.
1763
#函式說明:
1764
#針對特定目錄下的內容建立軟連結.
1765
#回傳結果:
1766
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1767
#$result["error"],錯誤訊息.
1768
#$result["function"],當前執行的函數名稱.
1769
#$result["content"],字串陣列,每個建立的軟連結資訊.
1770
#必填參數:
1771
#$conf["fileArgu"],字串,變數__FILE__的內容.
1772
$conf["fileArgu"]=__FILE__;
1773
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
1774
$conf["linkToDir"]=$rootPath.$name."/usr/lib/systemd/system";
1775
#可省略參數:
1776
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
1777
$conf["path"]="/etc/systemd/system";
1778
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
1779
#$conf["name"]=array(array("oriName","newName"));
1780
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1781
$conf["overWrite"]="true";
1782
#參考資料:
1783
#無.
1784
#備註:
1785
#無.
1786
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
1787
unset($conf);
1788
 
1789
#如果執行失敗
1790
if($createMultiLinkInDir["status"]==="false"){
1791
 
1792
	#函式說明:
1793
	#撰寫log
1794
	#回傳結果:
1795
	#$result["status"],狀態,"true"或"false".
1796
	#$result["error"],錯誤訊息陣列.
1797
	#$result["function"],當前函式的名稱.
1798
	#$result["argu"],使用的參數.
1799
	#必填參數:
1800
	#$conf["path"],字串,log檔案的路徑與名稱.
1801
	$conf["path"]=$logFile;
1802
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1803
	$conf["content"]=$createMultiLinkInDir;
1804
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1805
	$conf["fileArgu"]=__FILE__;
1806
	#可省略參數:
1807
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1808
	#$conf["rewrite"]="false";
1809
	#參考資料:
1810
	#無.
1811
	#備註:
1812
	#無.
1813
	$record=logs::record($conf);
1814
 
1815
	#如果執行失敗
1816
	if($record["status"]==="false"){
1817
 
1818
		#印出結果
1819
		var_dump($record);
1820
 
1821
		}#if end
1822
 
409 liveuser 1823
	#異常結束執行
1824
	exit(1);
1825
 
402 liveuser 1826
	}#if end
1827
 
1828
#函式說明:
1829
#針對特定目錄下的內容建立軟連結.
1830
#回傳結果:
1831
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1832
#$result["error"],錯誤訊息.
1833
#$result["function"],當前執行的函數名稱.
1834
#$result["content"],字串陣列,每個建立的軟連結資訊.
1835
#必填參數:
1836
#$conf["fileArgu"],字串,變數__FILE__的內容.
1837
$conf["fileArgu"]=__FILE__;
1838
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
1839
$conf["linkToDir"]=$rootPath.$name."/usr/local/etc";
1840
#可省略參數:
1841
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
1842
$conf["path"]="/usr/local/etc";
1843
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
1844
#$conf["name"]=array(array("oriName","newName"));
1845
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1846
$conf["overWrite"]="true";
1847
#參考資料:
1848
#無.
1849
#備註:
1850
#無.
1851
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
1852
unset($conf);
1853
 
1854
#如果執行失敗
1855
if($createMultiLinkInDir["status"]==="false"){
1856
 
1857
	#函式說明:
1858
	#撰寫log
1859
	#回傳結果:
1860
	#$result["status"],狀態,"true"或"false".
1861
	#$result["error"],錯誤訊息陣列.
1862
	#$result["function"],當前函式的名稱.
1863
	#$result["argu"],使用的參數.
1864
	#必填參數:
1865
	#$conf["path"],字串,log檔案的路徑與名稱.
1866
	$conf["path"]=$logFile;
1867
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1868
	$conf["content"]=$createMultiLinkInDir;
1869
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1870
	$conf["fileArgu"]=__FILE__;
1871
	#可省略參數:
1872
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1873
	#$conf["rewrite"]="false";
1874
	#參考資料:
1875
	#無.
1876
	#備註:
1877
	#無.
1878
	$record=logs::record($conf);
1879
 
1880
	#如果執行失敗
1881
	if($record["status"]==="false"){
1882
 
1883
		#印出結果
1884
		var_dump($record);
1885
 
1886
		}#if end
409 liveuser 1887
 
1888
	#異常結束執行
1889
	exit(1);
402 liveuser 1890
 
1891
	}#if end
1892
 
1893
#systemctl daemon-reload
1894
#函式說明:
1895
#執行 systemd 程序來管理服務.
1896
#回傳結果:
1897
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1898
#$result["error"],錯誤訊息.
1899
#$result["function"],當前執行的函式名稱.
1900
#$result["argu"],所使用的參數.
1901
#$result["content"],執行的結果.
1902
#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
1903
#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
1904
#必填參數:
1905
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1906
$conf["fileArgu"]=__FILE__;
1907
#$conf["name"],字串,服務名稱.
1908
$conf["name"]="daemon-reload";
1909
#可省略參數:
1910
#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
1911
#$conf["operation"]="";
1912
#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
1913
#$conf["username"]="";
1914
#$conf["password"],字串,使用者的密碼,預設不使用.
1915
#$conf["password"]="";
1916
#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
1917
$conf["daemonReload"]="true";
1918
#參考資料:
1919
#無.
1920
#備註:
1921
#無.
1922
$systemd=cmd::systemd($conf);
1923
unset($conf);
1924
 
1925
#如果執行失敗
1926
if($systemd["status"]==="false"){
1927
 
1928
	#函式說明:
1929
	#撰寫log
1930
	#回傳結果:
1931
	#$result["status"],狀態,"true"或"false".
1932
	#$result["error"],錯誤訊息陣列.
1933
	#$result["function"],當前函式的名稱.
1934
	#$result["argu"],使用的參數.
1935
	#必填參數:
1936
	#$conf["path"],字串,log檔案的路徑與名稱.
1937
	$conf["path"]=$logFile;
1938
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1939
	$conf["content"]=$systemd;
1940
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1941
	$conf["fileArgu"]=__FILE__;
1942
	#可省略參數:
1943
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1944
	#$conf["rewrite"]="false";
1945
	#參考資料:
1946
	#無.
1947
	#備註:
1948
	#無.
1949
	$record=logs::record($conf);
1950
 
1951
	#如果執行失敗
1952
	if($record["status"]==="false"){
1953
 
1954
		#印出結果
1955
		var_dump($record);
1956
 
1957
		}#if end
409 liveuser 1958
 
1959
	#異常結束執行
1960
	exit(1);
402 liveuser 1961
 
1962
	}#if end
1963
 
1964
#enable and restart 於 $rootPath.$name."/usr/lib/systemd/system" 底下的所有服務
1965
 
1966
#函式說明:
1967
#取得目錄底下所有目錄與檔案清單.
1968
#回傳結果:
1969
#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1970
#$result["error"],錯誤訊息陣列.
1971
#$result["function"],函數名稱.
1972
#$result["content"],陣列,目錄底下的檔案與子目錄.
1973
#$result["content"][$i]["name"],字串,目錄底下的檔案與子目錄的名稱.
1974
#$result["content"][$i]["folder"],字串,第$i+1個名稱為目錄還是檔案.
1975
#$result["folder"],字串,當前目標為目錄還是檔案"true"代表為目錄,"false"代表為檔案.
1976
#$result["position"],目前的位置.
1977
#必填參數:
1978
#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
1979
$conf["position"]=$rootPath.$name."/usr/lib/systemd/system";
1980
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1981
$conf["fileArgu"]=__FILE__;
1982
#可省略參數:
1983
#無
1984
#參考資料:
1985
#opendir=>http://php.net/manual/en/function.opendir.php
1986
#is_dir=>http://php.net/manual/en/function.is-dir.php
1987
#備註:
1988
#無.
1989
$getList=fileAccess::getList($conf);
1990
unset($conf);
1991
 
1992
#如果執行失敗
1993
if($getList["status"]==="false"){
1994
 
1995
	#函式說明:
1996
	#撰寫log
1997
	#回傳結果:
1998
	#$result["status"],狀態,"true"或"false".
1999
	#$result["error"],錯誤訊息陣列.
2000
	#$result["function"],當前函式的名稱.
2001
	#$result["argu"],使用的參數.
2002
	#必填參數:
2003
	#$conf["path"],字串,log檔案的路徑與名稱.
2004
	$conf["path"]=$logFile;
2005
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2006
	$conf["content"]=$getList;
2007
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2008
	$conf["fileArgu"]=__FILE__;
2009
	#可省略參數:
2010
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2011
	#$conf["rewrite"]="false";
2012
	#參考資料:
2013
	#無.
2014
	#備註:
2015
	#無.
2016
	$record=logs::record($conf);
2017
 
2018
	#如果執行失敗
2019
	if($record["status"]==="false"){
2020
 
2021
		#印出結果
2022
		var_dump($record);
2023
 
2024
		}#if end
409 liveuser 2025
 
2026
	#異常結束執行
2027
	exit(1);
402 liveuser 2028
 
2029
	}#if end
2030
 
2031
#針對每個服務
2032
foreach($getList["content"] as $fileInfo){
2033
 
2034
	#取得服務的名稱
2035
	$serviceName=$fileInfo["name"];
2036
 
2037
	#函式說明:
2038
	#執行 systemd 程序來管理服務.
2039
	#回傳結果:
2040
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2041
	#$result["error"],錯誤訊息.
2042
	#$result["function"],當前執行的函式名稱.
2043
	#$result["argu"],所使用的參數.
2044
	#$result["content"],執行的結果.
2045
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
2046
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
2047
	#必填參數:
2048
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2049
	$conf["fileArgu"]=__FILE__;
2050
	#$conf["name"],字串,服務名稱.
2051
	$conf["name"]=$serviceName;
2052
	#可省略參數:
2053
	#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
2054
	$conf["operation"]="enable";
2055
	#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
2056
	#$conf["username"]="";
2057
	#$conf["password"],字串,使用者的密碼,預設不使用.
2058
	#$conf["password"]="";
2059
	#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
2060
	#$conf["daemonReload"]="true";
2061
	#參考資料:
2062
	#無.
2063
	#備註:
2064
	#無.
2065
	$systemd=cmd::systemd($conf);
2066
	unset($conf);
2067
 
2068
	#如果執行失敗
2069
	if($systemd["status"]==="false"){
2070
 
2071
		#函式說明:
2072
		#撰寫log
2073
		#回傳結果:
2074
		#$result["status"],狀態,"true"或"false".
2075
		#$result["error"],錯誤訊息陣列.
2076
		#$result["function"],當前函式的名稱.
2077
		#$result["argu"],使用的參數.
2078
		#必填參數:
2079
		#$conf["path"],字串,log檔案的路徑與名稱.
2080
		$conf["path"]=$logFile;
2081
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2082
		$conf["content"]=$systemd;
2083
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2084
		$conf["fileArgu"]=__FILE__;
2085
		#可省略參數:
2086
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2087
		#$conf["rewrite"]="false";
2088
		#參考資料:
2089
		#無.
2090
		#備註:
2091
		#無.
2092
		$record=logs::record($conf);
2093
 
2094
		#如果執行失敗
2095
		if($record["status"]==="false"){
2096
 
2097
			#印出結果
2098
			var_dump($record);
2099
 
2100
			}#if end
409 liveuser 2101
 
2102
		#異常結束執行
2103
		exit(1);
402 liveuser 2104
 
2105
		}#if end
2106
 
2107
	#函式說明:
2108
	#執行 systemd 程序來管理服務.
2109
	#回傳結果:
2110
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2111
	#$result["error"],錯誤訊息.
2112
	#$result["function"],當前執行的函式名稱.
2113
	#$result["argu"],所使用的參數.
2114
	#$result["content"],執行的結果.
2115
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
2116
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
2117
	#必填參數:
2118
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2119
	$conf["fileArgu"]=__FILE__;
2120
	#$conf["name"],字串,服務名稱.
2121
	$conf["name"]=$serviceName;
2122
	#可省略參數:
2123
	#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
2124
	$conf["operation"]="restart";
2125
	#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
2126
	#$conf["username"]="";
2127
	#$conf["password"],字串,使用者的密碼,預設不使用.
2128
	#$conf["password"]="";
2129
	#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
2130
	#$conf["daemonReload"]="true";
2131
	#參考資料:
2132
	#無.
2133
	#備註:
2134
	#無.
2135
	$systemd=cmd::systemd($conf);
2136
	unset($conf);
2137
 
2138
	#如果執行失敗
2139
	if($systemd["status"]==="false"){
2140
 
2141
		#函式說明:
2142
		#撰寫log
2143
		#回傳結果:
2144
		#$result["status"],狀態,"true"或"false".
2145
		#$result["error"],錯誤訊息陣列.
2146
		#$result["function"],當前函式的名稱.
2147
		#$result["argu"],使用的參數.
2148
		#必填參數:
2149
		#$conf["path"],字串,log檔案的路徑與名稱.
2150
		$conf["path"]=$logFile;
2151
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
2152
		$conf["content"]=$systemd;
2153
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
2154
		$conf["fileArgu"]=__FILE__;
2155
		#可省略參數:
2156
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
2157
		#$conf["rewrite"]="false";
2158
		#參考資料:
2159
		#無.
2160
		#備註:
2161
		#無.
2162
		$record=logs::record($conf);
2163
 
2164
		#如果執行失敗
2165
		if($record["status"]==="false"){
2166
 
2167
			#印出結果
2168
			var_dump($record);
2169
 
2170
			}#if end
409 liveuser 2171
 
2172
		#異常結束執行
2173
		exit(1);
402 liveuser 2174
 
2175
		}#if end
2176
 
2177
	}#foreach end
2178
 
2179
?>