Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 469 | Rev 550 | 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
 
488 liveuser 525
/*
526
#break point
527
var_dump($chmod);
528
exit;
529
*/
530
 
402 liveuser 531
#讓 "qbpwcf/db" 可以被大家使用.
532
#函式說明:
533
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
534
#回傳結果:
535
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
536
#$result["error"],錯誤訊息.
537
#$result["function"],當前執行的函式名稱.
538
#必填參數:
539
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
540
$conf["mode"]="777";
541
#$conf["target"],字串,需要變更權限的目標.
542
$conf["target"]="qbpwcf/db";
543
#可省略參數:
544
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
545
#$conf["recursive"]="";
546
#參考資料:
547
#無.
548
#備註:
549
#無.
550
$chmod=cmd::chmod($conf);
551
unset($conf);
552
 
553
#如果執行失敗
554
if($chmod["status"]==="false"){
555
 
556
	#函式說明:
557
	#撰寫log
558
	#回傳結果:
559
	#$result["status"],狀態,"true"或"false".
560
	#$result["error"],錯誤訊息陣列.
561
	#$result["function"],當前函式的名稱.
562
	#$result["argu"],使用的參數.
563
	#必填參數:
564
	#$conf["path"],字串,log檔案的路徑與名稱.
565
	$conf["path"]=$logFile;
566
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
567
	$conf["content"]=$chmod;
568
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
569
	$conf["fileArgu"]=__FILE__;
570
	#可省略參數:
571
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
572
	#$conf["rewrite"]="false";
573
	#參考資料:
574
	#無.
575
	#備註:
576
	#無.
577
	$record=logs::record($conf);
578
 
579
	#如果執行失敗
580
	if($record["status"]==="false"){
581
 
582
		#印出結果
583
		var_dump($record);
584
 
585
		}#if end
409 liveuser 586
 
587
	#異常結束執行
588
	exit(1);
402 liveuser 589
 
590
	}#if end
488 liveuser 591
 
592
/*
593
#break point
594
var_dump($chmod);
595
exit;
596
*/
402 liveuser 597
 
598
#如果 ip 有指定
599
if($ip!==""){
600
 
601
	#依照參數設定 $rootPath.$name."/etc/config.php
602
	#函式說明:
603
	#建立軟連結.
604
	#回傳結果:
605
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
606
	#$result["error"],錯誤訊息.
607
	#$result["function"],當前執行的函數名稱.
608
	#$result["content"],軟連結的資訊.
609
	#必填參數:
610
	#$conf["fileArgu"],字串,變數__FILE__的內容.
611
	$conf["fileArgu"]=__FILE__;
612
	#$conf["file"],字串,要更新的檔案位置與名稱.
613
	$conf["file"]="qbpwcf/etc/config.php";
614
	#可省略參數:
615
	#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
426 liveuser 616
	$conf["overWriteWith"]=array("<?php","\$myIp="."\"".$ip."\";","?>");
402 liveuser 617
	#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
618
	#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
619
	#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
620
	#$conf["addToTailWhenNoMatch"]="false";
621
	#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
622
	#$conf["addToTailBeforeThat"]="?\>";
623
	#參考資料:
624
	#無.
625
	#備註:
626
	#無.
424 liveuser 627
	$updateFile=fileAccess::updateFile($conf);
402 liveuser 628
	unset($conf);
629
 
630
	#如果執行失敗
631
	if($updateFile["status"]==="false"){
632
 
633
		#函式說明:
634
		#撰寫log
635
		#回傳結果:
636
		#$result["status"],狀態,"true"或"false".
637
		#$result["error"],錯誤訊息陣列.
638
		#$result["function"],當前函式的名稱.
639
		#$result["argu"],使用的參數.
640
		#必填參數:
641
		#$conf["path"],字串,log檔案的路徑與名稱.
642
		$conf["path"]=$logFile;
643
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
644
		$conf["content"]=$updateFile;
645
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
646
		$conf["fileArgu"]=__FILE__;
647
		#可省略參數:
648
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
649
		#$conf["rewrite"]="false";
650
		#參考資料:
651
		#無.
652
		#備註:
653
		#無.
654
		$record=logs::record($conf);
655
 
656
		#如果執行失敗
657
		if($record["status"]==="false"){
658
 
659
			#印出結果
660
			var_dump($record);
661
 
662
			}#if end
409 liveuser 663
 
664
		#異常結束執行
665
		exit(1);
402 liveuser 666
 
667
		}#if end
431 liveuser 668
 
669
	#讓 "qbpwcf/etc/config.php" 可以被大家使用.
670
	#函式說明:
671
	#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
672
	#回傳結果:
673
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
674
	#$result["error"],錯誤訊息.
675
	#$result["function"],當前執行的函式名稱.
676
	#必填參數:
677
	#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
678
	$conf["mode"]="777";
679
	#$conf["target"],字串,需要變更權限的目標.
680
	$conf["target"]="qbpwcf/etc/config.php";
681
	#可省略參數:
682
	#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
683
	#$conf["recursive"]="";
684
	#參考資料:
685
	#無.
686
	#備註:
687
	#無.
688
	$chmod=cmd::chmod($conf);
689
	unset($conf);
402 liveuser 690
 
431 liveuser 691
	#如果執行失敗
692
	if($chmod["status"]==="false"){
693
 
694
		#函式說明:
695
		#撰寫log
696
		#回傳結果:
697
		#$result["status"],狀態,"true"或"false".
698
		#$result["error"],錯誤訊息陣列.
699
		#$result["function"],當前函式的名稱.
700
		#$result["argu"],使用的參數.
701
		#必填參數:
702
		#$conf["path"],字串,log檔案的路徑與名稱.
703
		$conf["path"]=$logFile;
704
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
705
		$conf["content"]=$chmod;
706
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
707
		$conf["fileArgu"]=__FILE__;
708
		#可省略參數:
709
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
710
		#$conf["rewrite"]="false";
711
		#參考資料:
712
		#無.
713
		#備註:
714
		#無.
715
		$record=logs::record($conf);
716
 
717
		#如果執行失敗
718
		if($record["status"]==="false"){
719
 
720
			#印出結果
721
			var_dump($record);
722
 
723
			}#if end
724
 
725
		#異常結束執行
726
		exit(1);
727
 
728
		}#if end	
729
 
402 liveuser 730
	}#if end
