Subversion Repositories php-qbpwcf

Rev

Rev 253 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2014~2026 MIN ZHI, CHEN

    This file is part of QBPWCF.

    QBPWCF is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QBPWCF is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.

*/

#使用命名空間qbpwcf
namespace qbpwcf;

#assets dir
$assetsDir="assets_of_zerossl::updateDnsRecordFile_20260206";

#複製一份既有的檔案到要更新的檔案
#函式說明:
#複製檔案、資料夾,只要符合權限就會執行並覆蓋既有內容.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$result["error"],錯誤訊息.
#$result["function"],當前執行的函式名稱.
#$result["content"],複製好的檔案路徑與名稱.
#必填參數:
#$conf["file"],字串,檔案的位置與名稱.
$conf["file"]=$assetsDir."/db.qbpwcf.org-ori";
#$conf["to"],字串,檔案要複製到哪裡.
$conf["to"]=$assetsDir."/db.qbpwcf.org";
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
$conf["fileArgu"]=__FILE__;
#可省略參數:
#無.
#參考資料:
#無.
#備註:
#等同於cmd::cp的應用.
$cp=fileAccess::cp($conf);
unset($conf);

#如果執行失敗
if($cp["status"]==="false"){

        #debug
        var_dump($cp);

        }#if end

#要新增的一筆RR
$paramsOfAdd=array();
$paramsOfAdd["query"]="_3FE7CA1D6DA057FB40FDD333B4C105F9.qbpwcf.org";
$paramsOfAdd["type"]="CNAME";
$paramsOfAdd["value"]="7B29341B7148276F5025CE90FC113803.7871040E5B7FBDB8E7EEF7CC8DAA4A56.2e85598b7f1b864.comodoca.com";
$paramsOfAdd["comment"]="for zerossl valid doma in qbpwcf.org";

#函式說明:
#新增DNS記錄到檔案裡面.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["argu"],所使用的參數.
#$result["content"],字串陣列,更新後的檔案RR(DNS記錄).
#$result["content"]["domain"],字串,RR所屬domain.
#$result["content"]["defaultTTL"],字串,預設的RR更新時間.
#必填參數:
#$conf["add"],多維陣列,每個元素有為有三個元素的陣列,key有"query"跟"update"跟"type"跟"value"以及"comment",分別代表要查詢的數值、更新周期、類型、答案、註解.
$conf["zerossl::updateDnsRecordFile"]["add"][]=$paramsOfAdd;
#$conf["dnsRecordFile"],字串,該ZONE檔案位置與名稱.
$conf["zerossl::updateDnsRecordFile"]["dnsRecordFile"]=$assetsDir."/db.qbpwcf.org";
#可省略參數:
#$conf["writeNow"],字串,是否要直接寫入既有ZONE檔案,預設為"false",不寫入;"true"為直接覆寫內容.
$conf["zerossl::updateDnsRecordFile"]["writeNow"]="true";
#$conf["debug"],字串,是否要開啟debug模式,預設為"false"不開啟;反之為"true"要開啟,會在/tmp/建立debug檔案zerossl\:\:updateDnsRecordFile.
$conf["zerossl::updateDnsRecordFile"]["debug"]="true";
#參考資料:
#無.
#備註:
#目前支援的DNS記錄檔案是給bind(Berkeley Internet Name Domain)套件使用的.
#通常qbpwcf使用者沒有權限存取RR(dns記錄檔案),本套件是透過sshfs掛載來繞過該問題.
#php-pear上的Net_DNS2也可以解析RR.
$updateDnsRecordFile=zerossl::updateDnsRecordFile($conf["zerossl::updateDnsRecordFile"]);
unset($conf["zerossl::updateDnsRecordFile"]);

#debug
var_dump($updateDnsRecordFile);