Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 431 | Rev 488 | 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
 
6
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
7
    Copyright (C) 2015~2023 Min-Jhin,Chen
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
 
29
#匯入套件
30
require_once("qbpwcf/allInOne.php");
31
 
32
#建議的log位置
33
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
34
 
35
#該指令的 help 文件
36
function help(){
37
 
38
	#help
39
	echo basename($_SERVER["PHP_SELF"])." is a program to install QBPWCF.".PHP_EOL;
40
	echo basename($_SERVER["PHP_SELF"])." usage:".PHP_EOL;
41
	echo "If run it without any argument, QBPWCF will be install defaultly".PHP_EOL;
42
	echo "--rootPath path where QBPWCF to put. Default is /usr/lib/".PHP_EOL;
43
	echo "--name folder name where QBPWCF to put inside. Default is qbpwcf".PHP_EOL;
44
	echo "--mode cp/link, default is link".PHP_EOL;
45
	echo "\tcp means copy and overwrite to installation path".PHP_EOL;
46
	echo "\tlink means create a softlink from current path to installation path".PHP_EOL;
47
	echo "--ip ip address, specify self ip address, if need.".PHP_EOL;
48
	echo "--dbAddr MariaDb service address, default is \"localhost\"".PHP_EOL;
49
	echo "--dbAcct MariaDb service account, default is \"root\"".PHP_EOL;
50
	echo "--dbPass MariaDb service password, default is output of uuid command".PHP_EOL;
51
	echo "--dbName MariaDb service database name, default is test".PHP_EOL;
52
	echo "--dbPort MariaDb service port, default is 3306".PHP_EOL;
405 liveuser 53
	echo "--headless true/false, default is false. If true, it means link allInOneForCI.php to allInOne.php".PHP_EOL;
402 liveuser 54
	exit;
55
 
56
	}#function help end
57
 
58
#函式說明:
59
#解析參數.
60
#回傳結果:
61
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
62
#$reuslt["error"],執行不正常結束的錯訊息陣列.
63
#$result["function"],當前執行的函式名稱.
64
#$result["content"],解析好的參數陣列.
65
#$result["content"][$key][$i],參數 $key 的 $i+1 個參數數值內容.
66
#$result["program"],字串,執行的程式名稱.
67
#必填參數:
68
#無.
69
#可省略參數:
70
#$conf["helpFunc"],如果解析的參數不成對,則要執行的函式名稱.
71
$conf["helpFunc"]="help";
72
#參考資料:
73
#無.
74
#備註:
75
#僅能在命令列底下執行.
76
#以後可將參數 --a--b 的名稱與後面的數值 $value 存成 $result["a"]["b"][$i]=$value .
77
$parseArgu=cmd::parseArgu($conf);
78
unset($conf);
79
 
80
#如果執行失敗
81
if($parseArgu["status"]==="false"){
82
 
83
	#函式說明:
84
	#撰寫log
85
	#回傳結果:
86
	#$result["status"],狀態,"true"或"false".
87
	#$result["error"],錯誤訊息陣列.
88
	#$result["function"],當前函式的名稱.
89
	#$result["argu"],使用的參數.
90
	#必填參數:
91
	#$conf["path"],字串,log檔案的路徑與名稱.
92
	$conf["path"]=$logFile;
93
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
94
	$conf["content"]=$parseArgu;
95
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
96
	$conf["fileArgu"]=__FILE__;
97
	#可省略參數:
98
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
99
	#$conf["rewrite"]="false";
100
	#參考資料:
101
	#無.
102
	#備註:
103
	#無.
104
	$record=logs::record($conf);
105
 
106
	#如果執行失敗
107
	if($record["status"]==="false"){
108
 
109
		#印出結果
110
		var_dump($record);
111
 
112
		}#if end
113
 
409 liveuser 114
	#異常結束執行
115
	exit(1);
116
 
402 liveuser 117
	}#if end
118
 
119
#函式說明:
120
#使用 linux 的 uuid 指令來產生 uuid 字串
121
#回傳結果:
122
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
123
#$result["error"],錯誤訊息.
124
#$result["function"],當前執行的函式名稱.
125
#必填參數:
126
#無.
127
#可省略參數:
128
#無.
129
#參考資料:
130
#無.
131
#備註:
132
#無.
133
$uuid=cmd::uuid();
134
 
135
#如果執行失敗
136
if($uuid["status"]==="false"){
137
 
138
	#函式說明:
139
	#撰寫log
140
	#回傳結果:
141
	#$result["status"],狀態,"true"或"false".
142
	#$result["error"],錯誤訊息陣列.
143
	#$result["function"],當前函式的名稱.
144
	#$result["argu"],使用的參數.
145
	#必填參數:
146
	#$conf["path"],字串,log檔案的路徑與名稱.
147
	$conf["path"]=$logFile;
148
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
149
	$conf["content"]=$uuid;
150
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
151
	$conf["fileArgu"]=__FILE__;
152
	#可省略參數:
153
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
154
	#$conf["rewrite"]="false";
155
	#參考資料:
156
	#無.
157
	#備註:
158
	#無.
159
	$record=logs::record($conf);
160
 
161
	#如果執行失敗
162
	if($record["status"]==="false"){
163
 
164
		#印出結果
165
		var_dump($record);
166
 
167
		}#if end
409 liveuser 168
 
169
	#異常結束執行
170
	exit(1);
402 liveuser 171
 
172
	}#if end
173
 
174
#預設的套件安裝位置
175
$rootPath="/usr/lib/";
176
 
177
#預設的套件資料夾名稱
178
$name="qbpwcf";
179
 
180
#預設運作模式為 "link" 亦即建立軟連結
181
$mode="link";
182
 
183
#預設不指定自己的IP
184
$ip="";
185
 
186
#預設的資料庫連線帳號
187
$dbAcct="root";
188
 
189
#預設的資料庫連線密碼
190
$dbPass=$uuid["content"];
191
 
192
#預設的資料庫名稱
193
$dbName="test";
194
 
195
#預設到資料庫位置
196
$dbAddr="localhost";
197
 
198
#預設的資料庫port
199
$dbPort="3306";
200
 
405 liveuser 201
#預設要有自動輸出的內容
202
$headless="false";
203
 
