| 253 |
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_20260206";
|
|
|
30 |
|
|
|
31 |
#複製一份既有的檔案到要更新的檔案
|
|
|
32 |
#函式說明:
|
|
|
33 |
#複製檔案、資料夾,只要符合權限就會執行並覆蓋既有內容.
|
|
|
34 |
#回傳結果:
|
|
|
35 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
36 |
#$result["error"],錯誤訊息.
|
|
|
37 |
#$result["function"],當前執行的函式名稱.
|
|
|
38 |
#$result["content"],複製好的檔案路徑與名稱.
|
|
|
39 |
#必填參數:
|
|
|
40 |
#$conf["file"],字串,檔案的位置與名稱.
|
|
|
41 |
$conf["file"]=$assetsDir."/db.qbpwcf.org-ori";
|
|
|
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);
|
|
|
60 |
|
|
|
61 |
}#if end
|
|
|
62 |
|
|
|
63 |
#要新增的一筆RR
|
|
|
64 |
$paramsOfAdd=array();
|
| 255 |
liveuser |
65 |
$paramsOfAdd["query"]="_3FE7CA1D6DA057FB40FDD333B4C105F9.qbpwcf.org";
|
| 253 |
liveuser |
66 |
$paramsOfAdd["type"]="CNAME";
|
|
|
67 |
$paramsOfAdd["value"]="7B29341B7148276F5025CE90FC113803.7871040E5B7FBDB8E7EEF7CC8DAA4A56.2e85598b7f1b864.comodoca.com";
|
|
|
68 |
$paramsOfAdd["comment"]="for zerossl valid doma in qbpwcf.org";
|
|
|
69 |
|
|
|
70 |
#函式說明:
|
|
|
71 |
#新增DNS記錄到檔案裡面.
|
|
|
72 |
#回傳結果:
|
|
|
73 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
74 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
75 |
#$result["function"],當前執行的函式名稱.
|
|
|
76 |
#$result["argu"],所使用的參數.
|
|
|
77 |
#$result["content"],字串陣列,更新後的檔案RR(DNS記錄).
|
|
|
78 |
#$result["content"]["domain"],字串,RR所屬domain.
|
|
|
79 |
#$result["content"]["defaultTTL"],字串,預設的RR更新時間.
|
|
|
80 |
#必填參數:
|
|
|
81 |
#$conf["add"],多維陣列,每個元素有為有三個元素的陣列,key有"query"跟"update"跟"type"跟"value"以及"comment",分別代表要查詢的數值、更新周期、類型、答案、註解.
|
|
|
82 |
$conf["zerossl::updateDnsRecordFile"]["add"][]=$paramsOfAdd;
|
|
|
83 |
#$conf["dnsRecordFile"],字串,該ZONE檔案位置與名稱.
|
|
|
84 |
$conf["zerossl::updateDnsRecordFile"]["dnsRecordFile"]=$assetsDir."/db.qbpwcf.org";
|
|
|
85 |
#可省略參數:
|
|
|
86 |
#$conf["writeNow"],字串,是否要直接寫入既有ZONE檔案,預設為"false",不寫入;"true"為直接覆寫內容.
|
|
|
87 |
$conf["zerossl::updateDnsRecordFile"]["writeNow"]="true";
|
| 255 |
liveuser |
88 |
#$conf["debug"],字串,是否要開啟debug模式,預設為"false"不開啟;反之為"true"要開啟,會在/tmp/建立debug檔案zerossl\:\:updateDnsRecordFile.
|
|
|
89 |
$conf["zerossl::updateDnsRecordFile"]["debug"]="true";
|
| 253 |
liveuser |
90 |
#參考資料:
|
|
|
91 |
#無.
|
|
|
92 |
#備註:
|
|
|
93 |
#目前支援的DNS記錄檔案是給bind(Berkeley Internet Name Domain)套件使用的.
|
|
|
94 |
#通常qbpwcf使用者沒有權限存取RR(dns記錄檔案),本套件是透過sshfs掛載來繞過該問題.
|
|
|
95 |
#php-pear上的Net_DNS2也可以解析RR.
|
|
|
96 |
$updateDnsRecordFile=zerossl::updateDnsRecordFile($conf["zerossl::updateDnsRecordFile"]);
|
|
|
97 |
unset($conf["zerossl::updateDnsRecordFile"]);
|
|
|
98 |
|
|
|
99 |
#debug
|
|
|
100 |
var_dump($updateDnsRecordFile);
|