@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | <meta property="og:site_name" content="<?php print $globalName; ?>"/> |
41 | 41 | |
42 | 42 | <?php |
43 | - if (!isset($_SESSION['install']) && !$globalInstalled) { |
|
43 | + if (!isset($_SESSION['install']) && !$globalInstalled) { |
|
44 | 44 | ?> |
45 | 45 | <script language="JavaScript" type="text/javascript"> |
46 | 46 | function datasource_js() { |
@@ -121,22 +121,22 @@ discard block |
||
121 | 121 | } |
122 | 122 | </script> |
123 | 123 | <?php |
124 | - } |
|
124 | + } |
|
125 | 125 | ?> |
126 | 126 | |
127 | 127 | </head> |
128 | 128 | |
129 | 129 | <?php |
130 | - if (!isset($_SESSION['install']) && !$globalInstalled) { |
|
130 | + if (!isset($_SESSION['install']) && !$globalInstalled) { |
|
131 | 131 | ?> |
132 | 132 | |
133 | 133 | <body class="page-<?php print strtolower($current_page); ?>" onload="datasource_js(); metarcycle_js(); create_database_js(); daemon_js(); schedule_js()"> |
134 | 134 | <?php |
135 | - } else { |
|
135 | + } else { |
|
136 | 136 | ?> |
137 | 137 | <body class="page-<?php print strtolower($current_page); ?>"> |
138 | 138 | <?php |
139 | - } |
|
139 | + } |
|
140 | 140 | ?> |
141 | 141 | <div class="navbar navbar-fixed-top" role="navigation"> |
142 | 142 | <div class="container"> |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | |
188 | 188 | <?php |
189 | 189 | if (isset($top_header)) { |
190 | - if ($top_header != "") |
|
191 | - { |
|
190 | + if ($top_header != "") |
|
191 | + { |
|
192 | 192 | print '<div class="top-header container clear" role="main">'; |
193 | 193 | print '<img src="../images/'.$top_header.'" alt="'.$title.'" title="'.$title.'" />'; |
194 | 194 | print '</div>'; |
195 | - } |
|
195 | + } |
|
196 | 196 | } |
197 | 197 | ?> |
198 | 198 |
@@ -7,14 +7,14 @@ discard block |
||
7 | 7 | header('Location: '.$globalURL.'/airport'); |
8 | 8 | die(); |
9 | 9 | } |
10 | -$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING); |
|
10 | +$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING); |
|
11 | 11 | $Spotter = new Spotter(); |
12 | -$spotter_array = $Spotter->getSpotterDataByAirport($airport,"0,1",""); |
|
12 | +$spotter_array = $Spotter->getSpotterDataByAirport($airport, "0,1", ""); |
|
13 | 13 | $airport_array = $Spotter->getAllAirportInfo($airport); |
14 | 14 | |
15 | 15 | if (!empty($airport_array)) |
16 | 16 | { |
17 | - $title = sprintf(_("Most Common Aircraft by Registration to/from %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']); |
|
17 | + $title = sprintf(_("Most Common Aircraft by Registration to/from %s, %s (%s)"), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']); |
|
18 | 18 | |
19 | 19 | require_once('header.php'); |
20 | 20 | print '<div class="select-item">'; |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | $airport_names = $Stats->getAllAirportNames(); |
26 | 26 | if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
27 | 27 | ksort($airport_names); |
28 | - foreach($airport_names as $airport_name) |
|
28 | + foreach ($airport_names as $airport_name) |
|
29 | 29 | { |
30 | - if($_GET['airport'] == $airport_name['airport_icao']) |
|
30 | + if ($_GET['airport'] == $airport_name['airport_icao']) |
|
31 | 31 | { |
32 | 32 | print '<option value="'.$airport_name['airport_icao'].'" selected="selected">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>'; |
33 | 33 | } else { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | include('airport-sub-menu.php'); |
59 | 59 | print '<div class="column">'; |
60 | 60 | print '<h2>'._("Most Common Aircraft by Registration").'</h2>'; |
61 | - print '<p>'.sprintf(_("The statistic below shows the most common aircraft by registration of flights to/from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>'; |
|
61 | + print '<p>'.sprintf(_("The statistic below shows the most common aircraft by registration of flights to/from <strong>%s, %s (%s)</strong>."), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']).'</p>'; |
|
62 | 62 | |
63 | 63 | $aircraft_array = $Spotter->countAllAircraftRegistrationByAirport($airport); |
64 | 64 | if (!empty($aircraft_array)) |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | print '</thead>'; |
76 | 76 | print '<tbody>'; |
77 | 77 | $i = 1; |
78 | - foreach($aircraft_array as $aircraft_item) |
|
78 | + foreach ($aircraft_array as $aircraft_item) |
|
79 | 79 | { |
80 | 80 | print '<tr>'; |
81 | 81 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -4,8 +4,8 @@ |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['airport'])) { |
7 | - header('Location: '.$globalURL.'/airport'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/airport'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING); |
11 | 11 | $Spotter = new Spotter(); |
@@ -23,7 +23,9 @@ |
||
23 | 23 | print '<option></option>'; |
24 | 24 | $Stats = new Stats(); |
25 | 25 | $airport_names = $Stats->getAllAirportNames(); |
26 | - if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); |
|
26 | + if (empty($airport_names)) { |
|
27 | + $airport_names = $Spotter->getAllAirportNames(); |
|
28 | + } |
|
27 | 29 | ksort($airport_names); |
28 | 30 | foreach($airport_names as $airport_name) |
29 | 31 | { |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | header('Location: '.$globalURL.'/airline'); |
8 | 8 | die(); |
9 | 9 | } |
10 | -$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
10 | +$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
11 | 11 | $Spotter = new Spotter(); |
12 | -$spotter_array = $Spotter->getSpotterDataByAirline($airline,"0,1",""); |
|
12 | +$spotter_array = $Spotter->getSpotterDataByAirline($airline, "0,1", ""); |
|
13 | 13 | |
14 | 14 | if (!empty($spotter_array)) |
15 | 15 | { |
16 | - $title = sprintf(_("Most Common Routes from %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']); |
|
16 | + $title = sprintf(_("Most Common Routes from %s (%s)"), $spotter_array[0]['airline_name'], $spotter_array[0]['airline_icao']); |
|
17 | 17 | require_once('header.php'); |
18 | 18 | print '<div class="select-item">'; |
19 | 19 | print '<form action="'.$globalURL.'/airline" method="post">'; |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | $Stats = new Stats(); |
23 | 23 | $airline_names = $Stats->getAllAirlineNames(); |
24 | 24 | if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames(); |
25 | - foreach($airline_names as $airline_name) |
|
25 | + foreach ($airline_names as $airline_name) |
|
26 | 26 | { |
27 | - if($airline == $airline_name['airline_icao']) |
|
27 | + if ($airline == $airline_name['airline_icao']) |
|
28 | 28 | { |
29 | 29 | print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>'; |
30 | 30 | } else { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | include('airline-sub-menu.php'); |
63 | 63 | print '<div class="column">'; |
64 | 64 | print '<h2>'._("Most Common Routes").'</h2>'; |
65 | - print '<p>'.sprintf(_("The statistic below shows the most common routes from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>'; |
|
65 | + print '<p>'.sprintf(_("The statistic below shows the most common routes from <strong>%s</strong>."), $spotter_array[0]['airline_name']).'</p>'; |
|
66 | 66 | $route_array = $Spotter->countAllRoutesByAirline($airline); |
67 | 67 | if (!empty($route_array)) |
68 | 68 | { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | print '</thead>'; |
79 | 79 | print '<tbody>'; |
80 | 80 | $i = 1; |
81 | - foreach($route_array as $route_item) |
|
81 | + foreach ($route_array as $route_item) |
|
82 | 82 | { |
83 | 83 | print '<tr>'; |
84 | 84 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -21,7 +21,9 @@ discard block |
||
21 | 21 | print '<option></option>'; |
22 | 22 | $Stats = new Stats(); |
23 | 23 | $airline_names = $Stats->getAllAirlineNames(); |
24 | - if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames(); |
|
24 | + if (empty($airline_names)) { |
|
25 | + $airline_names = $Spotter->getAllAirlineNames(); |
|
26 | + } |
|
25 | 27 | foreach($airline_names as $airline_name) |
26 | 28 | { |
27 | 29 | if($airline == $airline_name['airline_icao']) |
@@ -43,8 +45,7 @@ discard block |
||
43 | 45 | if ($globalIVAO && @getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif')) |
44 | 46 | { |
45 | 47 | print '<img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif" alt="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" title="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" class="logo" />'; |
46 | - } |
|
47 | - elseif (@getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png')) |
|
48 | + } elseif (@getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png')) |
|
48 | 49 | { |
49 | 50 | print '<img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png" alt="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" title="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" class="logo" />'; |
50 | 51 | } |
@@ -4,8 +4,8 @@ |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['airline'])) { |
7 | - header('Location: '.$globalURL.'/airline'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/airline'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
11 | 11 | $Spotter = new Spotter(); |
@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | require_once('require/class.Spotter.php'); |
4 | 4 | require_once('require/class.Language.php'); |
5 | 5 | $Spotter = new Spotter(); |
6 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
7 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
8 | -$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort); |
|
6 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
7 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
8 | +$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort); |
|
9 | 9 | |
10 | 10 | if (!empty($spotter_array)) |
11 | 11 | { |
12 | - $title = sprintf(_("Most Common Arrival Airports on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
12 | + $title = sprintf(_("Most Common Arrival Airports on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
13 | 13 | |
14 | 14 | require_once('header.php'); |
15 | 15 | print '<div class="select-item">'; |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
28 | 28 | print '<br />'; |
29 | 29 | print '<div class="info column">'; |
30 | - print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
30 | + print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
31 | 31 | print '</div>'; |
32 | 32 | |
33 | 33 | include('date-sub-menu.php'); |
34 | 34 | print '<div class="column">'; |
35 | 35 | print '<h2>'._("Most Common Arrival Airports").'</h2>'; |
36 | - print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
36 | + print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
37 | 37 | $airport_airport_array = $Spotter->countAllArrivalAirportsByDate($date); |
38 | 38 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script> |
39 | 39 | <script> |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | ["'._("Airport").'", "'._("# of times").'"],'; |
49 | 49 | |
50 | 50 | $airport_data = ''; |
51 | - foreach($airport_airport_array as $airport_item) |
|
51 | + foreach ($airport_airport_array as $airport_item) |
|
52 | 52 | { |
53 | 53 | $name = $airport_item['airport_arrival_city'].', '.$airport_item['airport_arrival_country'].' ('.$airport_item['airport_arrival_icao'].')'; |
54 | 54 | $name = str_replace("'", "", $name); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | print '</thead>'; |
88 | 88 | print '<tbody>'; |
89 | 89 | $i = 1; |
90 | - foreach($airport_airport_array as $airport_item) |
|
90 | + foreach ($airport_airport_array as $airport_item) |
|
91 | 91 | { |
92 | 92 | print '<tr>'; |
93 | 93 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $title = _("Unknown Date"); |
113 | 113 | require_once('header.php'); |
114 | 114 | print '<h1>'._("Error").'</h1>'; |
115 | - print '<p>'._("Sorry, this date does not exist in this database. :(");'</p>'; |
|
115 | + print '<p>'._("Sorry, this date does not exist in this database. :("); '</p>'; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | require_once('footer.php'); |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | die(); |
9 | 9 | } |
10 | 10 | $Spotter = new Spotter(); |
11 | -$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))); |
|
12 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
13 | -$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort); |
|
11 | +$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING))); |
|
12 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
13 | +$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $sort); |
|
14 | 14 | |
15 | 15 | if (!empty($spotter_array)) |
16 | 16 | { |
17 | - $title = sprintf(_("Most Common Departure Airports from %s"),$manufacturer); |
|
17 | + $title = sprintf(_("Most Common Departure Airports from %s"), $manufacturer); |
|
18 | 18 | |
19 | 19 | require_once('header.php'); |
20 | 20 | print '<div class="select-item">'; |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | $Stats = new Stats(); |
24 | 24 | $all_manufacturers = $Stats->getAllManufacturers(); |
25 | 25 | if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
26 | - foreach($all_manufacturers as $all_manufacturer) |
|
26 | + foreach ($all_manufacturers as $all_manufacturer) |
|
27 | 27 | { |
28 | - if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
28 | + if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
|
29 | 29 | { |
30 | 30 | print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>'; |
31 | 31 | } else { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | include('manufacturer-sub-menu.php'); |
45 | 45 | print '<div class="column">'; |
46 | 46 | print '<h2>'._("Most Common Departure Airports").'</h2>'; |
47 | - print '<p>'.sprintf(_("The statistic below shows all departure airports of flights from <strong>%s</strong>."),$manufacturer).'</p>'; |
|
47 | + print '<p>'.sprintf(_("The statistic below shows all departure airports of flights from <strong>%s</strong>."), $manufacturer).'</p>'; |
|
48 | 48 | $airport_airport_array = $Spotter->countAllDepartureAirportsByManufacturer($manufacturer); |
49 | 49 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script> |
50 | 50 | <script> |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ["'._("Airport").'", "'._("# of times").'"],'; |
60 | 60 | |
61 | 61 | $airport_data = ''; |
62 | - foreach($airport_airport_array as $airport_item) |
|
62 | + foreach ($airport_airport_array as $airport_item) |
|
63 | 63 | { |
64 | 64 | $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')'; |
65 | 65 | $name = str_replace("'", "", $name); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | print '</thead>'; |
99 | 99 | print '<tbody>'; |
100 | 100 | $i = 1; |
101 | - foreach($airport_airport_array as $airport_item) |
|
101 | + foreach ($airport_airport_array as $airport_item) |
|
102 | 102 | { |
103 | 103 | print '<tr>'; |
104 | 104 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -22,7 +22,9 @@ |
||
22 | 22 | print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">'; |
23 | 23 | $Stats = new Stats(); |
24 | 24 | $all_manufacturers = $Stats->getAllManufacturers(); |
25 | - if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers(); |
|
25 | + if (empty($all_manufacturers)) { |
|
26 | + $all_manufacturers = $Spotter->getAllManufacturers(); |
|
27 | + } |
|
26 | 28 | foreach($all_manufacturers as $all_manufacturer) |
27 | 29 | { |
28 | 30 | if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
@@ -4,8 +4,8 @@ |
||
4 | 4 | require_once('require/class.Stats.php'); |
5 | 5 | require_once('require/class.Language.php'); |
6 | 6 | if (!isset($_GET['aircraft_manufacturer'])) { |
7 | - header('Location: '.$globalURL.'/manufacturer'); |
|
8 | - die(); |
|
7 | + header('Location: '.$globalURL.'/manufacturer'); |
|
8 | + die(); |
|
9 | 9 | } |
10 | 10 | $Spotter = new Spotter(); |
11 | 11 | $manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))); |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') $aircraft_types = $Spotter->getAllAircraftTypes(); |
20 | 20 | $previous = null; |
21 | 21 | print '<div class="alphabet-legend">'; |
22 | - foreach($aircraft_types as $value) { |
|
22 | + foreach ($aircraft_types as $value) { |
|
23 | 23 | //$firstLetter = substr($value['aircraft_name'], 0, 1); |
24 | 24 | $firstLetter = substr($value['aircraft_manufacturer'], 0, 1); |
25 | - if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
|
25 | + if ($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
|
26 | 26 | { |
27 | 27 | if ($previous !== null) print ' | '; |
28 | 28 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | } |
32 | 32 | print '</div>'; |
33 | 33 | $previous = null; |
34 | - foreach($aircraft_types as $value) { |
|
34 | + foreach ($aircraft_types as $value) { |
|
35 | 35 | //$firstLetter = substr($value['aircraft_name'], 0, 1); |
36 | 36 | $firstLetter = substr($value['aircraft_manufacturer'], 0, 1); |
37 | 37 | if ($firstLetter != "") |
38 | 38 | { |
39 | - if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
|
39 | + if ($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
|
40 | 40 | { |
41 | 41 | if ($previous !== null) print '</div>'; |
42 | 42 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | print '<h1>'._("Aircrafts Types").'</h1>'; |
17 | 17 | |
18 | 18 | $aircraft_types = $Stats->getAllAircraftTypes(); |
19 | - if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
19 | + if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') { |
|
20 | + $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
21 | + } |
|
20 | 22 | $previous = null; |
21 | 23 | print '<div class="alphabet-legend">'; |
22 | 24 | foreach($aircraft_types as $value) { |
@@ -24,10 +26,14 @@ discard block |
||
24 | 26 | $firstLetter = substr($value['aircraft_manufacturer'], 0, 1); |
25 | 27 | if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
26 | 28 | { |
27 | - if ($previous !== null) print ' | '; |
|
29 | + if ($previous !== null) { |
|
30 | + print ' | '; |
|
31 | + } |
|
28 | 32 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
29 | 33 | } |
30 | - if ($firstLetter != '(' && $firstLetter != ')') $previous = $firstLetter; |
|
34 | + if ($firstLetter != '(' && $firstLetter != ')') { |
|
35 | + $previous = $firstLetter; |
|
36 | + } |
|
31 | 37 | } |
32 | 38 | print '</div>'; |
33 | 39 | $previous = null; |
@@ -38,10 +44,14 @@ discard block |
||
38 | 44 | { |
39 | 45 | if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
40 | 46 | { |
41 | - if ($previous !== null) print '</div>'; |
|
47 | + if ($previous !== null) { |
|
48 | + print '</div>'; |
|
49 | + } |
|
42 | 50 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
43 | 51 | } |
44 | - if ($firstLetter != '(' && $firstLetter != ')') $previous = $firstLetter; |
|
52 | + if ($firstLetter != '(' && $firstLetter != ')') { |
|
53 | + $previous = $firstLetter; |
|
54 | + } |
|
45 | 55 | print '<div class="alphabet-item">'; |
46 | 56 | print '<a href="'.$globalURL.'/aircraft/'.$value['aircraft_icao'].'">'; |
47 | 57 | if ($value['aircraft_name'] == '') { |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | ["'._("Month").'", "'._("# of Fatalities").'"], '; |
24 | 24 | |
25 | 25 | $date_data = ''; |
26 | -foreach($date_array as $date_item) |
|
26 | +foreach ($date_array as $date_item) |
|
27 | 27 | { |
28 | - $date_data .= '[ "'.date('F, Y',strtotime($date_item['year'].'-'.$date_item['month'].'-01')).'",'.$date_item['count'].'],'; |
|
28 | + $date_data .= '[ "'.date('F, Y', strtotime($date_item['year'].'-'.$date_item['month'].'-01')).'",'.$date_item['count'].'],'; |
|
29 | 29 | } |
30 | 30 | $date_data = substr($date_data, 0, -1); |
31 | 31 | print $date_data; |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | |
51 | 51 | if (!empty($date_array)) |
52 | 52 | { |
53 | - foreach($date_array as $key => $row) { |
|
53 | + foreach ($date_array as $key => $row) { |
|
54 | 54 | $years[$key] = $row['year']; |
55 | 55 | $months[$key] = $row['month']; |
56 | 56 | $counts[$key] = $row['count']; |
57 | 57 | } |
58 | 58 | // array_multisort($years,SORT_DESC,$months,SORT_DESC,$date_array); |
59 | - array_multisort($counts,SORT_DESC,$date_array); |
|
59 | + array_multisort($counts, SORT_DESC, $date_array); |
|
60 | 60 | print '<div class="table-responsive">'; |
61 | 61 | print '<table class="common-date table-striped">'; |
62 | 62 | print '<thead>'; |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | print '</thead>'; |
67 | 67 | print '<tbody>'; |
68 | 68 | $i = 1; |
69 | - foreach($date_array as $date_item) |
|
69 | + foreach ($date_array as $date_item) |
|
70 | 70 | { |
71 | 71 | print '<tr>'; |
72 | 72 | print '<td><strong>'.$i.'</strong></td>'; |
73 | 73 | print '<td>'; |
74 | - print '<a href="'.$globalURL.'/accident/'.$date_item['year'].'-'.$date_item['month'].'">'.date('F, Y',strtotime($date_item['year'].'-'.$date_item['month'].'-01')).'</a>'; |
|
74 | + print '<a href="'.$globalURL.'/accident/'.$date_item['year'].'-'.$date_item['month'].'">'.date('F, Y', strtotime($date_item['year'].'-'.$date_item['month'].'-01')).'</a>'; |
|
75 | 75 | print '</td>'; |
76 | 76 | print '<td>'; |
77 | 77 | print $date_item['count']; |
@@ -23,12 +23,12 @@ |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * Get Accidents data from DB |
|
27 | - * @param String $limit Limit |
|
28 | - * @param String $type Set type accident or incident |
|
29 | - * @param String $date get data for a date |
|
30 | - * @return Array Return Accidents data in array |
|
31 | - */ |
|
26 | + * Get Accidents data from DB |
|
27 | + * @param String $limit Limit |
|
28 | + * @param String $type Set type accident or incident |
|
29 | + * @param String $date get data for a date |
|
30 | + * @return Array Return Accidents data in array |
|
31 | + */ |
|
32 | 32 | public function getAccidentData($limit = '',$type = '',$date = '') { |
33 | 33 | global $globalURL, $globalDBdriver; |
34 | 34 | $Image = new Image($this->db); |
@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | * @param String $date get data for a date |
30 | 30 | * @return Array Return Accidents data in array |
31 | 31 | */ |
32 | - public function getAccidentData($limit = '',$type = '',$date = '') { |
|
32 | + public function getAccidentData($limit = '', $type = '', $date = '') { |
|
33 | 33 | global $globalURL, $globalDBdriver; |
34 | 34 | $Image = new Image($this->db); |
35 | 35 | $Spotter = new Spotter($this->db); |
36 | 36 | $Translation = new Translation($this->db); |
37 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
37 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
38 | 38 | date_default_timezone_set('UTC'); |
39 | 39 | $result = array(); |
40 | 40 | $limit_query = ''; |
41 | 41 | if ($limit != "") |
42 | 42 | { |
43 | 43 | $limit_array = explode(",", $limit); |
44 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
45 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
44 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
45 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
46 | 46 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
47 | 47 | { |
48 | 48 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -51,20 +51,20 @@ discard block |
||
51 | 51 | |
52 | 52 | if ($type != '') { |
53 | 53 | if ($date != '') { |
54 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
54 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
55 | 55 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY date DESC".$limit_query; |
56 | 56 | } else { |
57 | 57 | $date = $date.'%'; |
58 | 58 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY date DESC".$limit_query; |
59 | 59 | } |
60 | - $query_values = array(':type' => $type,':date' => $date); |
|
60 | + $query_values = array(':type' => $type, ':date' => $date); |
|
61 | 61 | } else { |
62 | 62 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type GROUP BY registration) ORDER BY date DESC".$limit_query; |
63 | 63 | $query_values = array(':type' => $type); |
64 | 64 | } |
65 | 65 | } else { |
66 | 66 | if ($date != '') { |
67 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
67 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
68 | 68 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY date DESC".$limit_query; |
69 | 69 | } else { |
70 | 70 | $date = $date.'%'; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | try { |
81 | 81 | $sth = $this->db->prepare($query); |
82 | 82 | $sth->execute($query_values); |
83 | - } catch(PDOException $e) { |
|
83 | + } catch (PDOException $e) { |
|
84 | 84 | return "error : ".$e->getMessage(); |
85 | 85 | } |
86 | 86 | $i = 0; |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | $data = array(); |
89 | 89 | if ($row['registration'] != '') { |
90 | 90 | $image_array = $Image->getSpotterImage($row['registration']); |
91 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
92 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
91 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
92 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
93 | 93 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
94 | 94 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
95 | 95 | if (!empty($aircraft_info)) { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
98 | 98 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
99 | 99 | } else { |
100 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
100 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
101 | 101 | } |
102 | 102 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
103 | 103 | if (!empty($owner_data)) { |
@@ -105,18 +105,18 @@ discard block |
||
105 | 105 | $data['aircraft_base'] = $owner_data['base']; |
106 | 106 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
107 | 107 | } |
108 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
108 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
109 | 109 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
110 | 110 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
111 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
111 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
112 | 112 | if (isset($identicao[0])) { |
113 | - if (substr($row['ident'],0,2) == 'AF') { |
|
114 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
115 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
116 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
117 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
113 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
114 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
115 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
116 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
117 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
118 | 118 | } else $icao = $row['ident']; |
119 | - $icao = $Translation->checkTranslation($icao,false); |
|
119 | + $icao = $Translation->checkTranslation($icao, false); |
|
120 | 120 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
121 | 121 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
122 | 122 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | if (!empty($airline_info)) { |
126 | 126 | //echo 'data found !'."\n"; |
127 | 127 | //print_r($airline_info); |
128 | - $data = array_merge($data,$airline_info); |
|
128 | + $data = array_merge($data, $airline_info); |
|
129 | 129 | } |
130 | 130 | //else echo 'No data...'."\n"; |
131 | 131 | } |
132 | - $data = array_merge($row,$data); |
|
132 | + $data = array_merge($row, $data); |
|
133 | 133 | if ($data['ident'] == null) $data['ident'] = $icao; |
134 | 134 | if ($data['title'] == null) { |
135 | 135 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | try { |
154 | 154 | $sth = $this->db->prepare($query); |
155 | 155 | $sth->execute(); |
156 | - } catch(PDOException $e) { |
|
156 | + } catch (PDOException $e) { |
|
157 | 157 | echo "Error : ".$e->getMessage(); |
158 | 158 | } |
159 | 159 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | try { |
169 | 169 | $sth = $this->db->prepare($query); |
170 | 170 | $sth->execute(); |
171 | - } catch(PDOException $e) { |
|
171 | + } catch (PDOException $e) { |
|
172 | 172 | echo "Error : ".$e->getMessage(); |
173 | 173 | } |
174 | 174 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -183,15 +183,15 @@ discard block |
||
183 | 183 | if ($globalDebug) echo 'Import '.$file."\n"; |
184 | 184 | $result = array(); |
185 | 185 | if (file_exists($file)) { |
186 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
187 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
186 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
187 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
188 | 188 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
189 | - $result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam'); |
|
189 | + $result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam'); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | fclose($handle); |
193 | 193 | } |
194 | - if (!empty($result)) $this->add($result,true); |
|
194 | + if (!empty($result)) $this->add($result, true); |
|
195 | 195 | elseif ($globalDebug) echo 'Nothing to import'; |
196 | 196 | } |
197 | 197 | } |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | $all_md5_new = array(); |
208 | 208 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
209 | 209 | if ($this->check_accidents_nb() > 0) { |
210 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
211 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
210 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
211 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
212 | 212 | if (isset($data[1])) { |
213 | 213 | $year = $data[0]; |
214 | 214 | $all_md5[$year] = $data[1]; |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
221 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
221 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
222 | 222 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
223 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
224 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
223 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
224 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
225 | 225 | if (isset($data[1])) { |
226 | 226 | $year = $data[0]; |
227 | 227 | $all_md5_new[$year] = $data[1]; |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | fclose($handle); |
231 | 231 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
232 | 232 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
233 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
233 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
234 | 234 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
235 | 235 | foreach ($result as $file => $md5) { |
236 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
236 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
237 | 237 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
238 | 238 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
239 | 239 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * Add data to DB |
244 | 244 | * @param Array $crash An array with accidents/incidents data |
245 | 245 | */ |
246 | - public function add($crash,$new = false) { |
|
246 | + public function add($crash, $new = false) { |
|
247 | 247 | global $globalTransaction, $globalDebug; |
248 | 248 | require_once('class.Connection.php'); |
249 | 249 | require_once('class.Image.php'); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $sthd->execute(array(':source' => $crash[0]['source'])); |
260 | 260 | } |
261 | 261 | if ($globalTransaction) $Connection->db->beginTransaction(); |
262 | - $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
|
262 | + $initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null); |
|
263 | 263 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
264 | 264 | $sth_check = $Connection->db->prepare($query_check); |
265 | 265 | $query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)'; |
@@ -272,31 +272,31 @@ discard block |
||
272 | 272 | $cr = array_map(function($value) { |
273 | 273 | return $value === "" ? NULL : $value; |
274 | 274 | }, $cr); |
275 | - if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
|
276 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
277 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
275 | + if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { |
|
276 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
277 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
278 | 278 | $sth_check->execute($query_check_values); |
279 | 279 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
280 | 280 | if ($result_check['nb'] == 0) { |
281 | - $query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']); |
|
281 | + $query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']); |
|
282 | 282 | $sth->execute($query_values); |
283 | - if ($cr['date'] > time()-(30*86400)) { |
|
283 | + if ($cr['date'] > time() - (30*86400)) { |
|
284 | 284 | if (empty($Image->getSpotterImage($cr['registration']))) { |
285 | 285 | //if ($globalDebug) echo 'Get image...'."\n"; |
286 | 286 | $Image->addSpotterImage($cr['registration']); |
287 | 287 | } |
288 | 288 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
289 | 289 | } |
290 | - $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
290 | + $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
291 | 291 | } |
292 | 292 | } |
293 | - if ($globalTransaction && $j % 1000 == 0) { |
|
293 | + if ($globalTransaction && $j%1000 == 0) { |
|
294 | 294 | $Connection->db->commit(); |
295 | 295 | $Connection->db->beginTransaction(); |
296 | 296 | } |
297 | 297 | } |
298 | 298 | if ($globalTransaction) $Connection->db->commit(); |
299 | - } catch(PDOException $e) { |
|
299 | + } catch (PDOException $e) { |
|
300 | 300 | if ($globalTransaction) $Connection->db->rollBack(); |
301 | 301 | echo $e->getMessage(); |
302 | 302 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $Connection = new Connection(); |
315 | 315 | $sth = $Connection->db->prepare($query); |
316 | 316 | $sth->execute(); |
317 | - } catch(PDOException $e) { |
|
317 | + } catch (PDOException $e) { |
|
318 | 318 | return "error : ".$e->getMessage(); |
319 | 319 | } |
320 | 320 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $Connection = new Connection(); |
333 | 333 | $sth = $Connection->db->prepare($query); |
334 | 334 | $sth->execute(); |
335 | - } catch(PDOException $e) { |
|
335 | + } catch (PDOException $e) { |
|
336 | 336 | return "error : ".$e->getMessage(); |
337 | 337 | } |
338 | 338 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $Connection = new Connection(); |
348 | 348 | $sth = $Connection->db->prepare($query); |
349 | 349 | $sth->execute(); |
350 | - } catch(PDOException $e) { |
|
350 | + } catch (PDOException $e) { |
|
351 | 351 | return "error : ".$e->getMessage(); |
352 | 352 | } |
353 | 353 | } |
@@ -88,8 +88,11 @@ discard block |
||
88 | 88 | $data = array(); |
89 | 89 | if ($row['registration'] != '') { |
90 | 90 | $image_array = $Image->getSpotterImage($row['registration']); |
91 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
92 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
91 | + if (count($image_array) > 0) { |
|
92 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
93 | + } else { |
|
94 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
95 | + } |
|
93 | 96 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
94 | 97 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
95 | 98 | if (!empty($aircraft_info)) { |
@@ -105,17 +108,30 @@ discard block |
||
105 | 108 | $data['aircraft_base'] = $owner_data['base']; |
106 | 109 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
107 | 110 | } |
108 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
109 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
110 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
111 | + } else { |
|
112 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
113 | + } |
|
114 | + if ($row['registration'] == '') { |
|
115 | + $row['registration'] = 'NA'; |
|
116 | + } |
|
117 | + if ($row['ident'] == '') { |
|
118 | + $row['ident'] = 'NA'; |
|
119 | + } |
|
111 | 120 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
112 | 121 | if (isset($identicao[0])) { |
113 | 122 | if (substr($row['ident'],0,2) == 'AF') { |
114 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
115 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
116 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
123 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
124 | + $icao = $row['ident']; |
|
125 | + } else { |
|
126 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
127 | + } |
|
128 | + } else { |
|
129 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
130 | + } |
|
117 | 131 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
118 | - } else $icao = $row['ident']; |
|
132 | + } else { |
|
133 | + $icao = $row['ident']; |
|
134 | + } |
|
119 | 135 | $icao = $Translation->checkTranslation($icao,false); |
120 | 136 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
121 | 137 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -130,18 +146,23 @@ discard block |
||
130 | 146 | //else echo 'No data...'."\n"; |
131 | 147 | } |
132 | 148 | $data = array_merge($row,$data); |
133 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
149 | + if ($data['ident'] == null) { |
|
150 | + $data['ident'] = $icao; |
|
151 | + } |
|
134 | 152 | if ($data['title'] == null) { |
135 | 153 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
136 | - } else $data['message'] = strtolower($data['title']); |
|
154 | + } else { |
|
155 | + $data['message'] = strtolower($data['title']); |
|
156 | + } |
|
137 | 157 | $result[] = $data; |
138 | 158 | $i++; |
139 | 159 | } |
140 | 160 | if (isset($result)) { |
141 | 161 | $result[0]['query_number_rows'] = $i; |
142 | 162 | return $result; |
163 | + } else { |
|
164 | + return array(); |
|
143 | 165 | } |
144 | - else return array(); |
|
145 | 166 | } |
146 | 167 | |
147 | 168 | /* |
@@ -180,7 +201,9 @@ discard block |
||
180 | 201 | */ |
181 | 202 | public function import($file) { |
182 | 203 | global $globalTransaction, $globalDebug; |
183 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
204 | + if ($globalDebug) { |
|
205 | + echo 'Import '.$file."\n"; |
|
206 | + } |
|
184 | 207 | $result = array(); |
185 | 208 | if (file_exists($file)) { |
186 | 209 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -191,8 +214,11 @@ discard block |
||
191 | 214 | } |
192 | 215 | fclose($handle); |
193 | 216 | } |
194 | - if (!empty($result)) $this->add($result,true); |
|
195 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
217 | + if (!empty($result)) { |
|
218 | + $this->add($result,true); |
|
219 | + } elseif ($globalDebug) { |
|
220 | + echo 'Nothing to import'; |
|
221 | + } |
|
196 | 222 | } |
197 | 223 | } |
198 | 224 | |
@@ -228,14 +254,23 @@ discard block |
||
228 | 254 | } |
229 | 255 | } |
230 | 256 | fclose($handle); |
231 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
232 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
257 | + } elseif ($globalDebug) { |
|
258 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
259 | + } |
|
260 | + } elseif ($globalDebug) { |
|
261 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
262 | + } |
|
233 | 263 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
234 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
264 | + if (empty($result) && $globalDebug) { |
|
265 | + echo 'Nothing to update'; |
|
266 | + } |
|
235 | 267 | foreach ($result as $file => $md5) { |
236 | 268 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
237 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
238 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
269 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
270 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
271 | + } elseif ($globalDebug) { |
|
272 | + echo 'Download '.$file.' failed'; |
|
273 | + } |
|
239 | 274 | } |
240 | 275 | } |
241 | 276 | |
@@ -252,13 +287,17 @@ discard block |
||
252 | 287 | $Image = new Image(); |
253 | 288 | $Spotter = new Spotter(); |
254 | 289 | |
255 | - if (empty($crash)) return false; |
|
290 | + if (empty($crash)) { |
|
291 | + return false; |
|
292 | + } |
|
256 | 293 | if (!$new) { |
257 | 294 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
258 | 295 | $sthd = $Connection->db->prepare($query_delete); |
259 | 296 | $sthd->execute(array(':source' => $crash[0]['source'])); |
260 | 297 | } |
261 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
298 | + if ($globalTransaction) { |
|
299 | + $Connection->db->beginTransaction(); |
|
300 | + } |
|
262 | 301 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
263 | 302 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
264 | 303 | $sth_check = $Connection->db->prepare($query_check); |
@@ -273,7 +312,9 @@ discard block |
||
273 | 312 | return $value === "" ? NULL : $value; |
274 | 313 | }, $cr); |
275 | 314 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
276 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
315 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
316 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
317 | + } |
|
277 | 318 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
278 | 319 | $sth_check->execute($query_check_values); |
279 | 320 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
@@ -295,9 +336,13 @@ discard block |
||
295 | 336 | $Connection->db->beginTransaction(); |
296 | 337 | } |
297 | 338 | } |
298 | - if ($globalTransaction) $Connection->db->commit(); |
|
339 | + if ($globalTransaction) { |
|
340 | + $Connection->db->commit(); |
|
341 | + } |
|
299 | 342 | } catch(PDOException $e) { |
300 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
343 | + if ($globalTransaction) { |
|
344 | + $Connection->db->rollBack(); |
|
345 | + } |
|
301 | 346 | echo $e->getMessage(); |
302 | 347 | } |
303 | 348 | $sth_check->closeCursor(); |
@@ -336,8 +381,11 @@ discard block |
||
336 | 381 | return "error : ".$e->getMessage(); |
337 | 382 | } |
338 | 383 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
339 | - if ($row['nb'] > 0) return false; |
|
340 | - else return true; |
|
384 | + if ($row['nb'] > 0) { |
|
385 | + return false; |
|
386 | + } else { |
|
387 | + return true; |
|
388 | + } |
|
341 | 389 | } |
342 | 390 | |
343 | 391 | public static function insert_last_accidents_update() { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ["'._("Year").'", "'._("# of Fatalities").'"], '; |
24 | 24 | |
25 | 25 | $date_data = ''; |
26 | -foreach($date_array as $date_item) |
|
26 | +foreach ($date_array as $date_item) |
|
27 | 27 | { |
28 | 28 | $date_data .= '[ "'.$date_item['year'].'",'.$date_item['count'].'],'; |
29 | 29 | } |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | |
51 | 51 | if (!empty($date_array)) |
52 | 52 | { |
53 | - foreach($date_array as $key => $row) { |
|
53 | + foreach ($date_array as $key => $row) { |
|
54 | 54 | $years[$key] = $row['year']; |
55 | 55 | $counts[$key] = $row['count']; |
56 | 56 | } |
57 | 57 | //array_multisort($years,SORT_DESC,$date_array); |
58 | - array_multisort($counts,SORT_DESC,$date_array); |
|
58 | + array_multisort($counts, SORT_DESC, $date_array); |
|
59 | 59 | print '<div class="table-responsive">'; |
60 | 60 | print '<table class="common-date table-striped">'; |
61 | 61 | print '<thead>'; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | print '</thead>'; |
66 | 66 | print '<tbody>'; |
67 | 67 | $i = 1; |
68 | - foreach($date_array as $date_item) |
|
68 | + foreach ($date_array as $date_item) |
|
69 | 69 | { |
70 | 70 | print '<tr>'; |
71 | 71 | print '<td><strong>'.$i.'</strong></td>'; |