402 liveuser 204
#檢查參數
205
#函式說明:
206
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
207
#回傳結果:
208
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
209
#$reuslt["error"],執行不正常結束的錯訊息陣列.
210
#$result["function"],當前執行的函式名稱.
211
#$result["argu"],設置給予的參數.
212
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
213
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
214
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
215
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
216
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
217
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
218
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
219
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
220
#必填參數:
221
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
222
$conf["varInput"]=&$parseArgu["content"];
223
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
224
$conf["referenceVarKey"]="variableCheck::checkArguments";
225
#可省略參數:
226
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
227
#$conf["mustBeFilledVariableName"]=array("");
228
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
229
#$conf["mustBeFilledVariableType"]=array();
230
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
231
#$conf["canBeEmptyString"]="false";
232
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
233
#$conf["canNotBeEmpty"]=array();
234
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
235
#$conf["canBeEmpty"]=array();
236
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
405 liveuser 237
$conf["skipableVariableCanNotBeEmpty"]=array("rootPath","name","mode","ip","dbAcct","dbPass","dbName","dbAddr","dbPort","headless");
402 liveuser 238
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
405 liveuser 239
$conf["skipableVariableName"]=array("rootPath","name","mode","ip","dbAcct","dbPass","dbName","dbAddr","dbPort","headless");
402 liveuser 240
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
405 liveuser 241
$conf["skipableVariableType"]=array("array","array","array","array","array","array","array","array","array","array");
402 liveuser 242
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
243
$conf["skipableVarDefaultValue"]=array(null,null,null,null);
244
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
245
#$conf["disallowAllSkipableVarIsEmpty"]="";
246
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
247
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
248
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
405 liveuser 249
$conf["arrayCountEqualCheck"][]=array("rootPath","name","mode","ip","dbAcct","dbPass","dbName","dbAddr","dbPort","headless");
402 liveuser 250
#參考資料:
251
#array_keys=>http://php.net/manual/en/function.array-keys.php
252
#備註:
253
#無.
254
$checkArguments=variableCheck::checkArguments($conf);
255
unset($conf);
256
 
257
#如果有設置參數
258
if(count($parseArgu["content"])>0){
259
 
260
	#如果有 rootPath 參數
261
	if(isset($parseArgu["content"]["rootPath"])){
262
 
263
		#如果有 rootPath 參數存在
264
		if(isset($parseArgu["content"]["rootPath"][0])){
265
 
266
			#更新套件的安裝位置
267
			$rootPath=$parseArgu["content"]["rootPath"][0];
268
 
269
			}#if end
270
 
271
		}#if enf
272
 
273
	#如果有 name 參數
274
	if(isset($parseArgu["content"]["name"])){
275
 
276
		#如果有 name 參數存在
277
		if(isset($parseArgu["content"]["name"][0])){
278
 
279
			#更新套件的資料夾名稱
280
			$name=$parseArgu["content"]["name"][0];
281
 
282
			}#if end
283
 
284
		}#if end
285
 
286
	#如果有 mode 參數
287
	if(isset($parseArgu["content"]["mode"])){
288
 
289
		#如果有 mode 參數存在
290
		if(isset($parseArgu["content"]["mode"][0])){
291
 
292
			#更新運作模式
293
			$mode=$parseArgu["content"]["mode"][0];
294
 
295
			}#if end
296
 
297
		}#if end
298
 
299
	#如果有 ip 參數
300
	if(isset($parseArgu["content"]["ip"])){
301
 
302
		#如果有 ip 參數存在
303
		if(isset($parseArgu["content"]["ip"][0])){
304
 
305
			#更新ip
306
			$ip=$parseArgu["content"]["ip"][0];
307
 
308
			}#if end
309
 
310
		}#if end
311
 
312
	#如果有 dbAcct 參數
313
	if(isset($parseArgu["content"]["dbAcct"])){
314
 
315
		#如果有 dbAcct 參數存在
316
		if(isset($parseArgu["content"]["dbAcct"][0])){
317
 
318
			#更新 dbAcct
319
			$dbAcct=$parseArgu["content"]["dbAcct"][0];
320
 
321
			}#if end
322
 
323
		}#if end
324
 
325
	#如果有 dbPass 參數
326
	if(isset($parseArgu["content"]["dbPass"])){
327
 
328
		#如果有 dbPass 參數存在
329
		if(isset($parseArgu["content"]["dbPass"][0])){
330
 
331
			#更新 dbPass
332
			$dbPass=$parseArgu["content"]["dbPass"][0];
333
 
334
			}#if end
335
 
336
		}#if end
337
 
338
	#如果有 dbName 參數
339
	if(isset($parseArgu["content"]["dbName"])){
340
 
341
		#如果有 dbName 參數存在
342
		if(isset($parseArgu["content"]["dbName"][0])){
343
 
344
			#更新 dbName
345
			$dbName=$parseArgu["content"]["dbName"][0];
346
 
347
			}#if end
348
 
349
		}#if end
350
 
351
	#如果有 dbAddr 參數
352
	if(isset($parseArgu["content"]["dbAddr"])){
353
 
354
		#如果有 dbAddr 參數存在
355
		if(isset($parseArgu["content"]["dbAddr"][0])){
356
 
357
			#更新 dbAddr
358
			$dbAddr=$parseArgu["content"]["dbAddr"][0];
359
 
360
			}#if end
361
 
362
		}#if end
363
 
364
	#如果有 dbPort 參數
365
	if(isset($parseArgu["content"]["dbPort"])){
366
 
367
		#如果有 dbPort 參數存在
368
		if(isset($parseArgu["content"]["dbPort"][0])){
369
 
370
			#更新 dbPort
371
			$dbPort=$parseArgu["content"]["dbPort"][0];
372
 
373
			}#if end
374
 
375
		}#if end
405 liveuser 376
 
377
	#如果有 headless 參數
378
	if(isset($parseArgu["content"]["headless"])){
379
 
380
		#如果有 headless 參數存在
381
		if(isset($parseArgu["content"]["headless"][0])){
382
 
383
			#更新 headless
384
			$headless=$parseArgu["content"]["headless"][0];
385
 
386
			}#if end
387
 
388
		}#if end
402 liveuser 389
 
390
	}#if end
391
 
405 liveuser 392
#如果要使用不自動輸出內容的 allInOneForCI.php 檔案
393
if($headless==="true"){
394
 
395
	#函式說明:
396
	#建立軟連結.
397
	#回傳結果:
398
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
399
	#$result["error"],錯誤訊息.
400
	#$result["function"],當前執行的函數名稱.
401
	#$result["content"],軟連結的資訊.
402
	#必填參數:
403
	#$conf["fileArgu"],字串,變數__FILE__的內容.
404
	$conf["fileArgu"]=__FILE__;
405
	#$conf["linkTo"],字串,軟連結要指向哪邊.
406
	$conf["linkTo"]="qbpwcf/allInOneForCI.php";
407
	#可省略參數:
408
	#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
409
	$conf["path"]="qbpwcf";
410
	#$conf["name"],字串,軟連結的名稱,預設為 "linkTo" 參數的檔案或目錄名稱.
411
	$conf["name"]="allInOne.php";
414 liveuser 412
	#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
413
	$conf["overWrite"]="true";
405 liveuser 414
	#參考資料:
415
	#無.
416
	#備註:
417
	#無.
418
	$createLink=fileAccess::createLink($conf);
419
	unset($conf);
420
 
414 liveuser 421
	#var_dump($createLink);
422
 
405 liveuser 423
	#如果執行失敗
424
	if($createLink["status"]==="false"){
425
 
426
		#函式說明:
427
		#撰寫log
428
		#回傳結果:
429
		#$result["status"],狀態,"true"或"false".
430
		#$result["error"],錯誤訊息陣列.
431
		#$result["function"],當前函式的名稱.
432
		#$result["argu"],使用的參數.
433
		#必填參數:
434
		#$conf["path"],字串,log檔案的路徑與名稱.
435
		$conf["path"]=$logFile;
436
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
437
		$conf["content"]=$createLink;
438
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
439
		$conf["fileArgu"]=__FILE__;
440
		#可省略參數:
441
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
442
		#$conf["rewrite"]="false";
443
		#參考資料:
444
		#無.
445
		#備註:
446
		#無.
447
		$record=logs::record($conf);
448
 
449
		#如果執行失敗
450
		if($record["status"]==="false"){
451
 
452
			#印出結果
453
			var_dump($record);
454
 
455
			}#if end
409 liveuser 456
 
457
		#異常結束執行
458
		exit(1);
405 liveuser 459
 
460
		}#if end
461
 
462
	}#if end
