Subversion Repositories php-qbpwcf

Rev

Rev 3 | Rev 239 | 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~2024 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 45... Line 45...
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
	#無.
47
	#無.
48
	*/
48
	*/
49
	public function __call($method,$arguments){
49
	public function __call($method,$arguments){
50
		
50
 
51
		#取得當前執行的函式
51
		#取得當前執行的函式
52
		$result["function"]=__FUNCTION__;
52
		$result["function"]=__FUNCTION__;
53
		
53
 
54
		#設置執行不正常
54
		#設置執行不正常
55
		$result["status"]="false";
55
		$result["status"]="false";
56
		
56
 
57
		#設置執行錯誤
57
		#設置執行錯誤
58
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
58
		$result["error"][]=__NAMESPACE__ ."/".$method."() 不存在!";
59
		
59
 
60
		#設置所丟入的參數
60
		#設置所丟入的參數
61
		$result["error"][]=$arguments;
61
		$result["error"][]=$arguments;
62
		
62
 
63
		#回傳結果
63
		#回傳結果
64
		return $result;
64
		return $result;
65
		
65
 
66
		}#function __call end
66
		}#function __call end
67
		
67
 
68
	/*
68
	/*
69
	#函式說明:
69
	#函式說明:
70
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
70
	#當前類別被呼叫的靜態方法不存在時,將會執行該函數,回報該方法不存在.
71
	#回傳結果:
71
	#回傳結果:
72
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
72
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 79... Line 79...
79
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
79
	#__call=>http://php.net/manual/en/language.oop5.overloading.php#object.callstatic
80
	#備註:
80
	#備註:
81
	#無.
81
	#無.
82
	*/
82
	*/
83
	public static function __callStatic($method,$arguments){
83
	public static function __callStatic($method,$arguments){
84
		
84
 
85
		#取得當前執行的函式
85
		#取得當前執行的函式
86
		$result["function"]=__FUNCTION__;
86
		$result["function"]=__FUNCTION__;
87
		
87
 
88
		#設置執行不正常
88
		#設置執行不正常
89
		$result["status"]="false";
89
		$result["status"]="false";
90
		
90
 
91
		#設置執行錯誤
91
		#設置執行錯誤
92
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
92
		$result["error"][]="欲呼叫的". __NAMESPACE__ ."/".$method."() 不存在!";
93
		
93
 
94
		#設置所丟入的參數
94
		#設置所丟入的參數
95
		$result["error"][]=$arguments;
95
		$result["error"][]=$arguments;
96
		
96
 
97
		#回傳結果
97
		#回傳結果
98
		return $result;
98
		return $result;
99
		
99
 
100
		}#function __callStatic end
100
		}#function __callStatic end
101
	
101
 
102
	/*
102
	/*
103
	#函式說明:
103
	#函式說明:
104
	#取得api的資訊
104
	#取得api的資訊
105
	#回傳結果:
105
	#回傳結果:
106
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
106
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 115... Line 115...
115
	#無.
115
	#無.
116
	#備註:
116
	#備註:
117
	#無.
117
	#無.
118
	*/
118
	*/
119
	public static function getApiInfo(){
119
	public static function getApiInfo(){
120
	
120
 
121
		#初始化要回傳的陣列
121
		#初始化要回傳的陣列
122
		$result=array();
122
		$result=array();
123
		
123
 
124
		#api domain
124
		#api domain
125
		$result["apiDomain"]="api.zerossl.com";
125
		$result["apiDomain"]="api.zerossl.com";
126
	
126
 
127
		#create certificate path
127
		#create certificate path
128
		$result["csrPath"]="/certificates";
128
		$result["csrPath"]="/certificates";
129
	
129
 
130
		#create certificate url
130
		#create certificate url
131
		$result["csrUrl"]=$result["apiDomain"].$result["csrPath"];
131
		$result["csrUrl"]=$result["apiDomain"].$result["csrPath"];
132
	
132
 
133
		#api access key
133
		#api access key
134
		$result["apiKey"]=zeroSSLapiKey;
134
		$result["apiKey"]=zeroSSLapiKey;
135
		
135
 
136
		#設置執行正常
136
		#設置執行正常
137
		$result["status"]="true";
137
		$result["status"]="true";
138
	
138
 
139
		#回傳結果
139
		#回傳結果
140
		return $result;
140
		return $result;
141
	
141
 
142
		}#function getApiInfo end
142
		}#function getApiInfo end
