cleanup
[GitHub/Stricted/speedport-hybrid-php-api.git] / System.class.php
index 418403b2e64d75527d9a9bacb2ecd402b5cb8387..4bf7a279b404abebb1f6b7013c833a89adf3e7f5 100644 (file)
@@ -81,4 +81,32 @@ trait System {
                
                return $data['body'];
        }
-}
\ No newline at end of file
+       
+       /**
+        * reboot the router
+        * 
+        * @return      boolean
+        */
+       public function reboot () {
+               $this->checkLogin();
+               
+               $path = 'data/Reboot.json';
+               $fields = array('csrf_token' => $this->token, 'reboot_device' => 'true');
+               $data = $this->sentEncryptedRequest($path, $fields, true);
+               $data = $this->getValues($data['body']);
+               
+               if ($data['status'] == 'ok') {
+                       // reset challenge and session
+                       $this->challenge = '';
+                       $this->cookie = '';
+                       $this->token = '';
+                       $this->derivedk = ''; 
+                       
+                       // throw an exception because router is unavailable for other tasks
+                       // like $this->logout() or $this->checkLogin
+                       throw new RebootException('Router Reboot');
+               }
+               
+               return false;
+       }
+}