463
 
402 liveuser 464
#讓 "qbpwcf/usr/bin" 底下的所有檔案為可執行. 
465
#函式說明:
466
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
467
#回傳結果:
468
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
469
#$result["error"],錯誤訊息.
470
#$result["function"],當前執行的函式名稱.
471
#必填參數:
472
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
473
$conf["mode"]="+x";
474
#$conf["target"],字串,需要變更權限的目標.
475
$conf["target"]="qbpwcf/usr/bin";
476
#可省略參數:
477
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
478
$conf["recursive"]="true";
479
#參考資料:
480
#無.
481
#備註:
482
#無.
483
$chmod=cmd::chmod($conf);
484
unset($conf);
485
 
486
#如果執行失敗
409 liveuser 487
if($chmod["status"]==="false"){
402 liveuser 488
 
489
	#函式說明:
490
	#撰寫log
491
	#回傳結果:
492
	#$result["status"],狀態,"true"或"false".
493
	#$result["error"],錯誤訊息陣列.
494
	#$result["function"],當前函式的名稱.
495
	#$result["argu"],使用的參數.
496
	#必填參數:
497
	#$conf["path"],字串,log檔案的路徑與名稱.
498
	$conf["path"]=$logFile;
499
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
500
	$conf["content"]=$chmod;
501
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
502
	$conf["fileArgu"]=__FILE__;
503
	#可省略參數:
504
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
505
	#$conf["rewrite"]="false";
506
	#參考資料:
507
	#無.
508
	#備註:
509
	#無.
510
	$record=logs::record($conf);
511
 
512
	#如果執行失敗
513
	if($record["status"]==="false"){
514
 
515
		#印出結果
516
		var_dump($record);
517
 
518
		}#if end
409 liveuser 519
 
520
	#異常結束執行
521
	exit(1);
402 liveuser 522
 
523
	}#if end
524
 
525
#讓 "qbpwcf/db" 可以被大家使用.
526
#函式說明:
527
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
528
#回傳結果:
529
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
530
#$result["error"],錯誤訊息.
531
#$result["function"],當前執行的函式名稱.
532
#必填參數:
533
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
534
$conf["mode"]="777";
535
#$conf["target"],字串,需要變更權限的目標.
536
$conf["target"]="qbpwcf/db";
537
#可省略參數:
538
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
539
#$conf["recursive"]="";
540
#參考資料:
541
#無.
542
#備註:
543
#無.
544
$chmod=cmd::chmod($conf);
545
unset($conf);
546
 
547
#如果執行失敗
548
if($chmod["status"]==="false"){
549
 
550
	#函式說明:
551
	#撰寫log
552
	#回傳結果:
553
	#$result["status"],狀態,"true"或"false".
554
	#$result["error"],錯誤訊息陣列.
555
	#$result["function"],當前函式的名稱.
556
	#$result["argu"],使用的參數.
557
	#必填參數:
558
	#$conf["path"],字串,log檔案的路徑與名稱.
559
	$conf["path"]=$logFile;
560
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
561
	$conf["content"]=$chmod;
562
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
563
	$conf["fileArgu"]=__FILE__;
564
	#可省略參數:
565
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
566
	#$conf["rewrite"]="false";
567
	#參考資料:
568
	#無.
569
	#備註:
570
	#無.
571
	$record=logs::record($conf);
572
 
573
	#如果執行失敗
574
	if($record["status"]==="false"){
575
 
576
		#印出結果
577
		var_dump($record);
578
 
579
		}#if end
409 liveuser 580
 
581
	#異常結束執行
582
	exit(1);
402 liveuser 583
 
584
	}#if end
585
 
586
#如果 ip 有指定
587
if($ip!==""){
588
 
589
	#依照參數設定 $rootPath.$name."/etc/config.php
590
	#函式說明:
591
	#建立軟連結.
592
	#回傳結果:
593
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
594
	#$result["error"],錯誤訊息.
595
	#$result["function"],當前執行的函數名稱.
596
	#$result["content"],軟連結的資訊.
597
	#必填參數:
598
	#$conf["fileArgu"],字串,變數__FILE__的內容.
599
	$conf["fileArgu"]=__FILE__;
600
	#$conf["file"],字串,要更新的檔案位置與名稱.
601
	$conf["file"]="qbpwcf/etc/config.php";
602
	#可省略參數:
603
	#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
426 liveuser 604
	$conf["overWriteWith"]=array("<?php","\$myIp="."\"".$ip."\";","?>");
402 liveuser 605
	#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
606
	#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
607
	#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
608
	#$conf["addToTailWhenNoMatch"]="false";
609
	#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
610
	#$conf["addToTailBeforeThat"]="?\>";
611
	#參考資料:
612
	#無.
613
	#備註:
614
	#無.
424 liveuser 615
	$updateFile=fileAccess::updateFile($conf);
402 liveuser 616
	unset($conf);
617
 
618
	#如果執行失敗
619
	if($updateFile["status"]==="false"){
620
 
621
		#函式說明:
622
		#撰寫log
623
		#回傳結果:
624
		#$result["status"],狀態,"true"或"false".
625
		#$result["error"],錯誤訊息陣列.
626
		#$result["function"],當前函式的名稱.
627
		#$result["argu"],使用的參數.
628
		#必填參數:
629
		#$conf["path"],字串,log檔案的路徑與名稱.
630
		$conf["path"]=$logFile;
631
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
632
		$conf["content"]=$updateFile;
633
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
634
		$conf["fileArgu"]=__FILE__;
635
		#可省略參數:
636
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
637
		#$conf["rewrite"]="false";
638
		#參考資料:
639
		#無.
640
		#備註:
641
		#無.
642
		$record=logs::record($conf);
643
 
644
		#如果執行失敗
645
		if($record["status"]==="false"){
646
 
647
			#印出結果
648
			var_dump($record);
649
 
650
			}#if end
409 liveuser 651
 
652
		#異常結束執行
653
		exit(1);
402 liveuser 654
 
655
		}#if end
431 liveuser 656
 
657
	#讓 "qbpwcf/etc/config.php" 可以被大家使用.
658
	#函式說明:
659
	#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
660
	#回傳結果:
661
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
662
	#$result["error"],錯誤訊息.
663
	#$result["function"],當前執行的函式名稱.
664
	#必填參數:
665
	#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
666
	$conf["mode"]="777";
667
	#$conf["target"],字串,需要變更權限的目標.
668
	$conf["target"]="qbpwcf/etc/config.php";
669
	#可省略參數:
670
	#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
671
	#$conf["recursive"]="";
672
	#參考資料:
673
	#無.
674
	#備註:
675
	#無.
676
	$chmod=cmd::chmod($conf);
677
	unset($conf);
402 liveuser 678
 
431 liveuser 679
	#如果執行失敗
680
	if($chmod["status"]==="false"){
681
 
682
		#函式說明:
683
		#撰寫log
684
		#回傳結果:
685
		#$result["status"],狀態,"true"或"false".
686
		#$result["error"],錯誤訊息陣列.
687
		#$result["function"],當前函式的名稱.
688
		#$result["argu"],使用的參數.
689
		#必填參數:
690
		#$conf["path"],字串,log檔案的路徑與名稱.
691
		$conf["path"]=$logFile;
692
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
693
		$conf["content"]=$chmod;
694
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
695
		$conf["fileArgu"]=__FILE__;
696
		#可省略參數:
697
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
698
		#$conf["rewrite"]="false";
699
		#參考資料:
700
		#無.
701
		#備註:
702
		#無.
703
		$record=logs::record($conf);
704
 
705
		#如果執行失敗
706
		if($record["status"]==="false"){
707
 
708
			#印出結果
709
			var_dump($record);
710
 
711
			}#if end
712
 
713
		#異常結束執行
714
		exit(1);
715
 
716
		}#if end	
717
 
402 liveuser 718
	}#if end
