Skip to content

Commit

Permalink
Merge pull request #994 from lokonli/garbageCirculus
Browse files Browse the repository at this point in the history
Garbage: Fix Circulius-berkel
  • Loading branch information
lokonli authored Apr 17, 2022
2 parents d3539bf + 36e6f83 commit 55182c6
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/releasenotes/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-----------------------
Expand Down
4 changes: 2 additions & 2 deletions js/components/garbage.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/loader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions vendor/dashticz/garbage/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -119,7 +138,10 @@ function curlWebMatch($url, $regexp) {
return $match;
}


function getCalendar() {
global $cookies;

$allDates=array();
$zipCode = $_GET['zipcode'];
$houseNr = $_GET['nr'];
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 55182c6

Please sign in to comment.