cleanup
[GitHub/Stricted/speedport-hybrid-php-api.git] / Connection.class.php
CommitLineData
9b926efe
S
1<?php
2/**
3 * @author Jan Altensen (Stricted)
4 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
5 * @copyright 2015 Jan Altensen (Stricted)
6 */
7trait Connection {
8 /**
9 * change dsl connection status
10 *
11 * @param string $status
12 * @return boolean
13 */
14 public function changeDSLStatus ($status) {
15 $this->checkLogin();
16
17 $path = 'data/Connect.json';
18
19 if ($status == 'online' || $status == 'offline') {
20 $fields = array('csrf_token' => 'nulltoken', 'showpw' => 0, 'password' => $this->hash, 'req_connect' => $status);
21 $data = $this->sentRequest($path, $fields, true);
22 $data = $this->getValues($data['body']);
23
24 if ($data['status'] == 'ok') {
25 return true;
26 }
27 else {
28 return false;
29 }
30 }
31 else {
32 throw new RouterException('unknown status');
33 }
34 }
35
36 /**
37 * change lte connection status
38 *
39 * @param string $status
40 * @return boolean
41 */
42 public function changeLTEStatus ($status) {
43 throw new Exception('unstable funtion');
44 $path = 'data/Modules.json';
45
46 if ($status == '0' || $status == '1' || $status == 'yes' || $status == 'no') {
47 if ($status == 'yes') $status = '1';
48 else if ($status == 'no') $status = '0';
49
50 $fields = array('csrf_token' => $this->token, 'use_lte' => $status);
51 $data = $this->sentEncryptedRequest($path, $fields, true);
52
53 // debug only
54 return $data;
55 }
56 else {
57 throw new RouterException('unknown status');
58 }
59 }
60
61 /**
62 * reconnect LTE
63 *
64 * @return array
65 */
66 public function reconnectLte () {
67 $this->checkLogin();
68
69 $path = 'data/modules.json';
70 $fields = array('csrf_token' => $this->token, 'lte_reconn' => '1');
71 $data = $this->sentEncryptedRequest($path, $fields, true);
72
73 return $data['body'];
74 }
89d43347 75}