kopia lustrzana https://github.com/sq9atk/sr0wx
Naprawa pobierania informacji o przekroczeniach stanów wód na wodowskazach
rodzic
c44985882c
commit
bc3880ee04
|
@ -3,9 +3,9 @@
|
||||||
ini_set('max_execution_time', 1800);
|
ini_set('max_execution_time', 1800);
|
||||||
|
|
||||||
function getAllIdsFromImgw () {
|
function getAllIdsFromImgw () {
|
||||||
$res = shell_exec("curl --silent 'https://hydro.imgw.pl/api/map/?category=hydro' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Accept-Language: pl,en-US;q=0.7,en;q=0.3' --compressed -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Referer: https://hydro.imgw.pl/' -H 'Cookie: SRV_=shsrv02.imgw.pl_SRV' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache'");
|
$res = shell_exec("curl --silent 'https://hydro-back.imgw.pl/map/stations/hydrologic?onlyMainStations=false' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Accept-Language: pl,en-US;q=0.7,en;q=0.3' --compressed -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Referer: https://hydro.imgw.pl/' -H 'Cookie: SRV_=shsrv02.imgw.pl_SRV' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache'");
|
||||||
|
|
||||||
return json_decode($res);
|
return json_decode($res)->stations;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRequestedIds ($base64json) {
|
function getRequestedIds ($base64json) {
|
||||||
|
@ -41,16 +41,16 @@
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach($allIds as $row){
|
foreach($allIds as $row){
|
||||||
|
|
||||||
if (!in_array($row->i, $requestIds)) continue;
|
if (!in_array($row->id, $requestIds)) continue;
|
||||||
|
|
||||||
if (dataFileIsToOld('imgwpodest_data/'.$row->i.'.json', 3600)) {
|
if (dataFileIsToOld('imgwpodest_data/'.$row->id.'.json', 3600)) {
|
||||||
$json = shell_exec("curl --silent 'https://hydro.imgw.pl/api/station/hydro/?id=".$row->i."' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Accept-Language: pl,en-US;q=0.7,en;q=0.3' --compressed -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Referer: https://hydro.imgw.pl/' -H 'Cookie: SRV_=shsrv01.imgw.pl_SRV' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache'");
|
$json = shell_exec("curl --silent 'https://hydro-back.imgw.pl/station/hydro/status?id=".$row->id."' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Accept-Language: pl,en-US;q=0.7,en;q=0.3' --compressed -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Referer: https://hydro.imgw.pl/' -H 'Cookie: SRV_=shsrv01.imgw.pl_SRV' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache'");
|
||||||
|
|
||||||
file_put_contents('imgwpodest_data/'.$row->i.'.json', $json);
|
file_put_contents('imgwpodest_data/'.$row->id.'.json', $json);
|
||||||
}
|
}
|
||||||
|
|
||||||
//file_put_contents('imgwpodest_data/'.$row->i.'.txt', print_r($subdata, true));
|
//file_put_contents('imgwpodest_data/'.$row->i.'.txt', print_r($subdata, true));
|
||||||
$subdata = json_decode(file_get_contents('imgwpodest_data/'.$row->i.'.json'));
|
$subdata = json_decode(file_get_contents('imgwpodest_data/'.$row->id.'.json'));
|
||||||
|
|
||||||
if (isset($subdata->exception) || !isset($subdata->status)) {
|
if (isset($subdata->exception) || !isset($subdata->status)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -59,12 +59,12 @@
|
||||||
$tmp_river = explode(' (',$subdata->status->river);
|
$tmp_river = explode(' (',$subdata->status->river);
|
||||||
|
|
||||||
$trends = array('const' => 0, 'unknown' => 0, 'down' => -1, 'up' => 1);
|
$trends = array('const' => 0, 'unknown' => 0, 'down' => -1, 'up' => 1);
|
||||||
$result[$row->i] = array(
|
$result[$row->id] = array(
|
||||||
'id' => $row->i,
|
'id' => $row->id,
|
||||||
'nazwa' => $subdata->status->description,
|
'nazwa' => $subdata->status->description,
|
||||||
'rzeka' => $tmp_river[0],
|
'rzeka' => $tmp_river[0],
|
||||||
'region' => $subdata->status->province,
|
'region' => $subdata->status->province,
|
||||||
'tendencja' => $trends[$subdata->trend],
|
'tendencja' => $subdata->status->trend,
|
||||||
'stan_cm' => isset($subdata->status->currentState) ? $subdata->status->currentState->value : null,
|
'stan_cm' => isset($subdata->status->currentState) ? $subdata->status->currentState->value : null,
|
||||||
'poziom_ostrzegawczy' => $subdata->status->warningValue,
|
'poziom_ostrzegawczy' => $subdata->status->warningValue,
|
||||||
'poziom_alarmowy' => $subdata->status->alarmValue,
|
'poziom_alarmowy' => $subdata->status->alarmValue,
|
||||||
|
@ -76,4 +76,3 @@
|
||||||
|
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue