3 * Functions to access the router
8 * @package linksys-wrt3g-tools
9 * @author Christian Weiske <cweiske@cweiske.de>
11 * @link http://cweiske.de/linksys-wrt3g-tools.htm
13 require_once 'HTTP/Request2.php';
14 require_once 'Wrt3g/HtmlParser.php';
27 * Name of user with administration privileges
43 * Returns the base URL to use for requests.
44 * Includes username, password and host.
46 * @return string URL without trailing slash after the host
48 protected function getBaseUrl()
52 . ':' . $this->password
60 * @return HTTP_Request2_Response
62 * @throws Exception When the router can't be reached, or unauthorized
64 public function reboot()
66 $r = new HTTP_Request2();
67 $r->setMethod(HTTP_Request2::METHOD_POST);
69 $this->getBaseUrl() . '/apply.cgi'
71 $r->addPostParameter('action', 'Reboot');
72 $r->addPostParameter('submit_button', 'Diagnostics');
73 $r->addPostParameter('wait_time', 1);
77 }//public function reboot()
82 * Retrieves status information about the router
84 * @return array Array with several key-value pairs
85 * connection => connecting, disconnected, connected
87 * @throws Exception When the router can't be reached, or unauthorized
89 public function getStatus()
93 $strUrlBase = $this->getBaseUrl();
94 $parser = new Wrt3g_HtmlParser();
99 $r = new HTTP_Request2();
100 $r->setMethod(HTTP_Request2::METHOD_GET);
101 $r->setUrl($strUrlBase . '/index_wstatus2.asp');
103 echo $resp->getStatus() . ' ' . $resp->getReasonPhrase() . "\n";
104 $arRetval = $parser->index_wstatus2($resp->getBody());
109 $r->setUrl($strUrlBase . '/index_wstatus1.asp');
111 $body = $resp->getBody();
112 $arRetval = array_merge($arRetval, $parser->index_wstatus1($body));
115 }//public function getStatus()