731
 
732
#依照參數設定 "qbpwcf/usr/local/etc/backupDb.conf"
733
#函式說明:
734
#建立軟連結.
735
#回傳結果:
736
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
737
#$result["error"],錯誤訊息.
738
#$result["function"],當前執行的函數名稱.
739
#$result["content"],軟連結的資訊.
740
#必填參數:
741
#$conf["fileArgu"],字串,變數__FILE__的內容.
742
$conf["fileArgu"]=__FILE__;
743
#$conf["file"],字串,要更新的檔案位置與名稱.
744
$conf["file"]="qbpwcf/usr/local/etc/backupDb.conf";
745
#可省略參數:
746
#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
747
$conf["overWriteWith"]=array();
748
$conf["overWriteWith"][]="<?php";
749
$conf["overWriteWith"][]="#資料庫連線帳號";
750
$conf["overWriteWith"][]="\$dbAcct=\"".$dbAcct."\";";
751
$conf["overWriteWith"][]="";
752
$conf["overWriteWith"][]="#資料庫連線密碼";
753
$conf["overWriteWith"][]="\$dbPass=\"".$dbPass."\";";
754
$conf["overWriteWith"][]="";
755
$conf["overWriteWith"][]="#資料庫名稱";
756
$conf["overWriteWith"][]="\$dbName=\"".$dbName."\";";
757
$conf["overWriteWith"][]="";
758
$conf["overWriteWith"][]="#資料庫位置";
759
$conf["overWriteWith"][]="\$dbAddr=\"".$dbAddr."\";";
760
$conf["overWriteWith"][]="";
761
$conf["overWriteWith"][]="#資料庫port";
762
$conf["overWriteWith"][]="\$dbPort=\"".$dbPort."\";";
763
#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
764
#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
765
#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
766
#$conf["addToTailWhenNoMatch"]="false";
767
#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
768
#$conf["addToTailBeforeThat"]="?\>";
769
#參考資料:
770
#無.
771
#備註:
772
#無.
409 liveuser 773
$updateFile=fileAccess::updateFile($conf);
402 liveuser 774
unset($conf);
775
 
776
#如果執行失敗
777
if($updateFile["status"]==="false"){
778
 
779
	#函式說明:
780
	#撰寫log
781
	#回傳結果:
782
	#$result["status"],狀態,"true"或"false".
783
	#$result["error"],錯誤訊息陣列.
784
	#$result["function"],當前函式的名稱.
785
	#$result["argu"],使用的參數.
786
	#必填參數:
787
	#$conf["path"],字串,log檔案的路徑與名稱.
788
	$conf["path"]=$logFile;
789
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
790
	$conf["content"]=$updateFile;
791
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
792
	$conf["fileArgu"]=__FILE__;
793
	#可省略參數:
794
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
795
	#$conf["rewrite"]="false";
796
	#參考資料:
797
	#無.
798
	#備註:
799
	#無.
800
	$record=logs::record($conf);
801
 
802
	#如果執行失敗
803
	if($record["status"]==="false"){
804
 
805
		#印出結果
806
		var_dump($record);
807
 
808
		}#if end
409 liveuser 809
 
810
	#異常結束執行
811
	exit(1);
402 liveuser 812
 
813
	}#if end
814
 