719
 
720
#依照參數設定 "qbpwcf/usr/local/etc/backupDb.conf"
721
#函式說明:
722
#建立軟連結.
723
#回傳結果:
724
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
725
#$result["error"],錯誤訊息.
726
#$result["function"],當前執行的函數名稱.
727
#$result["content"],軟連結的資訊.
728
#必填參數:
729
#$conf["fileArgu"],字串,變數__FILE__的內容.
730
$conf["fileArgu"]=__FILE__;
731
#$conf["file"],字串,要更新的檔案位置與名稱.
732
$conf["file"]="qbpwcf/usr/local/etc/backupDb.conf";
733
#可省略參數:
734
#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
735
$conf["overWriteWith"]=array();
736
$conf["overWriteWith"][]="<?php";
737
$conf["overWriteWith"][]="#資料庫連線帳號";
738
$conf["overWriteWith"][]="\$dbAcct=\"".$dbAcct."\";";
739
$conf["overWriteWith"][]="";
740
$conf["overWriteWith"][]="#資料庫連線密碼";
741
$conf["overWriteWith"][]="\$dbPass=\"".$dbPass."\";";
742
$conf["overWriteWith"][]="";
743
$conf["overWriteWith"][]="#資料庫名稱";
744
$conf["overWriteWith"][]="\$dbName=\"".$dbName."\";";
745
$conf["overWriteWith"][]="";
746
$conf["overWriteWith"][]="#資料庫位置";
747
$conf["overWriteWith"][]="\$dbAddr=\"".$dbAddr."\";";
748
$conf["overWriteWith"][]="";
749
$conf["overWriteWith"][]="#資料庫port";
750
$conf["overWriteWith"][]="\$dbPort=\"".$dbPort."\";";
751
#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
752
#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
753
#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
754
#$conf["addToTailWhenNoMatch"]="false";
755
#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
756
#$conf["addToTailBeforeThat"]="?\>";
757
#參考資料:
758
#無.
759
#備註:
760
#無.
409 liveuser 761
$updateFile=fileAccess::updateFile($conf);
402 liveuser 762
unset($conf);
763
 
764
#如果執行失敗
765
if($updateFile["status"]==="false"){
766
 
767
	#函式說明:
768
	#撰寫log
769
	#回傳結果:
770
	#$result["status"],狀態,"true"或"false".
771
	#$result["error"],錯誤訊息陣列.
772
	#$result["function"],當前函式的名稱.
773
	#$result["argu"],使用的參數.
774
	#必填參數:
775
	#$conf["path"],字串,log檔案的路徑與名稱.
776
	$conf["path"]=$logFile;
777
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
778
	$conf["content"]=$updateFile;
779
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
780
	$conf["fileArgu"]=__FILE__;
781
	#可省略參數:
782
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
783
	#$conf["rewrite"]="false";
784
	#參考資料:
785
	#無.
786
	#備註:
787
	#無.
788
	$record=logs::record($conf);
789
 
790
	#如果執行失敗
791
	if($record["status"]==="false"){
792
 
793
		#印出結果
794
		var_dump($record);
795
 
796
		}#if end
409 liveuser 797
 
798
	#異常結束執行
799
	exit(1);
402 liveuser 800
 
801
	}#if end
802
 
803
#重新建置 qbpwcf/usr/local/etc/qbpwcf.conf.xml
804
#函式說明:
805
#建立軟連結.
806
#回傳結果:
807
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
808
#$result["error"],錯誤訊息.
809
#$result["function"],當前執行的函數名稱.
810
#$result["content"],軟連結的資訊.
811
#必填參數:
812
#$conf["fileArgu"],字串,變數__FILE__的內容.
813
$conf["fileArgu"]=__FILE__;
814
#$conf["file"],字串,要更新的檔案位置與名稱.
815
$conf["file"]="qbpwcf/usr/local/etc/qbpwcf.conf.xml";
816
#可省略參數:
817
#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
818
$conf["overWriteWith"]=array();
819
$conf["overWriteWith"][]="<?xml version=\"1.0\"?>";
820
$conf["overWriteWith"][]="<root></root>";
821
#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
822
#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
823
#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
824
#$conf["addToTailWhenNoMatch"]="false";
825
#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
826
#$conf["addToTailBeforeThat"]="?\>";
827
#參考資料:
828
#無.
829
#備註:
830
#無.
409 liveuser 831
$updateFile=fileAccess::updateFile($conf);
402 liveuser 832
unset($conf);
833
 
834
#如果執行失敗
835
if($updateFile["status"]==="false"){
836
 
837
	#函式說明:
838
	#撰寫log
839
	#回傳結果:
840
	#$result["status"],狀態,"true"或"false".
841
	#$result["error"],錯誤訊息陣列.
842
	#$result["function"],當前函式的名稱.
843
	#$result["argu"],使用的參數.
844
	#必填參數:
845
	#$conf["path"],字串,log檔案的路徑與名稱.
846
	$conf["path"]=$logFile;
847
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
848
	$conf["content"]=$updateFile;
849
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
850
	$conf["fileArgu"]=__FILE__;
851
	#可省略參數:
852
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
853
	#$conf["rewrite"]="false";
854
	#參考資料:
855
	#無.
856
	#備註:
857
	#無.
858
	$record=logs::record($conf);
859
 
860
	#如果執行失敗
861
	if($record["status"]==="false"){
862
 
863
		#印出結果
864
		var_dump($record);
865
 
866
		}#if end
409 liveuser 867
 
868
	#異常結束執行
869
	exit(1);
402 liveuser 870
 
871
	}#if end
872
 
