Completed
Push — master ( 6f7c12...384f31 )
by Yannick
07:57
created
airline-statistics-route.php 3 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>';
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 			}
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
date-statistics-arrival-airport.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
ident-statistics-departure-airport-country.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['ident'])) {
6
-        header('Location: '.$globalURL.'/ident');
7
-        die();
6
+		header('Location: '.$globalURL.'/ident');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
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 Departure Airports by Country of %s"),$spotter_array[0]['ident']);
16
+	$title = sprintf(_("Most Common Departure Airports by Country 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>';
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	include('ident-sub-menu.php');
24 24
 	print '<div class="column">';
25 25
 	print '<h2>'._("Most Common Departure Airports by Country").'</h2>';
26
-	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with the ident/callsign <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
26
+	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with the ident/callsign <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
27 27
 
28 28
 	$airport_country_array = $Spotter->countAllDepartureAirportCountriesByIdent($ident);
29 29
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
33 33
 	print 'var series = [';
34 34
 	$country_data = '';
35
-	foreach($airport_country_array as $airport_item)
35
+	foreach ($airport_country_array as $airport_item)
36 36
 	{
37 37
 		$country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],';
38 38
 	}
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		print '</thead>';
81 81
 		print '<tbody>';
82 82
 		$i = 1;
83
-		foreach($airport_country_array as $airport_item)
83
+		foreach ($airport_country_array as $airport_item)
84 84
 		{
85 85
 			print '<tr>';
86 86
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
manufacturer-statistics-departure-airport.php 3 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>';
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
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'])))
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
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)));
Please login to merge, or discard this patch.
airport-statistics-departure-airport-country.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@
 block discarded – undo
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
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
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 Departure Airports by Country to %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']);
17
+	$title = sprintf(_("Most Common Departure Airports by Country to %s, %s (%s)"), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']);
18 18
 	require_once('header.php');
19 19
 	print '<div class="select-item">';
20 20
 	print '<form action="'.$globalURL.'/airport" method="post">';
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	$airport_names = $Stats->getAllAirportNames();
25 25
 	if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
26 26
 	ksort($airport_names);
27
-	foreach($airport_names as $airport_name)
27
+	foreach ($airport_names as $airport_name)
28 28
 	{
29
-		if($_GET['airport'] == $airport_name['airport_icao'])
29
+		if ($_GET['airport'] == $airport_name['airport_icao'])
30 30
 		{
31 31
 			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>';
32 32
 		} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	include('airport-sub-menu.php');
58 58
 	print '<div class="column">';
59 59
 	print '<h2>'._("Most Common Departure Airports by Country").'</h2>';
60
-	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights to <strong>%s, %s, (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>';
60
+	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights to <strong>%s, %s, (%s)</strong>."), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']).'</p>';
61 61
 
62 62
 	$airport_country_array = $Spotter->countAllDepartureAirportCountriesByAirport($airport);
63 63
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>'; 
67 67
 	print 'var series = [';
68 68
 	$country_data = '';
69
-	foreach($airport_country_array as $airport_item)
69
+	foreach ($airport_country_array as $airport_item)
70 70
 	{
71 71
 		$country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],';
72 72
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		print '</thead>';
115 115
 		print '<tbody>';
116 116
 		$i = 1;
117
-		foreach($airport_country_array as $airport_item)
117
+		foreach ($airport_country_array as $airport_item)
118 118
 		{
119 119
 			print '<tr>';
120 120
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
airport-statistics-airline-country.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@
 block discarded – undo
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
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
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 Airlines by Country to/from %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']);
17
+	$title = sprintf(_("Most Common Airlines by Country to/from %s, %s (%s)"), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']);
18 18
 	require_once('header.php');
19 19
 	print '<div class="select-item">';
20 20
 	print '<form action="'.$globalURL.'/airport" method="post">';
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	$airport_names = $Stats->getAllAirportNames();
25 25
 	if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
26 26
 	ksort($airport_names);
27
-	foreach($airport_names as $airport_name)
27
+	foreach ($airport_names as $airport_name)
28 28
 	{
29
-		if($airport == $airport_name['airport_icao'])
29
+		if ($airport == $airport_name['airport_icao'])
30 30
 		{
31 31
 			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>';
32 32
 		} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	include('airport-sub-menu.php');
58 58
 	print '<div class="column">';
59 59
 	print '<h2>'._("Most Common Airlines by Country").'</h2>';
60
-	print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights to/from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>';
60
+	print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights to/from <strong>%s, %s (%s)</strong>."), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']).'</p>';
61 61
 
62 62
 	$airline_array = $Spotter->countAllAirlineCountriesByAirport($airport);
63 63
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
67 67
 	print 'var series = [';
68 68
 	$country_data = '';
69
-	foreach($airline_array as $airline_item)
69
+	foreach ($airline_array as $airline_item)
70 70
 	{
71 71
 		$country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],';
72 72
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		print '</thead>';
115 115
 		print '<tbody>';
116 116
 		$i = 1;
117
-		foreach($airline_array as $airline_item)
117
+		foreach ($airline_array as $airline_item)
118 118
 		{
119 119
 			print '<tr>';
120 120
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
airport-statistics-arrival-airport-country.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@
 block discarded – undo
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
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
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 Arrival Airports by Country from %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']);
17
+	$title = sprintf(_("Most Common Arrival Airports by Country from %s, %s (%s)"), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']);
18 18
 	require_once('header.php');
19 19
 	print '<div class="select-item">';
20 20
 	print '<form action="'.$globalURL.'/airport" method="post">';
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	$airport_names = $Stats->getAllAirportNames();
25 25
 	if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
26 26
 	ksort($airport_names);
27
-	foreach($airport_names as $airport_name)
27
+	foreach ($airport_names as $airport_name)
28 28
 	{
29
-		if($airport == $airport_name['airport_icao'])
29
+		if ($airport == $airport_name['airport_icao'])
30 30
 		{
31 31
 			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>';
32 32
 		} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	include('airport-sub-menu.php');
58 58
 	print '<div class="column">';
59 59
 	print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
60
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>';
60
+	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s, %s (%s)</strong>."), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']).'</p>';
61 61
 	$airport_country_array = $Spotter->countAllArrivalAirportCountriesByAirport($airport);
62 62
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
63 63
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
66 66
 	print 'var series = [';
67 67
 	$country_data = '';
68
-	foreach($airport_country_array as $airport_item)
68
+	foreach ($airport_country_array as $airport_item)
69 69
 	{
70 70
 		$country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
71 71
 	}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		print '</thead>';
114 114
 		print '<tbody>';
115 115
 		$i = 1;
116
-		foreach($airport_country_array as $airport_item)
116
+		foreach ($airport_country_array as $airport_item)
117 117
 		{
118 118
 			print '<tr>';
119 119
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
aircraft.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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">';
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'] == '') {
Please login to merge, or discard this patch.
require/class.Accident.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 			//print_r($row);
111 111
 			//echo $row['flightaware_id'];
112 112
 			$data = array();
113
-			if ($row['registration'] != '' && preg_match('/^[\w\-]+$/',$row['registration'])) {
113
+			if ($row['registration'] != '' && preg_match('/^[\w\-]+$/', $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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'];
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		try {
189 189
 			$sth = $this->db->prepare($query);
190 190
 			$sth->execute();
191
-		} catch(PDOException $e) {
191
+		} catch (PDOException $e) {
192 192
 			echo "Error : ".$e->getMessage();
193 193
 		}
194 194
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		try {
209 209
 			$sth = $this->db->prepare($query);
210 210
 			$sth->execute();
211
-		} catch(PDOException $e) {
211
+		} catch (PDOException $e) {
212 212
 			echo "Error : ".$e->getMessage();
213 213
 		}
214 214
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -223,15 +223,15 @@  discard block
 block discarded – undo
223 223
 		if ($globalDebug) echo 'Import '.$file."\n";
224 224
 		$result = array();
225 225
 		if (file_exists($file)) {
226
-			if (($handle = fopen($file,'r')) !== FALSE) {
227
-				while (($data = fgetcsv($handle,2000,",")) !== FALSE) {
226
+			if (($handle = fopen($file, 'r')) !== FALSE) {
227
+				while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
228 228
 					if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') {
229
-						$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
+						$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');
230 230
 					}
231 231
 				}
232 232
 				fclose($handle);
233 233
 			}
234
-			if (!empty($result)) $this->add($result,true);
234
+			if (!empty($result)) $this->add($result, true);
235 235
 			elseif ($globalDebug) echo 'Nothing to import';
236 236
 		}
237 237
 	}
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 		$all_md5_new = array();
248 248
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
249 249
 			if ($this->check_accidents_nb() > 0) {
250
-				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
251
-					while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
250
+				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
251
+					while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
252 252
 						if (isset($data[1])) {
253 253
 							$year = $data[0];
254 254
 							$all_md5[$year] = $data[1];
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 				}
259 259
 			}
260 260
 		}
261
-		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5');
261
+		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5');
262 262
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
263
-			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
264
-				while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
263
+			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
264
+				while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
265 265
 					if (isset($data[1])) {
266 266
 						$year = $data[0];
267 267
 						$all_md5_new[$year] = $data[1];
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
 				fclose($handle);
271 271
 			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
272 272
 		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
273
-		$result = $Common->arr_diff($all_md5_new,$all_md5);
273
+		$result = $Common->arr_diff($all_md5_new, $all_md5);
274 274
 		if (empty($result) && $globalDebug) echo 'Nothing to update';
275 275
 		foreach ($result as $file => $md5) {
276
-			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
276
+			$Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file);
277 277
 			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
278 278
 			elseif ($globalDebug) echo 'Download '.$file.' failed';
279 279
 		}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	* Add data to DB
284 284
 	* @param Array $crash An array with accidents/incidents data
285 285
 	*/
286
-	public function add($crash,$new = false) {
286
+	public function add($crash, $new = false) {
287 287
 		global $globalTransaction, $globalDebug;
288 288
 		require_once('class.Connection.php');
289 289
 		require_once('class.Image.php');
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 			$sthd->execute(array(':source' => $crash[0]['source']));
300 300
 		}
301 301
 		if ($globalTransaction) $Connection->db->beginTransaction();
302
-		$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
+		$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);
303 303
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
304 304
 		$sth_check = $Connection->db->prepare($query_check);
305 305
 		$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)';
@@ -312,31 +312,31 @@  discard block
 block discarded – undo
312 312
 				$cr = array_map(function($value) {
313 313
 					return $value === "" ? NULL : $value;
314 314
 				}, $cr);
315
-				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
316
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
317
-					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
315
+				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) {
316
+					if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
317
+					$query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']);
318 318
 					$sth_check->execute($query_check_values);
319 319
 					$result_check = $sth_check->fetch(PDO::FETCH_ASSOC);
320 320
 					if ($result_check['nb'] == 0) {
321
-						$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
+						$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']);
322 322
 						$sth->execute($query_values);
323
-						if ($cr['date'] > time()-(30*86400)) {
323
+						if ($cr['date'] > time() - (30*86400)) {
324 324
 							if (empty($Image->getSpotterImage($cr['registration']))) {
325 325
 								//if ($globalDebug) echo 'Get image...'."\n";
326 326
 								$Image->addSpotterImage($cr['registration']);
327 327
 							}
328 328
 							// elseif ($globalDebug) echo 'Image already in DB'."\n";
329 329
 						}
330
-						$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
330
+						$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date']));
331 331
 					}
332 332
 				}
333
-				if ($globalTransaction && $j % 1000 == 0) {
333
+				if ($globalTransaction && $j%1000 == 0) {
334 334
 					$Connection->db->commit();
335 335
 					$Connection->db->beginTransaction();
336 336
 				}
337 337
 			}
338 338
 			if ($globalTransaction) $Connection->db->commit();
339
-		} catch(PDOException $e) {
339
+		} catch (PDOException $e) {
340 340
 			if ($globalTransaction) $Connection->db->rollBack();
341 341
 			echo $e->getMessage();
342 342
 		}
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 			$Connection = new Connection();
355 355
 			$sth = $Connection->db->prepare($query);
356 356
 			$sth->execute();
357
-		} catch(PDOException $e) {
357
+		} catch (PDOException $e) {
358 358
 			return "error : ".$e->getMessage();
359 359
 		}
360 360
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 			$Connection = new Connection();
373 373
 			$sth = $Connection->db->prepare($query);
374 374
 			$sth->execute();
375
-		} catch(PDOException $e) {
375
+		} catch (PDOException $e) {
376 376
 			return "error : ".$e->getMessage();
377 377
 		}
378 378
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 			$Connection = new Connection();
388 388
 			$sth = $Connection->db->prepare($query);
389 389
 			$sth->execute();
390
-		} catch(PDOException $e) {
390
+		} catch (PDOException $e) {
391 391
 			return "error : ".$e->getMessage();
392 392
 		}
393 393
 	}
Please login to merge, or discard this patch.
Braces   +75 added lines, -27 removed lines patch added patch discarded remove patch
@@ -112,8 +112,11 @@  discard block
 block discarded – undo
112 112
 			$data = array();
113 113
 			if ($row['registration'] != '' && preg_match('/^[\w\-]+$/',$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) {
116
+					$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']));
117
+				} else {
118
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
119
+				}
117 120
 				$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
118 121
 				$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
119 122
 				if (!empty($aircraft_info)) {
@@ -129,17 +132,30 @@  discard block
 block discarded – undo
129 132
 					$data['aircraft_base'] = $owner_data['base'];
130 133
 					$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
131 134
 				}
132
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
133
-			if ($row['registration'] == '') $row['registration'] = 'NA';
134
-			if ($row['ident'] == '') $row['ident'] = 'NA';
135
+			} else {
136
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
137
+			}
138
+			if ($row['registration'] == '') {
139
+				$row['registration'] = 'NA';
140
+			}
141
+			if ($row['ident'] == '') {
142
+				$row['ident'] = 'NA';
143
+			}
135 144
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
136 145
 			if (isset($identicao[0])) {
137 146
 				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');
147
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
148
+						$icao = $row['ident'];
149
+					} else {
150
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
151
+					}
152
+				} else {
153
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
154
+				}
141 155
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
142
-			} else $icao = $row['ident'];
156
+			} else {
157
+				$icao = $row['ident'];
158
+			}
143 159
 			$icao = $Translation->checkTranslation($icao,false);
144 160
 			//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
145 161
 			if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -154,10 +170,14 @@  discard block
 block discarded – undo
154 170
 				//else echo 'No data...'."\n";
155 171
 			}
156 172
 			$data = array_merge($row,$data);
157
-			if ($data['ident'] == null) $data['ident'] = $icao;
173
+			if ($data['ident'] == null) {
174
+				$data['ident'] = $icao;
175
+			}
158 176
 			if ($data['title'] == null) {
159 177
 				$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
160
-			} else $data['message'] = strtolower($data['title']);
178
+			} else {
179
+				$data['message'] = strtolower($data['title']);
180
+			}
161 181
 			$ids = $Spotter->getAllIDByRegistration($data['registration']);
