X-Git-Url: https://git.cweiske.de/linksys-wrt3g-tools.git/blobdiff_plain/8735a31fb391e9ef228f23873addb015385c77b4..0590cb4eefa73e311e2654cbf3e3b460be174cd3:/Wrt3g.php diff --git a/Wrt3g.php b/Wrt3g.php index 8d12ca6..18e8608 100644 --- a/Wrt3g.php +++ b/Wrt3g.php @@ -88,12 +88,12 @@ class Wrt3g /** - * Reboots the router. - * - * @return HTTP_Request2_Response - * - * @throws Exception When the router can't be reached, or unauthorized - */ + * Reboots the router. + * + * @return HTTP_Request2_Response + * + * @throws Exception When the router can't be reached, or unauthorized + */ public function reboot() { $url = $this->getAuthBaseUrl() . '/apply.cgi'; @@ -113,14 +113,14 @@ class Wrt3g /** - * Retrieves status information about the router - * - * @return array Array with several key-value pairs - * connection => connecting, disconnected, connected - * - * @throws Exception When the router can't be reached, or unauthorized - */ - public function getStatus() + * Retrieves status information about the router + * + * @return array Array with several key-value pairs + * connection => connecting, disconnected, connected + * + * @throws Exception When the router can't be reached, or unauthorized + */ + public function getConnectionStatus() { $arRetval = array(); @@ -128,8 +128,8 @@ class Wrt3g $parser = new Wrt3g_HtmlParser(); /** - * Connection status - */ + * Connection status + */ $r = new HTTP_Request2(); $r->setMethod(HTTP_Request2::METHOD_GET); $r->setUrl($strUrlBase . '/index_wstatus2.asp'); @@ -148,7 +148,77 @@ class Wrt3g $arRetval = array_merge($arRetval, $parser->index_wstatus1($body)); return $arRetval; - }//public function getStatus() + }//public function getConnectionStatus() + + + + /** + * Retrieves pc card/SIM status information + * + * @return array Array with several key-value pairs + * connection => connecting, disconnected, connected + * + * @throws Exception When the router can't be reached + */ + public function getCardStatus() + { + $arRetval = array(); + + $strUrlBase = $this->getAnonBaseUrl(); + + $url = $strUrlBase . '/Status_NoAuth.asp'; + $this->log('Connecting to ' . $url, 1); + + $r = new HTTP_Request2(); + $r->setMethod(HTTP_Request2::METHOD_GET); + $r->setUrl($url); + $resp = $r->send(); + $this->log($resp->getStatus() . ' ' . $resp->getReasonPhrase(), 1); + //FIXME: check status + + $parser = new Wrt3g_HtmlParser(); + $arRetval = $parser->status_noauth($resp->getBody()); + + return array_intersect_key( + $arRetval, + array( + 'card model' => 0, + 'card revision' => 0, + 'card firmware' => 0, + 'IMSI' => 0 + ) + ); + } + + + + /** + * Retrieves all status information one can get. + * + * @return array Array with several key-value pairs + * connection => connecting, disconnected, connected + * + * @throws Exception When the router can't be reached + */ + public function getFullStatus() + { + $arRetval = array(); + + $strUrlBase = $this->getAnonBaseUrl(); + + $url = $strUrlBase . '/Status_NoAuth.asp'; + $this->log('Connecting to ' . $url, 1); + + $r = new HTTP_Request2(); + $r->setMethod(HTTP_Request2::METHOD_GET); + $r->setUrl($url); + $resp = $r->send(); + $this->log($resp->getStatus() . ' ' . $resp->getReasonPhrase(), 1); + //FIXME: check status + + $parser = new Wrt3g_HtmlParser(); + return $parser->status_noauth($resp->getBody()); + } @@ -160,7 +230,7 @@ class Wrt3g * * @return void */ - protected function log($msg, $level = 1) + public function log($msg, $level = 1) { if ($this->verbosity >= $level) { echo $msg . "\n";