Subversion Repositories php-qbpwcf

Rev

Rev 40 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 1
#!/usr/bin/php
2
<?php
3
 
4
/*
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2015~2024 Min-Jhin,Chen
7
 
8
    This file is part of QBPWCF.
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
 
15
    QBPWCF is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
*/
24
 
25
/*
26
說明:
27
管理排程的執行
28
 
29
範例:
30
 
31
開啟daemon
32
auto.php --daemon on
33
*/
34
 
35
#使用命名空間qbpwcf
36
namespace qbpwcf;
37
 
38
#取得 lib path
39
exec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/libexec/folderOfUsrLib.php"),$output,$status);
40
 
41
#如果執行失敗
42
if($status!==0){
43
 
44
	#debug
45
	var_dump(__LINE__,$output);
46
 
47
	#結束執行,回傳shell 1.
48
	exit(1);
49
 
50
	}#if end
51
 
52
#儲存lib path
53
$folderOfUsrLib=$output[0];
54
 
55
#以該檔案的實際位置的 lib path 為 include path 首位
56
$output=array();
57
exec("cd ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../".$folderOfUsrLib."/qbpwcf").";pwd;",$output,$status);
58
 
59
#如果執行失敗
60
if($status!==0){
61
 
62
	#debug
63
	var_dump(__LINE__,$output);
64
 
65
	#結束執行,回傳shell 1.
66
	exit(1);
67
 
68
	}#if end
69
 
70
#設置 include path 
71
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
72
 
73
#匯入外部套件
74
include("allInOne.php");
75
 
76
#說明函式
77
function help(){
78
 
79
	#印出指令說明
80
	echo "Usage of ".basename(__FILE__).":".PHP_EOL; 
81
	echo "--daemon [on] 代表要啟動 daemon".PHP_EOL;
82
	echo "--socket [unix domain socket path and name] daemon 模式若需要建立 unix domain socket 的路徑與名稱,預設為\"/usr/lib/qbpwcf/qbpwcf-autoService.sock\"".PHP_EOL;
83
	echo "--config [schedule config path and name] daemon 模式所存取的排程設定檔案,預設位置為/usr/local/etc/qbpwcf-schedule.conf.php".PHP_EOL;
84
	echo "--log [write log file] 要將 log 寫入到哪邊?預設為\"/var/log/auto.log\"".PHP_EOL;
85
	echo "--action [command to run] 排程要執行的指令".PHP_EOL;
86
	echo "--startTime [HourHour:MinMin] 代表今日為HourHour:MinMin時要執行,若不設定代表立即執行.".PHP_EOL;
87
	echo "--startDate [YearYearYearYear-MonthMonth-DayDay] 代表特定日期才開始,預設為今天".PHP_EOL;
88
	echo "--repeat [times of repear] 預設為 -1 代表無執行周期上限".PHP_EOL;
89
	echo "--uuid [uuid of action] 排程的唯一識別碼,若不指定會隨即產生".PHP_EOL;
90
	echo "--cycleTime [time of cycle ] 周期時間,亦即過了多少時間要再執行一次,單位為秒".PHP_EOL;
91
	echo "--fixedMonth [Month][Month] 代表要固定月份執行".PHP_EOL;
92
	echo "--fixedDay [DayDay] 代表要固定日執行".PHP_EOL;
93
	echo "--fixedHour [HoutHour] 代表要固定小時執行".PHP_EOL;
94
	echo "--fixedMin [MinMin] 代表要固定分鐘執行".PHP_EOL;
95
	echo "--getList [yes] 代表要取得當前(更新後)的排程清單".PHP_EOL;
96
 
97
	#結束執行
98
	exit;
99
 
100
	}#function help end
101
 
