1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
<?php
include('php/configuration.php');
include('php/mysql-ouverture.php');
include('php/fonctions.php');
set_time_limit(0);
if( !($socket = socket_create(AF_INET, SOCK_STREAM, 0)) )
{
die("Impossible de créer le socket : [".socket_last_error()."] ".socket_strerror(socket_last_error())."\n");
}
echo "Socket créé\n";
if( !socket_connect($socket, ADSB_SERVER, ADSB_PORT) )
{
die("Impossible de se connecter : [".socket_last_error()."] ".socket_strerror(socket_last_error())."\n");
}
echo "Connection établie\n";
do
{
$line = socket_read($socket, 1024);
if( preg_match('~(AIR|CLK|ID|MSG|SEL|STA),(\d),(\d+),(\d+),([0-9A-F]{6}),(\d+),(\d{4}\/\d{2}\/\d{2}),(\d{2}:\d{2}:\d{2}.\d+),(\d{4}\/\d{2}\/\d{2}),(\d{2}:\d{2}:\d{2}.\d+),([0-9A-Z ]{8})?,(-?\d+)?,(\d+)?,(\d+)?,(\d+.\d+)?,(\d+.\d+)?,(-?\d+)?,(\d+)?,(-?[0-1])?,(-?[0-1])?,(-?[0-1])?,(-?[0-1])?~', $line, $matches) )
{
// Ici du code d'analyse, etc.
}
else
{
echo $line;
}
}
while(true);
socket_close($socket);
include('php/mysql-fermeture.php');
?> |
Partager