Beispiel #1
0
 /**
  * Executes the SQL statements to get the spotter information
  *
  * @param String $query the SQL query
  * @param String $limit the limit query
  * @return Array the spotter information
  *
  */
 public function getDataFromDB($query, $params = array(), $limitQuery = '')
 {
     global $globalSquawkCountry, $globalIVAO;
     $Image = new Image();
     $Schedule = new Schedule();
     $ACARS = new ACARS();
     if (!isset($globalIVAO)) {
         $globalIVAO = FALSE;
     }
     date_default_timezone_set('UTC');
     if (!is_string($query)) {
         return false;
     }
     if ($limitQuery != "") {
         if (!is_string($limitQuery)) {
             return false;
         }
     }
     try {
         $sth = $this->db->prepare($query . $limitQuery);
         $sth->execute($params);
     } catch (PDOException $e) {
         printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query . $limitQuery);
         exit;
     }
     //	$num_rows = count($sth->fetchAll());
     $num_rows = 0;
     $spotter_array = array();
     $temp_array = array();
     while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
         $num_rows++;
         $temp_array = array();
         if (isset($row['spotter_live_id'])) {
             $temp_array['spotter_id'] = $row['spotter_live_id'];
         } elseif (isset($row['spotter_archive_id'])) {
             $temp_array['spotter_id'] = $row['spotter_archive_id'];
         } else {
             $temp_array['spotter_id'] = $row['spotter_id'];
         }
         $temp_array['flightaware_id'] = $row['flightaware_id'];
         if (isset($row['modes'])) {
             $temp_array['modes'] = $row['modes'];
         }
         $temp_array['ident'] = $row['ident'];
         if (isset($row['registration']) && $row['registration'] != '') {
             $temp_array['registration'] = $row['registration'];
         } elseif (isset($temp_array['modes'])) {
             $temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
         } else {
             $temp_array['registration'] = '';
         }
         $temp_array['aircraft_type'] = $row['aircraft_icao'];
         $temp_array['departure_airport'] = $row['departure_airport_icao'];
         $temp_array['arrival_airport'] = $row['arrival_airport_icao'];
         $temp_array['latitude'] = $row['latitude'];
         $temp_array['longitude'] = $row['longitude'];
         /*
         if (Connection->tableExists('countries')) {
         	$country_info = Spotter->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
         	if (is_array($country_info) && isset($country_info['name']) && isset($country_info['iso2'])) {
         	    $temp_array['country'] = $country_info['name'];
         	    $temp_array['country_iso2'] = $country_info['iso2'];
         	}
         }
         */
         $temp_array['waypoints'] = $row['waypoints'];
         if (isset($row['route_stop'])) {
             $temp_array['route_stop'] = $row['route_stop'];
             if ($row['route_stop'] != '') {
                 $allroute = explode(' ', $row['route_stop']);
                 foreach ($allroute as $route) {
                     $route_airport_array = $this->getAllAirportInfo($route);
                     if (isset($route_airport_array[0]['name'])) {
                         $route_stop_details['airport_name'] = $route_airport_array[0]['name'];
                         $route_stop_details['airport_city'] = $route_airport_array[0]['city'];
                         $route_stop_details['airport_country'] = $route_airport_array[0]['country'];
                         $route_stop_details['airport_icao'] = $route_airport_array[0]['icao'];
                         $temp_array['route_stop_details'][] = $route_stop_details;
                     }
                 }
             }
         }
         $temp_array['altitude'] = $row['altitude'];
         $temp_array['heading'] = $row['heading'];
         $heading_direction = $this->parseDirection($row['heading']);
         if (isset($heading_direction[0]['direction_fullname'])) {
             $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
         }
         $temp_array['ground_speed'] = $row['ground_speed'];
         $temp_array['image'] = "";
         $temp_array['image_thumbnail'] = "";
         $temp_array['image_source'] = "";
         $temp_array['image_copyright'] = "";
         if (isset($row['highlight'])) {
             $temp_array['highlight'] = $row['highlight'];
         } else {
             $temp_array['highlight'] = '';
         }
         $dateArray = $this->parseDateString($row['date']);
         if ($dateArray['seconds'] < 10) {
             $temp_array['date'] = "a few seconds ago";
         } elseif ($dateArray['seconds'] >= 5 && $dateArray['seconds'] < 30) {
             $temp_array['date'] = "half a minute ago";
         } elseif ($dateArray['seconds'] >= 30 && $dateArray['seconds'] < 60) {
             $temp_array['date'] = "about a minute ago";
         } elseif ($dateArray['minutes'] < 5) {
             $temp_array['date'] = "a few minutes ago";
         } elseif ($dateArray['minutes'] >= 5 && $dateArray['minutes'] < 60) {
             $temp_array['date'] = "about " . $dateArray['minutes'] . " minutes ago";
         } elseif ($dateArray['hours'] < 2) {
             $temp_array['date'] = "about an hour ago";
         } elseif ($dateArray['hours'] >= 2 && $dateArray['hours'] < 24) {
             $temp_array['date'] = "about " . $dateArray['hours'] . " hours ago";
         } else {
             $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date'] . " UTC"));
         }
         $temp_array['date_minutes_past'] = $dateArray['minutes'];
         $temp_array['date_iso_8601'] = date("c", strtotime($row['date'] . " UTC"));
         $temp_array['date_rfc_2822'] = date("r", strtotime($row['date'] . " UTC"));
         $temp_array['date_unix'] = strtotime($row['date'] . " UTC");
         if (isset($row['aircraft_name']) && $row['aircraft_name'] != '' && isset($row['aircraft_shadow']) && $row['aircraft_shadow'] != '') {
             $temp_array['aircraft_name'] = $row['aircraft_name'];
             $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
             if (isset($row['aircraft_shadow'])) {
                 $temp_array['aircraft_shadow'] = $row['aircraft_shadow'];
             }
         } else {
             $aircraft_array = $this->getAllAircraftInfo($row['aircraft_icao']);
             if (count($aircraft_array) > 0) {
                 $temp_array['aircraft_name'] = $aircraft_array[0]['type'];
                 $temp_array['aircraft_manufacturer'] = $aircraft_array[0]['manufacturer'];
                 if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
                     $temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
                 } else {
                     $temp_array['aircraft_shadow'] = 'default.png';
                 }
             } else {
                 $temp_array['aircraft_shadow'] = 'default.png';
                 $temp_array['aircraft_name'] = 'N/A';
                 $temp_array['aircraft_manufacturer'] = 'N/A';
             }
         }
         if (!isset($row['airline_name']) || $row['airline_name'] == '') {
             $airline_array = array();
             if (!is_numeric(substr($row['ident'], 0, 3))) {
                 if (is_numeric(substr($row['ident'], 2, 1))) {
                     $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2));
                 } elseif (is_numeric(substr($row['ident'], 3, 1))) {
                     $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3));
                 } else {
                     $airline_array = $this->getAllAirlineInfo('NA');
                 }
             } else {
                 $airline_array = $this->getAllAirlineInfo('NA');
             }
             if (count($airline_array) > 0) {
                 $temp_array['airline_icao'] = $airline_array[0]['icao'];
                 $temp_array['airline_iata'] = $airline_array[0]['iata'];
                 $temp_array['airline_name'] = $airline_array[0]['name'];
                 $temp_array['airline_country'] = $airline_array[0]['country'];
                 $temp_array['airline_callsign'] = $airline_array[0]['callsign'];
                 $temp_array['airline_type'] = $airline_array[0]['type'];
             }
         } else {
             $temp_array['airline_icao'] = $row['airline_icao'];
             if (isset($row['airline_iata'])) {
                 $temp_array['airline_iata'] = $row['airline_iata'];
             } else {
                 $temp_array['airline_iata'] = '';
             }
             $temp_array['airline_name'] = $row['airline_name'];
             $temp_array['airline_country'] = $row['airline_country'];
             if (isset($row['airline_callsign'])) {
                 $temp_array['airline_callsign'] = $row['airline_callsign'];
             } else {
                 $temp_array['airline_callsign'] = 'N/A';
             }
             $temp_array['airline_type'] = $row['airline_type'];
         }
         if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
             $acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'] . substr($temp_array['ident'], 3));
             //$acars_array = ACARS->getLiveAcarsData('BA40YL');
             if (count($acars_array) > 0) {
                 $temp_array['acars'] = $acars_array;
                 //print_r($acars_array);
             }
         }
         if ($temp_array['registration'] != "" || $globalIVAO && $temp_array['aircraft_type'] != '') {
             if ($globalIVAO) {
                 if (isset($temp_array['airline_icao'])) {
                     $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type'], $temp_array['airline_icao']);
                 } else {
                     $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type']);
                 }
             } else {
                 $image_array = $Image->getSpotterImage($temp_array['registration']);
             }
             if (count($image_array) > 0) {
                 $temp_array['image'] = $image_array[0]['image'];
                 $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
                 $temp_array['image_source'] = $image_array[0]['image_source'];
                 $temp_array['image_source_website'] = $image_array[0]['image_source_website'];
                 if ($temp_array['image_source_website'] == '' && $temp_array['image_source'] == 'planespotters') {
                     $planespotter_url_array = explode("_", $temp_array['image']);
                     $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
                     $temp_array['image_source_website'] = 'http://www.planespotters.net/Aviation_Photos/photo.show?id=' . $planespotter_id;
                 }
                 $temp_array['image_copyright'] = $image_array[0]['image_copyright'];
             }
         }
         if (!isset($globalIVAO) || !$globalIVAO) {
             $schedule_array = $Schedule->getSchedule($temp_array['ident']);
             //print_r($schedule_array);
             if (count($schedule_array) > 0) {
                 if ($schedule_array['departure_airport_icao'] != '') {
                     $row['departure_airport_icao'] = $schedule_array['departure_airport_icao'];
                     $temp_array['departure_airport'] = $row['departure_airport_icao'];
                 }
                 if ($schedule_array['arrival_airport_icao'] != '') {
                     $row['arrival_airport_icao'] = $schedule_array['arrival_airport_icao'];
                     $temp_array['arrival_airport'] = $row['arrival_airport_icao'];
                 }
                 $temp_array['departure_airport_time'] = $schedule_array['departure_airport_time'];
                 $temp_array['arrival_airport_time'] = $schedule_array['arrival_airport_time'];
             }
         }
         //if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
         if ($row['departure_airport_icao'] != '') {
             $departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
             if (!isset($departure_airport_array[0]['name'])) {
                 $departure_airport_array = $this->getAllAirportInfo('NA');
             }
             /*
             } elseif ($row['departure_airport_name'] != '') {
             	$temp_array['departure_airport_name'] = $row['departure_airport_name'];
             	$temp_array['departure_airport_city'] = $row['departure_airport_city'];
             	$temp_array['departure_airport_country'] = $row['departure_airport_country'];
             	$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
             */
         } else {
             $departure_airport_array = $this->getAllAirportInfo('NA');
         }
         if (isset($departure_airport_array[0]['name'])) {
             $temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
             $temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
             $temp_array['departure_airport_country'] = $departure_airport_array[0]['country'];
             $temp_array['departure_airport_iata'] = $departure_airport_array[0]['iata'];
             $temp_array['departure_airport_icao'] = $departure_airport_array[0]['icao'];
             $temp_array['departure_airport_latitude'] = $departure_airport_array[0]['latitude'];
             $temp_array['departure_airport_longitude'] = $departure_airport_array[0]['longitude'];
             $temp_array['departure_airport_altitude'] = $departure_airport_array[0]['altitude'];
         }
         /*
         if (isset($row['departure_airport_time'])) {
         	$temp_array['departure_airport_time'] = $row['departure_airport_time'];
         }
         */
         if ($row['arrival_airport_icao'] != '') {
             $arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
             if (count($arrival_airport_array) == 0) {
                 $arrival_airport_array = $this->getAllAirportInfo('NA');
             }
         } else {
             $arrival_airport_array = $this->getAllAirportInfo('NA');
         }
         if (isset($arrival_airport_array[0]['name'])) {
             $temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
             $temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
             $temp_array['arrival_airport_country'] = $arrival_airport_array[0]['country'];
             $temp_array['arrival_airport_iata'] = $arrival_airport_array[0]['iata'];
             $temp_array['arrival_airport_icao'] = $arrival_airport_array[0]['icao'];
             $temp_array['arrival_airport_latitude'] = $arrival_airport_array[0]['latitude'];
             $temp_array['arrival_airport_longitude'] = $arrival_airport_array[0]['longitude'];
             $temp_array['arrival_airport_altitude'] = $arrival_airport_array[0]['altitude'];
         }
         /*
         if (isset($row['arrival_airport_time'])) {
         	$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
         }
         */
         if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
             $temp_array['pilot_id'] = $row['pilot_id'];
         }
         if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
             $temp_array['pilot_name'] = $row['pilot_name'];
         }
         if (isset($row['squawk'])) {
             $temp_array['squawk'] = $row['squawk'];
             if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
                 $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['country_iso2']);
                 if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
                     $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
                 }
             } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
                 $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
             }
         }
         $temp_array['query_number_rows'] = $num_rows;
         $spotter_array[] = $temp_array;
     }
     if ($num_rows == 0) {
         return array();
     }
     $spotter_array[0]['query_number_rows'] = $num_rows;
     return $spotter_array;
 }
