Mist leider zu früh gefreut…
Ich bekomme jetzt immer wieder einen neuen String Content geschrieben…
Hier das Skript:
<?
//Konfiguration
$fritzbox = 'fritz.box';
$fritzgui = 'http://' . $fritzbox . '/cgi-bin/webcm';
$password = 'xxx';
$anzeigen = array(1, 2, 3); //1 = Kommend, 2 = Kommend (Fehler), 3 = Gehend
$anzahl = 10;
//Ab hier nichts mehr ändern
$object = IPS_GetObject($IPS_SELF);
$parentID = $object['ParentID'];
//Installer
if ($IPS_SENDER == "Execute")
{
IPS_SetHidden($IPS_SELF, true);
IPS_SetName($IPS_SELF, "Auslese-Skript");
$parentObject = IPS_GetObject($parentID);
if ($parentObject['ObjectType'] !== 1)
{
$instanceID = IPS_CreateInstance("{485D0419-BE97-4548-AA9C-C083EB82E61E}");
IPS_SetParent($instanceID, $parentID);
$parentID = $instanceID;
IPS_SetParent($IPS_SELF, $parentID);
IPS_SetName($instanceID, "Anruferliste");
}
IPS_SetScriptTimer($IPS_SELF, 300);
}
$login = file_get_contents('http://' . $fritzbox . '/cgi-bin/webcm?getpage=../html/login_sid.xml');
$session_status_simplexml = @simplexml_load_string($login);
if($session_status_simplexml === false)
{
die("Fehler beim einlesen der XML Daten. Wahrscheinlich ist eine zu alte Firmware installiert");
}
else if ($session_status_simplexml->iswriteaccess == 1)
{
$SID = $session_status_simplexml->SID;
}
else
{
$challenge = $session_status_simplexml->Challenge;
$response = $challenge . '-' . md5(iconv("UTF-8", "UCS-2LE", $challenge . '-' . $password));
$postdata = http_build_query(array('getpage' => '../html/de/menus/menu2.html', 'login:command/response' => $response));
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-Length: '.strlen($postdata)."
".
'Content-Type: application/x-www-form-urlencoded',
'content'=> $postdata
)
);
$context = stream_context_create($opts);
$sendlogin = file_get_contents($fritzgui, false, $context);
preg_match('@<input type="hidden" name="sid" value="([A-Fa-f0-9]{16})" id="uiPostSid">@i', $sendlogin, $matches);
if (isset($matches[1]) && $matches[1] != '0000000000000000')
{
$SID = $matches[1];
}
else
{
echo "Fehler: Login fehlgeschlagen";
return;
}
}
//Anrufliste aktualisieren
$postdata = http_build_query(array('getpage' => '../html/de/menus/menu2.html','sid' => $SID, 'var:menu' => 'home', 'varagename' => 'foncalls'));
$opts = array('http' =>
array(
'method' => 'POST',
'header'=> 'Content-Length: '.strlen($postdata)."
".
'Content-Type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$getnewlist = file_get_contents($fritzgui, false, $context);
//Anrufliste abholen
$postdata = http_build_query(array('getpage' => '../html/de/FRITZ!Box_Anrufliste.csv', 'sid' => $SID));
$opts = array('http' =>
array(
'method' => 'POST',
'header'=> 'Content-Length: '.strlen($postdata)."
".
'Content-Type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$anrufliste = file_get_contents($fritzgui, false, $context);
$anrufliste = explode("
", $anrufliste);
$str = "<table width='90%' align='center'>"; // Farbe anpassen oder style entfernen
$str .= "<tr><td></td><td><b>Datum</b></td><td><b>Name/Rufnummer</b></td><td><b>Nebenstelle</b></td><td><b>Zeit</b></td></tr>";
$pos = 0;
for($i=3; $i<=sizeof($anrufliste); $i++)
{
$eintrag = explode(";", $anrufliste[$i]);
if(strlen($eintrag[2]) > 0)
$eintrag[3] = $eintrag[2];
unset($eintrag[2]);
if(strlen($eintrag[4]) > 0)
$eintrag[5] = $eintrag[4];
if(strlen($eintrag[3]) == 0)
$eintrag[3] = "Unbekannt";
unset($eintrag[4]);
$caller = $eintrag[0];
switch($caller) {
case 1:
$eintrag[0] = "<img src=/user/fritz/Callin.png>";
break;
case 2:
$eintrag[0] = "<img src=/user/fritz/Callinfailed.png>";
break;
case 3:
$eintrag[0] = "<img src=/user/fritz/Callout.png>";
break;
default:
$eintrag[0] = "";
break;
}
if(in_array($caller, $anzeigen))
{
$str .= "<tr>";
foreach($eintrag as $data)
$str .= '<td>'.$data.'</td>';
$str .= "</tr>";
$pos++;
}
if($pos >= $anzahl)
break;
}
$str .= "</table>";
$vid = CreateVariableByName($parentID, "Content", 3);
IPS_SetIcon($vid, "Speaker");
IPS_SetVariableCustomProfile($vid, "~HTMLBox");
SetValue($vid, $str);
$postdata = http_build_query(array('getpage' => '../html/de/menus/menu2.html', 'sid' => $SID, 'security:command/logout' => 'logout'));
$opts = array('http' =>
array(
'method' => 'POST',
'header'=> 'Content-Length: '.strlen($postdata)."
".
'Content-Type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$logout = file_get_contents($fritzgui, false, $context);
function CreateVariableByName($id, $name, $type)
{
global $IPS_SELF;
$vid = @IPS_GetVariableIDByName($name, $id);
if($vid === false)
{
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, $id);
IPS_SetName($vid, $name);
IPS_SetInfo($vid, "this variable was created by script #$IPS_SELF");
}
return $vid;
}
?>
Woran könnte das liegen?
Außerdem würde ich gerne den Punkt Telefon als eigenen Punkt haben. Also wie auf den Bildern zu sehen, wie bspw. Maxdome oder der Punkt „Haus“
Wie müsste ich da die Ordnerstruktur ändern bzw. das Webfront anpassen?
Besten Dank