85557f78ea5d9bc57b3fe38b4f2b9350d55a71c2
2 require_once('ISpeedport.class.php');
3 require_once('lib/exception/RouterException.class.php');
4 require_once('SpeedportHybrid.class.php');
7 * @author Jan Altensen (Stricted)
8 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
9 * @copyright 2015 Jan Altensen (Stricted)
11 class Speedportw724v
extends SpeedportHybrid
implements ISpeedport
{
12 public function login ($password) {
13 /* this is experimental, i dont have a speedport w724v so i cant test this
14 * feel free to test it and report if it dosent work
16 $path = 'data/Login.json';
17 $this->hash
= md5($password);
18 $fields = array('password' => $this->hash
, 'password_shadowed' => $this->hash
, 'showpw' => 0);
19 $data = $this->sentRequest($path, $fields);
20 $json = $this->getValues($data['body']);
22 if (isset($json['login']) && $json['login'] == 'success') {
23 if (isset($data['header']['Set-Cookie']) && !empty($data['header']['Set-Cookie'])) {
24 $this->cookie
= $data['header']['Set-Cookie'];
27 throw new RouterException('unable to get the session cookie from the router');
37 * sends the request to router
40 * @param mixed $fields
41 * @param string $cookie
42 * @param integer $count
45 protected function sentRequest ($path, $fields, $cookie = false, $count = 0) {
46 $data = parent
::sentRequest($path, $fields, $cookie, $count);
47 $header = $data['header'];
48 $body = $data['body'];
51 $body = preg_replace("/(\r\n)|(\r)/", "\n", $body);
52 $body = preg_replace('/\'/i', '"', $body);
53 $body = preg_replace("/\[\s+\]/i", '[ {} ]', $body);
54 $body = preg_replace("/},\s+]/", "}\n]", $body);
57 if (strpos($path, '.json') !== false) {
58 $json = json_decode($body, true);
60 if (is_array($json)) {
65 return array('header' => $header, 'body' => $body);