auth url and anon url
authorChristian Weiske <cweiske@cweiske.de>
Wed, 15 Dec 2010 17:43:41 +0000 (18:43 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Wed, 15 Dec 2010 17:43:41 +0000 (18:43 +0100)
Wrt3g.php

index 1b554164c476b097798fcbbe02688c26edfe3040..131f626951a745ad74c116694bdc7333e808d380 100644 (file)
--- a/Wrt3g.php
+++ b/Wrt3g.php
@@ -1,19 +1,28 @@
 <?php
 /**
 <?php
 /**
-* Functions to access the router
-*
-* PHP version 5
-*
-* @category Tools
-* @package  linksys-wrt3g-tools
-* @author   Christian Weiske <cweiske@cweiske.de>
-* @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 <cweiske@cweiske.de>
+ * @license  AGPL v3
+ * @link     http://cweiske.de/linksys-wrt3g-tools.htm
+ */
 require_once 'HTTP/Request2.php';
 require_once 'Wrt3g/HtmlParser.php';
 
 
 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 <cweiske@cweiske.de>
+ * @license  AGPL v3
+ * @link     http://cweiske.de/linksys-wrt3g-tools.htm
+ */
 class Wrt3g
 {
     /**
 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
      */
      * Includes username, password and host.
      *
      * @return string URL without trailing slash after the host
      */
-    protected function getBaseUrl()
+    protected function getAuthBaseUrl()
     {
         return 'http://'
             . $this->user
     {
         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.
     *
     /**
     * Reboots the router.
     *
@@ -66,7 +89,7 @@ class Wrt3g
         $r = new HTTP_Request2();
         $r->setMethod(HTTP_Request2::METHOD_POST);
         $r->setUrl(
         $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');
         );
         $r->addPostParameter('action', 'Reboot');
         $r->addPostParameter('submit_button', 'Diagnostics');
@@ -90,7 +113,7 @@ class Wrt3g
     {
         $arRetval = array();
 
     {
         $arRetval = array();
 
-        $strUrlBase = $this->getBaseUrl();
+        $strUrlBase = $this->getAuthBaseUrl();
         $parser = new Wrt3g_HtmlParser();
 
         /**
         $parser = new Wrt3g_HtmlParser();
 
         /**