diff --git a/docs/releasenotes/releasenotes.rst b/docs/releasenotes/releasenotes.rst index 1cc44137..535d65df 100644 --- a/docs/releasenotes/releasenotes.rst +++ b/docs/releasenotes/releasenotes.rst @@ -17,6 +17,7 @@ Fixes * Fixes in autoswipe timeout computations * Dial: Slightly bigger default size of dial. Set block parameter ``scale: 0.9`` to reduce the dial size. * Graph: Remove total counter graph line for some dial types, only in case graphTypes and legend have not been defined. +* Garbage: Fix for Circulus-Berkel V3.9.5 Beta (25-3-2022) ----------------------- diff --git a/js/components/garbage.js b/js/components/garbage.js index 242561c5..20e8ca10 100644 --- a/js/components/garbage.js +++ b/js/components/garbage.js @@ -737,8 +737,8 @@ var DT_garbage = (function () { circulusberkel: { handler: getGeneralData, param: { - service: 'afvalstromen', - subservice: 'circulusberkel', + service: 'circulusberkel', +// subservice: 'circulusberkel', }, }, cure: { diff --git a/js/loader.js b/js/loader.js index fb6040c1..2760ada4 100644 --- a/js/loader.js +++ b/js/loader.js @@ -1,6 +1,6 @@ /*global loadFiles dashtype */ -var _DASHTICZ_VERSION=46; +var _DASHTICZ_VERSION=47; var head = document.getElementsByTagName('head')[0], script = document.createElement('script'); diff --git a/vendor/dashticz/garbage/index.php b/vendor/dashticz/garbage/index.php index 36885fd6..a69df181 100644 --- a/vendor/dashticz/garbage/index.php +++ b/vendor/dashticz/garbage/index.php @@ -70,6 +70,22 @@ function logMsg($msg) { report( $msg, 'msg'); } +$cookies = Array(); +function curlResponseHeaderCallback($ch, $headerLine) { + global $cookies; + + preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $matches); + foreach($matches[1] as $item) { + parse_str($item, $cookie); + $cookies = array_merge($cookies, $cookie); + } + return strlen($headerLine); // Needed by curl +} + +function addCookie($cookie, $cookies, $key) { + return $cookie.'&'.$key.'='.$cookies[$key]; +} + function curlPost($url, $data=0) { //Create curl Post request debugMsg($url); @@ -91,9 +107,12 @@ function fileGetJson($url) { function curlWeb($url, $options=0) { global $ignoressl; + global $cookies; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HEADERFUNCTION, "curlResponseHeaderCallback"); + $cookies = array(); if ($ignoressl) { report('SSL check disabled', 'info'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); @@ -119,7 +138,10 @@ function curlWebMatch($url, $regexp) { return $match; } + function getCalendar() { + global $cookies; + $allDates=array(); $zipCode = $_GET['zipcode']; $houseNr = $_GET['nr']; @@ -413,6 +435,47 @@ function getCalendar() { } break; + case 'circulusberkel': + $url = 'https://mijn.circulus.nl/register/zipcode.json'; + $data = 'authenticityToken=1e1d2d435e5214dcdf453b31aba2f9d1fc5bb7a1&zipCode='.$_GET['zipcode'].'&number='.$_GET['nr']; +// var_dump($url); +// var_dump($data); + $res=curlPost($url, $data); +// var_dump($cookies); + $cb_session=$cookies['CB_SESSION']; +// var_dump($cb_session); +// var_dump($res); + + $startDate=date("Y-m-d"); + $endDate=date("Y-m-d",time()+28*24*60*60); + $url='https://mijn.circulus.nl/afvalkalender.json?from='.$startDate.'&till='.$endDate; + //selectedHouseNumber=36&selectedZipCode=7325XT&municipality=Apeldoorn&___TS=1650698691422&arisId=1000124990&residence=Apeldoorn&selectedHouseType=0 + $cookie = "CB_SESSION=".$cb_session; + $cookie = addCookie($cookie, $cookies, 'selectedHouseNumber'); + $cookie = addCookie($cookie, $cookies, 'selectedZipCode'); + $cookie = addCookie($cookie, $cookies, 'municipality'); + $cookie = addCookie($cookie, $cookies, '___TS'); + $cookie = addCookie($cookie, $cookies, 'arisId'); + $cookie = addCookie($cookie, $cookies, 'residence'); + $cookie = addCookie($cookie, $cookies, 'selectedHouseType'); + $options = array( + CURLOPT_HTTPHEADER => + 'Cookie: '.$cookie + ); + +// var_dump($url); +// var_dump($options); + + $result=curlWebJson($url, $options); + + foreach ($result->customData->response->garbage as $key => $value) { + foreach ($value->dates as $date) { + $code=$value->code; + if($code==='PAP') $code='Papier'; + $allDates[$date][$code] = $date; + } + } + } $temp=$allDates; $allDates=array();