Commit | Line | Data |
---|---|---|
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 | */ | |
7 | trait System { | |
8 | /** | |
9 | * get uptime based on online (connection) time | |
10 | * | |
11 | * @return string | |
12 | */ | |
13 | public function getUptime () { | |
14 | $data = $this->getData('LAN'); | |
15 | $data = $this->getValues($data); | |
16 | ||
17 | return $data['days_online']; | |
18 | } | |
19 | ||
20 | /** | |
21 | * return the given json as array | |
22 | * | |
23 | * @param string $file | |
24 | * @return array | |
25 | */ | |
26 | public function getData ($file) { | |
27 | if ($file != 'Status') $this->checkLogin(); | |
28 | ||
29 | $path = 'data/'.$file.'.json'; | |
30 | $fields = array(); | |
31 | $data = $this->sentRequest($path, $fields, true); | |
32 | ||
33 | return $data['body']; | |
34 | } | |
35 | ||
36 | /** | |
37 | * get the router syslog | |
38 | * | |
39 | * @return array | |
40 | */ | |
41 | public function getSyslog() { | |
42 | $data = $this->getData('SystemMessages'); | |
43 | $data = $this->getValues($data); | |
44 | ||
45 | if (isset($data['addmessage'])) { | |
46 | return $data['addmessage']; | |
47 | } | |
48 | else { | |
49 | return array(); | |
50 | } | |
51 | } | |
52 | ||
53 | /** | |
54 | * reset the router to Factory Default | |
55 | * not tested | |
56 | * | |
57 | * @return array | |
58 | */ | |
59 | public function resetToFactoryDefault () { | |
60 | $this->checkLogin(); | |
61 | ||
62 | $path = 'data/resetAllSetting.json'; | |
63 | $fields = array('csrf_token' => 'nulltoken', 'showpw' => 0, 'password' => $this->hash, 'reset_all' => 'true'); | |
64 | $data = $this->sentRequest($path, $fields, true); | |
65 | ||
66 | return $data['body']; | |
67 | } | |
68 | ||
69 | ||
70 | /** | |
71 | * check if firmware is actual | |
72 | * | |
73 | * @return array | |
74 | */ | |
75 | public function checkFirmware () { | |
76 | $this->checkLogin(); | |
77 | ||
78 | $path = 'data/checkfirmware.json'; | |
79 | $fields = array('checkfirmware' => 'true'); | |
80 | $data = $this->sentRequest($path, $fields, true); | |
81 | ||
82 | return $data['body']; | |
83 | } | |
84 | } |