102
#函式說明:
103
#解析參數.
104
#回傳結果:
105
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
106
#$reuslt["error"],執行不正常結束的錯訊息陣列.
107
#$result["function"],當前執行的函式名稱.
108
#$result["content"],解析好的參數陣列.
109
#$result["content"][$key][$i],參數 $key 的 $i+1 個參數數值內容.
110
#$result["program"],字串,執行的程式名稱.
111
#必填參數:
112
#無
113
#可省略參數:
114
#$conf["helpFunc"],如果解析的參數不成對,則要執行的函式名稱.
115
$conf["helpFunc"]="help";
116
#備註:
117
#僅能在命令列底下執行.
118
#建議:
119
#以後可將參數 --a--b 的名稱與後面的數值 $value 存成 $result["a"]["b"][$i]=$value .
120
$parseArgu=cmd::parseArgu($conf);
121
unset($conf);
122
 
123
#如果解析參數失敗
124
if($parseArgu["status"]==="false"){
125
 
126
	#印出結果
127
	var_dump($parseArgu);
128
 
129
	#結束執行,回傳shell 1,代表異常.
130
	exit(1);
131
 
132
	}#if end
133
 
134
#函式說明:
135
#使用 linux 的 uuid 指令來產生 uuid 字串
136
#回傳結果:
137
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
138
#$result["error"],錯誤訊息.
139
#$result["function"],當前執行的函式名稱.
140
#$result["content"],uuid.
141
#必填參數:
142
#無.
143
#可省略參數:
144
#無.
145
#參考資料:
146
#無.
147
#備註:
148
#無.
149
$uuid=cmd::uuid();
150
 
151
#如果建立uuid失敗
152
if($uuid["status"]==="false"){
153
 
154
	#印出結果
155
	var_dump($uuid);
156
 
157
	#結束執行,回傳shell 1,代表異常.
158
	exit(1);
159
 
160
	}#if end
161
 
162
#取得uuid
163
$uuid=$uuid["content"];
164
 
165
#檢查參數
166
#函式說明:
167
#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
168
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
169
#$reuslt["error"],執行不正常結束的錯訊息陣列.
170
#$result["function"],當前執行的函式名稱.
171
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
172
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
173
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
174
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
175
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
176
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
177
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
178
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
179
#必填寫的參數:
180
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
181
$conf["varInput"]=&$parseArgu["content"];
182
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
183
$conf["referenceVarKey"]="variableCheck::checkArguments";
184
#可以省略的參數:
185
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
186
#$conf["mustBeFilledVariableName"]=array("backupAddr");
187
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
188
#$conf["mustBeFilledVariableType"]=array("array");
189
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
190
#$conf["canBeEmptyString"]="false";
191
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
192
#$conf["canNotBeEmpty"]=array();
193
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
194
#$conf["canBeEmpty"]=array();
195
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
196
#$conf["skipableVariableCanNotBeEmpty"]=array("backTime");
197
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
198
$conf["skipableVariableName"]=array("daemon","socket","config","log","action","startTime","startDate","repeat","uuid","cycleTime","fixedMonth","fixedDay","fixedHour","fixedMin","getList");
199
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
200
$conf["skipableVariableType"]=array("array","array","array","array","array","array","array","array","array","array","array","array","array","array","array");
201
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
202
$conf["skipableVarDefaultValue"]=array(null,null,null,array("/var/log/auto.log"),null,null,null,array(array("times"=>"-1")),null,null,null,null,null,null,null);
203
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
204
#$conf["variableCheck::checkArguments"]["disallowAllSkipableVarIsEmpty"]="false";
205
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
206
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
207
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
208
#$conf["arrayCountEqualCheck"][]=array();
209
#參考資料來源:
210
#array_keys=>http://php.net/manual/en/function.array-keys.php
211
$checkArguments=variableCheck::checkArguments($conf);
212
unset($conf);
213
 
214
#若執行失敗
215
if($checkArguments["status"]==="false"){
216
 
217
	#印出結果
218
	var_dump($checkArguments);
219
 
220
	#結束執行,回傳shell 1,代表異常.
221
	exit(1);
222
 
223
	}#if end
224
 
225
#若檢查不通過
226
if($checkArguments["passed"]==="false"){
227
 
228
	#印出結果
229
	var_dump($checkArguments);
230
 
231
	#提示用法
232
	help();
233
 
234
	#結束執行
235
	exit;
236
 
237
	}#if end
