@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | $title = _("Statistics").' - '._("Most common Airline by Country"); |
7 | 7 | if (!isset($filter_name)) $filter_name = ''; |
8 | 8 | require_once('header.php'); |
9 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
10 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
9 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
10 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
11 | 11 | include('statistics-sub-menu.php'); |
12 | 12 | |
13 | 13 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script> |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | </div> |
17 | 17 | <p>'._("Below are the <strong>Top 10</strong> countries that an airline belongs to.").'</p>'; |
18 | 18 | |
19 | -$airline_array = $Stats->countAllAirlineCountries(true,$filter_name,$year,$month); |
|
19 | +$airline_array = $Stats->countAllAirlineCountries(true, $filter_name, $year, $month); |
|
20 | 20 | if (count($airline_array) > 0) { |
21 | 21 | print '<div id="chartCountry" class="chart" width="100%"></div> |
22 | 22 | <script> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | var data = google.visualization.arrayToDataTable([ |
27 | 27 | ["'._("Country").'", "'._("# of times").'"], '; |
28 | 28 | $country_data = ''; |
29 | -foreach($airline_array as $airline_item) |
|
29 | +foreach ($airline_array as $airline_item) |
|
30 | 30 | { |
31 | 31 | $country_data .= '[ "'.$airline_item['airline_country'].'",'.$airline_item['airline_country_count'].'],'; |
32 | 32 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | print '</thead>'; |
61 | 61 | print '<tbody>'; |
62 | 62 | $i = 1; |
63 | - foreach($airline_array as $airline_item) |
|
63 | + foreach ($airline_array as $airline_item) |
|
64 | 64 | { |
65 | 65 | print '<tr>'; |
66 | 66 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | $title = _("Statistics").' - '._("Most common Airline"); |
7 | 7 | require_once('header.php'); |
8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
9 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
10 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
9 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
10 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
11 | 11 | include('statistics-sub-menu.php'); |
12 | 12 | |
13 | 13 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script> |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | </div> |
17 | 17 | <p>'._("Below are the <strong>Top 10</strong> most common airlines.").'</p>'; |
18 | 18 | |
19 | -$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month); |
|
19 | +$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month); |
|
20 | 20 | print '<div id="chart" class="chart" width="100%"></div> |
21 | 21 | <script> |
22 | 22 | google.load("visualization", "1", {packages:["corechart"]}); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | var data = google.visualization.arrayToDataTable([ |
26 | 26 | ["'._("Airline").'", "'._("# of times").'"], '; |
27 | 27 | $airline_data = ''; |
28 | -foreach($airline_array as $airline_item) |
|
28 | +foreach ($airline_array as $airline_item) |
|
29 | 29 | { |
30 | 30 | $airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],'; |
31 | 31 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | print '</thead>'; |
61 | 61 | print '<tbody>'; |
62 | 62 | $i = 1; |
63 | - foreach($airline_array as $airline_item) |
|
63 | + foreach ($airline_array as $airline_item) |
|
64 | 64 | { |
65 | 65 | print '<tr>'; |
66 | 66 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | die(); |
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
11 | -$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
12 | -$spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", $sort); |
|
10 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
11 | +$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
12 | +$spotter_array = $Spotter->getSpotterDataByIdent($ident, "0,1", $sort); |
|
13 | 13 | |
14 | 14 | if (!empty($spotter_array)) |
15 | 15 | { |
16 | - $title = sprintf(_("Most Common Airlines of %s"),$spotter_array[0]['ident']); |
|
16 | + $title = sprintf(_("Most Common Airlines of %s"), $spotter_array[0]['ident']); |
|
17 | 17 | require_once('header.php'); |
18 | 18 | print '<div class="info column">'; |
19 | 19 | print '<h1>'.$spotter_array[0]['ident'].'</h1>'; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | include('ident-sub-menu.php'); |
25 | 25 | print '<div class="column">'; |
26 | 26 | print '<h2>'._("Most Common Airlines").'</h2>'; |
27 | - print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights using the ident/callsign <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
27 | + print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights using the ident/callsign <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>'; |
|
28 | 28 | |
29 | 29 | $airline_array = $Spotter->countAllAirlinesByIdent($ident); |
30 | 30 | if (!empty($airline_array)) |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | print '</thead>'; |
42 | 42 | print '<tbody>'; |
43 | 43 | $i = 1; |
44 | - foreach($airline_array as $airline_item) |
|
44 | + foreach ($airline_array as $airline_item) |
|
45 | 45 | { |
46 | 46 | print '<tr>'; |
47 | 47 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | die(); |
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
11 | -$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
10 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
11 | +$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
12 | 12 | if ($sort != '') { |
13 | - $spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", $sort); |
|
13 | + $spotter_array = $Spotter->getSpotterDataByIdent($ident, "0,1", $sort); |
|
14 | 14 | } else { |
15 | - $spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", ''); |
|
15 | + $spotter_array = $Spotter->getSpotterDataByIdent($ident, "0,1", ''); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | if (!empty($spotter_array)) |
19 | 19 | { |
20 | - $title = sprintf(_("Most Common Aircraft of %s"),$spotter_array[0]['ident']); |
|
20 | + $title = sprintf(_("Most Common Aircraft of %s"), $spotter_array[0]['ident']); |
|
21 | 21 | require_once('header.php'); |
22 | 22 | print '<div class="info column">'; |
23 | 23 | print '<h1>'.$spotter_array[0]['ident'].'</h1>'; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | include('ident-sub-menu.php'); |
29 | 29 | print '<div class="column">'; |
30 | 30 | print '<h2>'._("Most Common Aircraft").'</h2>'; |
31 | - print '<p>'.sprintf(_("The statistic below shows the most common aircrafts of flights using the ident/callsign <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
31 | + print '<p>'.sprintf(_("The statistic below shows the most common aircrafts of flights using the ident/callsign <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>'; |
|
32 | 32 | |
33 | 33 | $aircraft_array = $Spotter->countAllAircraftTypesByIdent($ident); |
34 | 34 | if (!empty($aircraft_array)) |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | print '</thead>'; |
44 | 44 | print '<tbody>'; |
45 | 45 | $i = 1; |
46 | - foreach($aircraft_array as $aircraft_item) |
|
46 | + foreach ($aircraft_array as $aircraft_item) |
|
47 | 47 | { |
48 | 48 | print '<tr>'; |
49 | 49 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | die(); |
8 | 8 | } |
9 | 9 | $Spotter = new Spotter(); |
10 | -$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
11 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
12 | -$spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", $sort); |
|
10 | +$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
11 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
12 | +$spotter_array = $Spotter->getSpotterDataByIdent($ident, "0,1", $sort); |
|
13 | 13 | |
14 | 14 | if (!empty($spotter_array)) |
15 | 15 | { |
16 | - $title = sprintf(_("Most Common Aircraft by Registration of %s"),$spotter_array[0]['ident']); |
|
16 | + $title = sprintf(_("Most Common Aircraft by Registration of %s"), $spotter_array[0]['ident']); |
|
17 | 17 | require_once('header.php'); |
18 | 18 | print '<div class="info column">'; |
19 | 19 | print '<h1>'.$spotter_array[0]['ident'].'</h1>'; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | include('ident-sub-menu.php'); |
25 | 25 | print '<div class="column">'; |
26 | 26 | print '<h2>'._("Most Common Aircraft by Registration").'</h2>'; |
27 | - print '<p>'.sprintf(_("The statistic below shows the most common aircraft by Registration of flights using the ident/callsign <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
|
27 | + print '<p>'.sprintf(_("The statistic below shows the most common aircraft by Registration of flights using the ident/callsign <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>'; |
|
28 | 28 | |
29 | 29 | $aircraft_array = $Spotter->countAllAircraftRegistrationByIdent($ident); |
30 | 30 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | print '</thead>'; |
43 | 43 | print '<tbody>'; |
44 | 44 | $i = 1; |
45 | - foreach($aircraft_array as $aircraft_item) |
|
45 | + foreach ($aircraft_array as $aircraft_item) |
|
46 | 46 | { |
47 | 47 | print '<tr>'; |
48 | 48 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | header('Location: '.$globalURL.'/pilot/'.$_POST['pilot']); |
10 | 10 | //} else if (isset($_GET['airport'])){ |
11 | 11 | } else { |
12 | - $Spotter= new Spotter(); |
|
12 | + $Spotter = new Spotter(); |
|
13 | 13 | $Stats = new Stats(); |
14 | 14 | $title = _("Pilots"); |
15 | 15 | require_once('header.php'); |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | //ksort($pilot_names); |
23 | 23 | $previous = null; |
24 | 24 | print '<div class="alphabet-legend">'; |
25 | - foreach($pilot_names as $value) { |
|
25 | + foreach ($pilot_names as $value) { |
|
26 | 26 | $firstLetter = mb_strtoupper(mb_substr($value['pilot_name'], 0, 1)); |
27 | - if($previous !== $firstLetter && $firstLetter != "'") |
|
27 | + if ($previous !== $firstLetter && $firstLetter != "'") |
|
28 | 28 | { |
29 | - if ($previous !== null){ |
|
29 | + if ($previous !== null) { |
|
30 | 30 | print ' | '; |
31 | 31 | } |
32 | 32 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | } |
36 | 36 | print '</div>'; |
37 | 37 | $previous = null; |
38 | - foreach($pilot_names as $value) { |
|
38 | + foreach ($pilot_names as $value) { |
|
39 | 39 | $firstLetter = mb_strtoupper(mb_substr($value['pilot_name'], 0, 1)); |
40 | 40 | if ($firstLetter != "") |
41 | 41 | { |
42 | - if($previous !== $firstLetter && $firstLetter != "'") |
|
42 | + if ($previous !== $firstLetter && $firstLetter != "'") |
|
43 | 43 | { |
44 | - if ($previous !== null){ |
|
44 | + if ($previous !== null) { |
|
45 | 45 | print '</div>'; |
46 | 46 | } |
47 | 47 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | header('Location: '.$globalURL.'/owner/'.$_POST['owner']); |
11 | 11 | //} else if (isset($_GET['airport'])){ |
12 | 12 | } else { |
13 | - $Spotter= new Spotter(); |
|
13 | + $Spotter = new Spotter(); |
|
14 | 14 | $Stats = new Stats(); |
15 | 15 | $Common = new Common(); |
16 | 16 | $title = _("Owners"); |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | ksort($owner_names); |
25 | 25 | $previous = null; |
26 | 26 | print '<div class="alphabet-legend">'; |
27 | - foreach($owner_names as $value) { |
|
27 | + foreach ($owner_names as $value) { |
|
28 | 28 | $firstLetter = $Common->remove_accents(mb_strtoupper(mb_substr($value['owner_name'], 0, 1))); |
29 | - if($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"') |
|
29 | + if ($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"') |
|
30 | 30 | { |
31 | - if ($previous !== null){ |
|
31 | + if ($previous !== null) { |
|
32 | 32 | print ' | '; |
33 | 33 | } |
34 | 34 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | } |
38 | 38 | print '</div>'; |
39 | 39 | $previous = null; |
40 | - foreach($owner_names as $value) { |
|
40 | + foreach ($owner_names as $value) { |
|
41 | 41 | $firstLetter = $Common->remove_accents(mb_strtoupper(mb_substr($value['owner_name'], 0, 1))); |
42 | 42 | if ($firstLetter != "") |
43 | 43 | { |
44 | - if($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"') |
|
44 | + if ($previous !== $firstLetter && $firstLetter != "'" && $firstLetter != '"') |
|
45 | 45 | { |
46 | - if ($previous !== null){ |
|
46 | + if ($previous !== null) { |
|
47 | 47 | print '</div>'; |
48 | 48 | } |
49 | 49 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
@@ -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,29 +51,29 @@ 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 accidents.date DESC".$limit_query; |
56 | 56 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
57 | - $query_values = array(':type' => $type,':date' => $date); |
|
58 | - } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { |
|
57 | + $query_values = array(':type' => $type, ':date' => $date); |
|
58 | + } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { |
|
59 | 59 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
60 | - $query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
61 | - } elseif (preg_match("/^[0-9]{4}$/",$date)) { |
|
60 | + $query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
61 | + } elseif (preg_match("/^[0-9]{4}$/", $date)) { |
|
62 | 62 | if ($globalDBdriver == 'mysql') { |
63 | 63 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
64 | 64 | } else { |
65 | 65 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
66 | 66 | } |
67 | - $query_values = array(':type' => $type,':date' => $date); |
|
67 | + $query_values = array(':type' => $type, ':date' => $date); |
|
68 | 68 | } else { |
69 | 69 | $date = $date.'%'; |
70 | 70 | if ($globalDBdriver == 'mysql') { |
71 | 71 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
72 | - $query_values = array(':type' => $type,':date' => $date); |
|
72 | + $query_values = array(':type' => $type, ':date' => $date); |
|
73 | 73 | } else { |
74 | 74 | $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 accidents.date DESC".$limit_query; |
75 | 75 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration 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 accidents.date DESC".$limit_query; |
76 | - $query_values = array(':type' => $type,':date' => $date); |
|
76 | + $query_values = array(':type' => $type, ':date' => $date); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | } else { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | } else { |
85 | 85 | if ($date != '') { |
86 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
86 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
87 | 87 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
88 | 88 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
89 | 89 | } else { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | try { |
103 | 103 | $sth = $this->db->prepare($query); |
104 | 104 | $sth->execute($query_values); |
105 | - } catch(PDOException $e) { |
|
105 | + } catch (PDOException $e) { |
|
106 | 106 | echo "error : ".$e->getMessage(); |
107 | 107 | } |
108 | 108 | $i = 0; |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | $data = array(); |
113 | 113 | if ($row['registration'] != '') { |
114 | 114 | $image_array = $Image->getSpotterImage($row['registration']); |
115 | - 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'])); |
|
116 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
115 | + 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'])); |
|
116 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
117 | 117 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
118 | 118 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
119 | 119 | if (!empty($aircraft_info)) { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
122 | 122 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
123 | 123 | } else { |
124 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
124 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
125 | 125 | } |
126 | 126 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
127 | 127 | if (!empty($owner_data)) { |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | $data['aircraft_base'] = $owner_data['base']; |
130 | 130 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
131 | 131 | } |
132 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
132 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
133 | 133 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
134 | 134 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
135 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
135 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
136 | 136 | if (isset($identicao[0])) { |
137 | - if (substr($row['ident'],0,2) == 'AF') { |
|
138 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
139 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
140 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
141 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
137 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
138 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
139 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
140 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
141 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
142 | 142 | } else $icao = $row['ident']; |
143 | - $icao = $Translation->checkTranslation($icao,false); |
|
143 | + $icao = $Translation->checkTranslation($icao, false); |
|
144 | 144 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
145 | 145 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
146 | 146 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | if (!empty($airline_info)) { |
150 | 150 | //echo 'data found !'."\n"; |
151 | 151 | //print_r($airline_info); |
152 | - $data = array_merge($data,$airline_info); |
|
152 | + $data = array_merge($data, $airline_info); |
|
153 | 153 | } |
154 | 154 | //else echo 'No data...'."\n"; |
155 | 155 | } |
156 | - $data = array_merge($row,$data); |
|
156 | + $data = array_merge($row, $data); |
|
157 | 157 | if ($data['ident'] == null) $data['ident'] = $icao; |
158 | 158 | if ($data['title'] == null) { |
159 | 159 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | try { |
188 | 188 | $sth = $this->db->prepare($query); |
189 | 189 | $sth->execute(); |
190 | - } catch(PDOException $e) { |
|
190 | + } catch (PDOException $e) { |
|
191 | 191 | echo "Error : ".$e->getMessage(); |
192 | 192 | } |
193 | 193 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | try { |
208 | 208 | $sth = $this->db->prepare($query); |
209 | 209 | $sth->execute(); |
210 | - } catch(PDOException $e) { |
|
210 | + } catch (PDOException $e) { |
|
211 | 211 | echo "Error : ".$e->getMessage(); |
212 | 212 | } |
213 | 213 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -222,15 +222,15 @@ discard block |
||
222 | 222 | if ($globalDebug) echo 'Import '.$file."\n"; |
223 | 223 | $result = array(); |
224 | 224 | if (file_exists($file)) { |
225 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
226 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
225 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
226 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
227 | 227 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
228 | - $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'); |
|
228 | + $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'); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | fclose($handle); |
232 | 232 | } |
233 | - if (!empty($result)) $this->add($result,true); |
|
233 | + if (!empty($result)) $this->add($result, true); |
|
234 | 234 | elseif ($globalDebug) echo 'Nothing to import'; |
235 | 235 | } |
236 | 236 | } |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | $all_md5_new = array(); |
247 | 247 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
248 | 248 | if ($this->check_accidents_nb() > 0) { |
249 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
250 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
249 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
250 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
251 | 251 | if (isset($data[1])) { |
252 | 252 | $year = $data[0]; |
253 | 253 | $all_md5[$year] = $data[1]; |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | } |
258 | 258 | } |
259 | 259 | } |
260 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
260 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
261 | 261 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
262 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
263 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
262 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
263 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
264 | 264 | if (isset($data[1])) { |
265 | 265 | $year = $data[0]; |
266 | 266 | $all_md5_new[$year] = $data[1]; |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | fclose($handle); |
270 | 270 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
271 | 271 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
272 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
272 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
273 | 273 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
274 | 274 | foreach ($result as $file => $md5) { |
275 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
275 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
276 | 276 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
277 | 277 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
278 | 278 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * Add data to DB |
283 | 283 | * @param Array $crash An array with accidents/incidents data |
284 | 284 | */ |
285 | - public function add($crash,$new = false) { |
|
285 | + public function add($crash, $new = false) { |
|
286 | 286 | global $globalTransaction, $globalDebug; |
287 | 287 | require_once('class.Connection.php'); |
288 | 288 | require_once('class.Image.php'); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $sthd->execute(array(':source' => $crash[0]['source'])); |
299 | 299 | } |
300 | 300 | if ($globalTransaction) $Connection->db->beginTransaction(); |
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); |
|
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); |
|
302 | 302 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
303 | 303 | $sth_check = $Connection->db->prepare($query_check); |
304 | 304 | $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)'; |
@@ -311,31 +311,31 @@ discard block |
||
311 | 311 | $cr = array_map(function($value) { |
312 | 312 | return $value === "" ? NULL : $value; |
313 | 313 | }, $cr); |
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'])) { |
|
315 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
316 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
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'])) { |
|
315 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
316 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
317 | 317 | $sth_check->execute($query_check_values); |
318 | 318 | $result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
319 | 319 | if ($result_check['nb'] == 0) { |
320 | - $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']); |
|
320 | + $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']); |
|
321 | 321 | $sth->execute($query_values); |
322 | - if ($cr['date'] > time()-(30*86400)) { |
|
322 | + if ($cr['date'] > time() - (30*86400)) { |
|
323 | 323 | if (empty($Image->getSpotterImage($cr['registration']))) { |
324 | 324 | //if ($globalDebug) echo 'Get image...'."\n"; |
325 | 325 | $Image->addSpotterImage($cr['registration']); |
326 | 326 | } |
327 | 327 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
328 | 328 | } |
329 | - $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
329 | + $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
330 | 330 | } |
331 | 331 | } |
332 | - if ($globalTransaction && $j % 1000 == 0) { |
|
332 | + if ($globalTransaction && $j%1000 == 0) { |
|
333 | 333 | $Connection->db->commit(); |
334 | 334 | $Connection->db->beginTransaction(); |
335 | 335 | } |
336 | 336 | } |
337 | 337 | if ($globalTransaction) $Connection->db->commit(); |
338 | - } catch(PDOException $e) { |
|
338 | + } catch (PDOException $e) { |
|
339 | 339 | if ($globalTransaction) $Connection->db->rollBack(); |
340 | 340 | echo $e->getMessage(); |
341 | 341 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $Connection = new Connection(); |
354 | 354 | $sth = $Connection->db->prepare($query); |
355 | 355 | $sth->execute(); |
356 | - } catch(PDOException $e) { |
|
356 | + } catch (PDOException $e) { |
|
357 | 357 | return "error : ".$e->getMessage(); |
358 | 358 | } |
359 | 359 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | $Connection = new Connection(); |
372 | 372 | $sth = $Connection->db->prepare($query); |
373 | 373 | $sth->execute(); |
374 | - } catch(PDOException $e) { |
|
374 | + } catch (PDOException $e) { |
|
375 | 375 | return "error : ".$e->getMessage(); |
376 | 376 | } |
377 | 377 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | $Connection = new Connection(); |
387 | 387 | $sth = $Connection->db->prepare($query); |
388 | 388 | $sth->execute(); |
389 | - } catch(PDOException $e) { |
|
389 | + } catch (PDOException $e) { |
|
390 | 390 | return "error : ".$e->getMessage(); |
391 | 391 | } |
392 | 392 | } |
@@ -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,14 +66,14 @@ 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 | 74 | if ($date_item['month'] < 10) $month = '0'.$date_item['month']; |
75 | 75 | else $month = $date_item['month']; |
76 | - print '<a href="'.$globalURL.'/accident/'.$date_item['year'].'-'.$month.'">'.date('F, Y',strtotime($date_item['year'].'-'.$date_item['month'].'-01')).'</a>'; |
|
76 | + print '<a href="'.$globalURL.'/accident/'.$date_item['year'].'-'.$month.'">'.date('F, Y', strtotime($date_item['year'].'-'.$date_item['month'].'-01')).'</a>'; |
|
77 | 77 | print '</td>'; |
78 | 78 | print '<td>'; |
79 | 79 | print $date_item['count']; |