Exemplo n.º 1
0
 /**
  * Change IATA to ICAO value for ident
  * 
  * @param String $ident ident
  * @return String the icao
  */
 public function ident2icao($ident)
 {
     $Spotter = new Spotter();
     if (!is_numeric(substr($ident, 0, 3))) {
         if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
             $airline_icao = substr($ident, 0, 2);
         } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
             //$airline_icao = substr($ident, 0, 3);
             return $ident;
         } else {
             return $ident;
         }
     } else {
         return $ident;
     }
     if ($airline_icao == 'AF') {
         if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags" => FILTER_FLAG_ALLOW_OCTAL))) {
             $icao = $ident;
         } else {
             $icao = 'AFR' . ltrim(substr($ident, 2), '0');
         }
     } else {
         $identicao = $Spotter->getAllAirlineInfo($airline_icao);
         if (isset($identicao[0])) {
             $icao = $identicao[0]['icao'] . ltrim(substr($ident, 2), '0');
         } else {
             $icao = $ident;
         }
     }
     return $icao;
 }
Exemplo n.º 2
0
 /**
  * Gets last spotter information based on a particular callsign
  *
  * @return Array the spotter information
  *
  */
 public static function getLastLiveSpotterDataById($id)
 {
     date_default_timezone_set('UTC');
     $id = filter_var($id, FILTER_SANITIZE_STRING);
     $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
     $spotter_array = Spotter::getDataFromDB($query, array(':id' => $id));
     return $spotter_array;
 }
        print '<div><span class="label">Coordinates</span><a href="http://maps.google.ca/maps?z=10&t=k&q=' . $airport_array[0]['latitude'] . ',' . $airport_array[0]['longitude'] . '" target="_blank">Google Map<i class="fa fa-angle-double-right"></i></a></div>';
        print '</div>';
    } else {
        print '<div class="alert alert-warning">This special airport profile shows all flights that do <u>not</u> have a departure and/or arrival airport associated with them.</div>';
    }
    include 'airport-sub-menu.php';
    print '<div class="column">';
    print '<h2>Most Common Arrival Airports</h2>';
    ?>
  	<p>The statistic below shows all arrival airports of flights from <strong><?php 
    print $airport_array[0]['city'] . ', ' . $airport_array[0]['name'] . ' (' . $airport_array[0]['icao'] . ')';
    ?>