238
 
239
#如果有 config 參數
240
if(isset($parseArgu["content"]["config"])){
241
 
242
	#取得 config 參數
243
	$config=$parseArgu["content"]["config"][0];
244
 
245
	}#if end
246
 
247
#如果有 socket 參數
248
if(isset($parseArgu["content"]["socket"])){
249
 
250
	#取得 socket 參數
251
	$socket=$parseArgu["content"]["socket"][0];
252
 
253
	}#if end
254
 
255
#如果有 log 參數
256
if(isset($parseArgu["content"]["log"])){
257
 
258
	#取得 log 參數
259
	$log=$parseArgu["content"]["log"][0];
260
 
261
	}#if end
262
 
263
#如果有 deamon 參數
264
if(isset($parseArgu["content"]["daemon"])){
265
 
266
	#取得 daemon 參數
267
	$daemon=$parseArgu["content"]["daemon"][0];
268
 
269
	}#if end
270
 
271
#反之
272
else{
273
 
274
	#設置不為daemon模式
275
	$daemon="off";
276
 
277
	}#else end
278
 
279
#如果有 daemon 為 "on"
280
if($daemon==="on"){
281
 
282
	#函式說明:
283
	#建立unix domain socket server,依照設定檔autoService::createList建立的設定檔案來執行排程事項.
284
	#回傳結果:
285
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
286
	#$result["error"],錯誤訊息陣列.
287
	#$result["function"],當前執行的函式名稱.
288
	#$result["argu"],所使用的參數.
289
	#必填參數:
290
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
291
	$conf["fileArgu"]=__FILE__;
292
	#可省略參數:
293
 
294
	#如果有config參數
295
	if(isset($config)){
296
 
297
		#$conf["config"],字串,排程的設定檔位置,預設為"/usr/local/etc/qbpwcf-schedule.conf.php".
298
		$conf["config"]=$config;
299
 
300
		}#if end
301
 
302
	#如果有socket參數
303
	if(isset($socket)){
304
 
305
		#$conf["unixDomainSocket"],字串,unix domain socket 檔案要放在哪裡,預設為"/usr/lib/qbpwcf/qbpwcf-autoService.sock".
306
		$conf["unixDomainSocket"]=$socket;
307
 
308
		}#if end
309
 
310
	#如果有log參數
311
	if(isset($log)){
312
 
313
		#$conf["log"],字串,要將log寫到哪個地方,若有指定就會嘗試寫log.
314
		$conf["log"]=$log;
315
 
316
		}#if end
317
 
318
	#可省略參數:
319
	#無.
320
	#參考資料:
321
	#無.
322
	#備註:
323
	#無.
324
	$daemon=autoService::daemon($conf);
325
	unset($conf);
326
 
327
	#若執行失敗
328
	if($daemon["status"]==="false"){
329
 
330
		#印出結果
331
		var_dump($uuid);
332
 
333
		#結束執行,回傳shell 1,代表異常.
334
		exit(1);
335
 
336
		}#if end
337
 
338
	#執行到這邊代表意外結束
339
	exit(1);
340
 
341
	}#if end
342
 
343
#如果有 startTime 參數
344
if(isset($parseArgu["content"]["startTime"])){
345
 
346
	#取得 startTime 參數
347
	$startTime=$parseArgu["content"]["startTime"][0];
348
 
349
	}#if end
350
 
351
#反之
352
else{
353
 
354
	#為當下時分秒
355
	$startTime=gmdate("H:i:s");
356
 
357
	}#else end
358
 
359
#如果有 startDate 參數
360
if(isset($parseArgu["content"]["startDate"])){
361
 
362
	#取得 startDate 參數
363
	$startDate=$parseArgu["content"]["startDate"][0];
364
 
365
	}#if end
366
 
367
#反之
368
else{
369
 
370
	#為當下年月日
371
	$startDate=gmdate("Y-m-d");
372
 
373
	}#else end
374
 
375
#如果有 repeat 參數
376
if(isset($parseArgu["content"]["repeat"])){
377
 
378
	#取得 repeat 參數
379
	$repeat=$parseArgu["content"]["repeat"][0];
380
 
381
	}#if end
382
 
383
#如果有 uuid 參數
384
if(isset($parseArgu["content"]["uuid"])){
385
 
386
	#取得 repeat 參數
387
	$uuid=$parseArgu["content"]["uuid"][0];
388
 
389
	}#if end
390
 
391
#反之
392
else{
393
 
394
	#函式說明:
395
	#使用 linux 的 uuid 指令來產生 uuid 字串
396
	#回傳結果:
397
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
398
	#$result["error"],錯誤訊息.
399
	#$result["function"],當前執行的函式名稱.
400
	#$result["content"],uuid.
401
	#必填參數:
402
	#無.
403
	#可省略參數:
404
	#無.
405
	#參考資料:
406
	#無.
407
	#備註:
408
	#無.
409
	$uuid=cmd::uuid();
410
 
411
	#如果建立uuid失敗
412
	if($uuid["status"]==="false"){
413
 
414
		#印出結果
415
		var_dump($uuid);
416
 
417
		#結束執行,回傳shell 1,代表異常.
418
		exit(1);
419
 
420
		}#if end
421
 
422
	#取得uuid
423
	$uuid=$uuid["content"];
424
 
425
	}#else end
426
 
427
#如果有 fixedMonth 參數
428
if(isset($parseArgu["content"]["fixedMonth"])){
429
 
430
	#取得 fixedMonth 參數
431
	$fixedMonth=$parseArgu["content"]["fixedMonth"][0];
432
 
433
	}#if end
434
 
435
#反之
436
else{
437
 
438
	#設置 fixedMonth 參數跟開始月份一樣
439
	$fixedMonth=$startDate[5].$startDate[6];
440
 
441
	}#else end
442
 
443
#如果有 fixedDay 參數
444
if(isset($parseArgu["content"]["fixedDay"])){
445
 
446
	#取得 fixedDay 參數
447
	$fixedDay=$parseArgu["content"]["fixedDay"][0];
448
 
449
	}#if end
450
 
451
#反之
452
else{
453
 
454
	#設置 fixedDay 參數跟開始日一樣
455
	$fixedDay=$startDate[8].$startDate[9];
456
 
457
	}#else end
458
 
459
#如果有 fixedHour 參數
460
if(isset($parseArgu["content"]["fixedHour"])){
461
 
462
	#取得 fixedHour 參數
463
	$fixedHour=$parseArgu["content"]["fixedHour"][0];
464
 
465
	#如果只有輸入一個數字
466
	if(strlen($fixedHour)===1){
467
 
468
		#前面補0
469
		$fixedHour="0".$fixedHour;
470
 
471
		}#if end
472
 
473
	}#if end
474
 
475
#反之
476
else{
477
 
478
	#設置 fixedHour 參數跟開始小時一樣
479
	$fixedHour=$startTime[0].$startTime[1];
480
 
481
	}#else end
482
 
483
#如果有 fixedMin 參數
484
if(isset($parseArgu["content"]["fixedMin"])){
485
 
486
	#取得 fixedMin 參數
487
	$fixedMin=$parseArgu["content"]["fixedMin"][0];
488
 
489
	}#if end
490
 
491
#反之
492
else{
493
 
494
	#設置 fixedMin 參數跟開始分鐘一樣
495
	$fixedMin=$startTime[3].$startTime[4];
496
 
497
	}#else end
498
 
499
 
500
 
501
#如果有 cycleTime 參數
502
if(isset($conf["cycleTime"])){
503
 
504
	#取得cycle參數
505
	$cycleTime=$parseArgu["content"]["cycleTime"][0];
506
 
507
	}#if end
508
 
