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';
26 * Name of user with administration privileges
42 * Returns the base URL to use for requests.
43 * Includes username, password and host.
45 * @return string URL without trailing slash after the host
47 protected function getBaseUrl()
51 . ':' . $this->password
59 * @return HTTP_Request2_Response
61 * @throws Exception When the router can't be reached, or unauthorized
63 public function reboot()
65 $r = new HTTP_Request2();
66 $r->setMethod(HTTP_Request2::METHOD_POST);
68 $this->getBaseUrl() . '/apply.cgi'
70 $r->addPostParameter('action', 'Reboot');
71 $r->addPostParameter('submit_button', 'Diagnostics');
72 $r->addPostParameter('wait_time', 1);
76 }//public function reboot()
81 * Retrieves status information about the router
83 * @return array Array with several key-value pairs
84 * connection => connecting, disconnected, connected
86 * @throws Exception When the router can't be reached, or unauthorized
88 public function getStatus()
92 $strUrlBase = $this->getBaseUrl();
97 $r = new HTTP_Request2();
98 $r->setMethod(HTTP_Request2::METHOD_GET);
99 $r->setUrl($strUrlBase . '/index_wstatus2.asp');
101 echo $resp->getStatus() . ' ' . $resp->getReasonPhrase() . "\n";
102 $arRetval = $parser->index_wstatus2($resp->getBody());
107 $r->setUrl($strUrlBase . '/index_wstatus1.asp');
109 $body = $resp->getBody();
110 $arRetval = array_merge($arRetval, $parser->index_wstatus1($body));
113 }//public function getStatus()