815
#重新建置 qbpwcf/usr/local/etc/qbpwcf.conf.xml
816
#函式說明:
817
#建立軟連結.
818
#回傳結果:
819
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
820
#$result["error"],錯誤訊息.
821
#$result["function"],當前執行的函數名稱.
822
#$result["content"],軟連結的資訊.
823
#必填參數:
824
#$conf["fileArgu"],字串,變數__FILE__的內容.
825
$conf["fileArgu"]=__FILE__;
826
#$conf["file"],字串,要更新的檔案位置與名稱.
827
$conf["file"]="qbpwcf/usr/local/etc/qbpwcf.conf.xml";
828
#可省略參數:
829
#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
830
$conf["overWriteWith"]=array();
831
$conf["overWriteWith"][]="<?xml version=\"1.0\"?>";
832
$conf["overWriteWith"][]="<root></root>";
833
#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
834
#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
835
#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
836
#$conf["addToTailWhenNoMatch"]="false";
837
#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
838
#$conf["addToTailBeforeThat"]="?\>";
839
#參考資料:
840
#無.
841
#備註:
842
#無.
409 liveuser 843
$updateFile=fileAccess::updateFile($conf);
402 liveuser 844
unset($conf);
845
 
846
#如果執行失敗
847
if($updateFile["status"]==="false"){
848
 
849
	#函式說明:
850
	#撰寫log
851
	#回傳結果:
852
	#$result["status"],狀態,"true"或"false".
853
	#$result["error"],錯誤訊息陣列.
854
	#$result["function"],當前函式的名稱.
855
	#$result["argu"],使用的參數.
856
	#必填參數:
857
	#$conf["path"],字串,log檔案的路徑與名稱.
858
	$conf["path"]=$logFile;
859
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
860
	$conf["content"]=$updateFile;
861
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
862
	$conf["fileArgu"]=__FILE__;
863
	#可省略參數:
864
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
865
	#$conf["rewrite"]="false";
866
	#參考資料:
867
	#無.
868
	#備註:
869
	#無.
870
	$record=logs::record($conf);
871
 
872
	#如果執行失敗
873
	if($record["status"]==="false"){
874
 
875
		#印出結果
876
		var_dump($record);
877
 
878
		}#if end
409 liveuser 879
 
880
	#異常結束執行
881
	exit(1);
402 liveuser 882
 
883
	}#if end
884
 
885
#讓 "qbpwcf/usr/local/etc/qbpwcf.conf.xml" 可以被大家使用.
886
#函式說明:
887
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
888
#回傳結果:
889
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
890
#$result["error"],錯誤訊息.
891
#$result["function"],當前執行的函式名稱.
892
#必填參數:
893
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
894
$conf["mode"]="777";
895
#$conf["target"],字串,需要變更權限的目標.
896
$conf["target"]="qbpwcf/usr/local/etc/qbpwcf.conf.xml";
897
#可省略參數:
898
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
899
#$conf["recursive"]="";
900
#參考資料:
901
#無.
902
#備註:
903
#無.
904
$chmod=cmd::chmod($conf);
905
unset($conf);
906
 
907
#如果執行失敗
908
if($chmod["status"]==="false"){
909
 
910
	#函式說明:
911
	#撰寫log
912
	#回傳結果:
913
	#$result["status"],狀態,"true"或"false".
914
	#$result["error"],錯誤訊息陣列.
915
	#$result["function"],當前函式的名稱.
916
	#$result["argu"],使用的參數.
917
	#必填參數:
918
	#$conf["path"],字串,log檔案的路徑與名稱.
919
	$conf["path"]=$logFile;
920
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
921
	$conf["content"]=$chmod;
922
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
923
	$conf["fileArgu"]=__FILE__;
924
	#可省略參數:
925
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
926
	#$conf["rewrite"]="false";
927
	#參考資料:
928
	#無.
929
	#備註:
930
	#無.
931
	$record=logs::record($conf);
932
 
933
	#如果執行失敗
934
	if($record["status"]==="false"){
935
 
936
		#印出結果
937
		var_dump($record);
938
 
939
		}#if end
409 liveuser 940
 
941
	#異常結束執行
942
	exit(1);
402 liveuser 943
 
944
	}#if end
945
 
488 liveuser 946
/*
947
#break point
948
var_dump($chmod);
949
exit;
950
*/
951
 
419 liveuser 952
#移除 qbpwcf/usr/lib/systemd/system 底下服務設定檔的執行權限
953
#函式說明:
954
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
955
#回傳結果:
956
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
957
#$result["error"],錯誤訊息.
958
#$result["function"],當前執行的函式名稱.
959
#必填參數:
960
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
469 liveuser 961
$conf["mode"]="640";
419 liveuser 962
#$conf["target"],字串,需要變更權限的目標.
963
$conf["target"]="qbpwcf/usr/lib/systemd/system";
964
#可省略參數:
965
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
966
$conf["recursive"]="true";
967
#$conf["excludeSelf"],字串,預設為"false"代表不處理;若為"true"則會排除目標自己(資料夾).
968
$conf["excludeSelf"]="true";
969
#參考資料:
970
#無.
971
#備註:
972
#無.
973
$chmod=cmd::chmod($conf);
974
unset($conf);
975
 
