234 lines
No EOL
10 KiB
PHP
234 lines
No EOL
10 KiB
PHP
<?php
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors',1);
|
|
require('lib/config.php');
|
|
require('lib/mysql.class.php');
|
|
//----------------------------------------------------------------------------------------------------------
|
|
date_default_timezone_set('Europe/Berlin');
|
|
$jahr = (int)date('Y'); $monat = (int)date('n'); $tag = (int)date('j');
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
$GLOBALS['mysql'] = new mysql(CONFIG_MYSQL_HOST,CONFIG_MYSQL_USER,CONFIG_MYSQL_PW,CONFIG_MYSQL_DB);
|
|
// mysqli_set_charset($GLOBALS['mysql'], 'utf8'); header("Content-Type: text/html; charset=utf-8");
|
|
//$GLOBALS['mysql']->mysql_query("SET NAMES 'utf8'");
|
|
//$GLOBALS['mysql']->mysql_query("SET CHARACTER SET 'utf8'");
|
|
|
|
$ipc=$GLOBALS['mysql']->sql("SELECT * FROM ipcheck"); $key=0;
|
|
while($row = $ipc->fetch_assoc()) {
|
|
$ip = gethostbyname($row['dns']);
|
|
echo $row['name'].' - '.$ip.'</br>';
|
|
$GLOBALS['mysql']->sql("UPDATE ipcheck SET ip4='".$ip."' WHERE id='".$row['id']."' ");
|
|
$GLOBALS['mysql']->sql("UPDATE ipcheck SET time='".time()."' WHERE id='".$row['id']."' ");
|
|
}
|
|
echo"fertig_ip_check";
|
|
//----------------------------------------------------------------------------------------------------------
|
|
// Verkehrsmeldungen
|
|
//----------------------------------------------------------------------------------------------------------
|
|
$GLOBALS['mysql']->insert("UPDATE verkehr SET status=7 WHERE status=2");
|
|
$GLOBALS['mysql']->insert("UPDATE verkehr SET status=6 WHERE status=1");
|
|
https://cdn3.atudo.net/api/4.0/pois.php?type=ts,0,1,2,3,4,5,6,21,23,24,25,29,traffic&z=11&box=51.239135999999995,11.664047,51.549751,12.946014
|
|
$page='https://cdn3.atudo.net/api/4.0/pois.php?type=0,1,2,3,4,5,6,21,23,24,25,29&z=50&box=51.281031,12.048568999999999,51.436460999999994,12.689551999999999';
|
|
//$page='https://cdn3.atudo.net/api/4.0/pois.php?type=0,1,2,3,4,5,6,20,21,23,24,25,ts&box=51.276736290728685,12.058525085449217,51.383995224782886,12.111868286132812';
|
|
//$page='https://cdn2.atudo.net/api/1.0/vl.php?type=0,1,2,3,4,5,6,20,21,23,24,25&box=51.276736290728685,12.058525085449217,51.383995224782886,12.711868286132812';
|
|
$html = file_get_contents($page);
|
|
$jsonrow=json_decode($html);
|
|
//echo "<pre>"; print_r($jsonrow); echo "</pre>";
|
|
|
|
for($i=0; $i < 100; $i++) {
|
|
if(isset($jsonrow->pois[$i])) {
|
|
$lat=($jsonrow->pois[$i]->lat); //MeldungsID
|
|
//$test=str_replace('.',',', $lat);
|
|
$vdata = $GLOBALS['mysql']->query_single("SELECT * FROM verkehr WHERE lat='".$lat."'");
|
|
|
|
if($vdata['num_rows']!= 0) {
|
|
$confirm=($jsonrow->pois[$i]->confirm_date); //bestätigungszeit
|
|
if($vdata['status']== 6) { $GLOBALS['mysql']->insert("UPDATE verkehr SET status=1 WHERE id='".$vdata['id']."'"); }
|
|
if($vdata['status']== 7) { $GLOBALS['mysql']->insert("UPDATE verkehr SET status=2 WHERE id='".$vdata['id']."'"); }
|
|
} else {
|
|
$bid=($jsonrow->pois[$i]->id);
|
|
$lat=($jsonrow->pois[$i]->lat);
|
|
$lng=($jsonrow->pois[$i]->lng);
|
|
$type=($jsonrow->pois[$i]->type);
|
|
|
|
if(isset($jsonrow->pois[$i]->info->partly_fixed)) {
|
|
if($jsonrow->pois[$i]->info->partly_fixed==1) {
|
|
$type=9;
|
|
}}
|
|
|
|
|
|
$ort=utf8_decode($jsonrow->pois[$i]->address->city);
|
|
$strasse=utf8_decode($jsonrow->pois[$i]->address->street);
|
|
$street=utf8_decode($jsonrow->pois[$i]->address->street);
|
|
|
|
//$street=utf8_decode(($jsonrow->pois[$i]->street));
|
|
$vmax=($jsonrow->pois[$i]->vmax);
|
|
// $create=($jsonrow->pois[$i]->create_date);
|
|
// $confirm=($jsonrow->pois[$i]->confirm_date); //bestätigungszeit
|
|
$counter=($jsonrow->pois[$i]->counter); //counter
|
|
$status=1;
|
|
|
|
if($bid!=0) {
|
|
$GLOBALS['mysql']->insert("INSERT INTO verkehr (bid,lat,lng,adresse1,adresse2,street,type,vmax,counter,status)
|
|
VALUES(
|
|
'".$bid."',
|
|
'".$lat."',
|
|
'".$lng."',
|
|
'".$ort."',
|
|
'".$strasse."',
|
|
'".$street."',
|
|
'".$type."',
|
|
'".$vmax."',
|
|
'".$counter."',
|
|
'".$status."')
|
|
");
|
|
}
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------- Anhänger
|
|
$page=""; $jsonrow="";
|
|
$page='https://cdn3.atudo.net/api/4.0/pois.php?type=ts,traffic&z=50&box=50.991285999999995,11.425780999999999,51.613752999999996,14.039154';
|
|
$html = file_get_contents($page);
|
|
$jsonrow=json_decode($html);
|
|
for($i=0; $i < 10; $i++) {
|
|
if(isset($jsonrow->pois[$i])) {
|
|
$lat=($jsonrow->pois[$i]->lat); //MeldungsID
|
|
//$test=str_replace('.',',', $lat);
|
|
$vdata = $GLOBALS['mysql']->query_single("SELECT * FROM verkehr WHERE lat='".$lat."'");
|
|
|
|
if($vdata['num_rows']!= 0) {
|
|
$confirm=($jsonrow->pois[$i]->confirm_date); //bestätigungszeit
|
|
if($vdata['status']== 6) { $GLOBALS['mysql']->insert("UPDATE verkehr SET status=1 WHERE id='".$vdata['id']."'"); }
|
|
if($vdata['status']== 7) { $GLOBALS['mysql']->insert("UPDATE verkehr SET status=2 WHERE id='".$vdata['id']."'"); }
|
|
} else {
|
|
$bid=($jsonrow->pois[$i]->id);
|
|
$lat=($jsonrow->pois[$i]->lat);
|
|
$lng=($jsonrow->pois[$i]->lng);
|
|
$type=($jsonrow->pois[$i]->type);
|
|
|
|
if(isset($jsonrow->pois[$i]->info->partly_fixed)) {
|
|
if($jsonrow->pois[$i]->info->partly_fixed==1) {
|
|
$type=9;
|
|
}}
|
|
|
|
|
|
$ort=utf8_decode($jsonrow->pois[$i]->address->city);
|
|
$strasse=utf8_decode($jsonrow->pois[$i]->address->street);
|
|
$street=utf8_decode($jsonrow->pois[$i]->address->street);
|
|
|
|
//$street=utf8_decode(($jsonrow->pois[$i]->street));
|
|
$vmax=($jsonrow->pois[$i]->vmax);
|
|
// $create=($jsonrow->pois[$i]->create_date);
|
|
// $confirm=($jsonrow->pois[$i]->confirm_date); //bestätigungszeit
|
|
$counter=($jsonrow->pois[$i]->counter); //counter
|
|
$status=1;
|
|
|
|
if($bid!=0) {
|
|
$GLOBALS['mysql']->insert("INSERT INTO verkehr (bid,lat,lng,adresse1,adresse2,street,type,vmax,counter,status)
|
|
VALUES(
|
|
'".$bid."',
|
|
'".$lat."',
|
|
'".$lng."',
|
|
'".$ort."',
|
|
'".$strasse."',
|
|
'".$street."',
|
|
'".$type."',
|
|
'".$vmax."',
|
|
'".$counter."',
|
|
'".$status."')
|
|
");
|
|
}
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
|
|
//echo "<pre>"; print_r($jsonrow); echo "</pre>";
|
|
//----------------------------------------------------------------------------------------------------------
|
|
$GLOBALS['mysql']->query("DELETE FROM verkehr WHERE status=8");
|
|
$GLOBALS['mysql']->query("DELETE FROM verkehr WHERE status=9");
|
|
//----------------------------------------------------------------------------------------------------------
|
|
$GLOBALS['mysql']->insert("UPDATE verkehr SET status=9 WHERE status=7 ");
|
|
$GLOBALS['mysql']->insert("UPDATE verkehr SET status=8 WHERE status=6 ");
|
|
//----------------------------------------------------------------------------------------------------------
|
|
//----------------------------------------------------------------------------------------------------------
|
|
//----------------------------------------------------------------------------------------------------------
|
|
$json = file_get_contents('https://creativecommons.tankerkoenig.de/json/list.php?lat=51.340&lng=12.375&rad=25&sort=dist&type=all&apikey=29e0b621-5ac4-52c0-1e12-723fbcf6fba0');
|
|
$tdata = json_decode($json);
|
|
$GLOBALS['mysql']->query("SET NAMES utf8");
|
|
foreach ($tdata->stations as $data ) {
|
|
$test = $GLOBALS['mysql']->query_single("SELECT * FROM tanken WHERE Tankid='".$data->id."'");
|
|
if($test['num_rows'] != 0) {
|
|
if ($data->isOpen==1) {
|
|
$GLOBALS['mysql']->insert("UPDATE tanken SET open=1 WHERE Tankid='".$data->id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tanken SET diesel='".$data->diesel."' WHERE Tankid='".$data->id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tanken SET e5='".$data->e5."' WHERE Tankid='".$data->id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tanken SET e10='".$data->e10."' WHERE Tankid='".$data->id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tanken SET name='".$data->name."' WHERE Tankid='".$data->id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tanken SET kname='".$data->brand."' WHERE Tankid='".$data->id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tanken SET street='".$data->street."' WHERE Tankid='".$data->id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tanken SET hnr='".$data->houseNumber."' WHERE Tankid='".$data->id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tanken SET plz='".$data->postCode."' WHERE Tankid='".$data->id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tanken SET ort='".$data->place."' WHERE Tankid='".$data->id."'");
|
|
}else{
|
|
$GLOBALS['mysql']->insert("UPDATE tanken SET open=0 WHERE Tankid='".$data->id."'");
|
|
}
|
|
}else{
|
|
if ($data->isOpen==1) { $open=1; }else{ $open=0; }
|
|
$GLOBALS['mysql']->insert("INSERT INTO tanken (Tankid,open,name,kname,street,hnr,plz,ort,e5,e10,diesel)
|
|
VALUES(
|
|
'".$data->id."',
|
|
'".$open."',
|
|
'".$data->name."',
|
|
'".$data->brand."',
|
|
'".$data->street."',
|
|
'".$data->houseNumber."',
|
|
'".$data->postCode."',
|
|
'".$data->place."',
|
|
'".$data->e5."',
|
|
'".$data->e10."',
|
|
'".$data->diesel."')
|
|
");
|
|
}
|
|
}
|
|
echo'<pre>'; print_r($tdata); echo'</pre>';
|
|
//----------------------------------------------------------------------------------------------------------
|
|
$data = json_decode(file_get_contents('http://api.openweathermap.org/data/2.5/weather?q=Leipzig,DE&units=metric&lang=de&APPID=e1fbd5096c088db7a388f3a582c99b02'));
|
|
$sunsetx=date("H:i",$data->sys->sunset);
|
|
$sunrisex=date("H:i",$data->sys->sunrise);
|
|
|
|
$iid=$data->weather[0]->icon;
|
|
$icon="http://openweathermap.org/img/w/".$iid."@2x.png";
|
|
$w_id=$data->weather[0]->id;
|
|
$cist=round($data->main->temp);
|
|
$cmin=round($data->main->temp_min);
|
|
$cmax=round($data->main->temp_max);
|
|
$text=$data->weather[0]->description;
|
|
$sunset = $data->sys->sunset;
|
|
$sunrise= $data->sys->sunrise;
|
|
if ($sunrise>time()) { $night=1; }
|
|
if ($sunrise<time() && $sunset>time()) { $night=0; }
|
|
if ($sunrise<time() && $sunset<time()) { $night=1; }
|
|
$GLOBALS['mysql']->insert("UPDATE system SET sunrise='".$sunrisex."', sunset='".$sunsetx."', night='".$night."', w_id='".$w_id."',cist='".$cist."', cmin='".$cmin."', cmax='".$cmax."', text='".$text."', icon='".$icon."' WHERE id=1");
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|