<?
if($_IPS['SENDER'] == "Execute")
{
$fritzbox_ip = 'fritz.box';
$password = 'xxxxx';
$ch = curl_init('http://' . $fritzbox_ip . '/cgi-bin/webcm?getpage=../html/login_sid.xml');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$login = curl_exec($ch);
$session_status_simplexml = simplexml_load_string($login);
if ($session_status_simplexml->iswriteaccess == 1)
{
$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, "login:command/response={$response}&getpage=../html/de/menus/menu2.html");
preg_match('/name="sid" value="([0-9a-f]*)"/', curl_exec($ch), $matches);
if(isset($matches[1]) && $matches[1] != '0000000000000000')
{
$SID = $matches[1];
}
else
{
echo "Fehler: Login fehlgeschlagen";
return;
}
curl_setopt($ch, CURLOPT_POSTFIELDS, "sid={$SID}&telcfg:settings/DialPort=60"); // Nebenstellennummer eintragen!
curl_exec($ch);
curl_setopt($ch, CURLOPT_POSTFIELDS, "sid={$SID}&telcfg:command/Dial=**612"); // Rufnummer eintragen!
curl_exec($ch);
curl_close($ch);
}
}
?>
Comments