forked from gpunktschmitz/fritz-dect-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
switchOff.php
29 lines (23 loc) · 1.01 KB
/
switchOff.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
if(isset($_GET['ain'])) {
require 'login.inc.php';
$ch = curl_init('http://fritz.box/login_sid.lua');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$login = curl_exec($ch);
$session_status_simplexml = simplexml_load_string($login);
$challenge = $session_status_simplexml->Challenge;
$response = $challenge . '-' . md5(mb_convert_encoding($challenge.'-'.$fritzbox_password, "UCS-2LE", "UTF-8"));
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".$fritzbox_username."&response={$response}&page=/login_sid.lua");
$sendlogin = curl_exec($ch);
$session_status_simplexml = simplexml_load_string($sendlogin);
if($session_status_simplexml->SID != '0000000000000000') {
$SID = $session_status_simplexml->SID;
} else {
echo "ERROR: Login failed";
exit;
}
curl_close($ch);
$switchOff = file_get_contents('http://fritz.box/webservices/homeautoswitch.lua?switchcmd=setswitchoff&sid='.$SID.'&ain='.$_GET['ain']);
$logout = file_get_contents('http://fritz.box/login.lua?page=/home/home.lua&logout=1&sid='.$SID);
}
?>