Completed
Push — master ( 7332ae...d8eaa0 )
by Yannick
177:55 queued 153:21
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   +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,19 +102,19 @@  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;
109 109
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
110 110
 			//print_r($row);
111 111
 			//echo $row['flightaware_id'];
112
-			if (preg_match('/^[\w\-]+$/',$row['registration'])) {
112
+			if (preg_match('/^[\w\-]+$/', $row['registration'])) {
113 113
 				$data = array();
114 114
 				if ($row['registration'] != '') {
115 115
 					$image_array = $Image->getSpotterImage($row['registration']);
116
-					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']));
117
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
116
+					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']));
117
+					else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
118 118
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
119 119
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
120 120
 					if (!empty($aircraft_info)) {
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 						$data['aircraft_name'] = $aircraft_info[0]['type'];
123 123
 						$data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer'];
124 124
 					} else {
125
-						$data = array_merge($data,array('aircraft_type' => 'NA'));
125
+						$data = array_merge($data, array('aircraft_type' => 'NA'));
126 126
 					}
127 127
 					$owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']);
128 128
 					if (!empty($owner_data)) {
@@ -130,18 +130,18 @@  discard block
 block discarded – undo
130 130
 						$data['aircraft_base'] = $owner_data['base'];
131 131
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
132 132
 					}
133
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
133
+				} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
134 134
 				if ($row['registration'] == '') $row['registration'] = 'NA';
135 135
 				if ($row['ident'] == '') $row['ident'] = 'NA';
136
-				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
136
+				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3));
137 137
 				if (isset($identicao[0])) {
138
-					if (substr($row['ident'],0,2) == 'AF') {
139
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
140
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
141
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
142
-					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
138
+					if (substr($row['ident'], 0, 2) == 'AF') {
139
+						if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
140
+						else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
141
+					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
142
+					$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
143 143
 				} else $icao = $row['ident'];
144
-				$icao = $Translation->checkTranslation($icao,false);
144
+				$icao = $Translation->checkTranslation($icao, false);
145 145
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
146 146
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
147 147
 					//echo 'Check airline info... for '.$row['airline_name'].' ';
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 					if (!empty($airline_info)) {
151 151
 						//echo 'data found !'."\n";
152 152
 						//print_r($airline_info);
153
-						$data = array_merge($data,$airline_info);
153
+						$data = array_merge($data, $airline_info);
154 154
 					} 
155 155
 					//else echo 'No data...'."\n";
156 156
 				}
157
-				$data = array_merge($row,$data);
157
+				$data = array_merge($row, $data);
158 158
 				if ($data['ident'] == null) $data['ident'] = $icao;
159 159
 				if ($data['title'] == null) {
160 160
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		try {
191 191
 			$sth = $this->db->prepare($query);
192 192
 			$sth->execute();
193
-		} catch(PDOException $e) {
193
+		} catch (PDOException $e) {
194 194
 			echo "Error : ".$e->getMessage();
195 195
 		}
196 196
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 		try {
211 211
 			$sth = $this->db->prepare($query);
212 212
 			$sth->execute();
213
-		} catch(PDOException $e) {
213
+		} catch (PDOException $e) {
214 214
 			echo "Error : ".$e->getMessage();
215 215
 		}
216 216
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -225,15 +225,15 @@  discard block
 block discarded – undo
225 225
 		if ($globalDebug) echo 'Import '.$file."\n";
226 226
 		$result = array();
227 227
 		if (file_exists($file)) {
228
-			if (($handle = fopen($file,'r')) !== FALSE) {
229
-				while (($data = fgetcsv($handle,2000,",")) !== FALSE) {
228
+			if (($handle = fopen($file, 'r')) !== FALSE) {
229
+				while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
230 230
 					if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') {
231
-						$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');
231
+						$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');
232 232
 					}
233 233
 				}
234 234
 				fclose($handle);
235 235
 			}
236
-			if (!empty($result)) $this->add($result,true);
236
+			if (!empty($result)) $this->add($result, true);
237 237
 			elseif ($globalDebug) echo 'Nothing to import';
238 238
 		}
239 239
 	}
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 		$all_md5_new = array();
250 250
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
251 251
 			if ($this->check_accidents_nb() > 0) {
252
-				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
253
-					while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
252
+				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
253
+					while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
254 254
 						if (isset($data[1])) {
255 255
 							$year = $data[0];
256 256
 							$all_md5[$year] = $data[1];
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 				}
261 261
 			}
262 262
 		}