976
#如果執行失敗
977
if($chmod["status"]==="false"){
978
 
979
	#函式說明:
980
	#撰寫log
981
	#回傳結果:
982
	#$result["status"],狀態,"true"或"false".
983
	#$result["error"],錯誤訊息陣列.
984
	#$result["function"],當前函式的名稱.
985
	#$result["argu"],使用的參數.
986
	#必填參數:
987
	#$conf["path"],字串,log檔案的路徑與名稱.
988
	$conf["path"]=$logFile;
989
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
990
	$conf["content"]=$chmod;
991
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
992
	$conf["fileArgu"]=__FILE__;
993
	#可省略參數:
994
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
995
	#$conf["rewrite"]="false";
996
	#參考資料:
997
	#無.
998
	#備註:
999
	#無.
1000
	$record=logs::record($conf);
1001
 
1002
	#如果執行失敗
1003
	if($record["status"]==="false"){
1004
 
1005
		#印出結果
1006
		var_dump($record);
1007
 
1008
		}#if end
1009
 
1010
	#異常結束執行
1011
	exit(1);
1012
 
1013
	}#if end
1014
 
488 liveuser 1015
/*
1016
#break point
1017
var_dump($chmod);
1018
exit;
1019
*/
1020
 
402 liveuser 1021
#判斷 $mode
1022
switch($mode){
1023
 
1024
	#如果是 "cp" mode
1025
	case "cp":
1026
 
1027
		#函式說明:
1028
		#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
1029
		#回傳結果:
1030
		#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1031
		#$result["error"],錯誤訊息陣列
1032
		#$result["warning"],警告訊息陣列
1033
		#$result["argu"],使用的參數.
1034
		#$result["content"],建立的目錄路徑.
1035
		#必填參數:
1036
		#$conf["dirPositionAndName"]="";#新建的位置與名稱
1037
		$conf["dirPositionAndName"]=$rootPath.$name;
1038
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1039
		$conf["fileArgu"]=__FILE__;
1040
		#可省略參數:
1041
		#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
1042
		#$conf["dirPermission"]="";
1043
		#$conf["web"],"false"代表在檔案系統環境,"true"代表在網頁稀系統環境.
1044
		#$conf["web"]="false";
1045
		#參考資料:
1046
		#mkdir=>http://php.net/manual/en/function.mkdir.php
1047
		#chmod=>http://php.net/manual/en/function.chmod.php
1048
		#備註:
1049
		#無.
1050
		$createFolderAfterCheck=fileAccess::createFolderAfterCheck($conf);
1051
		unset($conf);
1052
 
1053
		#如果執行失敗
1054
		if($createFolderAfterCheck["status"]==="false"){
1055
 
1056
			#函式說明:
1057
			#撰寫log
1058
			#回傳結果:
1059
			#$result["status"],狀態,"true"或"false".
1060
			#$result["error"],錯誤訊息陣列.
1061
			#$result["function"],當前函式的名稱.
1062
			#$result["argu"],使用的參數.
1063
			#必填參數:
1064
			#$conf["path"],字串,log檔案的路徑與名稱.
1065
			$conf["path"]=$logFile;
1066
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1067
			$conf["content"]=$createFolderAfterCheck;
1068
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1069
			$conf["fileArgu"]=__FILE__;
1070
			#可省略參數:
1071
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1072
			#$conf["rewrite"]="false";
1073
			#參考資料:
1074
			#無.
1075
			#備註:
1076
			#無.
1077
			$record=logs::record($conf);
1078
 
1079
			#如果執行失敗
1080
			if($record["status"]==="false"){
1081
 
1082
				#印出結果
1083
				var_dump($record);
1084
 
1085
				}#if end
409 liveuser 1086
 
1087
			#異常結束執行
1088
			exit(1);
402 liveuser 1089
 
1090
			}#if end
1091
 
1092
		#複製套件
1093
		#函式說明:
1094
		#複製檔案、資料夾.
1095
		#回傳結果:
1096
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1097
		#$result["error"],錯誤訊息.
1098
		#$result["function"],當前執行的函式名稱.
1099
		#$result["content"],複製好的檔案路徑與名稱.
1100
		#必填參數:
1101
		#$conf["file"],字串,檔案的位置與名稱.
1102
		$conf["file"]="../";
1103
		#$conf["to"],字串,檔案要複製到哪裡.
1104
		$conf["to"]=$rootPath.$name;
1105
		#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
1106
		$conf["fileArgu"]=__FILE__;
1107
		#可省略參數:
1108
		#$conf["username"],字串,要以哪個使用者來執行,預設為執行該php程式的使用者.
1109
		#$conf["username"]="";
1110
		#$conf["password"],字串,使用者對應的密碼,預設不使用.
1111
		#$conf["password"]="";
1112
		#參考資料:
1113
		#無.
1114
		#備註:
1115
		#僅能在命令列環境下運行
1116
		$cp=cmd::cp($conf);
1117
		unset($conf);
1118
 
1119
		#如果執行失敗
1120
		if($cp["status"]==="false"){
1121
 
1122
			#函式說明:
1123
			#撰寫log
1124
			#回傳結果:
1125
			#$result["status"],狀態,"true"或"false".
1126
			#$result["error"],錯誤訊息陣列.
1127
			#$result["function"],當前函式的名稱.
1128
			#$result["argu"],使用的參數.
1129
			#必填參數:
1130
			#$conf["path"],字串,log檔案的路徑與名稱.
1131
			$conf["path"]=$logFile;
1132
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1133
			$conf["content"]=$cp;
1134
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1135
			$conf["fileArgu"]=__FILE__;
1136
			#可省略參數:
1137
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1138
			#$conf["rewrite"]="false";
1139
			#參考資料:
1140
			#無.
1141
			#備註:
1142
			#無.
1143
			$record=logs::record($conf);
1144
 
1145
			#如果執行失敗
1146
			if($record["status"]==="false"){
1147
 
1148
				#印出結果
1149
				var_dump($record);
1150
 
1151
				}#if end
1152
 
409 liveuser 1153
			#異常結束執行
1154
			exit(1);
1155
 
402 liveuser 1156
			}#if end
1157
 
1158
		break;
1159
 
1160
	#如果是 "link" mode
1161
	case "link":
1162
 
1163
		#函式說明:
1164
		#建立軟連結.
1165
		#回傳結果:
1166
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1167
		#$result["error"],錯誤訊息.
1168
		#$result["function"],當前執行的函數名稱.
1169
		#$result["content"],軟連結的資訊.
1170
		#必填參數:
1171
		#$conf["fileArgu"],字串,變數__FILE__的內容.
1172
		$conf["fileArgu"]=__FILE__;
1173
		#$conf["linkTo"],字串,軟連結要指向哪邊.
409 liveuser 1174
		$conf["linkTo"]="qbpwcf";
402 liveuser 1175
		#可省略參數:
1176
		#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
409 liveuser 1177
		$conf["path"]=$rootPath;
402 liveuser 1178
		#$conf["name"],字串,軟連結的名稱,預設為 "linkTo" 參數的檔案或目錄名稱.
409 liveuser 1179
		$conf["name"]=$name;
1180
		#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1181
		$conf["overWrite"]="true";
402 liveuser 1182
		#參考資料:
1183
		#無.
1184
		#備註:
1185
		#無.
1186
		$createLink=fileAccess::createLink($conf);
1187
		unset($conf);
1188
 
1189
		#如果執行失敗
1190
		if($createLink["status"]==="false"){
1191
 
1192
			#函式說明:
1193
			#撰寫log
1194
			#回傳結果:
1195
			#$result["status"],狀態,"true"或"false".
1196
			#$result["error"],錯誤訊息陣列.
1197
			#$result["function"],當前函式的名稱.
1198
			#$result["argu"],使用的參數.
1199
			#必填參數:
1200
			#$conf["path"],字串,log檔案的路徑與名稱.
1201
			$conf["path"]=$logFile;
1202
			#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1203
			$conf["content"]=$createLink;
1204
			#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1205
			$conf["fileArgu"]=__FILE__;
1206
			#可省略參數:
1207
			#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1208
			#$conf["rewrite"]="false";
1209
			#參考資料:
1210
			#無.
1211
			#備註:
1212
			#無.
1213
			$record=logs::record($conf);
1214
 
1215
			#如果執行失敗
1216
			if($record["status"]==="false"){
1217
 
1218
				#印出結果
1219
				var_dump($record);
1220
 
1221
				}#if end
409 liveuser 1222
 
1223
			#異常結束執行
1224
			exit(1);
402 liveuser 1225
 
1226
			}#if end
1227
 
488 liveuser 1228
		/*
1229
		#break point
1230
		var_dump($createLink);
1231
		exit;
1232
		*/
1233
 
402 liveuser 1234
		break;
1235
 
1236
	default:
1237
 
1238
		#函式說明:
1239
		#撰寫log
1240
		#回傳結果:
1241
		#$result["status"],狀態,"true"或"false".
1242
		#$result["error"],錯誤訊息陣列.
1243
		#$result["function"],當前函式的名稱.
1244
		#$result["argu"],使用的參數.
1245
		#必填參數:
1246
		#$conf["path"],字串,log檔案的路徑與名稱.
1247
		$conf["path"]=$logFile;
1248
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1249
		$conf["content"]="mode \"".$mode."\" not supported!";
1250
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1251
		$conf["fileArgu"]=__FILE__;
1252
		#可省略參數:
1253
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1254
		#$conf["rewrite"]="false";
1255
		#參考資料:
1256
		#無.
1257
		#備註:
1258
		#無.
1259
		$record=logs::record($conf);
1260
 
1261
		#如果執行失敗
1262
		if($record["status"]==="false"){
1263
 
1264
			#印出結果
1265
			var_dump($record);
1266
 
1267
			}#if end
409 liveuser 1268
 
1269
		#異常結束執行
1270
		exit(1);
402 liveuser 1271
 
1272
	}#switch end