162 182
 			$date = $data['date'];
163 183
 			if (isset($ids[$date])) {
@@ -175,8 +195,9 @@  discard block
 block discarded – undo
175 195
 		if (isset($result)) {
176 196
 			$result[0]['query_number_rows'] = $i;
177 197
 			return $result;
198
+		} else {
199
+			return array();
178 200
 		}
179
-		else return array();
180 201
 	}
181 202
 	
182 203
 	/*
@@ -220,7 +241,9 @@  discard block
 block discarded – undo
220 241
 	*/
221 242
 	public function import($file) {
222 243
 		global $globalTransaction, $globalDebug;
223
-		if ($globalDebug) echo 'Import '.$file."\n";
244
+		if ($globalDebug) {
245
+			echo 'Import '.$file."\n";
246
+		}
224 247
 		$result = array();
225 248
 		if (file_exists($file)) {
226 249
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -231,8 +254,11 @@  discard block
 block discarded – undo
231 254
 				}
232 255
 				fclose($handle);
233 256
 			}
234
-			if (!empty($result)) $this->add($result,true);
235
-			elseif ($globalDebug) echo 'Nothing to import';
257
+			if (!empty($result)) {
258
+				$this->add($result,true);
259
+			} elseif ($globalDebug) {
260
+				echo 'Nothing to import';
261
+			}
236 262
 		}