143
	
143
 
144
	/*
144
	/*
145
	#函式說明:
145
	#函式說明:
146
	#產生ssl private key.
146
	#產生ssl private key.
147
	#回傳結果:
147
	#回傳結果:
148
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
148
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 160... Line 160...
160
	#無.
160
	#無.
161
	#備註:
161
	#備註:
162
	#key generated by openssl with RSA.
162
	#key generated by openssl with RSA.
163
	*/
163
	*/
164
	public static function createPrivateKey(&$conf){
164
	public static function createPrivateKey(&$conf){
165
	
165
 
166
		#初始化要回傳的結果
166
		#初始化要回傳的結果
167
		$result=array();
167
		$result=array();
168
		
168
 
169
		#取得當前執行的函數名稱
169
		#取得當前執行的函數名稱
170
		$result["function"]=__FUNCTION__;
170
		$result["function"]=__FUNCTION__;
171
		
171
 
172
		#如果 $conf 不為陣列
172
		#如果 $conf 不為陣列
173
		if(gettype($conf)!="array"){
173
		if(gettype($conf)!="array"){
174
			
174
 
175
			#設置執行失敗
175
			#設置執行失敗
176
			$result["status"]="false";
176
			$result["status"]="false";
177
			
177
 
178
			#設置執行錯誤訊息
178
			#設置執行錯誤訊息
179
			$result["error"][]="\$conf變數須為陣列形態";
179
			$result["error"][]="\$conf變數須為陣列形態";
180
 
180
 
181
			#如果傳入的參數為 null
181
			#如果傳入的參數為 null
182
			if($conf==null){
182
			if($conf==null){
183
				
183
 
184
				#設置執行錯誤訊息
184
				#設置執行錯誤訊息
185
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
185
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
186
				
186
 
187
				}#if end
187
				}#if end
188
 
188
 
189
			#回傳結果
189
			#回傳結果
190
			return $result;
190
			return $result;
191
			
191
 
192
			}#if end
192
			}#if end
193
		
193
 
194
		#取得參數
194
		#取得參數
195
		$result["argu"]=$conf;
195
		$result["argu"]=$conf;
196
	
196
 
197
		#函式說明:
197
		#函式說明:
198
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
198
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
199
		#回傳結果:
199
		#回傳結果:
200
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
200
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
201
		#$result["error"],執行不正常結束的錯訊息陣列.
201
		#$result["error"],執行不正常結束的錯訊息陣列.
Line 246... Line 246...
246
		#array_keys=>http://php.net/manual/en/function.array-keys.php
246
		#array_keys=>http://php.net/manual/en/function.array-keys.php
247
		#備註:
247
		#備註:
248
		#無.
248
		#無.
249
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
249
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
250
		unset($conf["variableCheck::checkArguments"]);
250
		unset($conf["variableCheck::checkArguments"]);
251
		
251
 
252
		#如果 $checkArguments["status"]等於 "false"
252
		#如果 $checkArguments["status"]等於 "false"
253
		if($checkArguments["status"]==="false"){
253
		if($checkArguments["status"]==="false"){
254
 
254
 
255
			#設置執行錯誤的識別
255
			#設置執行錯誤的識別
256
			$result["status"]="false";
256
			$result["status"]="false";
Line 274... Line 274...
274
 
274
 
275
			#回傳結果
275
			#回傳結果
276
			return $result;
276
			return $result;
277
 
277
 
278
			}#if end
278
			}#if end
279
		
279
 
280
		#函式說明:
280
		#函式說明:
281
		#呼叫shell執行系統命令,並取得回傳的內容.
281
		#呼叫shell執行系統命令,並取得回傳的內容.
282
		#回傳結果:
282
		#回傳結果:
283
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
283
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
284
		#$result["error"],錯誤訊息陣列.
284
		#$result["error"],錯誤訊息陣列.
Line 334... Line 334...
334
		#備註:
334
		#備註:
335
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
335
		#不是所有指令都能用apache的身份執行,目前已知java,javac指令無法執行,使用root身份可能會被selinux阻擋.
336
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
336
		#若使用的 command、argu 參數,含有 ~ 則會被視為字串,若有需要其於 shell 中代表的家目錄位置,可用 fileAccess::tildeToPath 來進行轉換.
337
		$callShell=external::callShell($conf["external::callShell"]);
337
		$callShell=external::callShell($conf["external::callShell"]);
338
		unset($conf["external::callShell"]);
338
		unset($conf["external::callShell"]);
339
	
339
 
340
		#如果異常
340
		#如果異常
341
		if($callShell["status"]==="false"){
341
		if($callShell["status"]==="false"){
342
			
342
 
343
			#設置錯誤識別
343
			#設置錯誤識別
344
			$result["status"]="false";
344
			$result["status"]="false";
345
			
345
 
346
			#設置錯誤訊息
346
			#設置錯誤訊息
347
			$result["error"]=$callShell;
347
			$result["error"]=$callShell;
348
			
348
 
349
			#回傳結果
349
			#回傳結果
350
			return $result;
350
			return $result;
351
			
351
 
352
			}#if end
352
			}#if end
353
	
353
 
354
		#函式說明:
354
		#函式說明:
355
		#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
355
		#將一維陣列轉換為用特定符號間隔的字串,ex:array("1","2","3") to "a;b;c;".
356
		#回傳的結果:
356
		#回傳的結果:
357
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
357
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
358
		#$result["function"],當前執行的function名稱
358
		#$result["function"],當前執行的function名稱
Line 373... Line 373...
373
		#無.
373
		#無.
374
		#備註:
374
		#備註:
375
		#無.
375
		#無.
376
		$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
376
		$arrayToString=arrays::arrayToString($conf["arrays::arrayToString"]);
377
		unset($conf["arrays::arrayToString"]);
377
		unset($conf["arrays::arrayToString"]);
378
	
378
 
379
		#如果異常
379
		#如果異常
380
		if($arrayToString["status"]==="false"){
380
		if($arrayToString["status"]==="false"){
381
			
381
 
382
			#設置錯誤識別
382
			#設置錯誤識別
383
			$result["status"]="false";
383
			$result["status"]="false";
384
			
384
 
385
			#設置錯誤訊息
385
			#設置錯誤訊息
386
			$result["error"]=$arrayToString;
386
			$result["error"]=$arrayToString;
387
			
387
 
388
			#回傳結果
388
			#回傳結果
389
			return $result;
389
			return $result;
390
			
390
 
391
			}#if end
391
			}#if end
392
	
392
 
393
		#取得 private key 字串
393
		#取得 private key 字串
394
		$result["content"]=$arrayToString["content"];
394
		$result["content"]=$arrayToString["content"];
395
	
395
 
396
		#設置執行正常
396
		#設置執行正常
397
		$result["status"]="true";
397
		$result["status"]="true";
398
	
398
 
399
		#回傳結果
399
		#回傳結果
400
		return $result;
400
		return $result;
401
	
401
 
402
		}#function createPrivateKey end
402
		}#function createPrivateKey end