1273
 
1274
#於 /usr/bin 底下建立 $rootPath.$name."/usr/bin" 底下所有檔案的軟連結.
1275
#函式說明:
1276
#針對特定目錄下的內容建立軟連結.
1277
#回傳結果:
1278
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1279
#$result["error"],錯誤訊息.
1280
#$result["function"],當前執行的函數名稱.
1281
#$result["content"],字串陣列,每個建立的軟連結資訊.
1282
#必填參數:
1283
#$conf["fileArgu"],字串,變數__FILE__的內容.
1284
$conf["fileArgu"]=__FILE__;
1285
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
1286
$conf["linkToDir"]=$rootPath.$name."/usr/bin";
1287
#可省略參數:
1288
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
1289
$conf["path"]="/usr/bin";
1290
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
1291
#$conf["name"]=array(array("oriName","newName"));
1292
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1293
$conf["overWrite"]="true";
1294
#參考資料:
1295
#無.
1296
#備註:
1297
#無.
1298
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
1299
unset($conf);
1300
 
1301
#如果執行失敗
1302
if($createMultiLinkInDir["status"]==="false"){
1303
 
1304
	#函式說明:
1305
	#撰寫log
1306
	#回傳結果:
1307
	#$result["status"],狀態,"true"或"false".
1308
	#$result["error"],錯誤訊息陣列.
1309
	#$result["function"],當前函式的名稱.
1310
	#$result["argu"],使用的參數.
1311
	#必填參數:
1312
	#$conf["path"],字串,log檔案的路徑與名稱.
1313
	$conf["path"]=$logFile;
1314
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1315
	$conf["content"]=$createMultiLinkInDir;
1316
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1317
	$conf["fileArgu"]=__FILE__;
1318
	#可省略參數:
1319
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1320
	#$conf["rewrite"]="false";
1321
	#參考資料:
1322
	#無.
1323
	#備註:
1324
	#無.
1325
	$record=logs::record($conf);
1326
 
1327
	#如果執行失敗
1328
	if($record["status"]==="false"){
1329
 
1330
		#印出結果
1331
		var_dump($record);
1332
 
1333
		}#if end
409 liveuser 1334
 
1335
	#異常結束執行
1336
	exit(1);
402 liveuser 1337
 
1338
	}#if end
