Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / route-detailed.php
blob350b1c595de29936010590c9a54788e48b2e5662
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Language.php');
6 if (!isset($_GET['departure_airport']) || !isset($_GET['arrival_airport'])){
7 header('Location: '.$globalURL.'');
8 } else {
9 $Spotter = new Spotter();
10 //calculuation for the pagination
11 if(!isset($_GET['limit']))
13 $limit_start = 0;
14 $limit_end = 25;
15 $absolute_difference = 25;
16 } else {
17 $limit_explode = explode(",", $_GET['limit']);
18 $limit_start = $limit_explode[0];
19 $limit_end = $limit_explode[1];
20 if (!ctype_digit(strval($limit_start)) || !ctype_digit(strval($limit_end))) {
21 $limit_start = 0;
22 $limit_end = 25;
25 $absolute_difference = abs($limit_start - $limit_end);
26 $limit_next = $limit_end + $absolute_difference;
27 $limit_previous_1 = $limit_start - $absolute_difference;
28 $limit_previous_2 = $limit_end - $absolute_difference;
30 $departure_airport = filter_input(INPUT_GET,'departure_airport',FILTER_SANITIZE_STRING);
31 $arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING);
32 $page_url = $globalURL.'/route/'.$departure_airport.'/'.$arrival_airport;
33 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
34 if ($sort != '') {
35 $spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, $limit_start.",".$absolute_difference, $sort);
36 } else {
37 $spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, $limit_start.",".$absolute_difference, '');
40 if (!empty($spotter_array))
42 $title = sprintf(_("Detailed View for flights between %s (%s), %s - %s (%s), %s"),$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']);
43 require_once('header.php');
44 print '<div class="info column">';
45 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>';
46 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>';
47 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>';
48 print '</div>';
50 include('route-sub-menu.php');
51 print '<div class="table column">';
52 print '<p>'.sprintf(_("The table below shows the detailed information of all flights that used the route <strong>%s - %s</strong>."),$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['arrival_airport_icao']).'</p>';
54 include('table-output.php');
55 print '<div class="pagination">';
56 if ($limit_previous_1 >= 0)
58 print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'/'.$sort.'">&laquo;'._("Previous Page").'</a>';
60 if ($spotter_array[0]['query_number_rows'] == $absolute_difference)
62 print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'/'.$sort.'">'._("Next Page").'&raquo;</a>';
64 print '</div>';
65 print '</div>';
66 } else {
67 $title = _("Unknown Route");
68 require_once('header.php');
69 print '<h1>'._("Error").'</h1>';
70 print '<p>'._("Sorry, this route does not exist in this database. :(").'</p>';
74 require_once('footer.php');