From: Christian Weiske Date: Wed, 15 Dec 2010 17:43:41 +0000 (+0100) Subject: auth url and anon url X-Git-Tag: 1.0.0~39 X-Git-Url: https://git.cweiske.de/linksys-wrt3g-tools.git/commitdiff_plain/db09f59478dcc4a92771d28e043a173462150433 auth url and anon url --- diff --git a/Wrt3g.php b/Wrt3g.php index 1b55416..131f626 100644 --- a/Wrt3g.php +++ b/Wrt3g.php @@ -1,19 +1,28 @@ -* @license AGPL v3 -* @link http://cweiske.de/linksys-wrt3g-tools.htm -*/ + * Part of Linksys WRT3G tools + * + * PHP version 5 + * + * @category Tools + * @package linksys-wrt3g-tools + * @author Christian Weiske + * @license AGPL v3 + * @link http://cweiske.de/linksys-wrt3g-tools.htm + */ require_once 'HTTP/Request2.php'; require_once 'Wrt3g/HtmlParser.php'; +/** + * Main class to interact with the router. + * + * @category Tools + * @package linksys-wrt3g-tools + * @author Christian Weiske + * @license AGPL v3 + * @link http://cweiske.de/linksys-wrt3g-tools.htm + */ class Wrt3g { /** @@ -40,12 +49,12 @@ class Wrt3g /** - * Returns the base URL to use for requests. + * Returns the base URL to use for requests that require authentification. * Includes username, password and host. * * @return string URL without trailing slash after the host */ - protected function getBaseUrl() + protected function getAuthBaseUrl() { return 'http://' . $this->user @@ -54,6 +63,20 @@ class Wrt3g } + + /** + * Returns the base URL to use for requests that do + * not require authentification. + * + * @return string URL without trailing slash after the host + */ + protected function getAnonBaseUrl() + { + return 'http://' . $this->host; + } + + + /** * Reboots the router. * @@ -66,7 +89,7 @@ class Wrt3g $r = new HTTP_Request2(); $r->setMethod(HTTP_Request2::METHOD_POST); $r->setUrl( - $this->getBaseUrl() . '/apply.cgi' + $this->getAuthBaseUrl() . '/apply.cgi' ); $r->addPostParameter('action', 'Reboot'); $r->addPostParameter('submit_button', 'Diagnostics'); @@ -90,7 +113,7 @@ class Wrt3g { $arRetval = array(); - $strUrlBase = $this->getBaseUrl(); + $strUrlBase = $this->getAuthBaseUrl(); $parser = new Wrt3g_HtmlParser(); /**