| 1 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
| 239 |
liveuser |
6 |
Copyright (C) 2014~2026 MIN ZHI, CHEN
|
| 1 |
liveuser |
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_threads::20250203";
|
|
|
30 |
|
|
|
31 |
#要運行的php程式
|
|
|
32 |
$cmd=<<<'PHP'
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
|
|
|
36 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
| 239 |
liveuser |
37 |
Copyright (C) 2014~2026 MIN ZHI, CHEN
|
| 1 |
liveuser |
38 |
|
|
|
39 |
This file is part of QBPWCF.
|
|
|
40 |
|
|
|
41 |
QBPWCF is free software: you can redistribute it and/or modify
|
|
|
42 |
it under the terms of the GNU General Public License as published by
|
|
|
43 |
the Free Software Foundation, either version 3 of the License, or
|
|
|
44 |
(at your option) any later version.
|
|
|
45 |
|
|
|
46 |
QBPWCF is distributed in the hope that it will be useful,
|
|
|
47 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
48 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
49 |
GNU General Public License for more details.
|
|
|
50 |
|
|
|
51 |
You should have received a copy of the GNU General Public License
|
|
|
52 |
along with QBPWCF. If not, see <http://www.gnu.org/licenses/>.
|
|
|
53 |
|
|
|
54 |
*/
|
|
|
55 |
|
|
|
56 |
#使用命名空間qbpwcf
|
|
|
57 |
namespace qbpwcf;
|
|
|
58 |
|
| 315 |
liveuser |
59 |
#設置第一優先的 include path
|
|
|
60 |
set_include_path("
|
|
|
61 |
PHP;
|
|
|
62 |
|
|
|
63 |
#串接要優先匯入的路徑
|
|
|
64 |
$cmd=$cmd.$phpIncludeFirstPath;
|
|
|
65 |
|
|
|
66 |
#串接要運行的php程式
|
|
|
67 |
$cmd=$cmd.<<<'PHP'
|
|
|
68 |
".PATH_SEPARATOR.get_include_path());
|
|
|
69 |
|
| 1 |
liveuser |
70 |
#匯入套件
|
| 315 |
liveuser |
71 |
require_once("allInOne.php");
|
| 1 |
liveuser |
72 |
|
|
|
73 |
#建議的log位置
|
| 315 |
liveuser |
74 |
$logFile=
|
|
|
75 |
PHP;
|
| 1 |
liveuser |
76 |
|
| 315 |
liveuser |
77 |
#串接要使用的log路徑與檔案名稱
|
|
|
78 |
$cmd=$cmd."\"".$logFile."\";".PHP_EOL;
|
| 1 |
liveuser |
79 |
|
| 315 |
liveuser |
80 |
#串接要運行的php程式
|
|
|
81 |
$cmd=$cmd.<<<'PHP'
|
|
|
82 |
|
| 1 |
liveuser |
83 |
#函式說明:
|
| 315 |
liveuser |
84 |
#更新程式檔案開頭版權宣告的年份,以及作者清單,取得更新過後的檔案路徑.
|
| 1 |
liveuser |
85 |
#回傳結果:
|
|
|
86 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
87 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
88 |
#$result["function"],當前執行的函式名稱.
|
| 315 |
liveuser |
89 |
#$result["argu"],本函式使用的參數.
|
| 1 |
liveuser |
90 |
#$result["content"],有更新的檔案清單,其元素有被取代的檔案路徑與名稱跟replacedInfo,其中replacedInfo為陣列,其key為要變動的行號(從0開始算),其數值有"from"代表要被取代的原始內容,"to"代表要置換成的新內容.
|
| 315 |
liveuser |
91 |
#$result["scannedFile"],陣列,有檢查過的檔案清單其完整路徑與檔案名稱.
|
| 1 |
liveuser |
92 |
#必填參數:
|
|
|
93 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
94 |
$conf["fileArgu"]=__FILE__;
|
|
|
95 |
#可省略參數:
|
|
|
96 |
#$conf["replaceFrom"],陣列,目標關鍵字,每個元素代表一行的內容,預設內容可參照本檔案開頭的版權宣告文字.
|
|
|
97 |
#$conf["replaceFrom"]=array();
|
|
|
98 |
#$conf["yearFrom],字串,起始年份,預設為西元"2014"年.
|
|
|
99 |
#$conf["yearFrom"]="2014";
|
|
|
100 |
#$conf["yearTo],字串,結束年份,預設為西元"gmdate('Y')"年.
|
|
|
101 |
#$conf["yearTo"]=gmdate('Y');
|
| 315 |
liveuser |
102 |
#$conf["Authors"],陣列,該套件的參與者,預設為array("MIN-ZHI, CHEN");
|
|
|
103 |
#$conf["Authors"]=array("MIN-ZHI, CHEN");
|
| 1 |
liveuser |
104 |
#$conf["searchPath"],陣列,要搜尋哪些地方的檔案要更新版權宣告年份,預設為使用中的本套件位置.
|
| 315 |
liveuser |
105 |
#$conf["searchPath"]=array("");
|
|
|
106 |
#$conf["skipHiddenFolder"],字串,要略過隱藏的資料夾,預設為"true";反之為"false";
|
|
|
107 |
#$conf["skipHiddenFolder"]="true";
|
|
|
108 |
#$conf["includeHiddenFolder"],陣列,符合名稱的隱藏資料夾會存取,預設不指定;
|
|
|
109 |
#$conf["includeHiddenFolder"]=array("");
|
|
|
110 |
#$conf["excludeDirName"],陣列,哪些目錄名稱要忽略,預設有"free-lib"、"no-free-lib"、"composer".
|
|
|
111 |
#$conf["excludeDirName"]=array("free-lib","no-free-lib","composer");
|
|
|
112 |
#$conf["excludeMineType"],陣列,哪些檔案類型要忽略,預設有"image/*"、"video/*"、"audio/*"、"media/*"、"application/*".
|
|
|
113 |
#$conf["excludeMineType"]=array("image/*","video/*","audio/*","media/*","application/*");
|
|
|
114 |
#$conf["excludeSecondName"],陣列,哪些附檔名的檔案要忽略,預設有"log"、"csv"、"sql"、"js"、"css"、"html".
|
|
|
115 |
#$conf["excludeSecondName"]=array("log"、,"csv","sql","js","css","html");
|
|
|
116 |
#$conf["multiThread"],字串,是否要啟用多執行序,預設為"false",反之為"true",目前尚未支援.
|
|
|
117 |
#$conf["multiThread"]="false";
|
|
|
118 |
#$conf["threadType"],字串,當"multiThread"參數為"true"時,要使用的threas類型,預設為"socket",其他可能有"proc".
|
|
|
119 |
#$conf["threadType"]="socket";
|
|
|
120 |
#$conf["socket"],字串,unix domain socket 的位置與名稱,預設為 qbpwcf_usock_path;
|
|
|
121 |
#$conf["socket"]=qbpwcf_usock_path;
|
|
|
122 |
#$conf["log"],字串,log的檔案位置與名稱,預設不使用.
|
|
|
123 |
$conf["log"]=$logFile;
|
|
|
124 |
#$conf["outputPath"],字串,更新後的檔案內容要存放到哪個路徑低下,預設為 /tmp 底下.
|
|
|
125 |
#$conf["outputPath"]="";
|
| 1 |
liveuser |
126 |
#參考資料:
|
|
|
127 |
#無.
|
|
|
128 |
#備註:
|
| 315 |
liveuser |
129 |
#目前尚未支援參數 multiThread 為 true 的設置.
|
| 1 |
liveuser |
130 |
$updateCopyRightYear=phpLib::updateCopyRightYear($conf);
|
|
|
131 |
unset($conf);
|
|
|
132 |
|
|
|
133 |
#debug
|
|
|
134 |
var_dump($updateCopyRightYear);
|
|
|
135 |
PHP;
|
|
|
136 |
|
| 315 |
liveuser |
137 |
#透過 php -r 來運行 php程式
|
| 1 |
liveuser |
138 |
$cmd="php -r ".escapeshellarg($cmd);
|
|
|
139 |
|
|
|
140 |
#函式說明:
|
|
|
141 |
#透過proc來多執行序運作.
|
|
|
142 |
#回傳結果:
|
|
|
143 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
144 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
145 |
#$result["function"],當前執行的函式名稱.
|
|
|
146 |
#$result["content"],陣列,每個元素為其指令執行的結果訊息陣列,key為"status"代表執行是否正常的識別;key為"statusCode"代表程式結束後回傳給對應executeBy程式的數值;key為"output"代表標準輸出,若為resource,則代表為pipe;key為"error"代表非標準輸出,若為resource,則代表為pipe;key為"input"代表成功輸入的指令;key為"process"代表該程序經proc_open後的process source.
|
|
|
147 |
#必填參數:
|
|
|
148 |
#$conf["cmds"],字串陣列,每個元素代表要執行的指令與參數.
|
|
|
149 |
$conf["cmds"]=array($cmd);
|
|
|
150 |
#可省略參數:
|
|
|
151 |
#$conf["wait"],字串,是否需要等待所有程序結束,預設為"true"要等待;反之為"false"不要等待.
|
|
|
152 |
#$conf["wait"]="false";
|
| 315 |
liveuser |
153 |
#$conf["timeout"],字串陣列,每個元素代表單一程序執行的最大等待秒數,超過後將會強迫停止執行,僅當wait參數為"true"時生效.
|
|
|
154 |
#$conf["timeout"]=array("10");
|
| 1 |
liveuser |
155 |
#$conf["workingDir"],字串陣列,個別程式執行時的家目錄,預設不指定.
|
|
|
156 |
#$conf["workingDir"]=array("path");
|
|
|
157 |
#$conf["envs"],2維字串陣列,每個元素代表個別程式執行時的指定環境變數,key變數名稱;value為變數內容.預設為array("QBPWCF" => "Quick Build PHP Website Componment base on Fedora Linux");
|
|
|
158 |
#$conf["envs"]=array(array("key"=>"value"));
|
|
|
159 |
#$conf["executeBy"],字串陣列,每個元素代表個別指令要用什麼程式執行,預設為"bash".
|
|
|
160 |
#$conf["executeBy"]=array("php");
|
|
|
161 |
#參考資料:
|
|
|
162 |
#https://www.php.net/manual/en/function.proc-open.php
|
|
|
163 |
#備註:
|
|
|
164 |
#無.
|
|
|
165 |
$proc=threads::proc($conf);
|
|
|
166 |
unset($conf);
|
|
|
167 |
|
|
|
168 |
#debug
|
|
|
169 |
var_dump($proc);
|
|
|
170 |
|