'http://www.norderstedt.de/output/abfall_export.php?call=suche&print=1&ort='.$ort.'&strasse='.$strasse.'&abfart[0]=1.1&abfart[1]=1.4&abfart[2]=1.2&abfart[3]=1917.1&vtyp=1'); // $data['_URL'] = "http://www.norderstedt.de/output/abfall_export.php?call=suche&print=1&ort=1087.1&strasse=1917.506.1&abfart[0]=1.1&abfart[1]=1.4&abfart[2]=1.2&abfart[3]=1917.1&vtyp=1"; // *********************************************************** // Installation // *********************************************************** if($_IPS['SENDER'] == "Execute") { // Kategorien anlegen $adir = CreateCategoryByName(0, 'ACSoft', 'AC-Soft'); $cdir = CreateCategoryByName($adir, 'AbfallKalender', 'Abfall Kalender'); $sdir = CreateCategoryByName($cdir, 'Scripte', 'Scripte'); $ddir = CreateCategoryByName($cdir, 'Data', 'Data'); $kdir = CreateCategoryByName($cdir, 'Konfiguration', 'Konfiguration'); $vdir = CreateCategoryByName($cdir, 'Visualisierung', 'Visualisierung'); // Variablen anlegen $vtonnen = CreateVariableByName($ddir, "TonnenRally", "TonnenRally", 3, "~HTMLBox", 10); if ($einzeltage == 1) // Bei aktiven Einzeltagen entsprechende Variablen erstellen { $vmo = CreateVariableByName($ddir, "Montag", "Montag", 3, "~HTMLBox", 20); $vdi = CreateVariableByName($ddir, "Dienstag", "Dienstag", 3, "~HTMLBox", 30); $vmi = CreateVariableByName($ddir, "Mittwoch", "Mittwoch", 3, "~HTMLBox", 40); $vdo = CreateVariableByName($ddir, "Donnerstag", "Donnerstag", 3, "~HTMLBox", 50); $vfr = CreateVariableByName($ddir, "Freitag", "Freitag", 3, "~HTMLBox", 60); $vsa = CreateVariableByName($ddir, "Samstag", "Samstag", 3, "~HTMLBox", 70); $vso = CreateVariableByName($ddir, "Sonntag", "Sonntag", 3, "~HTMLBox", 80); } // Links Struktur erstellen if ($visualisierung == 2) // Dummy erstellen { $wdir = CreateInstanceByName($vdir, 'AbfallWoche', 'Abfall Woche'); $wsdir = CreateInstanceByName($vdir, 'AbfallTage', 'Abfall Tage'); } else if ($visualisierung == 1) // Kategorie erstellen { $wdir = CreateCategoryByName($vdir, 'AbfallWoche', 'Abfall Woche'); $wsdir = CreateCategoryByName($vdir, 'AbfallTage', 'Abfall Tage'); } else // ohne Unterstruktur { $wdir = $vdir; $wsdir = $vdir; } // Links erstellen CreateLinkByName($wdir, 'TonnenRally', 'TonnenRally', $vtonnen, 10); if ($einzeltage == 1) // Bei aktiven Einzeltagen entsprechende Variablen erstellen { CreateLinkByName($wsdir, 'Montag', 'Montag', $vmo, 20); CreateLinkByName($wsdir, 'Dienstag', 'Dienstag', $vdi, 30); CreateLinkByName($wsdir, 'Mittwoch', 'Mittwoch', $vmi, 40); CreateLinkByName($wsdir, 'Donnerstag', 'Donnerstag', $vdo, 50); CreateLinkByName($wsdir, 'Freitag', 'Freitag', $vfr, 60); CreateLinkByName($wsdir, 'Samstag', 'Samstag', $vsa, 70); CreateLinkByName($wsdir, 'Sonntag', 'Sonntag', $vso, 80); } // Script verschieben IPS_SetParent($_IPS['SELF'], $sdir); IPS_SetName($_IPS['SELF'], 'Abfall Script'); // Timer erstellen/einstellen CreateTimer_Profile('AbfallTimer', 'Abfall Timer', $_IPS['SELF'], 0, 3, 2, 1, 0, 0, 0, 0, true); // KonfigScript erstellen $kscript = CreateScriptByName($kdir, "Konfiguration", "Konfiguration", ""); } // *********************************************************** // Inhalte mit Leben füllen // *********************************************************** if (($_IPS['SENDER'] == "Timer") || ($_IPS['SENDER'] == "Execute")) { $str = ""; $strmo = $str; $strdi = $str; $strmi = $str; $strdo = $str; $strfr = $str; $strsa = $str; $strso = $str; $data['_CH'] = curl_init(); curl_setopt($data['_CH'],CURLOPT_RETURNTRANSFER,true); curl_setopt($data['_CH'],CURLOPT_URL,$data['_URL']); $data['result'] = curl_exec($data['_CH']); curl_close($data['_CH']); $data['result'] = str_replace("  ",":", $data['result']); $data['result'] = str_replace(" ",";", $data['result']); $data['result'] = urldecode($data['result']); $data['resultutf'] = utf8_encode($data['result']); $dom = new DOMDocument(); @$dom->loadHTML($data['resultutf']); $select=$dom->getElementsByTagName('table'); foreach($select as $tb) { $dtype=$tb->getAttribute("class"); if (substr($dtype,0,7) == "abf_art") { $vals = explode(';', $tb->nodeValue); foreach($vals as $nr=>$val) { if ($nr >0) { $kal = mktime(0,0,0, substr($val,6,2), substr($val,3,2), substr($val,9,2)); $heute = mktime(0,0,0, date('m'), date('d'), date('y')); $week = mktime(0,0,0, date('m'), date('d')+7, date('y')); if (($kal <= $week) && ($kal >= $heute)) { if (utf8_decode($vals[0]) == "Restabfall 2-wöch.") { $color = "#444444"; $str .= ""; if ($einzeltage == 1) // Bei aktiven Einzeltagen entsprechende Variablen erstellen { if (substr($val,0,2) == "Mo") { $strmo .= ""; } if (substr($val,0,2) == "Di") { $strdi .= ""; } if (substr($val,0,2) == "Mi") { $strmi .= ""; } if (substr($val,0,2) == "Do") { $strdo .= ""; } if (substr($val,0,2) == "Fr") { $strfr .= ""; } if (substr($val,0,2) == "Sa") { $strsa .= ""; } if (substr($val,0,2) == "So") { $strso .= ""; } } } if (utf8_decode($vals[0]) == "Papiertonne") { $color = "#0000AA"; $str .= ""; if ($einzeltage == 1) // Bei aktiven Einzeltagen entsprechende Variablen erstellen { if (substr($val,0,2) == "Mo") { $strmo .= ""; } if (substr($val,0,2) == "Di") { $strdi .= ""; } if (substr($val,0,2) == "Mi") { $strmi .= ""; } if (substr($val,0,2) == "Do") { $strdo .= ""; } if (substr($val,0,2) == "Fr") { $strfr .= ""; } if (substr($val,0,2) == "Sa") { $strsa .= ""; } if (substr($val,0,2) == "So") { $strso .= ""; } } } if (utf8_decode($vals[0]) == "Gelbe Wertstofftonne/Säcke") { $color = "#AAAA00"; $str .= ""; if ($einzeltage == 1) // Bei aktiven Einzeltagen entsprechende Variablen erstellen { if (substr($val,0,2) == "Mo") { $strmo .= ""; } if (substr($val,0,2) == "Di") { $strdi .= ""; } if (substr($val,0,2) == "Mi") { $strmi .= ""; } if (substr($val,0,2) == "Do") { $strdo .= ""; } if (substr($val,0,2) == "Fr") { $strfr .= ""; } if (substr($val,0,2) == "Sa") { $strsa .= ""; } if (substr($val,0,2) == "So") { $strso .= ""; } } } if (utf8_decode($vals[0]) == "Bioabfall") { $color = "#A95A57"; $str .= ""; if ($einzeltage == 1) // Bei aktiven Einzeltagen entsprechende Variablen erstellen { if (substr($val,0,2) == "Mo") { $strmo .= ""; } if (substr($val,0,2) == "Di") { $strdi .= ""; } if (substr($val,0,2) == "Mi") { $strmi .= ""; } if (substr($val,0,2) == "Do") { $strdo .= ""; } if (substr($val,0,2) == "Fr") { $strfr .= ""; } if (substr($val,0,2) == "Sa") { $strsa .= ""; } if (substr($val,0,2) == "So") { $strso .= ""; } } } } } } } } $str .= "
".substr($val,0,2)."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".substr($val,0,2)."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".substr($val,0,2)."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".substr($val,0,2)."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."".utf8_decode($vals[0])."
"; $adir = IPS_GetObjectIDByIdent('ACSoft', 0); $cdir = IPS_GetObjectIDByIdent('AbfallKalender', $adir); $ddir = IPS_GetObjectIDByIdent('Data', $cdir); SetValue(IPS_GetObjectIDByIdent("TonnenRally",$ddir), $str); if ($einzeltage == 1) // Bei aktiven Einzeltagen entsprechende Variablen erstellen { SetValue(IPS_GetObjectIDByIdent("Montag",$ddir), $strmo); SetValue(IPS_GetObjectIDByIdent("Dienstag",$ddir), $strdi); SetValue(IPS_GetObjectIDByIdent("Mittwoch",$ddir), $strmi); SetValue(IPS_GetObjectIDByIdent("Donnerstag",$ddir), $strdo); SetValue(IPS_GetObjectIDByIdent("Freitag",$ddir), $strfr); SetValue(IPS_GetObjectIDByIdent("Samstag",$ddir), $strsa); SetValue(IPS_GetObjectIDByIdent("Sonntag",$ddir), $strso); } } /*****************************************************************/ /* F u n k t i o n e n */ /*****************************************************************/ function CreateTimer_Profile ( $Ident, $Name, $ParentId, $Stunde=0, $Minute=0, $Datumstyp = 0, $Datumsintervall = 0, $Datumstage = 0, $Datumstagesintervall = 0, $Zeittyp = 0, $Position=0, $Status=true) { Global $abfrageintervall, $debug; $TimerId = @IPS_GetObjectIDByIdent($Ident, $ParentId); // Timer erzeugen if ($TimerId === false) { $TimerId = IPS_CreateEvent(1 ); IPS_SetParent($TimerId, $ParentId); IPS_SetName($TimerId, $Name); IPS_SetIdent($TimerId, $Ident); IPS_SetPosition($TimerId, $Position); if ($debug) IPS_LogMessage("owncloud", "Created Wecker Timer ".$Name."=".$TimerId); } // Timer setzen if ( IPS_GetKernelVersion() >= "3.10"){ if (!IPS_SetEventCyclic($TimerId, $Datumstyp, $Datumsintervall, $Datumstage, $Datumstagesintervall, $Zeittyp, $abfrageintervall)) { Error ("IPS_SetEventCyclic failed !!!"); } if (!IPS_SetEventCyclicTimeFrom($TimerId, intval($Stunde), intval($Minute), 0)) { Error ("IPS_SetEventCyclicTimeBounds $TimerId with Time $zeit failed !!!"); } if (!IPS_SetEventCyclicDateFrom($TimerId, 0, 0, 0)) { Error ("IPS_SetEventCyclicTimeBounds $TimerId with DefaultDate failed !!!"); } }else{ if (!IPS_SetEventCyclicTimeBounds($TimerId, mktime($Stunde, $Minute, 0), 0)) { Error ("IPS_SetEventCyclicTimeBounds failed !!!"); } } IPS_SetEventActive($TimerId, $Status); return $TimerId; } function CreateScriptByName($id, $ident, $name, $content = "") { Global $_IPS; $vscr = @IPS_GetObjectIDByIdent($ident, $id); if($vscr === false) { $vscr = IPS_CreateScript(0); IPS_SetParent($vscr, $id); IPS_SetName($vscr, $name); IPS_SetIdent($vscr, $ident); IPS_SetInfo($vscr, "Diese Objekt wurde durch folgendes Script erstellt: #".$_IPS['SELF']); IPS_SetScriptContent($vscr, $content); // IPS_SetScriptFile($vscr, "$vscr.ips.php"); } return $vscr; } function CreateLinkByName($id, $ident, $name, $target, $position) { Global $_IPS; $vlnk = @IPS_GetObjectIDByIdent($ident, $id); if($vlnk === false) { $vlnk = IPS_CreateLink(); IPS_SetParent($vlnk, $id); IPS_SetName($vlnk, $name); IPS_SetIdent($vlnk, $ident); IPS_SetInfo($vlnk, "Diese Objekt wurde durch folgendes Script erstellt: #".$_IPS['SELF']); IPS_SetPosition($vlnk, $position); IPS_SetLinkTargetID($vlnk, $target); } return $vlnk; } function CreateInstanceByName($id, $ident, $name) { Global $_IPS; $vinst = @IPS_GetObjectIDByIdent($ident, $id); if($vinst === false) { $vinst = IPS_CreateInstance("{485D0419-BE97-4548-AA9C-C083EB82E61E}"); IPS_SetParent($vinst, $id); IPS_SetName($vinst, $name); IPS_SetIdent($vinst, $ident); IPS_SetInfo($vinst, "Diese Objekt wurde durch folgendes Script erstellt: #".$_IPS['SELF']); } return $vinst; } function CreateCategoryByName($id, $ident, $name) { Global $_IPS; $vdir = @IPS_GetObjectIDByIdent($ident, $id); if($vdir === false) { $vdir = IPS_CreateCategory(); IPS_SetParent($vdir, $id); IPS_SetName($vdir, $name); IPS_SetIdent($vdir, $ident); IPS_SetInfo($vdir, "Diese Objekt wurde durch folgendes Script erstellt: #".$_IPS['SELF']); } return $vdir; } function CreateVariableByName($id, $ident, $name, $type, $profile = "", $position = 0) { Global $_IPS; $vid = @IPS_GetObjectIDByIdent($ident, $id); if($vid === false) { $vid = IPS_CreateVariable($type); IPS_SetParent($vid, $id); IPS_SetName($vid, $name); IPS_SetIdent($vid, $ident); IPS_SetPosition($vid, $position); IPS_SetInfo($vid, "Diese Objekt wurde durch folgendes Script erstellt: #".$_IPS['SELF']); if($profile !== "") { IPS_SetVariableCustomProfile($vid, $profile); } } return $vid; } ?>