873
#讓 "qbpwcf/usr/local/etc/qbpwcf.conf.xml" 可以被大家使用.
874
#函式說明:
875
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
876
#回傳結果:
877
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
878
#$result["error"],錯誤訊息.
879
#$result["function"],當前執行的函式名稱.
880
#必填參數:
881
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
882
$conf["mode"]="777";
883
#$conf["target"],字串,需要變更權限的目標.
884
$conf["target"]="qbpwcf/usr/local/etc/qbpwcf.conf.xml";
885
#可省略參數:
886
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
887
#$conf["recursive"]="";
888
#參考資料:
889
#無.
890
#備註:
891
#無.
892
$chmod=cmd::chmod($conf);
893
unset($conf);
894
 
895
#如果執行失敗
896
if($chmod["status"]==="false"){
897
 
898
	#函式說明:
899
	#撰寫log
900
	#回傳結果:
901
	#$result["status"],狀態,"true"或"false".
902
	#$result["error"],錯誤訊息陣列.
903
	#$result["function"],當前函式的名稱.
904
	#$result["argu"],使用的參數.
905
	#必填參數:
906
	#$conf["path"],字串,log檔案的路徑與名稱.
907
	$conf["path"]=$logFile;
908
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
909
	$conf["content"]=$chmod;
910
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
911
	$conf["fileArgu"]=__FILE__;
912
	#可省略參數:
913
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
914
	#$conf["rewrite"]="false";
915
	#參考資料:
916
	#無.
917
	#備註:
918
	#無.
919
	$record=logs::record($conf);
920
 
921
	#如果執行失敗
922
	if($record["status"]==="false"){
923
 
924
		#印出結果
925
		var_dump($record);
926
 
927
		}#if end
409 liveuser 928
 
929
	#異常結束執行
930
	exit(1);
402 liveuser 931
 
932
	}#if end
933
 
419 liveuser 934
#移除 qbpwcf/usr/lib/systemd/system 底下服務設定檔的執行權限
935
#函式說明:
936
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
937
#回傳結果:
938
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
939
#$result["error"],錯誤訊息.
940
#$result["function"],當前執行的函式名稱.
941
#必填參數:
942
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
469 liveuser 943
$conf["mode"]="640";
419 liveuser 944
#$conf["target"],字串,需要變更權限的目標.
945
$conf["target"]="qbpwcf/usr/lib/systemd/system";
946
#可省略參數:
947
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
948
$conf["recursive"]="true";
949
#$conf["excludeSelf"],字串,預設為"false"代表不處理;若為"true"則會排除目標自己(資料夾).
950
$conf["excludeSelf"]="true";
951
#參考資料:
952
#無.
953
#備註:
954
#無.
955
$chmod=cmd::chmod($conf);
956
unset($conf);
957
 
958
#如果執行失敗
959
if($chmod["status"]==="false"){
960
 
961
	#函式說明:
962
	#撰寫log
963
	#回傳結果:
964
	#$result["status"],狀態,"true"或"false".
965
	#$result["error"],錯誤訊息陣列.
966
	#$result["function"],當前函式的名稱.
967
	#$result["argu"],使用的參數.
968
	#必填參數:
969
	#$conf["path"],字串,log檔案的路徑與名稱.
970
	$conf["path"]=$logFile;
971
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
972
	$conf["content"]=$chmod;
973
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
974
	$conf["fileArgu"]=__FILE__;
975
	#可省略參數:
976
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
977
	#$conf["rewrite"]="false";
978
	#參考資料:
979
	#無.
980
	#備註:
981
	#無.
982
	$record=logs::record($conf);
983
 
984
	#如果執行失敗
985
	if($record["status"]==="false"){
986
 
987
		#印出結果
988
		var_dump($record);
989
 
990
		}#if end
991
 
992
	#異常結束執行
993
	exit(1);
994
 
995
	}#if end
996
 