237 263
 	}
238 264
 
@@ -268,14 +294,23 @@  discard block
 block discarded – undo
268 294
 					}
269 295
 				}
270 296
 				fclose($handle);
271
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
272
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
297
+			} elseif ($globalDebug) {
298
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
299
+			}
300
+		} elseif ($globalDebug) {
301
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
302
+		}
273 303
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
274
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
304
+		if (empty($result) && $globalDebug) {
305
+			echo 'Nothing to update';
306
+		}
275 307
 		foreach ($result as $file => $md5) {
276 308
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
277
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
278
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
309
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
310
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
311
+			} elseif ($globalDebug) {
312
+				echo 'Download '.$file.' failed';
313
+			}
279 314
 		}
280 315
 	}
281 316
 
@@ -292,13 +327,17 @@  discard block
 block discarded – undo
292 327
 		$Image = new Image();
293 328
 		$Spotter = new Spotter();
294 329
 
295
-		if (empty($crash)) return false;
330
+		if (empty($crash)) {
331
+			return false;
332
+		}
296 333
 		if (!$new) {
297 334
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
298 335
 			$sthd = $Connection->db->prepare($query_delete);
299 336
 			$sthd->execute(array(':source' => $crash[0]['source']));
300 337
 		}
301
-		if ($globalTransaction) $Connection->db->beginTransaction();
338
+		if ($globalTransaction) {
339
+			$Connection->db->beginTransaction();
340
+		}
302 341
 		$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);