1339
 
1340
#於 /etc/systemd/system 底下建立 $rootPath.$name."/usr/lib/systemd/system" 底下所有服務檔案的軟連結.
1341
#函式說明:
1342
#針對特定目錄下的內容建立軟連結.
1343
#回傳結果:
1344
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1345
#$result["error"],錯誤訊息.
1346
#$result["function"],當前執行的函數名稱.
1347
#$result["content"],字串陣列,每個建立的軟連結資訊.
1348
#必填參數:
1349
#$conf["fileArgu"],字串,變數__FILE__的內容.
1350
$conf["fileArgu"]=__FILE__;
1351
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
1352
$conf["linkToDir"]=$rootPath.$name."/usr/lib/systemd/system";
1353
#可省略參數:
1354
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
1355
$conf["path"]="/etc/systemd/system";
1356
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
1357
#$conf["name"]=array(array("oriName","newName"));
1358
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1359
$conf["overWrite"]="true";
1360
#參考資料:
1361
#無.
1362
#備註:
1363
#無.
1364
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
1365
unset($conf);
1366
 
1367
#如果執行失敗
1368
if($createMultiLinkInDir["status"]==="false"){
1369
 
1370
	#函式說明:
1371
	#撰寫log
1372
	#回傳結果:
1373
	#$result["status"],狀態,"true"或"false".
1374
	#$result["error"],錯誤訊息陣列.
1375
	#$result["function"],當前函式的名稱.
1376
	#$result["argu"],使用的參數.
1377
	#必填參數:
1378
	#$conf["path"],字串,log檔案的路徑與名稱.
1379
	$conf["path"]=$logFile;
1380
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1381
	$conf["content"]=$createMultiLinkInDir;
1382
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1383
	$conf["fileArgu"]=__FILE__;
1384
	#可省略參數:
1385
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1386
	#$conf["rewrite"]="false";
1387
	#參考資料:
1388
	#無.
1389
	#備註:
1390
	#無.
1391
	$record=logs::record($conf);
1392
 
1393
	#如果執行失敗
1394
	if($record["status"]==="false"){
1395
 
1396
		#印出結果
1397
		var_dump($record);
1398
 
1399
		}#if end
1400
 
409 liveuser 1401
	#異常結束執行
1402
	exit(1);
1403
 
402 liveuser 1404
	}#if end
1405
 
1406
#函式說明:
1407
#針對特定目錄下的內容建立軟連結.
1408
#回傳結果:
1409
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1410
#$result["error"],錯誤訊息.
1411
#$result["function"],當前執行的函數名稱.
1412
#$result["content"],字串陣列,每個建立的軟連結資訊.
1413
#必填參數:
1414
#$conf["fileArgu"],字串,變數__FILE__的內容.
1415
$conf["fileArgu"]=__FILE__;
1416
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
1417
$conf["linkToDir"]=$rootPath.$name."/usr/local/etc";
1418
#可省略參數:
1419
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
1420
$conf["path"]="/usr/local/etc";
1421
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
1422
#$conf["name"]=array(array("oriName","newName"));
1423
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
1424
$conf["overWrite"]="true";
1425
#參考資料:
1426
#無.
1427
#備註:
1428
#無.
1429
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
1430
unset($conf);
1431
 
