jb-data.de/test.php
2025-08-11 22:23:30 +02:00

203 lines
No EOL
5.7 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
$kw_aktuell = (int)date('W');
$jahr = (int)date('Y');
require('lib/config.php');
require('lib/mysql.class.php');
$GLOBALS['mysql'] = new mysql(CONFIG_MYSQL_HOST,CONFIG_MYSQL_USER,CONFIG_MYSQL_PW,CONFIG_MYSQL_DB);
mysqli_set_charset($mysql, 'utf8');
header("Content-Type: text/html; charset=utf-8");
//----------------------------------------------------------------------------------------------------------------
$jstr1='{
"id": "c3mkmhw2ii8igw4s",
"ver": "1.48",
"lang": "deu",
"auth": {
"type": "AID",
"aid": "kAL6ULet"
},
"client": {
"id": "NASA",
"type": "WEB",
"name": "webapp",
"l": "vs_webapp_lvb",
"v": ""
},
"formatted": false,
"svcReqL": [
{
"req": {
"stbLoc": {
"lid": "A=1@O=Leipzig, Bautzner Str.@X=12433960@Y=51355544@U=80@L=11278@B=1@p=1686893883@i=A×de:14713:11278@",
"type": "S",
"name": "Leipzig, Bautzner Str.",
"icoX": 1,
"extId": "11278",
"state": "F",
"crd": {
"x": 12433960,
"y": 51355544,
"floor": 0
},
"pCls": 96,
"wt": 3549,
"globalIdL": [
{
"id": "de:14713:11278",
"type": "A"
}
],
"TZOffset": 120,
"chgTime": "000300"
},
"jnyFltrL": [
{
"type": "PROD",
"mode": "INC",
"value": 1023
}
],
"type": "DEP",
"sort": "PT",
"maxJny": 40
},
"meth": "StationBoard",
"id": "1|3|"
}
]
}
';
//-------------------------------------------------------------------------------------------------------------------
$jstr2='{
"id": "c3mkmhw2ii8igw4s",
"ver": "1.48",
"lang": "deu",
"auth": {
"type": "AID",
"aid": "kAL6ULet"
},
"client": {
"id": "NASA",
"type": "WEB",
"name": "webapp",
"l": "vs_webapp_lvb",
"v": ""
},
"formatted": false,
"svcReqL": [
{
"req": {
"stbLoc": {
"lid": "A=1@O=Leipzig, Braun-/Bautzner Str.@X=12430625@Y=51359329@U=80@L=12427@B=1@p=1686893883@i=A×de:14713:12427@",
"type": "S",
"name": "Leipzig, Braun-/Bautzner Str.",
"icoX": 1,
"extId": "12427",
"state": "F",
"crd": {
"x": 12430625,
"y": 51359329,
"floor": 0
},
"pCls": 64,
"wt": 174,
"globalIdL": [
{
"id": "de:14713:12427",
"type": "A"
}
],
"TZOffset": 120,
"chgTime": "000300"
},
"jnyFltrL": [
{
"type": "PROD",
"mode": "INC",
"value": 1023
}
],
"type": "DEP",
"sort": "PT",
"maxJny": 40
},
"meth": "StationBoard",
"id": "1|13|"
}
]
}
';
//--------------------------
$jarray1 = array(
'http' => array(
'method' => 'POST',
'content' => $jstr1,
'header'=> "Content-Type: application/json\r\n" .
"Accept: application/json\r\n" .
"Cookie: NAME=VaLuE"
)
);
$jarray2 = array(
'http' => array(
'method' => 'POST',
'content' => $jstr2,
'header'=> "Content-Type: application/json\r\n" .
"Accept: application/json\r\n" .
"Cookie: NAME=VaLuE"
)
);
//----------------------------------------------------------------------------------------------------------------
$context = stream_context_create($jarray1); $t=time();
$dataurl='https://reiseauskunft.insa.de/bin/mgate.exe?rnd='.$t; echo $dataurl;
$data=file_get_contents($dataurl, false, $context);
$jsonrow=json_decode($data,0);
for($i=0; $i <10; $i++) { $x=$i+1;
$ziel=$jsonrow->svcResL[0]->res->jnyL[$i]->dirTxt;
$soll=$jsonrow->svcResL[0]->res->jnyL[$i]->stbStop->dTimeS;
$ist =$jsonrow->svcResL[0]->res->jnyL[$i]->stbStop->dTimeR;
$info=$jsonrow->svcResL[0]->res->jnyL[$i]->stbStop->dTimeFR->txtA;
// $zx=substr($soll, 0, -2);
$z1=substr($soll, 0, -4);
$z2=substr($soll, 2, -2);
$zeit=$z1.":".$z2;
$temp=$jsonrow->svcResL[0]->res->jnyL[$i]->jid; $split = explode("#", $temp); $tmp = explode(" ", $split[30]);
$GLOBALS['mysql']->insert("UPDATE LVB SET ziel='".$ziel."',
soll='".$soll."',
ist ='".$ist."',
info='".$info."',
linie='".$tmp[4]."',
zeit='".$zeit."'
WHERE fpid='".$x."' and station=1 ");
}
//----------------------------------------------------------------------------------------------------------------
$context = stream_context_create($jarray2); $t=time();
$dataurl='https://reiseauskunft.insa.de/bin/mgate.exe?rnd='.$t; echo $dataurl;
$data=file_get_contents($dataurl, false, $context);
$jsonrow=json_decode($data,0);
for($i=0; $i <10; $i++) { $x=$i+1;
$ziel=$jsonrow->svcResL[0]->res->jnyL[$i]->dirTxt;
$soll=$jsonrow->svcResL[0]->res->jnyL[$i]->stbStop->dTimeS;
$ist =$jsonrow->svcResL[0]->res->jnyL[$i]->stbStop->dTimeR;
$z1=substr($soll, 0, -4);
$z2=substr($soll, 2, -2);
$zeit=$z1.":".$z2;
$info=$jsonrow->svcResL[0]->res->jnyL[$i]->stbStop->dTimeFR->txtA;
$temp=$jsonrow->svcResL[0]->res->jnyL[$i]->jid; $split = explode("#", $temp); $tmp = explode(" ", $split[30]);
$GLOBALS['mysql']->insert("UPDATE LVB SET ziel='".$ziel."',
soll='".$soll."',
ist ='".$ist."',
info='".$info."',
linie='".$tmp[4]."',
zeit='".$zeit."'
WHERE fpid='".$x."' and station=2 ");
}
// echo "<pre>"; print_r($ergebnis); echo "</pre>";
//-----------------------------------------------------------
//}
?>