509
#如果有 action 參數
510
if(isset($parseArgu["content"]["action"])){
511
 
512
	#取得 action 參數
513
	$action=$parseArgu["content"]["action"][0];
514
 
515
	#解析指令與參數
516
	#函式說明:
517
	#將指令字串解析成陣列,方便給予 external::callShell 使用 
518
	#回傳結果:
519
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
520
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
521
	#$result["function"],當前執行的函式名稱.
522
	#$result["content"],解析好的指令陣列.
523
	#$result["cmd"],解析好的指令名稱.
524
	#$result["argus"],解析好的參數陣列.
525
	#$result["argu"],所使用的參數.
526
	#必填參數
527
	#$conf["cmdStr"],字串,要解析的指令字串
528
	$conf["cmdStr"]=$action;
529
	#可省略參數:
530
	#無.
531
	#參考資料:
532
	#無.
533
	#備註:
534
	#無.
535
	$parseCmdString=cmd::parseCmdString($conf);
536
	unset($conf);
537
 
538
	#若執行失敗
539
	if($parseCmdString["status"]==="false"){
540
 
541
		#印出結果
542
		var_dump($parseCmdString);
543
 
544
		#結束執行,回傳shell 1,代表異常.
545
		exit(1);
546
 
547
		}#if end
548
 
549
	#初始化給createList函式的repeat參數
550
	$repeatArray=array();
551
 
552
	#設置重複的規則
553
	$repeatArray["times"]=$repeat;
554
 
555
	#如果有 $cycleTime
556
	if(isset($cycleTime)){
557
 
558
		#設置周期時間
559
		$repeatArray["after"]=$cycleTime;
560
 
561
		}#if end
562
 
563
	#反之如果有設定固定時間
564
	else{
565
 
566
		#組合成固定執行時間的年月日時分秒
567
		$dateAndTime=gmdate('Y')."-".$fixedMonth."-".$fixedDay." ".$fixedHour.":".$fixedMin.":00";
568
 
569
		#函式說明:
570
		#計算時間點距離1970/01/01多少秒,亦即unixtime.
571
		#回傳結果:
572
		#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
573
		#$result["error"],錯誤訊息陣列.
574
		#$result["content"],時間點距離1970/01/01的多少秒.
575
		#$result["argu"],使用的參數.
576
		#$result["unixtime"],執行本函式時的unixtime.
577
		#$result["oriDateAndTime"],原始輸入的內容,若replace0參數為"true",才會有該回傳內容.	
578
		#必填參數:
579
		#$conf["dateAndTime"],字串,格式爲 2011-05-27 23:59:59.
580
		$conf["time::caculateTimeAmount"]["dateAndTime"]=$dateAndTime;
581
		#可省略參數:
582
		#$conf["UTC"],字串,是否要用當前時區的設定去換算成unixtime,預設為"false",代表不要;反之為"true".
583
		$conf["time::caculateTimeAmount"]["UTC"]="true";
584
		#$conf["replace0"],字串,是否要將連續為0的內容替換成當下時間,預設為"true"代表要;反之為"false".
585
		$conf["time::caculateTimeAmount"]["replace0"]="false";
586
		#參考資料:
587
		#無.
588
		#備註:
589
		#無.
590
		$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
591
		unset($conf["time::caculateTimeAmount"]);
592
 
593
		#如果執行失敗
594
		if($caculateTimeAmount["status"]=="false"){
595
 
596
			#印出結果
597
			var_dump($caculateTimeAmount);
598
 
599
			#結束執行,回傳shell 1,代表異常.
600
			exit(1);
601
 
602
			}#if end
603
 
604
		#取得相對於update的固定時間
605
		$fixedTime=$caculateTimeAmount["unixtime"];
606
 
607
		#設置固定時間
608
		$repeatArray["fixed"]=$fixedTime;
609
 
610
		}#if end
611
 
612
	#函式說明:
613
	#新增或覆蓋系統上有哪些要自動執行的工作.
614
	#回傳結果:
615
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
616
	#$result["error"],錯誤訊息陣列.
617
	#$result["function"],當前執行的函式名稱.
618
	#$result["content"],當前排程資訊內容.
619
	#$result["argu"],使用的參數.
620
	#必填參數:
621
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
622
	$conf["fileArgu"]=__FILE__;
623
	#$conf["actions"],字串陣列,每個元素代表要執行的事情,每個事情為要執行的指令與參數所組成的一維陣列.
624
	$conf["actions"]=$parseCmdString["content"];
625
	#$conf["times"],字串陣列,每個元素代表要執行事情的時間點,單為為秒.格式為UTC時區的「年年年年-月月-日日 時 時:分分:秒秒」格式,事情不存在於啟動的狀態且當前時間大於等於之就會執行.
626
	$conf["times"]=array($startDate." ".$startTime);
627
	#$conf["repeat"],字串陣列,每個元素為一維陣列,代表要執行事情的重複方式.key為"times"代表剩下幾次可以執行,其value為"N"代表剩下N次(若N等於-1,則代表無限重複執行;若N等於0,則代表不用執行);key為"after"代表下次執行的時間為times+加其value;key為"fixed"代表下次執行的時間為一個循環的固定時間點,value為每次循環的固定時間點,例如每天01:05則為1h*3600s+5m*60s=3900,小於一天(86400秒)的時間,因此周期為天.
628
	$conf["repeat"]=array($repeat);
629
	#可省略參數:
630
 
631
	#如果有config參數
632
	if(isset($config)){
633
 
634
		#$conf["config"],字串,排程的設定檔位置,預設為"/usr/local/etc/qbpwcf-schedule.conf.php".
635
		$conf["config"]=$config;
636
 
637
		}#if end
638
 
639
	#如果有uuid參數
640
	if(isset($uuid)){
641
 
642
		#$conf["uuids"],字串陣列,每個排程的uuid,若不指定則會自動產生,若跟既有action的uuid相同,則會覆蓋其相關資訊.
643
		$conf["uuids"]=array($uuid);
644
 
645
		}#if end
646
 
647
	#參考資料:
648
	#無.
649
	#備註:
650
	#無.
651
	$createList=autoService::createList($conf);
652
	unset($conf);
653
 
654
	#若執行失敗
655
	if($createList["status"]==="false"){
656
 
657
		#印出結果
658
		var_dump($createList);
659
 
660
		#結束執行,回傳shell 1,代表異常.
661
		exit(1);
662
 
663
		}#if end
664
 
665
	}#if end