1432
#如果執行失敗
1433
if($createMultiLinkInDir["status"]==="false"){
1434
 
1435
	#函式說明:
1436
	#撰寫log
1437
	#回傳結果:
1438
	#$result["status"],狀態,"true"或"false".
1439
	#$result["error"],錯誤訊息陣列.
1440
	#$result["function"],當前函式的名稱.
1441
	#$result["argu"],使用的參數.
1442
	#必填參數:
1443
	#$conf["path"],字串,log檔案的路徑與名稱.
1444
	$conf["path"]=$logFile;
1445
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1446
	$conf["content"]=$createMultiLinkInDir;
1447
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1448
	$conf["fileArgu"]=__FILE__;
1449
	#可省略參數:
1450
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1451
	#$conf["rewrite"]="false";
1452
	#參考資料:
1453
	#無.
1454
	#備註:
1455
	#無.
1456
	$record=logs::record($conf);
1457
 
1458
	#如果執行失敗
1459
	if($record["status"]==="false"){
1460
 
1461
		#印出結果
1462
		var_dump($record);
1463
 
1464
		}#if end
409 liveuser 1465
 
1466
	#異常結束執行
1467
	exit(1);
402 liveuser 1468
 
1469
	}#if end
1470
 
1471
#systemctl daemon-reload
1472
#函式說明:
1473
#執行 systemd 程序來管理服務.
1474
#回傳結果:
1475
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1476
#$result["error"],錯誤訊息.
1477
#$result["function"],當前執行的函式名稱.
1478
#$result["argu"],所使用的參數.
1479
#$result["content"],執行的結果.
1480
#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
1481
#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
1482
#必填參數:
1483
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1484
$conf["fileArgu"]=__FILE__;
1485
#$conf["name"],字串,服務名稱.
1486
$conf["name"]="daemon-reload";
1487
#可省略參數:
1488
#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
1489
#$conf["operation"]="";
1490
#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
1491
#$conf["username"]="";
1492
#$conf["password"],字串,使用者的密碼,預設不使用.
1493
#$conf["password"]="";
1494
#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
1495
$conf["daemonReload"]="true";
1496
#參考資料:
1497
#無.
1498
#備註:
1499
#無.
1500
$systemd=cmd::systemd($conf);
1501
unset($conf);
1502
 
1503
#如果執行失敗
1504
if($systemd["status"]==="false"){
1505
 
1506
	#函式說明:
1507
	#撰寫log
1508
	#回傳結果:
1509
	#$result["status"],狀態,"true"或"false".
1510
	#$result["error"],錯誤訊息陣列.
1511
	#$result["function"],當前函式的名稱.
1512
	#$result["argu"],使用的參數.
1513
	#必填參數:
1514
	#$conf["path"],字串,log檔案的路徑與名稱.
1515
	$conf["path"]=$logFile;
1516
	#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1517
	$conf["content"]=$systemd;
1518
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1519
	$conf["fileArgu"]=__FILE__;
1520
	#可省略參數:
1521
	#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1522
	#$conf["rewrite"]="false";
1523
	#參考資料:
1524
	#無.
1525
	#備註:
1526
	#無.
1527
	$record=logs::record($conf);
1528
 
1529
	#如果執行失敗
1530
	if($record["status"]==="false"){
1531
 
1532
		#印出結果
1533
		var_dump($record);
1534
 
1535
		}#if end
409 liveuser 1536
 
1537
	#異常結束執行
1538
	exit(1);
402 liveuser 1539
 
1540
	}#if end
1541
 
1542
#enable and restart 於 $rootPath.$name."/usr/lib/systemd/system" 底下的所有服務
1543
 
1544
#函式說明:
1545
#取得目錄底下所有目錄與檔案清單.
1546
#回傳結果:
1547
#$result["status"],"true"爲建立成功,"false"爲建立失敗.
1548
#$result["error"],錯誤訊息陣列.
1549
#$result["function"],函數名稱.
1550
#$result["content"],陣列,目錄底下的檔案與子目錄.
1551
#$result["content"][$i]["name"],字串,目錄底下的檔案與子目錄的名稱.
1552
#$result["content"][$i]["folder"],字串,第$i+1個名稱為目錄還是檔案.
1553
#$result["folder"],字串,當前目標為目錄還是檔案"true"代表為目錄,"false"代表為檔案.
1554
#$result["position"],目前的位置.
1555
#必填參數:
1556
#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
1557
$conf["position"]=$rootPath.$name."/usr/lib/systemd/system";
1558
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1559
$conf["fileArgu"]=__FILE__;
1560
#可省略參數:
1561
#無
1562
#參考資料:
1563
#opendir=>http://php.net/manual/en/function.opendir.php
1564
#is_dir=>http://php.net/manual/en/function.is-dir.php
1565
#備註:
1566
#無.
1567
$getList=fileAccess::getList($conf);
1568
unset($conf);
1569
 