</strong>.</p>
    	
  	<?php 
    $airport_airport_array = Spotter::countAllArrivalAirportsByAirport($_GET['airport']);
    ?>
    	<script>
    	google.load("visualization", "1", {packages:["geochart"]});
    	google.setOnLoadCallback(drawCharts);
    	$(window).resize(function(){
    		drawCharts();
    	});
    	function drawCharts() {
    
        var data = google.visualization.arrayToDataTable([ 
        	["Airport", "# of Times"],
        	<?php 
    foreach ($airport_airport_array as $airport_item) {
        $name = $airport_item['airport_arrival_city'] . ', ' . $airport_item['airport_arrival_country'] . ' (' . $airport_item['airport_arrival_icao'] . ')';
        $name = str_replace("'", "", $name);
Exemplo n.º 4
0
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
$Spotter = new Spotter();
if ($_GET['flightaware_id'] != "") {
    $spotter_id = $Spotter->getSpotterIDBasedOnFlightAwareID($_GET['flightaware_id']);
    if ($spotter_id != "") {
        header('Location: ' . $globalURL . '/flightid/' . $spotter_id);
    } else {
        header('Location: ' . $globalURL);
    }
}
require 'require/class.Connection.php';
require 'require/class.Spotter.php';
$spotter_array = Spotter::getSpotterDataByRoute($_GET['departure_airport'], $_GET['arrival_airport'], "0,1", $_GET['sort']);
if (!empty($spotter_array)) {
    $title = 'Most Common Time of Day between ' . $spotter_array[0]['departure_airport_name'] . ' (' . $spotter_array[0]['departure_airport_icao'] . '), ' . $spotter_array[0]['departure_airport_country'] . ' - ' . $spotter_array[0]['arrival_airport_name'] . ' (' . $spotter_array[0]['arrival_airport_icao'] . '), ' . $spotter_array[0]['arrival_airport_country'];
    require 'header.php';
    print '<div class="info column">';
    print '<h1>Flights between ' . $spotter_array[0]['departure_airport_name'] . ' (' . $spotter_array[0]['departure_airport_icao'] . '), ' . $spotter_array[0]['departure_airport_country'] . ' - ' . $spotter_array[0]['arrival_airport_name'] . ' (' . $spotter_array[0]['arrival_airport_icao'] . '), ' . $spotter_array[0]['arrival_airport_country'] . '</h1>';
    print '<div><span class="label">Coming From</span><a href="' . $globalURL . '/airport/' . $spotter_array[0]['departure_airport_icao'] . '">' . $spotter_array[0]['departure_airport_name'] . ' (' . $spotter_array[0]['departure_airport_icao'] . '), ' . $spotter_array[0]['departure_airport_country'] . '</a></div>';
    print '<div><span class="label">Flying To</span><a href="' . $globalURL . '/airport/' . $spotter_array[0]['arrival_airport_icao'] . '">' . $spotter_array[0]['arrival_airport_name'] . ' (' . $spotter_array[0]['arrival_airport_icao'] . '), ' . $spotter_array[0]['arrival_airport_country'] . '</a></div>';
    print '</div>';
    include 'route-sub-menu.php';
    print '<div class="column">';
    print '<h2>Most Common Time of Day</h2>';
    print '<p>The statistic below shows the most common time of day of flights between <strong>' . $spotter_array[0]['departure_airport_name'] . ' (' . $spotter_array[0]['departure_airport_icao'] . '), ' . $spotter_array[0]['departure_airport_country'] . '</strong> and <strong>' . $spotter_array[0]['arrival_airport_name'] . ' (' . $spotter_array[0]['arrival_airport_icao'] . '), ' . $spotter_array[0]['arrival_airport_country'] . '</strong>.</p>';
    $hour_array = Spotter::countAllHoursByRoute($_GET['departure_airport'], $_GET['arrival_airport']);
    print '<div id="chartHour" class="chart" width="100%"></div>
      	<script> 
      		google.load("visualization", "1", {packages:["corechart"]});
          google.setOnLoadCallback(drawChart);
          function drawChart() {
            var data = google.visualization.arrayToDataTable([
            	["Hour", "# of Flights"], ';
    foreach ($hour_array as $hour_item) {
        $hour_data .= '[ "' . date("ga", strtotime($hour_item['hour_name'] . ":00")) . '",' . $hour_item['hour_count'] . '],';
    }
    $hour_data = substr($hour_data, 0, -1);
    print $hour_data;
    print ']);
    
            var options = {
Exemplo n.º 6
0
$limit_next = $limit_end + $absolute_difference;
$limit_previous_1 = $limit_start - $absolute_difference;
$limit_previous_2 = $limit_end - $absolute_difference;
$page_url = $globalURL . '/latest';
?>
 
  <?php 
print '<div class="info column">';
print '<h1>Latest Activity</h1>';
print '</div>';
print '<div class="table column">';
print '<p>The table below shows the detailed information of all recent flights.</p>';
if (isset($_GET['sort'])) {
    $spotter_array = Spotter::getLatestSpotterData($limit_start . "," . $absolute_difference, $_GET['sort']);
} else {
    $spotter_array = Spotter::getLatestSpotterData($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>';
}
?>
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
if (!isset($_GET['aircraft_manufacturer'])) {
    header('Location: ' . $globalURL . '/manufacturer');
    die;
}
$Spotter = new Spotter();
$manufacturer = ucwords(str_replace("-", " ", $_GET['aircraft_manufacturer']));
$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $_GET['sort']);
if (!empty($spotter_array)) {
    $title = 'Most Common Time of Day from ' . $manufacturer;
    require 'header.php';
    print '<div class="select-item">';
    print '<form action="' . $globalURL . '/manufacturer" method="post">';
    print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
    print '<option></option>';
    $all_manufacturers = $Spotter->getAllManufacturers();
    foreach ($all_manufacturers as $all_manufacturer) {
        if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) {
            print '<option value="' . strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])) . '" selected="selected">' . $all_manufacturer['aircraft_manufacturer'] . '</option>';
        } else {
            print '<option value="' . strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])) . '">' . $all_manufacturer['aircraft_manufacturer'] . '</option>';
        }
    }
    print '</select>';
    print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
    print '</form>';
    print '</div>';
    print '<div class="info column">';
 $limit_previous_2 = $limit_end - $absolute_difference;
 $manufacturer = ucwords(str_replace("-", " ", $_GET['aircraft_manufacturer']));
 $page_url = $globalURL . '/manufacturer/' . $_GET['aircraft_manufacturer'];
 if (isset($_GET['sort'])) {
     $spotter_array = Spotter::getSpotterDataByManufacturer($manufacturer, $limit_start . "," . $absolute_difference, $_GET['sort']);
 } else {
     $spotter_array = Spotter::getSpotterDataByManufacturer($manufacturer, $limit_start . "," . $absolute_difference, '');
 }
 if (!empty($spotter_array)) {
     $title = 'Detailed View for ' . $manufacturer;
     require 'header.php';
     print '<div class="select-item">';
     print '<form action="' . $globalURL . '/manufacturer" method="post">';
     print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
     print '<option></option>';
     $all_manufacturers = Spotter::getAllManufacturers();
     foreach ($all_manufacturers as $all_manufacturer) {
         if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) {
             print '<option value="' . strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])) . '" selected="selected">' . $all_manufacturer['aircraft_manufacturer'] . '</option>';
         } else {
             print '<option value="' . strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])) . '">' . $all_manufacturer['aircraft_manufacturer'] . '</option>';
         }
     }
     print '</select>';
     print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
     print '</form>';
     print '</div>';
     print '<div class="info column">';
     print '<h1>' . $manufacturer . '</h1>';
     print '</div>';
     print '<div class="table column">';
}
$spotter_array = Spotter::getSpotterDataByIdent($_GET['ident'], "0,1", $sort);
if (!empty($spotter_array)) {
    $title = 'Most Common Aircraft Manufacturer of ' . $spotter_array[0]['ident'];
    require 'header.php';
    print '<div class="info column">';
    print '<h1>' . $spotter_array[0]['ident'] . '</h1>';
    print '<div><span class="label">Ident</span>' . $spotter_array[0]['ident'] . '</div>';
    print '<div><span class="label">Airline</span><a href="' . $globalURL . '/airline/' . $spotter_array[0]['airline_icao'] . '">' . $spotter_array[0]['airline_name'] . '</a></div>';
    print '<div><span class="label">Flight History</span><a href="http://flightaware.com/live/flight/' . $spotter_array[0]['ident'] . '" target="_blank">View the Flight History of this callsign</a></div>';
    print '</div>';
    include 'ident-sub-menu.php';
    print '<div class="column">';
    print '<h2>Most Common Aircraft Manufacturer</h2>';
    print '<p>The statistic below shows the most common Aircraft Manufacturer of flights using the ident/callsign <strong>' . $spotter_array[0]['ident'] . '</strong>.</p>';
    $manufacturers_array = Spotter::countAllAircraftManufacturerByIdent($_GET['ident']);
    if (!empty($manufacturers_array)) {
        print '<div class="table-responsive">';
        print '<table class="common-manufacturer table-striped">';
        print '<thead>';
        print '<th></th>';
        print '<th>Aircraft Manufacturer</th>';
        print '<th># of Times</th>';
        print '<th></th>';
        print '</thead>';
        print '<tbody>';
        $i = 1;
        foreach ($manufacturers_array as $manufacturer_item) {
            print '<tr>';
            print '<td><strong>' . $i . '</strong></td>';
            print '<td>';
Exemplo n.º 10
0
 /**
  * Gets all the archive spotter information
  *
  * @return Array the spotter information
  *
  */
 public function getSpotteArchiveData($ident, $flightaware_id, $date)
 {
     $Spotter = new Spotter();
     $ident = filter_var($ident, FILTER_SANITIZE_STRING);
     $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
     $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date . '%'));
     return $spotter_array;
 }
Exemplo n.º 11
0
<?php

/**
* This script is used to import data from FlightAware. Not tested anymore, deprecated because no account available.
*/
require dirname(__FILE__) . '/../require/class.Connection.php';
require dirname(__FILE__) . '/../require/class.Spotter.php';
require dirname(__FILE__) . '/../require/class.SpotterLive.php';
require dirname(__FILE__) . '/../require/settings.php';
//checks to see if FlightAware import is set
if ($globalFlightAware == TRUE) {
    $SpotterLive = new SpotterLive();
    $Spotter = new Spotter();
    //deletes the spotter LIVE data
    $SpotterLive->deleteLiveSpotterData();
    //imports the new data from FlightAware
    $Spotter->importFromFlightAware();
}
Exemplo n.º 12
0
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
require 'require/class.METAR.php';
$Spotter = new Spotter();
if (isset($_GET['airport_icao'])) {
    $icao = filter_input(INPUT_GET, 'airport_icao', FILTER_SANITIZE_STRING);
    $spotter_array = $Spotter->getAllAirportInfo($icao);
    if (isset($globalMETAR) && $globalMETAR) {
        $METAR = new METAR();
        $metar_info = $METAR->getMETAR($icao);
        //print_r($metar_info);
        if (isset($metar_info[0]['metar'])) {
            $metar_parse = $METAR->parse($metar_info[0]['metar']);
        }
        //print_r($metar_parse);
    }
}
?>
<div class="alldetails">
<button type="button" class="close">&times;</button>
<?php 
$spotter_item = $spotter_array[0];
//print_r($spotter_item);
date_default_timezone_set('UTC');
if (isset($spotter_item['image_thumb']) && $spotter_item['image_thumb'] != "") {
    $image = $spotter_item['image_thumb'];
}
print '<div class="top">';
if (isset($image)) {
Exemplo n.º 13
0
<link type="text/css" rel="stylesheet" href="<?php 
print $globalURL;
?>
/css/style-tv.css?<?php 
print time();
?>
" />
</head>
<body>


<?php 
if (isset($_GET['q'])) {
    $spotter_array = Spotter::searchSpotterData($_GET['q'], "", "", "", "", "", "", "", "", "", "", "", "", "", "0,10", "", "");
} else {
    $spotter_array = Spotter::getLatestSpotterData("0,10", "");
}
print '<div class="table-responsive">';
print '<table id="table-tv">';
print '<tbody>';
foreach ($spotter_array as $spotter_item) {
    if (isset($globalTimezone)) {
        date_default_timezone_set($globalTimezone);
    } else {
        date_default_timezone_set('UTC');
    }
    print '<tr>';
    if (isset($_GET['image']) && $_GET['image'] == "true") {
        if ($spotter_item['image'] != "") {
            print '<td class="aircraft_image">';
            print '<img src="' . $spotter_item['image'] . '" alt="Click to see more information about this flight" title="Click to see more information about this flight" />';
Exemplo n.º 14
0
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
$Spotter = new Spotter();
$title = "Statistic - Most Busiest Month of Last Year";
require 'header.php';
include 'statistics-sub-menu.php';
?>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
		<div class="info">
	  	<h1>Most Busiest Day Last Month</h1>
	  </div>
      
      <p>Below is a chart that plots the busiest day during the <strong>last month</strong>.</p>
      
<?php 
$date_array = $Spotter->countAllDatesLastMonth();
print '<div id="chart" class="chart" width="100%"></div>
      	<script> 
      		google.load("visualization", "1", {packages:["corechart"]});
          google.setOnLoadCallback(drawChart);
          function drawChart() {
            var data = google.visualization.arrayToDataTable([
            	["Month", "# of Flights"], ';
$date_data = '';
foreach ($date_array as $date_item) {
    $date_data .= '[ "' . date("F j, Y", strtotime($date_item['date_name'])) . '",' . $date_item['date_count'] . '],';
}
$date_data = substr($date_data, 0, -1);
print $date_data;
Exemplo n.º 15
0
 $limit_previous_2 = $limit_end - $absolute_difference;
 $country = ucwords(str_replace("-", " ", $_GET['country']));
 $page_url = $globalURL . '/country/' . $_GET['country'];
 if (isset($_GET['sort'])) {
     $spotter_array = Spotter::getSpotterDataByCountry($country, $limit_start . "," . $absolute_difference, $_GET['sort']);
 } else {
     $spotter_array = Spotter::getSpotterDataByCountry($country, $limit_start . "," . $absolute_difference, '');
 }
 if (!empty($spotter_array)) {
     $title = 'Detailed View for Airports &amp; Airlines from ' . $country;
     require 'header.php';
     print '<div class="select-item">';
     print '<form action="' . $globalURL . '/country" method="post">';
     print '<select name="country" class="selectpicker" data-live-search="true">';
     print '<option></option>';
     $all_countries = Spotter::getAllCountries();
     foreach ($all_countries as $all_country) {
         if ($country == $all_country['country']) {
             print '<option value="' . strtolower(str_replace(" ", "-", $all_country['country'])) . '" selected="selected">' . $all_country['country'] . '</option>';
         } else {
             print '<option value="' . strtolower(str_replace(" ", "-", $all_country['country'])) . '">' . $all_country['country'] . '</option>';
         }
     }
     print '</select>';
     print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
     print '</form>';
     print '</div>';
     if ($_GET['country'] != "NA") {
         print '<div class="info column">';
         print '<h1>Airports &amp; Airlines from ' . $country . '</h1>';
         print '</div>';
require 'require/class.Connection.php';
require 'require/class.Spotter.php';
$title = "Statistic - Most common Departure Airport by Country";
require 'header.php';
include 'statistics-sub-menu.php';
?>

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
		<div class="info">
	  	<h1>Most common Departure Airport by Country</h1>
	  </div>
    
    	<p>Below are the <strong>Top 10</strong> most common countries of all the departure airports.</p>
    
<?php 
$airport_country_array = Spotter::countAllDepartureCountries();
?>

    	<script>
    	google.load("visualization", "1", {packages:["geochart"]});
    	google.setOnLoadCallback(drawCharts);
    	$(window).resize(function(){
    		drawCharts();
    	});
    	function drawCharts() {
        
        var data = google.visualization.arrayToDataTable([ 
        	["Country", "# of Times"],
<?php 
$country_data = '';
foreach ($airport_country_array as $airport_item) {
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
if (!isset($_GET['aircraft_type'])) {
    header('Location: ' . $globalURL . '/aircraft');
    die;
}
$Spotter = new Spotter();
$spotter_array = $Spotter->getSpotterDataByAircraft($_GET['aircraft_type'], "0,1", "");
if (!empty($spotter_array)) {
    $title = 'Most Common Routes from ' . $spotter_array[0]['aircraft_name'] . ' (' . $spotter_array[0]['aircraft_type'] . ')';
    require 'header.php';
    print '<div class="select-item">';
    print '<form action="' . $globalURL . '/aircraft" method="post">';
    print '<select name="aircraft_type" class="selectpicker" data-live-search="true">';
    print '<option></option>';
    $aircraft_types = $Spotter->getAllAircraftTypes();
    foreach ($aircraft_types as $aircraft_type) {
        if ($_GET['aircraft_type'] == $aircraft_type['aircraft_icao']) {
            print '<option value="' . $aircraft_type['aircraft_icao'] . '" selected="selected">' . $aircraft_type['aircraft_name'] . ' (' . $aircraft_type['aircraft_icao'] . ')</option>';
        } else {
            print '<option value="' . $aircraft_type['aircraft_icao'] . '">' . $aircraft_type['aircraft_name'] . ' (' . $aircraft_type['aircraft_icao'] . ')</option>';
        }
    }
    print '</select>';
    print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
    print '</form>';
    print '</div>';
    if ($_GET['aircraft_type'] != "NA") {
        print '<div class="info column">';
     }
     print '<div><span class="label">Name</span>' . $spotter_array[0]['airline_name'] . '</div>';
     print '<div><span class="label">Country</span>' . $spotter_array[0]['airline_country'] . '</div>';
     print '<div><span class="label">ICAO</span>' . $spotter_array[0]['airline_icao'] . '</div>';
     print '<div><span class="label">IATA</span>' . $spotter_array[0]['airline_iata'] . '</div>';
     print '<div><span class="label">Callsign</span>' . $spotter_array[0]['airline_callsign'] . '</div>';
     print '<div><span class="label">Type</span>' . ucwords($spotter_array[0]['airline_type']) . '</div>';
     print '</div>';
 } else {
     print '<div class="alert alert-warning">This special airline profile shows all flights that do <u>not</u> have a airline associated with them.</div>';
 }
 include 'airline-sub-menu.php';
 print '<div class="column">';
 print '<h2>Most Common Aircraft</h2>';
 print '<p>The statistic below shows the most common aircrafts of flights from <strong>' . $spotter_array[0]['airline_name'] . '</strong>.</p>';
 $aircraft_array = Spotter::countAllAircraftTypesByAirline($_GET['airline']);
 if (!empty($aircraft_array)) {
     print '<div class="table-responsive">';
     print '<table class="common-type table-striped">';
     print '<thead>';
     print '<th></th>';
     print '<th>Aircraft Type</th>';
     print '<th># of Times</th>';
     print '<th></th>';
     print '</thead>';
     print '<tbody>';
     $i = 1;
     foreach ($aircraft_array as $aircraft_item) {
         print '<tr>';
         print '<td><strong>' . $i . '</strong></td>';
         print '<td>';
    print '<div class="info column">';
    print '<h1>' . $spotter_array[0]['ident'] . '</h1>';
    print '<div><span class="label">Ident</span>' . $spotter_array[0]['ident'] . '</div>';
    print '<div><span class="label">Airline</span><a href="' . $globalURL . '/airline/' . $spotter_array[0]['airline_icao'] . '">' . $spotter_array[0]['airline_name'] . '</a></div>';
    print '<div><span class="label">Flight History</span><a href="http://flightaware.com/live/flight/' . $spotter_array[0]['ident'] . '" target="_blank">View the Flight History of this callsign</a></div>';
    print '</div>';
    include 'ident-sub-menu.php';
    print '<div class="column">';
    print '<h2>Most Common Arrival Airports by Country</h2>';
    ?>
  	<p>The statistic below shows all arrival airports by Country of origin of flights with the ident/callsign <strong><?php 
    print $spotter_array[0]['ident'];
    ?>
</strong>.</p>
  	<?php 
    $airport_country_array = Spotter::countAllArrivalAirportCountriesByIdent($_GET['ident']);
    print '<div id="chartCountry" class="chart" width="100%"></div>
      	<script> 
      		google.load("visualization", "1", {packages:["geochart"]});
          google.setOnLoadCallback(drawChart);
          function drawChart() {
            var data = google.visualization.arrayToDataTable([
            	["Country", "# of Times"], ';
    foreach ($airport_country_array as $airport_item) {
        $country_data .= '[ "' . $airport_item['arrival_airport_country'] . '",' . $airport_item['airport_arrival_country_count'] . '],';
    }
    $country_data = substr($country_data, 0, -1);
    print $country_data;
    print ']);
    
            var options = {
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
$Spotter = new Spotter();
$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
$spotter_array = $Spotter->getSpotterDataByDate($_GET['date'], "0,1", $sort);
if (!empty($spotter_array)) {
    $title = 'Most Common Arrival Airports by Country on ' . date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']));
    require 'header.php';
    print '<div class="select-item">';
    print '<form action="' . $globalURL . '/date" method="post">';
    print '<label for="date">Select a Date</label>';
    print '<input type="text" id="date" name="date" value="' . $_GET['date'] . '" size="8" readonly="readonly" class="custom" />';
    print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
    print '</form>';
    print '</div>';
    print '<div class="info column">';
    print '<h1>Flights from ' . date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])) . '</h1>';
    print '</div>';
    include 'date-sub-menu.php';
    print '<div class="column">';
    print '<h2>Most Common Arrival Airports by Country</h2>';
    ?>
  	<p>The statistic below shows all arrival airports by Country of origin of flights on <strong><?php 
    print date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']));
    ?>
</strong>.</p>
  	<?php 
    $airport_country_array = $Spotter->countAllArrivalAirportCountriesByDate($_GET['date']);
    print '<div id="chartCountry" class="chart" width="100%"></div>
Exemplo n.º 21
0
 static function add($line)
 {
     global $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBSupdate, $globalDebug;
     date_default_timezone_set('UTC');
     // signal handler - playing nice with sockets and dump1090
     // pcntl_signal_dispatch();
     // get the time (so we can figure the timeout)
     $time = time();
     //pcntl_signal_dispatch();
     $dataFound = false;
     $putinarchive = false;
     $send = false;
     // SBS format is CSV format
     if (is_array($line) && isset($line['hex'])) {
         //print_r($line);
         if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) == 6) {
             $hex = trim($line['hex']);
             $id = trim($line['hex']);
             //print_r(self::$all_flights);
             if (!isset(self::$all_flights[$id]['hex'])) {
                 self::$all_flights[$id] = array('hex' => $hex, 'datetime' => $line['datetime']);
                 if (!isset($line['aircraft_icao'])) {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('aircraft_icao' => Spotter::getAllAircraftType($hex)));
                 } else {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
                 }
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => ''));
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('lastupdate' => time()));
                 if ($globalDebug) {
                     echo "*********** New aircraft hex : " . $hex . " ***********\n";
                 }
             }
             if (isset($line['datetime']) && $line['datetime'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('datetime' => $line['datetime']));
             }
             if (isset($line['registration']) && $line['registration'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('registration' => $line['registration']));
             }
             if (isset($line['waypoints']) && $line['waypoints'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('waypoints' => $line['waypoints']));
             }
             if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('pilot_id' => $line['pilot_id']));
             }
             if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('pilot_name' => $line['pilot_name']));
             }
             if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && self::$all_flights[$id]['ident'] != trim($line['ident'])) {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('ident' => trim($line['ident'])));
                 if (!isset($line['id'])) {
                     if (!isset($globalDaemon)) {
                         $globalDaemon = TRUE;
                     }
                     if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) {
                         self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('id' => self::$all_flights[$id]['hex'] . '-' . self::$all_flights[$id]['ident'] . '-' . date('YmdGi')));
                     } else {
                         self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('id' => self::$all_flights[$id]['hex'] . '-' . self::$all_flights[$id]['ident']));
                     }
                 } else {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('id' => $line['id']));
                 }
                 $putinarchive = true;
                 if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
                 } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
                     $line['departure_airport_icao'] = Spotter::getAirportIcao($line['departure_airport_iata']);
                     $line['arrival_airport_icao'] = Spotter::getAirportIcao($line['arrival_airport_iata']);
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
                 } else {
                     $route = Spotter::getRouteInfo(trim($line['ident']));
                     if (count($route) > 0) {
                         //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
                         if ($route['fromairport_icao'] != $route['toairport_icao']) {
                             //    self::$all_flights[$id] = array_merge(self::$all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
                             self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
                         }
                     }
                     if (!isset($globalFork)) {
                         $globalFork = TRUE;
                     }
                     if (function_exists('pcntl_fork') && $globalFork) {
                         $pids[$id] = pcntl_fork();
                         if (!$pids[$id]) {
                             $sid = posix_setsid();
                             SBS::get_Schedule($id, trim($line['ident']));
                             exit(0);
                         }
                     }
                 }
             }
             if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
                 if (!isset(self::$all_flights[$id]['latitude']) || self::$all_flights[$id]['latitude'] == '' || abs(self::$all_flights[$id]['latitude'] - $line['latitude']) < 3 || $line['format_source'] != 'sbs') {
                     if (!isset(self::$all_flights[$id]['archive_latitude'])) {
                         self::$all_flights[$id]['archive_latitude'] = $line['latitude'];
                     }
                     if (!isset(self::$all_flights[$id]['livedb_latitude']) || abs(self::$all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.02) {
                         self::$all_flights[$id]['livedb_latitude'] = $line['latitude'];
                         $dataFound = true;
                     }
                     // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('latitude' => $line['latitude']));
                     if (abs(self::$all_flights[$id]['archive_latitude'] - self::$all_flights[$id]['latitude']) > 0.3) {
                         self::$all_flights[$id]['archive_latitude'] = $line['latitude'];
                         $putinarchive = true;
                     }
                 } elseif (isset(self::$all_flights[$id]['latitude'])) {
                     if ($globalDebug) {
                         echo '!!! Strange latitude value - diff : ' . abs(self::$all_flights[$id]['latitude'] - $line['latitude']) . '- previous lat : ' . self::$all_flights[$id]['latitude'] . '- new lat : ' . $line['latitude'] . "\n";
                     }
                 }
             }
             if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
                 if ($line['longitude'] > 180) {
                     $line['longitude'] = $line['longitude'] - 360;
                 }
                 if (!isset(self::$all_flights[$id]['longitude']) || self::$all_flights[$id]['longitude'] == '' || abs(self::$all_flights[$id]['longitude'] - $line['longitude']) < 2 || $line['format_source'] != 'sbs') {
                     if (!isset(self::$all_flights[$id]['archive_longitude'])) {
                         self::$all_flights[$id]['archive_longitude'] = $line['longitude'];
                     }
                     if (!isset(self::$all_flights[$id]['livedb_longitude']) || abs(self::$all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.02) {
                         self::$all_flights[$id]['livedb_longitude'] = $line['longitude'];
                         $dataFound = true;
                     }
                     // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('longitude' => $line['longitude']));
                     if (abs(self::$all_flights[$id]['archive_longitude'] - self::$all_flights[$id]['longitude']) > 0.3) {
                         self::$all_flights[$id]['archive_longitude'] = $line['longitude'];
                         $putinarchive = true;
                     }
                 } elseif (isset(self::$all_flights[$id]['longitude'])) {
                     if ($globalDebug) {
                         echo '!!! Strange longitude value - diff : ' . abs(self::$all_flights[$id]['longitude'] - $line['longitude']) . '- previous lat : ' . self::$all_flights[$id]['longitude'] . '- new lat : ' . $line['longitude'] . "\n";
                     }
                 }
             }
             if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('verticalrate' => $line['verticalrate']));
                 //$dataFound = true;
             }
             if (isset($line['emergency']) && $line['emergency'] != '') {
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('emergency' => $line['emergency']));
                 //$dataFound = true;
             }
             if (isset($line['speed']) && $line['speed'] != '') {
                 //    self::$all_flights[$id] = array_merge(self::$all_flights[$id],array('speed' => $line[12]));
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('speed' => round($line['speed'])));
                 //$dataFound = true;
             }
             if (isset($line['squawk']) && $line['squawk'] != '') {
                 if (isset(self::$all_flights[$id]['squawk']) && self::$all_flights[$id]['squawk'] != '7500' && self::$all_flights[$id]['squawk'] != '7600' && self::$all_flights[$id]['squawk'] != '7700' && isset(self::$all_flights[$id]['id'])) {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('squawk' => $line['squawk']));
                     $highlight = '';
                     if (self::$all_flights[$id]['squawk'] == '7500') {
                         $highlight = 'Squawk 7500 : Hijack at ' . date('G:i') . ' UTC';
                     }
                     if (self::$all_flights[$id]['squawk'] == '7600') {
                         $highlight = 'Squawk 7600 : Lost Comm (radio failure) at ' . date('G:i') . ' UTC';
                     }
                     if (self::$all_flights[$id]['squawk'] == '7700') {
                         $highlight = 'Squawk 7700 : Emergency at ' . date('G:i') . ' UTC';
                     }
                     if ($highlight != '') {
                         Spotter::setHighlightFlight(self::$all_flights[$id]['id'], $highlight);
                         $putinarchive = true;
                         $highlight = '';
                     }
                 } else {
                     self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('squawk' => $line['squawk']));
                 }
                 //$dataFound = true;
             }
             if (isset($line['altitude']) && $line['altitude'] != '') {
                 //if (!isset(self::$all_flights[$id]['altitude']) || self::$all_flights[$id]['altitude'] == '' || (self::$all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
                 if (abs(round($line['altitude'] / 100) - self::$all_flights[$id]['altitude']) > 2) {
                     $putinarchive = true;
                 }
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('altitude' => round($line['altitude'] / 100)));
                 //$dataFound = true;
                 //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
             }
             if (isset($line['heading']) && $line['heading'] != '') {
                 if (abs(self::$all_flights[$id]['heading'] - round($line['heading'])) > 2) {
                     $putinarchive = true;
                 }
                 self::$all_flights[$id] = array_merge(self::$all_flights[$id], array('heading' => round($line['heading'])));
                 //$dataFound = true;
             }
             if (isset($globalSBS1update) && $globalSBS1update != '' && isset(self::$all_flights[$id]['lastupdate']) && time() - self::$all_flights[$id]['lastupdate'] < $globalSBS1update) {
                 $dataFound = false;
             }
             //		print_r(self::$all_flights[$id]);
             //gets the callsign from the last hour
             //if (time()-self::$all_flights[$id]['lastupdate'] > 30 && $dataFound == true && self::$all_flights[$id]['ident'] != '' && self::$all_flights[$id]['latitude'] != '' && self::$all_flights[$id]['longitude'] != '') {
             if ($dataFound == true && isset(self::$all_flights[$id]['hex']) && self::$all_flights[$id]['ident'] != '' && self::$all_flights[$id]['latitude'] != '' && self::$all_flights[$id]['longitude'] != '') {
                 if (!isset($globalDistanceIgnore['latitude']) || isset($globalDistanceIgnore['latitude']) && Common::distance(self::$all_flights[$id]['latitude'], self::$all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance']) {
                     self::$all_flights[$id]['lastupdate'] = time();
                     //$last_hour_ident = Spotter::getIdentFromLastHour(self::$all_flights[$id]['ident']);
                     $recent_ident = SpotterLive::checkIdentRecent(self::$all_flights[$id]['ident']);
                     //if there was no aircraft with the same callsign within the last hour and go post it into the archive
                     if ($recent_ident == "") {
                         if ($globalDebug) {
                             echo "\\o/ Add " . self::$all_flights[$id]['ident'] . " in archive DB : ";
                         }
                         if (self::$all_flights[$id]['departure_airport'] == "") {
                             self::$all_flights[$id]['departure_airport'] = "NA";
                         }
                         if (self::$all_flights[$id]['arrival_airport'] == "") {
                             self::$all_flights[$id]['arrival_airport'] = "NA";
                         }
                         //adds the spotter data for the archive
                         $ignoreImport = false;
                         foreach ($globalAirportIgnore as $airportIgnore) {
                             if (self::$all_flights[$id]['departure_airport'] != $airportIgnore && self::$all_flights[$id]['arrival_airport'] != $airportIgnore) {
                                 $ignoreImport = true;
                             }
                         }
                         if (!$ignoreImport) {
                             $highlight = '';
                             if (self::$all_flights[$id]['squawk'] == '7500') {
                                 $highlight = 'Squawk 7500 : Hijack';
                             }
                             if (self::$all_flights[$id]['squawk'] == '7600') {
                                 $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
                             }
                             if (self::$all_flights[$id]['squawk'] == '7700') {
                                 $highlight = 'Squawk 7700 : Emergency';
                             }
                             $result = Spotter::addSpotterData(self::$all_flights[$id]['id'], self::$all_flights[$id]['ident'], self::$all_flights[$id]['aircraft_icao'], self::$all_flights[$id]['departure_airport'], self::$all_flights[$id]['arrival_airport'], self::$all_flights[$id]['latitude'], self::$all_flights[$id]['longitude'], self::$all_flights[$id]['waypoints'], self::$all_flights[$id]['altitude'], self::$all_flights[$id]['heading'], self::$all_flights[$id]['speed'], '', self::$all_flights[$id]['departure_airport_time'], self::$all_flights[$id]['arrival_airport_time'], self::$all_flights[$id]['squawk'], self::$all_flights[$id]['route_stop'], $highlight, self::$all_flights[$id]['hex'], self::$all_flights[$id]['registration'], self::$all_flights[$id]['pilot_id'], self::$all_flights[$id]['pilot_name']);
                         }
                         $ignoreImport = false;
                         if ($globalDebug) {
                             echo $result . "\n";
                         }
                         /*
                         if (isset($globalArchive) && $globalArchive) {
                             $archives_ident = SpotterLive::getAllLiveSpotterDataByIdent(self::$all_flights[$id]['ident']);
                             foreach ($archives_ident as $archive) {
                         	SpotterArchive::addSpotterArchiveData($archive['flightaware_id'], $archive['ident'], $archive['registration'],$archive['airline_name'],$archive['airline_icao'],$archive['airline_country'],$archive['airline_type'],$archive['aircraft_icao'],$archive['aircraft_shadow'],$archive['aircraft_name'],$archive['aircraft_manufacturer'], $archive['departure_airport_icao'],$archive['departure_airport_name'],$archive['departure_airport_city'],$archive['departure_airport_country'],$archive['departure_airport_time'],
                         	$archive['arrival_airport_icao'],$archive['arrival_airport_name'],$archive['arrival_airport_city'],$archive['arrival_airport_country'],$archive['arrival_airport_time'],
                         	$archive['route_stop'],$archive['date'],$archive['latitude'], $archive['longitude'], $archive['waypoints'], $archive['altitude'], $archive['heading'], $archive['ground_speed'],
                         	$archive['squawk'],$archive['ModeS']);
                             }
                         }
                         */
                         //SpotterLive::deleteLiveSpotterDataByIdent(self::$all_flights[$id]['ident']);
                         SpotterLive::deleteLiveSpotterData();
                     }
                 }
                 //adds the spotter LIVE data
                 //SpotterLive::addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
                 //echo "\nAdd in Live !! \n";
                 //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
                 if ($globalDebug) {
                     echo 'DATA : hex : ' . self::$all_flights[$id]['hex'] . ' - ident : ' . self::$all_flights[$id]['ident'] . ' - ICAO : ' . self::$all_flights[$id]['aircraft_icao'] . ' - Departure Airport : ' . self::$all_flights[$id]['departure_airport'] . ' - Arrival Airport : ' . self::$all_flights[$id]['arrival_airport'] . ' - Latitude : ' . self::$all_flights[$id]['latitude'] . ' - Longitude : ' . self::$all_flights[$id]['longitude'] . ' - waypoints : ' . self::$all_flights[$id]['waypoints'] . ' - Altitude : ' . self::$all_flights[$id]['altitude'] . ' - Heading : ' . self::$all_flights[$id]['heading'] . ' - Speed : ' . self::$all_flights[$id]['speed'] . ' - Departure Airport Time : ' . self::$all_flights[$id]['departure_airport_time'] . ' - Arrival Airport time : ' . self::$all_flights[$id]['arrival_airport_time'] . "\n";
                 }
                 $ignoreImport = false;
                 if (self::$all_flights[$id]['departure_airport'] == "") {
                     self::$all_flights[$id]['departure_airport'] = "NA";
                 }
                 if (self::$all_flights[$id]['arrival_airport'] == "") {
                     self::$all_flights[$id]['arrival_airport'] = "NA";
                 }
                 foreach ($globalAirportIgnore as $airportIgnore) {
                     if (self::$all_flights[$id]['departure_airport'] != $airportIgnore && self::$all_flights[$id]['arrival_airport'] != $airportIgnore) {
                         $ignoreImport = true;
                     }
                 }
                 if (!$ignoreImport) {
                     if (!isset($globalDistanceIgnore['latitude']) || isset($globalDistanceIgnore['latitude']) && Common::distance(self::$all_flights[$id]['latitude'], self::$all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance']) {
                         if ($globalDebug) {
                             echo "\\o/ Add " . self::$all_flights[$id]['ident'] . " in Live DB : ";
                         }
                         $result = SpotterLive::addLiveSpotterData(self::$all_flights[$id]['id'], self::$all_flights[$id]['ident'], self::$all_flights[$id]['aircraft_icao'], self::$all_flights[$id]['departure_airport'], self::$all_flights[$id]['arrival_airport'], self::$all_flights[$id]['latitude'], self::$all_flights[$id]['longitude'], self::$all_flights[$id]['waypoints'], self::$all_flights[$id]['altitude'], self::$all_flights[$id]['heading'], self::$all_flights[$id]['speed'], self::$all_flights[$id]['departure_airport_time'], self::$all_flights[$id]['arrival_airport_time'], self::$all_flights[$id]['squawk'], self::$all_flights[$id]['route_stop'], self::$all_flights[$id]['hex'], $putinarchive, self::$all_flights[$id]['registration'], self::$all_flights[$id]['pilot_id'], self::$all_flights[$id]['pilot_name']);
                         if ($putinarchive) {
                             $send = true;
                         }
                         //if ($globalDebug) echo "Distance : ".Common::distance(self::$all_flights[$id]['latitude'],self::$all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
                         if ($globalDebug) {
                             echo $result . "\n";
                         }
                     } elseif (isset(self::$all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
                         echo "!! Too far -> Distance : " . Common::distance(self::$all_flights[$id]['latitude'], self::$all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) . "\n";
                     }
                     self::del();
                 }
                 $ignoreImport = false;
             }
             if (function_exists('pcntl_fork') && $globalFork) {
                 pcntl_signal(SIGCHLD, SIG_IGN);
             }
             if ($send) {
                 return self::$all_flights[$id];
             }
         }
     }
 }
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
$Spotter = new Spotter();
$title = "Statistic - Most common Departure Airport by Country";
require 'header.php';
include 'statistics-sub-menu.php';
?>

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
		<div class="info">
	  	<h1>Most common Departure Airport by Country</h1>
	  </div>
    
    	<p>Below are the <strong>Top 10</strong> most common countries of all the departure airports.</p>
    
