-
- return true;
- }
-
- /**
- * logout
- *
- * @return array
- */
- public function logout () {
- if ($this->checkLogin() !== true) throw new Exception('you musst be logged in to use this method');
-
- $path = 'data/Login.json';
- $fields = array('csrf_token' => $this->token, 'logout' => 'byby');
- $data = $this->sentRequest($path, $fields, true);
- if ($this->checkLogin() === false) {
- // reset challenge and session
- $this->challenge = '';
- $this->session = '';
- $this->token = "";
-
- $json = json_decode($data['body'], true);
-
- return $json;
- }
- else {
- throw new Exception('logout failed');
- }
- }
-
- /**
- * reboot the router
- *
- * @return array
- */
- public function reboot () {
- if ($this->checkLogin() !== true) throw new Exception('you musst be logged in to use this method');
-
- $path = 'data/Reboot.json';
- $fields = array('csrf_token' => 'nulltoken', 'showpw' => 0, 'password' => $this->hash, 'reboot_device' => 'true');
- $data = $this->sentRequest($path, $fields, true);
-
- $json = json_decode($data['body'], true);
-
- return $json;
- }
-
- /**
- * change dsl connection status
- *
- * @param string $status
- */
- public function changeConnectionStatus ($status) {
- if ($this->checkLogin() !== true) throw new Exception('you musst be logged in to use this method');
-
- $path = 'data/Connect.json';
-
- if ($status == 'online' || $status == 'offline') {
- $fields = array('csrf_token' => 'nulltoken', 'showpw' => 0, 'password' => $this->hash, 'req_connect' => $status);
- $data = $this->sentRequest($path, $fields, true);
-
- $json = json_decode($this->decrypt($data['body']), true);
-
- return $json;
- }
- else {
- throw new Exception();
- }
- }
-
- /**
- * return the given json as array
- *
- * @param string $file
- * @return array
- */
- public function getData ($file) {
- if ($this->checkLogin() !== true && $file != "Status") throw new Exception('you musst be logged in to use this method');
-
- $path = 'data/'.$file.'.json';
- $fields = array();
- $data = $this->sentRequest($path, $fields, true);
-
- if (empty($data['body'])) {
- throw new Exception('unable to get '.$file.' data');
- }
-
- $json = json_decode($data['body'], true);
-
- return $json;
- }
-
- /**
- * get the router syslog
- *
- * @return array
- */
- public function getSyslog() {
- return $this->exportData('0');
- }
-
- /**
- * get the Missed Calls from router
- *
- * @return array
- */
- public function getMissedCalls() {
- return $this->exportData('1');
- }
-
- /**
- * get the Taken Calls from router
- *
- * @return array
- */
- public function getTakenCalls() {
- return $this->exportData('2');
- }
-
- /**
- * get the Dialed Calls from router
- *
- * @return array
- */
- public function getDialedCalls() {
- return $this->exportData('3');
- }
-
- /**
- * export data from router
- *
- * @return array
- */
- private function exportData ($type) {
- if ($this->checkLogin() !== true) throw new Exception('you musst be logged in to use this method');
-
- $path = 'data/Syslog.json';
- $fields = array('exporttype' => $type);
- $data = $this->sentRequest($path, $fields, true);
-
- if (empty($data['body'])) {
- throw new Exception('unable to get export data');