// get the csrf_token
$this->token = $this->getToken();
- if ($this->checkLogin() === true) {
+ if ($this->checkLogin(false) === true) {
return true;
}
}
/**
* check if we are logged in
*
- * @return boolean
+ * @param boolean $exception
+ * @return boolean
*/
- public function checkLogin () {
+ public function checkLogin ($exception = true) {
if (empty($this->challenge) && empty($this->session)) {
+ if ($exception === true) {
+ throw new RouterExeption('you musst be logged in to use this method');
+ }
+
return false;
}
$json = $this->getValues($json);
if ($json['loginstate'] != 1) {
+ if ($exception === true) {
+ throw new RouterExeption('you musst be logged in to use this method');
+ }
+
return false;
}
* @return array
*/
public function logout () {
- if ($this->checkLogin() !== true) throw new RouterExeption('you musst be logged in to use this method');
+ $this->checkLogin();
$path = 'data/Login.json';
$fields = array('csrf_token' => $this->token, 'logout' => 'byby');
$data = $this->sentRequest($path, $fields, true);
- if ($this->checkLogin() === false) {
+ if ($this->checkLogin(false) === false) {
// reset challenge and session
$this->challenge = '';
$this->session = '';
* @return array
*/
public function reboot () {
- if ($this->checkLogin() !== true) throw new RouterExeption('you musst be logged in to use this method');
+ $this->checkLogin();
$path = 'data/Reboot.json';
$fields = array('csrf_token' => $this->token, 'reboot_device' => 'true');
* @param string $status
*/
public function changeConnectionStatus ($status) {
- if ($this->checkLogin() !== true) throw new RouterExeption('you musst be logged in to use this method');
+ $this->checkLogin();
$path = 'data/Connect.json';
* @return array
*/
public function getData ($file) {
- if ($this->checkLogin() !== true && $file != "Status") throw new RouterExeption('you musst be logged in to use this method');
+ if ($file != "Status") $this->checkLogin();
$path = 'data/'.$file.'.json';
$fields = array();
* @return array
*/
private function exportData ($type) {
- if ($this->checkLogin() !== true) throw new RouterExeption('you musst be logged in to use this method');
+ $this->checkLogin();
$path = 'data/Syslog.json';
$fields = array('exporttype' => $type);
* @return array
*/
public function reconnectLte () {
- if ($this->checkLogin() !== true) throw new RouterExeption('you musst be logged in to use this method');
+ $this->checkLogin();
$path = 'data/modules.json';
$fields = array('csrf_token' => $this->token, 'lte_reconn' => '1');
* @return array
*/
public function resetToFactoryDefault () {
- if ($this->checkLogin() !== true) throw new RouterExeption('you musst be logged in to use this method');
+ $this->checkLogin();
$path = 'data/resetAllSetting.json';
$fields = array('csrf_token' => 'nulltoken', 'showpw' => 0, 'password' => $this->hash, 'reset_all' => 'true');
* @return array
*/
public function checkFirmware () {
- if ($this->checkLogin() !== true) throw new RouterExeption('you musst be logged in to use this method');
+ $this->checkLogin();
$path = 'data/checkfirmware.json';
$fields = array('checkfirmware' => 'true');
* @return string
*/
private function getToken () {
- if ($this->checkLogin() !== true) throw new RouterExeption('you musst be logged in to use this method');
+ $this->checkLogin();
$path = 'html/content/overview/index.html';
$fields = array();