<?php 
$airport_country_array = $Spotter->countAllDepartureCountries();
?>

    	<script>
    	google.load("visualization", "1", {packages:["geochart"]});
    	google.setOnLoadCallback(drawCharts);
    	$(window).resize(function(){
    		drawCharts();
    	});
    	function drawCharts() {
        
        var data = google.visualization.arrayToDataTable([ 
        	["Country", "# of Times"],
Exemplo n.º 23
0
            	colors: ["#1a3151"]
            };
    
            var chart = new google.visualization.AreaChart(document.getElementById("chart"));
            chart.draw(data, options);
          }
          $(window).resize(function(){
    			  drawChart();
    			});
      </script>';
?>
      
      <p>Below are the <strong>Top 10</strong> most busiest dates.</p>

<?php 
$date_array = Spotter::countAllDates();
if (!empty($date_array)) {
    print '<div class="table-responsive">';
    print '<table class="common-date table-striped">';
    print '<thead>';
    print '<th></th>';
    print '<th>Date</th>';
    print '<th># of Flights</th>';
    print '</thead>';
    print '<tbody>';
    $i = 1;
    foreach ($date_array as $date_item) {
        print '<tr>';
        print '<td><strong>' . $i . '</strong></td>';
        print '<td>';
        print '<a href="' . $globalURL . '/date/' . date("Y-m-d", strtotime($date_item['date_name'])) . '">' . date("l F j, Y", strtotime($date_item['date_name'])) . '</a>';
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
if (!isset($_GET['aircraft_manufacturer'])) {
    header('Location: ' . $globalURL . '/manufacturer');
    die;
}
$Spotter = new Spotter();
$manufacturer = ucwords(str_replace("-", " ", $_GET['aircraft_manufacturer']));
$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $_GET['sort']);
if (!empty($spotter_array)) {
    $title = 'Most Common Departure Airports from ' . $manufacturer;
    require 'header.php';
    print '<div class="select-item">';
    print '<form action="' . $globalURL . '/manufacturer" method="post">';
    print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
    print '<option></option>';
    $all_manufacturers = $Spotter->getAllManufacturers();
    foreach ($all_manufacturers as $all_manufacturer) {
        if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) {
            print '<option value="' . strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])) . '" selected="selected">' . $all_manufacturer['aircraft_manufacturer'] . '</option>';
        } else {
            print '<option value="' . strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])) . '">' . $all_manufacturer['aircraft_manufacturer'] . '</option>';
        }
    }
    print '</select>';
    print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
    print '</form>';
    print '</div>';
    print '<div class="info column">';
