Subversion Repositories php-qbpwcf

Rev

Rev 405 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
405 liveuser 1
<?php
2
 
3
/*
4
 
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2014~2026 MIN ZHI, CHEN
7
 
8
    This file is part of QBPWCF.
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
 
15
    QBPWCF is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
 
23
*/
24
 
25
#使用命名空間qbpwcf
26
namespace qbpwcf;
27
 
28
#assets dir
29
$assetsDir="assets_of_zerossl::updateDnsRecordFile_20260804";
30
 
31
#複製一份既有的檔案到要更新的檔案
32
#函式說明:
33
#複製檔案、資料夾,只要符合權限就會執行並覆蓋既有內容.
34
#回傳結果:
35
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
36
#$result["error"],錯誤訊息.
37
#$result["function"],當前執行的函式名稱.
38
#$result["content"],複製好的檔案路徑與名稱.
39
#必填參數:
40
#$conf["file"],字串,檔案的位置與名稱.
406 liveuser 41
$conf["file"]=$assetsDir."/db.qbpwcf.org.ori";
405 liveuser 42
#$conf["to"],字串,檔案要複製到哪裡.
43
$conf["to"]=$assetsDir."/db.qbpwcf.org";
44
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
45
$conf["fileArgu"]=__FILE__;
46
#可省略參數:
47
#無.
48
#參考資料:
49
#無.
50
#備註:
51
#等同於cmd::cp的應用.
52
$cp=fileAccess::cp($conf);
53
unset($conf);
54
 
55
#如果執行失敗
56
if($cp["status"]==="false"){
57
 
58
	#debug
59
	var_dump($cp);
406 liveuser 60
 
61
	#結束運行,回傳1給 shell.
62
	exit(1);
405 liveuser 63
 
64
	}#if end
65
 
66
#要新增的一筆RR
67
$paramsOfAdd=array();
68
$paramsOfAdd["query"]="www";
69
$paramsOfAdd["type"]="CAA";
70
$paramsOfAdd["value"]="0 issue \"sectigo.com\"";
71
$paramsOfAdd["comment"]="for zerossl valid doma in qbpwcf.org";
72
 
73
#函式說明:
74
#新增DNS記錄到檔案裡面.
75
#回傳結果:
76
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
77
#$reuslt["error"],執行不正常結束的錯訊息陣列.
78
#$result["function"],當前執行的函式名稱.
79
#$result["argu"],所使用的參數.
80
#$result["content"],字串陣列,更新後的檔案RR(DNS記錄).
81
#$result["content"]["domain"],字串,RR所屬domain.
82
#$result["content"]["defaultTTL"],字串,預設的RR更新時間.
83
#必填參數:
84
#$conf["add"],多維陣列,每個元素有為有三個元素的陣列,key有"query"跟"update"跟"type"跟"value"以及"comment",分別代表要查詢的數值、更新周期、類型、答案、註解.
85
$conf["zerossl::updateDnsRecordFile"]["add"][]=$paramsOfAdd;
86
#$conf["dnsRecordFile"],字串,該ZONE檔案位置與名稱.
87
$conf["zerossl::updateDnsRecordFile"]["dnsRecordFile"]=$assetsDir."/db.qbpwcf.org";
88
#可省略參數:
89
#$conf["writeNow"],字串,是否要直接寫入既有ZONE檔案,預設為"false",不寫入;"true"為直接覆寫內容.
90
$conf["zerossl::updateDnsRecordFile"]["writeNow"]="true";
91
#$conf["debug"],字串,是否要開啟debug模式,預設為"false"不開啟;反之為"true"要開啟,會在/tmp/建立debug檔案zerossl\:\:updateDnsRecordFile.
92
$conf["zerossl::updateDnsRecordFile"]["debug"]="true";
93
#參考資料:
94
#無.
95
#備註:
96
#目前支援的DNS記錄檔案是給bind(Berkeley Internet Name Domain)套件使用的.
97
#通常qbpwcf使用者沒有權限存取RR(dns記錄檔案),本套件是透過sshfs掛載來繞過該問題.
98
#php-pear上的Net_DNS2也可以解析RR.
99
$updateDnsRecordFile=zerossl::updateDnsRecordFile($conf["zerossl::updateDnsRecordFile"]);
100
unset($conf["zerossl::updateDnsRecordFile"]);
101
 
102
#debug
103
var_dump($updateDnsRecordFile);