1570
#如果執行失敗
1571
if($getList["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"]=$getList;
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
409 liveuser 1603
 
1604
	#異常結束執行
1605
	exit(1);
402 liveuser 1606
 
1607
	}#if end
1608
 
1609
#針對每個服務
1610
foreach($getList["content"] as $fileInfo){
1611
 
1612
	#取得服務的名稱
1613
	$serviceName=$fileInfo["name"];
1614
 
1615
	#函式說明:
1616
	#執行 systemd 程序來管理服務.
1617
	#回傳結果:
1618
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1619
	#$result["error"],錯誤訊息.
1620
	#$result["function"],當前執行的函式名稱.
1621
	#$result["argu"],所使用的參數.
1622
	#$result["content"],執行的結果.
1623
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
1624
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
1625
	#必填參數:
1626
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1627
	$conf["fileArgu"]=__FILE__;
1628
	#$conf["name"],字串,服務名稱.
1629
	$conf["name"]=$serviceName;
1630
	#可省略參數:
1631
	#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
1632
	$conf["operation"]="enable";
1633
	#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
1634
	#$conf["username"]="";
1635
	#$conf["password"],字串,使用者的密碼,預設不使用.
1636
	#$conf["password"]="";
1637
	#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
1638
	#$conf["daemonReload"]="true";
1639
	#參考資料:
1640
	#無.
1641
	#備註:
1642
	#無.
1643
	$systemd=cmd::systemd($conf);
1644
	unset($conf);
1645
 
1646
	#如果執行失敗
1647
	if($systemd["status"]==="false"){
1648
 
1649
		#函式說明:
1650
		#撰寫log
1651
		#回傳結果:
1652
		#$result["status"],狀態,"true"或"false".
1653
		#$result["error"],錯誤訊息陣列.
1654
		#$result["function"],當前函式的名稱.
1655
		#$result["argu"],使用的參數.
1656
		#必填參數:
1657
		#$conf["path"],字串,log檔案的路徑與名稱.
1658
		$conf["path"]=$logFile;
1659
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1660
		$conf["content"]=$systemd;
1661
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1662
		$conf["fileArgu"]=__FILE__;
1663
		#可省略參數:
1664
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1665
		#$conf["rewrite"]="false";
1666
		#參考資料:
1667
		#無.
1668
		#備註:
1669
		#無.
1670
		$record=logs::record($conf);
1671
 
1672
		#如果執行失敗
1673
		if($record["status"]==="false"){
1674
 
1675
			#印出結果
1676
			var_dump($record);
1677
 
1678
			}#if end
409 liveuser 1679
 
1680
		#異常結束執行
1681
		exit(1);
402 liveuser 1682
 
1683
		}#if end
1684
 
1685
	#函式說明:
1686
	#執行 systemd 程序來管理服務.
1687
	#回傳結果:
1688
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1689
	#$result["error"],錯誤訊息.
1690
	#$result["function"],當前執行的函式名稱.
1691
	#$result["argu"],所使用的參數.
1692
	#$result["content"],執行的結果.
1693
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
1694
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
1695
	#必填參數:
1696
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1697
	$conf["fileArgu"]=__FILE__;
1698
	#$conf["name"],字串,服務名稱.
1699
	$conf["name"]=$serviceName;
1700
	#可省略參數:
1701
	#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
1702
	$conf["operation"]="restart";
1703
	#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
1704
	#$conf["username"]="";
1705
	#$conf["password"],字串,使用者的密碼,預設不使用.
1706
	#$conf["password"]="";
1707
	#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
1708
	#$conf["daemonReload"]="true";
1709
	#參考資料:
1710
	#無.
1711
	#備註:
1712
	#無.
1713
	$systemd=cmd::systemd($conf);
1714
	unset($conf);
1715
 
1716
	#如果執行失敗
1717
	if($systemd["status"]==="false"){
1718
 
1719
		#函式說明:
1720
		#撰寫log
1721
		#回傳結果:
1722
		#$result["status"],狀態,"true"或"false".
1723
		#$result["error"],錯誤訊息陣列.
1724
		#$result["function"],當前函式的名稱.
1725
		#$result["argu"],使用的參數.
1726
		#必填參數:
1727
		#$conf["path"],字串,log檔案的路徑與名稱.
1728
		$conf["path"]=$logFile;
1729
		#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
1730
		$conf["content"]=$systemd;
1731
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
1732
		$conf["fileArgu"]=__FILE__;
1733
		#可省略參數:
1734
		#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
1735
		#$conf["rewrite"]="false";
1736
		#參考資料:
1737
		#無.
1738
		#備註:
1739
		#無.
1740
		$record=logs::record($conf);
1741
 
1742
		#如果執行失敗
1743
		if($record["status"]==="false"){
1744
 
1745
			#印出結果
1746
			var_dump($record);
1747
 
1748
			}#if end
409 liveuser 1749
 
1750
		#異常結束執行
1751
		exit(1);
402 liveuser 1752
 
1753
		}#if end
1754
 
1755
	}#foreach end
1756
 
1757
?>