Subversion Repositories php-qbpwcf

Rev

Rev 40 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 40 Rev 226
Line 1... Line 1...
1
#!/usr/bin/php
1
#!/usr/bin/php
2
<?php
2
<?php
3
 
3
 
4
/*
4
/*
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2014~2025 Min-Jhin,Chen
6
    Copyright (C) 2014~2025 MIN ZHI, CHEN
7
 
7
 
8
    This file is part of QBPWCF.
8
    This file is part of QBPWCF.
9
 
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
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
11
    it under the terms of the GNU General Public License as published by
Line 17... Line 17...
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
18
    GNU General Public License for more details.
19
 
19
 
20
    You should have received a copy of the GNU General Public License
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/>.
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
    
22
 
23
*/
23
*/
24
 
24
 
25
/*
25
/*
26
說明:
26
說明:
27
管理排程的執行
27
管理排程的執行
Line 65... Line 65...
65
	#結束執行,回傳shell 1.
65
	#結束執行,回傳shell 1.
66
	exit(1);
66
	exit(1);
67
 
67
 
68
	}#if end
68
	}#if end
69
 
69
 
70
#設置 include path 
70
#設置 include path
71
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
71
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
72
 
72
 
73
#匯入外部套件
73
#匯入外部套件
74
include("allInOne.php");
74
include("allInOne.php");
75
 
75
 
76
#說明函式
76
#說明函式
77
function help(){
77
function help(){
78
 
78
 
79
	#印出指令說明
79
	#印出指令說明
80
	echo "Usage of ".basename(__FILE__).":".PHP_EOL; 
80
	echo "Usage of ".basename(__FILE__).":".PHP_EOL;
81
	echo "--daemon [on] 代表要啟動 daemon".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;
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;
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;
84
	echo "--log [write log file] 要將 log 寫入到哪邊?預設為\"/var/log/auto.log\"".PHP_EOL;
85
	echo "--action [command to run] 排程要執行的指令".PHP_EOL;
85
	echo "--action [command to run] 排程要執行的指令".PHP_EOL;
Line 91... Line 91...
91
	echo "--fixedMonth [Month][Month] 代表要固定月份執行".PHP_EOL;
91
	echo "--fixedMonth [Month][Month] 代表要固定月份執行".PHP_EOL;
92
	echo "--fixedDay [DayDay] 代表要固定日執行".PHP_EOL;
92
	echo "--fixedDay [DayDay] 代表要固定日執行".PHP_EOL;
93
	echo "--fixedHour [HoutHour] 代表要固定小時執行".PHP_EOL;
93
	echo "--fixedHour [HoutHour] 代表要固定小時執行".PHP_EOL;
94
	echo "--fixedMin [MinMin] 代表要固定分鐘執行".PHP_EOL;
94
	echo "--fixedMin [MinMin] 代表要固定分鐘執行".PHP_EOL;
95
	echo "--getList [yes] 代表要取得當前(更新後)的排程清單".PHP_EOL;
95
	echo "--getList [yes] 代表要取得當前(更新後)的排程清單".PHP_EOL;
96
	
96
 
97
	#結束執行
97
	#結束執行
98
	exit;
98
	exit;
99
 
99
 
100
	}#function help end
100
	}#function help end
101
 
101
 
Line 123... Line 123...
123
#如果解析參數失敗
123
#如果解析參數失敗
124
if($parseArgu["status"]==="false"){
124
if($parseArgu["status"]==="false"){
125
 
125
 
126
	#印出結果
126
	#印出結果
127
	var_dump($parseArgu);
127
	var_dump($parseArgu);
128
	
128
 
129
	#結束執行,回傳shell 1,代表異常.
129
	#結束執行,回傳shell 1,代表異常.
130
	exit(1);
130
	exit(1);
131
	
131
 
132
	}#if end
132
	}#if end
133
	
133
 
134
#函式說明:
134
#函式說明:
135
#使用 linux 的 uuid 指令來產生 uuid 字串
135
#使用 linux 的 uuid 指令來產生 uuid 字串
136
#回傳結果:
136
#回傳結果:
137
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
137
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
138
#$result["error"],錯誤訊息.
138
#$result["error"],錯誤訊息.
Line 151... Line 151...
151
#如果建立uuid失敗
151
#如果建立uuid失敗
152
if($uuid["status"]==="false"){
152
if($uuid["status"]==="false"){
153
 
153
 
154
	#印出結果
154
	#印出結果
155
	var_dump($uuid);
155
	var_dump($uuid);
156
	
156
 
157
	#結束執行,回傳shell 1,代表異常.
157
	#結束執行,回傳shell 1,代表異常.
158
	exit(1);
158
	exit(1);
159
 
159
 
160
	}#if end
160
	}#if end
161
	
161
 
162
#取得uuid
162
#取得uuid
163
$uuid=$uuid["content"];
163
$uuid=$uuid["content"];
164
	
164
 
165
#檢查參數
165
#檢查參數
166
#函式說明:
166
#函式說明:
167
#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
167
#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
168
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
168
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
169
#$reuslt["error"],執行不正常結束的錯訊息陣列.
169
#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 214... Line 214...
214
#若執行失敗
214
#若執行失敗
215
if($checkArguments["status"]==="false"){
215
if($checkArguments["status"]==="false"){
216
 
216
 
217
	#印出結果
217
	#印出結果
218
	var_dump($checkArguments);
218
	var_dump($checkArguments);
219
	
219
 
220
	#結束執行,回傳shell 1,代表異常.
220
	#結束執行,回傳shell 1,代表異常.
221
	exit(1);
221
	exit(1);
222
 
222
 
223
	}#if end
223
	}#if end
224
 
224
 
225
#若檢查不通過
225
#若檢查不通過
226
if($checkArguments["passed"]==="false"){
226
if($checkArguments["passed"]==="false"){
227
 
227
 
228
	#印出結果
228
	#印出結果
229
	var_dump($checkArguments);
229
	var_dump($checkArguments);
230
	
230
 
231
	#提示用法
231
	#提示用法
232
	help();
232
	help();
233
	
233
 
234
	#結束執行
234
	#結束執行
235
	exit;
235
	exit;
236
 
236
 
237
	}#if end
237
	}#if end
238
 
238
 
Line 265... Line 265...
265
 
265
 
266
	#取得 daemon 參數
266
	#取得 daemon 參數
267
	$daemon=$parseArgu["content"]["daemon"][0];
267
	$daemon=$parseArgu["content"]["daemon"][0];
268
 
268
 
269
	}#if end
269
	}#if end
270
	
270
 
271
#反之
271
#反之
272
else{
272
else{
273
 
273
 
274
	#設置不為daemon模式
274
	#設置不為daemon模式
275
	$daemon="off";
275
	$daemon="off";
276
	
276
 
277
	}#else end
277
	}#else end
278
	
278
 
279
#如果有 daemon 為 "on"
279
#如果有 daemon 為 "on"
280
if($daemon==="on"){
280
if($daemon==="on"){
281
 
281
 
282
	#函式說明:
282
	#函式說明:
283
	#建立unix domain socket server,依照設定檔autoService::createList建立的設定檔案來執行排程事項.
283
	#建立unix domain socket server,依照設定檔autoService::createList建立的設定檔案來執行排程事項.
Line 288... Line 288...
288
	#$result["argu"],所使用的參數.
288
	#$result["argu"],所使用的參數.
289
	#必填參數:
289
	#必填參數:
290
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
290
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
291
	$conf["fileArgu"]=__FILE__;
291
	$conf["fileArgu"]=__FILE__;
292
	#可省略參數:
292
	#可省略參數:
293
	
293
 
294
	#如果有config參數
294
	#如果有config參數
295
	if(isset($config)){
295
	if(isset($config)){
296
	
296
 
297
		#$conf["config"],字串,排程的設定檔位置,預設為"/usr/local/etc/qbpwcf-schedule.conf.php".
297
		#$conf["config"],字串,排程的設定檔位置,預設為"/usr/local/etc/qbpwcf-schedule.conf.php".
298
		$conf["config"]=$config;
298
		$conf["config"]=$config;
299
	
299
 
300
		}#if end
300
		}#if end
301
	
301
 
302
	#如果有socket參數
302
	#如果有socket參數
303
	if(isset($socket)){
303
	if(isset($socket)){
304
	
304
 
305
		#$conf["unixDomainSocket"],字串,unix domain socket 檔案要放在哪裡,預設為"/usr/lib/qbpwcf/qbpwcf-autoService.sock".
305
		#$conf["unixDomainSocket"],字串,unix domain socket 檔案要放在哪裡,預設為"/usr/lib/qbpwcf/qbpwcf-autoService.sock".
306
		$conf["unixDomainSocket"]=$socket;
306
		$conf["unixDomainSocket"]=$socket;
307
	
307
 
308
		}#if end
308
		}#if end
309
	
309
 
310
	#如果有log參數
310
	#如果有log參數
311
	if(isset($log)){
311
	if(isset($log)){
312
	
312
 
313
		#$conf["log"],字串,要將log寫到哪個地方,若有指定就會嘗試寫log.
313
		#$conf["log"],字串,要將log寫到哪個地方,若有指定就會嘗試寫log.
314
		$conf["log"]=$log;
314
		$conf["log"]=$log;
315
	
315
 
316
		}#if end
316
		}#if end
317
	
317
 
318
	#可省略參數:
318
	#可省略參數:
319
	#無.
319
	#無.
320
	#參考資料:
320
	#參考資料:
321
	#無.
321
	#無.
322
	#備註:
322
	#備註:
Line 327... Line 327...
327
	#若執行失敗
327
	#若執行失敗
328
	if($daemon["status"]==="false"){
328
	if($daemon["status"]==="false"){
329
 
329
 
330
		#印出結果
330
		#印出結果
331
		var_dump($uuid);
331
		var_dump($uuid);
332
		
332
 
333
		#結束執行,回傳shell 1,代表異常.
333
		#結束執行,回傳shell 1,代表異常.
334
		exit(1);
334
		exit(1);
335
 
335
 
336
		}#if end
336
		}#if end
337
		
337
 
338
	#執行到這邊代表意外結束
338
	#執行到這邊代表意外結束
339
	exit(1);
339
	exit(1);
340
 
340
 
341
	}#if end
341
	}#if end
342
	
342
 
343
#如果有 startTime 參數
343
#如果有 startTime 參數
344
if(isset($parseArgu["content"]["startTime"])){
344
if(isset($parseArgu["content"]["startTime"])){
345
 
345
 
346
	#取得 startTime 參數
346
	#取得 startTime 參數
347
	$startTime=$parseArgu["content"]["startTime"][0];
347
	$startTime=$parseArgu["content"]["startTime"][0];
348
 
348
 
349
	}#if end
349
	}#if end
350
	
350
 
351
#反之
351
#反之
352
else{
352
else{
353
 
353
 
354
	#為當下時分秒
354
	#為當下時分秒
355
	$startTime=gmdate("H:i:s");
355
	$startTime=gmdate("H:i:s");
356
 
356
 
357
	}#else end
357
	}#else end
358
	
358
 
359
#如果有 startDate 參數
359
#如果有 startDate 參數
360
if(isset($parseArgu["content"]["startDate"])){
360
if(isset($parseArgu["content"]["startDate"])){
361
 
361
 
362
	#取得 startDate 參數
362
	#取得 startDate 參數
363
	$startDate=$parseArgu["content"]["startDate"][0];
363
	$startDate=$parseArgu["content"]["startDate"][0];
364
 
364
 
365
	}#if end
365
	}#if end
366
	
366
 
367
#反之
367
#反之
368
else{
368
else{
369
 
369
 
370
	#為當下年月日
370
	#為當下年月日
371
	$startDate=gmdate("Y-m-d");
371
	$startDate=gmdate("Y-m-d");
372
 
372
 
373
	}#else end
373
	}#else end
374
	
374
 
375
#如果有 repeat 參數
375
#如果有 repeat 參數
376
if(isset($parseArgu["content"]["repeat"])){
376
if(isset($parseArgu["content"]["repeat"])){
377
 
377
 
378
	#取得 repeat 參數
378
	#取得 repeat 參數
379
	$repeat=$parseArgu["content"]["repeat"][0];
379
	$repeat=$parseArgu["content"]["repeat"][0];
380
 
380
 
381
	}#if end
381
	}#if end
382
	
382
 
383
#如果有 uuid 參數
383
#如果有 uuid 參數
384
if(isset($parseArgu["content"]["uuid"])){
384
if(isset($parseArgu["content"]["uuid"])){
385
 
385
 
386
	#取得 repeat 參數
386
	#取得 repeat 參數
387
	$uuid=$parseArgu["content"]["uuid"][0];
387
	$uuid=$parseArgu["content"]["uuid"][0];
388
 
388
 
389
	}#if end
389
	}#if end
390
	
390
 
391
#反之
391
#反之
392
else{
392
else{
393
 
393
 
394
	#函式說明:
394
	#函式說明:
395
	#使用 linux 的 uuid 指令來產生 uuid 字串
395
	#使用 linux 的 uuid 指令來產生 uuid 字串
Line 411... Line 411...
411
	#如果建立uuid失敗
411
	#如果建立uuid失敗
412
	if($uuid["status"]==="false"){
412
	if($uuid["status"]==="false"){
413
 
413
 
414
		#印出結果
414
		#印出結果
415
		var_dump($uuid);
415
		var_dump($uuid);
416
		
416
 
417
		#結束執行,回傳shell 1,代表異常.
417
		#結束執行,回傳shell 1,代表異常.
418
		exit(1);
418
		exit(1);
419
 
419
 
420
		}#if end
420
		}#if end
421
		
421
 
422
	#取得uuid
422
	#取得uuid
423
	$uuid=$uuid["content"];
423
	$uuid=$uuid["content"];
424
 
424
 
425
	}#else end
425
	}#else end
426
 
426
 
427
#如果有 fixedMonth 參數
427
#如果有 fixedMonth 參數
428
if(isset($parseArgu["content"]["fixedMonth"])){
428
if(isset($parseArgu["content"]["fixedMonth"])){
429
 
429
 
430
	#取得 fixedMonth 參數
430
	#取得 fixedMonth 參數
431
	$fixedMonth=$parseArgu["content"]["fixedMonth"][0];
431
	$fixedMonth=$parseArgu["content"]["fixedMonth"][0];
432
	
432
 
433
	}#if end
433
	}#if end
434
 
434
 
435
#反之
435
#反之
436
else{
436
else{
437
 
437
 
Line 445... Line 445...
445
 
445
 
446
	#取得 fixedDay 參數
446
	#取得 fixedDay 參數
447
	$fixedDay=$parseArgu["content"]["fixedDay"][0];
447
	$fixedDay=$parseArgu["content"]["fixedDay"][0];
448
 
448
 
449
	}#if end
449
	}#if end
450
	
450
 
451
#反之
451
#反之
452
else{
452
else{
453
 
453
 
454
	#設置 fixedDay 參數跟開始日一樣
454
	#設置 fixedDay 參數跟開始日一樣
455
	$fixedDay=$startDate[8].$startDate[9];
455
	$fixedDay=$startDate[8].$startDate[9];
456
 
456
 
457
	}#else end
457
	}#else end
458
	
458
 
459
#如果有 fixedHour 參數
459
#如果有 fixedHour 參數
460
if(isset($parseArgu["content"]["fixedHour"])){
460
if(isset($parseArgu["content"]["fixedHour"])){
461
 
461
 
462
	#取得 fixedHour 參數
462
	#取得 fixedHour 參數
463
	$fixedHour=$parseArgu["content"]["fixedHour"][0];
463
	$fixedHour=$parseArgu["content"]["fixedHour"][0];
464
 
464
 
465
	#如果只有輸入一個數字
465
	#如果只有輸入一個數字
466
	if(strlen($fixedHour)===1){
466
	if(strlen($fixedHour)===1){
467
	
467
 
468
		#前面補0
468
		#前面補0
469
		$fixedHour="0".$fixedHour;
469
		$fixedHour="0".$fixedHour;
470
	
470
 
471
		}#if end
471
		}#if end
472
 
472
 
473
	}#if end
473
	}#if end
474
	
474
 
475
#反之
475
#反之
476
else{
476
else{
477
 
477
 
478
	#設置 fixedHour 參數跟開始小時一樣
478
	#設置 fixedHour 參數跟開始小時一樣
479
	$fixedHour=$startTime[0].$startTime[1];
479
	$fixedHour=$startTime[0].$startTime[1];
480
 
480
 
481
	}#else end
481
	}#else end
482
	
482
 
483
#如果有 fixedMin 參數
483
#如果有 fixedMin 參數
484
if(isset($parseArgu["content"]["fixedMin"])){
484
if(isset($parseArgu["content"]["fixedMin"])){
485
 
485
 
486
	#取得 fixedMin 參數
486
	#取得 fixedMin 參數
487
	$fixedMin=$parseArgu["content"]["fixedMin"][0];
487
	$fixedMin=$parseArgu["content"]["fixedMin"][0];
488
 
488
 
489
	}#if end
489
	}#if end
490
	
490
 
491
#反之
491
#反之
492
else{
492
else{
493
	
493
 
494
	#設置 fixedMin 參數跟開始分鐘一樣
494
	#設置 fixedMin 參數跟開始分鐘一樣
495
	$fixedMin=$startTime[3].$startTime[4];
495
	$fixedMin=$startTime[3].$startTime[4];
496
 
496
 
497
	}#else end
497
	}#else end
498
	
498
 
499
	
499
 
500
 
500
 
501
#如果有 cycleTime 參數
501
#如果有 cycleTime 參數
502
if(isset($conf["cycleTime"])){
502
if(isset($conf["cycleTime"])){
503
 
503
 
504
	#取得cycle參數
504
	#取得cycle參數
Line 509... Line 509...
509
#如果有 action 參數
509
#如果有 action 參數
510
if(isset($parseArgu["content"]["action"])){
510
if(isset($parseArgu["content"]["action"])){
511
 
511
 
512
	#取得 action 參數
512
	#取得 action 參數
513
	$action=$parseArgu["content"]["action"][0];
513
	$action=$parseArgu["content"]["action"][0];
514
	
514
 
515
	#解析指令與參數
515
	#解析指令與參數
516
	#函式說明:
516
	#函式說明:
517
	#將指令字串解析成陣列,方便給予 external::callShell 使用 
517
	#將指令字串解析成陣列,方便給予 external::callShell 使用
518
	#回傳結果:
518
	#回傳結果:
519
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
519
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
520
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
520
	#$reuslt["error"],執行不正常結束的錯訊息陣列.
521
	#$result["function"],當前執行的函式名稱.
521
	#$result["function"],當前執行的函式名稱.
522
	#$result["content"],解析好的指令陣列.
522
	#$result["content"],解析好的指令陣列.
Line 532... Line 532...
532
	#無.
532
	#無.
533
	#備註:
533
	#備註:
534
	#無.
534
	#無.
535
	$parseCmdString=cmd::parseCmdString($conf);
535
	$parseCmdString=cmd::parseCmdString($conf);
536
	unset($conf);
536
	unset($conf);
537
	
537
 
538
	#若執行失敗
538
	#若執行失敗
539
	if($parseCmdString["status"]==="false"){
539
	if($parseCmdString["status"]==="false"){
540
 
540
 
541
		#印出結果
541
		#印出結果
542
		var_dump($parseCmdString);
542
		var_dump($parseCmdString);
543
		
543
 
544
		#結束執行,回傳shell 1,代表異常.
544
		#結束執行,回傳shell 1,代表異常.
545
		exit(1);
545
		exit(1);
546
 
546
 
547
		}#if end
547
		}#if end
548
	
548
 
549
	#初始化給createList函式的repeat參數
549
	#初始化給createList函式的repeat參數
550
	$repeatArray=array();
550
	$repeatArray=array();
551
	
551
 
552
	#設置重複的規則
552
	#設置重複的規則
553
	$repeatArray["times"]=$repeat;
553
	$repeatArray["times"]=$repeat;
554
	
554
 
555
	#如果有 $cycleTime
555
	#如果有 $cycleTime
556
	if(isset($cycleTime)){
556
	if(isset($cycleTime)){
557
	
557
 
558
		#設置周期時間
558
		#設置周期時間
559
		$repeatArray["after"]=$cycleTime;
559
		$repeatArray["after"]=$cycleTime;
560
	
560
 
561
		}#if end
561
		}#if end
562
	
562
 
563
	#反之如果有設定固定時間
563
	#反之如果有設定固定時間
564
	else{
564
	else{
565
	
565
 
566
		#組合成固定執行時間的年月日時分秒
566
		#組合成固定執行時間的年月日時分秒
567
		$dateAndTime=gmdate('Y')."-".$fixedMonth."-".$fixedDay." ".$fixedHour.":".$fixedMin.":00";
567
		$dateAndTime=gmdate('Y')."-".$fixedMonth."-".$fixedDay." ".$fixedHour.":".$fixedMin.":00";
568
	
568
 
569
		#函式說明:
569
		#函式說明:
570
		#計算時間點距離1970/01/01多少秒,亦即unixtime.
570
		#計算時間點距離1970/01/01多少秒,亦即unixtime.
571
		#回傳結果:
571
		#回傳結果:
572
		#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
572
		#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
573
		#$result["error"],錯誤訊息陣列.
573
		#$result["error"],錯誤訊息陣列.
574
		#$result["content"],時間點距離1970/01/01的多少秒.
574
		#$result["content"],時間點距離1970/01/01的多少秒.
575
		#$result["argu"],使用的參數.
575
		#$result["argu"],使用的參數.
576
		#$result["unixtime"],執行本函式時的unixtime.
576
		#$result["unixtime"],執行本函式時的unixtime.
577
		#$result["oriDateAndTime"],原始輸入的內容,若replace0參數為"true",才會有該回傳內容.	
577
		#$result["oriDateAndTime"],原始輸入的內容,若replace0參數為"true",才會有該回傳內容.
578
		#必填參數:
578
		#必填參數:
579
		#$conf["dateAndTime"],字串,格式爲 2011-05-27 23:59:59.
579
		#$conf["dateAndTime"],字串,格式爲 2011-05-27 23:59:59.
580
		$conf["time::caculateTimeAmount"]["dateAndTime"]=$dateAndTime;
580
		$conf["time::caculateTimeAmount"]["dateAndTime"]=$dateAndTime;
581
		#可省略參數:
581
		#可省略參數:
582
		#$conf["UTC"],字串,是否要用當前時區的設定去換算成unixtime,預設為"false",代表不要;反之為"true".
582
		#$conf["UTC"],字串,是否要用當前時區的設定去換算成unixtime,預設為"false",代表不要;反之為"true".
Line 587... Line 587...
587
		#無.
587
		#無.
588
		#備註:
588
		#備註:
589
		#無.
589
		#無.
590
		$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
590
		$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
591
		unset($conf["time::caculateTimeAmount"]);
591
		unset($conf["time::caculateTimeAmount"]);
592
		
592
 
593
		#如果執行失敗
593
		#如果執行失敗
594
		if($caculateTimeAmount["status"]=="false"){
594
		if($caculateTimeAmount["status"]=="false"){
595
			
595
 
596
			#印出結果
596
			#印出結果
597
			var_dump($caculateTimeAmount);
597
			var_dump($caculateTimeAmount);
598
			
598
 
599
			#結束執行,回傳shell 1,代表異常.
599
			#結束執行,回傳shell 1,代表異常.
600
			exit(1);
600
			exit(1);
601
			
601
 
602
			}#if end
602
			}#if end
603
	
603
 
604
		#取得相對於update的固定時間
604
		#取得相對於update的固定時間
605
		$fixedTime=$caculateTimeAmount["unixtime"];
605
		$fixedTime=$caculateTimeAmount["unixtime"];
606
	
606
 
607
		#設置固定時間
607
		#設置固定時間
608
		$repeatArray["fixed"]=$fixedTime;
608
		$repeatArray["fixed"]=$fixedTime;
609
	
609
 
610
		}#if end
610
		}#if end
611
		
611
 
612
	#函式說明:
612
	#函式說明:
613
	#新增或覆蓋系統上有哪些要自動執行的工作.
613
	#新增或覆蓋系統上有哪些要自動執行的工作.
614
	#回傳結果:
614
	#回傳結果:
615
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
615
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
616
	#$result["error"],錯誤訊息陣列.
616
	#$result["error"],錯誤訊息陣列.
Line 625... Line 625...
625
	#$conf["times"],字串陣列,每個元素代表要執行事情的時間點,單為為秒.格式為UTC時區的「年年年年-月月-日日 時 時:分分:秒秒」格式,事情不存在於啟動的狀態且當前時間大於等於之就會執行.
625
	#$conf["times"],字串陣列,每個元素代表要執行事情的時間點,單為為秒.格式為UTC時區的「年年年年-月月-日日 時 時:分分:秒秒」格式,事情不存在於啟動的狀態且當前時間大於等於之就會執行.
626
	$conf["times"]=array($startDate." ".$startTime);
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秒)的時間,因此周期為天.
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);
628
	$conf["repeat"]=array($repeat);
629
	#可省略參數:
629
	#可省略參數:
630
	
630
 
631
	#如果有config參數
631
	#如果有config參數
632
	if(isset($config)){
632
	if(isset($config)){
633
	
633
 
634
		#$conf["config"],字串,排程的設定檔位置,預設為"/usr/local/etc/qbpwcf-schedule.conf.php".
634
		#$conf["config"],字串,排程的設定檔位置,預設為"/usr/local/etc/qbpwcf-schedule.conf.php".
635
		$conf["config"]=$config;
635
		$conf["config"]=$config;
636
		
636
 
637
		}#if end
637
		}#if end
638
	
638
 
639
	#如果有uuid參數
639
	#如果有uuid參數
640
	if(isset($uuid)){
640
	if(isset($uuid)){
641
	
641
 
642
		#$conf["uuids"],字串陣列,每個排程的uuid,若不指定則會自動產生,若跟既有action的uuid相同,則會覆蓋其相關資訊.
642
		#$conf["uuids"],字串陣列,每個排程的uuid,若不指定則會自動產生,若跟既有action的uuid相同,則會覆蓋其相關資訊.
643
		$conf["uuids"]=array($uuid);
643
		$conf["uuids"]=array($uuid);
644
	
644
 
645
		}#if end
645
		}#if end
646
	
646
 
647
	#參考資料:
647
	#參考資料:
648
	#無.
648
	#無.
649
	#備註:
649
	#備註:
650
	#無.
650
	#無.
651
	$createList=autoService::createList($conf);
651
	$createList=autoService::createList($conf);
652
	unset($conf);
652
	unset($conf);
653
	
653
 
654
	#若執行失敗
654
	#若執行失敗
655
	if($createList["status"]==="false"){
655
	if($createList["status"]==="false"){
656
 
656
 
657
		#印出結果
657
		#印出結果
658
		var_dump($createList);
658
		var_dump($createList);
659
		
659
 
660
		#結束執行,回傳shell 1,代表異常.
660
		#結束執行,回傳shell 1,代表異常.
661
		exit(1);
661
		exit(1);
662
 
662
 
663
		}#if end
663
		}#if end
664
	
664
 
665
	}#if end
665
	}#if end
666
	
666
 
667
#如果有 getList 參數
667
#如果有 getList 參數
668
if(isset($parseArgu["content"]["getList"])){
668
if(isset($parseArgu["content"]["getList"])){
669
 
669
 
670
	#取得 checkList 參數
670
	#取得 checkList 參數
671
	$getList=$parseArgu["content"]["getList"][0];
671
	$getList=$parseArgu["content"]["getList"][0];
672
	
672
 
673
	#如果要印出排程清單資訊
673
	#如果要印出排程清單資訊
674
	if($getList==="yes"){
674
	if($getList==="yes"){
675
	
675
 
676
		#函式說明:
676
		#函式說明:
677
		#查詢系統上有哪些要自動執行的工作檔案
677
		#查詢系統上有哪些要自動執行的工作檔案
678
		#回傳結果:
678
		#回傳結果:
679
		#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
679
		#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
680
		#$result["error"],錯誤訊息陣列.
680
		#$result["error"],錯誤訊息陣列.
Line 683... Line 683...
683
		#$result["found"],識別是否有要執行的動作.
683
		#$result["found"],識別是否有要執行的動作.
684
		#必填參數:
684
		#必填參數:
685
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
685
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
686
		$conf["fileArgu"]=__FILE__;
686
		$conf["fileArgu"]=__FILE__;
687
		#可省略參數:
687
		#可省略參數:
688
		
688
 
689
		#如果有config參數
689
		#如果有config參數
690
		if(isset($config)){
690
		if(isset($config)){
691
	
691
 
692
			#$conf["config"],字串,排程的設定檔位置,預設為"/usr/local/etc/qbpwcf-schedule.conf.php".
692
			#$conf["config"],字串,排程的設定檔位置,預設為"/usr/local/etc/qbpwcf-schedule.conf.php".
693
			$conf["config"]=$config;
693
			$conf["config"]=$config;
694
		
694
 
695
			}#if end
695
			}#if end
696
			
696
 
697
		#可省略參數:
697
		#可省略參數:
698
		#無.
698
		#無.
699
		#參考資料:
699
		#參考資料:
700
		#無.
700
		#無.
701
		#備註:
701
		#備註:
702
		#無.
702
		#無.
703
		$getList=autoService::getList($conf);
703
		$getList=autoService::getList($conf);
704
		unset($conf);
704
		unset($conf);
705
	
705
 
706
		#如果執行出錯
706
		#如果執行出錯
707
		if($getList["status"]==="false"){
707
		if($getList["status"]==="false"){
708
		
708
 
709
			#印出結果
709
			#印出結果
710
			var_dump($getList);
710
			var_dump($getList);
711
			
711
 
712
			#結束執行,回傳shell 1,代表異常.
712
			#結束執行,回傳shell 1,代表異常.
713
			exit(1);
713
			exit(1);
714
		
714
 
715
			}#if end
715
			}#if end
716
	
716
 
717
		}#if end
717
		}#if end
718
		
718
 
719
		#顯示排程清單
719
		#顯示排程清單
720
		var_dump($getList);
720
		var_dump($getList);
721
	
-
 
722
	}#if end
-
 
723
721
 
-
 
722
	}#if end
-
 
723