<?php

require 'require/class.Connection.php';
require 'require/class.ACARS.php';
$ACARS = new ACARS();
$title = "Latest ACARS messages";
require 'header.php';
$page_url = $globalURL . '/acars-archive';
if (!isset($_GET['limit'])) {
    $limit_start = 0;
    $limit_end = 25;
    $absolute_difference = 25;
} else {
    $limit_explode = explode(",", $_GET['limit']);
    $limit_start = $limit_explode[0];
    $limit_end = $limit_explode[1];
}
$absolute_difference = abs($limit_start - $limit_end);
$limit_next = $limit_end + $absolute_difference;
$limit_previous_1 = $limit_start - $absolute_difference;
$limit_previous_2 = $limit_end - $absolute_difference;
print '<div class="info column">';
print '<h1>Archive ACARS messages</h1>';
print '</div>';
print '<div class="table column">';
print '<p>The table below shows the latest ACARS messages.</p>';
$spotter_array = $ACARS->getArchiveAcarsData($limit_start . "," . $absolute_difference);
if (!empty($spotter_array)) {
    include 'table-output.php';
    print '<div class="pagination">';
    if ($limit_previous_1 >= 0) {
#!/usr/bin/php
<?php 
/**
* This daemon is used to receive ACARS messages from acarsdec
*/
// This is not a cron job... Use it like a daemon
require_once dirname(__FILE__) . '/../require/class.ACARS.php';
// Check if schema is at latest version
require_once dirname(__FILE__) . '/../require/class.Connection.php';
$schema = new Connection();
if ($schema->latest() === false) {
    echo "You MUST update to latest schema. Run install/index.php";
    exit;
}
$debug = true;
$ACARS = new ACARS();
date_default_timezone_set('UTC');
// signal handler - playing nice with sockets and dump1090
pcntl_signal(SIGINT, function ($signo) {
    global $sock;
    echo "\n\nctrl-c or kill signal received. Tidying up ... ";
    socket_shutdown($sock, 0);
    socket_close($sock);
    die("Bye!\n");
});
pcntl_signal_dispatch();
// let's try and connect
echo "Listen to acarsdec ... ";
// create our socket and set it to non-blocking
$sock = socket_create(AF_INET, SOCK_DGRAM, 0) or die("Unable to create socket\n");
// Bind the source address
Beispiel #4
0
    $limit_start = 0;
    $limit_end = 25;
    $absolute_difference = 25;
} else {
    $limit_explode = explode(",", $_GET['limit']);
    $limit_start = $limit_explode[0];
    $limit_end = $limit_explode[1];
}
$absolute_difference = abs($limit_start - $limit_end);
$limit_next = $limit_end + $absolute_difference;
$limit_previous_1 = $limit_start - $absolute_difference;
$limit_previous_2 = $limit_end - $absolute_difference;
print '<div class="info column">';
print '<h1>Latest ACARS messages</h1>';
print '</div>';
print '<div class="table column">';
print '<p>The table below shows the latest ACARS messages.</p>';
$spotter_array = ACARS::getLatestAcarsData($limit_start . "," . $absolute_difference);
if (!empty($spotter_array)) {
    include 'table-output.php';
    print '<div class="pagination">';
    if ($limit_previous_1 >= 0) {
        print '<a href="' . $page_url . '/' . $limit_previous_1 . ',' . $limit_previous_2 . '/' . $_GET['sort'] . '">&laquo;Previous Page</a>';
    }
    if ($spotter_array[0]['query_number_rows'] == $absolute_difference) {
        print '<a href="' . $page_url . '/' . $limit_end . ',' . $limit_next . '/' . $_GET['sort'] . '">Next Page&raquo;</a>';
    }
    print '</div>';
}
print '</div>';
require 'footer.php';
Beispiel #5
0
 /**
  * Add ACARS data
  *
  * @param String ACARS data in acarsdec data
  *
  */
 static function add($data)
 {
     global $globalDebug;
     //  (null) 4 09/03/2015 08:11:14 0 -41 2         ! SQ   02XA LYSLFL L104544N00505BV136975/ARINC
     //  (null) 1 09/03/2015 08:10:08 0 -36 R .F-GPMD T _d 8 S65A AF6202
     //    $line = sscapreg_split('/\(null\) \d
     //$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] .%6s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
     $n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\\r\\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
     if ($n == 0) {
         $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\\r\\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
     }
     /*
         
     	$line = explode(' ',$data,13);
     	$registration = substr($line[7],1);
     	$ident = $line[12];
     	$label = $line[9];
     	$block_id = $line[10];
     	$msg_no = $line[11];
     	//$message = implode(' ',array_slice($line,13));
     	$message = $line[13];
     */
     $icao = '';
     $airicao = '';
     $decode = array();
     $found = false;
     if ($globalDebug) {
         echo "Reg. : " . $registration . " - Ident : " . $ident . " - Label : " . $label . " - Message : " . $message . "\n";
     }
     if ($registration != '' && $ident != '' && $registration != '!') {
         /*
         Messages not yet parsed :
         =========================
         
         Reg. : G-EUXE - Ident : BA31CE - Label : H1 - Message : #CFBFLR/FR15022612180028424806FUEL QUANTITY           R ULTRACOMP 52QT/IDFUEL
         Reg. : OO-DWA - Ident : SN01LY - Label : 13 - Message : EBBR,LFLL,26FEB15,1626,164626
         Reg. : OO-SSF - Ident : SN088L - Label : 28 - Message : EBBR,LFSB,LFST,ELLX,
         N 46.668,E  5.692,31735
         
         Reg. : D-ABNL - Ident : AB718H - Label : 3V - Message : HB50,,
         718H,27FEB15,EDDN,LEPA,.D-ABNL,        LEPA,AB7892,
         6600,  3000, 200,,2, 4,
         ,EOF,
         
         Reg. : F-GHQJ - Ident : AF7889 - Label : H1 - Message : #DFBA02/CCF-GHQJ,FEB27,134654,LFRS,LFMN,0889/C106,15201,4000,42,0010,0,0100,42,X/CEN285,36992,252,778,5619,315,B5B7G8/CNN282,36984,252,777,5618,315/EC731134,42384,01436,41191,12/EE731212,44929,11866,43552,12/N1
         Reg. : CN-RNR - Ident : AT816C - Label : 5U - Message :   01 WXRQ   816C/27 GMMN/EDDT .CN-RNR
         /TYP 1/STA EDDT/STA LSZH/STA EDDS
         
         --Reg. : D-ABFN - Ident : AB662E - Label : 4A - Message : EDDL,EDDH,EDDV,,-SA,EOF,
         Reg. : F-GPMF - Ident : AF7828 - Label : H1 - Message : #DFBA01/A31901,1,1/CCF-GPMF,FEB27,175317,LFMN,LFLL,0828/C106,18139,4000,51,0011,0,1100,51,X/CEN097,15830,220,447,4989,254,C63015/EC731855,00832,01809,00757,C3,--/EE731869,00832,07653,00757,C3/N10333,0333,0656,4
         
         Reg. : F-GHQJ - Ident : AF6241 - Label : 80 - Message : /ORYKOAF.VER/071/A320/M
         SCH/AF6241/LFMN/LFPO/27FEB/2010
         FTX
         TPI
         
         Reg. : YU-API - Ident : EY0314 - Label : 2D - Message : TOD01,ASL314,LYBE,LFPG,,1828,LFPG26L
         
         Reg. : F-GLZH - Ident : AF0669 - Label : H1 - Message : #DFBR01/A34001,1,1
         C1,.F-GLZH,15MAR01,02.29.43,HDAM,LFPG,AFR669XXXX,5000,066
         C2,002,06.0,000000,SE1N05,VN1005,AF2055,000,052,052
         C3,N24.3,37957,0.799,111,1.03,1111,1010,0,0101,1111,1.03,-
         C4,N24.3,37956,0.8
         
         Reg. : F-GRHG - Ident : AF6040 - Label : 80 - Message : /RSYGXAF.VER/071/A319/M
         SCH/AF6040/LFPO/LFML/09MAR/1715
         FTX
         DESOLE NOUS NE COMPREN
         ONS PAS LE MESSAGE ...
         */
         if (!$found) {
             // example message : "FST01EGLLLIRFN047599E0033586390  55  25- 4C 74254      487  2059194"
             //FIX : Reg. : G-DOCF - Ident : BA2599 - Label : 15 - Message : FST01LIPXEGKKN478304E006124636000500057M057C060334309304372OA13431246
             //								    FST01MMMXEGKKN376904W079449733007380380 019061 XA1237 =>  wind direction and velocity (019/061)
             //$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%*11[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $temp);
             $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
             if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
                 $latitude = $la / 10000.0;
                 $longitude = $ln / 10000.0;
                 if ($lac == 'S') {
                     $latitude = '-' . $latitude;
                 }
                 if ($lnc == 'W') {
                     $longitude = '-' . $longitude;
                 }
                 // Temp not always available
                 if ($globalDebug) {
                     echo 'latitude : ' . $latitude . ' - longitude : ' . $longitude . ' - airport depart : ' . $dair . ' - airport arrival : ' . $darr . ' - température : ' . $temp . "°C\n";
                 }
                 if ($temp == '') {
                     $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
                 } else {
                     $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL' . $alt, 'Temperature' => $temp . '°C');
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $found = true;
             }
         }
         if (!$found && $label == '10') {
             $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
             if ($n == 4 && strlen($darr) == 4) {
                 if ($dhour != '') {
                     $dhour = substr(sprintf('%04d', $dhour), 0, 2) . ':' . substr(sprintf('%04d', $dhour), 2);
                 }
                 if ($ahour != '') {
                     $ahour = substr(sprintf('%04d', $ahour), 0, 2) . ':' . substr(sprintf('%04d', $ahour), 2);
                 }
                 if ($globalDebug) {
                     echo 'departure airport : ' . $dair . ' - arrival airport : ' . $darr . ' - departure hour : ' . $dhour . ' - arrival hour : ' . $ahour . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 Schedule::addSchedule($icao, $dair, $dhour, $darr, $ahour, 'ACARS');
                 $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
                 $found = true;
             } elseif ($n == 2 || $n == 4) {
                 if ($dhour != '') {
                     $dhour = substr(sprintf('%04d', $dhour), 0, 2) . ':' . substr(sprintf('%04d', $dhour), 2);
                 }
                 if ($globalDebug) {
                     echo 'airport arrival : ' . $dair . ' - arrival hour : ' . $dhour . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
                 $found = true;
             } elseif ($n == 1) {
                 if ($globalDebug) {
                     echo 'airport arrival : ' . $darr . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 $decode = array('Arrival airport' => $darr);
                 $found = true;
             }
         }
         if (!$found && ($label == '13' || $label == '12')) {
             // example message : "Reg. : OO-DWA - Ident : SN01LY - Label : 13 - Message : EBBR,LFLL,26FEB15,1626,164626"
             /*
             Reg. : OO-SSP - Ident : SN01LY - Label : 13 - Message : EBBR,LFLL,27FEB15,1624,164400
             N 46.493,E  3.980,19810
             */
             $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
             if ($n == 4) {
                 if ($globalDebug) {
                     echo 'airport depart : ' . $dair . ' - airport arrival : ' . $darr . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
                 $found = true;
             }
         }
         if (!$found) {
             /*
             		example message : 
             		    VER/071/A320/M
             		    SCH/AF6244/LFPO/LFMN/25FEB/0905
             		    FTX/ADDRESS/DEST STA/LFMN
             */
             /*
             		example message :
             		    VER/070/A319/M
             		    SCH/AF7671/LFML/LFPG/23FEB/1820
             		    WXR/META/LFLL/LFLC/LFPG
             */
             //$n = sscanf($message, "%*[0-9A-Z]/%*3d/%4s/%*c\nSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d\n%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
             $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste);
             if ($n > 8) {
                 if ($globalDebug) {
                     echo 'airicao : ' . $airicao . ' - ident : ' . $aident . ' - departure airport : ' . $dair . ' - arrival airport : ' . $darr . ' - date depart : ' . $ddate . ' - departure hour : ' . $dhour . ' - arrival hour : ' . $ahour . ' - arrival airport : ' . $aair . ' - arrival piste : ' . $apiste . "\n";
                 }
                 if ($dhour != '') {
                     $dhour = substr(sprintf('%04d', $dhour), 0, 2) . ':' . substr(sprintf('%04d', $dhour), 2);
                 }
                 if ($ahour != '') {
                     $ahour = substr(sprintf('%04d', $ahour), 0, 2) . ':' . substr(sprintf('%04d', $ahour), 2);
                 }
                 $icao = trim($aident);
                 //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
                 if ($ahour == '') {
                     $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
                 } else {
                     $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
                 }
                 Schedule::addSchedule($icao, $dair, $dhour, $darr, $ahour, 'ACARS');
                 $found = true;
             }
         }
         if (!$found) {
             // example message : "221111,34985,0817,  65,N 50.056 E 13.850"
             //Reg. : CS-TFY - Ident : CR0321 - Label : 16 - Message : 140600,34008,1440,  66,N 46.768 E  4.793
             $n = sscanf($message, "%*6c,%*5c,%*4c,%*4c,%c%3d.%3d %c%3d.%3d,", $lac, $las, $lass, $lnc, $lns, $lnss);
             if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
                 $las = $las . '.' . $lass;
                 $lns = $lns . '.' . $lns;
                 $latitude = $las / 1000.0;
                 $longitude = $lns / 1000.0;
                 if ($lac == 'S') {
                     $latitude = '-' . $latitude;
                 }
                 if ($lnc == 'W') {
                     $longitude = '-' . $longitude;
                 }
                 if ($globalDebug) {
                     echo 'latitude : ' . $latitude . ' - longitude : ' . $longitude . "\n";
                 }
                 $decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
                 $found = true;
             }
         }
         if (!$found && $label == '5U') {
             /*
                 		example message :
             	    	    Reg. : CN-RNR - Ident : AT816C - Label : 5U - Message :   01 WXRQ   816C/27 GMMN/EDDT .CN-RNR
             		    /TYP 1/STA EDDT/STA LSZH/STA EDDS
             		    Reg. : G-OOBD - Ident : DP079T - Label : 5U - Message :   01 WXRQ   079T/28 LIPX/EGKK .G-OOBD
             		    /TYP 1/STA EGKK/STA EGLL/STA EGHH
             */
             $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
             if ($n == 4) {
                 if ($globalDebug) {
                     echo 'airport depart : ' . $dair . ' - airport arrival : ' . $darr . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
                 $found = true;
             }
         }
         if (!$found && $label == '1L') {
             // example message : "Reg. : TS-ION - Ident : TU0634 - Label : 1L - Message : 000442152001337,DTTJ,LFPO,1609"
             $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
             if ($n == 4) {
                 if ($globalDebug) {
                     echo 'airport depart : ' . $dair . ' - airport arrival : ' . $darr . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
                 $found = true;
             }
         }
         if (!$found && $label == '5U') {
             // example message : "Reg. : OO-TAH - Ident : 3V042J - Label : 5U - Message : 002AF   EBLG EBBR                     N4621.5E  524.2195"
             $n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
             if ($n == 2) {
                 if ($globalDebug) {
                     echo 'airport depart : ' . $dair . ' - airport arrival : ' . $darr . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $found = true;
             }
         }
         if (!$found && $label == 'H1') {
             // example message : 'Reg. : F-GHQJ - Ident : AF6241 - Label : H1 - Message : #DFBA01/CCF-GHQJ,FEB27,205556,LFMN,LFPO,0241/C106,17404,5000,42,0010,0,0100,42,X/CEN270,36012,257,778,6106,299,B5B7G8/EC731134,42387,01439,41194,12/EE731212,44932,11870,43555,12/N10875,0875,0910,6330,1205,-----'
             $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
             if ($n == 6) {
                 if ($globalDebug) {
                     echo 'airport depart : ' . $dair . ' - airport arrival : ' . $darr . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
                 $found = true;
             }
         }
         if (!$found && $label == 'H1') {
             // example message : 'Reg. : F-GUGP - Ident : AF1842 - Label : H1 - Message : #DFBA01/A31801,1,1/CCF-GUGP,MAR11,093856,LFPG,LSGG,1842/C106,55832,5000,37,0010,0,0100,37,X/CEN282,31018,277,750,5515,255,C11036/EC577870,02282,07070,01987,73,14/EE577871,02282,06947,01987,73/N10790,0790,0903,5'
             $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
             if ($n == 7) {
                 if ($globalDebug) {
                     echo 'airport depart : ' . $dair . ' - airport arrival : ' . $darr . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
                 $found = true;
             }
         }
         if (!$found) {
             /* example message :
             	     Reg. : PH-BXO - Ident : KL079K - Label : H1 - Message : #DFB(POS-KLM79K  -4319N00252E/143435 F390
             RMK/FUEL   2.6 M0.79)
             	    */
             //$n = sscanf($message, "#DFB(POS-%s -%4d%c%5d%c/%*d F%d\nRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
             $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
             if ($n == 9) {
                 //if (self::$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
                 $icao = trim($aident);
                 $latitude = $las / 100.0;
                 $longitude = $lns / 100.0;
                 if ($lac == 'S') {
                     $latitude = '-' . $latitude;
                 }
                 if ($lnc == 'W') {
                     $longitude = '-' . $longitude;
                 }
                 $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL' . $alt, 'Fuel' => $fuel, 'speed' => $speed);
                 $found = true;
             }
         }
         if (!$found) {
             /* example message :
                Reg. : F-HBSA - Ident : XK505F - Label : 16 - Message : LAT N 46.184/LON E  5.019
                */
             $n = sscanf($message, "LAT %c %f/LON %c %f", $lac, $las, $lnc, $lns);
             if ($n == 4) {
                 $latitude = $las;
                 $longitude = $lns;
                 if ($lac == 'S') {
                     $latitude = '-' . $latitude;
                 }
                 if ($lnc == 'W') {
                     $longitude = '-' . $longitude;
                 }
                 $decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
                 $found = true;
             }
         }
         if (!$found && $label == '80') {
             /* example message : 
             		Reg. : EI-DSB - Ident : AZ0207 - Label : 80 - Message : 3X01 NLINFO 0207/28 EGLL/LIRF .EI-DSB
             		/AZ/1783/28/FCO/N
             	    */
             $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
             if ($n == 5) {
                 if ($globalDebug) {
                     echo 'airport depart : ' . $dair . ' - airport arrival : ' . $darr . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
                 $found = true;
             }
         }
         if (!$found) {
             /* example message : 
             		Reg. : D-ABNK - Ident : AB930V - Label : 3O - Message : HB50,,
             		930V,12MAR15,EDDH,LEPA,.D-ABNK,
             		LEPA,
             		AB7757,
             		DABNK,10100,  7100,02:46, 200, 44068,52.4, 77000, 62500, 66000,3, 4,
             	    */
             //    	    $n = sscanf($message, "%*[0-9A-Z],,\n%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,\n%*4[A-Z],\n%[0-9A-Z],", $dair, $darr, $aident);
             $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
             if ($n == 8) {
                 if ($globalDebug) {
                     echo 'airport depart : ' . $dair . ' - airport arrival : ' . $darr . "\n";
                 }
                 $icao = trim($aident);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
                 $found = true;
             }
         }
         if (!$found) {
             /* example message : 
             		Reg. : N702DN - Ident : DL0008 - Label : 80 - Message : 3401/11 KATL/OMDB .N702DN
             		ACK RDA
             	    */
             $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
             if ($n == 5) {
                 if ($globalDebug) {
                     echo 'airport depart : ' . $dair . ' - airport arrival : ' . $darr . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
                 $found = true;
             }
         }
         if (!$found) {
             /* example message : 
             		LFLLLFRS1315U2687X
             	    */
             $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
             if ($n == 3) {
                 if ($globalDebug) {
                     echo 'airport depart : ' . $dair . ' - airport arrival : ' . $darr . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
                 $found = true;
             }
         }
         if (!$found) {
             /* example message : 
             		3J01 DSPTCH 7503/01 LFTH/LFPO .F-HMLF
             	    */
             $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
             if ($n == 3) {
                 if ($globalDebug) {
                     echo 'airport depart : ' . $dair . ' - airport arrival : ' . $darr . "\n";
                 }
                 //$icao = ACARS::ident2icao($ident);
                 $icao = Translation::checkTranslation($ident);
                 Schedule::addSchedule($icao, $dair, '', $darr, '', 'ACARS');
                 $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
                 $found = true;
             }
         }
         if (!$found) {
             $n = sscanf($message, 'MET01%4c', $airport);
             if ($n == 1) {
                 if ($globalDebug) {
                     echo 'airport name : ' . $airport;
                 }
                 $decode = array('Airport/Waypoint name' => $airport);
                 $found = true;
             }
         }
         if ($label == 'H1') {
             if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
                 $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
             } elseif (preg_match('/^#DFB\\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
                 $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
             } elseif (preg_match('/^#DFB\\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
                 $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
             } elseif (preg_match('/^#DFB\\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
                 $decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
             } elseif (preg_match(':^#DFB/PIREP:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
             } elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
                 $decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
             } elseif (preg_match(':^#M1AAEP:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
             } elseif (preg_match(':^#M2APWD:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
             } elseif (preg_match(':^#M1BREQPWI:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
             } elseif (preg_match(':^#CF:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
             } elseif (preg_match(':^#DF:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
             } elseif (preg_match(':^#EC:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
             } elseif (preg_match(':^#EI:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
             } elseif (preg_match(':^#H1:', $message)) {
                 $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
             } elseif (preg_match(':^#H2:', $message)) {
                 $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
             } elseif (preg_match(':^#HD:', $message)) {
                 $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
             } elseif (preg_match(':^#M1:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
             } elseif (preg_match(':^#M2:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
             } elseif (preg_match(':^#M3:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
             } elseif (preg_match(':^#MD:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
             } elseif (preg_match(':^#PS:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
             } elseif (preg_match(':^#S1:', $message)) {
                 $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
             } elseif (preg_match(':^#S2:', $message)) {
                 $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
             } elseif (preg_match(':^#SD:', $message)) {
                 $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
             } elseif (preg_match(':^#T[0-8]:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
             } elseif (preg_match(':^#WO:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
             } elseif (preg_match(':^#A1:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
             } elseif (preg_match(':^#A3:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
             } elseif (preg_match(':^#A4:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
             } elseif (preg_match(':^#A6:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
             } elseif (preg_match(':^#A8:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
             } elseif (preg_match(':^#A9:', $message)) {
                 $decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
             } elseif (preg_match(':^#A0:', $message)) {
                 $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
             } elseif (preg_match(':^#AA:', $message)) {
                 $decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
             } elseif (preg_match(':^#AB:', $message)) {
                 $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
             } elseif (preg_match(':^#AC:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
             } elseif (preg_match(':^#AD:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
             } elseif (preg_match(':^#AF:', $message)) {
                 $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
             } elseif (preg_match(':^#B1:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
             } elseif (preg_match(':^#B2:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
             } elseif (preg_match(':^#B3:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
             } elseif (preg_match(':^#B4:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
             } elseif (preg_match(':^#B6:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
             } elseif (preg_match(':^#B8:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
             } elseif (preg_match(':^#B9:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
             } elseif (preg_match(':^#B0:', $message)) {
                 $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
             } elseif (preg_match(':^#BA:', $message)) {
                 $decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
             } elseif (preg_match(':^#BB:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
             } elseif (preg_match(':^#BC:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
             } elseif (preg_match(':^#BD:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
             } elseif (preg_match(':^#BE:', $message)) {
                 $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
             } elseif (preg_match(':^#BF:', $message)) {
                 $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
             } elseif (preg_match(':^#H3:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
             }
         }
         if ($label == '10') {
             if (preg_match(':^DTO01:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
             } elseif (preg_match(':^AIS01:', $message)) {
                 $decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
             } elseif (preg_match(':^FTX01:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
             } elseif (preg_match(':^FPL01:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
             } elseif (preg_match(':^WAB01:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
             } elseif (preg_match(':^MET01:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
             } elseif (preg_match(':^WAB02:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
             }
         }
         if ($label == '15') {
             if (preg_match(':^FST01:', $message)) {
                 $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
             }
         }
         if (!$found && $label == 'SA') {
             $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
             if ($n == 4) {
                 $vsta = array('Version' => $version);
                 if ($state == 'E') {
                     $vsta = array_merge($vsta, array('Link state' => 'Established'));
                 } elseif ($state == 'L') {
                     $vsta = array_merge($vsta, array('Link state' => 'Lost'));
                 } else {
                     $vsta = array_merge($vsta, array('Link state' => 'Unknown'));
                 }
                 if ($type == 'V') {
                     $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
                 } elseif ($type == 'S') {
                     $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
                 } elseif ($type == 'H') {
                     $vsta = array_merge($vsta, array('Link type' => 'HF'));
                 } elseif ($type == 'G') {
                     $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
                 } elseif ($type == 'C') {
                     $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
                 } elseif ($type == '2') {
                     $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
                 } elseif ($type == 'X') {
                     $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
                 } elseif ($type == 'I') {
                     $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
                 } else {
                     $vsta = array_merge($vsta, array('Link type' => 'Unknown'));
                 }
                 $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
                 $decode = array_merge($vsta, $decode);
             }
         }
         $title = ACARS::getTitlefromLabel($label);
         if ($title != '') {
             $decode = array_merge(array('Message title' => $title), $decode);
         }
         // Business jets always use GS0001
         if ($ident != 'GS0001') {
             $info = ACARS::addModeSData($ident, $registration, $icao, $airicao);
         }
         if ($globalDebug && isset($info) && $info != '') {
             echo $info;
         }
         $image_array = Image::getSpotterImage($registration);
         if (!isset($image_array[0]['registration'])) {
             Image::addSpotterImage($registration);
         }
     }
     if (count($decode) > 0) {
         $decode_json = json_encode($decode);
     } else {
         $decode_json = '';
     }
     $result = ACARS::addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode_json);
     //if ((is_numeric($label) && (($label > 9 && $label < 50) || ($label > 79 && $label < 90))) || $label == '3F') ACARS::addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode_json);
     if ($result && ($label == '10' || $label == '80' || $label == '81' || $label == '82' || $label == '3F')) {
         ACARS::addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode_json);
     }
     if ($globalDebug && count($decode) > 0) {
         echo "Human readable data : " . implode(' - ', $decode) . "\n";
     }
 }