From: Christian Weiske Date: Tue, 25 Jan 2011 05:03:05 +0000 (+0100) Subject: implement non-authenticated default status X-Git-Url: https://git.cweiske.de/linksys-wrt3g-tools.git/commitdiff_plain/064cd050748d919a60110106f7c8bc6a422ac9d8 implement non-authenticated default status --- diff --git a/Wrt3g.php b/Wrt3g.php index 2fe0db8..07a6821 100644 --- a/Wrt3g.php +++ b/Wrt3g.php @@ -145,14 +145,40 @@ class Wrt3g /** - * Retrieves status information about the router + * Retrieves basic connection 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 + * @throws Exception When the router can't be reached */ public function getConnectionStatus() + { + return array_intersect_key( + $this->loadStatus_NoAuth(), + array( + 'connection' => 0, + 'type' => 0, + 'network' => 0, + 'signal strength' => 0, + 'connection time' => 0, + 'session usage' => 0 + ) + ); + } + + + + /** + * Retrieves connection status information about the router. + * Uses pages that can only be reached with authentication. + * + * @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 getConnectionStatusAuth() { $arRetval = array(); diff --git a/scripts/linksys-wrt3g.php b/scripts/linksys-wrt3g.php index f53d76a..d9d7288 100755 --- a/scripts/linksys-wrt3g.php +++ b/scripts/linksys-wrt3g.php @@ -90,6 +90,12 @@ $stCmd = $parser->addCommand( 'description' => 'Show all status details' ) ); +$stCmd = $parser->addCommand( + 'authstatus', + array( + 'description' => 'Show the connection status the old way (authenticated)' + ) +); $parser->addCommand( @@ -147,9 +153,12 @@ try { $arStatus = $router->getFullStatus(); } else if ($result->command_name == 'card') { $arStatus = $router->getCardStatus(); + } else if ($result->command_name == 'authstatus') { + $arStatus = $router->getConnectionStatusAuth(); } else { $arStatus = $router->getConnectionStatus(); } + foreach ($arStatus as $key => $value) { echo $key . ': '; if (is_array($value)) {