263
-		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5');
263
+		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5');
264 264
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
265
-			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
266
-				while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
265
+			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
266
+				while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
267 267
 					if (isset($data[1])) {
268 268
 						$year = $data[0];
269 269
 						$all_md5_new[$year] = $data[1];
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 				fclose($handle);
273 273
 			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
274 274
 		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
275
-		$result = $Common->arr_diff($all_md5_new,$all_md5);
275
+		$result = $Common->arr_diff($all_md5_new, $all_md5);
276 276
 		if (empty($result) && $globalDebug) echo 'Nothing to update';
277 277
 		foreach ($result as $file => $md5) {
278
-			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
278
+			$Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file);
279 279
 			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
280 280
 			elseif ($globalDebug) echo 'Download '.$file.' failed';
281 281
 		}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	* Add data to DB
286 286
 	* @param Array $crash An array with accidents/incidents data
287 287
 	*/
288
-	public function add($crash,$new = false) {
288
+	public function add($crash, $new = false) {
289 289
 		global $globalTransaction, $globalDebug;
290 290
 		require_once('class.Connection.php');
291 291
 		require_once('class.Image.php');
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 			$sthd->execute(array(':source' => $crash[0]['source']));
302 302
 		}
303 303
 		if ($globalTransaction) $Connection->db->beginTransaction();
304
-		$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);
304
+		$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);
305 305
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
306 306
 		$sth_check = $Connection->db->prepare($query_check);
307 307
 		$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)';
@@ -314,15 +314,15 @@  discard block
 block discarded – undo
314 314
 				$cr = array_map(function($value) {
315 315
 					return $value === "" ? NULL : $value;
316 316
 				}, $cr);
317
-				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
318
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
319
-					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
317
+				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) {
318
+					if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
319
+					$query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']);
320 320
 					$sth_check->execute($query_check_values);
321 321
 					$result_check = $sth_check->fetch(PDO::FETCH_ASSOC);
322 322
 					if ($result_check['nb'] == 0) {
323
-						$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']);
323
+						$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']);
324 324
 						$sth->execute($query_values);
325
-						if ($cr['date'] > time()-(30*86400)) {
325
+						if ($cr['date'] > time() - (30*86400)) {
326 326
 							if (empty($Image->getSpotterImage($cr['registration']))) {
327 327
 								if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
328 328
 								$Image->addSpotterImage($cr['registration']);
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 							// elseif ($globalDebug) echo 'Image already in DB'."\n";
332 332
 						}
333 333
 						if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
334
-						$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
334
+						$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date']));
335 335
 					}
336 336
 				}
337
-				if ($globalTransaction && $j % 1000 == 0) {
337
+				if ($globalTransaction && $j%1000 == 0) {
338 338
 					$Connection->db->commit();
339 339
 					$Connection->db->beginTransaction();
340 340
 				}
341 341
 			}
342 342
 			if ($globalTransaction) $Connection->db->commit();
343
-		} catch(PDOException $e) {
343
+		} catch (PDOException $e) {
344 344
 			if ($globalTransaction) $Connection->db->rollBack();
345 345
 			echo $e->getMessage();
346 346
 		}
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 			$Connection = new Connection();
359 359
 			$sth = $Connection->db->prepare($query);
360 360
 			$sth->execute();
361
-		} catch(PDOException $e) {
361
+		} catch (PDOException $e) {
362 362
 			return "error : ".$e->getMessage();
363 363
 		}
364 364
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 			$Connection = new Connection();
377 377
 			$sth = $Connection->db->prepare($query);
378 378
 			$sth->execute();
379
-		} catch(PDOException $e) {
379
+		} catch (PDOException $e) {
380 380
 			return "error : ".$e->getMessage();
381 381
 		}
