diff --git a/php/muell.php b/php/muell.php new file mode 100755 index 0000000..4c7be8f --- /dev/null +++ b/php/muell.php @@ -0,0 +1,79 @@ +#!/usr/bin/php + + $kommune, + 'f_id_strasse' => $strasse, + 'f_id_abfalltyp_0' => 50, + 'f_id_abfalltyp_1' => 161, + 'f_id_abfalltyp_2' => 53, + 'f_id_abfalltyp_3' => 187, + 'f_abfallarten_index_max' => 5, + 'f_abfallarten' => '50,161,53,187', + 'f_zeitraum' => $dateRange, + 'f_export_als' => json_encode([ + 'action' => $url, + 'target' => '', + ]), +]; + +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_POST, 1); +curl_setopt($ch, CURLOPT_POSTFIELDS, $data); +curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla 70'); + +$response = curl_exec($ch); + +curl_close($ch); + +if ($response !== false) { + $tomorrow = (new DateTime('tomorrow'))->format('d.m.Y'); + $trashArr = str_getcsv($response, "\n"); + + foreach($trashArr as $row) { + $rowArr = str_getcsv($row, ';'); + $index = array_search($tomorrow, $rowArr); + if ($index !== false) { + $what = ''; + switch ($index) { + case 0: + case 1: + $what = "werden Biomüll und gelbe Tonne"; + break; + case 2: + $what = "wird Restmüll"; + break; + case 3: + $what = "wird Papier"; + break; + } + if ($what !== '') { + shell_exec(sprintf("echo Morgen %s abgeholt | %s -u %d", $what, $pathToBot, $tgReceiverId)); + } + } + } + +}