402 liveuser 997
#判斷 $mode
998
switch($mode){
999
 
1000
	#如果是 "cp" mode
1001
	case "cp":
1002
 
1003
		#函式說明:
1004
		#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
1005
		#回傳結果:
1006
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1007
		#$result["error"],錯誤訊息陣列
1008
		#$result["warning"],警告訊息陣列
1009
		#$result["argu"],使用的參數.
1010
		#$result["content"],建立的目錄路徑.
1011
		#必填參數:
1012
		#$conf["dirPositionAndName"]="";#新建的位置與名稱
1013
		$conf["dirPositionAndName"]=$rootPath.$name;
1014
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1015
		$conf["fileArgu"]=__FILE__;
1016
		#可省略參數:
1017
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
1018
		#$conf["dirPermission"]="";
1019
		#$conf["web"],"false"代表在檔案系統環境,"true"代表在網頁稀系統環境.
1020
		#$conf["web"]="false";
1021
		#參考資料:
1022
		#mkdir=>http://php.net/manual/en/function.mkdir.php
1023
		#chmod=>http://php.net/manual/en/function.chmod.php
1024
		#備註:
1025
		#無.
1026
		$createFolderAfterCheck=fileAccess::createFolderAfterCheck($conf);
1027
		unset($conf);
1028
 
1029
		#如果執行失敗
1030
		if($createFolderAfterCheck["status"]==="false"){
1031
 
1032
			#函式說明:
1033
			#撰寫log
1034
			#回傳結果:
1035
			#$result["status"],狀態,"true"或"false".
1036
			#$result["error"],錯誤訊息陣列.
1037
			#$result["function"],當前函式的名稱.
1038
			#$result["argu"],使用的參數.
1039
			#必填參數:
1040
			#$conf["path"],字串,log檔案的路徑與名稱.
1041
			$conf["path"]=$logFile;
1042
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1043
			$conf["content"]=$createFolderAfterCheck;
1044
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1045
			$conf["fileArgu"]=__FILE__;
1046
			#可省略參數:
1047
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1048
			#$conf["rewrite"]="false";
1049
			#參考資料:
1050
			#無.
1051
			#備註:
1052
			#無.
1053
			$record=logs::record($conf);
1054
 
1055
			#如果執行失敗
1056
			if($record["status"]==="false"){
1057
 
1058
				#印出結果
1059
				var_dump($record);
1060
 
1061
				}#if end
409 liveuser 1062
 
1063
			#異常結束執行
1064
			exit(1);
402 liveuser 1065
 
1066
			}#if end
1067
 
1068
		#複製套件
1069
		#函式說明:
1070
		#複製檔案、資料夾.
1071
		#回傳結果:
1072
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1073
		#$result["error"],錯誤訊息.
1074
		#$result["function"],當前執行的函式名稱.
1075
		#$result["content"],複製好的檔案路徑與名稱.
1076
		#必填參數:
1077
		#$conf["file"],字串,檔案的位置與名稱.
1078
		$conf["file"]="../";
1079
		#$conf["to"],字串,檔案要複製到哪裡.
1080
		$conf["to"]=$rootPath.$name;
1081
		#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
1082
		$conf["fileArgu"]=__FILE__;
1083
		#可省略參數:
1084
		#$conf["username"],字串,要以哪個使用者來執行,預設為執行該php程式的使用者.
1085
		#$conf["username"]="";
1086
		#$conf["password"],字串,使用者對應的密碼,預設不使用.
1087
		#$conf["password"]="";
1088
		#參考資料:
1089
		#無.
1090
		#備註:
1091
		#僅能在命令列環境下運行
1092
		$cp=cmd::cp($conf);
1093
		unset($conf);
1094
 
1095
		#如果執行失敗
1096
		if($cp["status"]==="false"){
1097
 
1098
			#函式說明:
1099
			#撰寫log
1100
			#回傳結果:
1101
			#$result["status"],狀態,"true"或"false".
1102
			#$result["error"],錯誤訊息陣列.
1103
			#$result["function"],當前函式的名稱.
1104
			#$result["argu"],使用的參數.
1105
			#必填參數:
1106
			#$conf["path"],字串,log檔案的路徑與名稱.
1107
			$conf["path"]=$logFile;
1108
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1109
			$conf["content"]=$cp;
1110
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1111
			$conf["fileArgu"]=__FILE__;
1112
			#可省略參數:
1113
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1114
			#$conf["rewrite"]="false";
1115
			#參考資料:
1116
			#無.
1117
			#備註:
1118
			#無.
1119
			$record=logs::record($conf);
1120
 
1121
			#如果執行失敗
1122
			if($record["status"]==="false"){
1123
 
1124
				#印出結果
1125
				var_dump($record);
1126
 
1127
				}#if end
1128
 
409 liveuser 1129
			#異常結束執行
1130
			exit(1);
1131
 
402 liveuser 1132
			}#if end
1133
 
1134
		break;
1135
 
1136
	#如果是 "link" mode
1137
	case "link":
1138
 
1139
		#函式說明:
1140
		#建立軟連結.
1141
		#回傳結果:
1142
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1143
		#$result["error"],錯誤訊息.
1144
		#$result["function"],當前執行的函數名稱.
1145
		#$result["content"],軟連結的資訊.
1146
		#必填參數:
1147
		#$conf["fileArgu"],字串,變數__FILE__的內容.
1148
		$conf["fileArgu"]=__FILE__;
1149
		#$conf["linkTo"],字串,軟連結要指向哪邊.
409 liveuser 1150
		$conf["linkTo"]="qbpwcf";
402 liveuser 1151
		#可省略參數:
1152
		#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
409 liveuser 1153
		$conf["path"]=$rootPath;
402 liveuser 1154
		#$conf["name"],字串,軟連結的名稱,預設為 "linkTo" 參數的檔案或目錄名稱.
409 liveuser 1155
		$conf["name"]=$name;
1156
		#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1157
		$conf["overWrite"]="true";
402 liveuser 1158
		#參考資料:
1159
		#無.
1160
		#備註:
1161
		#無.
1162
		$createLink=fileAccess::createLink($conf);
1163
		unset($conf);
1164
 
1165
		#如果執行失敗
1166
		if($createLink["status"]==="false"){
1167
 
1168
			#函式說明:
1169
			#撰寫log
1170
			#回傳結果:
1171
			#$result["status"],狀態,"true"或"false".
1172
			#$result["error"],錯誤訊息陣列.
1173
			#$result["function"],當前函式的名稱.
1174
			#$result["argu"],使用的參數.
1175
			#必填參數:
1176
			#$conf["path"],字串,log檔案的路徑與名稱.
1177
			$conf["path"]=$logFile;
1178
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1179
			$conf["content"]=$createLink;
1180
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1181
			$conf["fileArgu"]=__FILE__;
1182
			#可省略參數:
1183
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1184
			#$conf["rewrite"]="false";
1185
			#參考資料:
1186
			#無.
1187
			#備註:
1188
			#無.
1189
			$record=logs::record($conf);
1190
 
1191
			#如果執行失敗
1192
			if($record["status"]==="false"){
1193
 
1194
				#印出結果
1195
				var_dump($record);
1196
 
1197
				}#if end
409 liveuser 1198
 
1199
			#異常結束執行
1200
			exit(1);
402 liveuser 1201
 
1202
			}#if end
1203
 
1204
		break;
1205
 
1206
	default:
1207
 
1208
		#函式說明:
1209
		#撰寫log
1210
		#回傳結果:
1211
		#$result["status"],狀態,"true"或"false".
1212
		#$result["error"],錯誤訊息陣列.
1213
		#$result["function"],當前函式的名稱.
1214
		#$result["argu"],使用的參數.
1215
		#必填參數:
1216
		#$conf["path"],字串,log檔案的路徑與名稱.
1217
		$conf["path"]=$logFile;
1218
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1219
		$conf["content"]="mode \"".$mode."\" not supported!";
1220
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1221
		$conf["fileArgu"]=__FILE__;
1222
		#可省略參數:
1223
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1224
		#$conf["rewrite"]="false";
1225
		#參考資料:
1226
		#無.
1227
		#備註:
1228
		#無.
1229
		$record=logs::record($conf);
1230
 
1231
		#如果執行失敗
1232
		if($record["status"]==="false"){
1233
 
1234
			#印出結果
1235
			var_dump($record);
1236
 
1237
			}#if end
409 liveuser 1238
 
1239
		#異常結束執行
1240
		exit(1);
402 liveuser 1241
 
1242
	}#switch end
1243
 
1244
#於 /usr/bin 底下建立 $rootPath.$name."/usr/bin" 底下所有檔案的軟連結.
1245
#函式說明:
1246
#針對特定目錄下的內容建立軟連結.
1247
#回傳結果:
1248
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1249
#$result["error"],錯誤訊息.
1250
#$result["function"],當前執行的函數名稱.
1251
#$result["content"],字串陣列,每個建立的軟連結資訊.
1252
#必填參數:
1253
#$conf["fileArgu"],字串,變數__FILE__的內容.
1254
$conf["fileArgu"]=__FILE__;
1255
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
1256
$conf["linkToDir"]=$rootPath.$name."/usr/bin";
1257
#可省略參數:
1258
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
1259
$conf["path"]="/usr/bin";
1260
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
1261
#$conf["name"]=array(array("oriName","newName"));
1262
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1263
$conf["overWrite"]="true";
1264
#參考資料:
1265
#無.
1266
#備註:
1267
#無.
1268
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
1269
unset($conf);
1270
 
1271
#如果執行失敗
1272
if($createMultiLinkInDir["status"]==="false"){
1273
 
1274
	#函式說明:
1275
	#撰寫log
1276
	#回傳結果:
1277
	#$result["status"],狀態,"true"或"false".
1278
	#$result["error"],錯誤訊息陣列.
1279
	#$result["function"],當前函式的名稱.
1280
	#$result["argu"],使用的參數.
1281
	#必填參數:
1282
	#$conf["path"],字串,log檔案的路徑與名稱.
1283
	$conf["path"]=$logFile;
1284
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1285
	$conf["content"]=$createMultiLinkInDir;
1286
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1287
	$conf["fileArgu"]=__FILE__;
1288
	#可省略參數:
1289
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1290
	#$conf["rewrite"]="false";
1291
	#參考資料:
1292
	#無.
1293
	#備註:
1294
	#無.
1295
	$record=logs::record($conf);
1296
 
1297
	#如果執行失敗
1298
	if($record["status"]==="false"){
1299
 
1300
		#印出結果
1301
		var_dump($record);
1302
 
1303
		}#if end
409 liveuser 1304
 
1305
	#異常結束執行
1306
	exit(1);
402 liveuser 1307
 
1308
	}#if end
