Subversion Repositories qbpwcf-lib(archive)

Rev

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

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