Exemplo n.º 25
0
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
header('Content-Type: text/javascript');
$Spotter = new Spotter();
$spotter_array = $Spotter->getRealTimeData();
print '{';
print '"airline_logo": "';
if (@getimagesize('http://www.barriespotter.com/images/airlines/' . $spotter_array[0]['airline_icao'] . '.png')) {
    print 'http://www.barriespotter.com/images/airlines/' . $spotter_array[0]['airline_icao'] . '.png';
}
print '",';
print '"body": "' . $spotter_array[0]['ident'] . ' - ' . $spotter_array[0]['airline_name'] . ' | ' . $spotter_array[0]['aircraft_name'] . ' (' . $spotter_array[0]['aircraft_type'] . ') | ' . $spotter_array[0]['departure_airport'] . ' - ' . $spotter_array[0]['arrival_airport'] . '",';
print '"url": "http://www.barriespotter.com/flightid/' . $spotter_array[0]['spotter_id'] . '",';
print '"html": "';
if (!empty($spotter_array)) {
    print '<a href=\\"http://www.barriespotter.com/flightid/' . $spotter_array[0]['spotter_id'] . '\\">';
    if (@getimagesize('http://www.barriespotter.com/images/airlines/' . $spotter_array[0]['airline_icao'] . '.png')) {
        print '<img src=\\"http://www.barriespotter.com/images/airlines/' . $spotter_array[0]['airline_icao'] . '.png\\" width=\\"50px\\" /> ';
    }
    print $spotter_array[0]['ident'] . ' - ' . $spotter_array[0]['airline_name'] . ' | ' . $spotter_array[0]['aircraft_name'] . ' (' . $spotter_array[0]['aircraft_type'] . ') | ' . $spotter_array[0]['departure_airport'] . ' - ' . $spotter_array[0]['arrival_airport'] . '</a>';
}
print '"';
print '}';
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
if (!isset($_GET['aircraft_manufacturer'])) {
    header('Location: ' . $globalURL . '/manufacturer');
    die;
}
$Spotter = new Spotter();
$manufacturer = ucwords(str_replace("-", " ", $_GET['aircraft_manufacturer']));
$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $_GET['sort']);
if (!empty($spotter_array)) {
    $title = 'Most Common Arrival Airports by Country from ' . $manufacturer;
    require 'header.php';
    print '<div class="select-item">';
    print '<form action="' . $globalURL . '/manufacturer" method="post">';
    print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
    print '<option></option>';
    $all_manufacturers = $Spotter->getAllManufacturers();
    foreach ($all_manufacturers as $all_manufacturer) {
        if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) {
            print '<option value="' . strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])) . '" selected="selected">' . $all_manufacturer['aircraft_manufacturer'] . '</option>';
        } else {
            print '<option value="' . strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])) . '">' . $all_manufacturer['aircraft_manufacturer'] . '</option>';
        }
    }
    print '</select>';
    print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
    print '</form>';
    print '</div>';
    print '<div class="info column">';
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
if (!isset($_GET['ident'])) {
    header('Location: ' . $globalURL . '/ident');
    die;
}
$Spotter = new Spotter();
$sort = '';
if (isset($_GET['sort'])) {
    $sort = $_GET['sort'];
}
$spotter_array = $Spotter->getSpotterDataByIdent($_GET['ident'], "0,1", $sort);
if (!empty($spotter_array)) {
    $title = 'Most Common Departure Airports by Country of ' . $spotter_array[0]['ident'];
    require 'header.php';
    print '<div class="info column">';
    print '<h1>' . $spotter_array[0]['ident'] . '</h1>';
    print '<div><span class="label">Ident</span>' . $spotter_array[0]['ident'] . '</div>';
    print '<div><span class="label">Airline</span><a href="' . $globalURL . '/airline/' . $spotter_array[0]['airline_icao'] . '">' . $spotter_array[0]['airline_name'] . '</a></div>';
    print '<div><span class="label">Flight History</span><a href="http://flightaware.com/live/flight/' . $spotter_array[0]['ident'] . '" target="_blank">View the Flight History of this callsign</a></div>';
    print '</div>';
    include 'ident-sub-menu.php';
    print '<div class="column">';
    print '<h2>Most Common Departure Airports by Country</h2>';
    ?>
  	<p>The statistic below shows all departure airports by Country of origin of flights with the ident/callsign <strong><?php 
    print $spotter_array[0]['ident'];
    ?>
</strong>.</p>
<?php

if ($_GET['departure_airport'] == "" || $_GET['arrival_airport'] == "") {
    header('Location: /');
}
require 'require/class.Connection.php';
require 'require/class.Spotter.php';
$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
$Spotter = new Spotter();
$spotter_array = $Spotter->getSpotterDataByRoute($_GET['departure_airport'], $_GET['arrival_airport'], "0,1", $sort);
if (!empty($spotter_array)) {
    $title = 'Most Common Aircraft between ' . $spotter_array[0]['departure_airport_name'] . ' (' . $spotter_array[0]['departure_airport_icao'] . '), ' . $spotter_array[0]['departure_airport_country'] . ' - ' . $spotter_array[0]['arrival_airport_name'] . ' (' . $spotter_array[0]['arrival_airport_icao'] . '), ' . $spotter_array[0]['arrival_airport_country'];
    require 'header.php';
    print '<div class="info column">';
    print '<h1>Flights between ' . $spotter_array[0]['departure_airport_name'] . ' (' . $spotter_array[0]['departure_airport_icao'] . '), ' . $spotter_array[0]['departure_airport_country'] . ' - ' . $spotter_array[0]['arrival_airport_name'] . ' (' . $spotter_array[0]['arrival_airport_icao'] . '), ' . $spotter_array[0]['arrival_airport_country'] . '</h1>';
    print '<div><span class="label">Coming From</span><a href="' . $globalURL . '/airport/' . $spotter_array[0]['departure_airport_icao'] . '">' . $spotter_array[0]['departure_airport_name'] . ' (' . $spotter_array[0]['departure_airport_icao'] . '), ' . $spotter_array[0]['departure_airport_country'] . '</a></div>';
    print '<div><span class="label">Flying To</span><a href="' . $globalURL . '/airport/' . $spotter_array[0]['arrival_airport_icao'] . '">' . $spotter_array[0]['arrival_airport_name'] . ' (' . $spotter_array[0]['arrival_airport_icao'] . '), ' . $spotter_array[0]['arrival_airport_country'] . '</a></div>';
    print '</div>';
    include 'route-sub-menu.php';
    print '<div class="column">';
    print '<h2>Most Common Aircraft</h2>';
    print '<p>The statistic below shows the most common aircrafts of flights between <strong>' . $spotter_array[0]['departure_airport_name'] . ' (' . $spotter_array[0]['departure_airport_icao'] . '), ' . $spotter_array[0]['departure_airport_country'] . '</strong> and <strong>' . $spotter_array[0]['arrival_airport_name'] . ' (' . $spotter_array[0]['arrival_airport_icao'] . '), ' . $spotter_array[0]['arrival_airport_country'] . '</strong>.</p>';
    $aircraft_array = $Spotter->countAllAircraftTypesByRoute($_GET['departure_airport'], $_GET['arrival_airport']);
    if (!empty($aircraft_array)) {
        print '<div class="table-responsive">';
        print '<table class="common-type table-striped">';
        print '<thead>';
        print '<th></th>';
        print '<th>Aircraft Type</th>';
        print '<th># of Times</th>';
        print '<th></th>';
Exemplo n.º 29
0
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
if (isset($_POST['airline'])) {
    header('Location: ' . $globalURL . '/airline/' . $_POST['airline']);
} else {
    $title = "Airlines";
    require 'header.php';
    $Spotter = new Spotter();
    print '<div class="column">';
    print '<h1>Airlines</h1>';
    if (isset($_POST['airline_type'])) {
        $airline_type = filter_input(INPUT_POST, 'airline_type', FILTER_SANITIZE_STRING);
        $airline_names = $Spotter->getAllAirlineNames($airline_type);
    } else {
        $airline_names = $Spotter->getAllAirlineNames();
        $airline_type = 'all';
    }
    print '<div class="select-item"><form action="' . $globalURL . '/airline" method="post"><select name="airline_type" class="selectpicker" data-live-search="true">';
    print '<option value="all"';
    if ($airline_type == 'all') {
        print 'selected="selected" ';
    }
    print '>All</option><option value="passenger"';
    if ($airline_type == 'passenger') {
        print 'selected="selected" ';
    }
    print '>Passenger</option><option value="cargo"';
    if ($airline_type == 'cargo') {
        print 'selected="selected" ';
<?php

require 'require/class.Connection.php';
require 'require/class.Spotter.php';
if (!isset($_GET['ident'])) {
    header('Location: ' . $globalURL . '/ident');
    die;
}
$Spotter = new Spotter();
$sort = '';
if (isset($_GET['sort'])) {
    $sort = $_GET['sort'];
}
$spotter_array = $Spotter->getSpotterDataByIdent($_GET['ident'], "0,1", $sort);
if (!empty($spotter_array)) {
    $title = 'Most Common Aircraft Manufacturer of ' . $spotter_array[0]['ident'];
    require 'header.php';
    print '<div class="info column">';
    print '<h1>' . $spotter_array[0]['ident'] . '</h1>';
    print '<div><span class="label">Ident</span>' . $spotter_array[0]['ident'] . '</div>';
    print '<div><span class="label">Airline</span><a href="' . $globalURL . '/airline/' . $spotter_array[0]['airline_icao'] . '">' . $spotter_array[0]['airline_name'] . '</a></div>';
    print '<div><span class="label">Flight History</span><a href="http://flightaware.com/live/flight/' . $spotter_array[0]['ident'] . '" target="_blank">View the Flight History of this callsign</a></div>';
    print '</div>';
    include 'ident-sub-menu.php';
    print '<div class="column">';
    print '<h2>Most Common Aircraft Manufacturer</h2>';
    print '<p>The statistic below shows the most common Aircraft Manufacturer of flights using the ident/callsign <strong>' . $spotter_array[0]['ident'] . '</strong>.</p>';
    $manufacturers_array = $Spotter->countAllAircraftManufacturerByIdent($_GET['ident']);
    if (!empty($manufacturers_array)) {
        print '<div class="table-responsive">';
        print '<table class="common-manufacturer table-striped">';