| 757 |
liveuser |
1 |
#!/bin/php
|
|
|
2 |
<?php
|
|
|
3 |
|
|
|
4 |
/*
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
|
|
6 |
Copyright (C) 2015~2024 Min-Jhin,Chen
|
|
|
7 |
|
|
|
8 |
This file is part of QBPWCF.
|
|
|
9 |
|
|
|
10 |
QBPWCF is free software: you can redistribute it and/or modify
|
|
|
11 |
it under the terms of the GNU General Public License as published by
|
|
|
12 |
the Free Software Foundation, either version 3 of the License, or
|
|
|
13 |
(at your option) any later version.
|
|
|
14 |
|
|
|
15 |
QBPWCF is distributed in the hope that it will be useful,
|
|
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
18 |
GNU General Public License for more details.
|
|
|
19 |
|
|
|
20 |
You should have received a copy of the GNU General Public License
|
|
|
21 |
along with QBPWCF. If not, see <http://www.gnu.org/licenses/>.
|
|
|
22 |
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
/*
|
|
|
26 |
說明:
|
|
|
27 |
啟動 用來接收 request 來跟 web socket server 互動.
|
|
|
28 |
|
|
|
29 |
範例:
|
|
|
30 |
webSocketClientDaemon.php [--domain server.wss.org] [--path wss] [--port 443]
|
|
|
31 |
*/
|
|
|
32 |
|
|
|
33 |
#使用命名空間qbpwcf
|
|
|
34 |
namespace qbpwcf;
|
|
|
35 |
|
|
|
36 |
#以該檔案的實際位置的 lib path 為 include path 首位
|
| 919 |
liveuser |
37 |
exec("cd ".pathinfo(__FILE__)["dirname"]."/../lib/qbpwcf;pwd;",$output,$status);
|
| 757 |
liveuser |
38 |
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
|
|
|
39 |
|
|
|
40 |
#匯入外部套件
|
|
|
41 |
include("allInOne.php");
|
|
|
42 |
|
|
|
43 |
#說明函式
|
|
|
44 |
function help()
|
|
|
45 |
{
|
|
|
46 |
#印出指令說明
|
|
|
47 |
echo "Usage of ".basename(__FILE__).":".PHP_EOL;
|
|
|
48 |
echo "--domain 代表要連線的 web socket 服務域名".PHP_EOL;
|
|
|
49 |
echo "--path 代表要連線的 web socket 服務path,預設為 wss".PHP_EOL;
|
|
|
50 |
echo "--port 代表要連線的 web socket 服務port,預設為 443".PHP_EOL;
|
|
|
51 |
|
|
|
52 |
#結束執行
|
|
|
53 |
exit;
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
#函式說明:
|
|
|
57 |
#解析參數.
|
|
|
58 |
#回傳結果:
|
|
|
59 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
60 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
61 |
#$result["function"],當前執行的函式名稱.
|
|
|
62 |
#$result["content"],解析好的參數陣列.
|
|
|
63 |
#$result["content"][$key][$i],參數 $key 的 $i+1 個參數數值內容.
|
|
|
64 |
#$result["program"],字串,執行的程式名稱.
|
|
|
65 |
#必填參數:
|
|
|
66 |
#無
|
|
|
67 |
#可省略參數:
|
|
|
68 |
#$conf["helpFunc"],如果解析的參數不成對,則要執行的函式名稱.
|
|
|
69 |
$conf["helpFunc"]="help";
|
|
|
70 |
#備註:
|
|
|
71 |
#僅能在命令列底下執行.
|
|
|
72 |
#建議:
|
|
|
73 |
#以後可將參數 --a--b 的名稱與後面的數值 $value 存成 $result["a"]["b"][$i]=$value .
|
|
|
74 |
$parseArgu=cmd::parseArgu($conf);
|
|
|
75 |
unset($conf);
|
|
|
76 |
|
|
|
77 |
#如果解析參數失敗
|
|
|
78 |
if($parseArgu["status"]==="false")
|
|
|
79 |
{
|
|
|
80 |
#印出結果
|
|
|
81 |
var_dump($parseArgu);
|
|
|
82 |
|
|
|
83 |
#結束執行,回傳shell 1
|
|
|
84 |
exit(1);
|
|
|
85 |
|
|
|
86 |
}#if end
|
|
|
87 |
|
|
|
88 |
#檢查參數
|
|
|
89 |
#函式說明:
|
|
|
90 |
#檢查必填與可省略參數,可省略參數可指定預設要給與什麼數值內容。
|
|
|
91 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
92 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
93 |
#$result["function"],當前執行的函式名稱.
|
|
|
94 |
#$result["passed"],識別要檢查的全體變數是否存在以及型態是否正確的變數,"true"代表檢查全部通過;"false"代表檢查不通過
|
|
|
95 |
#$result[$shouldBeCheckedVarName]["varExist"],所檢查的變數是否存在,"false"代表不存在;"true"代表存在
|
|
|
96 |
#$result[$shouldBeCheckedVarName]["varType"],所檢查的變數型態是否正確,"false"代表錯誤;"true"代表正確
|
|
|
97 |
#$result[$shouldBeCheckedVarName]["error"],每個參數設定的錯誤訊息
|
|
|
98 |
#$result["shouldNotBeEmpty"],不應該為空字串或控陣列的變數.
|
|
|
99 |
#$result["argu"],字串陣列,目前輸入的參數名稱陣列.
|
|
|
100 |
#$result["legalVarName"],字串陣列,合法可用的參數名稱陣列.
|
|
|
101 |
#$result["notNeedVar"],字串陣列,多餘的參數名稱.
|
|
|
102 |
#必填寫的參數:
|
|
|
103 |
#$conf["varInput"],陣列變數,要檢查的陣列變數,請在要檢查的參數前面加上&,這樣變動的結果才能被套用。
|
|
|
104 |
$conf["varInput"]=&$parseArgu["content"];
|
|
|
105 |
#$conf["referenceVarKey"],字串,$conf參數後面的key值,用於移除不要的參考陣列.
|
|
|
106 |
$conf["referenceVarKey"]="variableCheck::checkArguments";
|
|
|
107 |
#可以省略的參數:
|
|
|
108 |
#$conf["mustBeFilledVariableName"],爲必填參數的變數名稱陣列,形態爲陣列變數,元素數量需要跟"mustBeFilledVariableType"參數的元素數量一致,例如: $conf["mustBeFilledVariableName"] = array("id","account","password");
|
|
|
109 |
$conf["mustBeFilledVariableName"]=array("domain");
|
|
|
110 |
#$conf["mustBeFilledVariableType"],爲必填參數的變數陣列應該爲何種變數形態,形態爲陣列,元素數量需要跟"mustBeFilledVariableName"參數的元素數量一致,例如: $conf["mustBeFilledVariableType"] = array("string",integer,"double","resource","object"); , null代表不指定變數形態.
|
|
|
111 |
$conf["mustBeFilledVariableType"]=array("array");
|
|
|
112 |
#$conf["canBeEmptyString"],字串,必填變數內容如果是空字串就不能算是有設置的話,請設為"false",預設爲"true",可以為空字串.
|
|
|
113 |
$conf["canBeEmptyString"]="false";
|
|
|
114 |
#$conf["canNotBeEmpty"],字串陣列,哪些必填參數的內容不得為空字串或空陣列,僅當$conf["canBeEmptyString"]為"true"時會生效.
|
|
|
115 |
#$conf["canNotBeEmpty"]=array();
|
|
|
116 |
#$conf["canBeEmpty"],字串陣列,哪些必填參數的內容可為空字串或空陣列,僅當$conf["canBeEmptyString"]為"false"時會生效.
|
|
|
117 |
#$conf["canBeEmpty"]=array();
|
|
|
118 |
#$conf["skipableVariableCanNotBeEmpty"],字串陣列,哪些可省略參數不可以為空字串或空陣列.
|
|
|
119 |
$conf["skipableVariableCanNotBeEmpty"]=array("path","port");
|
|
|
120 |
#$conf["skipableVariableName"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableName"] = array("id","account","password");
|
|
|
121 |
$conf["skipableVariableName"]=array("path","port");
|
|
|
122 |
#$conf["skipableVariableType"],陣列字串,爲可省略參數的變數名稱陣列,形態爲陣列變數,例如: $conf["skipableVariableType"] = array("string",integer,"double");
|
|
|
123 |
$conf["skipableVariableType"]=array("array","array");
|
|
|
124 |
#$conf["skipableVarDefaultValue"],字串陣列,每個不存在的可省略變數要初始化為什麼,null與代表不指定,若預設值是參數之一,請將$conf["mustBeFilledVar"]改成"\$conf["\mustBeFilledVar\"]".
|
|
|
125 |
$conf["skipableVarDefaultValue"]=array(array("wss"),array(443));
|
|
|
126 |
#$conf["disallowAllSkipableVarIsEmpty"],字串,是否允許每個可省略參數都為空字串,預設為"true"允許,反之為"false".
|
|
|
127 |
#$conf["variableCheck::checkArguments"]["disallowAllSkipableVarIsEmpty"]="false";
|
|
|
128 |
#$conf["disallowAllSkipableVarIsEmptyArray"],字串,是否允許每個可省略參數都為空陣列,預設為"true"允許,反之為"false".
|
|
|
129 |
#$conf["disallowAllSkipableVarIsEmptyArray"]="";
|
|
|
130 |
#$conf["arrayCountEqualCheck"],字串陣列,為檢查哪些陣列參數的元素數量要一樣,$conf["arrayCountEqualCheck"][$i]=array()為第$i組key為哪些的變數其元素數量要相等.
|
|
|
131 |
#$conf["arrayCountEqualCheck"][]=array();
|
|
|
132 |
#參考資料來源:
|
|
|
133 |
#array_keys=>http://php.net/manual/en/function.array-keys.php
|
|
|
134 |
$checkArguments=variableCheck::checkArguments($conf);
|
|
|
135 |
unset($conf);
|
|
|
136 |
|
|
|
137 |
#若執行失敗
|
|
|
138 |
if($checkArguments["status"]==="false"){
|
|
|
139 |
|
|
|
140 |
#印出結果
|
|
|
141 |
var_dump($checkArguments);
|
|
|
142 |
|
|
|
143 |
#結束執行,回傳shell 1
|
|
|
144 |
exit(1);
|
|
|
145 |
|
|
|
146 |
}#if end
|
|
|
147 |
|
|
|
148 |
#若檢查不通過
|
|
|
149 |
if($checkArguments["passed"]==="false"){
|
|
|
150 |
|
|
|
151 |
#印出結果
|
|
|
152 |
var_dump($checkArguments);
|
|
|
153 |
|
|
|
154 |
#結束執行,回傳shell 1
|
|
|
155 |
exit(1);
|
|
|
156 |
|
|
|
157 |
}#if end
|
|
|
158 |
|
|
|
159 |
#預設的 unix doamin socket
|
| 765 |
liveuser |
160 |
#$defaultUnixDomainSocket="./".basename(__FILE__).".sock";
|
| 757 |
liveuser |
161 |
|
|
|
162 |
#取得各項參數
|
|
|
163 |
$addr=$parseArgu["content"]["domain"][0];
|
|
|
164 |
$path=$parseArgu["content"]["path"][0];
|
|
|
165 |
$port=$parseArgu["content"]["port"][0];
|
|
|
166 |
|
|
|
167 |
#函式說明:
|
|
|
168 |
#透過proc來多執行序運作.
|
|
|
169 |
#回傳結果:
|
|
|
170 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
171 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
172 |
#$result["function"],當前執行的函式名稱.
|
|
|
173 |
#$result["argu"],使用的參數.
|
|
|
174 |
#$result["content"],陣列,每個元素為其指令執行的結果訊息陣列,key為"status"代表執行是否正常的識別;key為"statusCode"代表程式結束後回傳給對應executeBy程式的數值;key為"output"代表標準輸出,若為resource,則代表為pipe;key為"error"代表非標準輸出,若為resource,則代表為pipe;key為"input"代表成功輸入的指令;key為"process"代表該程序經proc_open後的process source;key為"proc_get_status"代表程序的資訊.
|
|
|
175 |
#必填參數:
|
|
|
176 |
#$conf["cmds"],字串陣列,每個元素代表要執行的指令與參數.
|
|
|
177 |
$conf["cmds"]=array("./libexec/webSocketClientDaemon.php --domain ".$addr." --path ".$path." --port ".$port);
|
|
|
178 |
#可省略參數:
|
|
|
179 |
#$conf["wait"],字串,是否需要等待所有程序結束,預設為"true"要等待;反之為"false"不要等待.
|
|
|
180 |
$conf["wait"]="false";
|
|
|
181 |
#$conf["workingDir"],字串陣列,個別程式執行時的家目錄,預設不指定.
|
|
|
182 |
#$conf["workingDir"]=array("path");
|
|
|
183 |
#$conf["envs"],2維字串陣列,每個元素代表個別程式執行時的指定環境變數,key變數名稱;value為變數內容.預設為array("QBPWCF" => "Quick Build PHP Website Componment base on Fedora Linux");
|
|
|
184 |
#$conf["envs"]=array(array("key"=>"value"));
|
|
|
185 |
#$conf["executeBy"],字串陣列,每個元素代表個別指令要用什麼程式執行,預設為"bash".
|
|
|
186 |
#$conf["executeBy"]=array("bash");
|
|
|
187 |
#參考資料:
|
|
|
188 |
#https://www.php.net/manual/en/function.proc-open.php
|
|
|
189 |
#https://www.php.net/manual/en/function.proc-get-status.php
|
|
|
190 |
#備註:
|
|
|
191 |
#無.
|
|
|
192 |
$proc=threads::proc($conf);
|
|
|
193 |
unset($conf);
|
|
|
194 |
|
|
|
195 |
#如果執行失敗
|
|
|
196 |
if($proc["status"]==="false"){
|
|
|
197 |
|
|
|
198 |
#印出結果
|
|
|
199 |
var_dump($proc);
|
|
|
200 |
|
|
|
201 |
#結束執行,回傳shell 1
|
|
|
202 |
exit(1);
|
|
|
203 |
|
|
|
204 |
}#if end
|
|
|
205 |
|
|
|
206 |
#提示執行的指令
|
|
|
207 |
echo "輸入指令:".$proc["content"][0]["input"]." 成功.".PHP_EOL;
|
|
|
208 |
|
|
|
209 |
#無窮迴圈
|
|
|
210 |
while(true){
|
|
|
211 |
|
|
|
212 |
#等待1毫秒
|
|
|
213 |
usleep(100000);
|
|
|
214 |
|
|
|
215 |
#針對每個程序
|
|
|
216 |
foreach($proc["content"] as $index=>$process){
|
|
|
217 |
|
|
|
218 |
#如果程序執行異常
|
|
|
219 |
if($process["status"]==="false"){
|
|
|
220 |
|
|
|
221 |
#debug
|
|
|
222 |
var_dump($proc);
|
|
|
223 |
|
|
|
224 |
#移除該程序資訊
|
|
|
225 |
unset($proc["content"][$index]);
|
|
|
226 |
|
|
|
227 |
}#if end
|
|
|
228 |
|
| 765 |
liveuser |
229 |
#如果是 resource
|
| 757 |
liveuser |
230 |
if(is_resource($process["process"])){
|
|
|
231 |
|
|
|
232 |
#如果error為resource
|
|
|
233 |
if(is_resource($process["error"])){
|
|
|
234 |
|
|
|
235 |
#將建立的 listen sock 放到 $master 陣列
|
|
|
236 |
$master[] = $process["error"];
|
|
|
237 |
|
|
|
238 |
#設置給 stream_select 監控的sock變數
|
|
|
239 |
$read = $write = $except = $master;
|
|
|
240 |
|
|
|
241 |
#等待0.1秒,看有沒有讀寫的狀況
|
|
|
242 |
$mod_fd = stream_select($read, $write, $except, 1);
|
|
|
243 |
|
|
|
244 |
#如果偵測異動失敗
|
|
|
245 |
if($mod_fd===FALSE){
|
|
|
246 |
|
|
|
247 |
#monitior stream failed
|
|
|
248 |
|
|
|
249 |
#debug
|
|
|
250 |
var_dump($proc);
|
|
|
251 |
|
|
|
252 |
#結束執行,回傳shell 1
|
|
|
253 |
exit(1);
|
|
|
254 |
|
|
|
255 |
}#if end
|
|
|
256 |
|
|
|
257 |
#如果有異動的跡象
|
|
|
258 |
else if($mod_fd>0){
|
|
|
259 |
|
|
|
260 |
#針對每個異動的 stream
|
|
|
261 |
foreach($read as $readStream){
|
|
|
262 |
|
|
|
263 |
#如果是有錯誤輸出
|
|
|
264 |
if($readStream===$process["error"]){
|
|
|
265 |
|
|
|
266 |
#debug
|
|
|
267 |
#echo "try read std error output".PHP_EOL;
|
|
|
268 |
|
|
|
269 |
#讀取1Kbyte
|
|
|
270 |
$errorByte=fread($process["error"],1024);
|
|
|
271 |
|
|
|
272 |
#提示為錯誤訊息
|
|
|
273 |
echo "error:";
|
|
|
274 |
|
|
|
275 |
#印出內容
|
|
|
276 |
echo $errorByte;
|
|
|
277 |
|
|
|
278 |
#換行
|
|
|
279 |
echo PHP_EOL;
|
|
|
280 |
|
|
|
281 |
}#if end
|
|
|
282 |
|
|
|
283 |
}#foreach end
|
|
|
284 |
|
|
|
285 |
}#if end
|
|
|
286 |
|
|
|
287 |
}#if end
|
|
|
288 |
|
|
|
289 |
#如果content為resource
|
|
|
290 |
if(is_resource($process["content"])){
|
|
|
291 |
|
|
|
292 |
#將建立的 listen sock 放到 $master 陣列
|
|
|
293 |
$master[] = $process["content"];
|
|
|
294 |
|
|
|
295 |
#設置給 stream_select 監控的sock變數
|
|
|
296 |
$read = $write = $except = $master;
|
|
|
297 |
|
|
|
298 |
#等待1秒,看有沒有讀寫的狀況
|
|
|
299 |
$mod_fd = stream_select($read, $write, $except, 1);
|
|
|
300 |
|
|
|
301 |
#如果偵測異動失敗
|
|
|
302 |
if($mod_fd===FALSE){
|
|
|
303 |
|
|
|
304 |
#monitior stream failed
|
|
|
305 |
|
|
|
306 |
#debug
|
|
|
307 |
var_dump($proc);
|
|
|
308 |
|
|
|
309 |
#結束執行,回傳shell 1
|
|
|
310 |
exit(1);
|
|
|
311 |
|
|
|
312 |
}#if end
|
|
|
313 |
|
|
|
314 |
#如果有異動的跡象
|
|
|
315 |
else if($mod_fd>0){
|
|
|
316 |
|
|
|
317 |
#針對每個異動的 stream
|
|
|
318 |
foreach($read as $readStream){
|
|
|
319 |
|
|
|
320 |
#如果是有標準輸出
|
|
|
321 |
if($readStream===$process["content"]){
|
|
|
322 |
|
|
|
323 |
#debug
|
|
|
324 |
#echo "try read std output".PHP_EOL;
|
|
|
325 |
|
|
|
326 |
#不讓標準輸出會阻擋程式執行
|
|
|
327 |
#stream_set_blocking($process["content"],false);
|
|
|
328 |
|
|
|
329 |
#讀取1Kbyte
|
|
|
330 |
$contentByte=fread($process["content"],1024);
|
|
|
331 |
|
|
|
332 |
#如果有資料
|
|
|
333 |
if(strlen($contentByte)>0){
|
|
|
334 |
|
|
|
335 |
#如果有關鍵字
|
|
|
336 |
if(strpos($contentByte,"unixDomainSocket:")===0){
|
|
|
337 |
|
|
|
338 |
#函式說明:
|
|
|
339 |
#將固定格式的字串分開,並回傳分開的結果.
|
|
|
340 |
#回傳結果:
|
|
|
341 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
342 |
#$result["error"],錯誤訊息陣列
|
|
|
343 |
#$result["function"],當前執行的函數名稱.
|
|
|
344 |
#$result["argu"],使用的參數.
|
|
|
345 |
#$result["oriStr"],要分割的原始字串內容
|
|
|
346 |
#$result["dataArray"],爲分割好字串的陣列內容,$result["dataArray"][$i]爲第($i+1)段的內容。
|
|
|
347 |
#$result["dataCounts"],爲總共分成幾段
|
|
|
348 |
#$result["found"],是否有在$conf["stringIn"]找到$conf["spiltSymbol"],"true"代表有找到,"false"代表沒有找到.
|
|
|
349 |
#必填參數:
|
|
|
350 |
#$conf["stringIn"],字串,要處理的字串.
|
|
|
351 |
$conf["stringIn"]=$contentByte;
|
|
|
352 |
#$conf["spiltSymbol"],字串,爲以哪個符號作爲分割.
|
|
|
353 |
$conf["spiltSymbol"]="unixDomainSocket:";
|
|
|
354 |
#可省略參數:
|
|
|
355 |
#$conf["allowEmptyStr"],是否允許分割出來空字串,預設為"false"不允許;"true"代表允許.
|
|
|
356 |
$conf["allowEmptyStr"]="false";
|
|
|
357 |
#參考資料:
|
|
|
358 |
#無.
|
|
|
359 |
#備註:
|
|
|
360 |
#無.
|
|
|
361 |
$spiltString=stringProcess::spiltString($conf);
|
|
|
362 |
unset($conf);
|
|
|
363 |
|
|
|
364 |
#debug
|
|
|
365 |
#var_dump(__LINE__,$spiltString);
|
|
|
366 |
|
|
|
367 |
#如果執行失敗
|
|
|
368 |
if($spiltString["status"]==="false"){
|
|
|
369 |
|
|
|
370 |
#debug
|
|
|
371 |
var_dump($spiltString);
|
|
|
372 |
|
|
|
373 |
#結束執行,回傳shell 1
|
|
|
374 |
exit(1);
|
|
|
375 |
|
|
|
376 |
}#if end
|
|
|
377 |
|
|
|
378 |
#如果有分割用的關鍵字
|
|
|
379 |
if($spiltString["found"]==="true"){
|
|
|
380 |
|
|
|
381 |
#如果分割出來的數量為1
|
|
|
382 |
if($spiltString["dataCounts"]===1){
|
|
|
383 |
|
|
|
384 |
#取得 unix doamin socket 的位置
|
|
|
385 |
$unixDomainSocket=$spiltString["dataArray"][0];
|
|
|
386 |
|
|
|
387 |
#提示透過 unix domain socket 來傳接收要做的事情
|
| 765 |
liveuser |
388 |
echo "Using unix domain socket:".$unixDomainSocket." 來跟 web socket server 互動".PHP_EOL;
|
| 757 |
liveuser |
389 |
|
| 765 |
liveuser |
390 |
#後面忽略,換下一個
|
|
|
391 |
continue;
|
|
|
392 |
|
| 757 |
liveuser |
393 |
}#if end
|
|
|
394 |
|
|
|
395 |
}#if end
|
|
|
396 |
|
|
|
397 |
}#if end
|
|
|
398 |
|
|
|
399 |
#印出內容
|
|
|
400 |
echo $contentByte;
|
|
|
401 |
|
|
|
402 |
#換行
|
|
|
403 |
echo PHP_EOL;
|
|
|
404 |
|
|
|
405 |
}#if end
|
|
|
406 |
|
|
|
407 |
}#if end
|
|
|
408 |
|
|
|
409 |
}#foreach end
|
|
|
410 |
|
|
|
411 |
}#if end
|
|
|
412 |
|
|
|
413 |
#反之代表沒有任何輸出
|
|
|
414 |
else{
|
|
|
415 |
|
|
|
416 |
#提示在等待任何輸出
|
|
|
417 |
echo ".";
|
|
|
418 |
|
|
|
419 |
}#else end
|
|
|
420 |
|
|
|
421 |
}#if end
|
|
|
422 |
|
|
|
423 |
#如果已經結束執行
|
|
|
424 |
if($process["proc_get_status"]["running"]==="false"){
|
|
|
425 |
|
|
|
426 |
#移除該程序資訊
|
|
|
427 |
unset($proc["content"][$index]);
|
|
|
428 |
|
|
|
429 |
}#if end
|
|
|
430 |
|
|
|
431 |
#反之
|
|
|
432 |
else{
|
|
|
433 |
|
|
|
434 |
#更新 "proc_get_status"
|
|
|
435 |
$proc["content"][$index]["proc_get_status"]=proc_get_status($process["process"]);
|
|
|
436 |
|
|
|
437 |
}#else end
|
|
|
438 |
|
|
|
439 |
}#if end
|
|
|
440 |
|
|
|
441 |
#反之
|
|
|
442 |
else{
|
|
|
443 |
|
|
|
444 |
#移除該程序資訊
|
|
|
445 |
unset($proc["content"][$index]);
|
|
|
446 |
|
|
|
447 |
}#else end
|
|
|
448 |
|
|
|
449 |
}#foreach end
|
|
|
450 |
|
|
|
451 |
}#while end
|