| 14 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
#宣告指派命名空間
|
|
|
4 |
namespace qbpwcf;
|
|
|
5 |
|
|
|
6 |
#匯入php命令列
|
|
|
7 |
include("../allInOneForSOAP.php");
|
|
|
8 |
|
|
|
9 |
/*
|
|
|
10 |
|
|
|
11 |
#提示要測試的函式開始
|
|
|
12 |
echo "\n"."cmd::readLine - testCase 1 start...\n";
|
|
|
13 |
|
|
|
14 |
#涵式說明:
|
|
|
15 |
#讀取標準I/O的一行輸入.並提供提示說明.
|
|
|
16 |
#回傳的結果:
|
|
|
17 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
18 |
#$result["error"],錯誤訊息.
|
|
|
19 |
#$result["content"],取得的輸入內容.
|
|
|
20 |
#必填的參數:
|
|
|
21 |
#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
|
|
|
22 |
$conf["commentsArray"]=array("請輸入任意內容");
|
|
|
23 |
#可省略的參數:
|
|
|
24 |
#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
|
|
|
25 |
#$conf["newLineBreak"]="false";
|
|
|
26 |
var_dump(cmd::readLine($conf));
|
|
|
27 |
unset($conf);
|
|
|
28 |
|
|
|
29 |
#提示要測試的函式結束
|
|
|
30 |
echo "\n"."cmd::readLine"." ...end\n";
|
|
|
31 |
|
|
|
32 |
*/
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
|
|
|
36 |
#提示要測試的函式開始
|
|
|
37 |
echo "\n"."cmd::transferTemperature - testCase 1 start...\n";
|
|
|
38 |
|
|
|
39 |
#涵式說明:
|
|
|
40 |
#轉換攝氏溫度爲華氏溫度
|
|
|
41 |
#回傳的結果:
|
|
|
42 |
#華氏溫度
|
|
|
43 |
#必填的參數:
|
|
|
44 |
$conf["temperature"]="30C";#輸入的攝氏溫度
|
|
|
45 |
#可省略的參數:
|
|
|
46 |
$conf["useC"]="true";#輸入內容是否使用單位C,如果要則設爲"true";反之不使用。
|
|
|
47 |
$conf["useF"]="true";#輸出內容是否使用單位F,如果要則設爲"true";反之不使用。
|
|
|
48 |
$conf["points"]="1";#要算到小數點後第幾位,並且四捨五入,預設是不限定小數點位數。
|
|
|
49 |
#原始公式:
|
|
|
50 |
#F = 9C / 5 + 32
|
|
|
51 |
var_dump(cmd::transferTemperature($conf));
|
|
|
52 |
unset($conf);
|
|
|
53 |
|
|
|
54 |
#提示要測試的函式結束
|
|
|
55 |
echo "\n"."cmd::transferTemperature"." ...end\n";
|
|
|
56 |
|
|
|
57 |
*/
|
|
|
58 |
|
|
|
59 |
/*
|
|
|
60 |
|
|
|
61 |
#提示要測試的函式開始
|
|
|
62 |
echo "\n"."cmd::mv - testCase 1 start...\n";
|
|
|
63 |
|
|
|
64 |
#涵式說明:
|
|
|
65 |
#移動檔案並重新命名,過程會提供提示說明.
|
|
|
66 |
#回傳的結果:
|
|
|
67 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
68 |
#$result["error"],錯誤訊息.
|
|
|
69 |
#$result["content"],取得的輸入內容.
|
|
|
70 |
#必填的參數:
|
|
|
71 |
#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
|
|
|
72 |
$conf["commentsArray"]=array("正在移動");
|
|
|
73 |
#$conf["movedFilePositionAndName"],字串,為想要移動的檔案位置與名稱.
|
|
|
74 |
$conf["movedFilePositionAndName"]="cmdT/cmdT1.txt";
|
|
|
75 |
#$conf["movedTargetFileAndName"],字串,要移動到的位置與新檔案名稱.
|
|
|
76 |
$conf["movedTargetFileAndName"]="cmdT/cmdT2.txt";
|
|
|
77 |
#可省略的參數:
|
|
|
78 |
#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
|
|
|
79 |
#$conf["newLineBreak"]="false";
|
|
|
80 |
#參考資料來源:
|
|
|
81 |
#rename函式用法
|
|
|
82 |
#http://php.net/manual/en/function.rename.php
|
|
|
83 |
var_dump(cmd::mv($conf));
|
|
|
84 |
unset($conf);
|
|
|
85 |
|
|
|
86 |
#涵式說明:
|
|
|
87 |
#移動檔案並重新命名,過程會提供提示說明.
|
|
|
88 |
#回傳的結果:
|
|
|
89 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
90 |
#$result["error"],錯誤訊息.
|
|
|
91 |
#$result["content"],取得的輸入內容.
|
|
|
92 |
#必填的參數:
|
|
|
93 |
#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
|
|
|
94 |
$conf["commentsArray"]=array("正在移動");
|
|
|
95 |
#$conf["movedFilePositionAndName"],字串,為想要移動的檔案位置與名稱.
|
|
|
96 |
$conf["movedFilePositionAndName"]="cmdT/cmdT2.txt";
|
|
|
97 |
#$conf["movedTargetFileAndName"],字串,要移動到的位置與新檔案名稱.
|
|
|
98 |
$conf["movedTargetFileAndName"]="cmdT/cmdT1.txt";
|
|
|
99 |
#可省略的參數:
|
|
|
100 |
#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
|
|
|
101 |
#$conf["newLineBreak"]="false";
|
|
|
102 |
#參考資料來源:
|
|
|
103 |
#rename函式用法
|
|
|
104 |
#http://php.net/manual/en/function.rename.php
|
|
|
105 |
var_dump(cmd::mv($conf));
|
|
|
106 |
unset($conf);
|
|
|
107 |
|
|
|
108 |
#提示要測試的函式結束
|
|
|
109 |
echo "\n"."cmd::mv"." ...end\n";
|
|
|
110 |
|
|
|
111 |
*/
|
|
|
112 |
|
|
|
113 |
/*
|
|
|
114 |
|
|
|
115 |
#提示要測試的函式開始
|
|
|
116 |
echo "\n"."cmd::makeTarGzFile - testCase 1 start...\n";
|
|
|
117 |
|
|
|
118 |
#涵式說明:
|
|
|
119 |
#將資料夾打包成tar.gz檔案
|
|
|
120 |
#回傳的結果:
|
|
|
121 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
122 |
#$result["error"],錯誤訊息.
|
|
|
123 |
#$result["content"],取得的輸入內容.
|
|
|
124 |
#必填的參數:
|
|
|
125 |
#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
|
|
|
126 |
$conf["commentsArray"]=array("正在打包");
|
|
|
127 |
#$conf["compressedFolder"],字串,要打包的資料夾位置
|
|
|
128 |
$conf["compressedFolder"]="phpLib";
|
|
|
129 |
#$conf["createdTarGzFile"],字串,打包好的檔案要放在哪裡,副檔名「.tar.gz」會自動加上.
|
|
|
130 |
$conf["createdTarGzFile"]="cmdT/phplib";
|
|
|
131 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
|
|
|
132 |
$conf["fileArgu"]=__FILE__;
|
|
|
133 |
#可省略的參數:
|
|
|
134 |
#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
|
|
|
135 |
#$conf["newLineBreak"]="false";
|
|
|
136 |
var_dump(cmd::makeTarGzFile($conf));
|
|
|
137 |
unset($conf);
|
|
|
138 |
|
|
|
139 |
#提示要測試的函式結束
|
|
|
140 |
echo "\n"."cmd::makeTarGzFile"." ...end\n";
|
|
|
141 |
|
|
|
142 |
*/
|
|
|
143 |
|
|
|
144 |
/*
|
|
|
145 |
|
|
|
146 |
#提示要測試的函式開始
|
|
|
147 |
echo "\n"."cmd::changeToAbsolutePath - testCase 1 start...\n";
|
|
|
148 |
|
|
|
149 |
#函式說明:
|
|
|
150 |
#檢查是否為相對路徑,並將之轉換為絕對路徑
|
|
|
151 |
#回傳的結果:
|
|
|
152 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
153 |
#$result["function"],當前執行的函數名稱.
|
|
|
154 |
#$result["error"],錯誤訊息.
|
|
|
155 |
#$result["absolutePath"],轉換好的路徑檔案字串.
|
|
|
156 |
#必填的參數:
|
|
|
157 |
#$conf["checkedPath"],字串,要檢查是不是絕對路徑的路徑檔案字串.
|
|
|
158 |
$conf["checkedPath"]="123/456/789";
|
|
|
159 |
var_dump(cmd::changeToAbsolutePath($conf));
|
|
|
160 |
unset($conf);
|
|
|
161 |
|
|
|
162 |
#函式說明:
|
|
|
163 |
#檢查是否為相對路徑,並將之轉換為絕對路徑
|
|
|
164 |
#回傳的結果:
|
|
|
165 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
166 |
#$result["function"],當前執行的函數名稱.
|
|
|
167 |
#$result["error"],錯誤訊息.
|
|
|
168 |
#$result["absolutePath"],轉換好的路徑檔案字串.
|
|
|
169 |
#必填的參數:
|
|
|
170 |
#$conf["checkedPath"],字串,要檢查是不是絕對路徑的路徑檔案字串.
|
|
|
171 |
$conf["checkedPath"]="/123/456/789";
|
|
|
172 |
var_dump(cmd::changeToAbsolutePath($conf));
|
|
|
173 |
unset($conf);
|
|
|
174 |
|
|
|
175 |
#提示要測試的函式結束
|
|
|
176 |
echo "\n"."cmd::changeToAbsolutePath"." ...end\n";
|
|
|
177 |
|
|
|
178 |
*/
|
|
|
179 |
|
|
|
180 |
/*
|
|
|
181 |
|
|
|
182 |
#提示要測試的函式開始
|
|
|
183 |
echo "\n"."cmd::changeMultiToAbsolutePath - testCase 1 start...\n";
|
|
|
184 |
|
|
|
185 |
#函式說明:
|
|
|
186 |
#檢查多個路徑字串是否為相對路徑,並將之轉換為絕對路徑
|
|
|
187 |
#回傳的結果:
|
|
|
188 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
189 |
#$result["error"],錯誤訊息.
|
|
|
190 |
#$result["absolutePath"][$i],為轉換好的第$i+1個路徑檔案陣列字串.
|
|
|
191 |
#必填的參數:
|
|
|
192 |
#$conf["checkedPathArray"],字串陣列,要檢查是不是絕對路徑的路徑檔案字串陣列.
|
|
|
193 |
$conf["checkedPathArray"]=array("123","/hgh/dssd/dsd","sdsd/sdsd/ss");
|
|
|
194 |
var_dump(cmd::changeMultiToAbsolutePath($conf));
|
|
|
195 |
unset($conf);
|
|
|
196 |
|
|
|
197 |
#提示要測試的函式結束
|
|
|
198 |
echo "\n"."cmd::changeMultiToAbsolutePath"." ...end\n";
|
|
|
199 |
|
|
|
200 |
*/
|
|
|
201 |
|
|
|
202 |
#提示要測試的函式開始
|
|
|
203 |
echo "<hr>cmd::packetToISO - testCase 1<br>";
|
|
|
204 |
|
|
|
205 |
/*
|
|
|
206 |
|
|
|
207 |
#涵式說明:
|
|
|
208 |
#將資料夾打包成iso檔
|
|
|
209 |
#回傳的結果:
|
|
|
210 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
211 |
#$result["error"],錯誤訊息.
|
|
|
212 |
#$result["storePlace"],檔案輸出後的位置與名稱.
|
|
|
213 |
#必填的參數:
|
|
|
214 |
#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
|
|
|
215 |
$conf["commentsArray"]=array("正在製作iso檔");
|
|
|
216 |
#$conf["targetInRoot"],字串陣列,要放在iso檔根目錄底下的多個檔案位置,array("*")代表目錄底下的所有檔案目錄.
|
|
|
217 |
$conf["targetInRoot"]=array("Jolla_music_ringtone.ogg","Jolla revealed.webm");
|
|
|
218 |
#$conf["createdIsoFile"],字串,打包好的檔案要放在哪裡,副檔名「.iso」會自動加上.
|
|
|
219 |
$conf["createdIsoFile"]="cmdT/test";
|
|
|
220 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
|
|
|
221 |
$conf["fileArgu"]=__FILE__;
|
|
|
222 |
#可省略的參數:
|
|
|
223 |
#$conf["folderInRoot"],字串陣列,要放在iso檔根目錄底下的資料夾
|
|
|
224 |
$conf["folderInRoot"]=array("phpLib","cmdT");
|
|
|
225 |
#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
|
|
|
226 |
#$conf["newLineBreak"]="false";
|
|
|
227 |
var_dump(cmd::packetToISO($conf));
|
|
|
228 |
unset($conf);
|
|
|
229 |
|
|
|
230 |
*/
|
|
|
231 |
|
|
|
232 |
echo "<hr>cmd::packetToISO - testCase 2<br>";
|
|
|
233 |
|
|
|
234 |
/*
|
|
|
235 |
|
|
|
236 |
#涵式說明:
|
|
|
237 |
#將資料夾打包成iso檔
|
|
|
238 |
#回傳的結果:
|
|
|
239 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
240 |
#$result["error"],錯誤訊息.
|
|
|
241 |
#$result["storePlace"],檔案輸出後的位置與名稱.
|
|
|
242 |
#必填的參數:
|
|
|
243 |
#$conf["commentsArray"],字串陣列,提示輸入的文字描述,$conf["commentsArray"][$i]代表第($+1)行的描述.
|
|
|
244 |
$conf["commentsArray"]=array("正在製作iso檔");
|
|
|
245 |
#$conf["targetInRoot"],字串陣列,要放在iso檔根目錄底下的多個檔案位置,array("*")代表目錄底下的所有檔案目錄.
|
|
|
246 |
$conf["targetInRoot"]=array("fedoraBear.png","jquery-2.0.3.js");
|
|
|
247 |
#$conf["createdIsoFile"],字串,打包好的檔案要放在哪裡,副檔名「.iso」會自動加上.
|
|
|
248 |
$conf["createdIsoFile"]="cmdT/test";
|
|
|
249 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
|
|
|
250 |
$conf["fileArgu"]=__FILE__;
|
|
|
251 |
#可省略的參數:
|
|
|
252 |
#$conf["folderInRoot"],字串陣列,要放在iso檔根目錄底下的資料夾
|
|
|
253 |
$conf["folderInRoot"]=array("phpLib");
|
|
|
254 |
#$conf["newLineBreak"],字串,是否$conf["commentsArray"]的每個元素後面都要斷行,"false"代表不要,預設為"true"要斷行.
|
|
|
255 |
#$conf["newLineBreak"]="false";
|
|
|
256 |
var_dump(cmd::packetToISO($conf));
|
|
|
257 |
unset($conf);
|
|
|
258 |
|
|
|
259 |
*/
|
|
|
260 |
|
|
|
261 |
echo "<hr>cmd::checkFileExist - testCase 1<br>";
|
|
|
262 |
|
|
|
263 |
/*
|
|
|
264 |
|
|
|
265 |
#函式說明:
|
|
|
266 |
#用shell檢查檔案是否存在,可以指定查詢時用的身份.
|
|
|
267 |
#回傳的結果:
|
|
|
268 |
#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
|
|
|
269 |
#$result["function"],當前執行的函數名稱.
|
|
|
270 |
#$result["error"],錯誤訊息陣列.
|
|
|
271 |
#必填的參數:
|
|
|
272 |
#$conf["fileName"],字串,要檢查的檔案名稱.
|
|
|
273 |
$conf["fileName"]="cmdT.php";
|
|
|
274 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
275 |
$conf["fileArgu"]=__FILE__;
|
|
|
276 |
#可省略參數:
|
|
|
277 |
#$conf["username"],字串,要用哪個身份來檢查檔案是否存在,預設不使用.
|
|
|
278 |
#$conf["username"]="";
|
|
|
279 |
#$conf["password"],字串,使用該身份需要的密碼,預設不使用密碼.
|
|
|
280 |
#$conf["password"]="";
|
|
|
281 |
var_dump(cmd::checkFileExist($conf));
|
|
|
282 |
unset($conf);
|
|
|
283 |
|
|
|
284 |
*/
|
|
|
285 |
|
|
|
286 |
echo "<hr>cmd::checkFileExist - testCase 2<br>";
|
|
|
287 |
|
|
|
288 |
/*
|
|
|
289 |
|
|
|
290 |
#函式說明:
|
|
|
291 |
#用shell檢查檔案是否存在,可以指定查詢時用的身份.
|
|
|
292 |
#回傳的結果:
|
|
|
293 |
#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
|
|
|
294 |
#$result["function"],當前執行的函數名稱.
|
|
|
295 |
#$result["error"],錯誤訊息陣列.
|
|
|
296 |
#必填的參數:
|
|
|
297 |
#$conf["fileName"],字串,要檢查的檔案名稱.
|
|
|
298 |
$conf["fileName"]="cmdT.php";
|
|
|
299 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
300 |
$conf["fileArgu"]=__FILE__;
|
|
|
301 |
#可省略參數:
|
|
|
302 |
#$conf["username"],字串,要用哪個身份來檢查檔案是否存在,預設不使用.
|
|
|
303 |
$conf["username"]="liveuser";
|
|
|
304 |
#$conf["password"],字串,使用該身份需要的密碼,預設不使用密碼.
|
|
|
305 |
$conf["password"]="superfedoralinux";
|
|
|
306 |
var_dump(cmd::checkFileExist($conf));
|
|
|
307 |
unset($conf);
|
|
|
308 |
|
|
|
309 |
*/
|
|
|
310 |
|
|
|
311 |
echo "<hr>cmd::checkFileExist - testCase 3<br>";
|
|
|
312 |
|
|
|
313 |
/*
|
|
|
314 |
|
|
|
315 |
#函式說明:
|
|
|
316 |
#用shell檢查檔案是否存在,可以指定查詢時用的身份.
|
|
|
317 |
#回傳的結果:
|
|
|
318 |
#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
|
|
|
319 |
#$result["function"],當前執行的函數名稱.
|
|
|
320 |
#$result["error"],錯誤訊息陣列.
|
|
|
321 |
#必填的參數:
|
|
|
322 |
#$conf["fileName"],字串,要檢查的檔案名稱.
|
|
|
323 |
$conf["fileName"]="cmdT.php";
|
|
|
324 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
325 |
$conf["fileArgu"]=__FILE__;
|
|
|
326 |
#可省略參數:
|
|
|
327 |
#$conf["username"],字串,要用哪個身份來檢查檔案是否存在,預設不使用,若沒有設定好不用密碼即可登入,則在web端會直接出錯,在命令列則會提示輸入密碼.
|
|
|
328 |
$conf["username"]="liveuser";
|
|
|
329 |
#$conf["password"],字串,使用該身份需要的密碼,預設不使用密碼.
|
|
|
330 |
#$conf["password"]="superfedoralinux";
|
|
|
331 |
var_dump(cmd::checkFileExist($conf));
|
|
|
332 |
unset($conf);
|
|
|
333 |
|
|
|
334 |
*/
|
|
|
335 |
|
|
|
336 |
echo "<hr>cmd::checkFileExist - testCase 4<br>";
|
|
|
337 |
|
|
|
338 |
/*
|
|
|
339 |
|
|
|
340 |
#函式說明:
|
|
|
341 |
#用shell檢查檔案是否存在,可以指定查詢時用的身份.
|
|
|
342 |
#回傳的結果:
|
|
|
343 |
#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.
|
|
|
344 |
#$result["function"],當前執行的函數名稱.
|
|
|
345 |
#$result["error"],錯誤訊息陣列.
|
|
|
346 |
#$result["founded"],"true"代表有找到檔案,"false"代表沒有找到檔案.
|
|
|
347 |
#必填的參數:
|
|
|
348 |
#$conf["fileName"],字串,要檢查的檔案名稱.
|
|
|
349 |
$conf["fileName"]="cmdT.php";
|
|
|
350 |
#可省略參數:
|
|
|
351 |
#$conf["username"],字串,要用哪個身份來檢查檔案是否存在,預設不使用,若沒有設定好不用密碼即可登入,則在web端會直接出錯,在命令列則會提示輸入密碼.
|
|
|
352 |
$conf["username"]="root";
|
|
|
353 |
#$conf["password"],字串,使用該身份需要的密碼,預設不使用密碼.
|
|
|
354 |
$conf["password"]="superFedoraLinux";
|
|
|
355 |
var_dump(cmd::checkFileExist($conf));
|
|
|
356 |
unset($conf);
|
|
|
357 |
|
|
|
358 |
*/
|
|
|
359 |
|
|
|
360 |
echo "<hr>cmd::getFromConf - testCase 1<br>";
|
|
|
361 |
|
|
|
362 |
/*
|
|
|
363 |
|
|
|
364 |
#函數說明:
|
|
|
365 |
#如果在設定檔取得不了對應的數值,則改用 readLine 取得設定值.
|
|
|
366 |
#必填參數:
|
|
|
367 |
#$conf["readVarName"],字串,要從設定檔取得的變數名稱.
|
|
|
368 |
$conf["readVarName"]="account";
|
|
|
369 |
#可省略參數:
|
|
|
370 |
#$conf["conf"],字串,設定檔的名稱與路徑,預設為 ".qbpwcf_tmp/cmd/getFromConf/conf.xml"
|
|
|
371 |
#$conf["conf"]=".qbpwcf_tmp/cmd/getFromConf/conf";
|
|
|
372 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
373 |
#$conf["fileArgu"]=__FILE__;
|
|
|
374 |
#$conf["commentsArray"],字串,提示輸入內容的描述,一個元素代表一列內容,預設為 array("請輸入變數 $conf["readVarName"] 的內容").
|
|
|
375 |
#$conf["commentsArray"]=array();
|
|
|
376 |
#備註:
|
|
|
377 |
#建構中...
|
|
|
378 |
var_dump(cmd::getFromConf($conf));
|
|
|
379 |
unset($conf);
|
|
|
380 |
|
|
|
381 |
*/
|
|
|
382 |
|
|
|
383 |
echo "<hr>cmd::getFromConf - testCase 2<br>";
|
|
|
384 |
|
|
|
385 |
/*
|
|
|
386 |
|
|
|
387 |
#函數說明:
|
|
|
388 |
#如果在設定檔取得不了對應的數值,則改用 readLine 取得設定值.
|
|
|
389 |
#必填參數:
|
|
|
390 |
#$conf["readVarName"],字串,要從設定檔取得的變數名稱.
|
|
|
391 |
$conf["readVarName"]="password";
|
|
|
392 |
#可省略參數:
|
|
|
393 |
#$conf["conf"],字串,設定檔的名稱與路徑,預設為 ".qbpwcf_tmp/cmd/getFromConf/conf.xml"
|
|
|
394 |
#$conf["conf"]=".qbpwcf_tmp/cmd/getFromConf/conf";
|
|
|
395 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
396 |
#$conf["fileArgu"]=__FILE__;
|
|
|
397 |
#$conf["commentsArray"],字串,提示輸入內容的描述,一個元素代表一列內容,預設為 array("請輸入變數 $conf["readVarName"] 的內容").
|
|
|
398 |
#$conf["commentsArray"]=array();
|
|
|
399 |
#備註:
|
|
|
400 |
#建構中...
|
|
|
401 |
var_dump(cmd::getFromConf($conf));
|
|
|
402 |
unset($conf);
|
|
|
403 |
|
|
|
404 |
*/
|
|
|
405 |
|
|
|
406 |
echo "<hr>cmd::getFromConf - testCase 3<br>";
|
|
|
407 |
|
|
|
408 |
/*
|
|
|
409 |
|
|
|
410 |
#函數說明:
|
|
|
411 |
#如果在設定檔取得不了對應的數值,則改用 readLine 取得設定值.
|
|
|
412 |
#必填參數:
|
|
|
413 |
#$conf["readVarName"],字串,要從設定檔取得的變數名稱.
|
|
|
414 |
$conf["readVarName"]="password";
|
|
|
415 |
#可省略參數:
|
|
|
416 |
#$conf["conf"],字串,設定檔的名稱與路徑,預設為 ".qbpwcf_tmp/cmd/getFromConf/conf.xml"
|
|
|
417 |
#$conf["conf"]=".qbpwcf_tmp/cmd/getFromConf/conf";
|
|
|
418 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
419 |
#$conf["fileArgu"]=__FILE__;
|
|
|
420 |
#$conf["commentsArray"],字串,提示輸入內容的描述,一個元素代表一列內容,預設為 array("請輸入變數 $conf["readVarName"] 的內容").
|
|
|
421 |
#$conf["commentsArray"]=array();
|
|
|
422 |
#$conf["forceRewrite"],字串,是否要強制覆寫設定值,"true"代表要;"false"代表不要.
|
|
|
423 |
$conf["forceRewrite"]="true";
|
|
|
424 |
#cmd::getFromConf($conf);
|
|
|
425 |
var_dump(cmd::getFromConf($conf));
|
|
|
426 |
unset($conf);
|
|
|
427 |
|
|
|
428 |
*/
|
|
|
429 |
|
|
|
430 |
echo "<hr>cmd::lsblk - testCase 1<br>";
|
|
|
431 |
|
|
|
432 |
/*
|
|
|
433 |
|
|
|
434 |
#涵式說明:
|
|
|
435 |
#取得lsblk指令的輸出
|
|
|
436 |
#回傳結果:
|
|
|
437 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
438 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
439 |
#$result["function"],當前執行的函式名稱.
|
|
|
440 |
#$result["content"],lsblk的輸出內容.
|
|
|
441 |
#必填參數:
|
|
|
442 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
443 |
$conf["fileArgu"]=__FILE__;
|
|
|
444 |
#可省略參數:
|
|
|
445 |
#無.
|
|
|
446 |
$lsblk=cmd::lsblk($conf);
|
|
|
447 |
unset($conf);
|
|
|
448 |
|
|
|
449 |
#如果執行失敗
|
|
|
450 |
if($lsblk["status"]==="false"){
|
|
|
451 |
|
|
|
452 |
#印出內容
|
|
|
453 |
var_dump($lsblk);
|
|
|
454 |
|
|
|
455 |
#結束程式
|
|
|
456 |
exit;
|
|
|
457 |
|
|
|
458 |
}#if end
|
|
|
459 |
|
|
|
460 |
#印出內容
|
|
|
461 |
var_dump($lsblk);
|
|
|
462 |
|
|
|
463 |
*/
|
|
|
464 |
|
|
|
465 |
echo "<hr>cmd::mountDev - testCase 1<br>";
|
|
|
466 |
|
|
|
467 |
/*
|
|
|
468 |
|
|
|
469 |
#函數說明:
|
|
|
470 |
#嘗試掛載儲存裝置
|
|
|
471 |
#回傳結果:
|
|
|
472 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
473 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
474 |
#$result["warning"],警告訊息陣列.
|
|
|
475 |
#$result["function"],當前執行的函式名稱.
|
|
|
476 |
#$result["content"],lsblk的輸出內容.
|
|
|
477 |
#必填參數:
|
|
|
478 |
#$conf["device"],陣列,想要掛載的裝置勢別資訊,當塞選到只剩下一個儲存裝置時,將會掛載之.
|
|
|
479 |
$conf["device"]=array("JetFlash");
|
|
|
480 |
#$conf["partNo"],字串,分割區號碼.
|
|
|
481 |
$conf["partNo"]="1";
|
|
|
482 |
#$conf["mountPoint"],字串,想要掛載到哪邊.
|
|
|
483 |
$conf["mountPoint"]="mountPoint";
|
|
|
484 |
#可省略參數:
|
|
|
485 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
486 |
$conf["fileArgu"]=__FILE__;
|
|
|
487 |
#$conf["createMountPoint"],字串,當掛載點不存在時是否要建立其目錄與路徑,"true"代表要,"false"代表不要,預設為"false".
|
|
|
488 |
#$conf["createMountPoint"]="";
|
|
|
489 |
var_dump(cmd::mountDev($conf));
|
|
|
490 |
unset($conf);
|
|
|
491 |
|
|
|
492 |
*/
|
|
|
493 |
|
|
|
494 |
echo "<hr>cmd::umountDev & cmd::mountDev - testCase 1<br>";
|
|
|
495 |
|
|
|
496 |
/*
|
|
|
497 |
|
|
|
498 |
#卸載裝置
|
|
|
499 |
#涵式說明:
|
|
|
500 |
#卸載儲存裝置
|
|
|
501 |
#回傳結果:
|
|
|
502 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
503 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
504 |
#$result["warning"],警告訊息陣列.
|
|
|
505 |
#$result["function"],當前執行的函式名稱.
|
|
|
506 |
#$result["content"],lsblk的輸出內容.
|
|
|
507 |
#必填參數:
|
|
|
508 |
#$conf["device"],陣列,想要卸載的裝置勢別資訊,當塞選到只剩下一個儲存裝置時,將會掛載之.
|
|
|
509 |
$conf["device"]=array("JetFlash");
|
|
|
510 |
#$conf["partNo"],字串,分割區號碼.
|
|
|
511 |
$conf["partNo"]="1";
|
|
|
512 |
#備註:
|
|
|
513 |
#建構中
|
|
|
514 |
var_dump(cmd::umountDev($conf));
|
|
|
515 |
unset($conf);
|
|
|
516 |
|
|
|
517 |
#移除存在的掛載點
|
|
|
518 |
rmdir("mountPoint");
|
|
|
519 |
|
|
|
520 |
#函數說明:
|
|
|
521 |
#嘗試掛載儲存裝置
|
|
|
522 |
#回傳結果:
|
|
|
523 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
524 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
525 |
#$result["warning"],警告訊息陣列.
|
|
|
526 |
#$result["function"],當前執行的函式名稱.
|
|
|
527 |
#$result["content"],lsblk的輸出內容.
|
|
|
528 |
#必填參數:
|
|
|
529 |
#$conf["device"],陣列,想要掛載的裝置勢別資訊,當塞選到只剩下一個儲存裝置時,將會掛載之.
|
|
|
530 |
$conf["device"]=array("JetFlash");
|
|
|
531 |
#$conf["partNo"],字串,分割區號碼.
|
|
|
532 |
$conf["partNo"]="1";
|
|
|
533 |
#$conf["mountPoint"],字串,想要掛載到哪邊.
|
|
|
534 |
$conf["mountPoint"]="mountPoint";
|
|
|
535 |
#可省略參數:
|
|
|
536 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
537 |
$conf["fileArgu"]=__FILE__;
|
|
|
538 |
#$conf["createMountPoint"],字串,當掛載點不存在時是否要建立其目錄與路徑,"true"代表要,"false"代表不要,預設為"false".
|
|
|
539 |
$conf["createMountPoint"]="true";
|
|
|
540 |
var_dump(cmd::mountDev($conf));
|
|
|
541 |
unset($conf);
|
|
|
542 |
|
|
|
543 |
*/
|
|
|
544 |
|
|
|
545 |
echo "<hr>cmd::umountDev & cmd::spice - testCase 1<br>";
|
|
|
546 |
|
|
|
547 |
/*
|
|
|
548 |
|
|
|
549 |
#涵式說明:
|
|
|
550 |
#使用remote-viewer指令進行遠端
|
|
|
551 |
#回傳結果:
|
|
|
552 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
553 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
554 |
#$result["function"],當前執行的函式名稱.
|
|
|
555 |
#$result["argu"],所使用的參數.
|
|
|
556 |
#$result["cmd"],執行的指令.
|
|
|
557 |
#$result["config"],連線所用的config檔案內容.
|
|
|
558 |
#必填參數:
|
|
|
559 |
#$conf["type"],字串,"tcp"代表是用網路連線;"sock"代表是用unix socket進行連線,僅限於本機.
|
|
|
560 |
$conf["type"]="tcp";
|
|
|
561 |
#$conf["addr"],字串,要連線到的位置,若$conf["type"]是tcp,則可以為IP位置或dns;若$conf["type"]是sock,則可以為socket檔案在本機上的位置.
|
|
|
562 |
$conf["addr"]="127.0.0.1";
|
|
|
563 |
#$conf["fileArgu"],字串,__FILE__的內容.
|
|
|
564 |
$conf["fileArgu"]=__FILE__;
|
|
|
565 |
#可省略參數:
|
|
|
566 |
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
|
|
|
567 |
#$conf["username"]="root";
|
|
|
568 |
#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
|
|
|
569 |
#$conf["password"]="superFedoraLinux";
|
|
|
570 |
#$conf["port"],字串,$conf["addr"]為tcp時,連線用的port.
|
|
|
571 |
$conf["port"]="5901";
|
|
|
572 |
#$conf["spicePass"],字串,連線時要使用的密碼,預設不使用.
|
|
|
573 |
$conf["spicePass"]="password";
|
|
|
574 |
#$conf["title"],字串,遠端視窗的標題要為什麼?預設為連線的位置.
|
|
|
575 |
$conf["title"]="sample-tcp";
|
|
|
576 |
#$conf["fullScreen"],字串,是否一連線就要全螢幕,"true"代表要,"false"代表不要,預設為"false".
|
|
|
577 |
#$conf["fullScreen"]="";
|
|
|
578 |
var_dump(cmd::spice($conf));
|
|
|
579 |
unset($conf);
|
|
|
580 |
|
|
|
581 |
*/
|
|
|
582 |
|
|
|
583 |
echo "<hr>cmd::umountDev & cmd::spice - testCase 2<br>";
|
|
|
584 |
|
|
|
585 |
/*
|
|
|
586 |
|
|
|
587 |
#涵式說明:
|
|
|
588 |
#使用remote-viewer指令進行遠端
|
|
|
589 |
#回傳結果:
|
|
|
590 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
591 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
592 |
#$result["function"],當前執行的函式名稱.
|
|
|
593 |
#$result["argu"],所使用的參數.
|
|
|
594 |
#$result["cmd"],執行的指令.
|
|
|
595 |
#$result["config"],連線所用的config檔案內容.
|
|
|
596 |
#必填參數:
|
|
|
597 |
#$conf["type"],字串,"tcp"代表是用網路連線;"sock"代表是用unix socket進行連線,僅限於本機.
|
|
|
598 |
$conf["type"]="tcp";
|
|
|
599 |
#$conf["addr"],字串,要連線到的位置,若$conf["type"]是tcp,則可以為IP位置或dns;若$conf["type"]是sock,則可以為socket檔案在本機上的位置.
|
|
|
600 |
$conf["addr"]="127.0.0.1";
|
|
|
601 |
#$conf["fileArgu"],字串,__FILE__的內容.
|
|
|
602 |
$conf["fileArgu"]=__FILE__;
|
|
|
603 |
#可省略參數:
|
|
|
604 |
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
|
|
|
605 |
$conf["username"]="root";
|
|
|
606 |
#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
|
|
|
607 |
$conf["password"]="superFedoraLinux";
|
|
|
608 |
#$conf["port"],字串,$conf["addr"]為tcp時,連線用的port.
|
|
|
609 |
$conf["port"]="5901";
|
|
|
610 |
#$conf["spicePass"],字串,連線時要使用的密碼,預設不使用.
|
|
|
611 |
$conf["spicePass"]="password";
|
|
|
612 |
#$conf["title"],字串,遠端視窗的標題要為什麼?預設為連線的位置.
|
|
|
613 |
$conf["title"]="sample-tcp";
|
|
|
614 |
#$conf["fullScreen"],字串,是否一連線就要全螢幕,"true"代表要,"false"代表不要,預設為"false".
|
|
|
615 |
#$conf["fullScreen"]="";
|
|
|
616 |
var_dump(cmd::spice($conf));
|
|
|
617 |
unset($conf);
|
|
|
618 |
|
|
|
619 |
*/
|
|
|
620 |
|
|
|
621 |
echo "<hr>cmd::umountDev & cmd::spice - testCase 3<br>";
|
|
|
622 |
|
|
|
623 |
/*
|
|
|
624 |
|
|
|
625 |
#涵式說明:
|
|
|
626 |
#使用remote-viewer指令進行遠端
|
|
|
627 |
#回傳結果:
|
|
|
628 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
629 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
630 |
#$result["function"],當前執行的函式名稱.
|
|
|
631 |
#$result["argu"],所使用的參數.
|
|
|
632 |
#$result["cmd"],執行的指令.
|
|
|
633 |
#$result["config"],連線所用的config檔案內容.
|
|
|
634 |
#必填參數:
|
|
|
635 |
#$conf["type"],字串,"tcp"代表是用網路連線;"sock"代表是用unix socket進行連線,僅限於本機.
|
|
|
636 |
$conf["type"]="sock";
|
|
|
637 |
#$conf["addr"],字串,要連線到的位置,若$conf["type"]是tcp,則可以為IP位置或dns;若$conf["type"]是sock,則可以為socket檔案在本機上的位置.
|
|
|
638 |
$conf["addr"]="/home/liveuser/Downloads/test.sock";
|
|
|
639 |
#$conf["fileArgu"],字串,__FILE__的內容.
|
|
|
640 |
$conf["fileArgu"]=__FILE__;
|
|
|
641 |
#可省略參數:
|
|
|
642 |
#$conf["username"],字串,要用什麼使用者來執行,預設為執行php的使用者,該參數不適用於apache環境.
|
|
|
643 |
#$conf["username"]="root";
|
|
|
644 |
#$conf["password"],字串,與$conf["username"]搭配的使用者密碼,預設不使用密碼,該參數不適用於apache環境.
|
|
|
645 |
#$conf["password"]="superFedoraLinux";
|
|
|
646 |
#$conf["port"],字串,$conf["addr"]為tcp時,連線用的port.
|
|
|
647 |
#$conf["port"]="5901";
|
|
|
648 |
#$conf["title"],字串,遠端視窗的標題要為什麼?預設為連線的位置.
|
|
|
649 |
$conf["title"]="sample-tcp";
|
|
|
650 |
#$conf["fullScreen"],字串,是否一連線就要全螢幕,"true"代表要,"false"代表不要,預設為"false".
|
|
|
651 |
#$conf["fullScreen"]="";
|
|
|
652 |
var_dump(cmd::spice($conf));
|
|
|
653 |
unset($conf);
|
|
|
654 |
|
|
|
655 |
*/
|
|
|
656 |
|
|
|
657 |
echo "<hr>cmd::validRootPasswd - testCase 1<br>";
|
|
|
658 |
|
|
|
659 |
/*
|
|
|
660 |
|
|
|
661 |
#函數說明:
|
|
|
662 |
#藉由使用者的輸入來確認root使用者密碼是否正確.
|
|
|
663 |
#回傳結果:
|
|
|
664 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
665 |
#$result["function"],當前執行的函數名稱.
|
|
|
666 |
#$result["error"],錯誤訊息陣列.
|
|
|
667 |
#$result["content"],root密碼.
|
|
|
668 |
#必填參數:
|
|
|
669 |
#無.
|
|
|
670 |
#可省略參數:
|
|
|
671 |
#$conf["password"],字串,用於驗證root使用者的密碼,若未設定則預設為"rootPasswd".
|
|
|
672 |
#$conf["password"]="";
|
|
|
673 |
$validRootPasswd=cmd::validRootPasswd();
|
|
|
674 |
|
|
|
675 |
#如果取得root密碼失敗
|
|
|
676 |
if($validRootPasswd["status"]==="false"){
|
|
|
677 |
|
|
|
678 |
#印出訊息
|
|
|
679 |
var_dump($validRootPasswd);
|
|
|
680 |
|
|
|
681 |
}#if end
|
|
|
682 |
|
|
|
683 |
#印出 root 密碼
|
|
|
684 |
echo $validRootPasswd["content"];
|
|
|
685 |
|
|
|
686 |
*/
|
|
|
687 |
|
|
|
688 |
#提示正在測試的功能
|
|
|
689 |
echo "<hr>cmd::checkFileKeyStrLBL - testCase 1<br>";
|
|
|
690 |
|
|
|
691 |
/*
|
|
|
692 |
|
|
|
693 |
#函數說明:
|
|
|
694 |
#取得檔的內容並以列為單位搜尋多個關鍵字.
|
|
|
695 |
#回傳結果:
|
|
|
696 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
697 |
#$result["error"],錯誤訊息.
|
|
|
698 |
#$result["function"],當前執行的函數名稱.
|
|
|
699 |
#$result["founded"],每個關鍵字串尋找的結果,"true"代表有找到,"false"代表沒有找到.
|
|
|
700 |
#$result["foundedLine"],每個找到的關鍵字是在第幾列找到的,key值與$result["founded"]的key值一樣.#必填的參數:
|
|
|
701 |
#必填參數:
|
|
|
702 |
#$conf["file"],字串,檔案的位置與名稱.
|
|
|
703 |
$conf["file"]="/etc/httpd/conf/httpd.conf";
|
|
|
704 |
#$conf["keyStr"],陣列字串,要搜尋每列有哪些關鍵字串.
|
|
|
705 |
$conf["keyStr"]=array("LoadModule proxy_module modules/mod_proxy.so","LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so","ProxyPass /wss/chatDemo ws://localhost:8080");
|
|
|
706 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
707 |
$conf["fileArgu"]=__FILE__;
|
|
|
708 |
#可省略參數:
|
|
|
709 |
#$conf["username"],字串,要以哪個使用者來執行,預設為執行該php程式的使用者.
|
|
|
710 |
#$conf["username"]="";
|
|
|
711 |
#$conf["password"],字串,使用者對應的密碼,預設不使用.
|
|
|
712 |
#$conf["password"]="";
|
|
|
713 |
#$conf["tempDir"],字串,暫存資料的目錄位置,預設為"cmd/checkFileKeyStrLBL".
|
|
|
714 |
#$conf["tempDir"]="";
|
|
|
715 |
$checkFileKeyStrLBL=cmd::checkFileKeyStrLBL($conf);
|
|
|
716 |
|
|
|
717 |
#如果執行失敗
|
|
|
718 |
if($checkFileKeyStrLBL["status"]==="false"){
|
|
|
719 |
|
|
|
720 |
#印出內容
|
|
|
721 |
var_dump($checkFileKeyStrLBL);
|
|
|
722 |
|
|
|
723 |
#結束程式
|
|
|
724 |
exit;
|
|
|
725 |
|
|
|
726 |
}#if end
|
|
|
727 |
|
|
|
728 |
var_dump($checkFileKeyStrLBL);
|
|
|
729 |
|
|
|
730 |
*/
|
|
|
731 |
|
|
|
732 |
#/*
|
|
|
733 |
|
|
|
734 |
#提示正在測試的功能
|
|
|
735 |
echo "<hr>cmd::cp - testCase 1<br>";
|
|
|
736 |
|
|
|
737 |
#涵式說明:
|
|
|
738 |
#複製檔案
|
|
|
739 |
#回傳結果:
|
|
|
740 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
741 |
#$result["error"],錯誤訊息.
|
|
|
742 |
#$result["function"],當前執行的函數名稱.
|
|
|
743 |
#$result["content"],複製好的檔案路徑與名稱.
|
|
|
744 |
#必填的參數:
|
|
|
745 |
#$conf["file"],字串,檔案的位置與名稱.
|
|
|
746 |
$conf["file"]="cmdT.php";
|
|
|
747 |
#$conf["to"],字串,檔案要複製到哪裡.
|
|
|
748 |
$conf["to"]="cmdT.php.backup";
|
|
|
749 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
750 |
$conf["fileArgu"]=__FILE__;
|
|
|
751 |
#可省略參數:
|
|
|
752 |
#$conf["username"],字串,要以哪個使用者來執行,預設為執行該php程式的使用者.
|
|
|
753 |
#$conf["username"]="";
|
|
|
754 |
#$conf["password"],字串,使用者對應的密碼,預設不使用.
|
|
|
755 |
#$conf["password"]="";
|
|
|
756 |
#備註:
|
|
|
757 |
#建構中...
|
|
|
758 |
var_dump(cmd::cp($conf));
|
|
|
759 |
|
|
|
760 |
#*/
|
|
|
761 |
|
|
|
762 |
/*
|
|
|
763 |
|
|
|
764 |
#提示正在測試的功能
|
|
|
765 |
echo "<hr>cmd::cp - testCase 2<br>";
|
|
|
766 |
|
|
|
767 |
#涵式說明:
|
|
|
768 |
#複製檔案
|
|
|
769 |
#回傳結果:
|
|
|
770 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
771 |
#$result["error"],錯誤訊息.
|
|
|
772 |
#$result["function"],當前執行的函數名稱.
|
|
|
773 |
#$result["content"],複製好的檔案路徑與名稱.
|
|
|
774 |
#必填的參數:
|
|
|
775 |
#$conf["file"],字串,檔案的位置與名稱.
|
|
|
776 |
$conf["file"]="cmdT not exist.php";
|
|
|
777 |
#$conf["to"],字串,檔案要複製到哪裡.
|
|
|
778 |
$conf["to"]="cmdT.php.backup";
|
|
|
779 |
#可省略參數:
|
|
|
780 |
#$conf["username"],字串,要以哪個使用者來執行,預設為執行該php程式的使用者.
|
|
|
781 |
#$conf["username"]="";
|
|
|
782 |
#$conf["password"],字串,使用者對應的密碼,預設不使用.
|
|
|
783 |
#$conf["password"]="";
|
|
|
784 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
785 |
#$conf["fileArgu"]=__FILE__;
|
|
|
786 |
#備註:
|
|
|
787 |
#建構中...
|
|
|
788 |
var_dump(cmd::cp($conf));
|
|
|
789 |
|
|
|
790 |
*/
|
|
|
791 |
|
|
|
792 |
#提示正在測試的功能
|
|
|
793 |
echo "<hr>cmd::getFileContent - testCase 1<br>";
|
|
|
794 |
|
|
|
795 |
/*
|
|
|
796 |
|
|
|
797 |
#涵式說明:
|
|
|
798 |
#取得檔案內容
|
|
|
799 |
#回傳內容
|
|
|
800 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
801 |
#$result["error"],錯誤訊息.
|
|
|
802 |
#$result["function"],當前執行的函數名稱.
|
|
|
803 |
#$result["content"],檔案的內容.
|
|
|
804 |
#必填參數:
|
|
|
805 |
#$conf["file"],字串,想要取得內容的檔案位置.
|
|
|
806 |
$conf["file"]="cmdT.php";
|
|
|
807 |
#$conf["fileArgu"],字串,當前檔案的位置,亦即__FILE__.
|
|
|
808 |
$conf["fileArgu"]=__FILE__;
|
|
|
809 |
#可省略參數:
|
|
|
810 |
#$conf["username"],字串,要以哪個使用者來執行,預設為執行該php程式的使用者.
|
|
|
811 |
#$conf["username"]="";
|
|
|
812 |
#$conf["password"],字串,使用者對應的密碼,預設不使用.
|
|
|
813 |
#$conf["password"]="";
|
|
|
814 |
#備註:
|
|
|
815 |
#建構中...
|
|
|
816 |
$getFileContent=cmd::getFileContent($conf);
|
|
|
817 |
unset($conf);
|
|
|
818 |
|
|
|
819 |
#如果取得檔案內容失敗
|
|
|
820 |
if($getFileContent["status"]==="false"){
|
|
|
821 |
|
|
|
822 |
#印出錯誤訊息
|
|
|
823 |
var_dump($getFileContent);
|
|
|
824 |
|
|
|
825 |
#停止程式
|
|
|
826 |
exit;
|
|
|
827 |
|
|
|
828 |
}#if end
|
|
|
829 |
|
|
|
830 |
#印出取得的檔案內容
|
|
|
831 |
var_dump($getFileContent["content"]);
|
|
|
832 |
|
|
|
833 |
*/
|
|
|
834 |
|
|
|
835 |
#提示正在測試的功能
|
|
|
836 |
echo "<hr>cmd::addTextToFile - testCase 1<br>";
|
|
|
837 |
|
|
|
838 |
/*
|
|
|
839 |
|
|
|
840 |
#涵式說明:
|
|
|
841 |
#新增文字內容到檔案裡面
|
|
|
842 |
#回傳結果:
|
|
|
843 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
844 |
#$result["error"],錯誤訊息.
|
|
|
845 |
#$result["function"],當前執行的函數名稱.
|
|
|
846 |
#$result["content"],新增好後的檔案內容.
|
|
|
847 |
#必填的參數:
|
|
|
848 |
#$conf["file"],字串,檔案的位置與名稱.
|
|
|
849 |
$conf["cmd::addTextToFile"]["file"]="cmdT/cmd::addTextToFile";
|
|
|
850 |
#$conf["addStr"],陣列字串,要新增的字串內容.
|
|
|
851 |
$conf["cmd::addTextToFile"]["addStr"]=array("a","b","c");
|
|
|
852 |
#可省略參數:
|
|
|
853 |
#$conf["username"],字串,要以哪個使用者來執行,預設為執行該php程式的使用者.
|
|
|
854 |
#$conf["username"]="";
|
|
|
855 |
#$conf["password"],字串,使用者對應的密碼,預設為"password".
|
|
|
856 |
#$conf["password"]="";
|
|
|
857 |
#$conf["fileArgu"],字串,__FILE__的內容,預設為當前檔案的位置.
|
|
|
858 |
$conf["cmd::addTextToFile"]["fileArgu"]=__FILE__;
|
|
|
859 |
#備註:
|
|
|
860 |
#建構中...
|
|
|
861 |
$addTextToFile=cmd::addTextToFile($conf["cmd::addTextToFile"]);
|
|
|
862 |
unset($conf["cmd::addTextToFile"]);
|
|
|
863 |
|
|
|
864 |
#如果新增內容失敗
|
|
|
865 |
if($addTextToFile["status"]==="false"){
|
|
|
866 |
|
|
|
867 |
#印出訊息
|
|
|
868 |
var_dump($addTextToFile);
|
|
|
869 |
|
|
|
870 |
#結束程式
|
|
|
871 |
exit;
|
|
|
872 |
|
|
|
873 |
}#if end
|
|
|
874 |
|
|
|
875 |
#印出新增好內容的檔案內容
|
|
|
876 |
var_dump($addTextToFile["content"]);
|
|
|
877 |
|
|
|
878 |
*/
|
|
|
879 |
|
|
|
880 |
#提示正在測試的功能
|
|
|
881 |
echo "<hr>cmd::checkCmdExist - testCase 1<br>";
|
|
|
882 |
|
|
|
883 |
/*
|
|
|
884 |
|
|
|
885 |
#函式說明:
|
|
|
886 |
#檢查指令是否存在
|
|
|
887 |
#回傳結果:
|
|
|
888 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
889 |
#$result["error"],錯誤訊息.
|
|
|
890 |
#$result["function"],當前執行的函數名稱.
|
|
|
891 |
#$result["argu"],使用的參數.
|
|
|
892 |
#$result["content"],新增好後的檔案內容.
|
|
|
893 |
#必填參數:
|
|
|
894 |
#$conf["cmd"],"字串",要查詢的指令.
|
|
|
895 |
$conf["cmd"]="qemu-system-x86_64";
|
|
|
896 |
#可省略參數:
|
|
|
897 |
#$conf["binPath"],字串,要搜尋的路徑,預設為"/usr/bin".
|
|
|
898 |
#$conf["binPath"]="";
|
|
|
899 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
900 |
$conf["fileArgu"]=__FILE__;
|
|
|
901 |
$checkCmdExist=cmd::checkCmdExist($conf);
|
|
|
902 |
unset($conf);
|
|
|
903 |
|
|
|
904 |
#如果新增內容失敗
|
|
|
905 |
if($checkCmdExist["status"]==="false"){
|
|
|
906 |
|
|
|
907 |
#印出訊息
|
|
|
908 |
var_dump($checkCmdExist);
|
|
|
909 |
|
|
|
910 |
#結束程式
|
|
|
911 |
exit;
|
|
|
912 |
|
|
|
913 |
}#if end
|
|
|
914 |
|
|
|
915 |
#印出新增好內容的檔案內容
|
|
|
916 |
var_dump($checkCmdExist["founded"]);
|
|
|
917 |
|
|
|
918 |
*/
|
|
|
919 |
|
|
|
920 |
#提示正在測試的功能
|
|
|
921 |
echo "<hr>cmd::searchOutPut - testCase 1<br>";
|
|
|
922 |
|
|
|
923 |
/*
|
|
|
924 |
|
|
|
925 |
#函數說明:
|
|
|
926 |
#檢查指令的輸出是否含有關鍵字
|
|
|
927 |
#回傳結果:
|
|
|
928 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
929 |
#$result["error"],錯誤訊息.
|
|
|
930 |
#$result["function"],當前執行的函數名稱.
|
|
|
931 |
#$result["argu"],使用的參數.
|
|
|
932 |
#$result["founded"],是否找到關鍵字,"true"代表有,"false"代表沒有.
|
|
|
933 |
#必填參數:
|
|
|
934 |
#$conf["cmd"],字串,要執行的指令.
|
|
|
935 |
$conf["cmd"]="lscpu";
|
|
|
936 |
#$conf["keyWord"],字串,要檢查是否有關鍵字.
|
|
|
937 |
$conf["keyWord"]="vmx";
|
|
|
938 |
#可省略參數:
|
|
|
939 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
940 |
$conf["fileArgu"]=__FILE__;
|
|
|
941 |
$searchOutPut=cmd::searchOutPut($conf);
|
|
|
942 |
|
|
|
943 |
#如果選找指令的輸出沒有關鍵字
|
|
|
944 |
if($searchOutPut["status"]==="false"){
|
|
|
945 |
|
|
|
946 |
#印出訊息
|
|
|
947 |
var_dump($searchOutPut);
|
|
|
948 |
|
|
|
949 |
#結束程式
|
|
|
950 |
exit;
|
|
|
951 |
|
|
|
952 |
}#if end
|
|
|
953 |
|
|
|
954 |
#印出搜尋的狀態
|
|
|
955 |
var_dump($searchOutPut["founded"]);
|
|
|
956 |
|
|
|
957 |
*/
|
|
|
958 |
|
|
|
959 |
#提示正在測試的功能
|
|
|
960 |
echo "<hr>cmd::searchOutPut - testCase 2<br>";
|
|
|
961 |
|
|
|
962 |
/*
|
|
|
963 |
|
|
|
964 |
#函數說明:
|
|
|
965 |
#檢查指令的輸出是否含有關鍵字
|
|
|
966 |
#回傳結果:
|
|
|
967 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
968 |
#$result["error"],錯誤訊息.
|
|
|
969 |
#$result["function"],當前執行的函數名稱.
|
|
|
970 |
#$result["argu"],使用的參數.
|
|
|
971 |
#$result["founded"],是否找到關鍵字,"true"代表有,"false"代表沒有.
|
|
|
972 |
#必填參數:
|
|
|
973 |
#$conf["cmd"],字串,要執行的指令.
|
|
|
974 |
$conf["cmd"]="lscpu";
|
|
|
975 |
#$conf["keyWord"],字串,要檢查是否有關鍵字.
|
|
|
976 |
$conf["keyWord"]="pae";
|
|
|
977 |
#可省略參數:
|
|
|
978 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
979 |
$conf["fileArgu"]=__FILE__;
|
|
|
980 |
$searchOutPut=cmd::searchOutPut($conf);
|
|
|
981 |
|
|
|
982 |
#如果選找指令的輸出沒有關鍵字
|
|
|
983 |
if($searchOutPut["status"]==="false"){
|
|
|
984 |
|
|
|
985 |
#印出訊息
|
|
|
986 |
var_dump($searchOutPut);
|
|
|
987 |
|
|
|
988 |
#結束程式
|
|
|
989 |
exit;
|
|
|
990 |
|
|
|
991 |
}#if end
|
|
|
992 |
|
|
|
993 |
#印出搜尋的狀態
|
|
|
994 |
var_dump($searchOutPut["founded"]);
|
|
|
995 |
var_dump($searchOutPut["content"]);
|
|
|
996 |
|
|
|
997 |
*/
|
|
|
998 |
|
|
|
999 |
#提示正在測試的功能
|
|
|
1000 |
echo "<hr>cmd::searchOutPut - testCase 3<br>";
|
|
|
1001 |
|
|
|
1002 |
/*
|
|
|
1003 |
|
|
|
1004 |
#函數說明:
|
|
|
1005 |
#檢查指令的輸出是否含有關鍵字
|
|
|
1006 |
#回傳結果:
|
|
|
1007 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1008 |
#$result["error"],錯誤訊息.
|
|
|
1009 |
#$result["function"],當前執行的函數名稱.
|
|
|
1010 |
#$result["argu"],使用的參數.
|
|
|
1011 |
#$result["founded"],是否找到關鍵字,"true"代表有,"false"代表沒有.
|
|
|
1012 |
#必填參數:
|
|
|
1013 |
#$conf["cmd"],字串,要執行的指令.
|
|
|
1014 |
$conf["cmd"]="lscpu1";
|
|
|
1015 |
#$conf["keyWord"],字串,要檢查是否有關鍵字.
|
|
|
1016 |
$conf["keyWord"]="pae";
|
|
|
1017 |
#可省略參數:
|
|
|
1018 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
1019 |
$conf["fileArgu"]=__FILE__;
|
|
|
1020 |
$searchOutPut=cmd::searchOutPut($conf);
|
|
|
1021 |
|
|
|
1022 |
#如果選找指令的輸出沒有關鍵字
|
|
|
1023 |
if($searchOutPut["status"]==="false"){
|
|
|
1024 |
|
|
|
1025 |
#印出訊息
|
|
|
1026 |
var_dump($searchOutPut);
|
|
|
1027 |
|
|
|
1028 |
#結束程式
|
|
|
1029 |
exit;
|
|
|
1030 |
|
|
|
1031 |
}#if end
|
|
|
1032 |
|
|
|
1033 |
#印出搜尋的狀態
|
|
|
1034 |
var_dump($searchOutPut["founded"]);
|
|
|
1035 |
var_dump($searchOutPut["content"]);
|
|
|
1036 |
|
|
|
1037 |
*/
|
|
|
1038 |
|
|
|
1039 |
#提示正在測試的功能
|
|
|
1040 |
echo "<hr>cmd::searchOutPut - testCase 4<br>";
|
|
|
1041 |
|
|
|
1042 |
/*
|
|
|
1043 |
|
|
|
1044 |
#函數說明:
|
|
|
1045 |
#檢查指令的輸出是否含有關鍵字
|
|
|
1046 |
#回傳結果:
|
|
|
1047 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1048 |
#$result["error"],錯誤訊息.
|
|
|
1049 |
#$result["function"],當前執行的函數名稱.
|
|
|
1050 |
#$result["argu"],使用的參數.
|
|
|
1051 |
#$result["founded"],是否找到關鍵字,"true"代表有,"false"代表沒有.
|
|
|
1052 |
#必填參數:
|
|
|
1053 |
#$conf["cmd"],字串,要執行的指令.
|
|
|
1054 |
$conf["cmd"]="echo 123";
|
|
|
1055 |
#$conf["keyWord"],字串,要檢查是否有關鍵字.
|
|
|
1056 |
$conf["keyWord"]="12";
|
|
|
1057 |
#可省略參數:
|
|
|
1058 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
1059 |
$conf["fileArgu"]=__FILE__;
|
|
|
1060 |
$searchOutPut=cmd::searchOutPut($conf);
|
|
|
1061 |
|
|
|
1062 |
#如果選找指令的輸出沒有關鍵字
|
|
|
1063 |
if($searchOutPut["status"]==="false"){
|
|
|
1064 |
|
|
|
1065 |
#印出訊息
|
|
|
1066 |
var_dump($searchOutPut);
|
|
|
1067 |
|
|
|
1068 |
#結束程式
|
|
|
1069 |
exit;
|
|
|
1070 |
|
|
|
1071 |
}#if end
|
|
|
1072 |
|
|
|
1073 |
#印出搜尋的狀態
|
|
|
1074 |
var_dump($searchOutPut["founded"]);
|
|
|
1075 |
var_dump($searchOutPut["content"]);
|
|
|
1076 |
|
|
|
1077 |
*/
|
|
|
1078 |
|
|
|
1079 |
#提示正在測試的功能
|
|
|
1080 |
echo "<hr>cmd::searchOutPut - testCase 5<br>";
|
|
|
1081 |
|
|
|
1082 |
/*
|
|
|
1083 |
|
|
|
1084 |
#函數說明:
|
|
|
1085 |
#檢查指令的輸出是否含有關鍵字
|
|
|
1086 |
#回傳結果:
|
|
|
1087 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1088 |
#$result["error"],錯誤訊息.
|
|
|
1089 |
#$result["function"],當前執行的函數名稱.
|
|
|
1090 |
#$result["argu"],使用的參數.
|
|
|
1091 |
#$result["founded"],是否找到關鍵字,"true"代表有,"false"代表沒有.
|
|
|
1092 |
#必填參數:
|
|
|
1093 |
#$conf["cmd"],字串,要執行的指令.
|
|
|
1094 |
$conf["cmd"]="echo2 123";
|
|
|
1095 |
#$conf["keyWord"],字串,要檢查是否有關鍵字.
|
|
|
1096 |
$conf["keyWord"]="12";
|
|
|
1097 |
#可省略參數:
|
|
|
1098 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
1099 |
$conf["fileArgu"]=__FILE__;
|
|
|
1100 |
$searchOutPut=cmd::searchOutPut($conf);
|
|
|
1101 |
|
|
|
1102 |
#如果選找指令的輸出沒有關鍵字
|
|
|
1103 |
if($searchOutPut["status"]==="false"){
|
|
|
1104 |
|
|
|
1105 |
#印出訊息
|
|
|
1106 |
var_dump($searchOutPut);
|
|
|
1107 |
|
|
|
1108 |
#結束程式
|
|
|
1109 |
exit;
|
|
|
1110 |
|
|
|
1111 |
}#if end
|
|
|
1112 |
|
|
|
1113 |
#印出搜尋的狀態
|
|
|
1114 |
var_dump($searchOutPut["founded"]);
|
|
|
1115 |
var_dump($searchOutPut["content"]);
|
|
|
1116 |
|
|
|
1117 |
*/
|
|
|
1118 |
|
|
|
1119 |
#提示正在測試的功能
|
|
|
1120 |
echo "<hr>cmd::nmap - testCase 1<br>";
|
|
|
1121 |
|
|
|
1122 |
/*
|
|
|
1123 |
|
|
|
1124 |
#函式說明:
|
|
|
1125 |
#掃port的程式
|
|
|
1126 |
#回傳結果:
|
|
|
1127 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1128 |
#$result["error"],錯誤訊息.
|
|
|
1129 |
#$result["function"],當前執行的函數名稱.
|
|
|
1130 |
#$result["argu"],使用的參數.
|
|
|
1131 |
#$result["content"],掃好可能可以使用的port資訊.
|
|
|
1132 |
#必填參數
|
|
|
1133 |
#無:
|
|
|
1134 |
#可省略參數:
|
|
|
1135 |
#$conf["target"],字串,要掃描的主機,預設為"127.0.0.1",
|
|
|
1136 |
#$conf["target"]="127.0.0.1";
|
|
|
1137 |
#$conf["-Pn"],字串,是否要啟用避免ping不到就會掃port失敗的功能,預設為"false".
|
|
|
1138 |
#$conf["-Pn"]="false";
|
|
|
1139 |
#$conf["fileArgu"],字串,變數__FILE__的內容.
|
|
|
1140 |
#$conf["fileArgu"]=__FILE__;
|
|
|
1141 |
#備註:
|
|
|
1142 |
#建構中...
|
|
|
1143 |
$nmap=cmd::nmap();
|
|
|
1144 |
|
|
|
1145 |
#如果執行失敗
|
|
|
1146 |
if($nmap["status"]==="false"){
|
|
|
1147 |
|
|
|
1148 |
#印出訊息
|
|
|
1149 |
var_dump($nmap);
|
|
|
1150 |
|
|
|
1151 |
#結束程式
|
|
|
1152 |
exit;
|
|
|
1153 |
|
|
|
1154 |
}#if end
|
|
|
1155 |
|
|
|
1156 |
#印出使用中的port
|
|
|
1157 |
var_dump($nmap["content"]);
|
|
|
1158 |
|
|
|
1159 |
*/
|
|
|
1160 |
|
|
|
1161 |
#提示正在測試的功能
|
|
|
1162 |
echo "<hr>cmd::nmcli_list - testCase 1<br>";
|
|
|
1163 |
|
|
|
1164 |
/*
|
|
|
1165 |
|
|
|
1166 |
#函式說明:
|
|
|
1167 |
#fedora的nmcli指令,取得所有網路連線設定的資訊.
|
|
|
1168 |
#回傳結果:
|
|
|
1169 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
1170 |
#$result["error"],錯誤訊息.
|
|
|
1171 |
#$result["function"],當前執行的函數名稱.
|
|
|
1172 |
#$result["argu"],使用的參數.
|
|
|
1173 |
#$result["content"],連線資訊.
|
|
|
1174 |
#必填參數
|
|
|
1175 |
#$conf["fileArgu"],字串,__FILE__的內容.
|
|
|
1176 |
$conf["fileArgu"]=__FILE__;
|
|
|
1177 |
#可省略參數:
|
|
|
1178 |
#無.
|
|
|
1179 |
#備註:
|
|
|
1180 |
#僅能在命令列環境下執行.
|
|
|
1181 |
$nmcli_list=cmd::nmcli_list($conf);
|
|
|
1182 |
unset($conf);
|
|
|
1183 |
|
|
|
1184 |
#如果執行失敗
|
|
|
1185 |
if($nmcli_list["status"]==="false"){
|
|
|
1186 |
|
|
|
1187 |
#印出內容
|
|
|
1188 |
var_dump($nmcli_list);
|
|
|
1189 |
|
|
|
1190 |
#結束程式
|
|
|
1191 |
exit;
|
|
|
1192 |
|
|
|
1193 |
}#if end
|
|
|
1194 |
|
|
|
1195 |
#反之
|
|
|
1196 |
else{
|
|
|
1197 |
|
|
|
1198 |
#印出內容
|
|
|
1199 |
var_dump($nmcli_list);
|
|
|
1200 |
|
|
|
1201 |
}#else end
|
|
|
1202 |
|
|
|
1203 |
*/
|
|
|
1204 |
|
|
|
1205 |
?>
|