Completed
Push — master ( db2756...3d0574 )
by Yannick
29:36
created
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-departure-airport.php 3 patches
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.
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.
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 to %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']);
17
+	$title = sprintf(_("Most Common Departure Airports 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($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 {
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	include('airport-sub-menu.php');
57 57
 	print '<div class="column">';
58 58
 	print '<h2>'._("Most Common Departure Airports").'</h2>';
59
-	print '<p>'.sprintf(_("The statistic below shows all departure airports of flights to <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>';
59
+	print '<p>'.sprintf(_("The statistic below shows all departure airports of flights to <strong>%s, %s (%s)</strong>."), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']).'</p>';
60 60
 	$airport_airport_array = $Spotter->countAllDepartureAirportsByAirport($airport);
61 61
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
62 62
 	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 '<script>';
66 66
 	print 'var series = [';
67 67
 	$airport_data = '';
68
-	foreach($airport_airport_array as $airport_item)
68
+	foreach ($airport_airport_array as $airport_item)
69 69
 	{
70 70
 		$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
71 71
 	}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	print '</thead>';
121 121
 	print '<tbody>';
122 122
 	$i = 1;
123
-	foreach($airport_airport_array as $airport_item)
123
+	foreach ($airport_airport_array as $airport_item)
124 124
 	{
125 125
 		print '<tr>';
126 126
 		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-airline.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 to/from %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']);
17
+	$title = sprintf(_("Most Common Airlines 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,14 +57,14 @@  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").'</h2>';
60
-	print '<p>'.sprintf(_("The statistic below shows the most common airlines 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 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->countAllAirlinesByAirport($airport);
63 63
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
64 64
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3pie.min.js"></script>';
65 65
 	print '<div id="chart" class="chart" width="100%"></div><script>';
66 66
 	$airline_data = '';
67
-	foreach($airline_array as $airline_item)
67
+	foreach ($airline_array as $airline_item)
68 68
 	{
69 69
 		$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
70 70
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		print '</thead>';
92 92
 		print '<tbody>';
93 93
 		$i = 1;
94
-		foreach($airline_array as $airline_item)
94
+		foreach ($airline_array as $airline_item)
95 95
 		{
96 96
 			print '<tr>';
97 97
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
airport-statistics-arrival-airport.php 3 patches
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.
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.
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 from %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']);
17
+	$title = sprintf(_("Most Common Arrival Airports 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").'</h2>';
60
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports 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 of flights from <strong>%s, %s (%s)</strong>."), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']).'</p>';
61 61
 	$airport_airport_array = $Spotter->countAllArrivalAirportsByAirport($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>';
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	print '<script>';
67 67
 	print 'var series = [';
68 68
 	$airport_data = '';
69
-	foreach($airport_airport_array as $airport_item)
69
+	foreach ($airport_airport_array as $airport_item)
70 70
 	{
71 71
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
72 72
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	print '</thead>';
122 122
 	print '<tbody>';
123 123
 	$i = 1;
124
-	foreach($airport_airport_array as $airport_item)
124
+	foreach ($airport_airport_array as $airport_item)
125 125
 	{
126 126
 		print '<tr>';
127 127
 		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.
airport-statistics-time.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   +10 added lines, -10 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 Time of Day to/from %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']);
17
+	$title = sprintf(_("Most Common Time of Day to/from %s, %s (%s)"), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']);
18 18
 
19 19
 	require_once('header.php');
20 20
 	print '<div class="select-item">';
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 	$airport_names = $Stats->getAllAirportNames();
26 26
 	if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
27 27
 	ksort($airport_names);
28
-	foreach($airport_names as $airport_name)
28
+	foreach ($airport_names as $airport_name)
29 29
 	{
30
-		if($airport == $airport_name['airport_icao'])
30
+		if ($airport == $airport_name['airport_icao'])
31 31
 		{
32 32
 			print '<option value="'.$airport_name['airport_icao'].'" selected="selected">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>';
33 33
 		} else {
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	include('airport-sub-menu.php');
59 59
 	print '<div class="column">';
60 60
 	print '<h2>'._("Most Common Time of Day").'</h2>';
61
-	print '<p>'.sprintf(_("The statistic below shows the most common time of day to/from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>';
61
+	print '<p>'.sprintf(_("The statistic below shows the most common time of day to/from <strong>%s, %s (%s)</strong>."), $airport_array[0]['city'], $airport_array[0]['name'], $airport_array[0]['icao']).'</p>';
62 62
 
63 63
 	$hour_array = $Spotter->countAllHoursByAirport($airport);
64 64
 	print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 	$hour_data = '';
69 69
 	$hour_cnt = '';
70 70
 	$last = 0;
71
-	foreach($hour_array as $hour_item)
71
+	foreach ($hour_array as $hour_item)
72 72
 	{
73
-		while($last != $hour_item['hour_name']) {
73
+		while ($last != $hour_item['hour_name']) {
74 74
 			$hour_data .= '"'.$last.':00",';
75 75
 			$hour_cnt .= '0,';
76 76
 			$last++;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		$hour_cnt .= $hour_item['hour_count'].',';
81 81
 	}
82 82
 	$hour_data = "[".substr($hour_data, 0, -1)."]";
83
-	$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
83
+	$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
84 84
 	print 'c3.generate({
85 85
 	    bindto: "#chartHour",
86 86
 	    data: {
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		print '</thead>';
104 104
 		print '<tbody>';
105 105
 		$i = 1;
106
-		foreach($hour_array as $hour_item)
106
+		foreach ($hour_array as $hour_item)
107 107
 		{
108 108
 			print '<tr>';
109 109
 			print '<td>'.$hour_item['hour_name'].':00</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   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 	* @param String $date get data for a date
29 29
 	* @return Array Return Accidents data in array
30 30
 	*/
31
-	public function getAccidentData($limit = '',$type = '',$date = '') {
31
+	public function getAccidentData($limit = '', $type = '', $date = '') {
32 32
 		global $globalURL, $globalDBdriver;
33 33
 		$Image = new Image($this->db);
34 34
 		$Spotter = new Spotter($this->db);
35 35
 		$Translation = new Translation($this->db);
36
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
36
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
37 37
 		date_default_timezone_set('UTC');
38 38
 		$result = array();
39 39
 		$limit_query = '';
40 40
 		if ($limit != "")
41 41
 		{
42 42
 			$limit_array = explode(",", $limit);
43
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
44
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
43
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
44
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
45 45
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
46 46
 			{
47 47
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -50,29 +50,29 @@  discard block
 block discarded – undo
50 50
 
51 51
 		if ($type != '') {
52 52
 			if ($date != '') {
53
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
53
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
54 54
 					$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;
55 55
 					//$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;
56
-					$query_values = array(':type' => $type,':date' => $date);
57
-				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) {
56
+					$query_values = array(':type' => $type, ':date' => $date);
57
+				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) {
58 58
 					$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;
59
-					$query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31');
60
-				} elseif (preg_match("/^[0-9]{4}$/",$date)) {
59
+					$query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31');
60
+				} elseif (preg_match("/^[0-9]{4}$/", $date)) {
61 61
 					if ($globalDBdriver == 'mysql') {
62 62
 						$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;
63 63
 					} else {
64 64
 						$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;
65 65
 					}
66
-					$query_values = array(':type' => $type,':date' => $date);
66
+					$query_values = array(':type' => $type, ':date' => $date);
67 67
 				} else {
68 68
 					$date = $date.'%';
69 69
 					if ($globalDBdriver == 'mysql') {
70 70
 						$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;
71
-						$query_values = array(':type' => $type,':date' => $date);
71
+						$query_values = array(':type' => $type, ':date' => $date);
72 72
 					} else {
73 73
 						$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;
74 74
 						//$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;
75
-						$query_values = array(':type' => $type,':date' => $date);
75
+						$query_values = array(':type' => $type, ':date' => $date);
76 76
 					}
77 77
 				}
78 78
 			} else {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			}
83 83
 		} else {
84 84
 			if ($date != '') {
85
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
85
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
86 86
 					$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;
87 87
 					//$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;
88 88
 				} else {
@@ -100,17 +100,17 @@  discard block
 block discarded – undo
100 100
 		try {
101 101
 			$sth = $this->db->prepare($query);
102 102
 			$sth->execute($query_values);
103
-		} catch(PDOException $e) {
103
+		} catch (PDOException $e) {
104 104
 			echo "error : ".$e->getMessage();
105 105
 		}
106 106
 		$i = 0;
107 107
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
108
-			if (preg_match('/^[\w\-]+$/',$row['registration'])) {
108
+			if (preg_match('/^[\w\-]+$/', $row['registration'])) {
109 109
 				$data = array();
110 110
 				if ($row['registration'] != '') {
111 111
 					$image_array = $Image->getSpotterImage($row['registration']);
112
-					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']));
113
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
112
+					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']));
113
+					else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
114 114
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
115 115
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
116 116
 					if (!empty($aircraft_info)) {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 						$data['aircraft_name'] = $aircraft_info[0]['type'];
119 119
 						$data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer'];
120 120
 					} else {
121
-						$data = array_merge($data,array('aircraft_type' => 'NA'));
121
+						$data = array_merge($data, array('aircraft_type' => 'NA'));
122 122
 					}
123 123
 					$owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']);
124 124
 					if (!empty($owner_data)) {
@@ -126,18 +126,18 @@  discard block
 block discarded – undo
126 126
 						$data['aircraft_base'] = $owner_data['base'];
127 127
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
128 128
 					}
129
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
129
+				} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
130 130
 				if ($row['registration'] == '') $row['registration'] = 'NA';
131 131
 				if ($row['ident'] == '') $row['ident'] = 'NA';
132
-				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
132
+				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3));
133 133
 				if (isset($identicao[0])) {
134
-					if (substr($row['ident'],0,2) == 'AF') {
135
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
136
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
137
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
138
-					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
134
+					if (substr($row['ident'], 0, 2) == 'AF') {
135
+						if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
136
+						else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
137
+					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
138
+					$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
139 139
 				} else $icao = $row['ident'];
140
-				$icao = $Translation->checkTranslation($icao,false);
140
+				$icao = $Translation->checkTranslation($icao, false);
141 141
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
142 142
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
143 143
 					//echo 'Check airline info... for '.$row['airline_name'].' ';
@@ -146,16 +146,16 @@  discard block
 block discarded – undo
146 146
 					if (!empty($airline_info)) {
147 147
 						//echo 'data found !'."\n";
148 148
 						//print_r($airline_info);
149
-						$data = array_merge($data,$airline_info);
149
+						$data = array_merge($data, $airline_info);
150 150
 					} 
151 151
 					//else echo 'No data...'."\n";
152 152
 				}
153
-				$data = array_merge($row,$data);
153
+				$data = array_merge($row, $data);
154 154
 				if ($data['ident'] == null) $data['ident'] = $icao;
155 155
 				if ($data['title'] == null) {
156 156
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
157 157
 				} else $data['message'] = strtolower($data['title']);
158
-				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
158
+				$ids = $Spotter->getAllIDByRegistration($data['registration'], true);
159 159
 				$date = $data['date'];
160 160
 				if (isset($ids[$date])) {
161 161
 					$data['spotted'] = TRUE;
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,15 +311,15 @@  discard block
 block discarded – undo
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
 							$imgchk = $Image->getSpotterImage($cr['registration']);
324 324
 							if (empty($imgchk)) {
325 325
 								if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
@@ -329,16 +329,16 @@  discard block
 block discarded – undo
329 329
 							// elseif ($globalDebug) echo 'Image already in DB'."\n";
330 330
 						}
331 331
 						if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
332
-						$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
332
+						$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date']));
333 333
 					}
334 334
 				}
335
-				if ($globalTransaction && $j % 1000 == 0) {
335
+				if ($globalTransaction && $j%1000 == 0) {
336 336
 					$Connection->db->commit();
337 337
 					$Connection->db->beginTransaction();
338 338
 				}
339 339
 			}
340 340
 			if ($globalTransaction) $Connection->db->commit();
341
-		} catch(PDOException $e) {
341
+		} catch (PDOException $e) {
342 342
 			if ($globalTransaction) $Connection->db->rollBack();
343 343
 			echo $e->getMessage();
344 344
 		}
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 			$Connection = new Connection();
357 357
 			$sth = $Connection->db->prepare($query);
358 358
 			$sth->execute();
359
-		} catch(PDOException $e) {
359
+		} catch (PDOException $e) {
360 360
 			return "error : ".$e->getMessage();
361 361
 		}
362 362
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 			$Connection = new Connection();
375 375
 			$sth = $Connection->db->prepare($query);
376 376
 			$sth->execute();
377
-		} catch(PDOException $e) {
377
+		} catch (PDOException $e) {
378 378
 			return "error : ".$e->getMessage();
379 379
 		}
380 380
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391 391
 			$sth->execute();
392
-		} catch(PDOException $e) {
392
+		} catch (PDOException $e) {
393 393
 			return "error : ".$e->getMessage();
394 394
 		}
395 395
 	}
Please login to merge, or discard this patch.
Braces   +87 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
 	public function __construct($dbc = null) {
21 21
 		$Connection = new Connection($dbc);
22 22
 		$this->db = $Connection->db();
23
-		if ($this->db === null) die('Error: No DB connection. (Accident)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Accident)');
25
+		}
24 26
 	}
25 27
 
26 28
 	/*
@@ -123,8 +125,11 @@  discard block
 block discarded – undo
123 125
 				$data = array();
124 126
 				if ($row['registration'] != '') {
125 127
 					$image_array = $Image->getSpotterImage($row['registration']);
126
-					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']));
127
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
128
+					if (count($image_array) > 0) {
129
+						$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']));
130
+					} else {
131
+						$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
132
+					}
128 133
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
129 134
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
130 135
 					if (!empty($aircraft_info)) {
@@ -140,17 +145,30 @@  discard block
 block discarded – undo
140 145
 						$data['aircraft_base'] = $owner_data['base'];
141 146
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
142 147
 					}
143
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
144
-				if ($row['registration'] == '') $row['registration'] = 'NA';
145
-				if ($row['ident'] == '') $row['ident'] = 'NA';
148
+				} else {
149
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
150
+				}
151
+				if ($row['registration'] == '') {
152
+					$row['registration'] = 'NA';
153
+				}
154
+				if ($row['ident'] == '') {
155
+					$row['ident'] = 'NA';
156
+				}
146 157
 				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
147 158
 				if (isset($identicao[0])) {
148 159
 					if (substr($row['ident'],0,2) == 'AF') {
149
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
150
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
151
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
160
+						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
161
+							$icao = $row['ident'];
162
+						} else {
163
+							$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
164
+						}
165
+					} else {
166
+						$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
167
+					}
152 168
 					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
153
-				} else $icao = $row['ident'];
169
+				} else {
170
+					$icao = $row['ident'];
171
+				}
154 172
 				$icao = $Translation->checkTranslation($icao,false);
155 173
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
156 174
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -165,10 +183,14 @@  discard block
 block discarded – undo
165 183
 					//else echo 'No data...'."\n";
166 184
 				}
167 185
 				$data = array_merge($row,$data);
168
-				if ($data['ident'] == null) $data['ident'] = $icao;
186
+				if ($data['ident'] == null) {
187
+					$data['ident'] = $icao;
188
+				}
169 189
 				if ($data['title'] == null) {
170 190
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
171
-				} else $data['message'] = strtolower($data['title']);
191
+				} else {
192
+					$data['message'] = strtolower($data['title']);
193
+				}
172 194
 				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
173 195
 				$date = $data['date'];
174 196
 				if (isset($ids[$date])) {
@@ -187,8 +209,9 @@  discard block
 block discarded – undo
187 209
 		if (isset($result)) {
188 210
 			$result[0]['query_number_rows'] = $i;
189 211
 			return $result;
212
+		} else {
213
+			return array();
190 214
 		}
191
-		else return array();
192 215
 	}
193 216
 
194 217
 	/*
@@ -233,7 +256,9 @@  discard block
 block discarded – undo
233 256
 	*/
234 257
 	public function import($file) {
235 258
 		global $globalTransaction, $globalDebug;
236
-		if ($globalDebug) echo 'Import '.$file."\n";
259
+		if ($globalDebug) {
260
+			echo 'Import '.$file."\n";
261
+		}
237 262
 		$result = array();
238 263
 		if (file_exists($file)) {
239 264
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -244,8 +269,11 @@  discard block
 block discarded – undo
244 269
 				}
245 270
 				fclose($handle);
246 271
 			}
247
-			if (!empty($result)) $this->add($result,true);
248
-			elseif ($globalDebug) echo 'Nothing to import';
272
+			if (!empty($result)) {
273
+				$this->add($result,true);
274
+			} elseif ($globalDebug) {
275
+				echo 'Nothing to import';
276
+			}
249 277
 		}
250 278
 	}
251 279
 
@@ -281,14 +309,23 @@  discard block
 block discarded – undo
281 309
 					}
282 310
 				}
283 311
 				fclose($handle);
284
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
285
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
312
+			} elseif ($globalDebug) {
313
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
314
+			}
315
+		} elseif ($globalDebug) {
316
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
317
+		}
286 318
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
287
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
319
+		if (empty($result) && $globalDebug) {
320
+			echo 'Nothing to update';
321
+		}
288 322
 		foreach ($result as $file => $md5) {
289 323
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
290
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
291
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
324
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
325
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
326
+			} elseif ($globalDebug) {
327
+				echo 'Download '.$file.' failed';
328
+			}
292 329
 		}
293 330
 	}
294 331
 
@@ -305,13 +342,17 @@  discard block
 block discarded – undo
305 342
 		$Image = new Image($this->db);
306 343
 		$Spotter = new Spotter($this->db);
307 344
 
308
-		if (empty($crash)) return false;
345
+		if (empty($crash)) {
346
+			return false;
347
+		}
309 348
 		if (!$new) {
310 349
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
311 350
 			$sthd = $Connection->db->prepare($query_delete);
312 351
 			$sthd->execute(array(':source' => $crash[0]['source']));
313 352
 		}
314
-		if ($globalTransaction) $Connection->db->beginTransaction();
353
+		if ($globalTransaction) {
354
+			$Connection->db->beginTransaction();
355
+		}
315 356
 		$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);
316 357
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
317 358
 		$sth_check = $Connection->db->prepare($query_check);
@@ -326,7 +367,9 @@  discard block
 block discarded – undo
326 367
 					return $value === "" ? NULL : $value;
327 368
 				}, $cr);
328 369
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
329
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
370
+					if (strpos($cr['registration'],'-') === FALSE) {
371
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
372
+					}
330 373
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
331 374
 					$sth_check->execute($query_check_values);
332 375
 					$result_check = $sth_check->fetch(PDO::FETCH_ASSOC);
@@ -336,13 +379,19 @@  discard block
 block discarded – undo
336 379
 						if ($cr['date'] > time()-(30*86400)) {
337 380
 							$imgchk = $Image->getSpotterImage($cr['registration']);
338 381
 							if (empty($imgchk)) {
339
-								if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
382
+								if ($globalDebug) {
383
+									echo "\t".'Get image for '.$cr['registration'].'...';
384
+								}
340 385
 								$Image->addSpotterImage($cr['registration']);
341
-								if ($globalDebug) echo "\t".'Done'."\n";
386
+								if ($globalDebug) {
387
+									echo "\t".'Done'."\n";
388
+								}
342 389
 							}
343 390
 							// elseif ($globalDebug) echo 'Image already in DB'."\n";
344 391
 						}
345
-						if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
392
+						if ($cr['title'] == '') {
393
+							$cr['title'] = $cr['registration'].' '.$cr['type'];
394
+						}
346 395
 						$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
347 396
 					}
348 397
 				}
@@ -351,9 +400,13 @@  discard block
 block discarded – undo
351 400
 					$Connection->db->beginTransaction();
352 401
 				}
353 402
 			}
354
-			if ($globalTransaction) $Connection->db->commit();
403
+			if ($globalTransaction) {
404
+				$Connection->db->commit();
405
+			}
355 406
 		} catch(PDOException $e) {
356
-			if ($globalTransaction) $Connection->db->rollBack();
407
+			if ($globalTransaction) {
408
+				$Connection->db->rollBack();
409
+			}
357 410
 			echo $e->getMessage();
358 411
 		}
359 412
 		$sth_check->closeCursor();
@@ -392,8 +445,11 @@  discard block
 block discarded – undo
392 445
 			return "error : ".$e->getMessage();
393 446
 		}
394 447
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
395
-		if ($row['nb'] > 0) return false;
396
-		else return true;
448
+		if ($row['nb'] > 0) {
449
+			return false;
450
+		} else {
451
+			return true;
452
+		}
397 453
 	}
398 454
 
399 455
 	public static function insert_last_accidents_update() {
Please login to merge, or discard this patch.