403
	
403
 
404
	/*
404
	/*
405
	#函式說明:
405
	#函式說明:
406
	#產生certificate sign request.
406
	#產生certificate sign request.
407
	#回傳結果:
407
	#回傳結果:
408
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
408
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
Line 428... Line 428...
428
	#無.
428
	#無.
429
	#備註:
429
	#備註:
430
	#無.
430
	#無.
431
	*/
431
	*/
432
	public static function csr(&$conf){
432
	public static function csr(&$conf){
433
	
433
 
434
		#break point
434
		#break point
435
		#var_dump(self::getApiInfo());exit;
435
		#var_dump(self::getApiInfo());exit;
436
	
436
 
437
		#初始化要回傳的結果
437
		#初始化要回傳的結果
438
		$result=array();
438
		$result=array();
439
		
439
 
440
		#設置當其函數名稱
440
		#設置當其函數名稱
441
		$result["function"]=__FUNCTION__;
441
		$result["function"]=__FUNCTION__;
442
		
442
 
443
		#如果 $conf 不為陣列
443
		#如果 $conf 不為陣列
444
		if(gettype($conf)!="array"){
444
		if(gettype($conf)!="array"){
445
			
445
 
446
			#設置執行失敗
446
			#設置執行失敗
447
			$result["status"]="false";
447
			$result["status"]="false";
448
			
448
 
449
			#設置執行錯誤訊息
449
			#設置執行錯誤訊息
450
			$result["error"][]="\$conf變數須為陣列形態";
450
			$result["error"][]="\$conf變數須為陣列形態";
451
 
451
 
452
			#如果傳入的參數為 null
452
			#如果傳入的參數為 null
453
			if($conf==null){
453
			if($conf==null){
454
				
454
 
455
				#設置執行錯誤訊息
455
				#設置執行錯誤訊息
456
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
456
				$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
457
				
457
 
458
				}#if end
458
				}#if end
459
 
459
 
460
			#回傳結果
460
			#回傳結果
461
			return $result;
461
			return $result;
462
			
462
 
463
			}#if end
463
			}#if end
464
		
464
 
465
		#取得參數
465
		#取得參數
466
		$result["argu"]=$conf;
466
		$result["argu"]=$conf;
467
		
467
 
468
		#檢查參數
468
		#檢查參數
469
		#函式說明:
469
		#函式說明:
470
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
470
		#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容。
471
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
471
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
472
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
472
		#$reuslt["error"],執行不正常結束的錯訊息陣列.
Line 482... Line 482...
482
		#必填寫的參數:
482
		#必填寫的參數:
483
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
483
		#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
484
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
484
		$conf["variableCheck::checkArguments"]["varInput"]=&$conf;
485
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
485
		#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
486
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","certificate_domains","certificate_csr");
486
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableName"]=array("fileArgu","certificate_domains","certificate_csr");
487
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); 
487
		#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object");
488
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
488
		$conf["variableCheck::checkArguments"]["mustBeFilledVariableType"]=array("string","string","string");
489
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
489
		#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
490
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
490
		$conf["variableCheck::checkArguments"]["referenceVarKey"]="variableCheck::checkArguments";
491
		#可以省略的參數:
491
		#可以省略的參數:
492
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
492
		#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
493
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
493
		$conf["variableCheck::checkArguments"]["canBeEmptyString"]="false";
494
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
494
		#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或集合.
495
		#$conf["skipableVariableCanNotBeEmpty"]=array();
495
		#$conf["skipableVariableCanNotBeEmpty"]=array();
496
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
496
		#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
497
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("apiDomain","path","key");
497
		$conf["variableCheck::checkArguments"]["skipableVariableName"]=array("apiDomain","path","key");
498
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double"); 
498
		#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
499
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
499
		$conf["variableCheck::checkArguments"]["skipableVariableType"]=array("string","string","string");
500
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
500
		#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
501
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(self::getApiInfo()["apiDomain"],self::getApiInfo()["csrPath"],self::getApiInfo()["apiKey"]);
501
		$conf["variableCheck::checkArguments"]["skipableVarDefaultValue"]=array(self::getApiInfo()["apiDomain"],self::getApiInfo()["csrPath"],self::getApiInfo()["apiKey"]);
502
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
502
		#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
503
		#$conf["arrayCountEqualCheck"][]=array();
503
		#$conf["arrayCountEqualCheck"][]=array();
504
		#參考資料來源:
504
		#參考資料來源:
505
		#array_keys=>http://php.net/manual/en/function.array-keys.php
505
		#array_keys=>http://php.net/manual/en/function.array-keys.php
506
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
506
		$checkArguments=variableCheck::checkArguments($conf["variableCheck::checkArguments"]);
507
		unset($conf["variableCheck::checkArguments"]);
507
		unset($conf["variableCheck::checkArguments"]);
508
		
508
 
509
		#如果檢查失敗
509
		#如果檢查失敗
510
		if($checkArguments["status"]=="false"){
510
		if($checkArguments["status"]=="false"){
511
			
511
 
512
			#設置錯誤識別
512
			#設置錯誤識別
513
			$result["status"]="false";
513
			$result["status"]="false";
514
			
514
 
515
			#設置錯誤訊息
515
			#設置錯誤訊息
516
			$result["error"]=$checkArguments;
516
			$result["error"]=$checkArguments;
517
			
517
 
518
			#回傳結果
518
			#回傳結果
519
			return $result;
519
			return $result;
520
			
520
 
521
			}#if end
521
			}#if end
522
	
522
 
523
		#如果檢查不通過
523
		#如果檢查不通過
524
		if($checkArguments["passed"]=="false"){
524
		if($checkArguments["passed"]=="false"){
525
			
525
 
526
			#設置錯誤識別
526
			#設置錯誤識別
527
			$result["status"]="false";
527
			$result["status"]="false";
528
			
528
 
529
			#設置錯誤訊息
529
			#設置錯誤訊息
530
			$result["error"]=$checkArguments;
530
			$result["error"]=$checkArguments;
531
			
531
 
532
			#回傳結果
532
			#回傳結果
533
			return $result;
533
			return $result;
534
			
534
 
535
			}#if end
535
			}#if end
536
		
536
 
537
		#要傳送的 key -> value
537
		#要傳送的 key -> value
538
		$postArray=array();
538
		$postArray=array();
539
		
539
 
540
		#設置要簽署的domain
540
		#設置要簽署的domain
541
		$postArray["certificate_domains"]=$conf["certificate_domains"];
541
		$postArray["certificate_domains"]=$conf["certificate_domains"];
542
		
542
 
543
		#設置csr
543
		#設置csr
544
		$postArray["certificate_csr"]=$conf["certificate_csr"];
544
		$postArray["certificate_csr"]=$conf["certificate_csr"];
545
		
545
 
546
		#預設為 90 天的憑證
546
		#預設為 90 天的憑證
547
		$postArray["certificate_validity_days"]=90;
547
		$postArray["certificate_validity_days"]=90;
548
		
548
 
549
		#強制讓 要簽署的domain 為 $postArray["certificate_domains"]
549
		#強制讓 要簽署的domain 為 $postArray["certificate_domains"]
550
		$postArray["strict_domains"]=1;
550
		$postArray["strict_domains"]=1;
551
		
551
 
552
		#設置要傳送的 json
552
		#設置要傳送的 json
553
		$postJson=json_encode($postArray);
553
		$postJson=json_encode($postArray);
554
		
554
 
555
		#函式說明:
555
		#函式說明:
556
		#運行curl cmd
556
		#運行curl cmd
557
		#回傳結果:
557
		#回傳結果:
558
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
558
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
559
		#$result["error"],錯誤訊息陣列.
559
		#$result["error"],錯誤訊息陣列.
Line 594... Line 594...
594
		#無.
594
		#無.
595
		#備註:
595
		#備註:
596
		#無.
596
		#無.
597
		$curlCmd=catchWebContent::curlCmd($conf["catchWebContent::curlCmd"]);
597
		$curlCmd=catchWebContent::curlCmd($conf["catchWebContent::curlCmd"]);
598
		unset($conf["catchWebContent::curlCmd"]);
598
		unset($conf["catchWebContent::curlCmd"]);
599
	
599
 
600
		#如果異常
600
		#如果異常
601
		if($curlCmd["status"]==="false"){
601
		if($curlCmd["status"]==="false"){
602
			
602
 
603
			#設置錯誤識別
603
			#設置錯誤識別
604
			$result["status"]="false";
604
			$result["status"]="false";
605
			
605
 
606
			#設置錯誤訊息
606
			#設置錯誤訊息
607
			$result["error"]=$curlCmd;
607
			$result["error"]=$curlCmd;
608
			
608
 
609
			#回傳結果
609
			#回傳結果
610
			return $result;
610
			return $result;
611
			
611
 
612
			}#if end
612
			}#if end
613
		
613
 
614
		#設置curl的詳細資訊
614
		#設置curl的詳細資訊
615
		$result["curl_verbose_info"]=$curlCmd;
615
		$result["curl_verbose_info"]=$curlCmd;
616
	
616
 
617
		/* 範例 json content
617
		/* 範例 json content
618
		"{"id":"f1448a54da0925356faec06154989452","type":"1","common_name":"test.qbpwcf.org","additional_domains":"","created":"2024-11-27 12:05:52","expires":"2025-02-25 00:00:00","status":"draft","validation_type":null,"validation_emails":null,"replacement_for":"","validation":{"email_validation":{"test.qbpwcf.org":["admin@test.qbpwcf.org","administrator@test.qbpwcf.org","hostmaster@test.qbpwcf.org","postmaster@test.qbpwcf.org","webmaster@test.qbpwcf.org","admin@qbpwcf.org","administrator@qbpwcf.org","hostmaster@qbpwcf.org","postmaster@qbpwcf.org","webmaster@qbpwcf.org"]},"other_methods":{"test.qbpwcf.org":{"file_validation_url_http":"http:\/\/test.qbpwcf.org\/.well-known\/pki-validation\/5CED79AF9CCCB7C8633875D1A7C919FA.txt","file_validation_url_https":"https:\/\/test.qbpwcf.org\/.well-known\/pki-validation\/5CED79AF9CCCB7C8633875D1A7C919FA.txt","file_validation_content":["2C2CAB7C8B941192CB6BD9345DA3806BBC9F13A3DF3109C1E1A8B9B1ECC5B5FC","comodoca.com","42f21840bf8a7a6"],"cname_validation_p1":"_5CED79AF9CCCB7C8633875D1A7C919FA.test.qbpwcf.org","cname_validation_p2":"2C2CAB7C8B941192CB6BD9345DA3806B.BC9F13A3DF3109C1E1A8B9B1ECC5B5FC.42f21840bf8a7a6.comodoca.com"}}}}"
618
		"{"id":"f1448a54da0925356faec06154989452","type":"1","common_name":"test.qbpwcf.org","additional_domains":"","created":"2024-11-27 12:05:52","expires":"2025-02-25 00:00:00","status":"draft","validation_type":null,"validation_emails":null,"replacement_for":"","validation":{"email_validation":{"test.qbpwcf.org":["admin@test.qbpwcf.org","administrator@test.qbpwcf.org","hostmaster@test.qbpwcf.org","postmaster@test.qbpwcf.org","webmaster@test.qbpwcf.org","admin@qbpwcf.org","administrator@qbpwcf.org","hostmaster@qbpwcf.org","postmaster@qbpwcf.org","webmaster@qbpwcf.org"]},"other_methods":{"test.qbpwcf.org":{"file_validation_url_http":"http:\/\/test.qbpwcf.org\/.well-known\/pki-validation\/5CED79AF9CCCB7C8633875D1A7C919FA.txt","file_validation_url_https":"https:\/\/test.qbpwcf.org\/.well-known\/pki-validation\/5CED79AF9CCCB7C8633875D1A7C919FA.txt","file_validation_content":["2C2CAB7C8B941192CB6BD9345DA3806BBC9F13A3DF3109C1E1A8B9B1ECC5B5FC","comodoca.com","42f21840bf8a7a6"],"cname_validation_p1":"_5CED79AF9CCCB7C8633875D1A7C919FA.test.qbpwcf.org","cname_validation_p2":"2C2CAB7C8B941192CB6BD9345DA3806B.BC9F13A3DF3109C1E1A8B9B1ECC5B5FC.42f21840bf8a7a6.comodoca.com"}}}}"
619
		*/
619
		*/
620
	
620
 
621
		#設置結果
621
		#設置結果
622
		$result["content"]=$curlCmd["content"];
622
		$result["content"]=$curlCmd["content"];
623
	
623
 
624
		#設置執行正常
624
		#設置執行正常
625
		$result["status"]="true";
625
		$result["status"]="true";
626
	
626
 
627
		#回傳結果
627
		#回傳結果
628
		return $result;
628
		return $result;
629
	
629
 
630
		}#function csr end
630
		}#function csr end
631
 
631
 
632
	}#class zerossl end
-
 
633
632
	}#class zerossl end
-
 
633