| 14 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
#使用命名空間qbpwcf
|
|
|
4 |
namespace qbpwcf;
|
|
|
5 |
|
|
|
6 |
#匯入外部套件
|
|
|
7 |
include("../allInOneForJson.php");
|
|
|
8 |
|
|
|
9 |
/*
|
|
|
10 |
|
|
|
11 |
#提示要測試的套件
|
|
|
12 |
echo "<hr>logs::parseHtmlStr & logs::filterMsgPack - testCase 1<br>";
|
|
|
13 |
|
|
|
14 |
#函式說明:
|
|
|
15 |
#解析讀取到的log內容,分段成數個訊息儲存到session陣列中並回傳完整的訊息部分.訊息內容的特徵為有為開頭關鍵字出現則為一個訊息的開始.
|
|
|
16 |
#回傳結果:
|
|
|
17 |
#$result["status"],狀態,"true"或"false".
|
|
|
18 |
#$result["error"],錯誤訊息陣列.
|
|
|
19 |
#$result["function"],當前函式的名稱.
|
|
|
20 |
#$result["argu"],使用的參數.
|
|
|
21 |
#必填參數:
|
|
|
22 |
#$conf["path"],log檔案的路徑與名稱.
|
|
|
23 |
$conf["path"]="fileAccessT/Devcom.log";
|
|
|
24 |
#$conf["msgStart"],字串,要寫的內容.
|
|
|
25 |
#$conf["msgStart"]="i UdpS, ".date('n')."/".date('j');
|
|
|
26 |
$conf["msgStart"]="i UdpS, 1/12";
|
|
|
27 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
28 |
$conf["fileArgu"]=__FILE__;
|
|
|
29 |
#可省略參數:
|
|
|
30 |
#$conf["sessionName"],字串,儲存log的session變數key.
|
|
|
31 |
#$conf["sessionName"]="";
|
|
|
32 |
#$conf["line2start"],字串,log從第幾列開始,預設為總行數減去linesPerTime+1.
|
|
|
33 |
$conf["line2start"]="0";
|
|
|
34 |
#$conf["linesPerTime"],字串,一次最多讀取幾列,預設爲10列.
|
|
|
35 |
$conf["linesPerTime"]="100";
|
|
|
36 |
$parseSessionLog=logs::parseLog2session($conf);
|
|
|
37 |
unset($conf);
|
|
|
38 |
|
|
|
39 |
#如果執行錯誤
|
|
|
40 |
if($parseSessionLog["status"]==="false"){
|
|
|
41 |
|
|
|
42 |
#印出結果
|
|
|
43 |
var_dump($parseSessionLog);
|
|
|
44 |
|
|
|
45 |
#結束執行
|
|
|
46 |
exit;
|
|
|
47 |
|
|
|
48 |
}#if end
|
|
|
49 |
|
|
|
50 |
#函式說明:
|
|
|
51 |
#解析多個訊息陣列,尋找有關鍵字出現的訊息,並回傳之.
|
|
|
52 |
#回傳結果:
|
|
|
53 |
#$result["status"],狀態,"true"或"false".
|
|
|
54 |
#$result["error"],錯誤訊息陣列.
|
|
|
55 |
#$result["function"],當前函式的名稱.
|
|
|
56 |
#$result["argu"],使用的參數.
|
|
|
57 |
#$result["content"],陣列,有開頭關鍵字出現的訊息陣列.
|
|
|
58 |
#必填參數:
|
|
|
59 |
#$conf["msgs"],陣列,由多個訊息陣列組成.
|
|
|
60 |
$conf["msgs"]=$parseSessionLog["content"];
|
|
|
61 |
#$conf["keyWord"],陣列,每個關鍵字.
|
|
|
62 |
$conf["keyWord"]=array("2","3","E","D");
|
|
|
63 |
#$conf["keyWordAddr"],陣列,關鍵字的位置是第幾個.
|
|
|
64 |
$conf["keyWordAddr"]=array("21","22","24","25");
|
|
|
65 |
#可省略參數:
|
|
|
66 |
#無
|
|
|
67 |
$filterMsgPack=logs::filterMsgPack($conf);
|
|
|
68 |
unset($conf);
|
|
|
69 |
|
|
|
70 |
#如果執行錯誤
|
|
|
71 |
if($filterMsgPack["status"]==="false"){
|
|
|
72 |
|
|
|
73 |
#印出結果
|
|
|
74 |
var_dump($filterMsgPack);
|
|
|
75 |
|
|
|
76 |
#結束執行
|
|
|
77 |
exit;
|
|
|
78 |
|
|
|
79 |
}#if end
|
|
|
80 |
|
|
|
81 |
#輸出結果
|
|
|
82 |
var_dump($filterMsgPack);
|
|
|
83 |
|
|
|
84 |
*/
|
|
|
85 |
|
|
|
86 |
/*
|
|
|
87 |
|
|
|
88 |
#提示要測試的套件
|
|
|
89 |
echo "<hr>logs::parseLog2sessionWithMultiMsgStartSupport & logs::filterMsgPackWithMultiKeywordSupport - testCase 1<br>";
|
|
|
90 |
|
|
|
91 |
#函式說明:
|
|
|
92 |
#解析讀取到的log內容,分段成數個訊息(可以有多種)儲存到session陣列中並回傳完整的訊息部分.
|
|
|
93 |
#回傳結果:
|
|
|
94 |
#$result["status"],狀態,"true"或"false".
|
|
|
95 |
#$result["error"],錯誤訊息陣列.
|
|
|
96 |
#$result["function"],當前函式的名稱.
|
|
|
97 |
#$result["argu"],使用的參數.
|
|
|
98 |
#$result["content"],陣列,每個有關鍵字的訊息陣列.
|
|
|
99 |
#$result["lineNun"],數字,當前行數.
|
|
|
100 |
#必填參數:
|
|
|
101 |
#$conf["path"],log檔案的路徑與名稱.
|
|
|
102 |
$conf["path"]="fileAccessT/Devcom.log";
|
|
|
103 |
#$conf["msgStart"],字串陣列,用來識別訊息開頭的開頭關鍵字,支援多種訊息的開頭.
|
|
|
104 |
#$conf["msgStart"]=array("i UdpS, ".date('n')."/".date('j'),"i TcpSvr, ".date('n')."/".date('j'));
|
|
|
105 |
$conf["msgStart"]=array("i UdpS, 1/9","i TcpSvr, 1/9");
|
|
|
106 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
|
|
|
107 |
$conf["fileArgu"]=__FILE__;
|
|
|
108 |
#可省略參數:
|
|
|
109 |
#$conf["sessionName"],字串,儲存log的session變數key.
|
|
|
110 |
#$conf["sessionName"]="";
|
|
|
111 |
#$conf["line2start"],字串,log從第幾列開始,預設為總行數減去linesPerTime+1.
|
|
|
112 |
$conf["line2start"]="23600";
|
|
|
113 |
#$conf["linesPerTime"],字串,一次最多讀取幾列,預設爲10列.
|
|
|
114 |
$conf["linesPerTime"]="200";
|
|
|
115 |
$parseLog2sessionWithMultiMsgStartSupport=logs::parseLog2sessionWithMultiMsgStartSupport($conf);
|
|
|
116 |
unset($conf);
|
|
|
117 |
|
|
|
118 |
#如果執行錯誤
|
|
|
119 |
if($parseLog2sessionWithMultiMsgStartSupport["status"]==="false"){
|
|
|
120 |
|
|
|
121 |
#印出結果
|
|
|
122 |
var_dump($parseLog2sessionWithMultiMsgStartSupport);
|
|
|
123 |
|
|
|
124 |
#結束執行
|
|
|
125 |
exit;
|
|
|
126 |
|
|
|
127 |
}#if end
|
|
|
128 |
|
|
|
129 |
#函式說明:
|
|
|
130 |
#解析多個訊息陣列,尋找符合其中一組關鍵字出現的訊息,並回傳之.
|
|
|
131 |
#回傳結果:
|
|
|
132 |
#$result["status"],狀態,"true"或"false".
|
|
|
133 |
#$result["error"],錯誤訊息陣列.
|
|
|
134 |
#$result["function"],當前函式的名稱.
|
|
|
135 |
#$result["argu"],使用的參數.
|
|
|
136 |
#$result["content"],陣列,有開頭關鍵字出現的訊息陣列.
|
|
|
137 |
#必填參數:
|
|
|
138 |
#$conf["msgs"],陣列,由多個訊息陣列組成.
|
|
|
139 |
$conf["msgs"]=$parseLog2sessionWithMultiMsgStartSupport["content"];
|
|
|
140 |
#$conf["keyWords"],二維陣列,每個關鍵字.
|
|
|
141 |
$conf["keyWords"]=array(array("2","3","E","D"),array("i"," ","T","c","p","S","v","r"));
|
|
|
142 |
#$conf["keyWordsAddr"],二維陣列,關鍵字的位置是第幾個.
|
|
|
143 |
$conf["keyWordsAddr"]=array(array("21","22","24","25"),array("0","1","2","3","4","5","6","7"));
|
|
|
144 |
#可省略參數:
|
|
|
145 |
#無
|
|
|
146 |
$filterMsgPackWithMultiKeywordSupport=logs::filterMsgPackWithMultiKeywordSupport($conf);
|
|
|
147 |
unset($conf);
|
|
|
148 |
|
|
|
149 |
#如果執行錯誤
|
|
|
150 |
if($filterMsgPackWithMultiKeywordSupport["status"]==="false"){
|
|
|
151 |
|
|
|
152 |
#印出結果
|
|
|
153 |
var_dump($filterMsgPackWithMultiKeywordSupport);
|
|
|
154 |
|
|
|
155 |
#結束執行
|
|
|
156 |
exit;
|
|
|
157 |
|
|
|
158 |
}#if end
|
|
|
159 |
|
|
|
160 |
echo "<pre>";
|
|
|
161 |
print_r($filterMsgPackWithMultiKeywordSupport["content"]);
|
|
|
162 |
echo "</pre>";
|
|
|
163 |
|
|
|
164 |
*/
|
|
|
165 |
|
|
|
166 |
/*
|
|
|
167 |
|
|
|
168 |
#提示要測試的套件
|
|
|
169 |
#echo "<hr>logs::parseLog2sessionWithMultiMsgStartSupport & logs::filterMsgPackWithMultiKeywordSupport - testCase 2<br>";
|
|
|
170 |
|
|
|
171 |
#函式說明:
|
|
|
172 |
#建立qbpwcf專屬的js函式庫
|
|
|
173 |
#回傳結果
|
|
|
174 |
#$result["funciton"],當前函式的名稱.
|
|
|
175 |
#$result["status"],執行的狀態,"true"代表正常,"false"代表不正常.
|
|
|
176 |
#$result["error"],錯誤訊息
|
|
|
177 |
#$result["content"],語法.
|
|
|
178 |
echo javaScript::qbpwcfJavaScript()["content"];
|
|
|
179 |
|
|
|
180 |
#函式說明:
|
|
|
181 |
#傳遞識別數字進而取得連續的資料
|
|
|
182 |
#回傳結果:
|
|
|
183 |
#$result["status"],執行正常與否,"true"代表正常,"false"代表不正常.
|
|
|
184 |
#$result["error"],錯誤訊息.
|
|
|
185 |
#$result["function"],當前執行的函式名稱.
|
|
|
186 |
#$result["content"],js語法.
|
|
|
187 |
#必填參數:
|
|
|
188 |
#$conf["params"],參數陣列,要傳遞的識別參數.
|
|
|
189 |
$conf["params"]=array("lineStart"=>1);
|
|
|
190 |
#$conf["url"],字串,要從哪個頁面要求連續的資料.
|
|
|
191 |
$conf["url"]="logsT2.php";
|
|
|
192 |
#可省略參數:
|
|
|
193 |
#$conf["method"],字串,資料傳輸的方式,有POST跟GET
|
|
|
194 |
$conf["method"]="POST";
|
|
|
195 |
#$conf["responseDivId"],字串,放置取得資料div的id.
|
|
|
196 |
$conf["responseDivId"]="rootDiv";
|
|
|
197 |
$tailAny=javaScript::tailAny($conf);
|
|
|
198 |
unset($conf);
|
|
|
199 |
|
|
|
200 |
#如果執行錯誤
|
|
|
201 |
if($tailAny["status"]==="false"){
|
|
|
202 |
|
|
|
203 |
#印出結果
|
|
|
204 |
var_dump($tailAny);
|
|
|
205 |
|
|
|
206 |
#結束執行
|
|
|
207 |
exit;
|
|
|
208 |
|
|
|
209 |
}#if end
|
|
|
210 |
|
|
|
211 |
#印出 js 語法
|
|
|
212 |
echo $tailAny["content"];
|
|
|
213 |
|
|
|
214 |
#印出 root div
|
|
|
215 |
echo "<div id='rootDiv'></div>";
|
|
|
216 |
|
|
|
217 |
*/
|
|
|
218 |
|
|
|
219 |
?>
|