projects
/
GitHub
/
Stricted
/
speedport-hybrid-php-api.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8162139
)
improve checkLogin
author
Stricted
<info@stricted.de>
Mon, 20 Jul 2015 00:04:15 +0000
(
02:04
+0200)
committer
Stricted
<info@stricted.de>
Mon, 20 Jul 2015 00:04:15 +0000
(
02:04
+0200)
SpeedportHybrid.class.php
patch
|
blob
|
blame
|
history
diff --git
a/SpeedportHybrid.class.php
b/SpeedportHybrid.class.php
index 43d60686009998d6b1eff53a8e81f928dc3c3660..d1fbd7e82b91736380c86c6464888c3ee7b54e38 100644
(file)
--- a/
SpeedportHybrid.class.php
+++ b/
SpeedportHybrid.class.php
@@
-112,7
+112,7
@@
class SpeedportHybrid {
// get the csrf_token
$this->token = $this->getToken();
// get the csrf_token
$this->token = $this->getToken();
- if ($this->checkLogin() === true) {
+ if ($this->checkLogin(
false
) === true) {
return true;
}
}
return true;
}
}
@@
-124,10
+124,15
@@
class SpeedportHybrid {
/**
* check if we are logged in
*
/**
* 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 (empty($this->challenge) && empty($this->session)) {
+ if ($exception === true) {
+ throw new RouterExeption('you musst be logged in to use this method');
+ }
+
return false;
}
return false;
}
@@
-143,6
+148,10
@@
class SpeedportHybrid {
$json = $this->getValues($json);
if ($json['loginstate'] != 1) {
$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 false;
}
@@
-155,12
+164,12
@@
class SpeedportHybrid {
* @return array
*/
public function logout () {
* @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);
$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 = '';
// reset challenge and session
$this->challenge = '';
$this->session = '';
@@
-181,7
+190,7
@@
class SpeedportHybrid {
* @return array
*/
public function reboot () {
* @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');
$path = 'data/Reboot.json';
$fields = array('csrf_token' => $this->token, 'reboot_device' => 'true');
@@
-206,7
+215,7
@@
class SpeedportHybrid {
* @param string $status
*/
public function changeConnectionStatus ($status) {
* @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';
$path = 'data/Connect.json';
@@
-230,7
+239,7
@@
class SpeedportHybrid {
* @return array
*/
public function getData ($file) {
* @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();
$path = 'data/'.$file.'.json';
$fields = array();
@@
-287,7
+296,7
@@
class SpeedportHybrid {
* @return array
*/
private function exportData ($type) {
* @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);
$path = 'data/Syslog.json';
$fields = array('exporttype' => $type);
@@
-306,7
+315,7
@@
class SpeedportHybrid {
* @return array
*/
public function reconnectLte () {
* @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');
$path = 'data/modules.json';
$fields = array('csrf_token' => $this->token, 'lte_reconn' => '1');
@@
-323,7
+332,7
@@
class SpeedportHybrid {
* @return array
*/
public function resetToFactoryDefault () {
* @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');
$path = 'data/resetAllSetting.json';
$fields = array('csrf_token' => 'nulltoken', 'showpw' => 0, 'password' => $this->hash, 'reset_all' => 'true');
@@
-340,7
+349,7
@@
class SpeedportHybrid {
* @return array
*/
public function checkFirmware () {
* @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');
$path = 'data/checkfirmware.json';
$fields = array('checkfirmware' => 'true');
@@
-493,7
+502,7
@@
class SpeedportHybrid {
* @return string
*/
private function getToken () {
* @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();
$path = 'html/content/overview/index.html';
$fields = array();