666
 
667
#如果有 getList 參數
668
if(isset($parseArgu["content"]["getList"])){
669
 
670
	#取得 checkList 參數
671
	$getList=$parseArgu["content"]["getList"][0];
672
 
673
	#如果要印出排程清單資訊
674
	if($getList==="yes"){
675
 
676
		#函式說明:
677
		#查詢系統上有哪些要自動執行的工作檔案
678
		#回傳結果:
679
		#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
680
		#$result["error"],錯誤訊息陣列.
681
		#$result["content"],回傳的結果,要執行的工作資訊陣列,每個元素的key有"uuid"跟"cmd&argu",前者為用於執行完畢時回報的排程項目識別;後者為該排程事項的指令與參數.
682
		#$result["function"],當前執行的函式名稱.
683
		#$result["found"],識別是否有要執行的動作.
684
		#必填參數:
685
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
686
		$conf["fileArgu"]=__FILE__;
687
		#可省略參數:
688
 
689
		#如果有config參數
690
		if(isset($config)){
691
 
692
			#$conf["config"],字串,排程的設定檔位置,預設為"/usr/local/etc/qbpwcf-schedule.conf.php".
693
			$conf["config"]=$config;
694
 
695
			}#if end
696
 
697
		#可省略參數:
698
		#無.
699
		#參考資料:
700
		#無.
701
		#備註:
702
		#無.
703
		$getList=autoService::getList($conf);
704
		unset($conf);
705
 
706
		#如果執行出錯
707
		if($getList["status"]==="false"){
708
 
709
			#印出結果
710
			var_dump($getList);
711
 
712
			#結束執行,回傳shell 1,代表異常.
713
			exit(1);
714
 
715
			}#if end
716
 
717
		}#if end
718
 
719
		#顯示排程清單
720
		var_dump($getList);
721
 
722
	}#if end