Subversion Repositories qbpwcf-lib(archive)

Rev

Blame | Last modification | View Log | RSS feed

<?php

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2014~2025 Min-Jhin,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_threads::20250203";

#要運行的php程式
$cmd=<<<'PHP'

/*

        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
    Copyright (C) 2014~2025 Min-Jhin,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;

#匯入套件
require_once("qbpwcf/allInOne.php");

#建議的log位置
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";


#函式說明:
#更新程式檔案開頭版權宣告的年份
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["content"],有更新的檔案清單,其元素有被取代的檔案路徑與名稱跟replacedInfo,其中replacedInfo為陣列,其key為要變動的行號(從0開始算),其數值有"from"代表要被取代的原始內容,"to"代表要置換成的新內容.
#必填參數:
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
$conf["fileArgu"]=__FILE__;
#可省略參數:
#$conf["replaceFrom"],陣列,目標關鍵字,每個元素代表一行的內容,預設內容可參照本檔案開頭的版權宣告文字.
#$conf["replaceFrom"]=array();
#$conf["yearFrom],字串,起始年份,預設為西元"2014"年.
#$conf["yearFrom"]="2014";
#$conf["yearTo],字串,結束年份,預設為西元"gmdate('Y')"年.
#$conf["yearTo"]=gmdate('Y');
#$conf["Authors"],陣列,該套件的參與者,預設為array("Min-Jhin,Chen");
#$conf["Authors"]=array("Min-Jhin,Chen");
#$conf["searchPath"],陣列,要搜尋哪些地方的檔案要更新版權宣告年份,預設為使用中的本套件位置.
#$conf["searchParh"]=array("");
#參考資料:
#無.
#備註:
#無.
$updateCopyRightYear=phpLib::updateCopyRightYear($conf);
unset($conf);

#debug
var_dump($updateCopyRightYear);
PHP;

#透過 php -a 來運行 php程式
$cmd="php -r ".escapeshellarg($cmd);

#函式說明:
#透過proc來多執行序運作.
#回傳結果:
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
#$reuslt["error"],執行不正常結束的錯訊息陣列.
#$result["function"],當前執行的函式名稱.
#$result["content"],陣列,每個元素為其指令執行的結果訊息陣列,key為"status"代表執行是否正常的識別;key為"statusCode"代表程式結束後回傳給對應executeBy程式的數值;key為"output"代表標準輸出,若為resource,則代表為pipe;key為"error"代表非標準輸出,若為resource,則代表為pipe;key為"input"代表成功輸入的指令;key為"process"代表該程序經proc_open後的process source.
#必填參數:
#$conf["cmds"],字串陣列,每個元素代表要執行的指令與參數.
$conf["cmds"]=array($cmd);
#可省略參數:
#$conf["wait"],字串,是否需要等待所有程序結束,預設為"true"要等待;反之為"false"不要等待.
#$conf["wait"]="false";
#$conf["workingDir"],字串陣列,個別程式執行時的家目錄,預設不指定.
#$conf["workingDir"]=array("path");
#$conf["envs"],2維字串陣列,每個元素代表個別程式執行時的指定環境變數,key變數名稱;value為變數內容.預設為array("QBPWCF" => "Quick Build PHP Website Componment base on Fedora Linux");
#$conf["envs"]=array(array("key"=>"value"));
#$conf["executeBy"],字串陣列,每個元素代表個別指令要用什麼程式執行,預設為"bash".
#$conf["executeBy"]=array("php");
#參考資料:
#https://www.php.net/manual/en/function.proc-open.php
#備註:
#無.
$proc=threads::proc($conf);
unset($conf);

#debug
var_dump($proc);