<?php
$fritzbox_ip = '192.168.xxx.xxx';
$password = 'mein Passwort';
$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);
if ($session_status_simplexml->SID != '0000000000000000')
{
$SID = $session_status_simplexml->SID;
}
else
{
$challenge = $session_status_simplexml->Challenge;
$response = $challenge . '-' . md5(mb_convert_encoding($challenge . '-' . $password, "UCS-2LE", "UTF-8"));
curl_setopt($ch, CURLOPT_POSTFIELDS, "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 "Fehler: Login fehlgeschlagen";
return;
}
}
curl_close($ch);
//Der Login ist abgeschlossen
//Nun schalten
$startHH="00";
$startMM="00";
$endHH="23";
$endMM="59";
$einAus="on";
$ch = curl_init("http://192.168.xxx.xxx/fon_devices/edit_dect_ring_block.lua?sid={$SID}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$rc1=curl_setopt($ch, CURLOPT_POSTFIELDS, ($einAus == "on" ? "nightsetting=1&lockmode=0&lockday=everday&starthh=".$startHH."&startmm=".$startMM."&endhh=".$endHH."&endmm=".$endMM : "") .
"&sid=" . $SID. "&idx=1&button_save=");
$rc2=curl_exec($ch);
echo "Geschaltet.<br>";
?>