382 382
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393 393
 			$sth->execute();
394
-		} catch(PDOException $e) {
394
+		} catch (PDOException $e) {
395 395
 			return "error : ".$e->getMessage();
396 396
 		}
397 397
 	}
Please login to merge, or discard this patch.
Braces   +84 added lines, -30 removed lines patch added patch discarded remove patch
@@ -113,8 +113,11 @@  discard block
 block discarded – undo
113 113
 				$data = array();
114 114
 				if ($row['registration'] != '') {
115 115
 					$image_array = $Image->getSpotterImage($row['registration']);
116
-					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']));
117
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
116
+					if (count($image_array) > 0) {
117
+						$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']));
118
+					} else {
119
+						$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
120
+					}
118 121
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
119 122
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
120 123
 					if (!empty($aircraft_info)) {
@@ -130,17 +133,30 @@  discard block
 block discarded – undo
130 133
 						$data['aircraft_base'] = $owner_data['base'];
131 134
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
132 135
 					}
133
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
134
-				if ($row['registration'] == '') $row['registration'] = 'NA';
135
-				if ($row['ident'] == '') $row['ident'] = 'NA';
136
+				} else {
137
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
138
+				}
139
+				if ($row['registration'] == '') {
140
+					$row['registration'] = 'NA';
141
+				}
142
+				if ($row['ident'] == '') {
143
+					$row['ident'] = 'NA';
144
+				}
136 145
 				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
137 146
 				if (isset($identicao[0])) {
138 147
 					if (substr($row['ident'],0,2) == 'AF') {
139
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
140
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
141
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
148
+						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
149
+							$icao = $row['ident'];
150
+						} else {
151
+							$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
152
+						}
153
+					} else {
154
+						$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
155
+					}
142 156
 					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
143
-				} else $icao = $row['ident'];
157
+				} else {
158
+					$icao = $row['ident'];
159
+				}
144 160
 				$icao = $Translation->checkTranslation($icao,false);
145 161
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
146 162
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -155,10 +171,14 @@  discard block
 block discarded – undo
155 171
 					//else echo 'No data...'."\n";
156 172
 				}
157 173
 				$data = array_merge($row,$data);
158
-				if ($data['ident'] == null) $data['ident'] = $icao;
174
+				if ($data['ident'] == null) {
175
+					$data['ident'] = $icao;
176
+				}
159 177
 				if ($data['title'] == null) {
160 178
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
161
-				} else $data['message'] = strtolower($data['title']);
179
+				} else {
180
+					$data['message'] = strtolower($data['title']);
181
+				}
162 182
 				$ids = $Spotter->getAllIDByRegistration($data['registration']);
163 183
 				$date = $data['date'];
164 184
 				if (isset($ids[$date])) {
@@ -177,8 +197,9 @@  discard block
 block discarded – undo
177 197
 		if (isset($result)) {
178 198
 			$result[0]['query_number_rows'] = $i;
179 199
 			return $result;
200
+		} else {
201
+			return array();
180 202
 		}
181
-		else return array();
182 203
 	}
183 204
 	
184 205
 	/*
@@ -222,7 +243,9 @@  discard block
 block discarded – undo
222 243
 	*/
223 244
 	public function import($file) {
224 245
 		global $globalTransaction, $globalDebug;
225
-		if ($globalDebug) echo 'Import '.$file."\n";
246
+		if ($globalDebug) {
247
+			echo 'Import '.$file."\n";
248
+		}
226 249
 		$result = array();
227 250
 		if (file_exists($file)) {
228 251
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -233,8 +256,11 @@  discard block
 block discarded – undo
233 256
 				}
234 257
 				fclose($handle);
235 258
 			}
236
-			if (!empty($result)) $this->add($result,true);
237
-			elseif ($globalDebug) echo 'Nothing to import';
259
+			if (!empty($result)) {
260
+				$this->add($result,true);
261
+			} elseif ($globalDebug) {
262
+				echo 'Nothing to import';
263
+			}
238 264
 		}
239 265
 	}
240 266
 
