Subversion Repositories php-qbpwcf

Rev

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

Rev 3 Rev 226
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
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) 2015~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 28... Line 28...
28
提供類似cronjob服務的類別.
28
提供類似cronjob服務的類別.
29
備註:
29
備註:
30
無.
30
無.
31
*/
31
*/
32
class autoService{
32
class autoService{
33
	
33
 
34
	/*
34
	/*
35
	#函式說明:
35
	#函式說明:
36
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
36
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
37
	#回傳結果:
37
	#回傳結果:
38
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
38
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 43... Line 43...
43
	#$arguments,陣列,為呼叫方法時所用的參數.
43
	#$arguments,陣列,為呼叫方法時所用的參數.
44
	#參考資料:
44
	#參考資料:
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
45
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
46
	*/
46
	*/
47
	public function __call($method,$arguments){
47
	public function __call($method,$arguments){
48
		
48
 
49
		#取得當前執行的函式
49
		#取得當前執行的函式
50
		$result["function"]=__FUNCTION__;
50
		$result["function"]=__FUNCTION__;
51
		
51
 
52
		#設置執行不正常
52
		#設置執行不正常
53
		$result["status"]="false";
53
		$result["status"]="false";
54
		
54
 
55
		#設置執行錯誤
55
		#設置執行錯誤
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
56
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
57
		
57
 
58
		#設置所丟入的參數
58
		#設置所丟入的參數
59
		$result["error"][]=$arguments;
59
		$result["error"][]=$arguments;
60
		
60
 
61
		#回傳結果
61
		#回傳結果
62
		return $result;
62
		return $result;
63
		
63
 
64
		}#function __call end
64
		}#function __call end
65
		
65
 
66
	/*
66
	/*
67
	#函式說明:
67
	#函式說明:
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
68
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
69
	#回傳結果:
69
	#回傳結果:
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
70
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 75... Line 75...
75
	#$arguments,陣列,為呼叫方法時所用的參數.
75
	#$arguments,陣列,為呼叫方法時所用的參數.
76
	#參考資料:
76
	#參考資料:
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
77
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
78
	*/
78
	*/
79
	public static function __callStatic($method,$arguments){
79
	public static function __callStatic($method,$arguments){
80
		
80
 
81
		#取得當前執行的函式
81
		#取得當前執行的函式
82
		$result["function"]=__FUNCTION__;
82
		$result["function"]=__FUNCTION__;
83
		
83
 
84
		#設置執行不正常
84
		#設置執行不正常
85
		$result["status"]="false";
85
		$result["status"]="false";
86
		
86
 
87
		#設置執行錯誤
87
		#設置執行錯誤
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
88
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
89
		
89
 
90
		#設置所丟入的參數
90
		#設置所丟入的參數
91
		$result["error"][]=$arguments;
91
		$result["error"][]=$arguments;
92
		
92
 
93
		#回傳結果
93
		#回傳結果
94
		return $result;
94
		return $result;
95
		
95
 
96
		}#function __callStatic end
96
		}#function __callStatic end
97
	
97
 
98
	/*
98
	/*
99
	#函式說明:
99
	#函式說明:
100
	#新增或覆蓋系統上有哪些要自動執行的工作.
100
	#新增或覆蓋系統上有哪些要自動執行的工作.
101
	#回傳結果:
101
	#回傳結果:
102
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
102
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
Line 122... Line 122...
122
	#無.
122
	#無.
123
	#備註:
123
	#備註:
124
	#無.
124
	#無.
125
	*/
125
	*/
126
	public static function createList(&$conf){
126
	public static function createList(&$conf){
127
	
127
 
128
		#初始化要回傳的變數
128
		#初始化要回傳的變數
129
		$result=array();
129
		$result=array();
130
 
130
 
131
		#初始化當前執行的函數名稱
131
		#初始化當前執行的函數名稱
132
		$result["function"]=__FUNCTION__;
132
		$result["function"]=__FUNCTION__;
133
 
133
 
134
		#如果 $conf 不為陣列
134
		#如果 $conf 不為陣列
135
		if(gettype($conf)!="array"){
135
		if(gettype($conf)!="array"){
136
			
136
 
137
			#設置執行失敗
137
			#設置執行失敗
138
			$result["status"]="false";
138
			$result["status"]="false";
139
			
139
 
140
			#設置執行錯誤訊息
140
			#設置執行錯誤訊息
141
			$result["error"][]="\$conf變數須為陣列形態";
141
			$result["error"][]="\$conf變數須為陣列形態";
142
 
142
 
143
			#如果傳入的參數為 null
143
			#如果傳入的參數為 null
144
			if($conf==null){
144
			if($conf==null){
145
				
145
 
146
				#設置執行錯誤訊息
146
				#設置執行錯誤訊息
147
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
147
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
148
				
148
 
149
				}#if end
149
				}#if end
150
 
150
 
151
			#回傳結果
151
			#回傳結果
152
			return $result;
152
			return $result;
153
			
153
 
154
			}#if end
154
			}#if end
155
	
155
 
156
		#取得使用的參數
156
		#取得使用的參數
157
		$result["argu"]=$conf;
157
		$result["argu"]=$conf;
158
		
158
 
159
		#函式說明:
159
		#函式說明:
160
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
160
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
161
		#回傳結果:
161
		#回傳結果:
162
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
162
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
163
		#$result["error"],執行不正常結束的錯訊息陣列.
163
		#$result["error"],執行不正常結束的錯訊息陣列.
Line 208... Line 208...
208
		#array_keys=>http://php.net/manual/en/function.array-keys.php
208
		#array_keys=>http://php.net/manual/en/function.array-keys.php
209
		#備註:
209
		#備註:
210
		#無.
210
		#無.
211
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
211
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
212
		unset($conf["variableCheck::checkArguments"]);
212
		unset($conf["variableCheck::checkArguments"]);
213
	
213
 
214
		#如果 $checkArguments["status"] 等於 "false"
214
		#如果 $checkArguments["status"] 等於 "false"
215
		if($checkArguments["status"]==="false"){
215
		if($checkArguments["status"]==="false"){
216
			
216
 
217
			#設置錯誤識別
217
			#設置錯誤識別
218
			$result["status"]="false";
218
			$result["status"]="false";
219
			
219
 
220
			#設置錯誤訊息
220
			#設置錯誤訊息
221
			$result["error"]=$checkArguments;
221
			$result["error"]=$checkArguments;
222
			
222
 
223
			#回傳結果
223
			#回傳結果
224
			return $result;				
224
			return $result;
225
			
225
 
226
			}#if end
226
			}#if end
227
			
227
 
228
		#如果 $checkArguments["passed"] 等於 "false"
228
		#如果 $checkArguments["passed"] 等於 "false"
229
		if($checkArguments["passed"]==="false"){
229
		if($checkArguments["passed"]==="false"){
230
			
230
 
231
			#設置錯誤識別
231
			#設置錯誤識別
232
			$result["status"]="false";
232
			$result["status"]="false";
233
			
233
 
234
			#設置錯誤訊息
234
			#設置錯誤訊息
235
			$result["error"]=$checkArguments;
235
			$result["error"]=$checkArguments;
236
			
236
 
237
			#回傳結果
237
			#回傳結果
238
			return $result;
238
			return $result;
239
			
239
 
240
			}#if end
240
			}#if end
241
		
241
 
242
		#檢查每個 time 的格式
242
		#檢查每個 time 的格式
243
		foreach($conf["times"] as $time){
243
		foreach($conf["times"] as $time){
244
		
244
 
245
			#函式說明:
245
			#函式說明:
246
			#檢查字串是否符合 RFC 3339/ISO-8601 格式
246
			#檢查字串是否符合 RFC 3339/ISO-8601 格式
247
			#回傳結果:
247
			#回傳結果:
248
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
248
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
249
			#$result["passed"],檢查是否通過,"true"代表通過,"false"代表不通過.
249
			#$result["passed"],檢查是否通過,"true"代表通過,"false"代表不通過.
Line 261... Line 261...
261
			#rfc3339=>https://www.rfc-editor.org/rfc/rfc3339
261
			#rfc3339=>https://www.rfc-editor.org/rfc/rfc3339
262
			#備註:
262
			#備註:
263
			#無.
263
			#無.
264
			$checkRFC3339=variableCheck::checkRFC3339($conf["variableCheck::checkRFC3339"]);
264
			$checkRFC3339=variableCheck::checkRFC3339($conf["variableCheck::checkRFC3339"]);
265
			unset($conf["variableCheck::checkRFC3339"]);
265
			unset($conf["variableCheck::checkRFC3339"]);
266
		
266
 
267
			#如果執行出錯
267
			#如果執行出錯
268
			if($checkRFC3339["status"]==="false"){
268
			if($checkRFC3339["status"]==="false"){
269
				
269
 
270
				#設置錯誤識別
270
				#設置錯誤識別
271
				$result["status"]="false";
271
				$result["status"]="false";
272
				
272
 
273
				#設置錯誤訊息
273
				#設置錯誤訊息
274
				$result["error"]=$checkRFC3339;
274
				$result["error"]=$checkRFC3339;
275
				
275
 
276
				#回傳結果
276
				#回傳結果
277
				return $result;
277
				return $result;
278
				
278
 
279
				}#if end
279
				}#if end
280
		
280
 
281
			#如果檢查不通過
281
			#如果檢查不通過
282
			if($checkRFC3339["passed"]==="false"){
282
			if($checkRFC3339["passed"]==="false"){
283
				
283
 
284
				#設置錯誤識別
284
				#設置錯誤識別
285
				$result["status"]="false";
285
				$result["status"]="false";
286
				
286
 
287
				#設置錯誤訊息
287
				#設置錯誤訊息
288
				$result["error"]=$checkRFC3339;
288
				$result["error"]=$checkRFC3339;
289
				
289
 
290
				#回傳結果
290
				#回傳結果
291
				return $result;
291
				return $result;
292
				
292
 
293
				}#if end
293
				}#if end
294
		
294
 
295
			}#foreach end
295
			}#foreach end
296
		
296
 
297
		#取得uuid的數量應該要多少
297
		#取得uuid的數量應該要多少
298
		$uuidCount=count($conf["actions"]);
298
		$uuidCount=count($conf["actions"]);
299
			
299
 
300
		#如果沒有指定 uuids
300
		#如果沒有指定 uuids
301
		if(!isset($conf["uuids"])){
301
		if(!isset($conf["uuids"])){
302
		
302
 
303
			#初始化 uuids
303
			#初始化 uuids
304
			$conf["uuids"]=array();
304
			$conf["uuids"]=array();
305
		
305
 
306
			#產生對應數量的uuid
306
			#產生對應數量的uuid
307
			for($i=0;$i<$uuidCount;$i++){
307
			for($i=0;$i<$uuidCount;$i++){
308
			
308
 
309
				#函式說明:
309
				#函式說明:
310
				#使用 linux 的 uuid 指令來產生 uuid 字串
310
				#使用 linux 的 uuid 指令來產生 uuid 字串
311
				#回傳結果:
311
				#回傳結果:
312
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
312
				#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
313
				#$result["error"],錯誤訊息.
313
				#$result["error"],錯誤訊息.
Line 319... Line 319...
319
				#參考資料:
319
				#參考資料:
320
				#無.
320
				#無.
321
				#備註:
321
				#備註:
322
				#無.
322
				#無.
323
				$uuid=cmd::uuid();
323
				$uuid=cmd::uuid();
324
			
324
 
325
				#如果執行失敗
325
				#如果執行失敗
326
				if($uuid["status"]==="false"){
326
				if($uuid["status"]==="false"){
327
					
327
 
328
					#設置錯誤識別
328
					#設置錯誤識別
329
					$result["status"]="false";
329
					$result["status"]="false";
330
					
330
 
331
					#設置錯誤訊息
331
					#設置錯誤訊息
332
					$result["error"]=$uuid;
332
					$result["error"]=$uuid;
333
					
333
 
334
					#回傳結果
334
					#回傳結果
335
					return $result;	
335
					return $result;
336
					
336
 
337
					}#if end
337
					}#if end
338
				
338
 
339
				#儲存新的uuid
339
				#儲存新的uuid
340
				$conf["uuids"][]=$uuid["content"];
340
				$conf["uuids"][]=$uuid["content"];
341
				
341
 
342
				}#for end
342
				}#for end
343
		
343
 
344
			}#if end
344
			}#if end
345
		
345
 
346
		#讀取既有排程設定檔
346
		#讀取既有排程設定檔
347
		#函式說明:
347
		#函式說明:
348
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
348
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
349
		#回傳的變數說明:
349
		#回傳的變數說明:
350
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
350
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
Line 375... Line 375...
375
		#無.
375
		#無.
376
		#備註:
376
		#備註:
377
		#無.
377
		#無.
378
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
378
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
379
		unset($conf["fileAccess::getFileContent"]);
379
		unset($conf["fileAccess::getFileContent"]);
380
		
380
 
381
		#如果執行失敗
381
		#如果執行失敗
382
		if($getFileContent["status"]=="false"){
382
		if($getFileContent["status"]=="false"){
383
			
383
 
384
			#設置錯誤識別
384
			#設置錯誤識別
385
			$result["status"]="false";
385
			$result["status"]="false";
386
			
386
 
387
			#設置錯誤訊息
387
			#設置錯誤訊息
388
			$result["error"]=$getFileContent;
388
			$result["error"]=$getFileContent;
389
			
389
 
390
			#回傳結果
390
			#回傳結果
391
			return $result;	
391
			return $result;
392
			
392
 
393
			}#if end
393
			}#if end
394
		
394
 
395
		#初始化原始設定擋內容
395
		#初始化原始設定擋內容
396
		$oriConfig=array();
396
		$oriConfig=array();
397
		
397
 
398
		#針對每行內容
398
		#針對每行內容
399
		foreach($getFileContent["fileContent"] as $lineNo=>$line){
399
		foreach($getFileContent["fileContent"] as $lineNo=>$line){
400
		
400
 
401
			#解析內容
401
			#解析內容
402
			#函式說明:
402
			#函式說明:
403
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
403
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
404
			#回傳結果:
404
			#回傳結果:
405
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
405
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
406
			#$result["function"],當前執行的函數名稱.
406
			#$result["function"],當前執行的函數名稱.
407
			#$result["content"],加密後的結果.
407
			#$result["content"],加密後的結果.
408
			#$result["error"],錯誤訊息陣列.
408
			#$result["error"],錯誤訊息陣列.
409
			#$result["argu"],使用的參數.
409
			#$result["argu"],使用的參數.
410
			#必填參數:
410
			#必填參數:
Line 431... Line 431...
431
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
431
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
432
			#備註:
432
			#備註:
433
			#無.
433
			#無.
434
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
434
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
435
			unset($conf["authenticate::enCodeStr"]);
435
			unset($conf["authenticate::enCodeStr"]);
436
		
436
 
437
			#如果執行失敗
437
			#如果執行失敗
438
			if($enCodeStr["status"]==="false"){
438
			if($enCodeStr["status"]==="false"){
439
				
439
 
440
				#設置錯誤識別
440
				#設置錯誤識別
441
				$result["status"]="false";
441
				$result["status"]="false";
442
				
442
 
443
				#設置錯誤訊息
443
				#設置錯誤訊息
444
				$result["error"]=$enCodeStr;
444
				$result["error"]=$enCodeStr;
445
				
445
 
446
				#回傳結果
446
				#回傳結果
447
				return $result;	
447
				return $result;
448
				
448
 
449
				}#if end
449
				}#if end
450
			
450
 
451
			#解碼後的內容
451
			#解碼後的內容
452
			$oriConfig[]=$enCodeStr["content"];
452
			$oriConfig[]=$enCodeStr["content"];
453
		
453
 
454
			}#foreach end
454
			}#foreach end
455
		
455
 
456
		#針對每個要新增的排程
456
		#針對每個要新增的排程
457
		foreach($conf["actions"] as $index => $action){
457
		foreach($conf["actions"] as $index => $action){
458
		
458
 
459
			#針對每個既有的排程
459
			#針對每個既有的排程
460
			foreach($oriConfig as $indexFor_oriConfig => $oCfg){
460
			foreach($oriConfig as $indexFor_oriConfig => $oCfg){
461
			
461
 
462
				#針對既有排程的uuid
462
				#針對既有排程的uuid
463
				$ouuid=$oCfg->uuid;
463
				$ouuid=$oCfg->uuid;
464
			
464
 
465
				#函式說明:
465
				#函式說明:
466
				#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
466
				#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
467
				#回傳結果:
467
				#回傳結果:
468
				#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
468
				#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
469
				#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
469
				#$result["founded"],"true"表示有找到相同的,"false"表示沒有找到相同的.
Line 483... Line 483...
483
				#無.
483
				#無.
484
				#備註:
484
				#備註:
485
				#無.
485
				#無.
486
				$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
486
				$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
487
				unset($conf["search::getEqualVar"]);
487
				unset($conf["search::getEqualVar"]);
488
			
488
 
489
				#如果執行失敗
489
				#如果執行失敗
490
				if($getEqualVar["status"]==="false"){
490
				if($getEqualVar["status"]==="false"){
491
					
491
 
492
					#設置錯誤識別
492
					#設置錯誤識別
493
					$result["status"]="false";
493
					$result["status"]="false";
494
					
494
 
495
					#設置錯誤訊息
495
					#設置錯誤訊息
496
					$result["error"]=$getEqualVar;
496
					$result["error"]=$getEqualVar;
497
					
497
 
498
					#回傳結果
498
					#回傳結果
499
					return $result;	
499
					return $result;
500
					
500
 
501
					}#if end
501
					}#if end
502
					
502
 
503
				#如果有找到相同uuid
503
				#如果有找到相同uuid
504
				if($getEqualVar["founded"]==="true"){
504
				if($getEqualVar["founded"]==="true"){
505
					
505
 
506
					#移除舊排程
506
					#移除舊排程
507
					unset($oriConfig[$indexFor_oriConfig]);
507
					unset($oriConfig[$indexFor_oriConfig]);
508
					
508
 
509
					#換看下個新排程的uuid
509
					#換看下個新排程的uuid
510
					break;
510
					break;
511
					
511
 
512
					}#if end
512
					}#if end
513
			
513
 
514
				}#foreach end
514
				}#foreach end
515
		
515
 
516
			}#foreach end
516
			}#foreach end
517
		
517
 
518
		#初始化儲存未加密的排程資訊
518
		#初始化儲存未加密的排程資訊
519
		$rawScheduleInfo=$oriConfig;
519
		$rawScheduleInfo=$oriConfig;
520
		
520
 
521
		#將剩下的每個舊排程
521
		#將剩下的每個舊排程
522
		foreach($oriConfig as $index => $config){
522
		foreach($oriConfig as $index => $config){
523
		
523
 
524
			#加密內容
524
			#加密內容
525
			#函式說明:
525
			#函式說明:
526
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
526
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
527
			#回傳結果:
527
			#回傳結果:
528
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
528
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
529
			#$result["function"],當前執行的函數名稱.
529
			#$result["function"],當前執行的函數名稱.
530
			#$result["content"],加密後的結果.
530
			#$result["content"],加密後的結果.
531
			#$result["error"],錯誤訊息陣列.
531
			#$result["error"],錯誤訊息陣列.
532
			#$result["argu"],使用的參數.
532
			#$result["argu"],使用的參數.
533
			#必填參數:
533
			#必填參數:
Line 554... Line 554...
554
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
554
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
555
			#備註:
555
			#備註:
556
			#無.
556
			#無.
557
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
557
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
558
			unset($conf["authenticate::enCodeStr"]);
558
			unset($conf["authenticate::enCodeStr"]);
559
		
559
 
560
			#如果執行失敗
560
			#如果執行失敗
561
			if($enCodeStr["status"]==="false"){
561
			if($enCodeStr["status"]==="false"){
562
				
562
 
563
				#設置錯誤識別
563
				#設置錯誤識別
564
				$result["status"]="false";
564
				$result["status"]="false";
565
				
565
 
566
				#設置錯誤訊息
566
				#設置錯誤訊息
567
				$result["error"]=$enCodeStr;
567
				$result["error"]=$enCodeStr;
568
				
568
 
569
				#回傳結果
569
				#回傳結果
570
				return $result;	
570
				return $result;
571
				
571
 
572
				}#if end
572
				}#if end
573
		
573
 
574
			#取得加密後的內容
574
			#取得加密後的內容
575
			$newConfig[]=$enCodeStr["content"];
575
			$newConfig[]=$enCodeStr["content"];
576
		
576
 
577
			}#foreach end
577
			}#foreach end
578
		
578
 
579
		#針對每個要新增的排程
579
		#針對每個要新增的排程
580
		foreach($conf["actions"] as $index => $action){
580
		foreach($conf["actions"] as $index => $action){
581
				
581
 
582
			#取得該uuid
582
			#取得該uuid
583
			$uuid=$conf["uuids"][$index];
583
			$uuid=$conf["uuids"][$index];
584
			
584
 
585
			#取得該time
585
			#取得該time
586
			$time=$conf["times"][$index];
586
			$time=$conf["times"][$index];
587
			
587
 
588
			#函式說明:
588
			#函式說明:
589
			#計算時間點距離1970/01/01多少秒,亦即unixtime.
589
			#計算時間點距離1970/01/01多少秒,亦即unixtime.
590
			#回傳結果:
590
			#回傳結果:
591
			#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
591
			#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
592
			#$result["error"],錯誤訊息陣列.
592
			#$result["error"],錯誤訊息陣列.
Line 606... Line 606...
606
			#無.
606
			#無.
607
			#備註:
607
			#備註:
608
			#無.
608
			#無.
609
			$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
609
			$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
610
			unset($conf["time::caculateTimeAmount"]);
610
			unset($conf["time::caculateTimeAmount"]);
611
			
611
 
612
			#如果執行失敗
612
			#如果執行失敗
613
			if($caculateTimeAmount["status"]==="false"){
613
			if($caculateTimeAmount["status"]==="false"){
614
				
614
 
615
				#設置錯誤識別
615
				#設置錯誤識別
616
				$result["status"]="false";
616
				$result["status"]="false";
617
				
617
 
618
				#設置錯誤訊息
618
				#設置錯誤訊息
619
				$result["error"]=$caculateTimeAmount;
619
				$result["error"]=$caculateTimeAmount;
620
				
620
 
621
				#回傳結果
621
				#回傳結果
622
				return $result;	
622
				return $result;
623
				
623
 
624
				}#if end
624
				}#if end
625
			
625
 
626
			#轉換成unixtime
626
			#轉換成unixtime
627
			$time=$caculateTimeAmount["content"];
627
			$time=$caculateTimeAmount["content"];
628
			
628
 
629
			#取得新增/覆蓋排程設定時的unixtime
629
			#取得新增/覆蓋排程設定時的unixtime
630
			$lastUpdateUnixTime=$time;
630
			$lastUpdateUnixTime=$time;
631
			
631
 
632
			#取代該repeat
632
			#取代該repeat
633
			$repeat=$conf["repeat"][$index];
633
			$repeat=$conf["repeat"][$index];
634
			
634
 
635
			#如果有指定固定時間執行
635
			#如果有指定固定時間執行
636
			if(isset($repeat["fixed"])){
636
			if(isset($repeat["fixed"])){
637
			
637
 
638
				#函式說明:
638
				#函式說明:
639
				#計算時間點距離1970/01/01多少秒,亦即unixtime.
639
				#計算時間點距離1970/01/01多少秒,亦即unixtime.
640
				#回傳結果:
640
				#回傳結果:
641
				#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
641
				#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
642
				#$result["error"],錯誤訊息陣列.
642
				#$result["error"],錯誤訊息陣列.
Line 655... Line 655...
655
				#無.
655
				#無.
656
				#備註:
656
				#備註:
657
				#無.
657
				#無.
658
				$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
658
				$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
659
				unset($conf["time::caculateTimeAmount"]);
659
				unset($conf["time::caculateTimeAmount"]);
660
				
660
 
661
				#如果執行失敗
661
				#如果執行失敗
662
				if($caculateTimeAmount["status"]==="false"){
662
				if($caculateTimeAmount["status"]==="false"){
663
					
663
 
664
					#設置錯誤識別
664
					#設置錯誤識別
665
					$result["status"]="false";
665
					$result["status"]="false";
666
					
666
 
667
					#設置錯誤訊息
667
					#設置錯誤訊息
668
					$result["error"]=$caculateTimeAmount;
668
					$result["error"]=$caculateTimeAmount;
669
					
669
 
670
					#回傳結果
670
					#回傳結果
671
					return $result;	
671
					return $result;
672
					
672
 
673
					}#if end
673
					}#if end
674
			
674
 
675
				#更新時間為unixtime
675
				#更新時間為unixtime
676
				$repeat["fixed"]=$caculateTimeAmount["content"];
676
				$repeat["fixed"]=$caculateTimeAmount["content"];
677
				
677
 
678
				}#if end
678
				}#if end
679
						
679
 
680
			#要加密的排程資訊,uuid(排程的識別碼),time(預計要執行的時間),repeat(重複的方式),update(新增/覆蓋排程設定時的unixtime)
680
			#要加密的排程資訊,uuid(排程的識別碼),time(預計要執行的時間),repeat(重複的方式),update(新增/覆蓋排程設定時的unixtime)
681
			$scheduleInfo=array("uuid"=>$uuid,"action"=>$action,"time"=>$time,"repeat"=>$repeat,"update"=>$time);
681
			$scheduleInfo=array("uuid"=>$uuid,"action"=>$action,"time"=>$time,"repeat"=>$repeat,"update"=>$time);
682
			
682
 
683
			#儲存未加密的排程資訊
683
			#儲存未加密的排程資訊
684
			$rawScheduleInfo[]=$scheduleInfo;
684
			$rawScheduleInfo[]=$scheduleInfo;
685
			
685
 
686
			#加密內容
686
			#加密內容
687
			#函式說明:
687
			#函式說明:
688
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
688
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
689
			#回傳結果:
689
			#回傳結果:
690
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
690
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
691
			#$result["function"],當前執行的函數名稱.
691
			#$result["function"],當前執行的函數名稱.
692
			#$result["content"],加密後的結果.
692
			#$result["content"],加密後的結果.
693
			#$result["error"],錯誤訊息陣列.
693
			#$result["error"],錯誤訊息陣列.
694
			#$result["argu"],使用的參數.
694
			#$result["argu"],使用的參數.
695
			#必填參數:
695
			#必填參數:
Line 716... Line 716...
716
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
716
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
717
			#備註:
717
			#備註:
718
			#無.
718
			#無.
719
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
719
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
720
			unset($conf["authenticate::enCodeStr"]);
720
			unset($conf["authenticate::enCodeStr"]);
721
		
721
 
722
			#如果執行失敗
722
			#如果執行失敗
723
			if($enCodeStr["status"]==="false"){
723
			if($enCodeStr["status"]==="false"){
724
				
724
 
725
				#設置錯誤識別
725
				#設置錯誤識別
726
				$result["status"]="false";
726
				$result["status"]="false";
727
				
727
 
728
				#設置錯誤訊息
728
				#設置錯誤訊息
729
				$result["error"]=$enCodeStr;
729
				$result["error"]=$enCodeStr;
730
				
730
 
731
				#回傳結果
731
				#回傳結果
732
				return $result;	
732
				return $result;
733
				
733
 
734
				}#if end
734
				}#if end
735
			
735
 
736
			#取得加密後的內容
736
			#取得加密後的內容
737
			$newConfig[]=$enCodeStr["content"];
737
			$newConfig[]=$enCodeStr["content"];
738
				
738
 
739
			}#foreach end
739
			}#foreach end
740
		
740
 
741
		#更新排程設定檔 
741
		#更新排程設定檔
742
		#函式說明:
742
		#函式說明:
743
		#將多行字串寫入到檔案
743
		#將多行字串寫入到檔案
744
		#回傳結果:
744
		#回傳結果:
745
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
745
		#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
746
		#$result["error"],錯誤訊息陣列.
746
		#$result["error"],錯誤訊息陣列.
Line 759... Line 759...
759
		#無.
759
		#無.
760
		#備註:
760
		#備註:
761
		#無.
761
		#無.
762
		$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
762
		$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
763
		unset($conf["fileAccess::writeMultiLine"]);
763
		unset($conf["fileAccess::writeMultiLine"]);
764
		
764
 
765
		#如果執行失敗
765
		#如果執行失敗
766
		if($writeMultiLine["status"]=="false"){
766
		if($writeMultiLine["status"]=="false"){
767
			
767
 
768
			#設置錯誤識別
768
			#設置錯誤識別
769
			$result["status"]="false";
769
			$result["status"]="false";
770
			
770
 
771
			#設置錯誤訊息
771
			#設置錯誤訊息
772
			$result["error"]=$writeMultiLine;
772
			$result["error"]=$writeMultiLine;
773
			
773
 
774
			#回傳結果
774
			#回傳結果
775
			return $result;
775
			return $result;
776
			
776
 
777
			}#if end
777
			}#if end
778
		
778
 
779
		#設置當前排程結果資訊
779
		#設置當前排程結果資訊
780
		$result["content"]=$rawScheduleInfo;
780
		$result["content"]=$rawScheduleInfo;
781
			
781
 
782
		#設置執行正常
782
		#設置執行正常
783
		$result["status"]="true";
783
		$result["status"]="true";
784
	
784
 
785
		return $result;
785
		return $result;
786
	
786
 
787
		}#function createList end
787
		}#function createList end
788
	
788
 
789
	/*
789
	/*
790
	#函式說明:
790
	#函式說明:
791
	#查詢系統上有哪些要自動執行的工作
791
	#查詢系統上有哪些要自動執行的工作
792
	#回傳結果:
792
	#回傳結果:
793
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
793
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
Line 806... Line 806...
806
	#無.
806
	#無.
807
	#備註:
807
	#備註:
808
	#無.
808
	#無.
809
	*/
809
	*/
810
	public static function getList(&$conf){
810
	public static function getList(&$conf){
811
	
811
 
812
		#初始化要回傳的變數
812
		#初始化要回傳的變數
813
		$result=array();
813
		$result=array();
814
 
814
 
815
		#初始化當前執行的函數名稱
815
		#初始化當前執行的函數名稱
816
		$result["function"]=__FUNCTION__;
816
		$result["function"]=__FUNCTION__;
817
 
817
 
818
		#如果 $conf 不為陣列
818
		#如果 $conf 不為陣列
819
		if(gettype($conf)!="array"){
819
		if(gettype($conf)!="array"){
820
			
820
 
821
			#設置執行失敗
821
			#設置執行失敗
822
			$result["status"]="false";
822
			$result["status"]="false";
823
			
823
 
824
			#設置執行錯誤訊息
824
			#設置執行錯誤訊息
825
			$result["error"][]="\$conf變數須為陣列形態";
825
			$result["error"][]="\$conf變數須為陣列形態";
826
 
826
 
827
			#如果傳入的參數為 null
827
			#如果傳入的參數為 null
828
			if($conf==null){
828
			if($conf==null){
829
				
829
 
830
				#設置執行錯誤訊息
830
				#設置執行錯誤訊息
831
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
831
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
832
				
832
 
833
				}#if end
833
				}#if end
834
 
834
 
835
			#回傳結果
835
			#回傳結果
836
			return $result;
836
			return $result;
837
			
837
 
838
			}#if end
838
			}#if end
839
	
839
 
840
		#取得使用的參數
840
		#取得使用的參數
841
		$result["argu"]=$conf;
841
		$result["argu"]=$conf;
842
 
842
 
843
		#檢查參數
843
		#檢查參數
844
		#函式說明:
844
		#函式說明:
Line 856... Line 856...
856
		#必填寫的參數:
856
		#必填寫的參數:
857
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
857
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
858
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
858
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
859
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
859
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
860
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
860
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
861
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
861
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
862
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
862
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
863
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
863
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
864
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
864
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
865
		#可以省略的參數:
865
		#可以省略的參數:
866
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
866
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
867
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
867
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
868
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
868
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
869
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("config");
869
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("config");
870
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
870
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
871
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
871
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
872
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
872
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
873
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("/usr/local/etc/qbpwcf-schedule.conf.php");
873
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("/usr/local/etc/qbpwcf-schedule.conf.php");
874
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
874
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
875
		#$conf["arrayCountEqualCheck"][]=array();
875
		#$conf["arrayCountEqualCheck"][]=array();
Line 878... Line 878...
878
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
878
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
879
		unset($conf["variableCheck::checkArguments"]);
879
		unset($conf["variableCheck::checkArguments"]);
880
 
880
 
881
		#如果 $checkArguments["status"] 等於 "false"
881
		#如果 $checkArguments["status"] 等於 "false"
882
		if($checkArguments["status"]=="false"){
882
		if($checkArguments["status"]=="false"){
883
			
883
 
884
			#設置錯誤識別
884
			#設置錯誤識別
885
			$result["status"]="false";
885
			$result["status"]="false";
886
			
886
 
887
			#設置錯誤訊息
887
			#設置錯誤訊息
888
			$result["error"]=$checkArguments;
888
			$result["error"]=$checkArguments;
889
			
889
 
890
			#回傳結果
890
			#回傳結果
891
			return $result;
891
			return $result;
892
			
892
 
893
			}#if end
893
			}#if end
894
			
894
 
895
		#如果 $checkArguments["passed"] 等於 "false"
895
		#如果 $checkArguments["passed"] 等於 "false"
896
		if($checkArguments["passed"]=="false"){
896
		if($checkArguments["passed"]=="false"){
897
			
897
 
898
			#設置錯誤識別
898
			#設置錯誤識別
899
			$result["status"]="false";
899
			$result["status"]="false";
900
			
900
 
901
			#設置錯誤訊息
901
			#設置錯誤訊息
902
			$result["error"]=$checkArguments;
902
			$result["error"]=$checkArguments;
903
			
903
 
904
			#回傳結果
904
			#回傳結果
905
			return $result;
905
			return $result;
906
			
906
 
907
			}#if end
907
			}#if end
908
				
908
 
909
		#函式說明:
909
		#函式說明:
910
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
910
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
911
		#回傳的變數說明:
911
		#回傳的變數說明:
912
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
912
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
913
		#$result["error"],錯誤訊息提示.
913
		#$result["error"],錯誤訊息提示.
Line 933... Line 933...
933
		#file=>http:#php.net/manual/en/function.file.php
933
		#file=>http:#php.net/manual/en/function.file.php
934
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
934
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
935
		#filesize=>http://php.net/manual/en/function.filesize.php
935
		#filesize=>http://php.net/manual/en/function.filesize.php
936
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
936
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
937
		unset($conf["fileAccess::getFileContent"]);
937
		unset($conf["fileAccess::getFileContent"]);
938
		
938
 
939
		#如果取得檔案失敗
939
		#如果取得檔案失敗
940
		if($getFileContent["status"]==="false"){
940
		if($getFileContent["status"]==="false"){
941
		
941
 
942
			#設置錯誤識別
942
			#設置錯誤識別
943
			$result["status"]="false";
943
			$result["status"]="false";
944
			
944
 
945
			#設置錯誤訊息
945
			#設置錯誤訊息
946
			$result["error"]=$getFileContent;
946
			$result["error"]=$getFileContent;
947
			
947
 
948
			#回傳結果
948
			#回傳結果
949
			return $result;	
949
			return $result;
950
		
950
 
951
			}#if end
951
			}#if end
952
			
952
 
953
		#解析檔案內容
953
		#解析檔案內容
954
		
954
 
955
		#針對每行內容
955
		#針對每行內容
956
		foreach($getFileContent["fileContent"] as $line){
956
		foreach($getFileContent["fileContent"] as $line){
957
		
957
 
958
			#加密內容
958
			#加密內容
959
			#函式說明:
959
			#函式說明:
960
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
960
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
961
			#回傳結果:
961
			#回傳結果:
962
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
962
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
963
			#$result["function"],當前執行的函數名稱.
963
			#$result["function"],當前執行的函數名稱.
964
			#$result["content"],加密後的結果.
964
			#$result["content"],加密後的結果.
965
			#$result["error"],錯誤訊息陣列.
965
			#$result["error"],錯誤訊息陣列.
966
			#$result["argu"],使用的參數.
966
			#$result["argu"],使用的參數.
967
			#必填參數:
967
			#必填參數:
Line 988... Line 988...
988
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
988
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
989
			#備註:
989
			#備註:
990
			#無.
990
			#無.
991
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
991
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
992
			unset($conf["authenticate::enCodeStr"]);
992
			unset($conf["authenticate::enCodeStr"]);
993
		
993
 
994
			#如果執行失敗失敗
994
			#如果執行失敗失敗
995
			if($enCodeStr["status"]==="false"){
995
			if($enCodeStr["status"]==="false"){
996
			
996
 
997
				#設置錯誤識別
997
				#設置錯誤識別
998
				$result["status"]="false";
998
				$result["status"]="false";
999
				
999
 
1000
				#設置錯誤訊息
1000
				#設置錯誤訊息
1001
				$result["error"]=$enCodeStr;
1001
				$result["error"]=$enCodeStr;
1002
				
1002
 
1003
				#回傳結果
1003
				#回傳結果
1004
				return $result;	
1004
				return $result;
1005
			
1005
 
1006
				}#if end
1006
				}#if end
1007
		
1007
 
1008
			#取得解密後的內容
1008
			#取得解密後的內容
1009
			$line=$enCodeStr["content"];
1009
			$line=$enCodeStr["content"];
1010
			
1010
 
1011
			#debug
1011
			#debug
1012
			#var_dump($line);
1012
			#var_dump($line);
1013
			
1013
 
1014
			#如果內容沒有 uuid
1014
			#如果內容沒有 uuid
1015
			if(!isset($line->uuid)){
1015
			if(!isset($line->uuid)){
1016
			
1016
 
1017
				#忽略該行
1017
				#忽略該行
1018
				continue;
1018
				continue;
1019
			
1019
 
1020
				}#if end
1020
				}#if end
1021
				
1021
 
1022
			#取得排程的uuid
1022
			#取得排程的uuid
1023
			$actionUuid=&$line->uuid;	
1023
			$actionUuid=&$line->uuid;
1024
		
1024
 
1025
			#如果內容沒有 time ,亦即排程設定的(預期/已)執行時間
1025
			#如果內容沒有 time ,亦即排程設定的(預期/已)執行時間
1026
			if(!isset($line->time)){
1026
			if(!isset($line->time)){
1027
			
1027
 
1028
				#忽略該行
1028
				#忽略該行
1029
				continue;
1029
				continue;
1030
			
1030
 
1031
				}#if end
1031
				}#if end
1032
				
1032
 
1033
			#取得排程的時間
1033
			#取得排程的時間
1034
			$actionUnixTime=&$line->time;	
1034
			$actionUnixTime=&$line->time;
1035
				
1035
 
1036
			#如果內容沒有 action ,亦即排程設定的指令與參數.
1036
			#如果內容沒有 action ,亦即排程設定的指令與參數.
1037
			if(!isset($line->action)){
1037
			if(!isset($line->action)){
1038
			
1038
 
1039
				#忽略該行
1039
				#忽略該行
1040
				continue;
1040
				continue;
1041
			
1041
 
1042
				}#if end
1042
				}#if end
1043
				
1043
 
1044
			#取得排程要做的事情資訊
1044
			#取得排程要做的事情資訊
1045
			$actionInfo=&$line->action;
1045
			$actionInfo=&$line->action;
1046
				
1046
 
1047
			#如果內容沒有 repeat ,亦即排程設定的執行模式.
1047
			#如果內容沒有 repeat ,亦即排程設定的執行模式.
1048
			if(!isset($line->repeat)){
1048
			if(!isset($line->repeat)){
1049
			
1049
 
1050
				#忽略該行
1050
				#忽略該行
1051
				continue;
1051
				continue;
1052
			
1052
 
1053
				}#if end
1053
				}#if end
1054
			
1054
 
1055
			#反之若不是無窮執行
1055
			#反之若不是無窮執行
1056
			else if($line->repeat!=="-1"){
1056
			else if($line->repeat!=="-1"){
1057
			
1057
 
1058
				#如果內容有 repeat->times ,亦即排程設定的剩下重複次數.
1058
				#如果內容有 repeat->times ,亦即排程設定的剩下重複次數.
1059
				if(isset($line->repeat->times)){
1059
				if(isset($line->repeat->times)){
1060
			
1060
 
1061
					#取得剩下的重複執行次數
1061
					#取得剩下的重複執行次數
1062
					$leftRepeatTimes=&$line->repeat->times;
1062
					$leftRepeatTimes=&$line->repeat->times;
1063
				
1063
 
1064
					}#if end
1064
					}#if end
1065
			
1065
 
1066
				#反之如果內容沒有 repeat->after(亦即排程設定的重複條件為time的之後多久) 跟 repeat->time->fixed(亦即排程設定的重複條件為用update mask過後的指定時間). 
1066
				#反之如果內容沒有 repeat->after(亦即排程設定的重複條件為time的之後多久) 跟 repeat->time->fixed(亦即排程設定的重複條件為用update mask過後的指定時間).
1067
				else if( !isset($line->repeat->after) && !isset($line->repeat->fixed) ){
1067
				else if( !isset($line->repeat->after) && !isset($line->repeat->fixed) ){
1068
			
1068
 
1069
					#忽略該行
1069
					#忽略該行
1070
					continue;
1070
					continue;
1071
			
1071
 
1072
					}#else end
1072
					}#else end
1073
				
1073
 
1074
				}#if end
1074
				}#if end
1075
				
1075
 
1076
			#如果內容沒有 update,亦即排程設定最後更新的時間
1076
			#如果內容沒有 update,亦即排程設定最後更新的時間
1077
			if(!isset($line->update)){
1077
			if(!isset($line->update)){
1078
			
1078
 
1079
				#忽略該行
1079
				#忽略該行
1080
				continue;
1080
				continue;
1081
			
1081
 
1082
				}#if end
1082
				}#if end
1083
			
1083
 
1084
			#初始化要執行的事情資訊
1084
			#初始化要執行的事情資訊
1085
			$jobInfo=array();
1085
			$jobInfo=array();
1086
			
1086
 
1087
			#設置其uuid
1087
			#設置其uuid
1088
			$jobInfo["uuid"]=$actionUuid;
1088
			$jobInfo["uuid"]=$actionUuid;
1089
			
1089
 
1090
			#設置其指令與參數
1090
			#設置其指令與參數
1091
			$jobInfo["cmd&argu"]=$actionInfo;
1091
			$jobInfo["cmd&argu"]=$actionInfo;
1092
			
1092
 
1093
			#設置其預期執行的unixtime
1093
			#設置其預期執行的unixtime
1094
			$jobInfo["time"]=$actionUnixTime;
1094
			$jobInfo["time"]=$actionUnixTime;
1095
		
1095
 
1096
			#設置其重複規則
1096
			#設置其重複規則
1097
			$jobInfo["repeat"]=$line->repeat;
1097
			$jobInfo["repeat"]=$line->repeat;
1098
		
1098
 
1099
			#儲存工作資訊
1099
			#儲存工作資訊
1100
			$result["content"][]=$jobInfo;
1100
			$result["content"][]=$jobInfo;
1101
		
1101
 
1102
			}#foreach end
1102
			}#foreach end
1103
		
1103
 
1104
		#設置執行正常
1104
		#設置執行正常
1105
		$result["status"]="true";
1105
		$result["status"]="true";
1106
		
1106
 
1107
		#回傳結果
1107
		#回傳結果
1108
		return $result;
1108
		return $result;
1109
	
1109
 
1110
		}#function getList end
1110
		}#function getList end
1111
	
1111
 
1112
	/*
1112
	/*
1113
	#函式說明:
1113
	#函式說明:
1114
	#查詢系統上有哪些於當下要自動執行的工作
1114
	#查詢系統上有哪些於當下要自動執行的工作
1115
	#回傳結果:
1115
	#回傳結果:
1116
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
1116
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
Line 1130... Line 1130...
1130
	#無.
1130
	#無.
1131
	#備註:
1131
	#備註:
1132
	#無.
1132
	#無.
1133
	*/
1133
	*/
1134
	public static function checkList(&$conf){
1134
	public static function checkList(&$conf){
1135
		
1135
 
1136
		#初始化要回傳的變數
1136
		#初始化要回傳的變數
1137
		$result=array();
1137
		$result=array();
1138
 
1138
 
1139
		#初始化當前執行的函數名稱
1139
		#初始化當前執行的函數名稱
1140
		$result["function"]=__FUNCTION__;
1140
		$result["function"]=__FUNCTION__;
1141
 
1141
 
1142
		#如果 $conf 不為陣列
1142
		#如果 $conf 不為陣列
1143
		if(gettype($conf)!="array"){
1143
		if(gettype($conf)!="array"){
1144
			
1144
 
1145
			#設置執行失敗
1145
			#設置執行失敗
1146
			$result["status"]="false";
1146
			$result["status"]="false";
1147
			
1147
 
1148
			#設置執行錯誤訊息
1148
			#設置執行錯誤訊息
1149
			$result["error"][]="\$conf變數須為陣列形態";
1149
			$result["error"][]="\$conf變數須為陣列形態";
1150
 
1150
 
1151
			#如果傳入的參數為 null
1151
			#如果傳入的參數為 null
1152
			if($conf==null){
1152
			if($conf==null){
1153
				
1153
 
1154
				#設置執行錯誤訊息
1154
				#設置執行錯誤訊息
1155
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1155
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1156
				
1156
 
1157
				}#if end
1157
				}#if end
1158
 
1158
 
1159
			#回傳結果
1159
			#回傳結果
1160
			return $result;
1160
			return $result;
1161
			
1161
 
1162
			}#if end
1162
			}#if end
1163
	
1163
 
1164
		#取得使用的參數
1164
		#取得使用的參數
1165
		$result["argu"]=$conf;
1165
		$result["argu"]=$conf;
1166
 
1166
 
1167
		#檢查參數
1167
		#檢查參數
1168
		#函式說明:
1168
		#函式說明:
Line 1180... Line 1180...
1180
		#必填寫的參數:
1180
		#必填寫的參數:
1181
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
1181
		#$conf["variableCheck::checkArguments"]["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
1182
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
1182
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
1183
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
1183
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
1184
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
1184
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu");
1185
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double"); 
1185
		#$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列 例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double");
1186
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
1186
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string");
1187
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
1187
		#$conf["variableCheck::checkArguments"]["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
1188
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
1188
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
1189
		#可以省略的參數:
1189
		#可以省略的參數:
1190
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
1190
		#$conf["variableCheck::checkArguments"]["canBeEmptyString"],必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true"。
1191
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1191
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
1192
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1192
		#$conf["variableCheck::checkArguments"]["skipableVariableName"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
1193
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("config");
1193
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("config");
1194
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
1194
		#$conf["variableCheck::checkArguments"]["skipableVariableType"],爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
1195
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
1195
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string");
1196
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1196
		#$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是必填參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
1197
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("/usr/local/etc/qbpwcf-schedule.conf.php");
1197
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array("/usr/local/etc/qbpwcf-schedule.conf.php");
1198
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1198
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
1199
		#$conf["arrayCountEqualCheck"][]=array();
1199
		#$conf["arrayCountEqualCheck"][]=array();
Line 1202... Line 1202...
1202
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1202
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1203
		unset($conf["variableCheck::checkArguments"]);
1203
		unset($conf["variableCheck::checkArguments"]);
1204
 
1204
 
1205
		#如果 $checkArguments["status"] 等於 "false"
1205
		#如果 $checkArguments["status"] 等於 "false"
1206
		if($checkArguments["status"]=="false"){
1206
		if($checkArguments["status"]=="false"){
1207
			
1207
 
1208
			#設置錯誤識別
1208
			#設置錯誤識別
1209
			$result["status"]="false";
1209
			$result["status"]="false";
1210
			
1210
 
1211
			#設置錯誤訊息
1211
			#設置錯誤訊息
1212
			$result["error"]=$checkArguments;
1212
			$result["error"]=$checkArguments;
1213
			
1213
 
1214
			#回傳結果
1214
			#回傳結果
1215
			return $result;				
1215
			return $result;
1216
			
1216
 
1217
			}#if end
1217
			}#if end
1218
			
1218
 
1219
		#如果 $checkArguments["passed"] 等於 "false"
1219
		#如果 $checkArguments["passed"] 等於 "false"
1220
		if($checkArguments["passed"]=="false"){
1220
		if($checkArguments["passed"]=="false"){
1221
			
1221
 
1222
			#設置錯誤識別
1222
			#設置錯誤識別
1223
			$result["status"]="false";
1223
			$result["status"]="false";
1224
			
1224
 
1225
			#設置錯誤訊息
1225
			#設置錯誤訊息
1226
			$result["error"]=$checkArguments;
1226
			$result["error"]=$checkArguments;
1227
			
1227
 
1228
			#回傳結果
1228
			#回傳結果
1229
			return $result;				
1229
			return $result;
1230
			
1230
 
1231
			}#if end
1231
			}#if end
1232
				
1232
 
1233
		#函式說明:
1233
		#函式說明:
1234
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
1234
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
1235
		#回傳的變數說明:
1235
		#回傳的變數說明:
1236
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
1236
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
1237
		#$result["error"],錯誤訊息提示.
1237
		#$result["error"],錯誤訊息提示.
Line 1257... Line 1257...
1257
		#file=>http:#php.net/manual/en/function.file.php
1257
		#file=>http:#php.net/manual/en/function.file.php
1258
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
1258
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
1259
		#filesize=>http://php.net/manual/en/function.filesize.php
1259
		#filesize=>http://php.net/manual/en/function.filesize.php
1260
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
1260
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
1261
		unset($conf["fileAccess::getFileContent"]);
1261
		unset($conf["fileAccess::getFileContent"]);
1262
		
1262
 
1263
		#如果取得檔案失敗
1263
		#如果取得檔案失敗
1264
		if($getFileContent["status"]==="false"){
1264
		if($getFileContent["status"]==="false"){
1265
		
1265
 
1266
			#設置錯誤識別
1266
			#設置錯誤識別
1267
			$result["status"]="false";
1267
			$result["status"]="false";
1268
			
1268
 
1269
			#設置錯誤訊息
1269
			#設置錯誤訊息
1270
			$result["error"]=$getFileContent;
1270
			$result["error"]=$getFileContent;
1271
			
1271
 
1272
			#回傳結果
1272
			#回傳結果
1273
			return $result;	
1273
			return $result;
1274
		
1274
 
1275
			}#if end
1275
			}#if end
1276
			
1276
 
1277
		#解析檔案內容
1277
		#解析檔案內容
1278
		
1278
 
1279
		#針對每行內容
1279
		#針對每行內容
1280
		foreach($getFileContent["fileContent"] as $line){
1280
		foreach($getFileContent["fileContent"] as $line){
1281
		
1281
 
1282
			#加密內容
1282
			#加密內容
1283
			#函式說明:
1283
			#函式說明:
1284
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
1284
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
1285
			#回傳結果:
1285
			#回傳結果:
1286
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
1286
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1287
			#$result["function"],當前執行的函數名稱.
1287
			#$result["function"],當前執行的函數名稱.
1288
			#$result["content"],加密後的結果.
1288
			#$result["content"],加密後的結果.
1289
			#$result["error"],錯誤訊息陣列.
1289
			#$result["error"],錯誤訊息陣列.
1290
			#$result["argu"],使用的參數.
1290
			#$result["argu"],使用的參數.
1291
			#必填參數:
1291
			#必填參數:
Line 1312... Line 1312...
1312
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
1312
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
1313
			#備註:
1313
			#備註:
1314
			#無.
1314
			#無.
1315
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
1315
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
1316
			unset($conf["authenticate::enCodeStr"]);
1316
			unset($conf["authenticate::enCodeStr"]);
1317
		
1317
 
1318
			#如果執行失敗失敗
1318
			#如果執行失敗失敗
1319
			if($enCodeStr["status"]==="false"){
1319
			if($enCodeStr["status"]==="false"){
1320
			
1320
 
1321
				#設置錯誤識別
1321
				#設置錯誤識別
1322
				$result["status"]="false";
1322
				$result["status"]="false";
1323
				
1323
 
1324
				#設置錯誤訊息
1324
				#設置錯誤訊息
1325
				$result["error"]=$enCodeStr;
1325
				$result["error"]=$enCodeStr;
1326
				
1326
 
1327
				#回傳結果
1327
				#回傳結果
1328
				return $result;	
1328
				return $result;
1329
			
1329
 
1330
				}#if end
1330
				}#if end
1331
		
1331
 
1332
			#取得解密後的內容
1332
			#取得解密後的內容
1333
			$line=$enCodeStr["content"];
1333
			$line=$enCodeStr["content"];
1334
					
1334
 
1335
			#如果內容沒有 uuid
1335
			#如果內容沒有 uuid
1336
			if(!isset($line->uuid)){
1336
			if(!isset($line->uuid)){
1337
			
1337
 
1338
				#忽略該行
1338
				#忽略該行
1339
				continue;
1339
				continue;
1340
			
1340
 
1341
				}#if end
1341
				}#if end
1342
				
1342
 
1343
			#取得排程的uuid
1343
			#取得排程的uuid
1344
			$actionUuid=&$line->uuid;	
1344
			$actionUuid=&$line->uuid;
1345
		
1345
 
1346
			#如果內容沒有 time ,亦即排程設定的(預期/已)執行時間
1346
			#如果內容沒有 time ,亦即排程設定的(預期/已)執行時間
1347
			if(!isset($line->time)){
1347
			if(!isset($line->time)){
1348
			
1348
 
1349
				#忽略該行
1349
				#忽略該行
1350
				continue;
1350
				continue;
1351
			
1351
 
1352
				}#if end
1352
				}#if end
1353
				
1353
 
1354
			#取得排程的時間
1354
			#取得排程的時間
1355
			$actionUnixTime=&$line->time;	
1355
			$actionUnixTime=&$line->time;
1356
				
1356
 
1357
			#如果內容沒有 action ,亦即排程設定的指令與參數.
1357
			#如果內容沒有 action ,亦即排程設定的指令與參數.
1358
			if(!isset($line->action)){
1358
			if(!isset($line->action)){
1359
			
1359
 
1360
				#忽略該行
1360
				#忽略該行
1361
				continue;
1361
				continue;
1362
			
1362
 
1363
				}#if end
1363
				}#if end
1364
				
1364
 
1365
			#取得排程要做的事情資訊
1365
			#取得排程要做的事情資訊
1366
			$actionInfo=&$line->action;
1366
			$actionInfo=&$line->action;
1367
				
1367
 
1368
			#如果內容沒有 repeat ,亦即排程設定的執行模式.
1368
			#如果內容沒有 repeat ,亦即排程設定的執行模式.
1369
			if(!isset($line->repeat)){
1369
			if(!isset($line->repeat)){
1370
			
1370
 
1371
				#忽略該行
1371
				#忽略該行
1372
				continue;
1372
				continue;
1373
			
1373
 
1374
				}#if end
1374
				}#if end
1375
			
1375
 
1376
			#反之若不是無窮執行
1376
			#反之若不是無窮執行
1377
			else if($line->repeat!=="-1"){
1377
			else if($line->repeat!=="-1"){
1378
			
1378
 
1379
				#如果內容有 repeat->times ,亦即排程設定的剩下重複次數.
1379
				#如果內容有 repeat->times ,亦即排程設定的剩下重複次數.
1380
				if(isset($line->repeat->times)){
1380
				if(isset($line->repeat->times)){
1381
			
1381
 
1382
					#取得剩下的重複執行次數
1382
					#取得剩下的重複執行次數
1383
					$leftRepeatTimes=&$line->repeat->times;
1383
					$leftRepeatTimes=&$line->repeat->times;
1384
				
1384
 
1385
					}#if end
1385
					}#if end
1386
			
1386
 
1387
				#反之如果內容沒有 repeat->after(亦即排程設定的重複條件為time的之後多久) 跟 repeat->time->fixed(亦即排程設定的重複條件為用update mask過後的指定時間). 
1387
				#反之如果內容沒有 repeat->after(亦即排程設定的重複條件為time的之後多久) 跟 repeat->time->fixed(亦即排程設定的重複條件為用update mask過後的指定時間).
1388
				else if( !isset($line->repeat->after) && !isset($line->repeat->fixed) ){
1388
				else if( !isset($line->repeat->after) && !isset($line->repeat->fixed) ){
1389
			
1389
 
1390
					#忽略該行
1390
					#忽略該行
1391
					continue;
1391
					continue;
1392
			
1392
 
1393
					}#else end
1393
					}#else end
1394
				
1394
 
1395
				}#if end
1395
				}#if end
1396
			
1396
 
1397
			#如果內容沒有 update,亦即排程設定最後更新的時間
1397
			#如果內容沒有 update,亦即排程設定最後更新的時間
1398
			if(!isset($line->update)){
1398
			if(!isset($line->update)){
1399
			
1399
 
1400
				#忽略該行
1400
				#忽略該行
1401
				continue;
1401
				continue;
1402
			
1402
 
1403
				}#if end
1403
				}#if end
1404
			
1404
 
1405
			#取得當下時間
1405
			#取得當下時間
1406
			$currenUnixTime=time::unix()["content"];
1406
			$currenUnixTime=time::unix()["content"];
1407
			
1407
 
1408
			#如果當前時間大於等於排程的時間
1408
			#如果當前時間大於等於排程的時間
1409
			if($currenUnixTime>=$actionUnixTime){
1409
			if($currenUnixTime>=$actionUnixTime){
1410
			
1410
 
1411
				#如果有抓到剩下的執行次數
1411
				#如果有抓到剩下的執行次數
1412
				if(isset($leftRepeatTimes)){
1412
				if(isset($leftRepeatTimes)){
1413
				
1413
 
1414
					#如果剩下的次數為0
1414
					#如果剩下的次數為0
1415
					if((int)$leftRepeatTimes===0){
1415
					if((int)$leftRepeatTimes===0){
1416
					
1416
 
1417
						#跳過不執行
1417
						#跳過不執行
1418
						continue;
1418
						continue;
1419
					
1419
 
1420
						}#if end
1420
						}#if end
1421
				
1421
 
1422
					}#if end
1422
					}#if end
1423
			
1423
 
1424
				#初始化要執行的事情資訊
1424
				#初始化要執行的事情資訊
1425
				$jobInfo=array();
1425
				$jobInfo=array();
1426
				
1426
 
1427
				#設置其uuid
1427
				#設置其uuid
1428
				$jobInfo["uuid"]=$actionUuid;
1428
				$jobInfo["uuid"]=$actionUuid;
1429
				
1429
 
1430
				#設置其指令與參數
1430
				#設置其指令與參數
1431
				$jobInfo["cmd&argu"]=$actionInfo;
1431
				$jobInfo["cmd&argu"]=$actionInfo;
1432
			
1432
 
1433
				#儲存工作資訊
1433
				#儲存工作資訊
1434
				$result["content"][]=$jobInfo;
1434
				$result["content"][]=$jobInfo;
1435
			
1435
 
1436
				}#if end
1436
				}#if end
1437
		
1437
 
1438
			}#foreach end
1438
			}#foreach end
1439
		
1439
 
1440
		#預設置沒有事情要執行
1440
		#預設置沒有事情要執行
1441
		$result["found"]="false";
1441
		$result["found"]="false";
1442
		
1442
 
1443
		#如果有要執行的事情
1443
		#如果有要執行的事情
1444
		if(isset($result["content"])){
1444
		if(isset($result["content"])){
1445
		
1445
 
1446
			#設置有事情要執行
1446
			#設置有事情要執行
1447
			$result["found"]="true";
1447
			$result["found"]="true";
1448
		
1448
 
1449
			}#if end
1449
			}#if end
1450
		
1450
 
1451
		#設置執行正常
1451
		#設置執行正常
1452
		$result["status"]="true";
1452
		$result["status"]="true";
1453
		
1453
 
1454
		#回傳結果
1454
		#回傳結果
1455
		return $result;
1455
		return $result;
1456
		
1456
 
1457
		}#function checkList end
1457
		}#function checkList end
1458
	
1458
 
1459
	/*
1459
	/*
1460
	#函式說明:
1460
	#函式說明:
1461
	#依照autoService::createList建立的設定檔案來執行排程事項,執行完畢後會更新排程設定檔案,並輸出執行結果.
1461
	#依照autoService::createList建立的設定檔案來執行排程事項,執行完畢後會更新排程設定檔案,並輸出執行結果.
1462
	#回傳結果:
1462
	#回傳結果:
1463
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
1463
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
Line 1487... Line 1487...
1487
	#無.
1487
	#無.
1488
	#備註:
1488
	#備註:
1489
	#無.
1489
	#無.
1490
	*/
1490
	*/
1491
	public static function runList(&$conf){
1491
	public static function runList(&$conf){
1492
	
1492
 
1493
		#初始化要回傳的變數
1493
		#初始化要回傳的變數
1494
		$result=array();
1494
		$result=array();
1495
 
1495
 
1496
		#初始化當前執行的函數名稱
1496
		#初始化當前執行的函數名稱
1497
		$result["function"]=__FUNCTION__;
1497
		$result["function"]=__FUNCTION__;
1498
 
1498
 
1499
		#如果 $conf 不為陣列
1499
		#如果 $conf 不為陣列
1500
		if(gettype($conf)!="array"){
1500
		if(gettype($conf)!="array"){
1501
			
1501
 
1502
			#設置執行失敗
1502
			#設置執行失敗
1503
			$result["status"]="false";
1503
			$result["status"]="false";
1504
			
1504
 
1505
			#設置執行錯誤訊息
1505
			#設置執行錯誤訊息
1506
			$result["error"][]="\$conf變數須為陣列形態";
1506
			$result["error"][]="\$conf變數須為陣列形態";
1507
 
1507
 
1508
			#如果傳入的參數為 null
1508
			#如果傳入的參數為 null
1509
			if($conf==null){
1509
			if($conf==null){
1510
				
1510
 
1511
				#設置執行錯誤訊息
1511
				#設置執行錯誤訊息
1512
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1512
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
1513
				
1513
 
1514
				}#if end
1514
				}#if end
1515
 
1515
 
1516
			#設置 cache result
1516
			#設置 cache result
1517
			$result["cache"]["result"]=&$result;
1517
			$result["cache"]["result"]=&$result;
1518
 
1518
 
1519
			#回傳結果
1519
			#回傳結果
1520
			return $result;
1520
			return $result;
1521
			
1521
 
1522
			}#if end
1522
			}#if end
1523
	
1523
 
1524
		#取得使用的參數
1524
		#取得使用的參數
1525
		$result["argu"]=$conf;
1525
		$result["argu"]=$conf;
1526
		
1526
 
1527
		#函式說明:
1527
		#函式說明:
1528
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
1528
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
1529
		#回傳結果:
1529
		#回傳結果:
1530
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1530
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
1531
		#$result["error"],執行不正常結束的錯訊息陣列.
1531
		#$result["error"],執行不正常結束的錯訊息陣列.
Line 1576... Line 1576...
1576
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1576
		#array_keys=>http://php.net/manual/en/function.array-keys.php
1577
		#備註:
1577
		#備註:
1578
		#無.
1578
		#無.
1579
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1579
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
1580
		unset($conf["variableCheck::checkArguments"]);
1580
		unset($conf["variableCheck::checkArguments"]);
1581
	
1581
 
1582
		#如果檢查出錯
1582
		#如果檢查出錯
1583
		if($checkArguments["status"]==="false"){
1583
		if($checkArguments["status"]==="false"){
1584
			
1584
 
1585
			#設置錯誤識別
1585
			#設置錯誤識別
1586
			$result["status"]="false";
1586
			$result["status"]="false";
1587
			
1587
 
1588
			#設置錯誤訊息
1588
			#設置錯誤訊息
1589
			$result["error"]=$checkArguments;
1589
			$result["error"]=$checkArguments;
1590
			
1590
 
1591
			#設置 cache result
1591
			#設置 cache result
1592
			$result["cache"]["result"]=&$result;
1592
			$result["cache"]["result"]=&$result;
1593
			
1593
 
1594
			#回傳結果
1594
			#回傳結果
1595
			return $result;
1595
			return $result;
1596
			
1596
 
1597
			}#if end
1597
			}#if end
1598
			
1598
 
1599
		#如果檢查不通過
1599
		#如果檢查不通過
1600
		if($checkArguments["passed"]==="false"){
1600
		if($checkArguments["passed"]==="false"){
1601
			
1601
 
1602
			#設置錯誤識別
1602
			#設置錯誤識別
1603
			$result["status"]="false";
1603
			$result["status"]="false";
1604
			
1604
 
1605
			#設置錯誤訊息
1605
			#設置錯誤訊息
1606
			$result["error"]=$checkArguments;
1606
			$result["error"]=$checkArguments;
1607
			
1607
 
1608
			#設置 cache result
1608
			#設置 cache result
1609
			$result["cache"]["result"]=&$result;
1609
			$result["cache"]["result"]=&$result;
1610
			
1610
 
1611
			#回傳結果
1611
			#回傳結果
1612
			return $result;
1612
			return $result;
1613
			
1613
 
1614
			}#if end
1614
			}#if end
1615
		
1615
 
1616
		#debug
1616
		#debug
1617
		#var_dump(__LINE__,$conf["log"]);
1617
		#var_dump(__LINE__,$conf["log"]);
1618
		
1618
 
1619
		#初始化預設要回傳的cache
1619
		#初始化預設要回傳的cache
1620
		$result["cache"]=array();
1620
		$result["cache"]=array();
1621
		
1621
 
1622
		#若有暫存資料要處理
1622
		#若有暫存資料要處理
1623
		if(isset($conf["serverCache"])){
1623
		if(isset($conf["serverCache"])){
1624
		
1624
 
1625
			/*
1625
			/*
1626
		
1626
 
1627
			#如果要寫log
1627
			#如果要寫log
1628
			if(isset($conf["log"])){
1628
			if(isset($conf["log"])){
1629
		
1629
 
1630
				#initial debug data
1630
				#initial debug data
1631
				$debug=array();
1631
				$debug=array();
1632
				
1632
 
1633
				#set debug file info
1633
				#set debug file info
1634
				$debug["file"]=__FILE__;
1634
				$debug["file"]=__FILE__;
1635
				
1635
 
1636
				#set debug function info
1636
				#set debug function info
1637
				$debug["function"]=__FUNCTION__;
1637
				$debug["function"]=__FUNCTION__;
1638
				
1638
 
1639
				#set debug line info
1639
				#set debug line info
1640
				$debug["line"]=__LINE__;
1640
				$debug["line"]=__LINE__;
1641
				
1641
 
1642
				#set debug content
1642
				#set debug content
1643
				$debug["content"]=$conf["serverCache"];
1643
				$debug["content"]=$conf["serverCache"];
1644
			
1644
 
1645
				#write debug info
1645
				#write debug info
1646
				#函式說明:
1646
				#函式說明:
1647
				#撰寫log
1647
				#撰寫log
1648
				#回傳結果:
1648
				#回傳結果:
1649
				#$result["status"],狀態,"true"或"false".
1649
				#$result["status"],狀態,"true"或"false".
Line 1667... Line 1667...
1667
				#無.
1667
				#無.
1668
				#備註:
1668
				#備註:
1669
				#無.
1669
				#無.
1670
				$record=logs::record($conf["logs::record"]);
1670
				$record=logs::record($conf["logs::record"]);
1671
				unset($conf["logs::record"]);
1671
				unset($conf["logs::record"]);
1672
				
1672
 
1673
				#如果執行失敗
1673
				#如果執行失敗
1674
				if($record["status"]==="false"){
1674
				if($record["status"]==="false"){
1675
					
1675
 
1676
					#設置錯誤識別
1676
					#設置錯誤識別
1677
					$result["status"]="false";
1677
					$result["status"]="false";
1678
				
1678
 
1679
					#設置錯誤訊息
1679
					#設置錯誤訊息
1680
					$result["error"]=$record;
1680
					$result["error"]=$record;
1681
					
1681
 
1682
					#設置 cache result
1682
					#設置 cache result
1683
					$result["cache"]["result"]=&$result;
1683
					$result["cache"]["result"]=&$result;
1684
										
1684
 
1685
					#回傳結果
1685
					#回傳結果
1686
					return $result;
1686
					return $result;
1687
					
1687
 
1688
					}#if end
1688
					}#if end
1689
				
1689
 
1690
				}#if end
1690
				}#if end
1691
				
1691
 
1692
			*/	
1692
			*/
1693
		
1693
 
1694
			#更新預設要回傳的cache
1694
			#更新預設要回傳的cache
1695
			$result["cache"]=&$conf["serverCache"];
1695
			$result["cache"]=&$conf["serverCache"];
1696
				
1696
 
1697
			#初始化儲存要更新排程設定的uuid
1697
			#初始化儲存要更新排程設定的uuid
1698
			$uuidsForUpdateList=array();
1698
			$uuidsForUpdateList=array();
1699
		
1699
 
1700
			#如果有之前的資料
1700
			#如果有之前的資料
1701
			if(count($conf["serverCache"])>0){
1701
			if(count($conf["serverCache"])>0){
1702
			
1702
 
1703
				#如果有之前運行的結果
1703
				#如果有之前運行的結果
1704
				if(isset($conf["serverCache"]["result"])){
1704
				if(isset($conf["serverCache"]["result"])){
1705
				
1705
 
1706
					/*
1706
					/*
1707
				
1707
 
1708
					#如果要寫log
1708
					#如果要寫log
1709
					if(isset($conf["log"])){
1709
					if(isset($conf["log"])){
1710
				
1710
 
1711
						#initial debug data
1711
						#initial debug data
1712
						$debug=array();
1712
						$debug=array();
1713
						
1713
 
1714
						#set debug file info
1714
						#set debug file info
1715
						$debug["file"]=__FILE__;
1715
						$debug["file"]=__FILE__;
1716
						
1716
 
1717
						#set debug function info
1717
						#set debug function info
1718
						$debug["function"]=__FUNCTION__;
1718
						$debug["function"]=__FUNCTION__;
1719
						
1719
 
1720
						#set debug line info
1720
						#set debug line info
1721
						$debug["line"]=__LINE__;
1721
						$debug["line"]=__LINE__;
1722
						
1722
 
1723
						#set debug content
1723
						#set debug content
1724
						$debug["content"]=$conf["serverCache"]["result"];
1724
						$debug["content"]=$conf["serverCache"]["result"];
1725
					
1725
 
1726
						#write debug info
1726
						#write debug info
1727
						#函式說明:
1727
						#函式說明:
1728
						#撰寫log
1728
						#撰寫log
1729
						#回傳結果:
1729
						#回傳結果:
1730
						#$result["status"],狀態,"true"或"false".
1730
						#$result["status"],狀態,"true"或"false".
Line 1748... Line 1748...
1748
						#無.
1748
						#無.
1749
						#備註:
1749
						#備註:
1750
						#無.
1750
						#無.
1751
						$record=logs::record($conf["logs::record"]);
1751
						$record=logs::record($conf["logs::record"]);
1752
						unset($conf["logs::record"]);
1752
						unset($conf["logs::record"]);
1753
						
1753
 
1754
						#如果執行失敗
1754
						#如果執行失敗
1755
						if($record["status"]==="false"){
1755
						if($record["status"]==="false"){
1756
							
1756
 
1757
							#設置錯誤識別
1757
							#設置錯誤識別
1758
							$result["status"]="false";
1758
							$result["status"]="false";
1759
							
1759
 
1760
							#設置錯誤訊息
1760
							#設置錯誤訊息
1761
							$result["error"]=$record;
1761
							$result["error"]=$record;
1762
							
1762
 
1763
							#設置 cache result
1763
							#設置 cache result
1764
							$result["cache"]["result"]=&$result;
1764
							$result["cache"]["result"]=&$result;
1765
							
1765
 
1766
							#回傳結果
1766
							#回傳結果
1767
							return $result;
1767
							return $result;
1768
							
1768
 
1769
							}#if end
1769
							}#if end
1770
						
1770
 
1771
						}#if end
1771
						}#if end
1772
				
1772
 
1773
					*/
1773
					*/
1774
				
1774
 
1775
					#如果之前運行正常
1775
					#如果之前運行正常
1776
					if($conf["serverCache"]["result"]["status"]==="true"){
1776
					if($conf["serverCache"]["result"]["status"]==="true"){
1777
					
1777
 
1778
						#如果有 cache 存在
1778
						#如果有 cache 存在
1779
						if(isset($conf["serverCache"]["result"]["cache"])){
1779
						if(isset($conf["serverCache"]["result"]["cache"])){
1780
						
1780
 
1781
							#如果有 result
1781
							#如果有 result
1782
							if(isset($conf["serverCache"]["result"]["cache"]["result"])){
1782
							if(isset($conf["serverCache"]["result"]["cache"]["result"])){
1783
						
1783
 
1784
								#如果有 content
1784
								#如果有 content
1785
								if(isset($conf["serverCache"]["result"]["cache"]["result"]["content"])){
1785
								if(isset($conf["serverCache"]["result"]["cache"]["result"]["content"])){
1786
									
1786
 
1787
									#針對之前執行的排程事項
1787
									#針對之前執行的排程事項
1788
									foreach($conf["serverCache"]["result"]["cache"]["result"]["content"] as $lastRanIndex => $lastRanInfo){
1788
									foreach($conf["serverCache"]["result"]["cache"]["result"]["content"] as $lastRanIndex => $lastRanInfo){
1789
								
1789
 
1790
										#debug
1790
										#debug
1791
										#var_dump(__FILE__,__LINE__,$lastRanIndex,$lastRanInfo);
1791
										#var_dump(__FILE__,__LINE__,$lastRanIndex,$lastRanInfo);
1792
								
1792
 
1793
										#如果記錄上顯示該程序尚在執行中
1793
										#如果記錄上顯示該程序尚在執行中
1794
										if($lastRanInfo["proc_get_status"]["running"]===true){
1794
										if($lastRanInfo["proc_get_status"]["running"]===true){
1795
										
1795
 
1796
											#嘗試取得該程序的狀態
1796
											#嘗試取得該程序的狀態
1797
											$proc_get_status=proc_get_status($lastRanInfo["process"]);
1797
											$proc_get_status=proc_get_status($lastRanInfo["process"]);
1798
										
1798
 
1799
											#如果已經結束執行
1799
											#如果已經結束執行
1800
											if($proc_get_status["running"]===false){
1800
											if($proc_get_status["running"]===false){
1801
											
1801
 
1802
												#儲存要更新排程設定的uuid
1802
												#儲存要更新排程設定的uuid
1803
												$uuidsForUpdateList[]=$lastRanInfo["uuid"];
1803
												$uuidsForUpdateList[]=$lastRanInfo["uuid"];
1804
												
1804
 
1805
												#移除已經跑完的排程
1805
												#移除已經跑完的排程
1806
												unset($conf["serverCache"]["result"]["cache"]["result"]["content"][$lastRanIndex]);
1806
												unset($conf["serverCache"]["result"]["cache"]["result"]["content"][$lastRanIndex]);
1807
												
1807
 
1808
												}#if end
1808
												}#if end
1809
											
1809
 
1810
											}#if end
1810
											}#if end
1811
										
1811
 
1812
										}#foreach end
1812
										}#foreach end
1813
										
1813
 
1814
									}#if end
1814
									}#if end
1815
						
1815
 
1816
								}#if end
1816
								}#if end
1817
						
1817
 
1818
							}#if end
1818
							}#if end
1819
						
1819
 
1820
						}#if end
1820
						}#if end
1821
						
1821
 
1822
					}#if end
1822
					}#if end
1823
				
1823
 
1824
				}#if end
1824
				}#if end
1825
		
1825
 
1826
			#如果有發現已經完工的排程
1826
			#如果有發現已經完工的排程
1827
			if(count($uuidsForUpdateList)>0){
1827
			if(count($uuidsForUpdateList)>0){
1828
				
1828
 
1829
				#函式說明:
1829
				#函式說明:
1830
				#將指定uuid的已執行排程,依照repeat的規格,進行資料更新.
1830
				#將指定uuid的已執行排程,依照repeat的規格,進行資料更新.
1831
				#回傳結果:
1831
				#回傳結果:
1832
				#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
1832
				#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
1833
				#$result["error"],錯誤訊息陣列.
1833
				#$result["error"],錯誤訊息陣列.
Line 1846... Line 1846...
1846
				#無.
1846
				#無.
1847
				#備註:
1847
				#備註:
1848
				#無.
1848
				#無.
1849
				$updateList=autoService::updateList($conf["autoService::updateList"]);
1849
				$updateList=autoService::updateList($conf["autoService::updateList"]);
1850
				unset($conf["autoService::updateList"]);
1850
				unset($conf["autoService::updateList"]);
1851
			
1851
 
1852
				#如果執行出錯
1852
				#如果執行出錯
1853
				if($updateList["status"]==="false"){
1853
				if($updateList["status"]==="false"){
1854
					
1854
 
1855
					#設置錯誤識別
1855
					#設置錯誤識別
1856
					$result["status"]="false";
1856
					$result["status"]="false";
1857
					
1857
 
1858
					#設置錯誤訊息
1858
					#設置錯誤訊息
1859
					$result["error"]=$updateList;
1859
					$result["error"]=$updateList;
1860
					
1860
 
1861
					#設置 cache result
1861
					#設置 cache result
1862
					$result["cache"]["result"]=&$result;
1862
					$result["cache"]["result"]=&$result;
1863
					
1863
 
1864
					#回傳結果
1864
					#回傳結果
1865
					return $result;
1865
					return $result;
1866
					
1866
 
1867
					}#if end
1867
					}#if end
1868
				
1868
 
1869
				#如果有更新後的排程內容
1869
				#如果有更新後的排程內容
1870
				if(isset($updateList["content"])){
1870
				if(isset($updateList["content"])){
1871
				
1871
 
1872
					#取得新的排程內容
1872
					#取得新的排程內容
1873
					$result["updatedConfigContent"]=$updateList["content"];
1873
					$result["updatedConfigContent"]=$updateList["content"];
1874
				
1874
 
1875
					}#if end
1875
					}#if end
1876
					
1876
 
1877
				}#if end
1877
				}#if end
1878
			
1878
 
1879
			}#if end
1879
			}#if end
1880
		
1880
 
1881
		#函式說明:
1881
		#函式說明:
1882
		#查詢系統上有哪些要自動執行的工作檔案
1882
		#查詢系統上有哪些要自動執行的工作檔案
1883
		#回傳結果:
1883
		#回傳結果:
1884
		#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
1884
		#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
1885
		#$result["error"],錯誤訊息陣列.
1885
		#$result["error"],錯誤訊息陣列.
Line 1898... Line 1898...
1898
		#無.
1898
		#無.
1899
		#備註:
1899
		#備註:
1900
		#無.
1900
		#無.
1901
		$checkList=autoService::checkList($conf["autoService::checkList"]);
1901
		$checkList=autoService::checkList($conf["autoService::checkList"]);
1902
		unset($conf["autoService::checkList"]);
1902
		unset($conf["autoService::checkList"]);
1903
	
1903
 
1904
		#如果執行失敗
1904
		#如果執行失敗
1905
		if($checkList["status"]==="false"){
1905
		if($checkList["status"]==="false"){
1906
			
1906
 
1907
			#設置錯誤識別
1907
			#設置錯誤識別
1908
			$result["status"]="false";
1908
			$result["status"]="false";
1909
			
1909
 
1910
			#設置錯誤訊息
1910
			#設置錯誤訊息
1911
			$result["error"]=$checkList;
1911
			$result["error"]=$checkList;
1912
			
1912
 
1913
			#設置 cache result
1913
			#設置 cache result
1914
			$result["cache"]["result"]=&$result;
1914
			$result["cache"]["result"]=&$result;
1915
			
1915
 
1916
			#回傳結果
1916
			#回傳結果
1917
			return $result;
1917
			return $result;
1918
			
1918
 
1919
			}#if end
1919
			}#if end
1920
			
1920
 
1921
		#如果無事可做
1921
		#如果無事可做
1922
		if($checkList["found"]==="false"){
1922
		if($checkList["found"]==="false"){
1923
			
1923
 
1924
			#設置錯誤識別
1924
			#設置錯誤識別
1925
			$result["status"]="true";
1925
			$result["status"]="true";
1926
			
1926
 
1927
			#設置 cache result
1927
			#設置 cache result
1928
			$result["cache"]["result"]=&$result;
1928
			$result["cache"]["result"]=&$result;
1929
			
1929
 
1930
			#回傳結果
1930
			#回傳結果
1931
			return $result;
1931
			return $result;
1932
			
1932
 
1933
			}#if end
1933
			}#if end
1934
	
1934
 
1935
		#debug
1935
		#debug
1936
		#var_dump(__FILE__,__LINE__,$checkList);
1936
		#var_dump(__FILE__,__LINE__,$checkList);
1937
	
1937
 
1938
		#針對每個要執行的排程 
1938
		#針對每個要執行的排程
1939
		foreach($checkList["content"] as $index => $actionInfo){
1939
		foreach($checkList["content"] as $index => $actionInfo){
1940
			
1940
 
1941
			#如果有cache參數
1941
			#如果有cache參數
1942
			if(isset($conf["serverCache"])){
1942
			if(isset($conf["serverCache"])){
1943
			
1943
 
1944
				#如果有之前的資料
1944
				#如果有之前的資料
1945
				if(count($conf["serverCache"])>0){
1945
				if(count($conf["serverCache"])>0){
1946
				
1946
 
1947
					#如果有之前運行的結果
1947
					#如果有之前運行的結果
1948
					if(isset($conf["serverCache"]["result"])){
1948
					if(isset($conf["serverCache"]["result"])){
1949
					
1949
 
1950
						#debug
1950
						#debug
1951
						#var_dump(__FILE__,__LINE__,$conf["serverCache"]["result"]);
1951
						#var_dump(__FILE__,__LINE__,$conf["serverCache"]["result"]);
1952
					
1952
 
1953
						/*
1953
						/*
1954
					
1954
 
1955
						#如果要寫log
1955
						#如果要寫log
1956
						if(isset($conf["log"])){
1956
						if(isset($conf["log"])){
1957
					
1957
 
1958
							#initial debug data
1958
							#initial debug data
1959
							$debug=array();
1959
							$debug=array();
1960
							
1960
 
1961
							#set debug file info
1961
							#set debug file info
1962
							$debug["file"]=__FILE__;
1962
							$debug["file"]=__FILE__;
1963
							
1963
 
1964
							#set debug function info
1964
							#set debug function info
1965
							$debug["function"]=__FUNCTION__;
1965
							$debug["function"]=__FUNCTION__;
1966
							
1966
 
1967
							#set debug line info
1967
							#set debug line info
1968
							$debug["line"]=__LINE__;
1968
							$debug["line"]=__LINE__;
1969
							
1969
 
1970
							#set debug content
1970
							#set debug content
1971
							$debug["content"]=$conf["serverCache"]["result"];
1971
							$debug["content"]=$conf["serverCache"]["result"];
1972
						
1972
 
1973
							#write debug info
1973
							#write debug info
1974
							#函式說明:
1974
							#函式說明:
1975
							#撰寫log
1975
							#撰寫log
1976
							#回傳結果:
1976
							#回傳結果:
1977
							#$result["status"],狀態,"true"或"false".
1977
							#$result["status"],狀態,"true"或"false".
Line 1995... Line 1995...
1995
							#無.
1995
							#無.
1996
							#備註:
1996
							#備註:
1997
							#無.
1997
							#無.
1998
							$record=logs::record($conf["logs::record"]);
1998
							$record=logs::record($conf["logs::record"]);
1999
							unset($conf["logs::record"]);
1999
							unset($conf["logs::record"]);
2000
							
2000
 
2001
							#如果執行失敗
2001
							#如果執行失敗
2002
							if($record["status"]==="false"){
2002
							if($record["status"]==="false"){
2003
								
2003
 
2004
								#設置錯誤識別
2004
								#設置錯誤識別
2005
								$result["status"]="false";
2005
								$result["status"]="false";
2006
								
2006
 
2007
								#設置錯誤訊息
2007
								#設置錯誤訊息
2008
								$result["error"]=$record;
2008
								$result["error"]=$record;
2009
								
2009
 
2010
								#設置 cache result
2010
								#設置 cache result
2011
								$result["cache"]["result"]=&$result;
2011
								$result["cache"]["result"]=&$result;
2012
								
2012
 
2013
								#回傳結果
2013
								#回傳結果
2014
								return $result;
2014
								return $result;
2015
								
2015
 
2016
								}#if end
2016
								}#if end
2017
							
2017
 
2018
							}#if end
2018
							}#if end
2019
					
2019
 
2020
						*/
2020
						*/
2021
					
2021
 
2022
						#如果之前運行正常
2022
						#如果之前運行正常
2023
						if($conf["serverCache"]["result"]["status"]==="true"){
2023
						if($conf["serverCache"]["result"]["status"]==="true"){
2024
						
2024
 
2025
							#如果有 cache 存在
2025
							#如果有 cache 存在
2026
							if(isset($conf["serverCache"]["result"]["cache"])){
2026
							if(isset($conf["serverCache"]["result"]["cache"])){
2027
							
2027
 
2028
								#如果有 result
2028
								#如果有 result
2029
								if(isset($conf["serverCache"]["result"]["cache"]["result"])){
2029
								if(isset($conf["serverCache"]["result"]["cache"]["result"])){
2030
							
2030
 
2031
									#如果有 content
2031
									#如果有 content
2032
									if(isset($conf["serverCache"]["result"]["cache"]["result"]["content"])){
2032
									if(isset($conf["serverCache"]["result"]["cache"]["result"]["content"])){
2033
										
2033
 
2034
										#針對之前執行的排程事項
2034
										#針對之前執行的排程事項
2035
										foreach($conf["serverCache"]["result"]["cache"]["result"]["content"] as $lastRanIndex => $lastRanInfo){
2035
										foreach($conf["serverCache"]["result"]["cache"]["result"]["content"] as $lastRanIndex => $lastRanInfo){
2036
									
2036
 
2037
											#如果記錄上顯示該程序尚在執行中
2037
											#如果記錄上顯示該程序尚在執行中
2038
											if($lastRanInfo["proc_get_status"]["running"]===true){
2038
											if($lastRanInfo["proc_get_status"]["running"]===true){
2039
											
2039
 
2040
												#如果是同排程的事項,亦即尚在執行中.
2040
												#如果是同排程的事項,亦即尚在執行中.
2041
												if($actionInfo["uuid"]===$lastRanInfo["uuid"]){
2041
												if($actionInfo["uuid"]===$lastRanInfo["uuid"]){
2042
														
2042
 
2043
													#跳過該排程的執行
2043
													#跳過該排程的執行
2044
													continue 2;
2044
													continue 2;
2045
												
2045
 
2046
													}#if end
2046
													}#if end
2047
											
2047
 
2048
												}#if end
2048
												}#if end
2049
											
2049
 
2050
											}#foreach end
2050
											}#foreach end
2051
											
2051
 
2052
										}#if end
2052
										}#if end
2053
							
2053
 
2054
									}#if end
2054
									}#if end
2055
							
2055
 
2056
								}#if end
2056
								}#if end
2057
							
2057
 
2058
							}#if end
2058
							}#if end
2059
					
2059
 
2060
						}#if end
2060
						}#if end
2061
				
2061
 
2062
					}#if end
2062
					}#if end
2063
			
2063
 
2064
				}#if end
2064
				}#if end
2065
			
2065
 
2066
			#取得排程的uuid
2066
			#取得排程的uuid
2067
			$actionUuids[]=$actionInfo["uuid"];
2067
			$actionUuids[]=$actionInfo["uuid"];
2068
			
2068
 
2069
			/*
2069
			/*
2070
			#函式說明:
2070
			#函式說明:
2071
			#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
2071
			#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
2072
			#回傳的結果:
2072
			#回傳的結果:
2073
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2073
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 2087... Line 2087...
2087
			#無.
2087
			#無.
2088
			#備註:
2088
			#備註:
2089
			#無.
2089
			#無.
2090
			$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
2090
			$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
2091
			unset($conf["arrays::arrayToString"]);
2091
			unset($conf["arrays::arrayToString"]);
2092
		
2092
 
2093
			#如果執行失敗
2093
			#如果執行失敗
2094
			if($arrayToString["status"]==="false"){
2094
			if($arrayToString["status"]==="false"){
2095
				
2095
 
2096
				#設置錯誤識別
2096
				#設置錯誤識別
2097
				$result["status"]="false";
2097
				$result["status"]="false";
2098
				
2098
 
2099
				#設置錯誤訊息
2099
				#設置錯誤訊息
2100
				$result["error"]=$arrayToString;
2100
				$result["error"]=$arrayToString;
2101
				
2101
 
2102
				#設置 cache result
2102
				#設置 cache result
2103
				$result["cache"]["result"]=&$result;
2103
				$result["cache"]["result"]=&$result;
2104
				
2104
 
2105
				#回傳結果
2105
				#回傳結果
2106
				return $result;
2106
				return $result;
2107
				
2107
 
2108
				}#if end
2108
				}#if end
2109
		
2109
 
2110
			#儲存排程的指令與參數
2110
			#儲存排程的指令與參數
2111
			$cmdStrs[]=$arrayToString["content"];
2111
			$cmdStrs[]=$arrayToString["content"];
2112
			*/
2112
			*/
2113
			
2113
 
2114
			#儲存排程的指令與參數
2114
			#儲存排程的指令與參數
2115
			$cmdStrs[]=$actionInfo["cmd&argu"];
2115
			$cmdStrs[]=$actionInfo["cmd&argu"];
2116
			
2116
 
2117
			}#foreach end
2117
			}#foreach end
2118
		
2118
 
2119
		#debug
2119
		#debug
2120
		#var_dump(__FILE__,__LINE__,$cmdStrs);
2120
		#var_dump(__FILE__,__LINE__,$cmdStrs);
2121
		
2121
 
2122
		#如果有要執行的指令
2122
		#如果有要執行的指令
2123
		if(isset($cmdStrs)){
2123
		if(isset($cmdStrs)){
2124
		
2124
 
2125
			#函式說明:
2125
			#函式說明:
2126
			#透過proc來多執行序運作.
2126
			#透過proc來多執行序運作.
2127
			#回傳結果:
2127
			#回傳結果:
2128
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2128
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2129
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
2129
			#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 2146... Line 2146...
2146
			#https://www.php.net/manual/en/function.proc-get-status.php
2146
			#https://www.php.net/manual/en/function.proc-get-status.php
2147
			#備註:
2147
			#備註:
2148
			#無.
2148
			#無.
2149
			$proc=threads::proc($conf["threads::proc"]);
2149
			$proc=threads::proc($conf["threads::proc"]);
2150
			unset($conf["threads::proc"]);
2150
			unset($conf["threads::proc"]);
2151
		
2151
 
2152
			#如果執行失敗
2152
			#如果執行失敗
2153
			if($proc["status"]==="false"){
2153
			if($proc["status"]==="false"){
2154
				
2154
 
2155
				#設置錯誤識別
2155
				#設置錯誤識別
2156
				$result["status"]="false";
2156
				$result["status"]="false";
2157
				
2157
 
2158
				#設置錯誤訊息
2158
				#設置錯誤訊息
2159
				$result["error"]=$proc;
2159
				$result["error"]=$proc;
2160
							
2160
 
2161
				#設置 cache result
2161
				#設置 cache result
2162
				$result["cache"]["result"]=&$result;
2162
				$result["cache"]["result"]=&$result;
2163
				
2163
 
2164
				#回傳結果
2164
				#回傳結果
2165
				return $result;
2165
				return $result;
2166
				
2166
 
2167
				}#if end
2167
				}#if end
2168
			
2168
 
2169
			#針對每個proc資訊
2169
			#針對每個proc資訊
2170
			foreach($proc["content"] as $index => $procInfo){
2170
			foreach($proc["content"] as $index => $procInfo){
2171
			
2171
 
2172
				#附加用於識別排程的uuid
2172
				#附加用於識別排程的uuid
2173
				$proc["content"][$index]["uuid"]=$actionUuids[$index];
2173
				$proc["content"][$index]["uuid"]=$actionUuids[$index];
2174
				
2174
 
2175
				#如果要寫log
2175
				#如果要寫log
2176
				if(isset($conf["log"])){
2176
				if(isset($conf["log"])){
2177
					
2177
 
2178
					#儲存要提示跑了什麼排程
2178
					#儲存要提示跑了什麼排程
2179
					$comment="運行排程 uuid:".$actionUuids[$index]." pid:".$proc["content"][$index]["proc_get_status"]["pid"]." 進入點:".$proc["content"][$index]["proc_get_status"]["command"]." 指令:".$cmdStrs[$index];
2179
					$comment="運行排程 uuid:".$actionUuids[$index]." pid:".$proc["content"][$index]["proc_get_status"]["pid"]." 進入點:".$proc["content"][$index]["proc_get_status"]["command"]." 指令:".$cmdStrs[$index];
2180
				
2180
 
2181
					#提示運行了什麼排程
2181
					#提示運行了什麼排程
2182
					#函式說明:
2182
					#函式說明:
2183
					#顯示多行文字.
2183
					#顯示多行文字.
2184
					#回傳的結果:
2184
					#回傳的結果:
2185
					#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
2185
					#$result["status"],執行是否正常,"true"為正常,"false"為不正常.
Line 2198... Line 2198...
2198
					#無.
2198
					#無.
2199
					#備註:
2199
					#備註:
2200
					#無.
2200
					#無.
2201
					$multiLine=text::multiLine($conf["text::multiLine"]);
2201
					$multiLine=text::multiLine($conf["text::multiLine"]);
2202
					unset($conf["text::multiLine"]);
2202
					unset($conf["text::multiLine"]);
2203
				
2203
 
2204
					#如果執行失敗
2204
					#如果執行失敗
2205
					if($multiLine["status"]==="false"){
2205
					if($multiLine["status"]==="false"){
2206
						
2206
 
2207
						#設置錯誤識別
2207
						#設置錯誤識別
2208
						$result["status"]="false";
2208
						$result["status"]="false";
2209
						
2209
 
2210
						#設置錯誤訊息
2210
						#設置錯誤訊息
2211
						$result["error"]=$multiLine;
2211
						$result["error"]=$multiLine;
2212
						
2212
 
2213
						#設置 cache result
2213
						#設置 cache result
2214
						$result["cache"]["result"]=&$result;
2214
						$result["cache"]["result"]=&$result;
2215
						
2215
 
2216
						#回傳結果
2216
						#回傳結果
2217
						return $result;
2217
						return $result;
2218
						
2218
 
2219
						}#if end
2219
						}#if end
2220
						
2220
 
2221
					#initial debug data
2221
					#initial debug data
2222
					$debug=array();
2222
					$debug=array();
2223
					
2223
 
2224
					#set debug file info
2224
					#set debug file info
2225
					$debug["file"]=__FILE__;
2225
					$debug["file"]=__FILE__;
2226
					
2226
 
2227
					#set debug function info
2227
					#set debug function info
2228
					$debug["function"]=__FUNCTION__;
2228
					$debug["function"]=__FUNCTION__;
2229
					
2229
 
2230
					#set debug line info
2230
					#set debug line info
2231
					$debug["line"]=__LINE__;
2231
					$debug["line"]=__LINE__;
2232
				
2232
 
2233
					#set debug content
2233
					#set debug content
2234
					$debug["content"]=$multiLine["content"];
2234
					$debug["content"]=$multiLine["content"];
2235
						
2235
 
2236
					#write debug info
2236
					#write debug info
2237
					#函式說明:
2237
					#函式說明:
2238
					#撰寫log
2238
					#撰寫log
2239
					#回傳結果:
2239
					#回傳結果:
2240
					#$result["status"],狀態,"true"或"false".
2240
					#$result["status"],狀態,"true"或"false".
Line 2258... Line 2258...
2258
					#無.
2258
					#無.
2259
					#備註:
2259
					#備註:
2260
					#無.
2260
					#無.
2261
					$record=logs::record($conf["logs::record"]);
2261
					$record=logs::record($conf["logs::record"]);
2262
					unset($conf["logs::record"]);
2262
					unset($conf["logs::record"]);
2263
					
2263
 
2264
					#如果執行失敗
2264
					#如果執行失敗
2265
					if($record["status"]==="false"){
2265
					if($record["status"]==="false"){
2266
						
2266
 
2267
						#設置錯誤識別
2267
						#設置錯誤識別
2268
						$result["status"]="false";
2268
						$result["status"]="false";
2269
						
2269
 
2270
						#設置錯誤訊息
2270
						#設置錯誤訊息
2271
						$result["error"]=$record;
2271
						$result["error"]=$record;
2272
						
2272
 
2273
						#設置 cache result
2273
						#設置 cache result
2274
						$result["cache"]["result"]=&$result;
2274
						$result["cache"]["result"]=&$result;
2275
						
2275
 
2276
						#回傳結果
2276
						#回傳結果
2277
						return $result;
2277
						return $result;
2278
						
2278
 
2279
						}#if end
2279
						}#if end
2280
						
2280
 
2281
					}#if end
2281
					}#if end
2282
						
2282
 
2283
				}#foreach end
2283
				}#foreach end
2284
			
2284
 
2285
			#依照每個剛執行的程序
2285
			#依照每個剛執行的程序
2286
			foreach($proc["content"] as $procJustRan){
2286
			foreach($proc["content"] as $procJustRan){
2287
			
2287
 
2288
				#取得每個程序執的執行結果
2288
				#取得每個程序執的執行結果
2289
				$result["content"][]=$procJustRan;
2289
				$result["content"][]=$procJustRan;
2290
			
2290
 
2291
				}#foreach end
2291
				}#foreach end
2292
				
2292
 
2293
			}#if end
2293
			}#if end
2294
		
2294
 
2295
		#設置執行正常
2295
		#設置執行正常
2296
		$result["status"]="true";
2296
		$result["status"]="true";
2297
		
2297
 
2298
		#設置 cache result
2298
		#設置 cache result
2299
		$result["cache"]["result"]=&$result;
2299
		$result["cache"]["result"]=&$result;
2300
		
2300
 
2301
		#如果該次沒有執行排程
2301
		#如果該次沒有執行排程
2302
		if(!isset($result["content"])){
2302
		if(!isset($result["content"])){
2303
					
2303
 
2304
			#從 cache 取得 content
2304
			#從 cache 取得 content
2305
			$result["content"]=&$result["cache"]["serverSide"]["funcToRunWhenIdle"]["\QBPWCF\autoService::runList"]["result"]["content"];
2305
			$result["content"]=&$result["cache"]["serverSide"]["funcToRunWhenIdle"]["\QBPWCF\autoService::runList"]["result"]["content"];
2306
		
2306
 
2307
			}#if end
2307
			}#if end
2308
		
2308
 
2309
		#debug
2309
		#debug
2310
		#var_dump(__FILE__,__LINE__,$result);
2310
		#var_dump(__FILE__,__LINE__,$result);
2311
		
2311
 
2312
		#回傳結果
2312
		#回傳結果
2313
		return $result;
2313
		return $result;
2314
	
2314
 
2315
		}#function runList end
2315
		}#function runList end
2316
	
2316
 
2317
	/*
2317
	/*
2318
	#函式說明:
2318
	#函式說明:
2319
	#將指定uuid的已執行排程,依照repeat的規格,進行資料更新.
2319
	#將指定uuid的已執行排程,依照repeat的規格,進行資料更新.
2320
	#回傳結果:
2320
	#回傳結果:
2321
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
2321
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
Line 2335... Line 2335...
2335
	#無.
2335
	#無.
2336
	#備註:
2336
	#備註:
2337
	#無.
2337
	#無.
2338
	*/
2338
	*/
2339
	public static function updateList(&$conf){
2339
	public static function updateList(&$conf){
2340
	
2340
 
2341
		#初始化要回傳的變數
2341
		#初始化要回傳的變數
2342
		$result=array();
2342
		$result=array();
2343
 
2343
 
2344
		#初始化當前執行的函數名稱
2344
		#初始化當前執行的函數名稱
2345
		$result["function"]=__FUNCTION__;
2345
		$result["function"]=__FUNCTION__;
2346
 
2346
 
2347
		#如果 $conf 不為陣列
2347
		#如果 $conf 不為陣列
2348
		if(gettype($conf)!="array"){
2348
		if(gettype($conf)!="array"){
2349
			
2349
 
2350
			#設置執行失敗
2350
			#設置執行失敗
2351
			$result["status"]="false";
2351
			$result["status"]="false";
2352
			
2352
 
2353
			#設置執行錯誤訊息
2353
			#設置執行錯誤訊息
2354
			$result["error"][]="\$conf變數須為陣列形態";
2354
			$result["error"][]="\$conf變數須為陣列形態";
2355
 
2355
 
2356
			#如果傳入的參數為 null
2356
			#如果傳入的參數為 null
2357
			if($conf==null){
2357
			if($conf==null){
2358
				
2358
 
2359
				#設置執行錯誤訊息
2359
				#設置執行錯誤訊息
2360
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
2360
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
2361
				
2361
 
2362
				}#if end
2362
				}#if end
2363
 
2363
 
2364
			#回傳結果
2364
			#回傳結果
2365
			return $result;
2365
			return $result;
2366
			
2366
 
2367
			}#if end
2367
			}#if end
2368
	
2368
 
2369
		#取得使用的參數
2369
		#取得使用的參數
2370
		$result["argu"]=$conf;
2370
		$result["argu"]=$conf;
2371
		
2371
 
2372
		#函式說明:
2372
		#函式說明:
2373
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
2373
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
2374
		#回傳結果:
2374
		#回傳結果:
2375
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2375
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2376
		#$result["error"],執行不正常結束的錯訊息陣列.
2376
		#$result["error"],執行不正常結束的錯訊息陣列.
Line 2421... Line 2421...
2421
		#array_keys=>http://php.net/manual/en/function.array-keys.php
2421
		#array_keys=>http://php.net/manual/en/function.array-keys.php
2422
		#備註:
2422
		#備註:
2423
		#無.
2423
		#無.
2424
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2424
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
2425
		unset($conf["variableCheck::checkArguments"]);
2425
		unset($conf["variableCheck::checkArguments"]);
2426
	
2426
 
2427
		#如果 $checkArguments["status"] 等於 "false"
2427
		#如果 $checkArguments["status"] 等於 "false"
2428
		if($checkArguments["status"]==="false"){
2428
		if($checkArguments["status"]==="false"){
2429
			
2429
 
2430
			#設置錯誤識別
2430
			#設置錯誤識別
2431
			$result["status"]="false";
2431
			$result["status"]="false";
2432
			
2432
 
2433
			#設置錯誤訊息
2433
			#設置錯誤訊息
2434
			$result["error"]=$checkArguments;
2434
			$result["error"]=$checkArguments;
2435
			
2435
 
2436
			#回傳結果
2436
			#回傳結果
2437
			return $result;				
2437
			return $result;
2438
			
2438
 
2439
			}#if end
2439
			}#if end
2440
			
2440
 
2441
		#如果 $checkArguments["passed"] 等於 "false"
2441
		#如果 $checkArguments["passed"] 等於 "false"
2442
		if($checkArguments["passed"]==="false"){
2442
		if($checkArguments["passed"]==="false"){
2443
			
2443
 
2444
			#設置錯誤識別
2444
			#設置錯誤識別
2445
			$result["status"]="false";
2445
			$result["status"]="false";
2446
			
2446
 
2447
			#設置錯誤訊息
2447
			#設置錯誤訊息
2448
			$result["error"]=$checkArguments;
2448
			$result["error"]=$checkArguments;
2449
			
2449
 
2450
			#回傳結果
2450
			#回傳結果
2451
			return $result;
2451
			return $result;
2452
			
2452
 
2453
			}#if end
2453
			}#if end
2454
			
2454
 
2455
		#函式說明:
2455
		#函式說明:
2456
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
2456
		#依據行號分隔抓取檔案的內容,結果會回傳一個陣列
2457
		#回傳的變數說明:
2457
		#回傳的變數說明:
2458
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
2458
		#$result["status"],執行是否成功,"true"代表成功;"fasle"代表失敗.
2459
		#$result["error"],錯誤訊息提示.
2459
		#$result["error"],錯誤訊息提示.
Line 2477... Line 2477...
2477
		#file=>http:#php.net/manual/en/function.file.php
2477
		#file=>http:#php.net/manual/en/function.file.php
2478
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
2478
		#rtrim(),剔除透過file()取得每行內容結尾的換行符號.
2479
		#filesize=>http://php.net/manual/en/function.filesize.php
2479
		#filesize=>http://php.net/manual/en/function.filesize.php
2480
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
2480
		$getFileContent=fileAccess::getFileContent($conf["fileAccess::getFileContent"]);
2481
		unset($conf["fileAccess::getFileContent"]);
2481
		unset($conf["fileAccess::getFileContent"]);
2482
		
2482
 
2483
		#如果取得檔案失敗
2483
		#如果取得檔案失敗
2484
		if($getFileContent["status"]==="false"){
2484
		if($getFileContent["status"]==="false"){
2485
		
2485
 
2486
			#設置錯誤識別
2486
			#設置錯誤識別
2487
			$result["status"]="false";
2487
			$result["status"]="false";
2488
			
2488
 
2489
			#設置錯誤訊息
2489
			#設置錯誤訊息
2490
			$result["error"]=$getFileContent;
2490
			$result["error"]=$getFileContent;
2491
			
2491
 
2492
			#回傳結果
2492
			#回傳結果
2493
			return $result;	
2493
			return $result;
2494
		
2494
 
2495
			}#if end
2495
			}#if end
2496
		
2496
 
2497
		#解析檔案內容
2497
		#解析檔案內容
2498
		
2498
 
2499
		#針對每行內容
2499
		#針對每行內容
2500
		foreach($getFileContent["fileContent"] as $line){
2500
		foreach($getFileContent["fileContent"] as $line){
2501
			
2501
 
2502
			#解密內容
2502
			#解密內容
2503
			#函式說明:
2503
			#函式說明:
2504
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
2504
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
2505
			#回傳結果:
2505
			#回傳結果:
2506
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
2506
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
2507
			#$result["function"],當前執行的函數名稱.
2507
			#$result["function"],當前執行的函數名稱.
2508
			#$result["content"],加密後的結果.
2508
			#$result["content"],加密後的結果.
2509
			#$result["error"],錯誤訊息陣列.
2509
			#$result["error"],錯誤訊息陣列.
2510
			#$result["argu"],使用的參數.
2510
			#$result["argu"],使用的參數.
2511
			#必填參數:
2511
			#必填參數:
Line 2532... Line 2532...
2532
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
2532
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
2533
			#備註:
2533
			#備註:
2534
			#無.
2534
			#無.
2535
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
2535
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
2536
			unset($conf["authenticate::enCodeStr"]);
2536
			unset($conf["authenticate::enCodeStr"]);
2537
		
2537
 
2538
			#如果執行失敗失敗
2538
			#如果執行失敗失敗
2539
			if($enCodeStr["status"]==="false"){
2539
			if($enCodeStr["status"]==="false"){
2540
			
2540
 
2541
				#設置錯誤識別
2541
				#設置錯誤識別
2542
				$result["status"]="false";
2542
				$result["status"]="false";
2543
				
2543
 
2544
				#設置錯誤訊息
2544
				#設置錯誤訊息
2545
				$result["error"]=$enCodeStr;
2545
				$result["error"]=$enCodeStr;
2546
				
2546
 
2547
				#回傳結果
2547
				#回傳結果
2548
				return $result;	
2548
				return $result;
2549
			
2549
 
2550
				}#if end
2550
				}#if end
2551
		
2551
 
2552
			#取得解密後的內容
2552
			#取得解密後的內容
2553
			$line=$enCodeStr["content"];
2553
			$line=$enCodeStr["content"];
2554
				
2554
 
2555
			#debug
2555
			#debug
2556
			#var_dump(__LINE__,$line);
2556
			#var_dump(__LINE__,$line);
2557
				
2557
 
2558
			#如果內容沒有 uuid
2558
			#如果內容沒有 uuid
2559
			if(!isset($line->uuid)){
2559
			if(!isset($line->uuid)){
2560
			
2560
 
2561
				#忽略該行
2561
				#忽略該行
2562
				continue;
2562
				continue;
2563
			
2563
 
2564
				}#if end
2564
				}#if end
2565
				
2565
 
2566
			#取得排程的uuid
2566
			#取得排程的uuid
2567
			$uuidInFile=$line->uuid;	
2567
			$uuidInFile=$line->uuid;
2568
		
2568
 
2569
			#如果內容沒有 time ,亦即排程設定的(預期/已)執行時間
2569
			#如果內容沒有 time ,亦即排程設定的(預期/已)執行時間
2570
			if(!isset($line->time)){
2570
			if(!isset($line->time)){
2571
			
2571
 
2572
				#忽略該行
2572
				#忽略該行
2573
				continue;
2573
				continue;
2574
			
2574
 
2575
				}#if end
2575
				}#if end
2576
				
2576
 
2577
			#取得排程的時間
2577
			#取得排程的時間
2578
			$actionUnixTimeInFile=&$line->time;	
2578
			$actionUnixTimeInFile=&$line->time;
2579
				
2579
 
2580
			#如果內容沒有 action ,亦即排程設定的指令與參數.
2580
			#如果內容沒有 action ,亦即排程設定的指令與參數.
2581
			if(!isset($line->action)){
2581
			if(!isset($line->action)){
2582
			
2582
 
2583
				#忽略該行
2583
				#忽略該行
2584
				continue;
2584
				continue;
2585
			
2585
 
2586
				}#if end
2586
				}#if end
2587
				
2587
 
2588
			#取得排程要做的事情資訊
2588
			#取得排程要做的事情資訊
2589
			$actionInFile=$line->action;
2589
			$actionInFile=$line->action;
2590
				
2590
 
2591
			#如果內容沒有 repeat ,亦即排程設定的執行模式.
2591
			#如果內容沒有 repeat ,亦即排程設定的執行模式.
2592
			if(!isset($line->repeat)){
2592
			if(!isset($line->repeat)){
2593
			
2593
 
2594
				#忽略該行
2594
				#忽略該行
2595
				continue;
2595
				continue;
2596
			
2596
 
2597
				}#if end
2597
				}#if end
2598
				
2598
 
2599
			#取得重複的方式
2599
			#取得重複的方式
2600
			$repeatInFile=$line->repeat;
2600
			$repeatInFile=$line->repeat;
2601
				
2601
 
2602
			#如果內容沒有 repeat->time ,亦即排程設定的剩下重複次數.
2602
			#如果內容沒有 repeat->time ,亦即排程設定的剩下重複次數.
2603
			if(!isset($line->repeat->times)){
2603
			if(!isset($line->repeat->times)){
2604
			
2604
 
2605
				#忽略該行
2605
				#忽略該行
2606
				continue;
2606
				continue;
2607
			
2607
 
2608
				}#if end
2608
				}#if end
2609
				
2609
 
2610
			#取得剩下的重複執行次數
2610
			#取得剩下的重複執行次數
2611
			$leftRepeatTimesInFile=&$line->repeat->times;
2611
			$leftRepeatTimesInFile=&$line->repeat->times;
2612
				
2612
 
2613
			#如果內容沒有 repeat->after(亦即排程設定的重複條件為time的之後多久) 跟 repeat->time->fixed(亦即排程設定的重複條件為用update mask過後的指定時間). 
2613
			#如果內容沒有 repeat->after(亦即排程設定的重複條件為time的之後多久) 跟 repeat->time->fixed(亦即排程設定的重複條件為用update mask過後的指定時間).
2614
			if( !isset($line->repeat->after) && !isset($line->repeat->fixed) ){
2614
			if( !isset($line->repeat->after) && !isset($line->repeat->fixed) ){
2615
			
2615
 
2616
				#忽略該行
2616
				#忽略該行
2617
				continue;
2617
				continue;
2618
			
2618
 
2619
				}#if end
2619
				}#if end
2620
				
2620
 
2621
			#如果內容沒有 update,亦即排程設定最後更新的時間
2621
			#如果內容沒有 update,亦即排程設定最後更新的時間
2622
			if(!isset($line->update)){
2622
			if(!isset($line->update)){
2623
			
2623
 
2624
				#忽略該行
2624
				#忽略該行
2625
				continue;
2625
				continue;
2626
			
2626
 
2627
				}#if end
2627
				}#if end
2628
				
2628
 
2629
			#取得排程設定產生/更新的時間點
2629
			#取得排程設定產生/更新的時間點
2630
			$updateTimeInFile=$line->update;
2630
			$updateTimeInFile=$line->update;
2631
			
2631
 
2632
			#判斷是否為目標排程的uuid
2632
			#判斷是否為目標排程的uuid
2633
			#函式說明:
2633
			#函式說明:
2634
			#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
2634
			#檢查一個數值是否與陣列裏面的元素相同,找到一個相符合的元素後就會停止搜尋.
2635
			#回傳結果:
2635
			#回傳結果:
2636
			#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
2636
			#$result["status"],"true"表示執行正確,"false"表示執行錯誤.
Line 2651... Line 2651...
2651
			#無.
2651
			#無.
2652
			#備註:
2652
			#備註:
2653
			#無.
2653
			#無.
2654
			$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
2654
			$getEqualVar=search::getEqualVar($conf["search::getEqualVar"]);
2655
			unset($conf["search::getEqualVar"]);
2655
			unset($conf["search::getEqualVar"]);
2656
			
2656
 
2657
			#debug
2657
			#debug
2658
			#var_dump(__LINE__,$getEqualVar);
2658
			#var_dump(__LINE__,$getEqualVar);
2659
			
2659
 
2660
			#如果執行失敗
2660
			#如果執行失敗
2661
			if($getEqualVar["status"]==="false"){
2661
			if($getEqualVar["status"]==="false"){
2662
			
2662
 
2663
				#設置錯誤識別
2663
				#設置錯誤識別
2664
				$result["status"]="false";
2664
				$result["status"]="false";
2665
				
2665
 
2666
				#設置錯誤訊息
2666
				#設置錯誤訊息
2667
				$result["error"]=$getEqualVar;
2667
				$result["error"]=$getEqualVar;
2668
				
2668
 
2669
				#回傳結果
2669
				#回傳結果
2670
				return $result;	
2670
				return $result;
2671
			
2671
 
2672
				}#if end
2672
				}#if end
2673
				
2673
 
2674
			#如果有相符的uuid
2674
			#如果有相符的uuid
2675
			if($getEqualVar["founded"]==="true"){
2675
			if($getEqualVar["founded"]==="true"){
2676
			
2676
 
2677
				#當前unixtime
2677
				#當前unixtime
2678
				$currentUnixTime=time::unix()["content"];
2678
				$currentUnixTime=time::unix()["content"];
2679
			
2679
 
2680
				#檔案中的排程時間
2680
				#檔案中的排程時間
2681
				#$actionUnixTimeInFile
2681
				#$actionUnixTimeInFile
2682
				
2682
 
2683
				#檔案中的排程重複方式
2683
				#檔案中的排程重複方式
2684
				#$repeatInFile
2684
				#$repeatInFile
2685
				
2685
 
2686
				#debug
2686
				#debug
2687
				#var_dump(__LINE__,$repeatInFile);
2687
				#var_dump(__LINE__,$repeatInFile);
2688
				
2688
 
2689
				#檔案中排程設定產生/更新的時間點
2689
				#檔案中排程設定產生/更新的時間點
2690
				#$updateTimeInFile
2690
				#$updateTimeInFile
2691
				
2691
 
2692
				#如果是要固定時間執行
2692
				#如果是要固定時間執行
2693
				if(isset($repeatInFile->fixed)){
2693
				if(isset($repeatInFile->fixed)){
2694
				
2694
 
2695
					#如果西元元相等
2695
					#如果西元元相等
2696
					if( gmdate("Y",$repeatInFile->fixed)===gmdate("Y",$updateTimeInFile) ){
2696
					if( gmdate("Y",$repeatInFile->fixed)===gmdate("Y",$updateTimeInFile) ){
2697
					
2697
 
2698
						#debug
2698
						#debug
2699
						#var_dump(__LINE__,"西元元相等(".gmdate("Y",$repeatInFile->fixed)."=".gmdate("Y",$updateTimeInFile).")");
2699
						#var_dump(__LINE__,"西元元相等(".gmdate("Y",$repeatInFile->fixed)."=".gmdate("Y",$updateTimeInFile).")");
2700
					
2700
 
2701
						#如果月份相同
2701
						#如果月份相同
2702
						if( gmdate("m",$repeatInFile->fixed)===gmdate("m",$updateTimeInFile) ){
2702
						if( gmdate("m",$repeatInFile->fixed)===gmdate("m",$updateTimeInFile) ){
2703
					
2703
 
2704
							#debug
2704
							#debug
2705
							#var_dump(__LINE__,"月份相同(".gmdate("m",$repeatInFile->fixed)."=".gmdate("m",$updateTimeInFile).")");
2705
							#var_dump(__LINE__,"月份相同(".gmdate("m",$repeatInFile->fixed)."=".gmdate("m",$updateTimeInFile).")");
2706
										
2706
 
2707
							#如果日相同
2707
							#如果日相同
2708
							if( gmdate("d",$repeatInFile->fixed)===gmdate("d",$updateTimeInFile) ){
2708
							if( gmdate("d",$repeatInFile->fixed)===gmdate("d",$updateTimeInFile) ){
2709
					
2709
 
2710
								#debug
2710
								#debug
2711
								#var_dump(__LINE__,"日相同(".gmdate("d",$repeatInFile->fixed)."=".gmdate("d",$updateTimeInFile).")");
2711
								#var_dump(__LINE__,"日相同(".gmdate("d",$repeatInFile->fixed)."=".gmdate("d",$updateTimeInFile).")");
2712
												
2712
 
2713
								#如果時相同
2713
								#如果時相同
2714
								if( gmdate("H",$repeatInFile->fixed)===gmdate("H",$updateTimeInFile) ){
2714
								if( gmdate("H",$repeatInFile->fixed)===gmdate("H",$updateTimeInFile) ){
2715
								
2715
 
2716
									#debug
2716
									#debug
2717
									#var_dump(__LINE__,"時相同(".gmdate("H",$repeatInFile->fixed)."=".gmdate("H",$updateTimeInFile).")");
2717
									#var_dump(__LINE__,"時相同(".gmdate("H",$repeatInFile->fixed)."=".gmdate("H",$updateTimeInFile).")");
2718
									
2718
 
2719
									#如果分相同
2719
									#如果分相同
2720
									if( gmdate("i",$repeatInFile->fixed)===gmdate("i",$updateTimeInFile) ){
2720
									if( gmdate("i",$repeatInFile->fixed)===gmdate("i",$updateTimeInFile) ){
2721
									
2721
 
2722
										#debug
2722
										#debug
2723
										#var_dump(__LINE__,"分相同(".gmdate("i",$repeatInFile->fixed)."=".gmdate("i",$updateTimeInFile).")");
2723
										#var_dump(__LINE__,"分相同(".gmdate("i",$repeatInFile->fixed)."=".gmdate("i",$updateTimeInFile).")");
2724
																		
-
 
-
 
2724
 
2725
										#代表要在固定秒數執行
2725
										#代表要在固定秒數執行
2726
										$runAtThisSec=gmdate("s",$repeatInFile->fixed);
2726
										$runAtThisSec=gmdate("s",$repeatInFile->fixed);
2727
																			
-
 
-
 
2727
 
2728
										#更新下次執行排程的時間,為1分鐘後
2728
										#更新下次執行排程的時間,為1分鐘後
2729
										$line->time=$repeatInFile->fixed+60;
2729
										$line->time=$repeatInFile->fixed+60;
2730
										
2730
 
2731
										#更新用於代表要在固定秒數執行的設定
2731
										#更新用於代表要在固定秒數執行的設定
2732
										$line->repeat->fixed=$line->time+60;
2732
										$line->repeat->fixed=$line->time+60;
2733
										
2733
 
2734
										#debug
2734
										#debug
2735
										#var_dump(__LINE__,"分相同(".gmdate("i",$repeatInFile->fixed)."=".gmdate("i",$updateTimeInFile).")");
2735
										#var_dump(__LINE__,"分相同(".gmdate("i",$repeatInFile->fixed)."=".gmdate("i",$updateTimeInFile).")");
2736
																				
-
 
-
 
2736
 
2737
										}#if end
2737
										}#if end
2738
										
2738
 
2739
									#反之到小時都相同
2739
									#反之到小時都相同
2740
									else{
2740
									else{
2741
									
2741
 
2742
										#代表要在固定分鐘數執行
2742
										#代表要在固定分鐘數執行
2743
										$runAtThisMin=gmdate("i",$repeatInFile->fixed);
2743
										$runAtThisMin=gmdate("i",$repeatInFile->fixed);
2744
																			
-
 
-
 
2744
 
2745
										#更新下次執行排程的時間,為小1時後.
2745
										#更新下次執行排程的時間,為小1時後.
2746
										$line->time=$repeatInFile->fixed+60*60;
2746
										$line->time=$repeatInFile->fixed+60*60;
2747
										
2747
 
2748
										#更新用於代表要在固定分鐘數執行的設定
2748
										#更新用於代表要在固定分鐘數執行的設定
2749
										$line->repeat->fixed=$line->time+60*60;
2749
										$line->repeat->fixed=$line->time+60*60;
2750
									
2750
 
2751
										}#else end
2751
										}#else end
2752
								
2752
 
2753
									}#if end
2753
									}#if end
2754
									
2754
 
2755
								#反之到日都相等
2755
								#反之到日都相等
2756
								else{
2756
								else{
2757
								
2757
 
2758
									#代表要在固定時數執行
2758
									#代表要在固定時數執行
2759
									$runAtThisHour=gmdate("H",$repeatInFile->fixed);
2759
									$runAtThisHour=gmdate("H",$repeatInFile->fixed);
2760
																			
-
 
-
 
2760
 
2761
									#更新下次執行排程的時間,為1天後.
2761
									#更新下次執行排程的時間,為1天後.
2762
									$line->time=$repeatInFile->fixed+60*60*24;
2762
									$line->time=$repeatInFile->fixed+60*60*24;
2763
									
2763
 
2764
									#更新用於代表要在固定小時數執行的設定
2764
									#更新用於代表要在固定小時數執行的設定
2765
									$line->repeat->fixed=$line->time+60*60*24;
2765
									$line->repeat->fixed=$line->time+60*60*24;
2766
								
2766
 
2767
									}#else end
2767
									}#else end
2768
					
2768
 
2769
								}#if end
2769
								}#if end
2770
								
2770
 
2771
							#反之到月都相等
2771
							#反之到月都相等
2772
							else{
2772
							else{
2773
							
2773
 
2774
								#代表要在固定日執行
2774
								#代表要在固定日執行
2775
								$runAtThisDay=gmdate("d",$repeatInFile->fixed);
2775
								$runAtThisDay=gmdate("d",$repeatInFile->fixed);
2776
								
2776
 
2777
								#取得該次執行的年份
2777
								#取得該次執行的年份
2778
								$year=gmdate("Y",$repeatInFile->fixed);
2778
								$year=gmdate("Y",$repeatInFile->fixed);
2779
								
2779
 
2780
								#取得執行該次的月份
2780
								#取得執行該次的月份
2781
								$month=gmdate("m",$repeatInFile->fixed);
2781
								$month=gmdate("m",$repeatInFile->fixed);
2782
							
2782
 
2783
								#如果月份等於"12"
2783
								#如果月份等於"12"
2784
								if($month==="12"){
2784
								if($month==="12"){
2785
								
2785
 
2786
									#將之變為01
2786
									#將之變為01
2787
									$month="01";
2787
									$month="01";
2788
								
2788
 
2789
									#西元年也加1
2789
									#西元年也加1
2790
									$year=$year+1;
2790
									$year=$year+1;
2791
								
2791
 
2792
									}#if end
2792
									}#if end
2793
								
2793
 
2794
								#反之
2794
								#反之
2795
								else{
2795
								else{
2796
								
2796
 
2797
									#月份+1
2797
									#月份+1
2798
									$month=printf("02s",$month+1);
2798
									$month=printf("02s",$month+1);
2799
								
2799
 
2800
									}#else end
2800
									}#else end
2801
								
2801
 
2802
								#組合YYYY-mm-dd HH:ii:ss字串參數
2802
								#組合YYYY-mm-dd HH:ii:ss字串參數
2803
								$dateAndTime=$year."-".$month."-".$runAtThisDay." ".gmdate("H",$repeatInFile->fixed).":".gmdate("i",$repeatInFile->fixed).":".gmdate("s",$repeatInFile->fixed);
2803
								$dateAndTime=$year."-".$month."-".$runAtThisDay." ".gmdate("H",$repeatInFile->fixed).":".gmdate("i",$repeatInFile->fixed).":".gmdate("s",$repeatInFile->fixed);
2804
								
2804
 
2805
								#函式說明:
2805
								#函式說明:
2806
								#計算時間點距離1970/01/01多少秒,亦即unixtime.
2806
								#計算時間點距離1970/01/01多少秒,亦即unixtime.
2807
								#回傳結果:
2807
								#回傳結果:
2808
								#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
2808
								#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
2809
								#$result["error"],錯誤訊息陣列.
2809
								#$result["error"],錯誤訊息陣列.
2810
								#$result["content"],時間點距離1970/01/01的多少秒.
2810
								#$result["content"],時間點距離1970/01/01的多少秒.
2811
								#$result["argu"],使用的參數.
2811
								#$result["argu"],使用的參數.
2812
								#$result["unixtime"],執行本函式時的unixtime.
2812
								#$result["unixtime"],執行本函式時的unixtime.
2813
								#$result["oriDateAndTime"],原始輸入的內容,若replace0參數為"true",才會有該回傳內容.	
2813
								#$result["oriDateAndTime"],原始輸入的內容,若replace0參數為"true",才會有該回傳內容.
2814
								#必填參數:
2814
								#必填參數:
2815
								#$conf["dateAndTime"],字串,格式爲 2011-05-27 23:59:59.
2815
								#$conf["dateAndTime"],字串,格式爲 2011-05-27 23:59:59.
2816
								$conf["time::caculateTimeAmount"]["dateAndTime"]=$dateAndTime;
2816
								$conf["time::caculateTimeAmount"]["dateAndTime"]=$dateAndTime;
2817
								#可省略參數:
2817
								#可省略參數:
2818
								#$conf["UTC"],字串,是否要用當前時區的設定去換算成unixtime,預設為"false",代表不要;反之為"true".
2818
								#$conf["UTC"],字串,是否要用當前時區的設定去換算成unixtime,預設為"false",代表不要;反之為"true".
Line 2823... Line 2823...
2823
								#無.
2823
								#無.
2824
								#備註:
2824
								#備註:
2825
								#無.
2825
								#無.
2826
								$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
2826
								$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
2827
								unset($conf["time::caculateTimeAmount"]);
2827
								unset($conf["time::caculateTimeAmount"]);
2828
								
2828
 
2829
								#如果執行失敗
2829
								#如果執行失敗
2830
								if($caculateTimeAmount["status"]=="false"){
2830
								if($caculateTimeAmount["status"]=="false"){
2831
									
2831
 
2832
									#設置執行失敗的訊息
2832
									#設置執行失敗的訊息
2833
									$result["status"]="false";
2833
									$result["status"]="false";
2834
									
2834
 
2835
									#設置錯誤訊息
2835
									#設置錯誤訊息
2836
									$result["error"]=$caculateTimeAmount;
2836
									$result["error"]=$caculateTimeAmount;
2837
									
2837
 
2838
									#回傳結果
2838
									#回傳結果
2839
									return $result;
2839
									return $result;
2840
									
2840
 
2841
									}#if end
2841
									}#if end
2842
								
2842
 
2843
								#更新下次執行排程的時間,為1個月後.
2843
								#更新下次執行排程的時間,為1個月後.
2844
								$line->time=$caculateTimeAmount["content"];
2844
								$line->time=$caculateTimeAmount["content"];
2845
								
2845
 
2846
								#代表要在固定日執行
2846
								#代表要在固定日執行
2847
								$runAtThisDay=gmdate("d",$repeatInFile->fixed);
2847
								$runAtThisDay=gmdate("d",$repeatInFile->fixed);
2848
																
-
 
-
 
2848
 
2849
								#如果月份等於"12"
2849
								#如果月份等於"12"
2850
								if($month==="12"){
2850
								if($month==="12"){
2851
								
2851
 
2852
									#將之變為01
2852
									#將之變為01
2853
									$month="01";
2853
									$month="01";
2854
								
2854
 
2855
									#西元年也加1
2855
									#西元年也加1
2856
									$year=$year+1;
2856
									$year=$year+1;
2857
								
2857
 
2858
									}#if end
2858
									}#if end
2859
								
2859
 
2860
								#反之
2860
								#反之
2861
								else{
2861
								else{
2862
								
2862
 
2863
									#月份+1
2863
									#月份+1
2864
									$month=printf("02s",$month+1);
2864
									$month=printf("02s",$month+1);
2865
								
2865
 
2866
									}#else end
2866
									}#else end
2867
								
2867
 
2868
								#組合YYYY-mm-dd HH:ii:ss字串參數
2868
								#組合YYYY-mm-dd HH:ii:ss字串參數
2869
								$dateAndTime=$year."-".$month."-".$runAtThisDay." ".gmdate("H",$repeatInFile->fixed).":".gmdate("i",$repeatInFile->fixed).":".gmdate("s",$repeatInFile->fixed);
2869
								$dateAndTime=$year."-".$month."-".$runAtThisDay." ".gmdate("H",$repeatInFile->fixed).":".gmdate("i",$repeatInFile->fixed).":".gmdate("s",$repeatInFile->fixed);
2870
								
2870
 
2871
								#函式說明:
2871
								#函式說明:
2872
								#計算時間點距離1970/01/01多少秒,亦即unixtime.
2872
								#計算時間點距離1970/01/01多少秒,亦即unixtime.
2873
								#回傳結果:
2873
								#回傳結果:
2874
								#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
2874
								#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
2875
								#$result["error"],錯誤訊息陣列.
2875
								#$result["error"],錯誤訊息陣列.
2876
								#$result["content"],時間點距離1970/01/01的多少秒.
2876
								#$result["content"],時間點距離1970/01/01的多少秒.
2877
								#$result["argu"],使用的參數.
2877
								#$result["argu"],使用的參數.
2878
								#$result["unixtime"],執行本函式時的unixtime.
2878
								#$result["unixtime"],執行本函式時的unixtime.
2879
								#$result["oriDateAndTime"],原始輸入的內容,若replace0參數為"true",才會有該回傳內容.	
2879
								#$result["oriDateAndTime"],原始輸入的內容,若replace0參數為"true",才會有該回傳內容.
2880
								#必填參數:
2880
								#必填參數:
2881
								#$conf["dateAndTime"],字串,格式爲 2011-05-27 23:59:59.
2881
								#$conf["dateAndTime"],字串,格式爲 2011-05-27 23:59:59.
2882
								$conf["time::caculateTimeAmount"]["dateAndTime"]=$dateAndTime;
2882
								$conf["time::caculateTimeAmount"]["dateAndTime"]=$dateAndTime;
2883
								#可省略參數:
2883
								#可省略參數:
2884
								#$conf["UTC"],字串,是否要用當前時區的設定去換算成unixtime,預設為"false",代表不要;反之為"true".
2884
								#$conf["UTC"],字串,是否要用當前時區的設定去換算成unixtime,預設為"false",代表不要;反之為"true".
Line 2889... Line 2889...
2889
								#無.
2889
								#無.
2890
								#備註:
2890
								#備註:
2891
								#無.
2891
								#無.
2892
								$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
2892
								$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
2893
								unset($conf["time::caculateTimeAmount"]);
2893
								unset($conf["time::caculateTimeAmount"]);
2894
								
2894
 
2895
								#如果執行失敗
2895
								#如果執行失敗
2896
								if($caculateTimeAmount["status"]=="false"){
2896
								if($caculateTimeAmount["status"]=="false"){
2897
									
2897
 
2898
									#設置執行失敗的訊息
2898
									#設置執行失敗的訊息
2899
									$result["status"]="false";
2899
									$result["status"]="false";
2900
									
2900
 
2901
									#設置錯誤訊息
2901
									#設置錯誤訊息
2902
									$result["error"]=$caculateTimeAmount;
2902
									$result["error"]=$caculateTimeAmount;
2903
									
2903
 
2904
									#回傳結果
2904
									#回傳結果
2905
									return $result;
2905
									return $result;
2906
									
2906
 
2907
									}#if end
2907
									}#if end
2908
								
2908
 
2909
								#更新用於代表要在固定日子執行的設定
2909
								#更新用於代表要在固定日子執行的設定
2910
								$line->repeat->fixed=$caculateTimeAmount["content"];
2910
								$line->repeat->fixed=$caculateTimeAmount["content"];
2911
							
2911
 
2912
								}#else end
2912
								}#else end
2913
					
2913
 
2914
							}#if end
2914
							}#if end
2915
					
2915
 
2916
						#反之到年都相等
2916
						#反之到年都相等
2917
						else{
2917
						else{
2918
						
2918
 
2919
							#代表要在固定月執行
2919
							#代表要在固定月執行
2920
							$runAtThisMonth=gmdate("m",$repeatInFile->fixed);
2920
							$runAtThisMonth=gmdate("m",$repeatInFile->fixed);
2921
						
2921
 
2922
							#取得該次執行的年份
2922
							#取得該次執行的年份
2923
							$year=gmdate("Y",$repeatInFile->fixed);
2923
							$year=gmdate("Y",$repeatInFile->fixed);
2924
							
2924
 
2925
							#明年執行
2925
							#明年執行
2926
							$year=$year+1;
2926
							$year=$year+1;
2927
						
2927
 
2928
							#組合YYYY-mm-dd HH:ii:ss字串參數
2928
							#組合YYYY-mm-dd HH:ii:ss字串參數
2929
							$dateAndTime=$year."-".$runAtThisMonth."-".gmdate("d",$repeatInFile->fixed)." ".gmdate("H",$repeatInFile->fixed).":".gmdate("i",$repeatInFile->fixed).":".gmdate("s",$repeatInFile->fixed);
2929
							$dateAndTime=$year."-".$runAtThisMonth."-".gmdate("d",$repeatInFile->fixed)." ".gmdate("H",$repeatInFile->fixed).":".gmdate("i",$repeatInFile->fixed).":".gmdate("s",$repeatInFile->fixed);
2930
							
2930
 
2931
							#函式說明:
2931
							#函式說明:
2932
							#計算時間點距離1970/01/01多少秒,亦即unixtime.
2932
							#計算時間點距離1970/01/01多少秒,亦即unixtime.
2933
							#回傳結果:
2933
							#回傳結果:
2934
							#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
2934
							#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
2935
							#$result["error"],錯誤訊息陣列.
2935
							#$result["error"],錯誤訊息陣列.
2936
							#$result["content"],時間點距離1970/01/01的多少秒.
2936
							#$result["content"],時間點距離1970/01/01的多少秒.
2937
							#$result["argu"],使用的參數.
2937
							#$result["argu"],使用的參數.
2938
							#$result["unixtime"],執行本函式時的unixtime.
2938
							#$result["unixtime"],執行本函式時的unixtime.
2939
							#$result["oriDateAndTime"],原始輸入的內容,若replace0參數為"true",才會有該回傳內容.	
2939
							#$result["oriDateAndTime"],原始輸入的內容,若replace0參數為"true",才會有該回傳內容.
2940
							#必填參數:
2940
							#必填參數:
2941
							#$conf["dateAndTime"],字串,格式爲 2011-05-27 23:59:59.
2941
							#$conf["dateAndTime"],字串,格式爲 2011-05-27 23:59:59.
2942
							$conf["time::caculateTimeAmount"]["dateAndTime"]=$dateAndTime;
2942
							$conf["time::caculateTimeAmount"]["dateAndTime"]=$dateAndTime;
2943
							#可省略參數:
2943
							#可省略參數:
2944
							#$conf["UTC"],字串,是否要用當前時區的設定去換算成unixtime,預設為"false",代表不要;反之為"true".
2944
							#$conf["UTC"],字串,是否要用當前時區的設定去換算成unixtime,預設為"false",代表不要;反之為"true".
Line 2949... Line 2949...
2949
							#無.
2949
							#無.
2950
							#備註:
2950
							#備註:
2951
							#無.
2951
							#無.
2952
							$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
2952
							$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
2953
							unset($conf["time::caculateTimeAmount"]);
2953
							unset($conf["time::caculateTimeAmount"]);
2954
							
2954
 
2955
							#如果執行失敗
2955
							#如果執行失敗
2956
							if($caculateTimeAmount["status"]=="false"){
2956
							if($caculateTimeAmount["status"]=="false"){
2957
								
2957
 
2958
								#設置執行失敗的訊息
2958
								#設置執行失敗的訊息
2959
								$result["status"]="false";
2959
								$result["status"]="false";
2960
								
2960
 
2961
								#設置錯誤訊息
2961
								#設置錯誤訊息
2962
								$result["error"]=$caculateTimeAmount;
2962
								$result["error"]=$caculateTimeAmount;
2963
								
2963
 
2964
								#回傳結果
2964
								#回傳結果
2965
								return $result;
2965
								return $result;
2966
								
2966
 
2967
								}#if end
2967
								}#if end
2968
							
2968
 
2969
							#更新下次執行排程的時間,為1年後.
2969
							#更新下次執行排程的時間,為1年後.
2970
							$line->time=$caculateTimeAmount["content"];
2970
							$line->time=$caculateTimeAmount["content"];
2971
							
2971
 
2972
							#代表要在固定月執行
2972
							#代表要在固定月執行
2973
							$runAtThisMonth=gmdate("m",$repeatInFile->fixed);
2973
							$runAtThisMonth=gmdate("m",$repeatInFile->fixed);
2974
						
2974
 
2975
							#取得該次執行的年份
2975
							#取得該次執行的年份
2976
							$year=gmdate("Y",$repeatInFile->fixed);
2976
							$year=gmdate("Y",$repeatInFile->fixed);
2977
							
2977
 
2978
							#明年執行
2978
							#明年執行
2979
							$year=$year+1;
2979
							$year=$year+1;
2980
						
2980
 
2981
							#組合YYYY-mm-dd HH:ii:ss字串參數
2981
							#組合YYYY-mm-dd HH:ii:ss字串參數
2982
							$dateAndTime=$year."-".$runAtThisMonth."-".gmdate("d",$repeatInFile->fixed)." ".gmdate("H",$repeatInFile->fixed).":".gmdate("i",$repeatInFile->fixed).":".gmdate("s",$repeatInFile->fixed);
2982
							$dateAndTime=$year."-".$runAtThisMonth."-".gmdate("d",$repeatInFile->fixed)." ".gmdate("H",$repeatInFile->fixed).":".gmdate("i",$repeatInFile->fixed).":".gmdate("s",$repeatInFile->fixed);
2983
							
2983
 
2984
							#函式說明:
2984
							#函式說明:
2985
							#計算時間點距離1970/01/01多少秒,亦即unixtime.
2985
							#計算時間點距離1970/01/01多少秒,亦即unixtime.
2986
							#回傳結果:
2986
							#回傳結果:
2987
							#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
2987
							#$result["stauts"],執行是否成功,"true"代表執行成功;"false"代表執行失敗.
2988
							#$result["error"],錯誤訊息陣列.
2988
							#$result["error"],錯誤訊息陣列.
2989
							#$result["content"],時間點距離1970/01/01的多少秒.
2989
							#$result["content"],時間點距離1970/01/01的多少秒.
2990
							#$result["argu"],使用的參數.
2990
							#$result["argu"],使用的參數.
2991
							#$result["unixtime"],執行本函式時的unixtime.
2991
							#$result["unixtime"],執行本函式時的unixtime.
2992
							#$result["oriDateAndTime"],原始輸入的內容,若replace0參數為"true",才會有該回傳內容.	
2992
							#$result["oriDateAndTime"],原始輸入的內容,若replace0參數為"true",才會有該回傳內容.
2993
							#必填參數:
2993
							#必填參數:
2994
							#$conf["dateAndTime"],字串,格式爲 2011-05-27 23:59:59.
2994
							#$conf["dateAndTime"],字串,格式爲 2011-05-27 23:59:59.
2995
							$conf["time::caculateTimeAmount"]["dateAndTime"]=$dateAndTime;
2995
							$conf["time::caculateTimeAmount"]["dateAndTime"]=$dateAndTime;
2996
							#可省略參數:
2996
							#可省略參數:
2997
							#$conf["UTC"],字串,是否要用當前時區的設定去換算成unixtime,預設為"false",代表不要;反之為"true".
2997
							#$conf["UTC"],字串,是否要用當前時區的設定去換算成unixtime,預設為"false",代表不要;反之為"true".
Line 3002... Line 3002...
3002
							#無.
3002
							#無.
3003
							#備註:
3003
							#備註:
3004
							#無.
3004
							#無.
3005
							$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
3005
							$caculateTimeAmount=time::caculateTimeAmount($conf["time::caculateTimeAmount"]);
3006
							unset($conf["time::caculateTimeAmount"]);
3006
							unset($conf["time::caculateTimeAmount"]);
3007
							
3007
 
3008
							#如果執行失敗
3008
							#如果執行失敗
3009
							if($caculateTimeAmount["status"]=="false"){
3009
							if($caculateTimeAmount["status"]=="false"){
3010
								
3010
 
3011
								#設置執行失敗的訊息
3011
								#設置執行失敗的訊息
3012
								$result["status"]="false";
3012
								$result["status"]="false";
3013
								
3013
 
3014
								#設置錯誤訊息
3014
								#設置錯誤訊息
3015
								$result["error"]=$caculateTimeAmount;
3015
								$result["error"]=$caculateTimeAmount;
3016
								
3016
 
3017
								#回傳結果
3017
								#回傳結果
3018
								return $result;
3018
								return $result;
3019
								
3019
 
3020
								}#if end
3020
								}#if end
3021
							
3021
 
3022
							#更新用於代表要在固定月份執行的設定
3022
							#更新用於代表要在固定月份執行的設定
3023
							$line->repeat->fixed=$caculateTimeAmount["content"];
3023
							$line->repeat->fixed=$caculateTimeAmount["content"];
3024
							
3024
 
3025
							}#else end
3025
							}#else end
3026
					
3026
 
3027
						}#if end
3027
						}#if end
3028
				
3028
 
3029
					#反之,從年份就不同
3029
					#反之,從年份就不同
3030
					else{
3030
					else{
3031
					
3031
 
3032
						#執行到這邊代表是一次性排程,以後不會在碰到,除非時光倒退.
3032
						#執行到這邊代表是一次性排程,以後不會在碰到,除非時光倒退.
3033
					
3033
 
3034
						}#else end
3034
						}#else end
3035
				
3035
 
3036
					}#if end
3036
					}#if end
3037
				
3037
 
3038
				#如果是要特定時間後執行
3038
				#如果是要特定時間後執行
3039
				else if(isset($repeatInFile->after)){
3039
				else if(isset($repeatInFile->after)){
3040
					
3040
 
3041
					#debug
3041
					#debug
3042
					#var_dump(__LINE__,"要特定時間後執行");
3042
					#var_dump(__LINE__,"要特定時間後執行");
3043
					
3043
 
3044
					#更新下次執行排程的時間
3044
					#更新下次執行排程的時間
3045
					$line->time=$currentUnixTime+$repeatInFile->after;
3045
					$line->time=$currentUnixTime+$repeatInFile->after;
3046
					
3046
 
3047
					}#if end
3047
					}#if end
3048
			
3048
 
3049
				#更新異動的時間
3049
				#更新異動的時間
3050
				$line->update=$currentUnixTime;
3050
				$line->update=$currentUnixTime;
3051
			
3051
 
3052
				#如果檔案中剩下的可執行次數大於0
3052
				#如果檔案中剩下的可執行次數大於0
3053
				if($leftRepeatTimesInFile>0){
3053
				if($leftRepeatTimesInFile>0){
3054
				
3054
 
3055
					#檔案中剩下的可執行次數-1
3055
					#檔案中剩下的可執行次數-1
3056
					$line->repeat->times=$leftRepeatTimesInFile-1;
3056
					$line->repeat->times=$leftRepeatTimesInFile-1;
3057
				
3057
 
3058
					}#if end
3058
					}#if end
3059
				
3059
 
3060
				}#if end
3060
				}#if end
3061
			
3061
 
3062
			#debug
3062
			#debug
3063
			#var_dump(__LINE__,$line);
3063
			#var_dump(__LINE__,$line);
3064
			
3064
 
3065
			#取得解密後新排程的內容
3065
			#取得解密後新排程的內容
3066
			$result["content"][]=$line;
3066
			$result["content"][]=$line;
3067
		
3067
 
3068
			#加密 $line
3068
			#加密 $line
3069
			#函式說明:
3069
			#函式說明:
3070
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
3070
			#加密字串,可以用的方法有sha1,md5,password_sha,sha1可以回傳20或40的數值字串,md5可以回傳32個數值字串,password_hash可以回傳60~255個字元.
3071
			#回傳結果:
3071
			#回傳結果:
3072
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常. 
3072
			#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3073
			#$result["function"],當前執行的函數名稱.
3073
			#$result["function"],當前執行的函數名稱.
3074
			#$result["content"],加密後的結果.
3074
			#$result["content"],加密後的結果.
3075
			#$result["error"],錯誤訊息陣列.
3075
			#$result["error"],錯誤訊息陣列.
3076
			#$result["argu"],使用的參數.
3076
			#$result["argu"],使用的參數.
3077
			#必填參數:
3077
			#必填參數:
Line 3098... Line 3098...
3098
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
3098
			#json_decode=>https://www.php.net/manual/en/function.json-decode.php
3099
			#備註:
3099
			#備註:
3100
			#無.
3100
			#無.
3101
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
3101
			$enCodeStr=authenticate::enCodeStr($conf["authenticate::enCodeStr"]);
3102
			unset($conf["authenticate::enCodeStr"]);
3102
			unset($conf["authenticate::enCodeStr"]);
3103
		
3103
 
3104
			#如果執行失敗失敗
3104
			#如果執行失敗失敗
3105
			if($enCodeStr["status"]==="false"){
3105
			if($enCodeStr["status"]==="false"){
3106
			
3106
 
3107
				#設置錯誤識別
3107
				#設置錯誤識別
3108
				$result["status"]="false";
3108
				$result["status"]="false";
3109
				
3109
 
3110
				#設置錯誤訊息
3110
				#設置錯誤訊息
3111
				$result["error"]=$enCodeStr;
3111
				$result["error"]=$enCodeStr;
3112
				
3112
 
3113
				#回傳結果
3113
				#回傳結果
3114
				return $result;	
3114
				return $result;
3115
			
3115
 
3116
				}#if end
3116
				}#if end
3117
		
3117
 
3118
			#取得加密後的內容
3118
			#取得加密後的內容
3119
			$line=$enCodeStr["content"];
3119
			$line=$enCodeStr["content"];
3120
			
3120
 
3121
			#將新的內容儲存起來
3121
			#將新的內容儲存起來
3122
			$content2write[]=$line;
3122
			$content2write[]=$line;
3123
			
3123
 
3124
			}#foreach end
3124
			}#foreach end
3125
		
3125
 
3126
		#如果有要更新排程的內容
3126
		#如果有要更新排程的內容
3127
		if(isset($content2write)){
3127
		if(isset($content2write)){
3128
		
3128
 
3129
			#重新寫入排程檔案.
3129
			#重新寫入排程檔案.
3130
			#函式說明:
3130
			#函式說明:
3131
			#將多行字串寫入到檔案
3131
			#將多行字串寫入到檔案
3132
			#回傳結果:
3132
			#回傳結果:
3133
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
3133
			#$result["status"],"true"表示檔案寫入成功,"false"表示檔案寫入失敗.
Line 3146... Line 3146...
3146
			#無.
3146
			#無.
3147
			#備註:
3147
			#備註:
3148
			#無.
3148
			#無.
3149
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
3149
			$writeMultiLine=fileAccess::writeMultiLine($conf["fileAccess::writeMultiLine"]);
3150
			unset($conf["fileAccess::writeMultiLine"]);
3150
			unset($conf["fileAccess::writeMultiLine"]);
3151
		
3151
 
3152
			#如果執行失敗失敗
3152
			#如果執行失敗失敗
3153
			if($writeMultiLine["status"]==="false"){
3153
			if($writeMultiLine["status"]==="false"){
3154
			
3154
 
3155
				#設置錯誤識別
3155
				#設置錯誤識別
3156
				$result["status"]="false";
3156
				$result["status"]="false";
3157
				
3157
 
3158
				#設置錯誤訊息
3158
				#設置錯誤訊息
3159
				$result["error"]=$writeMultiLine;
3159
				$result["error"]=$writeMultiLine;
3160
				
3160
 
3161
				#回傳結果
3161
				#回傳結果
3162
				return $result;	
3162
				return $result;
3163
			
3163
 
3164
				}#if end
3164
				}#if end
3165
		
3165
 
3166
			}#if end
3166
			}#if end
3167
		
3167
 
3168
		#設置執行正常
3168
		#設置執行正常
3169
		$result["status"]="true";
3169
		$result["status"]="true";
3170
		
3170
 
3171
		#回傳結果
3171
		#回傳結果
3172
		return $result;
3172
		return $result;
3173
	
3173
 
3174
		}#function updateList end
3174
		}#function updateList end
3175
	
3175
 
3176
	/*
3176
	/*
3177
	#函式說明:
3177
	#函式說明:
3178
	#建立unix domain socket server,依照設定檔autoService::createList建立的設定檔案來執行排程事項.
3178
	#建立unix domain socket server,依照設定檔autoService::createList建立的設定檔案來執行排程事項.
3179
	#回傳結果:
3179
	#回傳結果:
3180
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
3180
	#$result["ststus"],執行是否正常,"true"代表執行正常,"false"代表執行不正常.
Line 3195... Line 3195...
3195
	#無.
3195
	#無.
3196
	#備註:
3196
	#備註:
3197
	#無.
3197
	#無.
3198
	*/
3198
	*/
3199
	public static function daemon(&$conf){
3199
	public static function daemon(&$conf){
3200
	
3200
 
3201
		#初始化要回傳的變數
3201
		#初始化要回傳的變數
3202
		$result=array();
3202
		$result=array();
3203
 
3203
 
3204
		#初始化當前執行的函數名稱
3204
		#初始化當前執行的函數名稱
3205
		$result["function"]=__FUNCTION__;
3205
		$result["function"]=__FUNCTION__;
3206
 
3206
 
3207
		#如果 $conf 不為陣列
3207
		#如果 $conf 不為陣列
3208
		if(gettype($conf)!="array"){
3208
		if(gettype($conf)!="array"){
3209
			
3209
 
3210
			#設置執行失敗
3210
			#設置執行失敗
3211
			$result["status"]="false";
3211
			$result["status"]="false";
3212
			
3212
 
3213
			#設置執行錯誤訊息
3213
			#設置執行錯誤訊息
3214
			$result["error"][]="\$conf變數須為陣列形態";
3214
			$result["error"][]="\$conf變數須為陣列形態";
3215
 
3215
 
3216
			#如果傳入的參數為 null
3216
			#如果傳入的參數為 null
3217
			if($conf==null){
3217
			if($conf==null){
3218
				
3218
 
3219
				#設置執行錯誤訊息
3219
				#設置執行錯誤訊息
3220
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3220
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
3221
				
3221
 
3222
				}#if end
3222
				}#if end
3223
 
3223
 
3224
			#回傳結果
3224
			#回傳結果
3225
			return $result;
3225
			return $result;
3226
			
3226
 
3227
			}#if end
3227
			}#if end
3228
	
3228
 
3229
		#取得使用的參數
3229
		#取得使用的參數
3230
		$result["argu"]=$conf;
3230
		$result["argu"]=$conf;
3231
		
3231
 
3232
		#函式說明:
3232
		#函式說明:
3233
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
3233
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
3234
		#回傳結果:
3234
		#回傳結果:
3235
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3235
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
3236
		#$result["error"],執行不正常結束的錯訊息陣列.
3236
		#$result["error"],執行不正常結束的錯訊息陣列.
Line 3281... Line 3281...
3281
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3281
		#array_keys=>http://php.net/manual/en/function.array-keys.php
3282
		#備註:
3282
		#備註:
3283
		#無.
3283
		#無.
3284
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3284
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
3285
		unset($conf["variableCheck::checkArguments"]);
3285
		unset($conf["variableCheck::checkArguments"]);
3286
	
3286
 
3287
		#debug
3287
		#debug
3288
		#var_dump(__LINE__,$checkArguments);
3288
		#var_dump(__LINE__,$checkArguments);
3289
	
3289
 
3290
		#如果 $checkArguments["status"] 等於 "false"
3290
		#如果 $checkArguments["status"] 等於 "false"
3291
		if($checkArguments["status"]==="false"){
3291
		if($checkArguments["status"]==="false"){
3292
			
3292
 
3293
			#設置錯誤識別
3293
			#設置錯誤識別
3294
			$result["status"]="false";
3294
			$result["status"]="false";
3295
			
3295
 
3296
			#設置錯誤訊息
3296
			#設置錯誤訊息
3297
			$result["error"]=$checkArguments;
3297
			$result["error"]=$checkArguments;
3298
			
3298
 
3299
			#回傳結果
3299
			#回傳結果
3300
			return $result;
3300
			return $result;
3301
			
3301
 
3302
			}#if end
3302
			}#if end
3303
			
3303
 
3304
		#如果 $checkArguments["passed"] 等於 "false"
3304
		#如果 $checkArguments["passed"] 等於 "false"
3305
		if($checkArguments["passed"]==="false"){
3305
		if($checkArguments["passed"]==="false"){
3306
			
3306
 
3307
			#設置錯誤識別
3307
			#設置錯誤識別
3308
			$result["status"]="false";
3308
			$result["status"]="false";
3309
			
3309
 
3310
			#設置錯誤訊息
3310
			#設置錯誤訊息
3311
			$result["error"]=$checkArguments;
3311
			$result["error"]=$checkArguments;
3312
			
3312
 
3313
			#回傳結果
3313
			#回傳結果
3314
			return $result;
3314
			return $result;
3315
			
3315
 
3316
			}#if end
3316
			}#if end
3317
	
3317
 
3318
		#初始化閒置時要給予 \QBPWCF\autoService::runList 的參數
3318
		#初始化閒置時要給予 \QBPWCF\autoService::runList 的參數
3319
		$paramsForFuncToRunWhenIdle=array("config"=>$conf["config"],"fileArgu"=>$conf["fileArgu"]);
3319
		$paramsForFuncToRunWhenIdle=array("config"=>$conf["config"],"fileArgu"=>$conf["fileArgu"]);
3320
	
3320
 
3321
		#如果有指定 log 參數
3321
		#如果有指定 log 參數
3322
		if(isset($conf["log"])){
3322
		if(isset($conf["log"])){
3323
		
3323
 
3324
			#增加之
3324
			#增加之
3325
			$paramsForFuncToRunWhenIdle["log"]=$conf["log"];
3325
			$paramsForFuncToRunWhenIdle["log"]=$conf["log"];
3326
		
3326
 
3327
			}#if end
3327
			}#if end
3328
	
3328
 
3329
		#debug
3329
		#debug
3330
		#var_dump(__LINE__,$paramsForFuncToRunWhenIdle);
3330
		#var_dump(__LINE__,$paramsForFuncToRunWhenIdle);
3331
	
3331
 
3332
		#函式說明:
3332
		#函式說明:
3333
		#建立 unix domain socket server, 僅提供具備檔案存取權限的用戶使用,預設提供可以下達任何指令的功能.
3333
		#建立 unix domain socket server, 僅提供具備檔案存取權限的用戶使用,預設提供可以下達任何指令的功能.
3334
		#回傳結果:
3334
		#回傳結果:
3335
		#$result["status"],"true"代表執行正常;"false"代表執行不正常.
3335
		#$result["status"],"true"代表執行正常;"false"代表執行不正常.
3336
		#$result["error"],錯誤訊息陣列.
3336
		#$result["error"],錯誤訊息陣列.
Line 3360... Line 3360...
3360
		#http://php.net/manual/en/function.stream-socket-server.php
3360
		#http://php.net/manual/en/function.stream-socket-server.php
3361
		#備註:
3361
		#備註:
3362
		#無.
3362
		#無.
3363
		$unixDomainSockServer=sock::unixDomainSockServer($conf["sock::unixDomainSockServer"]);
3363
		$unixDomainSockServer=sock::unixDomainSockServer($conf["sock::unixDomainSockServer"]);
3364
		unset($conf["sock::unixDomainSockServer"]);
3364
		unset($conf["sock::unixDomainSockServer"]);
3365
	
3365
 
3366
		#如果執行出錯
3366
		#如果執行出錯
3367
		if($unixDomainSockServer["status"]==="false"){
3367
		if($unixDomainSockServer["status"]==="false"){
3368
		
3368
 
3369
			#設置錯誤識別
3369
			#設置錯誤識別
3370
			$result["status"]="false";
3370
			$result["status"]="false";
3371
				
3371
 
3372
			#設置錯誤訊息
3372
			#設置錯誤訊息
3373
			$result["error"]=$unixDomainSockServer;
3373
			$result["error"]=$unixDomainSockServer;
3374
				
3374
 
3375
			#回傳結果
3375
			#回傳結果
3376
			return $result;	
3376
			return $result;
3377
			
3377
 
3378
			}#if end
3378
			}#if end
3379
			
3379
 
3380
		#設置正常識別
3380
		#設置正常識別
3381
		$result["status"]="true";
3381
		$result["status"]="true";
3382
		
3382
 
3383
		#回傳結果
3383
		#回傳結果
3384
		return $result;	
3384
		return $result;
3385
	
3385
 
3386
		}#function daemon end
3386
		}#function daemon end
3387
	
3387
 
3388
	}#class autoService end
3388
	}#class autoService end
3389
 
3389
 
3390
?>
3390
?>