1309
 
1310
#於 /etc/systemd/system 底下建立 $rootPath.$name."/usr/lib/systemd/system" 底下所有服務檔案的軟連結.
1311
#函式說明:
1312
#針對特定目錄下的內容建立軟連結.
1313
#回傳結果:
1314
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1315
#$result["error"],錯誤訊息.
1316
#$result["function"],當前執行的函數名稱.
1317
#$result["content"],字串陣列,每個建立的軟連結資訊.
1318
#必填參數:
1319
#$conf["fileArgu"],字串,變數__FILE__的內容.
1320
$conf["fileArgu"]=__FILE__;
1321
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
1322
$conf["linkToDir"]=$rootPath.$name."/usr/lib/systemd/system";
1323
#可省略參數:
1324
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
1325
$conf["path"]="/etc/systemd/system";
1326
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
1327
#$conf["name"]=array(array("oriName","newName"));
1328
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1329
$conf["overWrite"]="true";
1330
#參考資料:
1331
#無.
1332
#備註:
1333
#無.
1334
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
1335
unset($conf);
1336
 
1337
#如果執行失敗
1338
if($createMultiLinkInDir["status"]==="false"){
1339
 
1340
	#函式說明:
1341
	#撰寫log
1342
	#回傳結果:
1343
	#$result["status"],狀態,"true"或"false".
1344
	#$result["error"],錯誤訊息陣列.
1345
	#$result["function"],當前函式的名稱.
1346
	#$result["argu"],使用的參數.
1347
	#必填參數:
1348
	#$conf["path"],字串,log檔案的路徑與名稱.
1349
	$conf["path"]=$logFile;
1350
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1351
	$conf["content"]=$createMultiLinkInDir;
1352
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1353
	$conf["fileArgu"]=__FILE__;
1354
	#可省略參數:
1355
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1356
	#$conf["rewrite"]="false";
1357
	#參考資料:
1358
	#無.
1359
	#備註:
1360
	#無.
1361
	$record=logs::record($conf);
1362
 
1363
	#如果執行失敗
1364
	if($record["status"]==="false"){
1365
 
1366
		#印出結果
1367
		var_dump($record);
1368
 
1369
		}#if end
1370
 
409 liveuser 1371
	#異常結束執行
1372
	exit(1);
1373
 
402 liveuser 1374
	}#if end
1375
 
1376
#函式說明:
1377
#針對特定目錄下的內容建立軟連結.
1378
#回傳結果:
1379
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1380
#$result["error"],錯誤訊息.
1381
#$result["function"],當前執行的函數名稱.
1382
#$result["content"],字串陣列,每個建立的軟連結資訊.
1383
#必填參數:
1384
#$conf["fileArgu"],字串,變數__FILE__的內容.
1385
$conf["fileArgu"]=__FILE__;
1386
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
1387
$conf["linkToDir"]=$rootPath.$name."/usr/local/etc";
1388
#可省略參數:
1389
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
1390
$conf["path"]="/usr/local/etc";
1391
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
1392
#$conf["name"]=array(array("oriName","newName"));
1393
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1394
$conf["overWrite"]="true";
1395
#參考資料:
1396
#無.
1397
#備註:
1398
#無.
1399
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
1400
unset($conf);
1401
 
1402
#如果執行失敗
1403
if($createMultiLinkInDir["status"]==="false"){
1404
 
1405
	#函式說明:
1406
	#撰寫log
1407
	#回傳結果:
1408
	#$result["status"],狀態,"true"或"false".
1409
	#$result["error"],錯誤訊息陣列.
1410
	#$result["function"],當前函式的名稱.
1411
	#$result["argu"],使用的參數.
1412
	#必填參數:
1413
	#$conf["path"],字串,log檔案的路徑與名稱.
1414
	$conf["path"]=$logFile;
1415
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1416
	$conf["content"]=$createMultiLinkInDir;
1417
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1418
	$conf["fileArgu"]=__FILE__;
1419
	#可省略參數:
1420
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1421
	#$conf["rewrite"]="false";
1422
	#參考資料:
1423
	#無.
1424
	#備註:
1425
	#無.
1426
	$record=logs::record($conf);
1427
 
1428
	#如果執行失敗
1429
	if($record["status"]==="false"){
1430
 
1431
		#印出結果
1432
		var_dump($record);
1433
 
1434
		}#if end
409 liveuser 1435
 
1436
	#異常結束執行
1437
	exit(1);
402 liveuser 1438
 
1439
	}#if end
1440
 
1441
#systemctl daemon-reload
1442
#函式說明:
1443
#執行 systemd 程序來管理服務.
1444
#回傳結果:
1445
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1446
#$result["error"],錯誤訊息.
1447
#$result["function"],當前執行的函式名稱.
1448
#$result["argu"],所使用的參數.
1449
#$result["content"],執行的結果.
1450
#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
1451
#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
1452
#必填參數:
1453
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1454
$conf["fileArgu"]=__FILE__;
1455
#$conf["name"],字串,服務名稱.
1456
$conf["name"]="daemon-reload";
1457
#可省略參數:
1458
#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
1459
#$conf["operation"]="";
1460
#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
1461
#$conf["username"]="";
1462
#$conf["password"],字串,使用者的密碼,預設不使用.
1463
#$conf["password"]="";
1464
#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
1465
$conf["daemonReload"]="true";
1466
#參考資料:
1467
#無.
1468
#備註:
1469
#無.
1470
$systemd=cmd::systemd($conf);
1471
unset($conf);
1472
 
1473
#如果執行失敗
1474
if($systemd["status"]==="false"){
1475
 
1476
	#函式說明:
1477
	#撰寫log
1478
	#回傳結果:
1479
	#$result["status"],狀態,"true"或"false".
1480
	#$result["error"],錯誤訊息陣列.
1481
	#$result["function"],當前函式的名稱.
1482
	#$result["argu"],使用的參數.
1483
	#必填參數:
1484
	#$conf["path"],字串,log檔案的路徑與名稱.
1485
	$conf["path"]=$logFile;
1486
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1487
	$conf["content"]=$systemd;
1488
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1489
	$conf["fileArgu"]=__FILE__;
1490
	#可省略參數:
1491
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1492
	#$conf["rewrite"]="false";
1493
	#參考資料:
1494
	#無.
1495
	#備註:
1496
	#無.
1497
	$record=logs::record($conf);
1498
 
1499
	#如果執行失敗
1500
	if($record["status"]==="false"){
1501
 
1502
		#印出結果
1503
		var_dump($record);
1504
 
1505
		}#if end
409 liveuser 1506
 
1507
	#異常結束執行
1508
	exit(1);
402 liveuser 1509
 
1510
	}#if end
1511
 
1512
#enable and restart 於 $rootPath.$name."/usr/lib/systemd/system" 底下的所有服務
1513
 