303 342
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
304 343
 		$sth_check = $Connection->db->prepare($query_check);
@@ -313,7 +352,9 @@  discard block
 block discarded – undo
313 352
 					return $value === "" ? NULL : $value;
314 353
 				}, $cr);
315 354
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
316
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
355
+					if (strpos($cr['registration'],'-') === FALSE) {
356
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
357
+					}
317 358
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
318 359
 					$sth_check->execute($query_check_values);
319 360
 					$result_check = $sth_check->fetch(PDO::FETCH_ASSOC);
@@ -335,9 +376,13 @@  discard block
 block discarded – undo
335 376
 					$Connection->db->beginTransaction();
336 377
 				}
337 378
 			}
338
-			if ($globalTransaction) $Connection->db->commit();
379
+			if ($globalTransaction) {
380
+				$Connection->db->commit();
381
+			}
339 382
 		} catch(PDOException $e) {
340
-			if ($globalTransaction) $Connection->db->rollBack();
383
+			if ($globalTransaction) {
384
+				$Connection->db->rollBack();
385
+			}
341 386
 			echo $e->getMessage();
342 387
 		}
343 388
 		$sth_check->closeCursor();
@@ -376,8 +421,11 @@  discard block
 block discarded – undo
376 421
 			return "error : ".$e->getMessage();
377 422
 		}
378 423
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
379
-		if ($row['nb'] > 0) return false;
380
-		else return true;
424
+		if ($row['nb'] > 0) {
425
+			return false;
426
+		} else {
427
+			return true;
428
+		}
381 429
 	}
382 430
 
383 431
 	public static function insert_last_accidents_update() {
Please login to merge, or discard this patch.