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)
9 * get phone book entrys
13 public function getPhoneBookEntrys () {
14 $data = $this->getData('PhoneBook');
15 $data = $this->getValues($data);
17 if (isset($data['addbookentry'])) {
18 return $data['addbookentry'];
26 * add Phone Book Entry
29 * @param string $firstname
30 * @param string $private
32 * @param string $mobile
37 public function addPhoneBookEntry ($name, $firstname, $private, $work, $mobile, $id = -1) {
40 $path = 'data/PhoneBook.json';
41 $fields = array('csrf_token' => $this->token
,
44 'phonebook_name' => $name,
45 'phonebook_vorname' => $firstname,
46 'phonebook_number_p' => $private,
47 'phonebook_number_a' => $work,
48 'phonebook_number_m' => $mobile
51 $data = $this->sentRequest($path, $fields, true);
52 $data = $this->getValues($data['body']);
54 if ($data['status'] == 'ok') {
58 throw new RouterException('can not add/edit Phone Book Entry');
63 * edit Phone Book Entry
67 * @param string $firstname
68 * @param string $private
70 * @param string $mobile
74 public function changePhoneBookEntry ($id, $name, $firstname, $private, $work, $mobile) {
75 return $this->addPhoneBookEntry($name, $firstname, $private, $work, $private, $id);
79 * delete Phone Book Entry
85 public function deletePhoneBookEntry ($id) {
88 $path = 'data/PhoneBook.json';
89 $fields = array('csrf_token' => $this->token
,
91 'deleteEntry' => 'delete'
94 $data = $this->sentRequest($path, $fields, true);
95 $data = $this->getValues($data['body']);
97 if ($data['status'] == 'ok') {
101 throw new RouterException('can not delete Phone Book Entry');
106 * get the Missed Calls from router
110 public function getMissedCalls() {
111 $lines = $this->exportData('1');
113 $c = count($lines) -2;
115 foreach ($lines as $line) {
116 if (empty($line) ||
strpos($line, 'Date') !== false) continue;
118 $exp = explode(' ', $line);
122 $data['missedcalls_date'] = $exp[0];
123 $data['missedcalls_time'] = $exp[1];
124 $data['missedcalls_who'] = $exp[2];
133 * get the Taken Calls from router
137 public function getTakenCalls() {
138 $lines = $this->exportData('2');
140 $c = count($lines) -2;
142 foreach ($lines as $line) {
143 if (empty($line) ||
strpos($line, 'Date') !== false) continue;
145 $exp = explode(' ', $line);
149 $data['takencalls_date'] = $exp[0];
150 $data['takencalls_time'] = $exp[1];
151 $data['takencalls_who'] = $exp[2];
152 $data['takencalls_duration'] = $exp[3];
162 * get the Dialed Calls from router
166 public function getDialedCalls() {
167 $lines = $this->exportData('3');
169 $c = count($lines) -2;
171 foreach ($lines as $line) {
172 if (empty($line) ||
strpos($line, 'Date') !== false) continue;
174 $exp = explode(' ', $line);
178 $data['dialedcalls_date'] = $exp[0];
179 $data['dialedcalls_time'] = $exp[1];
180 $data['dialedcalls_who'] = $exp[2];
181 $data['dialedcalls_duration'] = $exp[3];
190 * export data from router
194 private function exportData ($type) {
197 $path = 'data/Syslog.json';
198 $fields = array('exporttype' => $type);
199 $data = $this->sentRequest($path, $fields, true);
201 return explode("\n", $data['body']);