aboutsummaryrefslogtreecommitdiff
path: root/Wrt3g/HtmlParser.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2010-12-17 09:01:37 +0100
committerChristian Weiske <cweiske@cweiske.de>2010-12-17 09:01:37 +0100
commit85f7ff92a4c5ef908fe063d9e88028dc239ff0dd (patch)
treefc11ca9eb7845cb65fa3a08039f0772d6ec8a7a0 /Wrt3g/HtmlParser.php
parent0f92c156212e32beb269055165cb77f1f8a1d5bf (diff)
downloadlinksys-wrt3g-tools-85f7ff92a4c5ef908fe063d9e88028dc239ff0dd.tar.gz
linksys-wrt3g-tools-85f7ff92a4c5ef908fe063d9e88028dc239ff0dd.zip
test for noauth status page without connection; add support for connection status in status_noauth
Diffstat (limited to 'Wrt3g/HtmlParser.php')
-rw-r--r--Wrt3g/HtmlParser.php28
1 files changed, 21 insertions, 7 deletions
diff --git a/Wrt3g/HtmlParser.php b/Wrt3g/HtmlParser.php
index d420f4d..f369bd1 100644
--- a/Wrt3g/HtmlParser.php
+++ b/Wrt3g/HtmlParser.php
@@ -19,6 +19,7 @@ class Wrt3g_HtmlParser
'GPRS_MSG.ACQUIRING' => 'aquiring',
'GPRS_MSG.WWBEAR_GPRS' => 'GPRS',
'GPRS_MSG.WWBEAR_UMTS' => 'UMTS',
+ 'GPRS_MSG.None' => null,
'GPRS_MSG.GOOD' => 'good',
'GPRS_MSG.EXCELLENT' => 'excellent',
'GPRS_MSG.CTIME' => 'connection time',
@@ -135,8 +136,6 @@ class Wrt3g_HtmlParser
* - card revision
* - card firmware
* - IMSI
- *
- * @todo FIXME implement "connection" value as index_wstatus2() does it
*/
public function status_noauth($body)
{
@@ -150,7 +149,8 @@ class Wrt3g_HtmlParser
$doc->loadHtml($body);
$xpath = new DOMXPath($doc);
$trs = $xpath->query('//table//table/tbody/tr');
- $arRaw = array();
+ $arRaw = array('connection' => null);
+ $bAquiring = false;
foreach ($trs as $tr) {
$titleItems = $xpath->query('td[@width=125]/text()', $tr);
$valueItems = $xpath->query('td[@width=296]/*[1]', $tr);
@@ -165,10 +165,22 @@ class Wrt3g_HtmlParser
$value = trim(strip_tags($value));
if (substr($value, 0, 8) == 'Capture(') {
$value = self::$arTranslations[substr($value, 8, -1)];
+ if ($value == 'aquiring') {
+ $bAquiring = true;
+ $value = null;
+ }
}
}
unset($value);
+ if ($bAquiring) {
+ $arRaw['connection'] = 'connecting';
+ } else if ($arRaw['type'] != null) {
+ $arRaw['connection'] = 'connected';
+ } else {
+ $arRaw['connection'] = 'disconnected';
+ }
+
if (isset($arRaw['connection time'])) {
$arRaw['connection time'] = str_replace(
array(
@@ -188,10 +200,12 @@ class Wrt3g_HtmlParser
'TX = ',
str_replace('RX = ', '', $arRaw['session usage'])
);
- $arRaw['session usage'] = array(
- 'received' => $arS[0],
- 'sent' => $arS[1]
- );
+ if (count($arS) > 1) {
+ $arRaw['session usage'] = array(
+ 'received' => $arS[0],
+ 'sent' => $arS[1]
+ );
+ }
}
return $arRaw;