| 402 |
liveuser |
1 |
#!/usr/bin/php
|
|
|
2 |
<?php
|
|
|
3 |
|
|
|
4 |
/*
|
|
|
5 |
|
|
|
6 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
|
|
7 |
Copyright (C) 2015~2023 Min-Jhin,Chen
|
|
|
8 |
|
|
|
9 |
This file is part of QBPWCF.
|
|
|
10 |
|
|
|
11 |
QBPWCF is free software: you can redistribute it and/or modify
|
|
|
12 |
it under the terms of the GNU General Public License as published by
|
|
|
13 |
the Free Software Foundation, either version 3 of the License, or
|
|
|
14 |
(at your option) any later version.
|
|
|
15 |
|
|
|
16 |
QBPWCF is distributed in the hope that it will be useful,
|
|
|
17 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
18 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
19 |
GNU General Public License for more details.
|
|
|
20 |
|
|
|
21 |
You should have received a copy of the GNU General Public License
|
|
|
22 |
along with QBPWCF. If not, see <http://www.gnu.org/licenses/>.
|
|
|
23 |
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
#使用 qbpwcf 命名空間
|
|
|
27 |
namespace qbpwcf;
|
|
|
28 |
|
|
|
29 |
#匯入套件
|
|
|
30 |
require_once("qbpwcf/allInOne.php");
|
|
|
31 |
|
|
|
32 |
#建議的log位置
|
|
|
33 |
$logFile=$_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"].".log";
|
|
|
34 |
|
|
|
35 |
#該指令的 help 文件
|
|
|
36 |
function help(){
|
|
|
37 |
|
|
|
38 |
#help
|
|
|
39 |
echo basename($_SERVER["PHP_SELF"])." is a program to install QBPWCF.".PHP_EOL;
|
|
|
40 |
echo basename($_SERVER["PHP_SELF"])." usage:".PHP_EOL;
|
|
|
41 |
echo "If run it without any argument, QBPWCF will be install defaultly".PHP_EOL;
|
|
|
42 |
echo "--rootPath path where QBPWCF to put. Default is /usr/lib/".PHP_EOL;
|
|
|
43 |
echo "--name folder name where QBPWCF to put inside. Default is qbpwcf".PHP_EOL;
|
|
|
44 |
echo "--mode cp/link, default is link".PHP_EOL;
|
|
|
45 |
echo "\tcp means copy and overwrite to installation path".PHP_EOL;
|
|
|
46 |
echo "\tlink means create a softlink from current path to installation path".PHP_EOL;
|
|
|
47 |
echo "--ip ip address, specify self ip address, if need.".PHP_EOL;
|
|
|
48 |
echo "--dbAddr MariaDb service address, default is \"localhost\"".PHP_EOL;
|
|
|
49 |
echo "--dbAcct MariaDb service account, default is \"root\"".PHP_EOL;
|
|
|
50 |
echo "--dbPass MariaDb service password, default is output of uuid command".PHP_EOL;
|
|
|
51 |
echo "--dbName MariaDb service database name, default is test".PHP_EOL;
|
|
|
52 |
echo "--dbPort MariaDb service port, default is 3306".PHP_EOL;
|
| 405 |
liveuser |
53 |
echo "--headless true/false, default is false. If true, it means link allInOneForCI.php to allInOne.php".PHP_EOL;
|
| 402 |
liveuser |
54 |
exit;
|
|
|
55 |
|
|
|
56 |
}#function help end
|
|
|
57 |
|
|
|
58 |
#函式說明:
|
|
|
59 |
#解析參數.
|
|
|
60 |
#回傳結果:
|
|
|
61 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
62 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
63 |
#$result["function"],當前執行的函式名稱.
|
|
|
64 |
#$result["content"],解析好的參數陣列.
|
|
|
65 |
#$result["content"][$key][$i],參數 $key 的 $i+1 個參數數值內容.
|
|
|
66 |
#$result["program"],字串,執行的程式名稱.
|
|
|
67 |
#必填參數:
|
|
|
68 |
#無.
|
|
|
69 |
#可省略參數:
|
|
|
70 |
#$conf["helpFunc"],如果解析的參數不成對,則要執行的函式名稱.
|
|
|
71 |
$conf["helpFunc"]="help";
|
|
|
72 |
#參考資料:
|
|
|
73 |
#無.
|
|
|
74 |
#備註:
|
|
|
75 |
#僅能在命令列底下執行.
|
|
|
76 |
#以後可將參數 --a--b 的名稱與後面的數值 $value 存成 $result["a"]["b"][$i]=$value .
|
|
|
77 |
$parseArgu=cmd::parseArgu($conf);
|
|
|
78 |
unset($conf);
|
|
|
79 |
|
|
|
80 |
#如果執行失敗
|
|
|
81 |
if($parseArgu["status"]==="false"){
|
|
|
82 |
|
|
|
83 |
#函式說明:
|
|
|
84 |
#撰寫log
|
|
|
85 |
#回傳結果:
|
|
|
86 |
#$result["status"],狀態,"true"或"false".
|
|
|
87 |
#$result["error"],錯誤訊息陣列.
|
|
|
88 |
#$result["function"],當前函式的名稱.
|
|
|
89 |
#$result["argu"],使用的參數.
|
|
|
90 |
#必填參數:
|
|
|
91 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
92 |
$conf["path"]=$logFile;
|
|
|
93 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
94 |
$conf["content"]=$parseArgu;
|
|
|
95 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
96 |
$conf["fileArgu"]=__FILE__;
|
|
|
97 |
#可省略參數:
|
|
|
98 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
99 |
#$conf["rewrite"]="false";
|
|
|
100 |
#參考資料:
|
|
|
101 |
#無.
|
|
|
102 |
#備註:
|
|
|
103 |
#無.
|
|
|
104 |
$record=logs::record($conf);
|
|
|
105 |
|
|
|
106 |
#如果執行失敗
|
|
|
107 |
if($record["status"]==="false"){
|
|
|
108 |
|
|
|
109 |
#印出結果
|
|
|
110 |
var_dump($record);
|
|
|
111 |
|
|
|
112 |
}#if end
|
|
|
113 |
|
| 409 |
liveuser |
114 |
#異常結束執行
|
|
|
115 |
exit(1);
|
|
|
116 |
|
| 402 |
liveuser |
117 |
}#if end
|
|
|
118 |
|
|
|
119 |
#函式說明:
|
|
|
120 |
#使用 linux 的 uuid 指令來產生 uuid 字串
|
|
|
121 |
#回傳結果:
|
|
|
122 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
123 |
#$result["error"],錯誤訊息.
|
|
|
124 |
#$result["function"],當前執行的函式名稱.
|
|
|
125 |
#必填參數:
|
|
|
126 |
#無.
|
|
|
127 |
#可省略參數:
|
|
|
128 |
#無.
|
|
|
129 |
#參考資料:
|
|
|
130 |
#無.
|
|
|
131 |
#備註:
|
|
|
132 |
#無.
|
|
|
133 |
$uuid=cmd::uuid();
|
|
|
134 |
|
|
|
135 |
#如果執行失敗
|
|
|
136 |
if($uuid["status"]==="false"){
|
|
|
137 |
|
|
|
138 |
#函式說明:
|
|
|
139 |
#撰寫log
|
|
|
140 |
#回傳結果:
|
|
|
141 |
#$result["status"],狀態,"true"或"false".
|
|
|
142 |
#$result["error"],錯誤訊息陣列.
|
|
|
143 |
#$result["function"],當前函式的名稱.
|
|
|
144 |
#$result["argu"],使用的參數.
|
|
|
145 |
#必填參數:
|
|
|
146 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
147 |
$conf["path"]=$logFile;
|
|
|
148 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
149 |
$conf["content"]=$uuid;
|
|
|
150 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
151 |
$conf["fileArgu"]=__FILE__;
|
|
|
152 |
#可省略參數:
|
|
|
153 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
154 |
#$conf["rewrite"]="false";
|
|
|
155 |
#參考資料:
|
|
|
156 |
#無.
|
|
|
157 |
#備註:
|
|
|
158 |
#無.
|
|
|
159 |
$record=logs::record($conf);
|
|
|
160 |
|
|
|
161 |
#如果執行失敗
|
|
|
162 |
if($record["status"]==="false"){
|
|
|
163 |
|
|
|
164 |
#印出結果
|
|
|
165 |
var_dump($record);
|
|
|
166 |
|
|
|
167 |
}#if end
|
| 409 |
liveuser |
168 |
|
|
|
169 |
#異常結束執行
|
|
|
170 |
exit(1);
|
| 402 |
liveuser |
171 |
|
|
|
172 |
}#if end
|
|
|
173 |
|
|
|
174 |
#預設的套件安裝位置
|
|
|
175 |
$rootPath="/usr/lib/";
|
|
|
176 |
|
|
|
177 |
#預設的套件資料夾名稱
|
|
|
178 |
$name="qbpwcf";
|
|
|
179 |
|
|
|
180 |
#預設運作模式為 "link" 亦即建立軟連結
|
|
|
181 |
$mode="link";
|
|
|
182 |
|
|
|
183 |
#預設不指定自己的IP
|
|
|
184 |
$ip="";
|
|
|
185 |
|
|
|
186 |
#預設的資料庫連線帳號
|
|
|
187 |
$dbAcct="root";
|
|
|
188 |
|
|
|
189 |
#預設的資料庫連線密碼
|
|
|
190 |
$dbPass=$uuid["content"];
|
|
|
191 |
|
|
|
192 |
#預設的資料庫名稱
|
|
|
193 |
$dbName="test";
|
|
|
194 |
|
|
|
195 |
#預設到資料庫位置
|
|
|
196 |
$dbAddr="localhost";
|
|
|
197 |
|
|
|
198 |
#預設的資料庫port
|
|
|
199 |
$dbPort="3306";
|
|
|
200 |
|
| 405 |
liveuser |
201 |
#預設要有自動輸出的內容
|
|
|
202 |
$headless="false";
|
|
|
203 |
|
| 402 |
liveuser |
204 |
#檢查參數
|
|
|
205 |
#函式說明:
|
|
|
206 |
#檢查必填與可省略的參數,可省略參數可指定預設要給與什麼數值內容.
|
|
|
207 |
#回傳結果:
|
|
|
208 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
209 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
210 |
#$result["function"],當前執行的函式名稱.
|
|
|
211 |
#$result["argu"],設置給予的參數.
|
|
|
212 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
213 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
214 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
215 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
216 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
217 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
218 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
219 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
220 |
#必填參數:
|
|
|
221 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
222 |
$conf["varInput"]=&$parseArgu["content"];
|
|
|
223 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
224 |
$conf["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
225 |
#可省略參數:
|
|
|
226 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
227 |
#$conf["mustBeFilledVariableName"]=array("");
|
|
|
228 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
|
|
|
229 |
#$conf["mustBeFilledVariableType"]=array();
|
|
|
230 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
231 |
#$conf["canBeEmptyString"]="false";
|
|
|
232 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
233 |
#$conf["canNotBeEmpty"]=array();
|
|
|
234 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
235 |
#$conf["canBeEmpty"]=array();
|
|
|
236 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
| 405 |
liveuser |
237 |
$conf["skipableVariableCanNotBeEmpty"]=array("rootPath","name","mode","ip","dbAcct","dbPass","dbName","dbAddr","dbPort","headless");
|
| 402 |
liveuser |
238 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
| 405 |
liveuser |
239 |
$conf["skipableVariableName"]=array("rootPath","name","mode","ip","dbAcct","dbPass","dbName","dbAddr","dbPort","headless");
|
| 402 |
liveuser |
240 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
| 405 |
liveuser |
241 |
$conf["skipableVariableType"]=array("array","array","array","array","array","array","array","array","array","array");
|
| 402 |
liveuser |
242 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
243 |
$conf["skipableVarDefaultValue"]=array(null,null,null,null);
|
|
|
244 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
|
|
245 |
#$conf["disallowAllSkipableVarIsEmpty"]="";
|
|
|
246 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
|
|
247 |
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
|
|
|
248 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
| 405 |
liveuser |
249 |
$conf["arrayCountEqualCheck"][]=array("rootPath","name","mode","ip","dbAcct","dbPass","dbName","dbAddr","dbPort","headless");
|
| 402 |
liveuser |
250 |
#參考資料:
|
|
|
251 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
252 |
#備註:
|
|
|
253 |
#無.
|
|
|
254 |
$checkArguments=variableCheck::checkArguments($conf);
|
|
|
255 |
unset($conf);
|
|
|
256 |
|
|
|
257 |
#如果有設置參數
|
|
|
258 |
if(count($parseArgu["content"])>0){
|
|
|
259 |
|
|
|
260 |
#如果有 rootPath 參數
|
|
|
261 |
if(isset($parseArgu["content"]["rootPath"])){
|
|
|
262 |
|
|
|
263 |
#如果有 rootPath 參數存在
|
|
|
264 |
if(isset($parseArgu["content"]["rootPath"][0])){
|
|
|
265 |
|
|
|
266 |
#更新套件的安裝位置
|
|
|
267 |
$rootPath=$parseArgu["content"]["rootPath"][0];
|
|
|
268 |
|
|
|
269 |
}#if end
|
|
|
270 |
|
|
|
271 |
}#if enf
|
|
|
272 |
|
|
|
273 |
#如果有 name 參數
|
|
|
274 |
if(isset($parseArgu["content"]["name"])){
|
|
|
275 |
|
|
|
276 |
#如果有 name 參數存在
|
|
|
277 |
if(isset($parseArgu["content"]["name"][0])){
|
|
|
278 |
|
|
|
279 |
#更新套件的資料夾名稱
|
|
|
280 |
$name=$parseArgu["content"]["name"][0];
|
|
|
281 |
|
|
|
282 |
}#if end
|
|
|
283 |
|
|
|
284 |
}#if end
|
|
|
285 |
|
|
|
286 |
#如果有 mode 參數
|
|
|
287 |
if(isset($parseArgu["content"]["mode"])){
|
|
|
288 |
|
|
|
289 |
#如果有 mode 參數存在
|
|
|
290 |
if(isset($parseArgu["content"]["mode"][0])){
|
|
|
291 |
|
|
|
292 |
#更新運作模式
|
|
|
293 |
$mode=$parseArgu["content"]["mode"][0];
|
|
|
294 |
|
|
|
295 |
}#if end
|
|
|
296 |
|
|
|
297 |
}#if end
|
|
|
298 |
|
|
|
299 |
#如果有 ip 參數
|
|
|
300 |
if(isset($parseArgu["content"]["ip"])){
|
|
|
301 |
|
|
|
302 |
#如果有 ip 參數存在
|
|
|
303 |
if(isset($parseArgu["content"]["ip"][0])){
|
|
|
304 |
|
|
|
305 |
#更新ip
|
|
|
306 |
$ip=$parseArgu["content"]["ip"][0];
|
|
|
307 |
|
|
|
308 |
}#if end
|
|
|
309 |
|
|
|
310 |
}#if end
|
|
|
311 |
|
|
|
312 |
#如果有 dbAcct 參數
|
|
|
313 |
if(isset($parseArgu["content"]["dbAcct"])){
|
|
|
314 |
|
|
|
315 |
#如果有 dbAcct 參數存在
|
|
|
316 |
if(isset($parseArgu["content"]["dbAcct"][0])){
|
|
|
317 |
|
|
|
318 |
#更新 dbAcct
|
|
|
319 |
$dbAcct=$parseArgu["content"]["dbAcct"][0];
|
|
|
320 |
|
|
|
321 |
}#if end
|
|
|
322 |
|
|
|
323 |
}#if end
|
|
|
324 |
|
|
|
325 |
#如果有 dbPass 參數
|
|
|
326 |
if(isset($parseArgu["content"]["dbPass"])){
|
|
|
327 |
|
|
|
328 |
#如果有 dbPass 參數存在
|
|
|
329 |
if(isset($parseArgu["content"]["dbPass"][0])){
|
|
|
330 |
|
|
|
331 |
#更新 dbPass
|
|
|
332 |
$dbPass=$parseArgu["content"]["dbPass"][0];
|
|
|
333 |
|
|
|
334 |
}#if end
|
|
|
335 |
|
|
|
336 |
}#if end
|
|
|
337 |
|
|
|
338 |
#如果有 dbName 參數
|
|
|
339 |
if(isset($parseArgu["content"]["dbName"])){
|
|
|
340 |
|
|
|
341 |
#如果有 dbName 參數存在
|
|
|
342 |
if(isset($parseArgu["content"]["dbName"][0])){
|
|
|
343 |
|
|
|
344 |
#更新 dbName
|
|
|
345 |
$dbName=$parseArgu["content"]["dbName"][0];
|
|
|
346 |
|
|
|
347 |
}#if end
|
|
|
348 |
|
|
|
349 |
}#if end
|
|
|
350 |
|
|
|
351 |
#如果有 dbAddr 參數
|
|
|
352 |
if(isset($parseArgu["content"]["dbAddr"])){
|
|
|
353 |
|
|
|
354 |
#如果有 dbAddr 參數存在
|
|
|
355 |
if(isset($parseArgu["content"]["dbAddr"][0])){
|
|
|
356 |
|
|
|
357 |
#更新 dbAddr
|
|
|
358 |
$dbAddr=$parseArgu["content"]["dbAddr"][0];
|
|
|
359 |
|
|
|
360 |
}#if end
|
|
|
361 |
|
|
|
362 |
}#if end
|
|
|
363 |
|
|
|
364 |
#如果有 dbPort 參數
|
|
|
365 |
if(isset($parseArgu["content"]["dbPort"])){
|
|
|
366 |
|
|
|
367 |
#如果有 dbPort 參數存在
|
|
|
368 |
if(isset($parseArgu["content"]["dbPort"][0])){
|
|
|
369 |
|
|
|
370 |
#更新 dbPort
|
|
|
371 |
$dbPort=$parseArgu["content"]["dbPort"][0];
|
|
|
372 |
|
|
|
373 |
}#if end
|
|
|
374 |
|
|
|
375 |
}#if end
|
| 405 |
liveuser |
376 |
|
|
|
377 |
#如果有 headless 參數
|
|
|
378 |
if(isset($parseArgu["content"]["headless"])){
|
|
|
379 |
|
|
|
380 |
#如果有 headless 參數存在
|
|
|
381 |
if(isset($parseArgu["content"]["headless"][0])){
|
|
|
382 |
|
|
|
383 |
#更新 headless
|
|
|
384 |
$headless=$parseArgu["content"]["headless"][0];
|
|
|
385 |
|
|
|
386 |
}#if end
|
|
|
387 |
|
|
|
388 |
}#if end
|
| 402 |
liveuser |
389 |
|
|
|
390 |
}#if end
|
|
|
391 |
|
| 405 |
liveuser |
392 |
#如果要使用不自動輸出內容的 allInOneForCI.php 檔案
|
|
|
393 |
if($headless==="true"){
|
|
|
394 |
|
|
|
395 |
#函式說明:
|
|
|
396 |
#建立軟連結.
|
|
|
397 |
#回傳結果:
|
|
|
398 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
399 |
#$result["error"],錯誤訊息.
|
|
|
400 |
#$result["function"],當前執行的函數名稱.
|
|
|
401 |
#$result["content"],軟連結的資訊.
|
|
|
402 |
#必填參數:
|
|
|
403 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
404 |
$conf["fileArgu"]=__FILE__;
|
|
|
405 |
#$conf["linkTo"],字串,軟連結要指向哪邊.
|
|
|
406 |
$conf["linkTo"]="qbpwcf/allInOneForCI.php";
|
|
|
407 |
#可省略參數:
|
|
|
408 |
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
|
|
|
409 |
$conf["path"]="qbpwcf";
|
|
|
410 |
#$conf["name"],字串,軟連結的名稱,預設為 "linkTo" 參數的檔案或目錄名稱.
|
|
|
411 |
$conf["name"]="allInOne.php";
|
| 414 |
liveuser |
412 |
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
|
|
|
413 |
$conf["overWrite"]="true";
|
| 405 |
liveuser |
414 |
#參考資料:
|
|
|
415 |
#無.
|
|
|
416 |
#備註:
|
|
|
417 |
#無.
|
|
|
418 |
$createLink=fileAccess::createLink($conf);
|
|
|
419 |
unset($conf);
|
|
|
420 |
|
| 414 |
liveuser |
421 |
#var_dump($createLink);
|
|
|
422 |
|
| 405 |
liveuser |
423 |
#如果執行失敗
|
|
|
424 |
if($createLink["status"]==="false"){
|
|
|
425 |
|
|
|
426 |
#函式說明:
|
|
|
427 |
#撰寫log
|
|
|
428 |
#回傳結果:
|
|
|
429 |
#$result["status"],狀態,"true"或"false".
|
|
|
430 |
#$result["error"],錯誤訊息陣列.
|
|
|
431 |
#$result["function"],當前函式的名稱.
|
|
|
432 |
#$result["argu"],使用的參數.
|
|
|
433 |
#必填參數:
|
|
|
434 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
435 |
$conf["path"]=$logFile;
|
|
|
436 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
437 |
$conf["content"]=$createLink;
|
|
|
438 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
439 |
$conf["fileArgu"]=__FILE__;
|
|
|
440 |
#可省略參數:
|
|
|
441 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
442 |
#$conf["rewrite"]="false";
|
|
|
443 |
#參考資料:
|
|
|
444 |
#無.
|
|
|
445 |
#備註:
|
|
|
446 |
#無.
|
|
|
447 |
$record=logs::record($conf);
|
|
|
448 |
|
|
|
449 |
#如果執行失敗
|
|
|
450 |
if($record["status"]==="false"){
|
|
|
451 |
|
|
|
452 |
#印出結果
|
|
|
453 |
var_dump($record);
|
|
|
454 |
|
|
|
455 |
}#if end
|
| 409 |
liveuser |
456 |
|
|
|
457 |
#異常結束執行
|
|
|
458 |
exit(1);
|
| 405 |
liveuser |
459 |
|
|
|
460 |
}#if end
|
|
|
461 |
|
|
|
462 |
}#if end
|
|
|
463 |
|
| 402 |
liveuser |
464 |
#讓 "qbpwcf/usr/bin" 底下的所有檔案為可執行.
|
|
|
465 |
#函式說明:
|
|
|
466 |
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
|
|
|
467 |
#回傳結果:
|
|
|
468 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
469 |
#$result["error"],錯誤訊息.
|
|
|
470 |
#$result["function"],當前執行的函式名稱.
|
|
|
471 |
#必填參數:
|
|
|
472 |
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
|
|
|
473 |
$conf["mode"]="+x";
|
|
|
474 |
#$conf["target"],字串,需要變更權限的目標.
|
|
|
475 |
$conf["target"]="qbpwcf/usr/bin";
|
|
|
476 |
#可省略參數:
|
|
|
477 |
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
|
|
|
478 |
$conf["recursive"]="true";
|
|
|
479 |
#參考資料:
|
|
|
480 |
#無.
|
|
|
481 |
#備註:
|
|
|
482 |
#無.
|
|
|
483 |
$chmod=cmd::chmod($conf);
|
|
|
484 |
unset($conf);
|
|
|
485 |
|
|
|
486 |
#如果執行失敗
|
| 409 |
liveuser |
487 |
if($chmod["status"]==="false"){
|
| 402 |
liveuser |
488 |
|
|
|
489 |
#函式說明:
|
|
|
490 |
#撰寫log
|
|
|
491 |
#回傳結果:
|
|
|
492 |
#$result["status"],狀態,"true"或"false".
|
|
|
493 |
#$result["error"],錯誤訊息陣列.
|
|
|
494 |
#$result["function"],當前函式的名稱.
|
|
|
495 |
#$result["argu"],使用的參數.
|
|
|
496 |
#必填參數:
|
|
|
497 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
498 |
$conf["path"]=$logFile;
|
|
|
499 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
500 |
$conf["content"]=$chmod;
|
|
|
501 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
502 |
$conf["fileArgu"]=__FILE__;
|
|
|
503 |
#可省略參數:
|
|
|
504 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
505 |
#$conf["rewrite"]="false";
|
|
|
506 |
#參考資料:
|
|
|
507 |
#無.
|
|
|
508 |
#備註:
|
|
|
509 |
#無.
|
|
|
510 |
$record=logs::record($conf);
|
|
|
511 |
|
|
|
512 |
#如果執行失敗
|
|
|
513 |
if($record["status"]==="false"){
|
|
|
514 |
|
|
|
515 |
#印出結果
|
|
|
516 |
var_dump($record);
|
|
|
517 |
|
|
|
518 |
}#if end
|
| 409 |
liveuser |
519 |
|
|
|
520 |
#異常結束執行
|
|
|
521 |
exit(1);
|
| 402 |
liveuser |
522 |
|
|
|
523 |
}#if end
|
|
|
524 |
|
|
|
525 |
#讓 "qbpwcf/db" 可以被大家使用.
|
|
|
526 |
#函式說明:
|
|
|
527 |
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
|
|
|
528 |
#回傳結果:
|
|
|
529 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
530 |
#$result["error"],錯誤訊息.
|
|
|
531 |
#$result["function"],當前執行的函式名稱.
|
|
|
532 |
#必填參數:
|
|
|
533 |
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
|
|
|
534 |
$conf["mode"]="777";
|
|
|
535 |
#$conf["target"],字串,需要變更權限的目標.
|
|
|
536 |
$conf["target"]="qbpwcf/db";
|
|
|
537 |
#可省略參數:
|
|
|
538 |
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
|
|
|
539 |
#$conf["recursive"]="";
|
|
|
540 |
#參考資料:
|
|
|
541 |
#無.
|
|
|
542 |
#備註:
|
|
|
543 |
#無.
|
|
|
544 |
$chmod=cmd::chmod($conf);
|
|
|
545 |
unset($conf);
|
|
|
546 |
|
|
|
547 |
#如果執行失敗
|
|
|
548 |
if($chmod["status"]==="false"){
|
|
|
549 |
|
|
|
550 |
#函式說明:
|
|
|
551 |
#撰寫log
|
|
|
552 |
#回傳結果:
|
|
|
553 |
#$result["status"],狀態,"true"或"false".
|
|
|
554 |
#$result["error"],錯誤訊息陣列.
|
|
|
555 |
#$result["function"],當前函式的名稱.
|
|
|
556 |
#$result["argu"],使用的參數.
|
|
|
557 |
#必填參數:
|
|
|
558 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
559 |
$conf["path"]=$logFile;
|
|
|
560 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
561 |
$conf["content"]=$chmod;
|
|
|
562 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
563 |
$conf["fileArgu"]=__FILE__;
|
|
|
564 |
#可省略參數:
|
|
|
565 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
566 |
#$conf["rewrite"]="false";
|
|
|
567 |
#參考資料:
|
|
|
568 |
#無.
|
|
|
569 |
#備註:
|
|
|
570 |
#無.
|
|
|
571 |
$record=logs::record($conf);
|
|
|
572 |
|
|
|
573 |
#如果執行失敗
|
|
|
574 |
if($record["status"]==="false"){
|
|
|
575 |
|
|
|
576 |
#印出結果
|
|
|
577 |
var_dump($record);
|
|
|
578 |
|
|
|
579 |
}#if end
|
| 409 |
liveuser |
580 |
|
|
|
581 |
#異常結束執行
|
|
|
582 |
exit(1);
|
| 402 |
liveuser |
583 |
|
|
|
584 |
}#if end
|
|
|
585 |
|
|
|
586 |
#如果 ip 有指定
|
|
|
587 |
if($ip!==""){
|
|
|
588 |
|
|
|
589 |
#依照參數設定 $rootPath.$name."/etc/config.php
|
|
|
590 |
#函式說明:
|
|
|
591 |
#建立軟連結.
|
|
|
592 |
#回傳結果:
|
|
|
593 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
594 |
#$result["error"],錯誤訊息.
|
|
|
595 |
#$result["function"],當前執行的函數名稱.
|
|
|
596 |
#$result["content"],軟連結的資訊.
|
|
|
597 |
#必填參數:
|
|
|
598 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
599 |
$conf["fileArgu"]=__FILE__;
|
|
|
600 |
#$conf["file"],字串,要更新的檔案位置與名稱.
|
|
|
601 |
$conf["file"]="qbpwcf/etc/config.php";
|
|
|
602 |
#可省略參數:
|
|
|
603 |
#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
|
|
|
604 |
$conf["overWriteWith"]=array("<?php","\$ip="."\"".$ip."\";","?>");
|
|
|
605 |
#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
|
|
|
606 |
#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
|
|
|
607 |
#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
|
|
|
608 |
#$conf["addToTailWhenNoMatch"]="false";
|
|
|
609 |
#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
|
|
|
610 |
#$conf["addToTailBeforeThat"]="?\>";
|
|
|
611 |
#參考資料:
|
|
|
612 |
#無.
|
|
|
613 |
#備註:
|
|
|
614 |
#無.
|
|
|
615 |
$updateFile=fileaAccess::updateFile($conf);
|
|
|
616 |
unset($conf);
|
|
|
617 |
|
|
|
618 |
#如果執行失敗
|
|
|
619 |
if($updateFile["status"]==="false"){
|
|
|
620 |
|
|
|
621 |
#函式說明:
|
|
|
622 |
#撰寫log
|
|
|
623 |
#回傳結果:
|
|
|
624 |
#$result["status"],狀態,"true"或"false".
|
|
|
625 |
#$result["error"],錯誤訊息陣列.
|
|
|
626 |
#$result["function"],當前函式的名稱.
|
|
|
627 |
#$result["argu"],使用的參數.
|
|
|
628 |
#必填參數:
|
|
|
629 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
630 |
$conf["path"]=$logFile;
|
|
|
631 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
632 |
$conf["content"]=$updateFile;
|
|
|
633 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
634 |
$conf["fileArgu"]=__FILE__;
|
|
|
635 |
#可省略參數:
|
|
|
636 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
637 |
#$conf["rewrite"]="false";
|
|
|
638 |
#參考資料:
|
|
|
639 |
#無.
|
|
|
640 |
#備註:
|
|
|
641 |
#無.
|
|
|
642 |
$record=logs::record($conf);
|
|
|
643 |
|
|
|
644 |
#如果執行失敗
|
|
|
645 |
if($record["status"]==="false"){
|
|
|
646 |
|
|
|
647 |
#印出結果
|
|
|
648 |
var_dump($record);
|
|
|
649 |
|
|
|
650 |
}#if end
|
| 409 |
liveuser |
651 |
|
|
|
652 |
#異常結束執行
|
|
|
653 |
exit(1);
|
| 402 |
liveuser |
654 |
|
|
|
655 |
}#if end
|
|
|
656 |
|
|
|
657 |
}#if end
|
|
|
658 |
|
|
|
659 |
#依照參數設定 "qbpwcf/usr/local/etc/backupDb.conf"
|
|
|
660 |
#函式說明:
|
|
|
661 |
#建立軟連結.
|
|
|
662 |
#回傳結果:
|
|
|
663 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
664 |
#$result["error"],錯誤訊息.
|
|
|
665 |
#$result["function"],當前執行的函數名稱.
|
|
|
666 |
#$result["content"],軟連結的資訊.
|
|
|
667 |
#必填參數:
|
|
|
668 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
669 |
$conf["fileArgu"]=__FILE__;
|
|
|
670 |
#$conf["file"],字串,要更新的檔案位置與名稱.
|
|
|
671 |
$conf["file"]="qbpwcf/usr/local/etc/backupDb.conf";
|
|
|
672 |
#可省略參數:
|
|
|
673 |
#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
|
|
|
674 |
$conf["overWriteWith"]=array();
|
|
|
675 |
$conf["overWriteWith"][]="<?php";
|
|
|
676 |
$conf["overWriteWith"][]="#資料庫連線帳號";
|
|
|
677 |
$conf["overWriteWith"][]="\$dbAcct=\"".$dbAcct."\";";
|
|
|
678 |
$conf["overWriteWith"][]="";
|
|
|
679 |
$conf["overWriteWith"][]="#資料庫連線密碼";
|
|
|
680 |
$conf["overWriteWith"][]="\$dbPass=\"".$dbPass."\";";
|
|
|
681 |
$conf["overWriteWith"][]="";
|
|
|
682 |
$conf["overWriteWith"][]="#資料庫名稱";
|
|
|
683 |
$conf["overWriteWith"][]="\$dbName=\"".$dbName."\";";
|
|
|
684 |
$conf["overWriteWith"][]="";
|
|
|
685 |
$conf["overWriteWith"][]="#資料庫位置";
|
|
|
686 |
$conf["overWriteWith"][]="\$dbAddr=\"".$dbAddr."\";";
|
|
|
687 |
$conf["overWriteWith"][]="";
|
|
|
688 |
$conf["overWriteWith"][]="#資料庫port";
|
|
|
689 |
$conf["overWriteWith"][]="\$dbPort=\"".$dbPort."\";";
|
|
|
690 |
#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
|
|
|
691 |
#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
|
|
|
692 |
#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
|
|
|
693 |
#$conf["addToTailWhenNoMatch"]="false";
|
|
|
694 |
#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
|
|
|
695 |
#$conf["addToTailBeforeThat"]="?\>";
|
|
|
696 |
#參考資料:
|
|
|
697 |
#無.
|
|
|
698 |
#備註:
|
|
|
699 |
#無.
|
| 409 |
liveuser |
700 |
$updateFile=fileAccess::updateFile($conf);
|
| 402 |
liveuser |
701 |
unset($conf);
|
|
|
702 |
|
|
|
703 |
#如果執行失敗
|
|
|
704 |
if($updateFile["status"]==="false"){
|
|
|
705 |
|
|
|
706 |
#函式說明:
|
|
|
707 |
#撰寫log
|
|
|
708 |
#回傳結果:
|
|
|
709 |
#$result["status"],狀態,"true"或"false".
|
|
|
710 |
#$result["error"],錯誤訊息陣列.
|
|
|
711 |
#$result["function"],當前函式的名稱.
|
|
|
712 |
#$result["argu"],使用的參數.
|
|
|
713 |
#必填參數:
|
|
|
714 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
715 |
$conf["path"]=$logFile;
|
|
|
716 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
717 |
$conf["content"]=$updateFile;
|
|
|
718 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
719 |
$conf["fileArgu"]=__FILE__;
|
|
|
720 |
#可省略參數:
|
|
|
721 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
722 |
#$conf["rewrite"]="false";
|
|
|
723 |
#參考資料:
|
|
|
724 |
#無.
|
|
|
725 |
#備註:
|
|
|
726 |
#無.
|
|
|
727 |
$record=logs::record($conf);
|
|
|
728 |
|
|
|
729 |
#如果執行失敗
|
|
|
730 |
if($record["status"]==="false"){
|
|
|
731 |
|
|
|
732 |
#印出結果
|
|
|
733 |
var_dump($record);
|
|
|
734 |
|
|
|
735 |
}#if end
|
| 409 |
liveuser |
736 |
|
|
|
737 |
#異常結束執行
|
|
|
738 |
exit(1);
|
| 402 |
liveuser |
739 |
|
|
|
740 |
}#if end
|
|
|
741 |
|
|
|
742 |
#重新建置 qbpwcf/usr/local/etc/qbpwcf.conf.xml
|
|
|
743 |
#函式說明:
|
|
|
744 |
#建立軟連結.
|
|
|
745 |
#回傳結果:
|
|
|
746 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
747 |
#$result["error"],錯誤訊息.
|
|
|
748 |
#$result["function"],當前執行的函數名稱.
|
|
|
749 |
#$result["content"],軟連結的資訊.
|
|
|
750 |
#必填參數:
|
|
|
751 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
752 |
$conf["fileArgu"]=__FILE__;
|
|
|
753 |
#$conf["file"],字串,要更新的檔案位置與名稱.
|
|
|
754 |
$conf["file"]="qbpwcf/usr/local/etc/qbpwcf.conf.xml";
|
|
|
755 |
#可省略參數:
|
|
|
756 |
#$conf["overWriteWith"],字串陣列,要置換成什麼樣的內容,每個元素代表一行內容.
|
|
|
757 |
$conf["overWriteWith"]=array();
|
|
|
758 |
$conf["overWriteWith"][]="<?xml version=\"1.0\"?>";
|
|
|
759 |
$conf["overWriteWith"][]="<root></root>";
|
|
|
760 |
#$conf["replaceWith"],字串陣列,要將什麼內容置換成什麼內容.
|
|
|
761 |
#conf["replaceWith"]=array(array("ori content","new content"),array("ori content","new content"),...);
|
|
|
762 |
#$conf["addToTailWhenNoMatch"],字串,預設為"false"不做事;若為"true",則代表若使用 "replaceWith" 參數但沒有符合條件的內容出現,則新增到檔案的尾端.
|
|
|
763 |
#$conf["addToTailWhenNoMatch"]="false";
|
|
|
764 |
#$conf["addToTailBeforeThat"],字串,當 "replaceWith" 參數有使用,且 "addToTailWhenNoMatch" 為 "true" 時,若有使用該參數,則會從尾端尋找符合條件的行內容,然後將 沒有符合 "replaceWith" 條件的內容新增在此之前.
|
|
|
765 |
#$conf["addToTailBeforeThat"]="?\>";
|
|
|
766 |
#參考資料:
|
|
|
767 |
#無.
|
|
|
768 |
#備註:
|
|
|
769 |
#無.
|
| 409 |
liveuser |
770 |
$updateFile=fileAccess::updateFile($conf);
|
| 402 |
liveuser |
771 |
unset($conf);
|
|
|
772 |
|
|
|
773 |
#如果執行失敗
|
|
|
774 |
if($updateFile["status"]==="false"){
|
|
|
775 |
|
|
|
776 |
#函式說明:
|
|
|
777 |
#撰寫log
|
|
|
778 |
#回傳結果:
|
|
|
779 |
#$result["status"],狀態,"true"或"false".
|
|
|
780 |
#$result["error"],錯誤訊息陣列.
|
|
|
781 |
#$result["function"],當前函式的名稱.
|
|
|
782 |
#$result["argu"],使用的參數.
|
|
|
783 |
#必填參數:
|
|
|
784 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
785 |
$conf["path"]=$logFile;
|
|
|
786 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
787 |
$conf["content"]=$updateFile;
|
|
|
788 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
789 |
$conf["fileArgu"]=__FILE__;
|
|
|
790 |
#可省略參數:
|
|
|
791 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
792 |
#$conf["rewrite"]="false";
|
|
|
793 |
#參考資料:
|
|
|
794 |
#無.
|
|
|
795 |
#備註:
|
|
|
796 |
#無.
|
|
|
797 |
$record=logs::record($conf);
|
|
|
798 |
|
|
|
799 |
#如果執行失敗
|
|
|
800 |
if($record["status"]==="false"){
|
|
|
801 |
|
|
|
802 |
#印出結果
|
|
|
803 |
var_dump($record);
|
|
|
804 |
|
|
|
805 |
}#if end
|
| 409 |
liveuser |
806 |
|
|
|
807 |
#異常結束執行
|
|
|
808 |
exit(1);
|
| 402 |
liveuser |
809 |
|
|
|
810 |
}#if end
|
|
|
811 |
|
|
|
812 |
#讓 "qbpwcf/usr/local/etc/qbpwcf.conf.xml" 可以被大家使用.
|
|
|
813 |
#函式說明:
|
|
|
814 |
#使用 linux 的 chmod 指令來修改目標檔案或目錄的權限.
|
|
|
815 |
#回傳結果:
|
|
|
816 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
817 |
#$result["error"],錯誤訊息.
|
|
|
818 |
#$result["function"],當前執行的函式名稱.
|
|
|
819 |
#必填參數:
|
|
|
820 |
#$conf["mode"],字串,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
|
|
|
821 |
$conf["mode"]="777";
|
|
|
822 |
#$conf["target"],字串,需要變更權限的目標.
|
|
|
823 |
$conf["target"]="qbpwcf/usr/local/etc/qbpwcf.conf.xml";
|
|
|
824 |
#可省略參數:
|
|
|
825 |
#$conf["recursive"],字串,"true"代表目標目錄底下的內容都要套用,預設為"false".
|
|
|
826 |
#$conf["recursive"]="";
|
|
|
827 |
#參考資料:
|
|
|
828 |
#無.
|
|
|
829 |
#備註:
|
|
|
830 |
#無.
|
|
|
831 |
$chmod=cmd::chmod($conf);
|
|
|
832 |
unset($conf);
|
|
|
833 |
|
|
|
834 |
#如果執行失敗
|
|
|
835 |
if($chmod["status"]==="false"){
|
|
|
836 |
|
|
|
837 |
#函式說明:
|
|
|
838 |
#撰寫log
|
|
|
839 |
#回傳結果:
|
|
|
840 |
#$result["status"],狀態,"true"或"false".
|
|
|
841 |
#$result["error"],錯誤訊息陣列.
|
|
|
842 |
#$result["function"],當前函式的名稱.
|
|
|
843 |
#$result["argu"],使用的參數.
|
|
|
844 |
#必填參數:
|
|
|
845 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
846 |
$conf["path"]=$logFile;
|
|
|
847 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
848 |
$conf["content"]=$chmod;
|
|
|
849 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
850 |
$conf["fileArgu"]=__FILE__;
|
|
|
851 |
#可省略參數:
|
|
|
852 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
853 |
#$conf["rewrite"]="false";
|
|
|
854 |
#參考資料:
|
|
|
855 |
#無.
|
|
|
856 |
#備註:
|
|
|
857 |
#無.
|
|
|
858 |
$record=logs::record($conf);
|
|
|
859 |
|
|
|
860 |
#如果執行失敗
|
|
|
861 |
if($record["status"]==="false"){
|
|
|
862 |
|
|
|
863 |
#印出結果
|
|
|
864 |
var_dump($record);
|
|
|
865 |
|
|
|
866 |
}#if end
|
| 409 |
liveuser |
867 |
|
|
|
868 |
#異常結束執行
|
|
|
869 |
exit(1);
|
| 402 |
liveuser |
870 |
|
|
|
871 |
}#if end
|
|
|
872 |
|
|
|
873 |
#判斷 $mode
|
|
|
874 |
switch($mode){
|
|
|
875 |
|
|
|
876 |
#如果是 "cp" mode
|
|
|
877 |
case "cp":
|
|
|
878 |
|
|
|
879 |
#函式說明:
|
|
|
880 |
#建立資料夾,若要建立的資料夾所屬路徑不存在,則會自動嘗試建立,建立後的資料夾也可指定權限,要設定權限,必須為資料夾的擁有者.
|
|
|
881 |
#回傳結果:
|
|
|
882 |
#$result["status"],"true"爲建立成功,"false"爲建立失敗.
|
|
|
883 |
#$result["error"],錯誤訊息陣列
|
|
|
884 |
#$result["warning"],警告訊息陣列
|
|
|
885 |
#$result["argu"],使用的參數.
|
|
|
886 |
#$result["content"],建立的目錄路徑.
|
|
|
887 |
#必填參數:
|
|
|
888 |
#$conf["dirPositionAndName"]="";#新建的位置與名稱
|
|
|
889 |
$conf["dirPositionAndName"]=$rootPath.$name;
|
|
|
890 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
891 |
$conf["fileArgu"]=__FILE__;
|
|
|
892 |
#可省略參數:
|
|
|
893 |
#$conf["dirPermission"],字串,新建資料夾的權限設定,預設爲0770,亦即擁有者,同群組者可以讀,寫,存取,其他人僅能存取.
|
|
|
894 |
#$conf["dirPermission"]="";
|
|
|
895 |
#$conf["web"],"false"代表在檔案系統環境,"true"代表在網頁稀系統環境.
|
|
|
896 |
#$conf["web"]="false";
|
|
|
897 |
#參考資料:
|
|
|
898 |
#mkdir=>http://php.net/manual/en/function.mkdir.php
|
|
|
899 |
#chmod=>http://php.net/manual/en/function.chmod.php
|
|
|
900 |
#備註:
|
|
|
901 |
#無.
|
|
|
902 |
$createFolderAfterCheck=fileAccess::createFolderAfterCheck($conf);
|
|
|
903 |
unset($conf);
|
|
|
904 |
|
|
|
905 |
#如果執行失敗
|
|
|
906 |
if($createFolderAfterCheck["status"]==="false"){
|
|
|
907 |
|
|
|
908 |
#函式說明:
|
|
|
909 |
#撰寫log
|
|
|
910 |
#回傳結果:
|
|
|
911 |
#$result["status"],狀態,"true"或"false".
|
|
|
912 |
#$result["error"],錯誤訊息陣列.
|
|
|
913 |
#$result["function"],當前函式的名稱.
|
|
|
914 |
#$result["argu"],使用的參數.
|
|
|
915 |
#必填參數:
|
|
|
916 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
917 |
$conf["path"]=$logFile;
|
|
|
918 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
919 |
$conf["content"]=$createFolderAfterCheck;
|
|
|
920 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
921 |
$conf["fileArgu"]=__FILE__;
|
|
|
922 |
#可省略參數:
|
|
|
923 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
924 |
#$conf["rewrite"]="false";
|
|
|
925 |
#參考資料:
|
|
|
926 |
#無.
|
|
|
927 |
#備註:
|
|
|
928 |
#無.
|
|
|
929 |
$record=logs::record($conf);
|
|
|
930 |
|
|
|
931 |
#如果執行失敗
|
|
|
932 |
if($record["status"]==="false"){
|
|
|
933 |
|
|
|
934 |
#印出結果
|
|
|
935 |
var_dump($record);
|
|
|
936 |
|
|
|
937 |
}#if end
|
| 409 |
liveuser |
938 |
|
|
|
939 |
#異常結束執行
|
|
|
940 |
exit(1);
|
| 402 |
liveuser |
941 |
|
|
|
942 |
}#if end
|
|
|
943 |
|
|
|
944 |
#複製套件
|
|
|
945 |
#函式說明:
|
|
|
946 |
#複製檔案、資料夾.
|
|
|
947 |
#回傳結果:
|
|
|
948 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
949 |
#$result["error"],錯誤訊息.
|
|
|
950 |
#$result["function"],當前執行的函式名稱.
|
|
|
951 |
#$result["content"],複製好的檔案路徑與名稱.
|
|
|
952 |
#必填參數:
|
|
|
953 |
#$conf["file"],字串,檔案的位置與名稱.
|
|
|
954 |
$conf["file"]="../";
|
|
|
955 |
#$conf["to"],字串,檔案要複製到哪裡.
|
|
|
956 |
$conf["to"]=$rootPath.$name;
|
|
|
957 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
958 |
$conf["fileArgu"]=__FILE__;
|
|
|
959 |
#可省略參數:
|
|
|
960 |
#$conf["username"],字串,要以哪個使用者來執行,預設為執行該php程式的使用者.
|
|
|
961 |
#$conf["username"]="";
|
|
|
962 |
#$conf["password"],字串,使用者對應的密碼,預設不使用.
|
|
|
963 |
#$conf["password"]="";
|
|
|
964 |
#參考資料:
|
|
|
965 |
#無.
|
|
|
966 |
#備註:
|
|
|
967 |
#僅能在命令列環境下運行
|
|
|
968 |
$cp=cmd::cp($conf);
|
|
|
969 |
unset($conf);
|
|
|
970 |
|
|
|
971 |
#如果執行失敗
|
|
|
972 |
if($cp["status"]==="false"){
|
|
|
973 |
|
|
|
974 |
#函式說明:
|
|
|
975 |
#撰寫log
|
|
|
976 |
#回傳結果:
|
|
|
977 |
#$result["status"],狀態,"true"或"false".
|
|
|
978 |
#$result["error"],錯誤訊息陣列.
|
|
|
979 |
#$result["function"],當前函式的名稱.
|
|
|
980 |
#$result["argu"],使用的參數.
|
|
|
981 |
#必填參數:
|
|
|
982 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
983 |
$conf["path"]=$logFile;
|
|
|
984 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
985 |
$conf["content"]=$cp;
|
|
|
986 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
987 |
$conf["fileArgu"]=__FILE__;
|
|
|
988 |
#可省略參數:
|
|
|
989 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
990 |
#$conf["rewrite"]="false";
|
|
|
991 |
#參考資料:
|
|
|
992 |
#無.
|
|
|
993 |
#備註:
|
|
|
994 |
#無.
|
|
|
995 |
$record=logs::record($conf);
|
|
|
996 |
|
|
|
997 |
#如果執行失敗
|
|
|
998 |
if($record["status"]==="false"){
|
|
|
999 |
|
|
|
1000 |
#印出結果
|
|
|
1001 |
var_dump($record);
|
|
|
1002 |
|
|
|
1003 |
}#if end
|
|
|
1004 |
|
| 409 |
liveuser |
1005 |
#異常結束執行
|
|
|
1006 |
exit(1);
|
|
|
1007 |
|
| 402 |
liveuser |
1008 |
}#if end
|
|
|
1009 |
|
|
|
1010 |
break;
|
|
|
1011 |
|
|
|
1012 |
#如果是 "link" mode
|
|
|
1013 |
case "link":
|
|
|
1014 |
|
|
|
1015 |
#函式說明:
|
|
|
1016 |
#建立軟連結.
|
|
|
1017 |
#回傳結果:
|
|
|
1018 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1019 |
#$result["error"],錯誤訊息.
|
|
|
1020 |
#$result["function"],當前執行的函數名稱.
|
|
|
1021 |
#$result["content"],軟連結的資訊.
|
|
|
1022 |
#必填參數:
|
|
|
1023 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
1024 |
$conf["fileArgu"]=__FILE__;
|
|
|
1025 |
#$conf["linkTo"],字串,軟連結要指向哪邊.
|
| 409 |
liveuser |
1026 |
$conf["linkTo"]="qbpwcf";
|
| 402 |
liveuser |
1027 |
#可省略參數:
|
|
|
1028 |
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
|
| 409 |
liveuser |
1029 |
$conf["path"]=$rootPath;
|
| 402 |
liveuser |
1030 |
#$conf["name"],字串,軟連結的名稱,預設為 "linkTo" 參數的檔案或目錄名稱.
|
| 409 |
liveuser |
1031 |
$conf["name"]=$name;
|
|
|
1032 |
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
|
|
|
1033 |
$conf["overWrite"]="true";
|
| 402 |
liveuser |
1034 |
#參考資料:
|
|
|
1035 |
#無.
|
|
|
1036 |
#備註:
|
|
|
1037 |
#無.
|
|
|
1038 |
$createLink=fileAccess::createLink($conf);
|
|
|
1039 |
unset($conf);
|
|
|
1040 |
|
|
|
1041 |
#如果執行失敗
|
|
|
1042 |
if($createLink["status"]==="false"){
|
|
|
1043 |
|
|
|
1044 |
#函式說明:
|
|
|
1045 |
#撰寫log
|
|
|
1046 |
#回傳結果:
|
|
|
1047 |
#$result["status"],狀態,"true"或"false".
|
|
|
1048 |
#$result["error"],錯誤訊息陣列.
|
|
|
1049 |
#$result["function"],當前函式的名稱.
|
|
|
1050 |
#$result["argu"],使用的參數.
|
|
|
1051 |
#必填參數:
|
|
|
1052 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
1053 |
$conf["path"]=$logFile;
|
|
|
1054 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
1055 |
$conf["content"]=$createLink;
|
|
|
1056 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1057 |
$conf["fileArgu"]=__FILE__;
|
|
|
1058 |
#可省略參數:
|
|
|
1059 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
1060 |
#$conf["rewrite"]="false";
|
|
|
1061 |
#參考資料:
|
|
|
1062 |
#無.
|
|
|
1063 |
#備註:
|
|
|
1064 |
#無.
|
|
|
1065 |
$record=logs::record($conf);
|
|
|
1066 |
|
|
|
1067 |
#如果執行失敗
|
|
|
1068 |
if($record["status"]==="false"){
|
|
|
1069 |
|
|
|
1070 |
#印出結果
|
|
|
1071 |
var_dump($record);
|
|
|
1072 |
|
|
|
1073 |
}#if end
|
| 409 |
liveuser |
1074 |
|
|
|
1075 |
#異常結束執行
|
|
|
1076 |
exit(1);
|
| 402 |
liveuser |
1077 |
|
|
|
1078 |
}#if end
|
|
|
1079 |
|
|
|
1080 |
break;
|
|
|
1081 |
|
|
|
1082 |
default:
|
|
|
1083 |
|
|
|
1084 |
#函式說明:
|
|
|
1085 |
#撰寫log
|
|
|
1086 |
#回傳結果:
|
|
|
1087 |
#$result["status"],狀態,"true"或"false".
|
|
|
1088 |
#$result["error"],錯誤訊息陣列.
|
|
|
1089 |
#$result["function"],當前函式的名稱.
|
|
|
1090 |
#$result["argu"],使用的參數.
|
|
|
1091 |
#必填參數:
|
|
|
1092 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
1093 |
$conf["path"]=$logFile;
|
|
|
1094 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
1095 |
$conf["content"]="mode \"".$mode."\" not supported!";
|
|
|
1096 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1097 |
$conf["fileArgu"]=__FILE__;
|
|
|
1098 |
#可省略參數:
|
|
|
1099 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
1100 |
#$conf["rewrite"]="false";
|
|
|
1101 |
#參考資料:
|
|
|
1102 |
#無.
|
|
|
1103 |
#備註:
|
|
|
1104 |
#無.
|
|
|
1105 |
$record=logs::record($conf);
|
|
|
1106 |
|
|
|
1107 |
#如果執行失敗
|
|
|
1108 |
if($record["status"]==="false"){
|
|
|
1109 |
|
|
|
1110 |
#印出結果
|
|
|
1111 |
var_dump($record);
|
|
|
1112 |
|
|
|
1113 |
}#if end
|
| 409 |
liveuser |
1114 |
|
|
|
1115 |
#異常結束執行
|
|
|
1116 |
exit(1);
|
| 402 |
liveuser |
1117 |
|
|
|
1118 |
}#switch end
|
|
|
1119 |
|
|
|
1120 |
#於 /usr/bin 底下建立 $rootPath.$name."/usr/bin" 底下所有檔案的軟連結.
|
|
|
1121 |
#函式說明:
|
|
|
1122 |
#針對特定目錄下的內容建立軟連結.
|
|
|
1123 |
#回傳結果:
|
|
|
1124 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1125 |
#$result["error"],錯誤訊息.
|
|
|
1126 |
#$result["function"],當前執行的函數名稱.
|
|
|
1127 |
#$result["content"],字串陣列,每個建立的軟連結資訊.
|
|
|
1128 |
#必填參數:
|
|
|
1129 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
1130 |
$conf["fileArgu"]=__FILE__;
|
|
|
1131 |
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
|
|
|
1132 |
$conf["linkToDir"]=$rootPath.$name."/usr/bin";
|
|
|
1133 |
#可省略參數:
|
|
|
1134 |
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
|
|
|
1135 |
$conf["path"]="/usr/bin";
|
|
|
1136 |
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
|
|
|
1137 |
#$conf["name"]=array(array("oriName","newName"));
|
|
|
1138 |
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
|
|
|
1139 |
$conf["overWrite"]="true";
|
|
|
1140 |
#參考資料:
|
|
|
1141 |
#無.
|
|
|
1142 |
#備註:
|
|
|
1143 |
#無.
|
|
|
1144 |
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
|
|
|
1145 |
unset($conf);
|
|
|
1146 |
|
|
|
1147 |
#如果執行失敗
|
|
|
1148 |
if($createMultiLinkInDir["status"]==="false"){
|
|
|
1149 |
|
|
|
1150 |
#函式說明:
|
|
|
1151 |
#撰寫log
|
|
|
1152 |
#回傳結果:
|
|
|
1153 |
#$result["status"],狀態,"true"或"false".
|
|
|
1154 |
#$result["error"],錯誤訊息陣列.
|
|
|
1155 |
#$result["function"],當前函式的名稱.
|
|
|
1156 |
#$result["argu"],使用的參數.
|
|
|
1157 |
#必填參數:
|
|
|
1158 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
1159 |
$conf["path"]=$logFile;
|
|
|
1160 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
1161 |
$conf["content"]=$createMultiLinkInDir;
|
|
|
1162 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1163 |
$conf["fileArgu"]=__FILE__;
|
|
|
1164 |
#可省略參數:
|
|
|
1165 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
1166 |
#$conf["rewrite"]="false";
|
|
|
1167 |
#參考資料:
|
|
|
1168 |
#無.
|
|
|
1169 |
#備註:
|
|
|
1170 |
#無.
|
|
|
1171 |
$record=logs::record($conf);
|
|
|
1172 |
|
|
|
1173 |
#如果執行失敗
|
|
|
1174 |
if($record["status"]==="false"){
|
|
|
1175 |
|
|
|
1176 |
#印出結果
|
|
|
1177 |
var_dump($record);
|
|
|
1178 |
|
|
|
1179 |
}#if end
|
| 409 |
liveuser |
1180 |
|
|
|
1181 |
#異常結束執行
|
|
|
1182 |
exit(1);
|
| 402 |
liveuser |
1183 |
|
|
|
1184 |
}#if end
|
|
|
1185 |
|
|
|
1186 |
#於 /etc/systemd/system 底下建立 $rootPath.$name."/usr/lib/systemd/system" 底下所有服務檔案的軟連結.
|
|
|
1187 |
#函式說明:
|
|
|
1188 |
#針對特定目錄下的內容建立軟連結.
|
|
|
1189 |
#回傳結果:
|
|
|
1190 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1191 |
#$result["error"],錯誤訊息.
|
|
|
1192 |
#$result["function"],當前執行的函數名稱.
|
|
|
1193 |
#$result["content"],字串陣列,每個建立的軟連結資訊.
|
|
|
1194 |
#必填參數:
|
|
|
1195 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
1196 |
$conf["fileArgu"]=__FILE__;
|
|
|
1197 |
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
|
|
|
1198 |
$conf["linkToDir"]=$rootPath.$name."/usr/lib/systemd/system";
|
|
|
1199 |
#可省略參數:
|
|
|
1200 |
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
|
|
|
1201 |
$conf["path"]="/etc/systemd/system";
|
|
|
1202 |
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
|
|
|
1203 |
#$conf["name"]=array(array("oriName","newName"));
|
|
|
1204 |
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
|
|
|
1205 |
$conf["overWrite"]="true";
|
|
|
1206 |
#參考資料:
|
|
|
1207 |
#無.
|
|
|
1208 |
#備註:
|
|
|
1209 |
#無.
|
|
|
1210 |
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
|
|
|
1211 |
unset($conf);
|
|
|
1212 |
|
|
|
1213 |
#如果執行失敗
|
|
|
1214 |
if($createMultiLinkInDir["status"]==="false"){
|
|
|
1215 |
|
|
|
1216 |
#函式說明:
|
|
|
1217 |
#撰寫log
|
|
|
1218 |
#回傳結果:
|
|
|
1219 |
#$result["status"],狀態,"true"或"false".
|
|
|
1220 |
#$result["error"],錯誤訊息陣列.
|
|
|
1221 |
#$result["function"],當前函式的名稱.
|
|
|
1222 |
#$result["argu"],使用的參數.
|
|
|
1223 |
#必填參數:
|
|
|
1224 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
1225 |
$conf["path"]=$logFile;
|
|
|
1226 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
1227 |
$conf["content"]=$createMultiLinkInDir;
|
|
|
1228 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1229 |
$conf["fileArgu"]=__FILE__;
|
|
|
1230 |
#可省略參數:
|
|
|
1231 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
1232 |
#$conf["rewrite"]="false";
|
|
|
1233 |
#參考資料:
|
|
|
1234 |
#無.
|
|
|
1235 |
#備註:
|
|
|
1236 |
#無.
|
|
|
1237 |
$record=logs::record($conf);
|
|
|
1238 |
|
|
|
1239 |
#如果執行失敗
|
|
|
1240 |
if($record["status"]==="false"){
|
|
|
1241 |
|
|
|
1242 |
#印出結果
|
|
|
1243 |
var_dump($record);
|
|
|
1244 |
|
|
|
1245 |
}#if end
|
|
|
1246 |
|
| 409 |
liveuser |
1247 |
#異常結束執行
|
|
|
1248 |
exit(1);
|
|
|
1249 |
|
| 402 |
liveuser |
1250 |
}#if end
|
|
|
1251 |
|
|
|
1252 |
#函式說明:
|
|
|
1253 |
#針對特定目錄下的內容建立軟連結.
|
|
|
1254 |
#回傳結果:
|
|
|
1255 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1256 |
#$result["error"],錯誤訊息.
|
|
|
1257 |
#$result["function"],當前執行的函數名稱.
|
|
|
1258 |
#$result["content"],字串陣列,每個建立的軟連結資訊.
|
|
|
1259 |
#必填參數:
|
|
|
1260 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
1261 |
$conf["fileArgu"]=__FILE__;
|
|
|
1262 |
#$conf["linkToDir"],字串,軟連結要指向哪個目錄底下的內容.
|
|
|
1263 |
$conf["linkToDir"]=$rootPath.$name."/usr/local/etc";
|
|
|
1264 |
#可省略參數:
|
|
|
1265 |
#$conf["path"],字串,軟連結要放在哪邊,預設為當前位置.
|
|
|
1266 |
$conf["path"]="/usr/local/etc";
|
|
|
1267 |
#$conf["name"],字串陣列,軟連結的名稱,預設為 "linkToDir" 目錄底下的檔案或目錄名稱.若要指定特定檔案目錄的軟連結名稱,則可以用 $conf["name"][]=array("原始名稱","新的名稱"); 來指定.
|
|
|
1268 |
#$conf["name"]=array(array("oriName","newName"));
|
|
|
1269 |
#$conf["overWrite"],字串,"true"代表要移除既有的項目名稱,來重新建立軟連結;預設為"false"不進行處理.
|
|
|
1270 |
$conf["overWrite"]="true";
|
|
|
1271 |
#參考資料:
|
|
|
1272 |
#無.
|
|
|
1273 |
#備註:
|
|
|
1274 |
#無.
|
|
|
1275 |
$createMultiLinkInDir=fileAccess::createMultiLinkInDir($conf);
|
|
|
1276 |
unset($conf);
|
|
|
1277 |
|
|
|
1278 |
#如果執行失敗
|
|
|
1279 |
if($createMultiLinkInDir["status"]==="false"){
|
|
|
1280 |
|
|
|
1281 |
#函式說明:
|
|
|
1282 |
#撰寫log
|
|
|
1283 |
#回傳結果:
|
|
|
1284 |
#$result["status"],狀態,"true"或"false".
|
|
|
1285 |
#$result["error"],錯誤訊息陣列.
|
|
|
1286 |
#$result["function"],當前函式的名稱.
|
|
|
1287 |
#$result["argu"],使用的參數.
|
|
|
1288 |
#必填參數:
|
|
|
1289 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
1290 |
$conf["path"]=$logFile;
|
|
|
1291 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
1292 |
$conf["content"]=$createMultiLinkInDir;
|
|
|
1293 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1294 |
$conf["fileArgu"]=__FILE__;
|
|
|
1295 |
#可省略參數:
|
|
|
1296 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
1297 |
#$conf["rewrite"]="false";
|
|
|
1298 |
#參考資料:
|
|
|
1299 |
#無.
|
|
|
1300 |
#備註:
|
|
|
1301 |
#無.
|
|
|
1302 |
$record=logs::record($conf);
|
|
|
1303 |
|
|
|
1304 |
#如果執行失敗
|
|
|
1305 |
if($record["status"]==="false"){
|
|
|
1306 |
|
|
|
1307 |
#印出結果
|
|
|
1308 |
var_dump($record);
|
|
|
1309 |
|
|
|
1310 |
}#if end
|
| 409 |
liveuser |
1311 |
|
|
|
1312 |
#異常結束執行
|
|
|
1313 |
exit(1);
|
| 402 |
liveuser |
1314 |
|
|
|
1315 |
}#if end
|
|
|
1316 |
|
|
|
1317 |
#systemctl daemon-reload
|
|
|
1318 |
#函式說明:
|
|
|
1319 |
#執行 systemd 程序來管理服務.
|
|
|
1320 |
#回傳結果:
|
|
|
1321 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1322 |
#$result["error"],錯誤訊息.
|
|
|
1323 |
#$result["function"],當前執行的函式名稱.
|
|
|
1324 |
#$result["argu"],所使用的參數.
|
|
|
1325 |
#$result["content"],執行的結果.
|
|
|
1326 |
#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
|
|
|
1327 |
#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
|
|
|
1328 |
#必填參數:
|
|
|
1329 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1330 |
$conf["fileArgu"]=__FILE__;
|
|
|
1331 |
#$conf["name"],字串,服務名稱.
|
|
|
1332 |
$conf["name"]="daemon-reload";
|
|
|
1333 |
#可省略參數:
|
|
|
1334 |
#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
|
|
|
1335 |
#$conf["operation"]="";
|
|
|
1336 |
#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
|
|
|
1337 |
#$conf["username"]="";
|
|
|
1338 |
#$conf["password"],字串,使用者的密碼,預設不使用.
|
|
|
1339 |
#$conf["password"]="";
|
|
|
1340 |
#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
|
|
|
1341 |
$conf["daemonReload"]="true";
|
|
|
1342 |
#參考資料:
|
|
|
1343 |
#無.
|
|
|
1344 |
#備註:
|
|
|
1345 |
#無.
|
|
|
1346 |
$systemd=cmd::systemd($conf);
|
|
|
1347 |
unset($conf);
|
|
|
1348 |
|
|
|
1349 |
#如果執行失敗
|
|
|
1350 |
if($systemd["status"]==="false"){
|
|
|
1351 |
|
|
|
1352 |
#函式說明:
|
|
|
1353 |
#撰寫log
|
|
|
1354 |
#回傳結果:
|
|
|
1355 |
#$result["status"],狀態,"true"或"false".
|
|
|
1356 |
#$result["error"],錯誤訊息陣列.
|
|
|
1357 |
#$result["function"],當前函式的名稱.
|
|
|
1358 |
#$result["argu"],使用的參數.
|
|
|
1359 |
#必填參數:
|
|
|
1360 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
1361 |
$conf["path"]=$logFile;
|
|
|
1362 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
1363 |
$conf["content"]=$systemd;
|
|
|
1364 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1365 |
$conf["fileArgu"]=__FILE__;
|
|
|
1366 |
#可省略參數:
|
|
|
1367 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
1368 |
#$conf["rewrite"]="false";
|
|
|
1369 |
#參考資料:
|
|
|
1370 |
#無.
|
|
|
1371 |
#備註:
|
|
|
1372 |
#無.
|
|
|
1373 |
$record=logs::record($conf);
|
|
|
1374 |
|
|
|
1375 |
#如果執行失敗
|
|
|
1376 |
if($record["status"]==="false"){
|
|
|
1377 |
|
|
|
1378 |
#印出結果
|
|
|
1379 |
var_dump($record);
|
|
|
1380 |
|
|
|
1381 |
}#if end
|
| 409 |
liveuser |
1382 |
|
|
|
1383 |
#異常結束執行
|
|
|
1384 |
exit(1);
|
| 402 |
liveuser |
1385 |
|
|
|
1386 |
}#if end
|
|
|
1387 |
|
|
|
1388 |
#enable and restart 於 $rootPath.$name."/usr/lib/systemd/system" 底下的所有服務
|
|
|
1389 |
|
|
|
1390 |
#函式說明:
|
|
|
1391 |
#取得目錄底下所有目錄與檔案清單.
|
|
|
1392 |
#回傳結果:
|
|
|
1393 |
#$result["status"],"true"爲建立成功,"false"爲建立失敗.
|
|
|
1394 |
#$result["error"],錯誤訊息陣列.
|
|
|
1395 |
#$result["function"],函數名稱.
|
|
|
1396 |
#$result["content"],陣列,目錄底下的檔案與子目錄.
|
|
|
1397 |
#$result["content"][$i]["name"],字串,目錄底下的檔案與子目錄的名稱.
|
|
|
1398 |
#$result["content"][$i]["folder"],字串,第$i+1個名稱為目錄還是檔案.
|
|
|
1399 |
#$result["folder"],字串,當前目標為目錄還是檔案"true"代表為目錄,"false"代表為檔案.
|
|
|
1400 |
#$result["position"],目前的位置.
|
|
|
1401 |
#必填參數:
|
|
|
1402 |
#$conf["position"],字串,目錄位置與名稱,「.」代表當前位置,「..」代表上一層.
|
|
|
1403 |
$conf["position"]=$rootPath.$name."/usr/lib/systemd/system";
|
|
|
1404 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1405 |
$conf["fileArgu"]=__FILE__;
|
|
|
1406 |
#可省略參數:
|
|
|
1407 |
#無
|
|
|
1408 |
#參考資料:
|
|
|
1409 |
#opendir=>http://php.net/manual/en/function.opendir.php
|
|
|
1410 |
#is_dir=>http://php.net/manual/en/function.is-dir.php
|
|
|
1411 |
#備註:
|
|
|
1412 |
#無.
|
|
|
1413 |
$getList=fileAccess::getList($conf);
|
|
|
1414 |
unset($conf);
|
|
|
1415 |
|
|
|
1416 |
#如果執行失敗
|
|
|
1417 |
if($getList["status"]==="false"){
|
|
|
1418 |
|
|
|
1419 |
#函式說明:
|
|
|
1420 |
#撰寫log
|
|
|
1421 |
#回傳結果:
|
|
|
1422 |
#$result["status"],狀態,"true"或"false".
|
|
|
1423 |
#$result["error"],錯誤訊息陣列.
|
|
|
1424 |
#$result["function"],當前函式的名稱.
|
|
|
1425 |
#$result["argu"],使用的參數.
|
|
|
1426 |
#必填參數:
|
|
|
1427 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
1428 |
$conf["path"]=$logFile;
|
|
|
1429 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
1430 |
$conf["content"]=$getList;
|
|
|
1431 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1432 |
$conf["fileArgu"]=__FILE__;
|
|
|
1433 |
#可省略參數:
|
|
|
1434 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
1435 |
#$conf["rewrite"]="false";
|
|
|
1436 |
#參考資料:
|
|
|
1437 |
#無.
|
|
|
1438 |
#備註:
|
|
|
1439 |
#無.
|
|
|
1440 |
$record=logs::record($conf);
|
|
|
1441 |
|
|
|
1442 |
#如果執行失敗
|
|
|
1443 |
if($record["status"]==="false"){
|
|
|
1444 |
|
|
|
1445 |
#印出結果
|
|
|
1446 |
var_dump($record);
|
|
|
1447 |
|
|
|
1448 |
}#if end
|
| 409 |
liveuser |
1449 |
|
|
|
1450 |
#異常結束執行
|
|
|
1451 |
exit(1);
|
| 402 |
liveuser |
1452 |
|
|
|
1453 |
}#if end
|
|
|
1454 |
|
|
|
1455 |
#針對每個服務
|
|
|
1456 |
foreach($getList["content"] as $fileInfo){
|
|
|
1457 |
|
|
|
1458 |
#取得服務的名稱
|
|
|
1459 |
$serviceName=$fileInfo["name"];
|
|
|
1460 |
|
|
|
1461 |
#函式說明:
|
|
|
1462 |
#執行 systemd 程序來管理服務.
|
|
|
1463 |
#回傳結果:
|
|
|
1464 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1465 |
#$result["error"],錯誤訊息.
|
|
|
1466 |
#$result["function"],當前執行的函式名稱.
|
|
|
1467 |
#$result["argu"],所使用的參數.
|
|
|
1468 |
#$result["content"],執行的結果.
|
|
|
1469 |
#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
|
|
|
1470 |
#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
|
|
|
1471 |
#必填參數:
|
|
|
1472 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1473 |
$conf["fileArgu"]=__FILE__;
|
|
|
1474 |
#$conf["name"],字串,服務名稱.
|
|
|
1475 |
$conf["name"]=$serviceName;
|
|
|
1476 |
#可省略參數:
|
|
|
1477 |
#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
|
|
|
1478 |
$conf["operation"]="enable";
|
|
|
1479 |
#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
|
|
|
1480 |
#$conf["username"]="";
|
|
|
1481 |
#$conf["password"],字串,使用者的密碼,預設不使用.
|
|
|
1482 |
#$conf["password"]="";
|
|
|
1483 |
#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
|
|
|
1484 |
#$conf["daemonReload"]="true";
|
|
|
1485 |
#參考資料:
|
|
|
1486 |
#無.
|
|
|
1487 |
#備註:
|
|
|
1488 |
#無.
|
|
|
1489 |
$systemd=cmd::systemd($conf);
|
|
|
1490 |
unset($conf);
|
|
|
1491 |
|
|
|
1492 |
#如果執行失敗
|
|
|
1493 |
if($systemd["status"]==="false"){
|
|
|
1494 |
|
|
|
1495 |
#函式說明:
|
|
|
1496 |
#撰寫log
|
|
|
1497 |
#回傳結果:
|
|
|
1498 |
#$result["status"],狀態,"true"或"false".
|
|
|
1499 |
#$result["error"],錯誤訊息陣列.
|
|
|
1500 |
#$result["function"],當前函式的名稱.
|
|
|
1501 |
#$result["argu"],使用的參數.
|
|
|
1502 |
#必填參數:
|
|
|
1503 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
1504 |
$conf["path"]=$logFile;
|
|
|
1505 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
1506 |
$conf["content"]=$systemd;
|
|
|
1507 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1508 |
$conf["fileArgu"]=__FILE__;
|
|
|
1509 |
#可省略參數:
|
|
|
1510 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
1511 |
#$conf["rewrite"]="false";
|
|
|
1512 |
#參考資料:
|
|
|
1513 |
#無.
|
|
|
1514 |
#備註:
|
|
|
1515 |
#無.
|
|
|
1516 |
$record=logs::record($conf);
|
|
|
1517 |
|
|
|
1518 |
#如果執行失敗
|
|
|
1519 |
if($record["status"]==="false"){
|
|
|
1520 |
|
|
|
1521 |
#印出結果
|
|
|
1522 |
var_dump($record);
|
|
|
1523 |
|
|
|
1524 |
}#if end
|
| 409 |
liveuser |
1525 |
|
|
|
1526 |
#異常結束執行
|
|
|
1527 |
exit(1);
|
| 402 |
liveuser |
1528 |
|
|
|
1529 |
}#if end
|
|
|
1530 |
|
|
|
1531 |
#函式說明:
|
|
|
1532 |
#執行 systemd 程序來管理服務.
|
|
|
1533 |
#回傳結果:
|
|
|
1534 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1535 |
#$result["error"],錯誤訊息.
|
|
|
1536 |
#$result["function"],當前執行的函式名稱.
|
|
|
1537 |
#$result["argu"],所使用的參數.
|
|
|
1538 |
#$result["content"],執行的結果.
|
|
|
1539 |
#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
|
|
|
1540 |
#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
|
|
|
1541 |
#必填參數:
|
|
|
1542 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1543 |
$conf["fileArgu"]=__FILE__;
|
|
|
1544 |
#$conf["name"],字串,服務名稱.
|
|
|
1545 |
$conf["name"]=$serviceName;
|
|
|
1546 |
#可省略參數:
|
|
|
1547 |
#$conf["operation"],字串,"enable","disable","start","stop","restart",預設為"list".
|
|
|
1548 |
$conf["operation"]="restart";
|
|
|
1549 |
#$conf["username"],字串,要用什麼使用者來執行,預設為root使用者
|
|
|
1550 |
#$conf["username"]="";
|
|
|
1551 |
#$conf["password"],字串,使用者的密碼,預設不使用.
|
|
|
1552 |
#$conf["password"]="";
|
|
|
1553 |
#$conf["daemonReload"],字串,"true"代表要reload daemon;預設為"false"不做事.
|
|
|
1554 |
#$conf["daemonReload"]="true";
|
|
|
1555 |
#參考資料:
|
|
|
1556 |
#無.
|
|
|
1557 |
#備註:
|
|
|
1558 |
#無.
|
|
|
1559 |
$systemd=cmd::systemd($conf);
|
|
|
1560 |
unset($conf);
|
|
|
1561 |
|
|
|
1562 |
#如果執行失敗
|
|
|
1563 |
if($systemd["status"]==="false"){
|
|
|
1564 |
|
|
|
1565 |
#函式說明:
|
|
|
1566 |
#撰寫log
|
|
|
1567 |
#回傳結果:
|
|
|
1568 |
#$result["status"],狀態,"true"或"false".
|
|
|
1569 |
#$result["error"],錯誤訊息陣列.
|
|
|
1570 |
#$result["function"],當前函式的名稱.
|
|
|
1571 |
#$result["argu"],使用的參數.
|
|
|
1572 |
#必填參數:
|
|
|
1573 |
#$conf["path"],字串,log檔案的路徑與名稱.
|
|
|
1574 |
$conf["path"]=$logFile;
|
|
|
1575 |
#$conf["content"],any,要寫的內容,若內容不為字串則會用var_dump的格式寫入.
|
|
|
1576 |
$conf["content"]=$systemd;
|
|
|
1577 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
1578 |
$conf["fileArgu"]=__FILE__;
|
|
|
1579 |
#可省略參數:
|
|
|
1580 |
#$conf["rewrite"],預設為"false",接續寫入;反之"true"代表重新寫入.
|
|
|
1581 |
#$conf["rewrite"]="false";
|
|
|
1582 |
#參考資料:
|
|
|
1583 |
#無.
|
|
|
1584 |
#備註:
|
|
|
1585 |
#無.
|
|
|
1586 |
$record=logs::record($conf);
|
|
|
1587 |
|
|
|
1588 |
#如果執行失敗
|
|
|
1589 |
if($record["status"]==="false"){
|
|
|
1590 |
|
|
|
1591 |
#印出結果
|
|
|
1592 |
var_dump($record);
|
|
|
1593 |
|
|
|
1594 |
}#if end
|
| 409 |
liveuser |
1595 |
|
|
|
1596 |
#異常結束執行
|
|
|
1597 |
exit(1);
|
| 402 |
liveuser |
1598 |
|
|
|
1599 |
}#if end
|
|
|
1600 |
|
|
|
1601 |
}#foreach end
|
|
|
1602 |
|
|
|
1603 |
?>
|