@@ -270,14 +296,23 @@  discard block
 block discarded – undo
270 296
 					}
271 297
 				}
272 298
 				fclose($handle);
273
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
274
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
299
+			} elseif ($globalDebug) {
300
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
301
+			}
302
+		} elseif ($globalDebug) {
303
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
304
+		}
275 305
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
276
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
306
+		if (empty($result) && $globalDebug) {
307
+			echo 'Nothing to update';
308
+		}
277 309
 		foreach ($result as $file => $md5) {
278 310
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
279
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
280
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
311
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
312
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
313
+			} elseif ($globalDebug) {
314
+				echo 'Download '.$file.' failed';
315
+			}
281 316
 		}
282 317
 	}
283 318
 
@@ -294,13 +329,17 @@  discard block
 block discarded – undo
294 329
 		$Image = new Image();
295 330
 		$Spotter = new Spotter();
296 331
 
297
-		if (empty($crash)) return false;
332
+		if (empty($crash)) {
333
+			return false;
334
+		}
298 335
 		if (!$new) {
299 336
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
300 337
 			$sthd = $Connection->db->prepare($query_delete);
301 338
 			$sthd->execute(array(':source' => $crash[0]['source']));
302 339
 		}
303
-		if ($globalTransaction) $Connection->db->beginTransaction();
340
+		if ($globalTransaction) {
341
+			$Connection->db->beginTransaction();
342
+		}
304 343
 		$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);
305 344
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
306 345
 		$sth_check = $Connection->db->prepare($query_check);
@@ -315,7 +354,9 @@  discard block
 block discarded – undo
315 354
 					return $value === "" ? NULL : $value;
316 355
 				}, $cr);
317 356
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
318
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
357
+					if (strpos($cr['registration'],'-') === FALSE) {
358
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
359
+					}
319 360
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
320 361
 					$sth_check->execute($query_check_values);
321 362
 					$result_check = $sth_check->fetch(PDO::FETCH_ASSOC);
@@ -324,13 +365,19 @@  discard block
 block discarded – undo
324 365
 						$sth->execute($query_values);
325 366
 						if ($cr['date'] > time()-(30*86400)) {
326 367
 							if (empty($Image->getSpotterImage($cr['registration']))) {
327
-								if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
368
+								if ($globalDebug) {
369
+									echo "\t".'Get image for '.$cr['registration'].'...';
370
+								}
328 371
 								$Image->addSpotterImage($cr['registration']);
329
-								if ($globalDebug) echo "\t".'Done'."\n";
372
+								if ($globalDebug) {
373
+									echo "\t".'Done'."\n";
374
+								}
330 375
 							}
331 376
 							// elseif ($globalDebug) echo 'Image already in DB'."\n";
332 377
 						}
333
-						if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
378
+						if ($cr['title'] == '') {
379
+							$cr['title'] = $cr['registration'].' '.$cr['type'];
380
+						}
334 381
 						$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
335 382
 					}
336 383
 				}
@@ -339,9 +386,13 @@  discard block
 block discarded – undo
339 386
 					$Connection->db->beginTransaction();
340 387
 				}
341 388
 			}
342
-			if ($globalTransaction) $Connection->db->commit();
389
+			if ($globalTransaction) {
390
+				$Connection->db->commit();
391
+			}
343 392
 		} catch(PDOException $e) {
344
-			if ($globalTransaction) $Connection->db->rollBack();
393
+			if ($globalTransaction) {
394
+				$Connection->db->rollBack();
395
+			}
345 396
 			echo $e->getMessage();
346 397
 		}
347 398
 		$sth_check->closeCursor();
@@ -380,8 +431,11 @@  discard block
 block discarded – undo
380 431
 			return "error : ".$e->getMessage();
381 432
 		}
382 433
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
383
-		if ($row['nb'] > 0) return false;
384
-		else return true;
434
+		if ($row['nb'] > 0) {
435
+			return false;
436
+		} else {
437
+			return true;
438
+		}
385 439
 	}
386 440
 
387 441
 	public static function insert_last_accidents_update() {
Please login to merge, or discard this patch.