1514
#函式說明:
1515
#取得目錄底下所有目錄與檔案清單.
1516
#回傳結果:
1517
#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1518
#$result["error"],錯誤訊息陣列.
1519
#$result["function"],函數名稱.
1520
#$result["content"],陣列,目錄底下的檔案與子目錄.
1521
#$result["content"][$i]["name"],字串,目錄底下的檔案與子目錄的名稱.
1522
#$result["content"][$i]["folder"],字串,第$i+1個名稱為目錄還是檔案.
1523
#$result["folder"],字串,當前目標為目錄還是檔案"true"代表為目錄,"false"代表為檔案.
1524
#$result["position"],目前的位置.
1525
#必填參數:
1526
#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
1527
$conf["position"]=$rootPath.$name."/usr/lib/systemd/system";
1528
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1529
$conf["fileArgu"]=__FILE__;
1530
#可省略參數:
1531
#無
1532
#參考資料:
1533
#opendir=>http://php.net/manual/en/function.opendir.php
1534
#is_dir=>http://php.net/manual/en/function.is-dir.php
1535
#備註:
1536
#無.
1537
$getList=fileAccess::getList($conf);
1538
unset($conf);
1539
 
1540
#如果執行失敗
1541
if($getList["status"]==="false"){
1542
 
1543
	#函式說明:
1544
	#撰寫log
1545
	#回傳結果:
1546
	#$result["status"],狀態,"true"或"false".
1547
	#$result["error"],錯誤訊息陣列.
1548
	#$result["function"],當前函式的名稱.
1549
	#$result["argu"],使用的參數.
1550
	#必填參數:
1551
	#$conf["path"],字串,log檔案的路徑與名稱.
1552
	$conf["path"]=$logFile;
1553
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1554
	$conf["content"]=$getList;
1555
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1556
	$conf["fileArgu"]=__FILE__;
1557
	#可省略參數:
1558
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1559
	#$conf["rewrite"]="false";
1560
	#參考資料:
1561
	#無.
1562
	#備註:
1563
	#無.
1564
	$record=logs::record($conf);
1565
 
1566
	#如果執行失敗
1567
	if($record["status"]==="false"){
1568
 
1569
		#印出結果
1570
		var_dump($record);
1571
 
1572
		}#if end
409 liveuser 1573
 
1574
	#異常結束執行
1575
	exit(1);
402 liveuser 1576
 
1577
	}#if end
1578
 
1579
#針對每個服務
1580
foreach($getList["content"] as $fileInfo){
1581
 
1582
	#取得服務的名稱
1583
	$serviceName=$fileInfo["name"];
1584
 
1585
	#函式說明:
1586
	#執行 systemd 程序來管理服務.
1587
	#回傳結果:
1588
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1589
	#$result["error"],錯誤訊息.
1590
	#$result["function"],當前執行的函式名稱.
1591
	#$result["argu"],所使用的參數.
1592
	#$result["content"],執行的結果.
1593
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
1594
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
1595
	#必填參數:
1596
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1597
	$conf["fileArgu"]=__FILE__;
1598
	#$conf["name"],字串,服務名稱.
1599
	$conf["name"]=$serviceName;
1600
	#可省略參數:
1601
	#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
1602
	$conf["operation"]="enable";
1603
	#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
1604
	#$conf["username"]="";
1605
	#$conf["password"],字串,使用者的密碼,預設不使用.
1606
	#$conf["password"]="";
1607
	#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
1608
	#$conf["daemonReload"]="true";
1609
	#參考資料:
1610
	#無.
1611
	#備註:
1612
	#無.
1613
	$systemd=cmd::systemd($conf);
1614
	unset($conf);
1615
 
1616
	#如果執行失敗
1617
	if($systemd["status"]==="false"){
1618
 
1619
		#函式說明:
1620
		#撰寫log
1621
		#回傳結果:
1622
		#$result["status"],狀態,"true"或"false".
1623
		#$result["error"],錯誤訊息陣列.
1624
		#$result["function"],當前函式的名稱.
1625
		#$result["argu"],使用的參數.
1626
		#必填參數:
1627
		#$conf["path"],字串,log檔案的路徑與名稱.
1628
		$conf["path"]=$logFile;
1629
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1630
		$conf["content"]=$systemd;
1631
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1632
		$conf["fileArgu"]=__FILE__;
1633
		#可省略參數:
1634
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1635
		#$conf["rewrite"]="false";
1636
		#參考資料:
1637
		#無.
1638
		#備註:
1639
		#無.
1640
		$record=logs::record($conf);
1641
 
1642
		#如果執行失敗
1643
		if($record["status"]==="false"){
1644
 
1645
			#印出結果
1646
			var_dump($record);
1647
 
1648
			}#if end
409 liveuser 1649
 
1650
		#異常結束執行
1651
		exit(1);
402 liveuser 1652
 
1653
		}#if end
1654
 
1655
	#函式說明:
1656
	#執行 systemd 程序來管理服務.
1657
	#回傳結果:
1658
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1659
	#$result["error"],錯誤訊息.
1660
	#$result["function"],當前執行的函式名稱.
1661
	#$result["argu"],所使用的參數.
1662
	#$result["content"],執行的結果.
1663
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
1664
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
1665
	#必填參數:
1666
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1667
	$conf["fileArgu"]=__FILE__;
1668
	#$conf["name"],字串,服務名稱.
1669
	$conf["name"]=$serviceName;
1670
	#可省略參數:
1671
	#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
1672
	$conf["operation"]="restart";
1673
	#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
1674
	#$conf["username"]="";
1675
	#$conf["password"],字串,使用者的密碼,預設不使用.
1676
	#$conf["password"]="";
1677
	#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
1678
	#$conf["daemonReload"]="true";
1679
	#參考資料:
1680
	#無.
1681
	#備註:
1682
	#無.
1683
	$systemd=cmd::systemd($conf);
1684
	unset($conf);
1685
 
1686
	#如果執行失敗
1687
	if($systemd["status"]==="false"){
1688
 
1689
		#函式說明:
1690
		#撰寫log
1691
		#回傳結果:
1692
		#$result["status"],狀態,"true"或"false".
1693
		#$result["error"],錯誤訊息陣列.
1694
		#$result["function"],當前函式的名稱.
1695
		#$result["argu"],使用的參數.
1696
		#必填參數:
1697
		#$conf["path"],字串,log檔案的路徑與名稱.
1698
		$conf["path"]=$logFile;
1699
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1700
		$conf["content"]=$systemd;
1701
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1702
		$conf["fileArgu"]=__FILE__;
1703
		#可省略參數:
1704
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1705
		#$conf["rewrite"]="false";
1706
		#參考資料:
1707
		#無.
1708
		#備註:
1709
		#無.
1710
		$record=logs::record($conf);
1711
 
1712
		#如果執行失敗
1713
		if($record["status"]==="false"){
1714
 
1715
			#印出結果
1716
			var_dump($record);
1717
 
1718
			}#if end
409 liveuser 1719
 
1720
		#異常結束執行
1721
		exit(1);
402 liveuser 1722
 
1723
		}#if end
1724
 
1725
	}#foreach end
1726
 
1727
?>