Completed
Push — master ( 55f75d...0ab128 )
by Yannick
14:33
created
incident.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
4 4
 if ($date == '') $date = date('Y-m-d');
5 5
 header('Location: '.$globalURL.'/incident/'.$date);
6 6
 ?>
7 7
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/incident/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.
country-statistics-airline-country.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['country'])) {
6
-        header('Location: '.$globalURL.'/country');
7
-        die();
6
+		header('Location: '.$globalURL.'/country');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING)));
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING)));
11
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
10
+$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'country', FILTER_SANITIZE_STRING)));
11
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
12 12
 
13 13
 if (isset($_GET['sort'])) {
14 14
 	$spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort);
@@ -18,16 +18,16 @@  discard block
 block discarded – undo
18 18
 
19 19
 if (!empty($spotter_array))
20 20
 {
21
-	$title = sprintf(_("Most Common Airlines by Country of %s"),$country);
21
+	$title = sprintf(_("Most Common Airlines by Country of %s"), $country);
22 22
 	require_once('header.php');
23 23
 	print '<div class="select-item">';
24 24
 	print '<form action="'.$globalURL.'/country" method="post">';
25 25
 	print '<select name="country" class="selectpicker" data-live-search="true">';
26 26
 	print '<option></option>';
27 27
 	$all_countries = $Spotter->getAllCountries();
28
-	foreach($all_countries as $all_country)
28
+	foreach ($all_countries as $all_country)
29 29
 	{
30
-		if($country == $all_country['country'])
30
+		if ($country == $all_country['country'])
31 31
 		{
32 32
 			print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>';
33 33
 		} else {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	if ($_GET['country'] != "NA")
43 43
 	{
44 44
 		print '<div class="info column">';
45
-		print '<h1>'.sprintf(_("Airports &amp; Airlines from %s"),$country).'</h1>';
45
+		print '<h1>'.sprintf(_("Airports &amp; Airlines from %s"), $country).'</h1>';
46 46
 		print '</div>';
47 47
 	} else {
48 48
 		print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>';
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	include('country-sub-menu.php');
52 52
 	print '<div class="column">';
53 53
 	print '<h2>'._("Most Common Airlines by Country").'</h2>';
54
-	print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights from airports &amp; airlines of <strong>%s</strong>."),$country).'</p>';
54
+	print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights from airports &amp; airlines of <strong>%s</strong>."), $country).'</p>';
55 55
 	$airline_array = $Spotter->countAllAirlineCountriesByCountry($country);
56 56
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
57 57
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
60 60
 	print 'var series = [';
61 61
 	$country_data = '';
62
-	foreach($airline_array as $airline_item)
62
+	foreach ($airline_array as $airline_item)
63 63
 	{
64 64
 		$country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],';
65 65
 	}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		print '</thead>';
108 108
 		print '<tbody>';
109 109
 		$i = 1;
110
-		foreach($airline_array as $airline_item)
110
+		foreach ($airline_array as $airline_item)
111 111
 		{
112 112
 			print '<tr>';
113 113
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
country-statistics-arrival-airport-country.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['country'])) {
6
-        header('Location: '.$globalURL.'/country');
7
-        die();
6
+		header('Location: '.$globalURL.'/country');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING)));
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	include('country-sub-menu.php');
52 52
 	print '<div class="column">';
53 53
 	print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
54
-        print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports &amp; airlines from <strong>%s</strong>."),$country).'</p>';
54
+		print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports &amp; airlines from <strong>%s</strong>."),$country).'</p>';
55 55
 
56 56
 	$airport_country_array = $Spotter->countAllArrivalAirportCountriesByCountry($country);
57 57
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING)));
11
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
10
+$country = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'country', FILTER_SANITIZE_STRING)));
11
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
12 12
 
13 13
 if (isset($_GET['sort'])) {
14 14
 	$spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort);
@@ -18,16 +18,16 @@  discard block
 block discarded – undo
18 18
 
19 19
 if (!empty($spotter_array))
20 20
 {
21
-	$title = sprintf(_("Most Common Arrival Airports by Country from %s"),$country);
21
+	$title = sprintf(_("Most Common Arrival Airports by Country from %s"), $country);
22 22
 	require_once('header.php');
23 23
 	print '<div class="select-item">';
24 24
 	print '<form action="'.$globalURL.'/country" method="post">';
25 25
 	print '<select name="country" class="selectpicker" data-live-search="true">';
26 26
 	print '<option></option>';
27 27
 	$all_countries = $Spotter->getAllCountries();
28
-	foreach($all_countries as $all_country)
28
+	foreach ($all_countries as $all_country)
29 29
 	{
30
-		if($country == $all_country['country'])
30
+		if ($country == $all_country['country'])
31 31
 		{
32 32
 			print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>';
33 33
 		} else {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	if ($_GET['country'] != "NA")
43 43
 	{
44 44
 		print '<div class="info column">';
45
-		print '<h1>'.sprintf(_("Airports &amp; Airlines from %s"),$country).'</h1>';
45
+		print '<h1>'.sprintf(_("Airports &amp; Airlines from %s"), $country).'</h1>';
46 46
 		print '</div>';
47 47
 	} else {
48 48
 		print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>';
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	include('country-sub-menu.php');
52 52
 	print '<div class="column">';
53 53
 	print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
54
-        print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports &amp; airlines from <strong>%s</strong>."),$country).'</p>';
54
+        print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports &amp; airlines from <strong>%s</strong>."), $country).'</p>';
55 55
 
56 56
 	$airport_country_array = $Spotter->countAllArrivalAirportCountriesByCountry($country);
57 57
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
62 62
 	print 'var series = [';
63 63
 	$country_data = '';
64
-	foreach($airport_country_array as $airport_item)
64
+	foreach ($airport_country_array as $airport_item)
65 65
 	{
66 66
 		$country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
67 67
 	}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		print '</thead>';
110 110
 		print '<tbody>';
111 111
 		$i = 1;
112
-		foreach($airport_country_array as $airport_item)
112
+		foreach ($airport_country_array as $airport_item)
113 113
 		{
114 114
 			print '<tr>';
115 115
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
date-statistics-departure-airport-country.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
8
-$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
8
+$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort);
9 9
 
10 10
 if (!empty($spotter_array))
11 11
 {
12
-	$title = sprintf(_("Most Common Departure Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
12
+	$title = sprintf(_("Most Common Departure Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
13 13
 
14 14
 	require_once('header.php');
15 15
 	print '<div class="select-item">';
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 	print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
28 28
 	print '<br />';
29 29
 	print '<div class="info column">';
30
-	print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
30
+	print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
31 31
 	print '</div>';
32 32
 
33 33
 	include('date-sub-menu.php');
34 34
 	print '<div class="column">';
35 35
 	print '<h2>'._("Most Common Departure Airports by Country").'</h2>';
36
-	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
36
+	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
37 37
 	$airport_country_array = $Spotter->countAllDepartureAirportCountriesByDate($date);
38 38
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
39 39
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
42 42
 	print 'var series = [';
43 43
 	$country_data = '';
44
-	foreach($airport_country_array as $airport_item)
44
+	foreach ($airport_country_array as $airport_item)
45 45
 	{
46 46
 		$country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],';
47 47
 	}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		print '</thead>';
90 90
 		print '<tbody>';
91 91
 		$i = 1;
92
-		foreach($airport_country_array as $airport_item)
92
+		foreach ($airport_country_array as $airport_item)
93 93
 		{
94 94
 			print '<tr>';
95 95
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
date-statistics-arrival-airport-country.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
8
-$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
8
+$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort);
9 9
 
10 10
 if (!empty($spotter_array))
11 11
 {
12
-	$title = sprintf(_("Most Common Arrival Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
12
+	$title = sprintf(_("Most Common Arrival Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
13 13
 	require_once('header.php');
14 14
 	print '<div class="select-item">';
15 15
 	print '<form action="'.$globalURL.'/date" method="post" class="form-inline">';
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 	print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
27 27
 	print '<br />';
28 28
 	print '<div class="info column">';
29
-	print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
29
+	print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
30 30
 	print '</div>';
31 31
 
32 32
 	include('date-sub-menu.php');
33 33
 	print '<div class="column">';
34 34
 	print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
35
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
35
+	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
36 36
 
37 37
 	$airport_country_array = $Spotter->countAllArrivalAirportCountriesByDate($date);
38 38
 	//print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 */
74 74
 	print 'var series = [';
75 75
 	$country_data = '';
76
-	foreach($airport_country_array as $airport_item)
76
+	foreach ($airport_country_array as $airport_item)
77 77
 	{
78 78
 		$country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
79 79
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		print '</thead>';
122 122
 		print '<tbody>';
123 123
 		$i = 1;
124
-		foreach($airport_country_array as $airport_item)
124
+		foreach ($airport_country_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.
manufacturer-sub-menu.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
 </span>
4 4
 <div class="sub-menu sub-menu-container">
5 5
 	<ul class="nav nav-pills">
6
-		<li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
6
+		<li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
7 7
 		<li class="dropdown">
8
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
8
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration") { print 'active'; } ?>" data-toggle="dropdown" href="#">
9 9
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
10 10
 		    </a>
11 11
 		    <ul class="dropdown-menu" role="menu">
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		    </ul>
15 15
 		</li>
16 16
 		<li class="dropdown">
17
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
17
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
18 18
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
19 19
 		    </a>
20 20
 		    <ul class="dropdown-menu" role="menu">
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		    </ul>
24 24
 		</li>
25 25
 		<li class="dropdown">
26
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
26
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
27 27
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
28 28
 		    </a>
29 29
 		    <ul class="dropdown-menu" role="menu">
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 			  <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/arrival-airport-country/<?php print $manufacturer; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
34 34
 		    </ul>
35 35
 		</li>
36
-		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
37
-		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
36
+		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
37
+		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
38 38
 	</ul>
39 39
 </div>
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
airport-geojson.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		date_default_timezone_set('UTC');
28 28
 		//waypoint plotting
29 29
 		$output .= '{"type": "Feature",';
30
-		    $output .= '"properties": {';
30
+			$output .= '"properties": {';
31 31
 			$output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",';
32 32
 			$output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",';
33 33
 			$output .= '"country": "'.$spotter_item['country'].'",';
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 			$output .= '"homepage": "'.$spotter_item['home_link'].'",';
51 51
 			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
52 52
 //			$output .= '"photo": "'.$spotter_item['image_thumbnail'].'",';
53
-		    $output .= '},';
54
-		    $output .= '"geometry": {';
53
+			$output .= '},';
54
+			$output .= '"geometry": {';
55 55
 			$output .= '"type": "Point",';
56 56
 			$output .= '"coordinates": [';
57
-			    $output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
57
+				$output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
58 58
 			$output .= ']';
59
-		    $output .= '}';
59
+			$output .= '}';
60 60
 		$output .= '},';
61 61
 	}
62 62
 	$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (isset($_GET['coord'])) 
13 13
 {
14
-	$coords = explode(',',$_GET['coord']);
14
+	$coords = explode(',', $_GET['coord']);
15 15
 	$spotter_array = $Spotter->getAllAirportInfobyCoord($coords);
16 16
 } else {
17 17
 	$spotter_array = $Spotter->getAllAirportInfo();
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
             
23 23
 if (!empty($spotter_array))
24 24
 {	  
25
-	foreach($spotter_array as $spotter_item)
25
+	foreach ($spotter_array as $spotter_item)
26 26
 	{
27 27
 		date_default_timezone_set('UTC');
28 28
 		//waypoint plotting
29 29
 		$output .= '{"type": "Feature",';
30 30
 		    $output .= '"properties": {';
31
-			$output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",';
32
-			$output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",';
31
+			$output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",';
32
+			$output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",';
33 33
 			$output .= '"country": "'.$spotter_item['country'].'",';
34 34
 			$output .= '"altitude": "'.$spotter_item['altitude'].'",';
35
-			$output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",';
35
+			$output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",';
36 36
 			if ($spotter_item['type'] == 'large_airport') {
37 37
 				$output .= '"icon": "'.$globalURL.'/images/airport.png",';
38 38
 			} elseif ($spotter_item['type'] == 'heliport') {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		    $output .= '}';
60 60
 		$output .= '},';
61 61
 	}
62
-	$output  = substr($output, 0, -1);
62
+	$output = substr($output, 0, -1);
63 63
 }
64 64
 $output .= ']}';
65 65
 print $output;
Please login to merge, or discard this patch.
install/class.update_db.php 4 patches
Indentation   +459 added lines, -459 removed lines patch added patch discarded remove patch
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
 		try {
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78
-                        $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
80
-                        return "error : ".$e->getMessage();
81
-                }
78
+						$sth->execute(array(':source' => $database_file));
79
+				} catch(PDOException $e) {
80
+						return "error : ".$e->getMessage();
81
+				}
82 82
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
84
-    		update_db::connect_sqlite($database_file);
83
+			if ($globalDebug) echo " - Add routes to DB -";
84
+			update_db::connect_sqlite($database_file);
85 85
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 86
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
87 87
 		try {
88
-                        $sth = update_db::$db_sqlite->prepare($query);
89
-                        $sth->execute();
90
-                } catch(PDOException $e) {
91
-                        return "error : ".$e->getMessage();
92
-                }
88
+						$sth = update_db::$db_sqlite->prepare($query);
89
+						$sth->execute();
90
+				} catch(PDOException $e) {
91
+						return "error : ".$e->getMessage();
92
+				}
93 93
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
94 94
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$Connection = new Connection();
96 96
 		$sth_dest = $Connection->db->prepare($query_dest);
97 97
 		try {
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
99
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 101
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 102
 				$sth_dest->execute($query_dest_values);
103
-            		}
103
+					}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105 105
 		} catch(PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
109
-                return '';
109
+				return '';
110 110
 	}
111 111
 	public static function retrieve_route_oneworld($database_file) {
112 112
 		global $globalDebug, $globalTransaction;
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 		try {
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120
-                        $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
122
-                        return "error : ".$e->getMessage();
123
-                }
120
+						$sth->execute(array(':source' => 'oneworld'));
121
+				} catch(PDOException $e) {
122
+						return "error : ".$e->getMessage();
123
+				}
124 124
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
125
+			if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128 128
 		if ($fh = fopen($database_file,"r")) {
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 			if ($globalTransaction) $Connection->db->commit();
148 148
 		}
149
-                return '';
149
+				return '';
150 150
 	}
151 151
 	
152 152
 	public static function retrieve_route_skyteam($database_file) {
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 		try {
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161
-                        $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
163
-                        return "error : ".$e->getMessage();
164
-                }
161
+						$sth->execute(array(':source' => 'skyteam'));
162
+				} catch(PDOException $e) {
163
+						return "error : ".$e->getMessage();
164
+				}
165 165
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
166
+			if ($globalDebug) echo " - Add routes to DB -";
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
191 191
 		}
192
-                return '';
192
+				return '';
193 193
 	}
194 194
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
195 195
 		global $globalTransaction;
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 		try {
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201
-                        $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
203
-                        return "error : ".$e->getMessage();
204
-                }
201
+						$sth->execute(array(':source' => $database_file));
202
+				} catch(PDOException $e) {
203
+						return "error : ".$e->getMessage();
204
+				}
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
206 206
 		try {
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209
-                        $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
211
-                        return "error : ".$e->getMessage();
212
-                }
209
+						$sth->execute(array(':source' => $database_file));
210
+				} catch(PDOException $e) {
211
+						return "error : ".$e->getMessage();
212
+				}
213 213
 
214
-    		update_db::connect_sqlite($database_file);
214
+			update_db::connect_sqlite($database_file);
215 215
 		$query = 'select * from Aircraft';
216 216
 		try {
217
-                        $sth = update_db::$db_sqlite->prepare($query);
218
-                        $sth->execute();
219
-                } catch(PDOException $e) {
220
-                        return "error : ".$e->getMessage();
221
-                }
217
+						$sth = update_db::$db_sqlite->prepare($query);
218
+						$sth->execute();
219
+				} catch(PDOException $e) {
220
+						return "error : ".$e->getMessage();
221
+				}
222 222
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
223 223
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
224 224
 		
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 230
 		try {
231 231
 			if ($globalTransaction) $Connection->db->beginTransaction();
232
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
232
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 233
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236 236
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
-				    $sth_dest_owner->execute($query_dest_owner_values);
239
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+					$sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242
-            		}
242
+					}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244 244
 		} catch(PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 		try {
251 251
 			$Connection = new Connection();
252 252
 			$sth = $Connection->db->prepare($query);
253
-                        $sth->execute(array(':source' => $database_file));
254
-                } catch(PDOException $e) {
255
-                        return "error : ".$e->getMessage();
256
-                }
253
+						$sth->execute(array(':source' => $database_file));
254
+				} catch(PDOException $e) {
255
+						return "error : ".$e->getMessage();
256
+				}
257 257
 		return '';
258 258
 	}
259 259
 
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 		try {
266 266
 			$Connection = new Connection();
267 267
 			$sth = $Connection->db->prepare($query);
268
-                        $sth->execute(array(':source' => $database_file));
269
-                } catch(PDOException $e) {
270
-                        return "error : ".$e->getMessage();
271
-                }
268
+						$sth->execute(array(':source' => $database_file));
269
+				} catch(PDOException $e) {
270
+						return "error : ".$e->getMessage();
271
+				}
272 272
 		
273 273
 		if ($fh = fopen($database_file,"r")) {
274 274
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -278,26 +278,26 @@  discard block
 block discarded – undo
278 278
 			$sth_dest = $Connection->db->prepare($query_dest);
279 279
 			try {
280 280
 				if ($globalTransaction) $Connection->db->beginTransaction();
281
-            			while (!feof($fh)) {
282
-            				$values = array();
283
-            				$line = $Common->hex2str(fgets($fh,9999));
281
+						while (!feof($fh)) {
282
+							$values = array();
283
+							$line = $Common->hex2str(fgets($fh,9999));
284 284
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
285
-            				$values['ModeS'] = substr($line,0,6);
286
-            				$values['Registration'] = trim(substr($line,69,6));
287
-            				$aircraft_name = trim(substr($line,48,6));
288
-            				// Check if we can find ICAO, else set it to GLID
289
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
-            				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
-            				$sth_search = $Connection->db->prepare($query_search);
285
+							$values['ModeS'] = substr($line,0,6);
286
+							$values['Registration'] = trim(substr($line,69,6));
287
+							$aircraft_name = trim(substr($line,48,6));
288
+							// Check if we can find ICAO, else set it to GLID
289
+							$aircraft_name_split = explode(' ',$aircraft_name);
290
+							$search_more = '';
291
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
+							$sth_search = $Connection->db->prepare($query_search);
294 294
 					try {
295
-                                    		$sth_search->execute();
296
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
-	            				//if (count($result) > 0) {
298
-	            				if (isset($result['icao']) && $result['icao'] != '') {
299
-	            				    $values['ICAOTypeCode'] = $result['icao'];
300
-	            				} 
295
+											$sth_search->execute();
296
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
+								//if (count($result) > 0) {
298
+								if (isset($result['icao']) && $result['icao'] != '') {
299
+									$values['ICAOTypeCode'] = $result['icao'];
300
+								} 
301 301
 					} catch(PDOException $e) {
302 302
 						return "error : ".$e->getMessage();
303 303
 					}
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 		try {
321 321
 			$Connection = new Connection();
322 322
 			$sth = $Connection->db->prepare($query);
323
-                        $sth->execute(array(':source' => $database_file));
324
-                } catch(PDOException $e) {
325
-                        return "error : ".$e->getMessage();
326
-                }
323
+						$sth->execute(array(':source' => $database_file));
324
+				} catch(PDOException $e) {
325
+						return "error : ".$e->getMessage();
326
+				}
327 327
 		return '';
328 328
 	}
329 329
 
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 		try {
335 335
 			$Connection = new Connection();
336 336
 			$sth = $Connection->db->prepare($query);
337
-                        $sth->execute(array(':source' => $database_file));
338
-                } catch(PDOException $e) {
339
-                        return "error : ".$e->getMessage();
340
-                }
337
+						$sth->execute(array(':source' => $database_file));
338
+				} catch(PDOException $e) {
339
+						return "error : ".$e->getMessage();
340
+				}
341 341
 		
342 342
 		if ($fh = fopen($database_file,"r")) {
343 343
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -348,24 +348,24 @@  discard block
 block discarded – undo
348 348
 			try {
349 349
 				if ($globalTransaction) $Connection->db->beginTransaction();
350 350
 				$tmp = fgetcsv($fh,9999,',',"'");
351
-            			while (!feof($fh)) {
352
-            				$line = fgetcsv($fh,9999,',',"'");
351
+						while (!feof($fh)) {
352
+							$line = fgetcsv($fh,9999,',',"'");
353 353
             				
354 354
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
355 355
 					//print_r($line);
356
-            				$values['ModeS'] = $line[1];
357
-            				$values['Registration'] = $line[3];
358
-            				$aircraft_name = $line[2];
359
-            				// Check if we can find ICAO, else set it to GLID
360
-            				$aircraft_name_split = explode(' ',$aircraft_name);
361
-            				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
-            				$sth_search = $Connection->db->prepare($query_search);
356
+							$values['ModeS'] = $line[1];
357
+							$values['Registration'] = $line[3];
358
+							$aircraft_name = $line[2];
359
+							// Check if we can find ICAO, else set it to GLID
360
+							$aircraft_name_split = explode(' ',$aircraft_name);
361
+							$search_more = '';
362
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
+							$sth_search = $Connection->db->prepare($query_search);
365 365
 					try {
366
-                                    		$sth_search->execute();
367
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
366
+											$sth_search->execute();
367
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
369 369
 					} catch(PDOException $e) {
370 370
 						return "error : ".$e->getMessage();
371 371
 					}
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
 		try {
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391
-                        $sth->execute(array(':source' => $database_file));
392
-                } catch(PDOException $e) {
393
-                        return "error : ".$e->getMessage();
394
-                }
391
+						$sth->execute(array(':source' => $database_file));
392
+				} catch(PDOException $e) {
393
+						return "error : ".$e->getMessage();
394
+				}
395 395
 		return '';
396 396
 	}
397 397
 
@@ -402,16 +402,16 @@  discard block
 block discarded – undo
402 402
 		try {
403 403
 			$Connection = new Connection();
404 404
 			$sth = $Connection->db->prepare($query);
405
-                        $sth->execute(array(':source' => $database_file));
406
-                } catch(PDOException $e) {
407
-                        return "error : ".$e->getMessage();
408
-                }
405
+						$sth->execute(array(':source' => $database_file));
406
+				} catch(PDOException $e) {
407
+						return "error : ".$e->getMessage();
408
+				}
409 409
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
410 410
 		$Spotter = new Spotter();
411 411
 		if ($fh = fopen($database_file,"r")) {
412 412
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
413 413
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
414
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
414
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
415 415
 		        
416 416
 			$Connection = new Connection();
417 417
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -419,126 +419,126 @@  discard block
 block discarded – undo
419 419
 			try {
420 420
 				if ($globalTransaction) $Connection->db->beginTransaction();
421 421
 				$tmp = fgetcsv($fh,9999,',','"');
422
-            			while (!feof($fh)) {
423
-            				$line = fgetcsv($fh,9999,',','"');
424
-            				$values = array();
425
-            				//print_r($line);
426
-            				if ($country == 'F') {
427
-            				    $values['registration'] = $line[0];
428
-            				    $values['base'] = $line[4];
429
-            				    $values['owner'] = $line[5];
430
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
431
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
432
-					    $values['cancel'] = $line[7];
422
+						while (!feof($fh)) {
423
+							$line = fgetcsv($fh,9999,',','"');
424
+							$values = array();
425
+							//print_r($line);
426
+							if ($country == 'F') {
427
+								$values['registration'] = $line[0];
428
+								$values['base'] = $line[4];
429
+								$values['owner'] = $line[5];
430
+								if ($line[6] == '') $values['date_first_reg'] = null;
431
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
432
+						$values['cancel'] = $line[7];
433 433
 					} elseif ($country == 'EI') {
434
-					    // TODO : add modeS & reg to aircraft_modes
435
-            				    $values['registration'] = $line[0];
436
-            				    $values['base'] = $line[3];
437
-            				    $values['owner'] = $line[2];
438
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
439
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
440
-					    $values['cancel'] = '';
441
-					    $values['modes'] = $line[7];
442
-					    $values['icao'] = $line[8];
434
+						// TODO : add modeS & reg to aircraft_modes
435
+								$values['registration'] = $line[0];
436
+								$values['base'] = $line[3];
437
+								$values['owner'] = $line[2];
438
+								if ($line[1] == '') $values['date_first_reg'] = null;
439
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
440
+						$values['cancel'] = '';
441
+						$values['modes'] = $line[7];
442
+						$values['icao'] = $line[8];
443 443
 					    
444 444
 					} elseif ($country == 'HB') {
445
-					    // TODO : add modeS & reg to aircraft_modes
446
-            				    $values['registration'] = $line[0];
447
-            				    $values['base'] = null;
448
-            				    $values['owner'] = $line[5];
449
-            				    $values['date_first_reg'] = null;
450
-					    $values['cancel'] = '';
451
-					    $values['modes'] = $line[4];
452
-					    $values['icao'] = $line[7];
445
+						// TODO : add modeS & reg to aircraft_modes
446
+								$values['registration'] = $line[0];
447
+								$values['base'] = null;
448
+								$values['owner'] = $line[5];
449
+								$values['date_first_reg'] = null;
450
+						$values['cancel'] = '';
451
+						$values['modes'] = $line[4];
452
+						$values['icao'] = $line[7];
453 453
 					} elseif ($country == 'OK') {
454
-					    // TODO : add modeS & reg to aircraft_modes
455
-            				    $values['registration'] = $line[3];
456
-            				    $values['base'] = null;
457
-            				    $values['owner'] = $line[5];
458
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
460
-					    $values['cancel'] = '';
454
+						// TODO : add modeS & reg to aircraft_modes
455
+								$values['registration'] = $line[3];
456
+								$values['base'] = null;
457
+								$values['owner'] = $line[5];
458
+								if ($line[18] == '') $values['date_first_reg'] = null;
459
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
460
+						$values['cancel'] = '';
461 461
 					} elseif ($country == 'VH') {
462
-					    // TODO : add modeS & reg to aircraft_modes
463
-            				    $values['registration'] = $line[0];
464
-            				    $values['base'] = null;
465
-            				    $values['owner'] = $line[12];
466
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
467
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
468
-
469
-					    $values['cancel'] = $line[39];
462
+						// TODO : add modeS & reg to aircraft_modes
463
+								$values['registration'] = $line[0];
464
+								$values['base'] = null;
465
+								$values['owner'] = $line[12];
466
+								if ($line[28] == '') $values['date_first_reg'] = null;
467
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
468
+
469
+						$values['cancel'] = $line[39];
470 470
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
471
-            				    $values['registration'] = $line[0];
472
-            				    $values['base'] = null;
473
-            				    $values['owner'] = $line[4];
474
-            				    $values['date_first_reg'] = null;
475
-					    $values['cancel'] = '';
471
+								$values['registration'] = $line[0];
472
+								$values['base'] = null;
473
+								$values['owner'] = $line[4];
474
+								$values['date_first_reg'] = null;
475
+						$values['cancel'] = '';
476 476
 					} elseif ($country == 'CC') {
477
-            				    $values['registration'] = $line[0];
478
-            				    $values['base'] = null;
479
-            				    $values['owner'] = $line[6];
480
-            				    $values['date_first_reg'] = null;
481
-					    $values['cancel'] = '';
477
+								$values['registration'] = $line[0];
478
+								$values['base'] = null;
479
+								$values['owner'] = $line[6];
480
+								$values['date_first_reg'] = null;
481
+						$values['cancel'] = '';
482 482
 					} elseif ($country == 'HJ') {
483
-            				    $values['registration'] = $line[0];
484
-            				    $values['base'] = null;
485
-            				    $values['owner'] = $line[8];
486
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
487
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
488
-					    $values['cancel'] = '';
483
+								$values['registration'] = $line[0];
484
+								$values['base'] = null;
485
+								$values['owner'] = $line[8];
486
+								if ($line[7] == '') $values['date_first_reg'] = null;
487
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
488
+						$values['cancel'] = '';
489 489
 					} elseif ($country == 'PP') {
490
-            				    $values['registration'] = $line[0];
491
-            				    $values['base'] = null;
492
-            				    $values['owner'] = $line[4];
493
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
494
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
-					    $values['cancel'] = $line[7];
490
+								$values['registration'] = $line[0];
491
+								$values['base'] = null;
492
+								$values['owner'] = $line[4];
493
+								if ($line[6] == '') $values['date_first_reg'] = null;
494
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
+						$values['cancel'] = $line[7];
496 496
 					} elseif ($country == 'E7') {
497
-            				    $values['registration'] = $line[0];
498
-            				    $values['base'] = null;
499
-            				    $values['owner'] = $line[4];
500
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
501
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
502
-					    $values['cancel'] = '';
497
+								$values['registration'] = $line[0];
498
+								$values['base'] = null;
499
+								$values['owner'] = $line[4];
500
+								if ($line[5] == '') $values['date_first_reg'] = null;
501
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
502
+						$values['cancel'] = '';
503 503
 					} elseif ($country == '8Q') {
504
-            				    $values['registration'] = $line[0];
505
-            				    $values['base'] = null;
506
-            				    $values['owner'] = $line[3];
507
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
509
-					    $values['cancel'] = '';
504
+								$values['registration'] = $line[0];
505
+								$values['base'] = null;
506
+								$values['owner'] = $line[3];
507
+								if ($line[7] == '') $values['date_first_reg'] = null;
508
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
509
+						$values['cancel'] = '';
510 510
 					} elseif ($country == 'ZK') {
511
-            				    $values['registration'] = $line[0];
512
-            				    $values['base'] = null;
513
-            				    $values['owner'] = $line[3];
514
-            				    $values['date_first_reg'] = null;
515
-					    $values['cancel'] = '';
516
-					    $values['modes'] = $line[5];
517
-					    $values['icao'] = $line[9];
511
+								$values['registration'] = $line[0];
512
+								$values['base'] = null;
513
+								$values['owner'] = $line[3];
514
+								$values['date_first_reg'] = null;
515
+						$values['cancel'] = '';
516
+						$values['modes'] = $line[5];
517
+						$values['icao'] = $line[9];
518 518
 					} elseif ($country == 'M') {
519
-            				    $values['registration'] = $line[0];
520
-            				    $values['base'] = null;
521
-            				    $values['owner'] = $line[6];
522
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
523
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
-					    $values['modes'] = $line[4];
525
-					    $values['icao'] = $line[10];
519
+								$values['registration'] = $line[0];
520
+								$values['base'] = null;
521
+								$values['owner'] = $line[6];
522
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
523
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
+						$values['modes'] = $line[4];
525
+						$values['icao'] = $line[10];
526 526
 					} elseif ($country == 'OY') {
527
-            				    $values['registration'] = $line[0];
528
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
529
-					    $values['modes'] = $line[5];
530
-					    $values['icao'] = $line[6];
527
+								$values['registration'] = $line[0];
528
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
529
+						$values['modes'] = $line[5];
530
+						$values['icao'] = $line[6];
531 531
 					} elseif ($country == 'PH') {
532
-            				    $values['registration'] = $line[0];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
534
-					    $values['modes'] = $line[4];
535
-					    $values['icao'] = $line[5];
532
+								$values['registration'] = $line[0];
533
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
534
+						$values['modes'] = $line[4];
535
+						$values['icao'] = $line[5];
536 536
 					} elseif ($country == 'OM' || $country == 'TF') {
537
-            				    $values['registration'] = $line[0];
538
-            				    $values['base'] = null;
539
-            				    $values['owner'] = $line[3];
540
-            				    $values['date_first_reg'] = null;
541
-					    $values['cancel'] = '';
537
+								$values['registration'] = $line[0];
538
+								$values['base'] = null;
539
+								$values['owner'] = $line[3];
540
+								$values['date_first_reg'] = null;
541
+						$values['cancel'] = '';
542 542
 					}
543 543
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
544 544
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -665,20 +665,20 @@  discard block
 block discarded – undo
665 665
 		try {
666 666
 			$Connection = new Connection();
667 667
 			$sth = $Connection->db->prepare($query);
668
-                        $sth->execute();
669
-                } catch(PDOException $e) {
670
-                        return "error : ".$e->getMessage();
671
-                }
668
+						$sth->execute();
669
+				} catch(PDOException $e) {
670
+						return "error : ".$e->getMessage();
671
+				}
672 672
 
673 673
 
674 674
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
675 675
 		try {
676 676
 			$Connection = new Connection();
677 677
 			$sth = $Connection->db->prepare($query);
678
-                        $sth->execute();
679
-                } catch(PDOException $e) {
680
-                        return "error : ".$e->getMessage();
681
-                }
678
+						$sth->execute();
679
+				} catch(PDOException $e) {
680
+						return "error : ".$e->getMessage();
681
+				}
682 682
 
683 683
 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)
684 684
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
@@ -744,10 +744,10 @@  discard block
 block discarded – undo
744 744
 		try {
745 745
 			$Connection = new Connection();
746 746
 			$sth = $Connection->db->prepare($query);
747
-                        $sth->execute();
748
-                } catch(PDOException $e) {
749
-                        return "error : ".$e->getMessage();
750
-                }
747
+						$sth->execute();
748
+				} catch(PDOException $e) {
749
+						return "error : ".$e->getMessage();
750
+				}
751 751
 
752 752
 
753 753
 		if ($globalDebug) echo "Insert Not available Airport...\n";
@@ -757,10 +757,10 @@  discard block
 block discarded – undo
757 757
 		try {
758 758
 			$Connection = new Connection();
759 759
 			$sth = $Connection->db->prepare($query);
760
-                        $sth->execute($query_values);
761
-                } catch(PDOException $e) {
762
-                        return "error : ".$e->getMessage();
763
-                }
760
+						$sth->execute($query_values);
761
+				} catch(PDOException $e) {
762
+						return "error : ".$e->getMessage();
763
+				}
764 764
 		$i++;
765 765
 /*
766 766
 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 
875 875
 
876 876
 
877
-                return "success";
877
+				return "success";
878 878
 	}
879 879
 	
880 880
 	public static function translation() {
@@ -890,10 +890,10 @@  discard block
 block discarded – undo
890 890
 		try {
891 891
 			$Connection = new Connection();
892 892
 			$sth = $Connection->db->prepare($query);
893
-                        $sth->execute(array(':source' => 'translation.csv'));
894
-                } catch(PDOException $e) {
895
-                        return "error : ".$e->getMessage();
896
-                }
893
+						$sth->execute(array(':source' => 'translation.csv'));
894
+				} catch(PDOException $e) {
895
+						return "error : ".$e->getMessage();
896
+				}
897 897
 
898 898
 		
899 899
 		//update_db::unzip($out_file);
@@ -912,21 +912,21 @@  discard block
 block discarded – undo
912 912
 					$data = $row;
913 913
 					$operator = $data[2];
914 914
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
915
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
916
-                                                //echo substr($operator, 0, 2)."\n";;
917
-                                                if (count($airline_array) > 0) {
915
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
916
+												//echo substr($operator, 0, 2)."\n";;
917
+												if (count($airline_array) > 0) {
918 918
 							//print_r($airline_array);
919 919
 							$operator = $airline_array[0]['icao'].substr($operator,2);
920
-                                                }
921
-                                        }
920
+												}
921
+										}
922 922
 					
923 923
 					$operator_correct = $data[3];
924 924
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
925
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
926
-                                                if (count($airline_array) > 0) {
927
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
928
-                                            	}
929
-                                        }
925
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
926
+												if (count($airline_array) > 0) {
927
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
928
+												}
929
+										}
930 930
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
931 931
 					try {
932 932
 						$sth = $Connection->db->prepare($query);
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 			//$Connection->db->commit();
941 941
 		}
942 942
 		return '';
943
-        }
943
+		}
944 944
 	
945 945
 	public static function translation_fam() {
946 946
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -950,10 +950,10 @@  discard block
 block discarded – undo
950 950
 		try {
951 951
 			$Connection = new Connection();
952 952
 			$sth = $Connection->db->prepare($query);
953
-                        $sth->execute(array(':source' => 'website_fam'));
954
-                } catch(PDOException $e) {
955
-                        return "error : ".$e->getMessage();
956
-                }
953
+						$sth->execute(array(':source' => 'website_fam'));
954
+				} catch(PDOException $e) {
955
+						return "error : ".$e->getMessage();
956
+				}
957 957
 
958 958
 		
959 959
 		//update_db::unzip($out_file);
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 			//$Connection->db->commit();
983 983
 		}
984 984
 		return '';
985
-        }
985
+		}
986 986
 
987 987
 	/*
988 988
 	* This function use FAA public data.
@@ -994,19 +994,19 @@  discard block
 block discarded – undo
994 994
 		try {
995 995
 			$Connection = new Connection();
996 996
 			$sth = $Connection->db->prepare($query);
997
-                        $sth->execute(array(':source' => 'website_faa'));
998
-                } catch(PDOException $e) {
999
-                        return "error : ".$e->getMessage();
1000
-                }
997
+						$sth->execute(array(':source' => 'website_faa'));
998
+				} catch(PDOException $e) {
999
+						return "error : ".$e->getMessage();
1000
+				}
1001 1001
 
1002 1002
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1003 1003
 		try {
1004 1004
 			$Connection = new Connection();
1005 1005
 			$sth = $Connection->db->prepare($query);
1006
-                        $sth->execute(array(':source' => 'website_faa'));
1007
-                } catch(PDOException $e) {
1008
-                        return "error : ".$e->getMessage();
1009
-                }
1006
+						$sth->execute(array(':source' => 'website_faa'));
1007
+				} catch(PDOException $e) {
1008
+						return "error : ".$e->getMessage();
1009
+				}
1010 1010
 
1011 1011
 		$delimiter = ",";
1012 1012
 		$mfr = array();
@@ -1082,17 +1082,17 @@  discard block
 block discarded – undo
1082 1082
 		}
1083 1083
 		print_r($mfr);
1084 1084
 		return '';
1085
-        }
1085
+		}
1086 1086
 	public static function modes_fam() {
1087 1087
 		global $tmp_dir, $globalTransaction;
1088 1088
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1089 1089
 		try {
1090 1090
 			$Connection = new Connection();
1091 1091
 			$sth = $Connection->db->prepare($query);
1092
-                        $sth->execute(array(':source' => 'website_fam'));
1093
-                } catch(PDOException $e) {
1094
-                        return "error : ".$e->getMessage();
1095
-                }
1092
+						$sth->execute(array(':source' => 'website_fam'));
1093
+				} catch(PDOException $e) {
1094
+						return "error : ".$e->getMessage();
1095
+				}
1096 1096
 
1097 1097
 		
1098 1098
 		//update_db::unzip($out_file);
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 			if ($globalTransaction) $Connection->db->commit();
1123 1123
 		}
1124 1124
 		return '';
1125
-        }
1125
+		}
1126 1126
         
1127 1127
 	public static function owner_fam() {
1128 1128
 		global $tmp_dir, $globalTransaction;
@@ -1130,10 +1130,10 @@  discard block
 block discarded – undo
1130 1130
 		try {
1131 1131
 			$Connection = new Connection();
1132 1132
 			$sth = $Connection->db->prepare($query);
1133
-                        $sth->execute(array(':source' => 'website_fam'));
1134
-                } catch(PDOException $e) {
1135
-                        return "error : ".$e->getMessage();
1136
-                }
1133
+						$sth->execute(array(':source' => 'website_fam'));
1134
+				} catch(PDOException $e) {
1135
+						return "error : ".$e->getMessage();
1136
+				}
1137 1137
 
1138 1138
 		$delimiter = "\t";
1139 1139
 		$Connection = new Connection();
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 			if ($globalTransaction) $Connection->db->commit();
1160 1160
 		}
1161 1161
 		return '';
1162
-        }
1162
+		}
1163 1163
 
1164 1164
 	public static function routes_fam() {
1165 1165
 		global $tmp_dir, $globalTransaction;
@@ -1167,10 +1167,10 @@  discard block
 block discarded – undo
1167 1167
 		try {
1168 1168
 			$Connection = new Connection();
1169 1169
 			$sth = $Connection->db->prepare($query);
1170
-                        $sth->execute(array(':source' => 'website_fam'));
1171
-                } catch(PDOException $e) {
1172
-                        return "error : ".$e->getMessage();
1173
-                }
1170
+						$sth->execute(array(':source' => 'website_fam'));
1171
+				} catch(PDOException $e) {
1172
+						return "error : ".$e->getMessage();
1173
+				}
1174 1174
 
1175 1175
 		
1176 1176
 		//update_db::unzip($out_file);
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 			if ($globalTransaction) $Connection->db->commit();
1200 1200
 		}
1201 1201
 		return '';
1202
-        }
1202
+		}
1203 1203
 
1204 1204
 	public static function marine_identity_fam() {
1205 1205
 		global $tmp_dir, $globalTransaction;
@@ -1207,10 +1207,10 @@  discard block
 block discarded – undo
1207 1207
 		try {
1208 1208
 			$Connection = new Connection();
1209 1209
 			$sth = $Connection->db->prepare($query);
1210
-                        $sth->execute();
1211
-                } catch(PDOException $e) {
1212
-                        return "error : ".$e->getMessage();
1213
-                }
1210
+						$sth->execute();
1211
+				} catch(PDOException $e) {
1212
+						return "error : ".$e->getMessage();
1213
+				}
1214 1214
 
1215 1215
 		
1216 1216
 		//update_db::unzip($out_file);
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 			if ($globalTransaction) $Connection->db->commit();
1240 1240
 		}
1241 1241
 		return '';
1242
-        }
1242
+		}
1243 1243
 
1244 1244
 	public static function banned_fam() {
1245 1245
 		global $tmp_dir, $globalTransaction;
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 			if ($globalTransaction) $Connection->db->commit();
1274 1274
 		}
1275 1275
 		return '';
1276
-        }
1276
+		}
1277 1277
 
1278 1278
 	public static function tle($filename,$tletype) {
1279 1279
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1284,10 +1284,10 @@  discard block
 block discarded – undo
1284 1284
 		try {
1285 1285
 			$Connection = new Connection();
1286 1286
 			$sth = $Connection->db->prepare($query);
1287
-                        $sth->execute(array(':source' => $filename));
1288
-                } catch(PDOException $e) {
1289
-                        return "error : ".$e->getMessage();
1290
-                }
1287
+						$sth->execute(array(':source' => $filename));
1288
+				} catch(PDOException $e) {
1289
+						return "error : ".$e->getMessage();
1290
+				}
1291 1291
 		
1292 1292
 		$Connection = new Connection();
1293 1293
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1322,54 +1322,54 @@  discard block
 block discarded – undo
1322 1322
 			//$Connection->db->commit();
1323 1323
 		}
1324 1324
 		return '';
1325
-        }
1325
+		}
1326 1326
 
1327 1327
 	/**
1328
-        * Convert a HTML table to an array
1329
-        * @param String $data HTML page
1330
-        * @return Array array of the tables in HTML page
1331
-        */
1332
-        private static function table2array($data) {
1333
-                $html = str_get_html($data);
1334
-                $tabledata=array();
1335
-                foreach($html->find('tr') as $element)
1336
-                {
1337
-                        $td = array();
1338
-                        foreach( $element->find('th') as $row)
1339
-                        {
1340
-                                $td [] = trim($row->plaintext);
1341
-                        }
1342
-                        $td=array_filter($td);
1343
-                        $tabledata[] = $td;
1344
-
1345
-                        $td = array();
1346
-                        $tdi = array();
1347
-                        foreach( $element->find('td') as $row)
1348
-                        {
1349
-                                $td [] = trim($row->plaintext);
1350
-                                $tdi [] = trim($row->innertext);
1351
-                        }
1352
-                        $td=array_filter($td);
1353
-                        $tdi=array_filter($tdi);
1354
-                    //    $tabledata[]=array_merge($td,$tdi);
1355
-                        $tabledata[]=$td;
1356
-                }
1357
-                return(array_filter($tabledata));
1358
-        }
1359
-
1360
-       /**
1361
-        * Get data from form result
1362
-        * @param String $url form URL
1363
-        * @return String the result
1364
-        */
1365
-        private static function getData($url) {
1366
-                $ch = curl_init();
1367
-                curl_setopt($ch, CURLOPT_URL, $url);
1368
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1369
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1370
-                curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
1371
-                return curl_exec($ch);
1372
-        }
1328
+	 * Convert a HTML table to an array
1329
+	 * @param String $data HTML page
1330
+	 * @return Array array of the tables in HTML page
1331
+	 */
1332
+		private static function table2array($data) {
1333
+				$html = str_get_html($data);
1334
+				$tabledata=array();
1335
+				foreach($html->find('tr') as $element)
1336
+				{
1337
+						$td = array();
1338
+						foreach( $element->find('th') as $row)
1339
+						{
1340
+								$td [] = trim($row->plaintext);
1341
+						}
1342
+						$td=array_filter($td);
1343
+						$tabledata[] = $td;
1344
+
1345
+						$td = array();
1346
+						$tdi = array();
1347
+						foreach( $element->find('td') as $row)
1348
+						{
1349
+								$td [] = trim($row->plaintext);
1350
+								$tdi [] = trim($row->innertext);
1351
+						}
1352
+						$td=array_filter($td);
1353
+						$tdi=array_filter($tdi);
1354
+					//    $tabledata[]=array_merge($td,$tdi);
1355
+						$tabledata[]=$td;
1356
+				}
1357
+				return(array_filter($tabledata));
1358
+		}
1359
+
1360
+	   /**
1361
+	    * Get data from form result
1362
+	    * @param String $url form URL
1363
+	    * @return String the result
1364
+	    */
1365
+		private static function getData($url) {
1366
+				$ch = curl_init();
1367
+				curl_setopt($ch, CURLOPT_URL, $url);
1368
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1369
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1370
+				curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
1371
+				return curl_exec($ch);
1372
+		}
1373 1373
 /*
1374 1374
 	public static function waypoints() {
1375 1375
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
 			if ($globalTransaction) $Connection->db->commit();
1453 1453
 		}
1454 1454
 		return '';
1455
-        }
1455
+		}
1456 1456
 
1457 1457
 	public static function ivao_airlines($filename) {
1458 1458
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1462,10 +1462,10 @@  discard block
 block discarded – undo
1462 1462
 		try {
1463 1463
 			$Connection = new Connection();
1464 1464
 			$sth = $Connection->db->prepare($query);
1465
-                        $sth->execute();
1466
-                } catch(PDOException $e) {
1467
-                        return "error : ".$e->getMessage();
1468
-                }
1465
+						$sth->execute();
1466
+				} catch(PDOException $e) {
1467
+						return "error : ".$e->getMessage();
1468
+				}
1469 1469
 
1470 1470
 		$header = NULL;
1471 1471
 		$delimiter = ':';
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
 			if ($globalTransaction) $Connection->db->commit();
1490 1490
 		}
1491 1491
 		return '';
1492
-        }
1492
+		}
1493 1493
 	
1494 1494
 	public static function update_airspace() {
1495 1495
 		global $tmp_dir, $globalDBdriver;
@@ -1499,11 +1499,11 @@  discard block
 block discarded – undo
1499 1499
 			$query = 'DROP TABLE airspace';
1500 1500
 			try {
1501 1501
 				$sth = $Connection->db->prepare($query);
1502
-                    		$sth->execute();
1503
-	                } catch(PDOException $e) {
1502
+							$sth->execute();
1503
+					} catch(PDOException $e) {
1504 1504
 				return "error : ".$e->getMessage();
1505
-	                }
1506
-	        }
1505
+					}
1506
+			}
1507 1507
 
1508 1508
 
1509 1509
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1558,10 +1558,10 @@  discard block
 block discarded – undo
1558 1558
 			$query = 'DROP TABLE countries';
1559 1559
 			try {
1560 1560
 				$sth = $Connection->db->prepare($query);
1561
-            	        	$sth->execute();
1562
-	                } catch(PDOException $e) {
1563
-    	                	echo "error : ".$e->getMessage();
1564
-	                }
1561
+							$sth->execute();
1562
+					} catch(PDOException $e) {
1563
+							echo "error : ".$e->getMessage();
1564
+					}
1565 1565
 		}
1566 1566
 		if ($globalDBdriver == 'mysql') {
1567 1567
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2090,11 +2090,11 @@  discard block
 block discarded – undo
2090 2090
 						$query = 'DROP TABLE airspace';
2091 2091
 						try {
2092 2092
 							$sth = $Connection->db->prepare($query);
2093
-    	    	    					$sth->execute();
2094
-			            		} catch(PDOException $e) {
2093
+										$sth->execute();
2094
+								} catch(PDOException $e) {
2095 2095
 							return "error : ".$e->getMessage();
2096
-		            			}
2097
-		    			}
2096
+								}
2097
+						}
2098 2098
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2099 2099
 					update_db::insert_airspace_version($airspace_md5);
2100 2100
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -2251,12 +2251,12 @@  discard block
 block discarded – undo
2251 2251
 		echo $data;
2252 2252
 		*/
2253 2253
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2254
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2255
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2256
-		    $result = fread($fh,100000000);
2257
-		    //echo $result;
2258
-		    //var_dump(str_get_html($result));
2259
-		    //print_r(self::table2array($result));
2254
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2255
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2256
+			$result = fread($fh,100000000);
2257
+			//echo $result;
2258
+			//var_dump(str_get_html($result));
2259
+			//print_r(self::table2array($result));
2260 2260
 		}
2261 2261
 
2262 2262
 	}
@@ -2270,10 +2270,10 @@  discard block
 block discarded – undo
2270 2270
 		try {
2271 2271
 			$Connection = new Connection();
2272 2272
 			$sth = $Connection->db->prepare($query);
2273
-                        $sth->execute();
2274
-                } catch(PDOException $e) {
2275
-                        return "error : ".$e->getMessage();
2276
-                }
2273
+						$sth->execute();
2274
+				} catch(PDOException $e) {
2275
+						return "error : ".$e->getMessage();
2276
+				}
2277 2277
 
2278 2278
 		$error = '';
2279 2279
 		if ($globalDebug) echo "Notam : Download...";
@@ -2329,8 +2329,8 @@  discard block
 block discarded – undo
2329 2329
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2330 2330
 					$data['permanent'] = 0;
2331 2331
 				} else {
2332
-				    $data['date_end'] = NULL;
2333
-				    $data['permanent'] = 1;
2332
+					$data['date_end'] = NULL;
2333
+					$data['permanent'] = 1;
2334 2334
 				}
2335 2335
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2336 2336
 				$NOTAM = new NOTAM();
@@ -2404,13 +2404,13 @@  discard block
 block discarded – undo
2404 2404
 		try {
2405 2405
 			$Connection = new Connection();
2406 2406
 			$sth = $Connection->db->prepare($query);
2407
-                        $sth->execute();
2408
-                } catch(PDOException $e) {
2409
-                        return "error : ".$e->getMessage();
2410
-                }
2411
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2412
-                if ($row['nb'] > 0) return false;
2413
-                else return true;
2407
+						$sth->execute();
2408
+				} catch(PDOException $e) {
2409
+						return "error : ".$e->getMessage();
2410
+				}
2411
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2412
+				if ($row['nb'] > 0) return false;
2413
+				else return true;
2414 2414
 	}
2415 2415
 
2416 2416
 	public static function insert_last_update() {
@@ -2419,10 +2419,10 @@  discard block
 block discarded – undo
2419 2419
 		try {
2420 2420
 			$Connection = new Connection();
2421 2421
 			$sth = $Connection->db->prepare($query);
2422
-                        $sth->execute();
2423
-                } catch(PDOException $e) {
2424
-                        return "error : ".$e->getMessage();
2425
-                }
2422
+						$sth->execute();
2423
+				} catch(PDOException $e) {
2424
+						return "error : ".$e->getMessage();
2425
+				}
2426 2426
 	}
2427 2427
 
2428 2428
 	public static function check_airspace_version($version) {
@@ -2430,13 +2430,13 @@  discard block
 block discarded – undo
2430 2430
 		try {
2431 2431
 			$Connection = new Connection();
2432 2432
 			$sth = $Connection->db->prepare($query);
2433
-                        $sth->execute(array(':version' => $version));
2434
-                } catch(PDOException $e) {
2435
-                        return "error : ".$e->getMessage();
2436
-                }
2437
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2438
-                if ($row['nb'] > 0) return true;
2439
-                else return false;
2433
+						$sth->execute(array(':version' => $version));
2434
+				} catch(PDOException $e) {
2435
+						return "error : ".$e->getMessage();
2436
+				}
2437
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2438
+				if ($row['nb'] > 0) return true;
2439
+				else return false;
2440 2440
 	}
2441 2441
 
2442 2442
 	public static function check_marine_identity_version($version) {
@@ -2444,13 +2444,13 @@  discard block
 block discarded – undo
2444 2444
 		try {
2445 2445
 			$Connection = new Connection();
2446 2446
 			$sth = $Connection->db->prepare($query);
2447
-                        $sth->execute(array(':version' => $version));
2448
-                } catch(PDOException $e) {
2449
-                        return "error : ".$e->getMessage();
2450
-                }
2451
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2452
-                if ($row['nb'] > 0) return true;
2453
-                else return false;
2447
+						$sth->execute(array(':version' => $version));
2448
+				} catch(PDOException $e) {
2449
+						return "error : ".$e->getMessage();
2450
+				}
2451
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2452
+				if ($row['nb'] > 0) return true;
2453
+				else return false;
2454 2454
 	}
2455 2455
 
2456 2456
 
@@ -2460,10 +2460,10 @@  discard block
 block discarded – undo
2460 2460
 		try {
2461 2461
 			$Connection = new Connection();
2462 2462
 			$sth = $Connection->db->prepare($query);
2463
-                        $sth->execute(array(':version' => $version));
2464
-                } catch(PDOException $e) {
2465
-                        return "error : ".$e->getMessage();
2466
-                }
2463
+						$sth->execute(array(':version' => $version));
2464
+				} catch(PDOException $e) {
2465
+						return "error : ".$e->getMessage();
2466
+				}
2467 2467
 	}
2468 2468
 
2469 2469
 	public static function insert_marine_identity_version($version) {
@@ -2472,10 +2472,10 @@  discard block
 block discarded – undo
2472 2472
 		try {
2473 2473
 			$Connection = new Connection();
2474 2474
 			$sth = $Connection->db->prepare($query);
2475
-                        $sth->execute(array(':version' => $version));
2476
-                } catch(PDOException $e) {
2477
-                        return "error : ".$e->getMessage();
2478
-                }
2475
+						$sth->execute(array(':version' => $version));
2476
+				} catch(PDOException $e) {
2477
+						return "error : ".$e->getMessage();
2478
+				}
2479 2479
 	}
2480 2480
 
2481 2481
 	public static function check_last_notam_update() {
@@ -2488,13 +2488,13 @@  discard block
 block discarded – undo
2488 2488
 		try {
2489 2489
 			$Connection = new Connection();
2490 2490
 			$sth = $Connection->db->prepare($query);
2491
-                        $sth->execute();
2492
-                } catch(PDOException $e) {
2493
-                        return "error : ".$e->getMessage();
2494
-                }
2495
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2496
-                if ($row['nb'] > 0) return false;
2497
-                else return true;
2491
+						$sth->execute();
2492
+				} catch(PDOException $e) {
2493
+						return "error : ".$e->getMessage();
2494
+				}
2495
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2496
+				if ($row['nb'] > 0) return false;
2497
+				else return true;
2498 2498
 	}
2499 2499
 
2500 2500
 	public static function insert_last_notam_update() {
@@ -2503,10 +2503,10 @@  discard block
 block discarded – undo
2503 2503
 		try {
2504 2504
 			$Connection = new Connection();
2505 2505
 			$sth = $Connection->db->prepare($query);
2506
-                        $sth->execute();
2507
-                } catch(PDOException $e) {
2508
-                        return "error : ".$e->getMessage();
2509
-                }
2506
+						$sth->execute();
2507
+				} catch(PDOException $e) {
2508
+						return "error : ".$e->getMessage();
2509
+				}
2510 2510
 	}
2511 2511
 	public static function check_last_airspace_update() {
2512 2512
 		global $globalDBdriver;
@@ -2518,13 +2518,13 @@  discard block
 block discarded – undo
2518 2518
 		try {
2519 2519
 			$Connection = new Connection();
2520 2520
 			$sth = $Connection->db->prepare($query);
2521
-                        $sth->execute();
2522
-                } catch(PDOException $e) {
2523
-                        return "error : ".$e->getMessage();
2524
-                }
2525
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2526
-                if ($row['nb'] > 0) return false;
2527
-                else return true;
2521
+						$sth->execute();
2522
+				} catch(PDOException $e) {
2523
+						return "error : ".$e->getMessage();
2524
+				}
2525
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2526
+				if ($row['nb'] > 0) return false;
2527
+				else return true;
2528 2528
 	}
2529 2529
 
2530 2530
 	public static function insert_last_airspace_update() {
@@ -2533,10 +2533,10 @@  discard block
 block discarded – undo
2533 2533
 		try {
2534 2534
 			$Connection = new Connection();
2535 2535
 			$sth = $Connection->db->prepare($query);
2536
-                        $sth->execute();
2537
-                } catch(PDOException $e) {
2538
-                        return "error : ".$e->getMessage();
2539
-                }
2536
+						$sth->execute();
2537
+				} catch(PDOException $e) {
2538
+						return "error : ".$e->getMessage();
2539
+				}
2540 2540
 	}
2541 2541
 
2542 2542
 	public static function check_last_owner_update() {
@@ -2549,13 +2549,13 @@  discard block
 block discarded – undo
2549 2549
 		try {
2550 2550
 			$Connection = new Connection();
2551 2551
 			$sth = $Connection->db->prepare($query);
2552
-                        $sth->execute();
2553
-                } catch(PDOException $e) {
2554
-                        return "error : ".$e->getMessage();
2555
-                }
2556
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2557
-                if ($row['nb'] > 0) return false;
2558
-                else return true;
2552
+						$sth->execute();
2553
+				} catch(PDOException $e) {
2554
+						return "error : ".$e->getMessage();
2555
+				}
2556
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2557
+				if ($row['nb'] > 0) return false;
2558
+				else return true;
2559 2559
 	}
2560 2560
 
2561 2561
 	public static function insert_last_owner_update() {
@@ -2564,10 +2564,10 @@  discard block
 block discarded – undo
2564 2564
 		try {
2565 2565
 			$Connection = new Connection();
2566 2566
 			$sth = $Connection->db->prepare($query);
2567
-                        $sth->execute();
2568
-                } catch(PDOException $e) {
2569
-                        return "error : ".$e->getMessage();
2570
-                }
2567
+						$sth->execute();
2568
+				} catch(PDOException $e) {
2569
+						return "error : ".$e->getMessage();
2570
+				}
2571 2571
 	}
2572 2572
 	public static function check_last_schedules_update() {
2573 2573
 		global $globalDBdriver;
@@ -2579,13 +2579,13 @@  discard block
 block discarded – undo
2579 2579
 		try {
2580 2580
 			$Connection = new Connection();
2581 2581
 			$sth = $Connection->db->prepare($query);
2582
-                        $sth->execute();
2583
-                } catch(PDOException $e) {
2584
-                        return "error : ".$e->getMessage();
2585
-                }
2586
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2587
-                if ($row['nb'] > 0) return false;
2588
-                else return true;
2582
+						$sth->execute();
2583
+				} catch(PDOException $e) {
2584
+						return "error : ".$e->getMessage();
2585
+				}
2586
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2587
+				if ($row['nb'] > 0) return false;
2588
+				else return true;
2589 2589
 	}
2590 2590
 
2591 2591
 	public static function insert_last_schedules_update() {
@@ -2594,10 +2594,10 @@  discard block
 block discarded – undo
2594 2594
 		try {
2595 2595
 			$Connection = new Connection();
2596 2596
 			$sth = $Connection->db->prepare($query);
2597
-                        $sth->execute();
2598
-                } catch(PDOException $e) {
2599
-                        return "error : ".$e->getMessage();
2600
-                }
2597
+						$sth->execute();
2598
+				} catch(PDOException $e) {
2599
+						return "error : ".$e->getMessage();
2600
+				}
2601 2601
 	}
2602 2602
 	public static function check_last_tle_update() {
2603 2603
 		global $globalDBdriver;
@@ -2609,13 +2609,13 @@  discard block
 block discarded – undo
2609 2609
 		try {
2610 2610
 			$Connection = new Connection();
2611 2611
 			$sth = $Connection->db->prepare($query);
2612
-                        $sth->execute();
2613
-                } catch(PDOException $e) {
2614
-                        return "error : ".$e->getMessage();
2615
-                }
2616
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2617
-                if ($row['nb'] > 0) return false;
2618
-                else return true;
2612
+						$sth->execute();
2613
+				} catch(PDOException $e) {
2614
+						return "error : ".$e->getMessage();
2615
+				}
2616
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2617
+				if ($row['nb'] > 0) return false;
2618
+				else return true;
2619 2619
 	}
2620 2620
 
2621 2621
 	public static function insert_last_tle_update() {
@@ -2624,10 +2624,10 @@  discard block
 block discarded – undo
2624 2624
 		try {
2625 2625
 			$Connection = new Connection();
2626 2626
 			$sth = $Connection->db->prepare($query);
2627
-                        $sth->execute();
2628
-                } catch(PDOException $e) {
2629
-                        return "error : ".$e->getMessage();
2630
-                }
2627
+						$sth->execute();
2628
+				} catch(PDOException $e) {
2629
+						return "error : ".$e->getMessage();
2630
+				}
2631 2631
 	}
2632 2632
 	public static function check_last_marine_identity_update() {
2633 2633
 		global $globalDBdriver;
@@ -2639,13 +2639,13 @@  discard block
 block discarded – undo
2639 2639
 		try {
2640 2640
 			$Connection = new Connection();
2641 2641
 			$sth = $Connection->db->prepare($query);
2642
-                        $sth->execute();
2643
-                } catch(PDOException $e) {
2644
-                        return "error : ".$e->getMessage();
2645
-                }
2646
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2647
-                if ($row['nb'] > 0) return false;
2648
-                else return true;
2642
+						$sth->execute();
2643
+				} catch(PDOException $e) {
2644
+						return "error : ".$e->getMessage();
2645
+				}
2646
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2647
+				if ($row['nb'] > 0) return false;
2648
+				else return true;
2649 2649
 	}
2650 2650
 
2651 2651
 	public static function insert_last_marine_identity_update() {
@@ -2654,10 +2654,10 @@  discard block
 block discarded – undo
2654 2654
 		try {
2655 2655
 			$Connection = new Connection();
2656 2656
 			$sth = $Connection->db->prepare($query);
2657
-                        $sth->execute();
2658
-                } catch(PDOException $e) {
2659
-                        return "error : ".$e->getMessage();
2660
-                }
2657
+						$sth->execute();
2658
+				} catch(PDOException $e) {
2659
+						return "error : ".$e->getMessage();
2660
+				}
2661 2661
 	}
2662 2662
 	public static function delete_duplicatemodes() {
2663 2663
 		global $globalDBdriver;
@@ -2669,10 +2669,10 @@  discard block
 block discarded – undo
2669 2669
 		try {
2670 2670
 			$Connection = new Connection();
2671 2671
 			$sth = $Connection->db->prepare($query);
2672
-                        $sth->execute();
2673
-                } catch(PDOException $e) {
2674
-                        return "error : ".$e->getMessage();
2675
-                }
2672
+						$sth->execute();
2673
+				} catch(PDOException $e) {
2674
+						return "error : ".$e->getMessage();
2675
+				}
2676 2676
 	}
2677 2677
 	public static function delete_duplicateowner() {
2678 2678
 		global $globalDBdriver;
@@ -2684,10 +2684,10 @@  discard block
 block discarded – undo
2684 2684
 		try {
2685 2685
 			$Connection = new Connection();
2686 2686
 			$sth = $Connection->db->prepare($query);
2687
-                        $sth->execute();
2688
-                } catch(PDOException $e) {
2689
-                        return "error : ".$e->getMessage();
2690
-                }
2687
+						$sth->execute();
2688
+				} catch(PDOException $e) {
2689
+						return "error : ".$e->getMessage();
2690
+				}
2691 2691
 	}
2692 2692
 	
2693 2693
 	public static function update_all() {
Please login to merge, or discard this patch.
Doc Comments   +42 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@  discard block
 block discarded – undo
10 10
 class update_db {
11 11
 	public static $db_sqlite;
12 12
 
13
+	/**
14
+	 * @param string $file
15
+	 */
13 16
 	public static function download($url, $file, $referer = '') {
14 17
 		//$file = str_replace('/',DIRECTORY_SEPARATOR,$file);
15 18
 		$fp = fopen($file, 'w+');
@@ -25,6 +28,9 @@  discard block
 block discarded – undo
25 28
 		fclose($fp);
26 29
 	}
27 30
 
31
+	/**
32
+	 * @param string $in_file
33
+	 */
28 34
 	public static function gunzip($in_file,$out_file_name = '') {
29 35
 		//echo $in_file.' -> '.$out_file_name."\n";
30 36
 		$buffer_size = 4096; // read 4kb at a time
@@ -46,6 +52,9 @@  discard block
 block discarded – undo
46 52
 		}
47 53
 	}
48 54
 
55
+	/**
56
+	 * @param string $in_file
57
+	 */
49 58
 	public static function unzip($in_file) {
50 59
 		if ($in_file != '' && file_exists($in_file)) {
51 60
 			$path = pathinfo(realpath($in_file), PATHINFO_DIRNAME);
@@ -67,6 +76,9 @@  discard block
 block discarded – undo
67 76
 		}
68 77
 	}
69 78
 	
79
+	/**
80
+	 * @param string $database_file
81
+	 */
70 82
 	public static function retrieve_route_sqlite_to_dest($database_file) {
71 83
 		global $globalDebug, $globalTransaction;
72 84
 		//$query = 'TRUNCATE TABLE routes';
@@ -109,6 +121,10 @@  discard block
 block discarded – undo
109 121
 		}
110 122
                 return '';
111 123
 	}
124
+
125
+	/**
126
+	 * @param string $database_file
127
+	 */
112 128
 	public static function retrieve_route_oneworld($database_file) {
113 129
 		global $globalDebug, $globalTransaction;
114 130
 		//$query = 'TRUNCATE TABLE routes';
@@ -150,6 +166,9 @@  discard block
 block discarded – undo
150 166
                 return '';
151 167
 	}
152 168
 	
169
+	/**
170
+	 * @param string $database_file
171
+	 */
153 172
 	public static function retrieve_route_skyteam($database_file) {
154 173
 		global $globalDebug, $globalTransaction;
155 174
 		//$query = 'TRUNCATE TABLE routes';
@@ -192,6 +211,10 @@  discard block
 block discarded – undo
192 211
 		}
193 212
                 return '';
194 213
 	}
214
+
215
+	/**
216
+	 * @param string $database_file
217
+	 */
195 218
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
196 219
 		global $globalTransaction;
197 220
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -258,6 +281,9 @@  discard block
 block discarded – undo
258 281
 		return '';
259 282
 	}
260 283
 
284
+	/**
285
+	 * @param string $database_file
286
+	 */
261 287
 	public static function retrieve_modes_flarmnet($database_file) {
262 288
 		global $globalTransaction;
263 289
 		$Common = new Common();
@@ -328,6 +354,9 @@  discard block
 block discarded – undo
328 354
 		return '';
329 355
 	}
330 356
 
357
+	/**
358
+	 * @param string $database_file
359
+	 */
331 360
 	public static function retrieve_modes_ogn($database_file) {
332 361
 		global $globalTransaction;
333 362
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -396,6 +425,9 @@  discard block
 block discarded – undo
396 425
 		return '';
397 426
 	}
398 427
 
428
+	/**
429
+	 * @param string $database_file
430
+	 */
399 431
 	public static function retrieve_owner($database_file,$country = 'F') {
400 432
 		global $globalTransaction, $globalMasterSource;
401 433
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -1276,6 +1308,10 @@  discard block
 block discarded – undo
1276 1308
 		return '';
1277 1309
         }
1278 1310
 
1311
+	/**
1312
+	 * @param string $filename
1313
+	 * @param string $tletype
1314
+	 */
1279 1315
 	public static function tle($filename,$tletype) {
1280 1316
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1281 1317
 		global $tmp_dir, $globalTransaction;
@@ -1408,6 +1444,9 @@  discard block
 block discarded – undo
1408 1444
 
1409 1445
 	}
1410 1446
 */
1447
+	/**
1448
+	 * @param string $filename
1449
+	 */
1411 1450
 	public static function waypoints($filename) {
1412 1451
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1413 1452
 		global $tmp_dir, $globalTransaction;
@@ -1455,6 +1494,9 @@  discard block
 block discarded – undo
1455 1494
 		return '';
1456 1495
         }
1457 1496
 
1497
+	/**
1498
+	 * @param string $filename
1499
+	 */
1458 1500
 	public static function ivao_airlines($filename) {
1459 1501
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1460 1502
 		global $tmp_dir, $globalTransaction;
Please login to merge, or discard this patch.
Spacing   +306 added lines, -306 removed lines patch added patch discarded remove patch
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
 		fclose($fp);
26 26
 	}
27 27
 
28
-	public static function gunzip($in_file,$out_file_name = '') {
28
+	public static function gunzip($in_file, $out_file_name = '') {
29 29
 		//echo $in_file.' -> '.$out_file_name."\n";
30 30
 		$buffer_size = 4096; // read 4kb at a time
31 31
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32 32
 		if ($in_file != '' && file_exists($in_file)) {
33 33
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
34
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
35
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
36 36
 			else {
37 37
 				echo 'gzopen not available';
38 38
 				die;
39 39
 			}
40 40
 			$out_file = fopen($out_file_name, 'wb'); 
41
-			while(!gzeof($file)) {
41
+			while (!gzeof($file)) {
42 42
 				fwrite($out_file, gzread($file, $buffer_size));
43 43
 			}  
44 44
 			fclose($out_file);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		try {
63 63
 			self::$db_sqlite = new PDO('sqlite:'.$database);
64 64
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
65
-		} catch(PDOException $e) {
65
+		} catch (PDOException $e) {
66 66
 			return "error : ".$e->getMessage();
67 67
 		}
68 68
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79 79
                         $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
80
+                } catch (PDOException $e) {
81 81
                         return "error : ".$e->getMessage();
82 82
                 }
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		try {
89 89
                         $sth = update_db::$db_sqlite->prepare($query);
90 90
                         $sth->execute();
91
-                } catch(PDOException $e) {
91
+                } catch (PDOException $e) {
92 92
                         return "error : ".$e->getMessage();
93 93
                 }
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100 100
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104 104
             		}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
@@ -119,26 +119,26 @@  discard block
 block discarded – undo
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121 121
                         $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
122
+                } catch (PDOException $e) {
123 123
                         return "error : ".$e->getMessage();
124 124
                 }
125 125
 
126 126
     		if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129
-		if ($fh = fopen($database_file,"r")) {
129
+		if ($fh = fopen($database_file, "r")) {
130 130
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 131
 			$Connection = new Connection();
132 132
 			$sth_dest = $Connection->db->prepare($query_dest);
133 133
 			if ($globalTransaction) $Connection->db->beginTransaction();
134 134
 			while (!feof($fh)) {
135
-				$line = fgetcsv($fh,9999,',');
135
+				$line = fgetcsv($fh, 9999, ',');
136 136
 				if ($line[0] != '') {
137 137
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
138 138
 						try {
139
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
140 140
 							$sth_dest->execute($query_dest_values);
141
-						} catch(PDOException $e) {
141
+						} catch (PDOException $e) {
142 142
 							if ($globalTransaction) $Connection->db->rollBack(); 
143 143
 							return "error : ".$e->getMessage();
144 144
 						}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162 162
                         $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
163
+                } catch (PDOException $e) {
164 164
                         return "error : ".$e->getMessage();
165 165
                 }
166 166
 
@@ -168,24 +168,24 @@  discard block
 block discarded – undo
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
171
-		if ($fh = fopen($database_file,"r")) {
171
+		if ($fh = fopen($database_file, "r")) {
172 172
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
173 173
 			$Connection = new Connection();
174 174
 			$sth_dest = $Connection->db->prepare($query_dest);
175 175
 			try {
176 176
 				if ($globalTransaction) $Connection->db->beginTransaction();
177 177
 				while (!feof($fh)) {
178
-					$line = fgetcsv($fh,9999,',');
178
+					$line = fgetcsv($fh, 9999, ',');
179 179
 					if ($line[0] != '') {
180
-						$datebe = explode('  -  ',$line[2]);
180
+						$datebe = explode('  -  ', $line[2]);
181 181
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
182
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
182
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
183 183
 							$sth_dest->execute($query_dest_values);
184 184
 						}
185 185
 					}
186 186
 				}
187 187
 				if ($globalTransaction) $Connection->db->commit();
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				if ($globalTransaction) $Connection->db->rollBack(); 
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202 202
                         $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
203
+                } catch (PDOException $e) {
204 204
                         return "error : ".$e->getMessage();
205 205
                 }
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210 210
                         $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
211
+                } catch (PDOException $e) {
212 212
                         return "error : ".$e->getMessage();
213 213
                 }
214 214
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		try {
218 218
                         $sth = update_db::$db_sqlite->prepare($query);
219 219
                         $sth->execute();
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
241 241
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243 243
             		}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245
-		} catch(PDOException $e) {
245
+		} catch (PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
247 247
 		}
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254 254
                         $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
255
+                } catch (PDOException $e) {
256 256
                         return "error : ".$e->getMessage();
257 257
                 }
258 258
 		return '';
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269 269
                         $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
270
+                } catch (PDOException $e) {
271 271
                         return "error : ".$e->getMessage();
272 272
                 }
273 273
 		
274
-		if ($fh = fopen($database_file,"r")) {
274
+		if ($fh = fopen($database_file, "r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
276 276
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
277 277
 		
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282 282
             			while (!feof($fh)) {
283 283
             				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
284
+            				$line = $Common->hex2str(fgets($fh, 9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
286
+            				$values['ModeS'] = substr($line, 0, 6);
287
+            				$values['Registration'] = trim(substr($line, 69, 6));
288
+            				$aircraft_name = trim(substr($line, 48, 6));
289 289
             				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
+            				$aircraft_name_split = explode(' ', $aircraft_name);
291 291
             				$search_more = '';
292 292
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293 293
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 	            				if (isset($result['icao']) && $result['icao'] != '') {
300 300
 	            				    $values['ICAOTypeCode'] = $result['icao'];
301 301
 	            				} 
302
-					} catch(PDOException $e) {
302
+					} catch (PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
305 305
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
306 306
 					// Add data to db
307 307
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 308
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
309
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
309
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
310 310
 						//print_r($query_dest_values);
311 311
 						$sth_dest->execute($query_dest_values);
312 312
 					}
313 313
 				}
314 314
 				if ($globalTransaction) $Connection->db->commit();
315
-			} catch(PDOException $e) {
315
+			} catch (PDOException $e) {
316 316
 				return "error : ".$e->getMessage();
317 317
 			}
318 318
 		}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324 324
                         $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
325
+                } catch (PDOException $e) {
326 326
                         return "error : ".$e->getMessage();
327 327
                 }
328 328
 		return '';
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338 338
                         $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
339
+                } catch (PDOException $e) {
340 340
                         return "error : ".$e->getMessage();
341 341
                 }
342 342
 		
343
-		if ($fh = fopen($database_file,"r")) {
343
+		if ($fh = fopen($database_file, "r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
345 345
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
346 346
 		
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 			$sth_dest = $Connection->db->prepare($query_dest);
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351
-				$tmp = fgetcsv($fh,9999,',',"'");
351
+				$tmp = fgetcsv($fh, 9999, ',', "'");
352 352
             			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
353
+            				$line = fgetcsv($fh, 9999, ',', "'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
             				$values['Registration'] = $line[3];
359 359
             				$aircraft_name = $line[2];
360 360
             				// Check if we can find ICAO, else set it to GLID
361
-            				$aircraft_name_split = explode(' ',$aircraft_name);
361
+            				$aircraft_name_split = explode(' ', $aircraft_name);
362 362
             				$search_more = '';
363 363
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
364 364
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -367,20 +367,20 @@  discard block
 block discarded – undo
367 367
                                     		$sth_search->execute();
368 368
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
369 369
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
370
-					} catch(PDOException $e) {
370
+					} catch (PDOException $e) {
371 371
 						return "error : ".$e->getMessage();
372 372
 					}
373 373
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
374 374
 					// Add data to db
375 375
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
376 376
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
377
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
377
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
378 378
 						//print_r($query_dest_values);
379 379
 						$sth_dest->execute($query_dest_values);
380 380
 					}
381 381
 				}
382 382
 				if ($globalTransaction) $Connection->db->commit();
383
-			} catch(PDOException $e) {
383
+			} catch (PDOException $e) {
384 384
 				return "error : ".$e->getMessage();
385 385
 			}
386 386
 		}
@@ -390,13 +390,13 @@  discard block
 block discarded – undo
390 390
 			$Connection = new Connection();
391 391
 			$sth = $Connection->db->prepare($query);
392 392
                         $sth->execute(array(':source' => $database_file));
393
-                } catch(PDOException $e) {
393
+                } catch (PDOException $e) {
394 394
                         return "error : ".$e->getMessage();
395 395
                 }
396 396
 		return '';
397 397
 	}
398 398
 
399
-	public static function retrieve_owner($database_file,$country = 'F') {
399
+	public static function retrieve_owner($database_file, $country = 'F') {
400 400
 		global $globalTransaction, $globalMasterSource;
401 401
 		//$query = 'TRUNCATE TABLE aircraft_modes';
402 402
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 			$Connection = new Connection();
405 405
 			$sth = $Connection->db->prepare($query);
406 406
                         $sth->execute(array(':source' => $database_file));
407
-                } catch(PDOException $e) {
407
+                } catch (PDOException $e) {
408 408
                         return "error : ".$e->getMessage();
409 409
                 }
410 410
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
411 411
 		$Spotter = new Spotter();
412
-		if ($fh = fopen($database_file,"r")) {
412
+		if ($fh = fopen($database_file, "r")) {
413 413
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
414 414
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
415 415
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
 			$sth_modes = $Connection->db->prepare($query_modes);
420 420
 			try {
421 421
 				if ($globalTransaction) $Connection->db->beginTransaction();
422
-				$tmp = fgetcsv($fh,9999,',','"');
422
+				$tmp = fgetcsv($fh, 9999, ',', '"');
423 423
             			while (!feof($fh)) {
424
-            				$line = fgetcsv($fh,9999,',','"');
424
+            				$line = fgetcsv($fh, 9999, ',', '"');
425 425
             				$values = array();
426 426
             				//print_r($line);
427 427
             				if ($country == 'F') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
             				    $values['base'] = $line[4];
430 430
             				    $values['owner'] = $line[5];
431 431
             				    if ($line[6] == '') $values['date_first_reg'] = null;
432
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
432
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
433 433
 					    $values['cancel'] = $line[7];
434 434
 					} elseif ($country == 'EI') {
435 435
 					    // TODO : add modeS & reg to aircraft_modes
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
             				    $values['base'] = $line[3];
438 438
             				    $values['owner'] = $line[2];
439 439
             				    if ($line[1] == '') $values['date_first_reg'] = null;
440
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
440
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
441 441
 					    $values['cancel'] = '';
442 442
 					    $values['modes'] = $line[7];
443 443
 					    $values['icao'] = $line[8];
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             				    $values['base'] = null;
458 458
             				    $values['owner'] = $line[5];
459 459
             				    if ($line[18] == '') $values['date_first_reg'] = null;
460
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
460
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
461 461
 					    $values['cancel'] = '';
462 462
 					} elseif ($country == 'VH') {
463 463
 					    // TODO : add modeS & reg to aircraft_modes
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
             				    $values['base'] = null;
466 466
             				    $values['owner'] = $line[12];
467 467
             				    if ($line[28] == '') $values['date_first_reg'] = null;
468
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
468
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
469 469
 
470 470
 					    $values['cancel'] = $line[39];
471 471
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -485,28 +485,28 @@  discard block
 block discarded – undo
485 485
             				    $values['base'] = null;
486 486
             				    $values['owner'] = $line[8];
487 487
             				    if ($line[7] == '') $values['date_first_reg'] = null;
488
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
488
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
489 489
 					    $values['cancel'] = '';
490 490
 					} elseif ($country == 'PP') {
491 491
             				    $values['registration'] = $line[0];
492 492
             				    $values['base'] = null;
493 493
             				    $values['owner'] = $line[4];
494 494
             				    if ($line[6] == '') $values['date_first_reg'] = null;
495
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
496 496
 					    $values['cancel'] = $line[7];
497 497
 					} elseif ($country == 'E7') {
498 498
             				    $values['registration'] = $line[0];
499 499
             				    $values['base'] = null;
500 500
             				    $values['owner'] = $line[4];
501 501
             				    if ($line[5] == '') $values['date_first_reg'] = null;
502
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
502
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
503 503
 					    $values['cancel'] = '';
504 504
 					} elseif ($country == '8Q') {
505 505
             				    $values['registration'] = $line[0];
506 506
             				    $values['base'] = null;
507 507
             				    $values['owner'] = $line[3];
508 508
             				    if ($line[7] == '') $values['date_first_reg'] = null;
509
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
509
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
510 510
 					    $values['cancel'] = '';
511 511
 					} elseif ($country == 'ZK') {
512 512
             				    $values['registration'] = $line[0];
@@ -520,18 +520,18 @@  discard block
 block discarded – undo
520 520
             				    $values['registration'] = $line[0];
521 521
             				    $values['base'] = null;
522 522
             				    $values['owner'] = $line[6];
523
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
524
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
523
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
524
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
525 525
 					    $values['modes'] = $line[4];
526 526
 					    $values['icao'] = $line[10];
527 527
 					} elseif ($country == 'OY') {
528 528
             				    $values['registration'] = $line[0];
529
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
529
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
530 530
 					    $values['modes'] = $line[5];
531 531
 					    $values['icao'] = $line[6];
532 532
 					} elseif ($country == 'PH') {
533 533
             				    $values['registration'] = $line[0];
534
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
534
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
535 535
 					    $values['modes'] = $line[4];
536 536
 					    $values['icao'] = $line[5];
537 537
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -542,17 +542,17 @@  discard block
 block discarded – undo
542 542
 					    $values['cancel'] = '';
543 543
 					}
544 544
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
545
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
545
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
546 546
 						$sth_dest->execute($query_dest_values);
547 547
 					}
548 548
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
549 549
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
550
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
550
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
551 551
 						$sth_modes->execute($query_modes_values);
552 552
 					}
553 553
 				}
554 554
 				if ($globalTransaction) $Connection->db->commit();
555
-			} catch(PDOException $e) {
555
+			} catch (PDOException $e) {
556 556
 				return "error : ".$e->getMessage();
557 557
 			}
558 558
 		}
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 			$Connection = new Connection();
668 668
 			$sth = $Connection->db->prepare($query);
669 669
                         $sth->execute();
670
-                } catch(PDOException $e) {
670
+                } catch (PDOException $e) {
671 671
                         return "error : ".$e->getMessage();
672 672
                 }
673 673
 
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 			$Connection = new Connection();
678 678
 			$sth = $Connection->db->prepare($query);
679 679
                         $sth->execute();
680
-                } catch(PDOException $e) {
680
+                } catch (PDOException $e) {
681 681
                         return "error : ".$e->getMessage();
682 682
                 }
683 683
 
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 		if ($globalTransaction) $Connection->db->beginTransaction();
689 689
   
690 690
 		$i = 0;
691
-		while($row = sparql_fetch_array($result))
691
+		while ($row = sparql_fetch_array($result))
692 692
 		{
693 693
 			if ($i >= 1) {
694 694
 			//print_r($row);
@@ -708,31 +708,31 @@  discard block
 block discarded – undo
708 708
 				$row['image'] = '';
709 709
 				$row['image_thumb'] = '';
710 710
 			} else {
711
-				$image = str_replace(' ','_',$row['image']);
711
+				$image = str_replace(' ', '_', $row['image']);
712 712
 				$digest = md5($image);
713
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
714
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
715
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
716
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
713
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
714
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
715
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
716
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
717 717
 			}
718 718
 			
719
-			$country = explode('-',$row['country']);
719
+			$country = explode('-', $row['country']);
720 720
 			$row['country'] = $country[0];
721 721
 			
722 722
 			$row['type'] = trim($row['type']);
723
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
723
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
724 724
 				$row['type'] = 'Military';
725 725
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
726 726
 				$row['type'] = 'small_airport';
727 727
 			}
728 728
 			
729
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
730
-			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
729
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
730
+			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
731 731
 			//print_r($query_dest_values);
732 732
 			
733 733
 			try {
734 734
 				$sth_dest->execute($query_dest_values);
735
-			} catch(PDOException $e) {
735
+			} catch (PDOException $e) {
736 736
 				return "error : ".$e->getMessage();
737 737
 			}
738 738
 			}
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 			$Connection = new Connection();
747 747
 			$sth = $Connection->db->prepare($query);
748 748
                         $sth->execute();
749
-                } catch(PDOException $e) {
749
+                } catch (PDOException $e) {
750 750
                         return "error : ".$e->getMessage();
751 751
                 }
752 752
 
@@ -754,12 +754,12 @@  discard block
 block discarded – undo
754 754
 		if ($globalDebug) echo "Insert Not available Airport...\n";
755 755
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
756 756
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
757
-		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
757
+		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => '');
758 758
 		try {
759 759
 			$Connection = new Connection();
760 760
 			$sth = $Connection->db->prepare($query);
761 761
                         $sth->execute($query_values);
762
-                } catch(PDOException $e) {
762
+                } catch (PDOException $e) {
763 763
                         return "error : ".$e->getMessage();
764 764
                 }
765 765
 		$i++;
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 		echo "Download data from ourairports.com...\n";
778 778
 		$delimiter = ',';
779 779
 		$out_file = $tmp_dir.'airports.csv';
780
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
780
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
781 781
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
782 782
 		echo "Add data from ourairports.com...\n";
783 783
 
@@ -788,32 +788,32 @@  discard block
 block discarded – undo
788 788
 			//$Connection->db->beginTransaction();
789 789
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
790 790
 			{
791
-				if(!$header) $header = $row;
791
+				if (!$header) $header = $row;
792 792
 				else {
793 793
 					$data = array();
794 794
 					$data = array_combine($header, $row);
795 795
 					try {
796 796
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
797 797
 						$sth->execute(array(':icao' => $data['gps_code']));
798
-					} catch(PDOException $e) {
798
+					} catch (PDOException $e) {
799 799
 						return "error : ".$e->getMessage();
800 800
 					}
801 801
 					if ($sth->fetchColumn() > 0) {
802 802
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
803 803
 						try {
804 804
 							$sth = $Connection->db->prepare($query);
805
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
806
-						} catch(PDOException $e) {
805
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
806
+						} catch (PDOException $e) {
807 807
 							return "error : ".$e->getMessage();
808 808
 						}
809 809
 					} else {
810 810
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
811 811
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
812
-						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
812
+						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
813 813
 						try {
814 814
 							$sth = $Connection->db->prepare($query);
815 815
 							$sth->execute($query_values);
816
-						} catch(PDOException $e) {
816
+						} catch (PDOException $e) {
817 817
 							return "error : ".$e->getMessage();
818 818
 						}
819 819
 						$i++;
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 
827 827
 		echo "Download data from another free database...\n";
828 828
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
829
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
829
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
830 830
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
831 831
 		update_db::unzip($out_file);
832 832
 		$header = NULL;
@@ -838,15 +838,15 @@  discard block
 block discarded – undo
838 838
 			//$Connection->db->beginTransaction();
839 839
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
840 840
 			{
841
-				if(!$header) $header = $row;
841
+				if (!$header) $header = $row;
842 842
 				else {
843 843
 					$data = $row;
844 844
 
845 845
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
846 846
 					try {
847 847
 						$sth = $Connection->db->prepare($query);
848
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
849
-					} catch(PDOException $e) {
848
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
849
+					} catch (PDOException $e) {
850 850
 						return "error : ".$e->getMessage();
851 851
 					}
852 852
 				}
@@ -860,15 +860,15 @@  discard block
 block discarded – undo
860 860
 		try {
861 861
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
862 862
 			$sth->execute();
863
-		} catch(PDOException $e) {
863
+		} catch (PDOException $e) {
864 864
 			return "error : ".$e->getMessage();
865 865
 		}
866 866
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
867 867
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
868 868
 			try {
869 869
 				$sth2 = $Connection->db->prepare($query2);
870
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
871
-			} catch(PDOException $e) {
870
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
871
+			} catch (PDOException $e) {
872 872
 				return "error : ".$e->getMessage();
873 873
 			}
874 874
 		}
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 			$Connection = new Connection();
893 893
 			$sth = $Connection->db->prepare($query);
894 894
                         $sth->execute(array(':source' => 'translation.csv'));
895
-                } catch(PDOException $e) {
895
+                } catch (PDOException $e) {
896 896
                         return "error : ".$e->getMessage();
897 897
                 }
898 898
 
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
910 910
 			{
911 911
 				$i++;
912
-				if($i > 12) {
912
+				if ($i > 12) {
913 913
 					$data = $row;
914 914
 					$operator = $data[2];
915 915
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
                                                 //echo substr($operator, 0, 2)."\n";;
918 918
                                                 if (count($airline_array) > 0) {
919 919
 							//print_r($airline_array);
920
-							$operator = $airline_array[0]['icao'].substr($operator,2);
920
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
921 921
                                                 }
922 922
                                         }
923 923
 					
@@ -925,14 +925,14 @@  discard block
 block discarded – undo
925 925
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
926 926
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
927 927
                                                 if (count($airline_array) > 0) {
928
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
928
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
929 929
                                             	}
930 930
                                         }
931 931
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
932 932
 					try {
933 933
 						$sth = $Connection->db->prepare($query);
934
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
935
-					} catch(PDOException $e) {
934
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
935
+					} catch (PDOException $e) {
936 936
 						return "error : ".$e->getMessage();
937 937
 					}
938 938
 				}
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
 			$Connection = new Connection();
953 953
 			$sth = $Connection->db->prepare($query);
954 954
                         $sth->execute(array(':source' => 'website_fam'));
955
-                } catch(PDOException $e) {
955
+                } catch (PDOException $e) {
956 956
                         return "error : ".$e->getMessage();
957 957
                 }
958 958
 
@@ -972,8 +972,8 @@  discard block
 block discarded – undo
972 972
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
973 973
 					try {
974 974
 						$sth = $Connection->db->prepare($query);
975
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
976
-					} catch(PDOException $e) {
975
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
976
+					} catch (PDOException $e) {
977 977
 						return "error : ".$e->getMessage();
978 978
 					}
979 979
 				}
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 			$Connection = new Connection();
997 997
 			$sth = $Connection->db->prepare($query);
998 998
                         $sth->execute(array(':source' => 'website_faa'));
999
-                } catch(PDOException $e) {
999
+                } catch (PDOException $e) {
1000 1000
                         return "error : ".$e->getMessage();
1001 1001
                 }
1002 1002
 
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 			$Connection = new Connection();
1006 1006
 			$sth = $Connection->db->prepare($query);
1007 1007
                         $sth->execute(array(':source' => 'website_faa'));
1008
-                } catch(PDOException $e) {
1008
+                } catch (PDOException $e) {
1009 1009
                         return "error : ".$e->getMessage();
1010 1010
                 }
1011 1011
 
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1023 1023
 					try {
1024 1024
 						$sths = $Connection->db->prepare($query_search);
1025
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1026
-					} catch(PDOException $e) {
1025
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1026
+					} catch (PDOException $e) {
1027 1027
 						return "error s : ".$e->getMessage();
1028 1028
 					}
1029 1029
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
 							//}
1037 1037
 						try {
1038 1038
 							$sthi = $Connection->db->prepare($queryi);
1039
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1040
-						} catch(PDOException $e) {
1039
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1040
+						} catch (PDOException $e) {
1041 1041
 							return "error u : ".$e->getMessage();
1042 1042
 						}
1043 1043
 					} else {
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 						try {
1046 1046
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1047 1047
 							$sthsm->execute(array(':mfr' => $data[2]));
1048
-						} catch(PDOException $e) {
1048
+						} catch (PDOException $e) {
1049 1049
 							return "error mfr : ".$e->getMessage();
1050 1050
 						}
1051 1051
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1055,8 +1055,8 @@  discard block
 block discarded – undo
1055 1055
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1056 1056
 							try {
1057 1057
 								$sthf = $Connection->db->prepare($queryf);
1058
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1059
-							} catch(PDOException $e) {
1058
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1059
+							} catch (PDOException $e) {
1060 1060
 								return "error f : ".$e->getMessage();
1061 1061
 							}
1062 1062
 						}
@@ -1066,13 +1066,13 @@  discard block
 block discarded – undo
1066 1066
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1067 1067
 						try {
1068 1068
 							$sth = $Connection->db->prepare($query);
1069
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1070
-						} catch(PDOException $e) {
1069
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1070
+						} catch (PDOException $e) {
1071 1071
 							return "error i : ".$e->getMessage();
1072 1072
 						}
1073 1073
 					}
1074 1074
 				}
1075
-				if ($i % 90 == 0) {
1075
+				if ($i%90 == 0) {
1076 1076
 					if ($globalTransaction) $Connection->db->commit();
1077 1077
 					if ($globalTransaction) $Connection->db->beginTransaction();
1078 1078
 				}
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 			$Connection = new Connection();
1092 1092
 			$sth = $Connection->db->prepare($query);
1093 1093
                         $sth->execute(array(':source' => 'website_fam'));
1094
-                } catch(PDOException $e) {
1094
+                } catch (PDOException $e) {
1095 1095
                         return "error : ".$e->getMessage();
1096 1096
                 }
1097 1097
 
@@ -1112,8 +1112,8 @@  discard block
 block discarded – undo
1112 1112
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1113 1113
 					try {
1114 1114
 						$sth = $Connection->db->prepare($query);
1115
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1116
-					} catch(PDOException $e) {
1115
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1116
+					} catch (PDOException $e) {
1117 1117
 						return "error : ".$e->getMessage();
1118 1118
 					}
1119 1119
 				}
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 			$Connection = new Connection();
1133 1133
 			$sth = $Connection->db->prepare($query);
1134 1134
                         $sth->execute(array(':source' => 'website_fam'));
1135
-                } catch(PDOException $e) {
1135
+                } catch (PDOException $e) {
1136 1136
                         return "error : ".$e->getMessage();
1137 1137
                 }
1138 1138
 
@@ -1148,8 +1148,8 @@  discard block
 block discarded – undo
1148 1148
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1149 1149
 					try {
1150 1150
 						$sth = $Connection->db->prepare($query);
1151
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1152
-					} catch(PDOException $e) {
1151
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1152
+					} catch (PDOException $e) {
1153 1153
 						print_r($data);
1154 1154
 						return "error : ".$e->getMessage();
1155 1155
 					}
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 			$Connection = new Connection();
1170 1170
 			$sth = $Connection->db->prepare($query);
1171 1171
                         $sth->execute(array(':source' => 'website_fam'));
1172
-                } catch(PDOException $e) {
1172
+                } catch (PDOException $e) {
1173 1173
                         return "error : ".$e->getMessage();
1174 1174
                 }
1175 1175
 
@@ -1189,8 +1189,8 @@  discard block
 block discarded – undo
1189 1189
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1190 1190
 					try {
1191 1191
 						$sth = $Connection->db->prepare($query);
1192
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1193
-					} catch(PDOException $e) {
1192
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1193
+					} catch (PDOException $e) {
1194 1194
 						return "error : ".$e->getMessage();
1195 1195
 					}
1196 1196
 				}
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
 			$Connection = new Connection();
1210 1210
 			$sth = $Connection->db->prepare($query);
1211 1211
                         $sth->execute();
1212
-                } catch(PDOException $e) {
1212
+                } catch (PDOException $e) {
1213 1213
                         return "error : ".$e->getMessage();
1214 1214
                 }
1215 1215
 
@@ -1229,8 +1229,8 @@  discard block
 block discarded – undo
1229 1229
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1230 1230
 					try {
1231 1231
 						$sth = $Connection->db->prepare($query);
1232
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1233
-					} catch(PDOException $e) {
1232
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1233
+					} catch (PDOException $e) {
1234 1234
 						return "error : ".$e->getMessage();
1235 1235
 					}
1236 1236
 				}
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 			$Connection = new Connection();
1250 1250
 			$sth = $Connection->db->prepare($query);
1251 1251
 			$sth->execute();
1252
-		} catch(PDOException $e) {
1252
+		} catch (PDOException $e) {
1253 1253
 			return "error : ".$e->getMessage();
1254 1254
 		}
1255 1255
 
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
 					try {
1266 1266
 						$sth = $Connection->db->prepare($query);
1267 1267
 						$sth->execute(array(':icao' => $icao));
1268
-					} catch(PDOException $e) {
1268
+					} catch (PDOException $e) {
1269 1269
 						return "error : ".$e->getMessage();
1270 1270
 					}
1271 1271
 				}
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		return '';
1277 1277
         }
1278 1278
 
1279
-	public static function tle($filename,$tletype) {
1279
+	public static function tle($filename, $tletype) {
1280 1280
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1281 1281
 		global $tmp_dir, $globalTransaction;
1282 1282
 		//$Spotter = new Spotter();
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
 			$Connection = new Connection();
1287 1287
 			$sth = $Connection->db->prepare($query);
1288 1288
                         $sth->execute(array(':source' => $filename));
1289
-                } catch(PDOException $e) {
1289
+                } catch (PDOException $e) {
1290 1290
                         return "error : ".$e->getMessage();
1291 1291
                 }
1292 1292
 		
@@ -1311,8 +1311,8 @@  discard block
 block discarded – undo
1311 1311
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1312 1312
 					try {
1313 1313
 						$sth = $Connection->db->prepare($query);
1314
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1315
-					} catch(PDOException $e) {
1314
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1315
+					} catch (PDOException $e) {
1316 1316
 						return "error : ".$e->getMessage();
1317 1317
 					}
1318 1318
 
@@ -1332,28 +1332,28 @@  discard block
 block discarded – undo
1332 1332
         */
1333 1333
         private static function table2array($data) {
1334 1334
                 $html = str_get_html($data);
1335
-                $tabledata=array();
1336
-                foreach($html->find('tr') as $element)
1335
+                $tabledata = array();
1336
+                foreach ($html->find('tr') as $element)
1337 1337
                 {
1338 1338
                         $td = array();
1339
-                        foreach( $element->find('th') as $row)
1339
+                        foreach ($element->find('th') as $row)
1340 1340
                         {
1341 1341
                                 $td [] = trim($row->plaintext);
1342 1342
                         }
1343
-                        $td=array_filter($td);
1343
+                        $td = array_filter($td);
1344 1344
                         $tabledata[] = $td;
1345 1345
 
1346 1346
                         $td = array();
1347 1347
                         $tdi = array();
1348
-                        foreach( $element->find('td') as $row)
1348
+                        foreach ($element->find('td') as $row)
1349 1349
                         {
1350 1350
                                 $td [] = trim($row->plaintext);
1351 1351
                                 $tdi [] = trim($row->innertext);
1352 1352
                         }
1353
-                        $td=array_filter($td);
1354
-                        $tdi=array_filter($tdi);
1353
+                        $td = array_filter($td);
1354
+                        $tdi = array_filter($tdi);
1355 1355
                     //    $tabledata[]=array_merge($td,$tdi);
1356
-                        $tabledata[]=$td;
1356
+                        $tabledata[] = $td;
1357 1357
                 }
1358 1358
                 return(array_filter($tabledata));
1359 1359
         }
@@ -1426,13 +1426,13 @@  discard block
 block discarded – undo
1426 1426
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1427 1427
 			{
1428 1428
 				$i++;
1429
-				if($i > 3 && count($row) > 2) {
1429
+				if ($i > 3 && count($row) > 2) {
1430 1430
 					$data = array_values(array_filter($row));
1431 1431
 					$cntdata = count($data);
1432 1432
 					if ($cntdata > 10) {
1433 1433
 						$value = $data[9];
1434 1434
 						
1435
-						for ($i =10;$i < $cntdata;$i++) {
1435
+						for ($i = 10; $i < $cntdata; $i++) {
1436 1436
 							$value .= ' '.$data[$i];
1437 1437
 						}
1438 1438
 						$data[9] = $value;
@@ -1442,8 +1442,8 @@  discard block
 block discarded – undo
1442 1442
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1443 1443
 						try {
1444 1444
 							$sth = $Connection->db->prepare($query);
1445
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1446
-						} catch(PDOException $e) {
1445
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1446
+						} catch (PDOException $e) {
1447 1447
 							return "error : ".$e->getMessage();
1448 1448
 						}
1449 1449
 					}
@@ -1464,7 +1464,7 @@  discard block
 block discarded – undo
1464 1464
 			$Connection = new Connection();
1465 1465
 			$sth = $Connection->db->prepare($query);
1466 1466
                         $sth->execute();
1467
-                } catch(PDOException $e) {
1467
+                } catch (PDOException $e) {
1468 1468
                         return "error : ".$e->getMessage();
1469 1469
                 }
1470 1470
 
@@ -1476,12 +1476,12 @@  discard block
 block discarded – undo
1476 1476
 			if ($globalTransaction) $Connection->db->beginTransaction();
1477 1477
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1478 1478
 			{
1479
-				if(count($row) > 1) {
1479
+				if (count($row) > 1) {
1480 1480
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1481 1481
 					try {
1482 1482
 						$sth = $Connection->db->prepare($query);
1483
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1484
-					} catch(PDOException $e) {
1483
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1484
+					} catch (PDOException $e) {
1485 1485
 						return "error : ".$e->getMessage();
1486 1486
 					}
1487 1487
 				}
@@ -1501,21 +1501,21 @@  discard block
 block discarded – undo
1501 1501
 			try {
1502 1502
 				$sth = $Connection->db->prepare($query);
1503 1503
                     		$sth->execute();
1504
-	                } catch(PDOException $e) {
1504
+	                } catch (PDOException $e) {
1505 1505
 				return "error : ".$e->getMessage();
1506 1506
 	                }
1507 1507
 	        }
1508 1508
 
1509 1509
 
1510
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1510
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1511 1511
 		else {
1512
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1512
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1513 1513
 			$query = "CREATE EXTENSION postgis";
1514
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1514
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1515 1515
 			try {
1516 1516
 				$sth = $Connection->db->prepare($query);
1517 1517
 				$sth->execute();
1518
-			} catch(PDOException $e) {
1518
+			} catch (PDOException $e) {
1519 1519
 				return "error : ".$e->getMessage();
1520 1520
 			}
1521 1521
 		}
@@ -1528,7 +1528,7 @@  discard block
 block discarded – undo
1528 1528
 		include_once('class.create_db.php');
1529 1529
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1530 1530
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1531
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1531
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1532 1532
 		$error = '';
1533 1533
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1534 1534
 			if ($globalDebug) echo "Gunzip...";
@@ -1560,14 +1560,14 @@  discard block
 block discarded – undo
1560 1560
 			try {
1561 1561
 				$sth = $Connection->db->prepare($query);
1562 1562
             	        	$sth->execute();
1563
-	                } catch(PDOException $e) {
1563
+	                } catch (PDOException $e) {
1564 1564
     	                	echo "error : ".$e->getMessage();
1565 1565
 	                }
1566 1566
 		}
1567 1567
 		if ($globalDBdriver == 'mysql') {
1568
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1568
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1569 1569
 		} else {
1570
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1570
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1571 1571
 		}
1572 1572
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1573 1573
 		return $error;
@@ -1580,7 +1580,7 @@  discard block
 block discarded – undo
1580 1580
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1581 1581
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1582 1582
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1583
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1583
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
1584 1584
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1585 1585
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1586 1586
 		return $error;
@@ -1600,7 +1600,7 @@  discard block
 block discarded – undo
1600 1600
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1601 1601
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1602 1602
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1603
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1603
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1604 1604
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1605 1605
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1606 1606
 		if ($error != '') {
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 		global $tmp_dir, $globalDebug;
1614 1614
 		$error = '';
1615 1615
 		if ($globalDebug) echo "Routes : Download...";
1616
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1616
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1617 1617
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1618 1618
 			if ($globalDebug) echo "Gunzip...";
1619 1619
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
 		global $tmp_dir, $globalDebug;
1630 1630
 		$error = '';
1631 1631
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1632
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1632
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1633 1633
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1634 1634
 			if ($globalDebug) echo "Gunzip...";
1635 1635
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1645,7 +1645,7 @@  discard block
 block discarded – undo
1645 1645
 		global $tmp_dir, $globalDebug;
1646 1646
 		$error = '';
1647 1647
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1648
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1648
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1649 1649
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1650 1650
 			if ($globalDebug) echo "Gunzip...";
1651 1651
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1673,7 +1673,7 @@  discard block
 block discarded – undo
1673 1673
 */
1674 1674
 		if ($globalDebug) echo "Modes : Download...";
1675 1675
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1676
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1676
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1677 1677
 
1678 1678
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1679 1679
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1693,7 +1693,7 @@  discard block
 block discarded – undo
1693 1693
 	public static function update_ModeS_faa() {
1694 1694
 		global $tmp_dir, $globalDebug;
1695 1695
 		if ($globalDebug) echo "Modes FAA: Download...";
1696
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1696
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1697 1697
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1698 1698
 			if ($globalDebug) echo "Unzip...";
1699 1699
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
 	public static function update_ModeS_flarm() {
1710 1710
 		global $tmp_dir, $globalDebug;
1711 1711
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1712
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1712
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1713 1713
 		if (file_exists($tmp_dir.'data.fln')) {
1714 1714
 			if ($globalDebug) echo "Add to DB...";
1715 1715
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
 	public static function update_ModeS_ogn() {
1724 1724
 		global $tmp_dir, $globalDebug;
1725 1725
 		if ($globalDebug) echo "Modes OGN: Download...";
1726
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1726
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1727 1727
 		if (file_exists($tmp_dir.'ogn.csv')) {
1728 1728
 			if ($globalDebug) echo "Add to DB...";
1729 1729
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1738,201 +1738,201 @@  discard block
 block discarded – undo
1738 1738
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1739 1739
 		
1740 1740
 		if ($globalDebug) echo "Owner France: Download...";
1741
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1741
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1742 1742
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1743 1743
 			if ($globalDebug) echo "Add to DB...";
1744
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1744
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1745 1745
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1746 1746
 		if ($error != '') {
1747 1747
 			return $error;
1748 1748
 		} elseif ($globalDebug) echo "Done\n";
1749 1749
 		
1750 1750
 		if ($globalDebug) echo "Owner Ireland: Download...";
1751
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1751
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1752 1752
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1753 1753
 			if ($globalDebug) echo "Add to DB...";
1754
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1754
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1755 1755
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1756 1756
 		if ($error != '') {
1757 1757
 			return $error;
1758 1758
 		} elseif ($globalDebug) echo "Done\n";
1759 1759
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1760
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1760
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1761 1761
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1762 1762
 			if ($globalDebug) echo "Add to DB...";
1763
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1763
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1764 1764
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1765 1765
 		if ($error != '') {
1766 1766
 			return $error;
1767 1767
 		} elseif ($globalDebug) echo "Done\n";
1768 1768
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1769
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1769
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1770 1770
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1771 1771
 			if ($globalDebug) echo "Add to DB...";
1772
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1772
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1773 1773
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1774 1774
 		if ($error != '') {
1775 1775
 			return $error;
1776 1776
 		} elseif ($globalDebug) echo "Done\n";
1777 1777
 		if ($globalDebug) echo "Owner Australia: Download...";
1778
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1778
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1779 1779
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1780 1780
 			if ($globalDebug) echo "Add to DB...";
1781
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1781
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1782 1782
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1783 1783
 		if ($error != '') {
1784 1784
 			return $error;
1785 1785
 		} elseif ($globalDebug) echo "Done\n";
1786 1786
 		if ($globalDebug) echo "Owner Austria: Download...";
1787
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1787
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1788 1788
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1789 1789
 			if ($globalDebug) echo "Add to DB...";
1790
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1790
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1791 1791
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1792 1792
 		if ($error != '') {
1793 1793
 			return $error;
1794 1794
 		} elseif ($globalDebug) echo "Done\n";
1795 1795
 		if ($globalDebug) echo "Owner Chile: Download...";
1796
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1796
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1797 1797
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1798 1798
 			if ($globalDebug) echo "Add to DB...";
1799
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1799
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1800 1800
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1801 1801
 		if ($error != '') {
1802 1802
 			return $error;
1803 1803
 		} elseif ($globalDebug) echo "Done\n";
1804 1804
 		if ($globalDebug) echo "Owner Colombia: Download...";
1805
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1805
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1806 1806
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1807 1807
 			if ($globalDebug) echo "Add to DB...";
1808
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1808
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1809 1809
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1810 1810
 		if ($error != '') {
1811 1811
 			return $error;
1812 1812
 		} elseif ($globalDebug) echo "Done\n";
1813 1813
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1814
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1814
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1815 1815
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1816 1816
 			if ($globalDebug) echo "Add to DB...";
1817
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1817
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1818 1818
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1819 1819
 		if ($error != '') {
1820 1820
 			return $error;
1821 1821
 		} elseif ($globalDebug) echo "Done\n";
1822 1822
 		if ($globalDebug) echo "Owner Brazil: Download...";
1823
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1823
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1824 1824
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1825 1825
 			if ($globalDebug) echo "Add to DB...";
1826
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1826
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1827 1827
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1828 1828
 		if ($error != '') {
1829 1829
 			return $error;
1830 1830
 		} elseif ($globalDebug) echo "Done\n";
1831 1831
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1832
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1832
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1833 1833
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1834 1834
 			if ($globalDebug) echo "Add to DB...";
1835
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1835
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1836 1836
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1837 1837
 		if ($error != '') {
1838 1838
 			return $error;
1839 1839
 		} elseif ($globalDebug) echo "Done\n";
1840 1840
 		if ($globalDebug) echo "Owner Croatia: Download...";
1841
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1841
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1842 1842
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1843 1843
 			if ($globalDebug) echo "Add to DB...";
1844
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1844
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1845 1845
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1846 1846
 		if ($error != '') {
1847 1847
 			return $error;
1848 1848
 		} elseif ($globalDebug) echo "Done\n";
1849 1849
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1850
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1850
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1851 1851
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1852 1852
 			if ($globalDebug) echo "Add to DB...";
1853
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1853
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1854 1854
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1855 1855
 		if ($error != '') {
1856 1856
 			return $error;
1857 1857
 		} elseif ($globalDebug) echo "Done\n";
1858 1858
 		if ($globalDebug) echo "Owner Maldives: Download...";
1859
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1859
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1860 1860
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1861 1861
 			if ($globalDebug) echo "Add to DB...";
1862
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1862
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1863 1863
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1864 1864
 		if ($error != '') {
1865 1865
 			return $error;
1866 1866
 		} elseif ($globalDebug) echo "Done\n";
1867 1867
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1868
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1868
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1869 1869
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1870 1870
 			if ($globalDebug) echo "Add to DB...";
1871
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1871
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1872 1872
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1873 1873
 		if ($error != '') {
1874 1874
 			return $error;
1875 1875
 		} elseif ($globalDebug) echo "Done\n";
1876 1876
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1877
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1877
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1878 1878
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1879 1879
 			if ($globalDebug) echo "Add to DB...";
1880
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1880
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1881 1881
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1882 1882
 		if ($error != '') {
1883 1883
 			return $error;
1884 1884
 		} elseif ($globalDebug) echo "Done\n";
1885 1885
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1886
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1886
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1887 1887
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1888 1888
 			if ($globalDebug) echo "Add to DB...";
1889
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1889
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1890 1890
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1891 1891
 		if ($error != '') {
1892 1892
 			return $error;
1893 1893
 		} elseif ($globalDebug) echo "Done\n";
1894 1894
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1895
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1895
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1896 1896
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1897 1897
 			if ($globalDebug) echo "Add to DB...";
1898
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1898
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1899 1899
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1900 1900
 		if ($error != '') {
1901 1901
 			return $error;
1902 1902
 		} elseif ($globalDebug) echo "Done\n";
1903 1903
 		if ($globalDebug) echo "Owner Iceland: Download...";
1904
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1904
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1905 1905
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1906 1906
 			if ($globalDebug) echo "Add to DB...";
1907
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1907
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1908 1908
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1909 1909
 		if ($error != '') {
1910 1910
 			return $error;
1911 1911
 		} elseif ($globalDebug) echo "Done\n";
1912 1912
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
1913
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1913
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
1914 1914
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1915 1915
 			if ($globalDebug) echo "Add to DB...";
1916
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1916
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
1917 1917
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
1918 1918
 		if ($error != '') {
1919 1919
 			return $error;
1920 1920
 		} elseif ($globalDebug) echo "Done\n";
1921 1921
 		if ($globalMasterSource) {
1922 1922
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
1923
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1923
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
1924 1924
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1925 1925
 				if ($globalDebug) echo "Add to DB...";
1926
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1926
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
1927 1927
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
1928 1928
 			if ($error != '') {
1929 1929
 				return $error;
1930 1930
 			} elseif ($globalDebug) echo "Done\n";
1931 1931
 			if ($globalDebug) echo "ModeS Denmark: Download...";
1932
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1932
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
1933 1933
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1934 1934
 				if ($globalDebug) echo "Add to DB...";
1935
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1935
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
1936 1936
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
1937 1937
 			if ($error != '') {
1938 1938
 				return $error;
@@ -1945,7 +1945,7 @@  discard block
 block discarded – undo
1945 1945
 		global $tmp_dir, $globalDebug;
1946 1946
 		$error = '';
1947 1947
 		if ($globalDebug) echo "Translation : Download...";
1948
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1948
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1949 1949
 		if (file_exists($tmp_dir.'translation.zip')) {
1950 1950
 			if ($globalDebug) echo "Unzip...";
1951 1951
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1961,7 +1961,7 @@  discard block
 block discarded – undo
1961 1961
 	public static function update_translation_fam() {
1962 1962
 		global $tmp_dir, $globalDebug;
1963 1963
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1964
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1964
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1965 1965
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1966 1966
 			if ($globalDebug) echo "Gunzip...";
1967 1967
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1976,7 +1976,7 @@  discard block
 block discarded – undo
1976 1976
 	public static function update_ModeS_fam() {
1977 1977
 		global $tmp_dir, $globalDebug;
1978 1978
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1979
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1979
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1980 1980
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1981 1981
 			if ($globalDebug) echo "Gunzip...";
1982 1982
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1992,9 +1992,9 @@  discard block
 block discarded – undo
1992 1992
 		global $tmp_dir, $globalDebug, $globalOwner;
1993 1993
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
1994 1994
 		if ($globalOwner === TRUE) {
1995
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1995
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
1996 1996
 		} else {
1997
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1997
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
1998 1998
 		}
1999 1999
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2000 2000
 			if ($globalDebug) echo "Gunzip...";
@@ -2010,7 +2010,7 @@  discard block
 block discarded – undo
2010 2010
 	public static function update_routes_fam() {
2011 2011
 		global $tmp_dir, $globalDebug;
2012 2012
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2013
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2013
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2014 2014
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2015 2015
 			if ($globalDebug) echo "Gunzip...";
2016 2016
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -2024,13 +2024,13 @@  discard block
 block discarded – undo
2024 2024
 	}
2025 2025
 	public static function update_marine_identity_fam() {
2026 2026
 		global $tmp_dir, $globalDebug;
2027
-		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2027
+		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2028 2028
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2029
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2029
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2030 2030
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2031 2031
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2032 2032
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2033
-				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2033
+				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2034 2034
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2035 2035
 					if ($globalDebug) echo "Gunzip...";
2036 2036
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
 	public static function update_banned_fam() {
2051 2051
 		global $tmp_dir, $globalDebug;
2052 2052
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2053
-		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2053
+		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2054 2054
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2055 2055
 			//if ($globalDebug) echo "Gunzip...";
2056 2056
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2069,18 +2069,18 @@  discard block
 block discarded – undo
2069 2069
 		$error = '';
2070 2070
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2071 2071
 		if ($globalDBdriver == 'mysql') {
2072
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2072
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2073 2073
 		} else {
2074
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2074
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2075 2075
 		}
2076 2076
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2077
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2077
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2078 2078
 			$airspace_md5 = $airspace_md5_file[0];
2079 2079
 			if (!update_db::check_airspace_version($airspace_md5)) {
2080 2080
 				if ($globalDBdriver == 'mysql') {
2081
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2081
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2082 2082
 				} else {
2083
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2083
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2084 2084
 				}
2085 2085
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2086 2086
 					if ($globalDebug) echo "Gunzip...";
@@ -2092,7 +2092,7 @@  discard block
 block discarded – undo
2092 2092
 						try {
2093 2093
 							$sth = $Connection->db->prepare($query);
2094 2094
     	    	    					$sth->execute();
2095
-			            		} catch(PDOException $e) {
2095
+			            		} catch (PDOException $e) {
2096 2096
 							return "error : ".$e->getMessage();
2097 2097
 		            			}
2098 2098
 		    			}
@@ -2110,15 +2110,15 @@  discard block
 block discarded – undo
2110 2110
 	public static function update_tle() {
2111 2111
 		global $tmp_dir, $globalDebug;
2112 2112
 		if ($globalDebug) echo "Download TLE : Download...";
2113
-		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2114
-		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2115
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2113
+		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt',
2114
+		'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt',
2115
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
2116 2116
 		foreach ($alltle as $filename) {
2117 2117
 			if ($globalDebug) echo "downloading ".$filename.'...';
2118
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2118
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2119 2119
 			if (file_exists($tmp_dir.$filename)) {
2120 2120
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2121
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2121
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2122 2122
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2123 2123
 			if ($error != '') {
2124 2124
 				echo $error."\n";
@@ -2131,32 +2131,32 @@  discard block
 block discarded – undo
2131 2131
 		global $tmp_dir, $globalDebug;
2132 2132
 		$error = '';
2133 2133
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2134
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2134
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2135 2135
 		if (file_exists($tmp_dir.'models.md5sum')) {
2136 2136
 			if ($globalDebug) echo "Check files...\n";
2137 2137
 			$newmodelsdb = array();
2138
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2139
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2138
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2139
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2140 2140
 					$model = trim($row[2]);
2141 2141
 					$newmodelsdb[$model] = trim($row[0]);
2142 2142
 				}
2143 2143
 			}
2144 2144
 			$modelsdb = array();
2145 2145
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2146
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2147
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2146
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2147
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2148 2148
 						$model = trim($row[2]);
2149 2149
 						$modelsdb[$model] = trim($row[0]);
2150 2150
 					}
2151 2151
 				}
2152 2152
 			}
2153
-			$diff = array_diff($newmodelsdb,$modelsdb);
2153
+			$diff = array_diff($newmodelsdb, $modelsdb);
2154 2154
 			foreach ($diff as $key => $value) {
2155 2155
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2156
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2156
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2157 2157
 				
2158 2158
 			}
2159
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2159
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2160 2160
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2161 2161
 		if ($error != '') {
2162 2162
 			return $error;
@@ -2168,32 +2168,32 @@  discard block
 block discarded – undo
2168 2168
 		global $tmp_dir, $globalDebug;
2169 2169
 		$error = '';
2170 2170
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2171
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2171
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2172 2172
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2173 2173
 			if ($globalDebug) echo "Check files...\n";
2174 2174
 			$newmodelsdb = array();
2175
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2176
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2175
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2176
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2177 2177
 					$model = trim($row[2]);
2178 2178
 					$newmodelsdb[$model] = trim($row[0]);
2179 2179
 				}
2180 2180
 			}
2181 2181
 			$modelsdb = array();
2182 2182
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2183
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2184
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2183
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2184
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2185 2185
 						$model = trim($row[2]);
2186 2186
 						$modelsdb[$model] = trim($row[0]);
2187 2187
 					}
2188 2188
 				}
2189 2189
 			}
2190
-			$diff = array_diff($newmodelsdb,$modelsdb);
2190
+			$diff = array_diff($newmodelsdb, $modelsdb);
2191 2191
 			foreach ($diff as $key => $value) {
2192 2192
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2193
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2193
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2194 2194
 				
2195 2195
 			}
2196
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2196
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2197 2197
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2198 2198
 		if ($error != '') {
2199 2199
 			return $error;
@@ -2205,32 +2205,32 @@  discard block
 block discarded – undo
2205 2205
 		global $tmp_dir, $globalDebug;
2206 2206
 		$error = '';
2207 2207
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2208
-		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2208
+		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2209 2209
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2210 2210
 			if ($globalDebug) echo "Check files...\n";
2211 2211
 			$newmodelsdb = array();
2212
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2213
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2212
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2213
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2214 2214
 					$model = trim($row[2]);
2215 2215
 					$newmodelsdb[$model] = trim($row[0]);
2216 2216
 				}
2217 2217
 			}
2218 2218
 			$modelsdb = array();
2219 2219
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2220
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2221
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2220
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2221
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2222 2222
 						$model = trim($row[2]);
2223 2223
 						$modelsdb[$model] = trim($row[0]);
2224 2224
 					}
2225 2225
 				}
2226 2226
 			}
2227
-			$diff = array_diff($newmodelsdb,$modelsdb);
2227
+			$diff = array_diff($newmodelsdb, $modelsdb);
2228 2228
 			foreach ($diff as $key => $value) {
2229 2229
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2230
-				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2230
+				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2231 2231
 				
2232 2232
 			}
2233
-			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2233
+			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2234 2234
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2235 2235
 		if ($error != '') {
2236 2236
 			return $error;
@@ -2253,8 +2253,8 @@  discard block
 block discarded – undo
2253 2253
 		*/
2254 2254
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2255 2255
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2256
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2257
-		    $result = fread($fh,100000000);
2256
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2257
+		    $result = fread($fh, 100000000);
2258 2258
 		    //echo $result;
2259 2259
 		    //var_dump(str_get_html($result));
2260 2260
 		    //print_r(self::table2array($result));
@@ -2272,23 +2272,23 @@  discard block
 block discarded – undo
2272 2272
 			$Connection = new Connection();
2273 2273
 			$sth = $Connection->db->prepare($query);
2274 2274
                         $sth->execute();
2275
-                } catch(PDOException $e) {
2275
+                } catch (PDOException $e) {
2276 2276
                         return "error : ".$e->getMessage();
2277 2277
                 }
2278 2278
 
2279 2279
 		$error = '';
2280 2280
 		if ($globalDebug) echo "Notam : Download...";
2281
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2281
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2282 2282
 		if (file_exists($tmp_dir.'notam.rss')) {
2283
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2283
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2284 2284
 			foreach ($notams['channel']['item'] as $notam) {
2285
-				$title = explode(':',$notam['title']);
2285
+				$title = explode(':', $notam['title']);
2286 2286
 				$data['ref'] = trim($title[0]);
2287 2287
 				unset($title[0]);
2288
-				$data['title'] = trim(implode(':',$title));
2289
-				$description = strip_tags($notam['description'],'<pre>');
2290
-				preg_match(':^(.*?)<pre>:',$description,$match);
2291
-				$q = explode('/',$match[1]);
2288
+				$data['title'] = trim(implode(':', $title));
2289
+				$description = strip_tags($notam['description'], '<pre>');
2290
+				preg_match(':^(.*?)<pre>:', $description, $match);
2291
+				$q = explode('/', $match[1]);
2292 2292
 				$data['fir'] = $q[0];
2293 2293
 				$data['code'] = $q[1];
2294 2294
 				$ifrvfr = $q[2];
@@ -2304,30 +2304,30 @@  discard block
 block discarded – undo
2304 2304
 				$data['lower_limit'] = $q[5];
2305 2305
 				$data['upper_limit'] = $q[6];
2306 2306
 				$latlonrad = $q[7];
2307
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2308
-				$latitude = $Common->convertDec($las,'latitude');
2309
-				$longitude = $Common->convertDec($lns,'longitude');
2307
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2308
+				$latitude = $Common->convertDec($las, 'latitude');
2309
+				$longitude = $Common->convertDec($lns, 'longitude');
2310 2310
 				if ($lac == 'S') $latitude = '-'.$latitude;
2311 2311
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2312 2312
 				$data['center_latitude'] = $latitude;
2313 2313
 				$data['center_longitude'] = $longitude;
2314 2314
 				$data['radius'] = intval($radius);
2315 2315
 				
2316
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2316
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2317 2317
 				$data['text'] = $match[1];
2318
-				preg_match(':</pre>(.*?)$:',$description,$match);
2318
+				preg_match(':</pre>(.*?)$:', $description, $match);
2319 2319
 				$fromto = $match[1];
2320
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2320
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2321 2321
 				$fromall = trim($match[1]);
2322
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2322
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2323 2323
 				$from = trim($match[1]);
2324
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2325
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2324
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2325
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2326 2326
 				$toall = trim($match[1]);
2327
-				if (!preg_match(':Permanent:',$toall)) {
2328
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2327
+				if (!preg_match(':Permanent:', $toall)) {
2328
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2329 2329
 					$to = trim($match[1]);
2330
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2330
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2331 2331
 					$data['permanent'] = 0;
2332 2332
 				} else {
2333 2333
 				    $data['date_end'] = NULL;
@@ -2335,7 +2335,7 @@  discard block
 block discarded – undo
2335 2335
 				}
2336 2336
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2337 2337
 				$NOTAM = new NOTAM();
2338
-				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2338
+				$NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
2339 2339
 				unset($data);
2340 2340
 			} 
2341 2341
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2358,16 +2358,16 @@  discard block
 block discarded – undo
2358 2358
 				$Connection = new Connection();
2359 2359
 				$sth = $Connection->db->prepare($query);
2360 2360
 				$sth->execute();
2361
-			} catch(PDOException $e) {
2361
+			} catch (PDOException $e) {
2362 2362
 				return "error : ".$e->getMessage();
2363 2363
 			}
2364 2364
 		}
2365 2365
 		$Common = new Common();
2366 2366
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2367
-		$airspace_json = json_decode($airspace_lst,true);
2367
+		$airspace_json = json_decode($airspace_lst, true);
2368 2368
 		foreach ($airspace_json['records'] as $airspace) {
2369 2369
 			if ($globalDebug) echo $airspace['name']."...\n";
2370
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2370
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2371 2371
 			if (file_exists($tmp_dir.$airspace['name'])) {
2372 2372
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2373 2373
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2389,7 +2389,7 @@  discard block
 block discarded – undo
2389 2389
 				$Connection = new Connection();
2390 2390
 				$sth = $Connection->db->prepare($query);
2391 2391
 				$sth->execute(array(':new' => $new, ':old' => $old));
2392
-			} catch(PDOException $e) {
2392
+			} catch (PDOException $e) {
2393 2393
 				return "error : ".$e->getMessage();
2394 2394
 			}
2395 2395
 		}
@@ -2406,7 +2406,7 @@  discard block
 block discarded – undo
2406 2406
 			$Connection = new Connection();
2407 2407
 			$sth = $Connection->db->prepare($query);
2408 2408
                         $sth->execute();
2409
-                } catch(PDOException $e) {
2409
+                } catch (PDOException $e) {
2410 2410
                         return "error : ".$e->getMessage();
2411 2411
                 }
2412 2412
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2421,7 +2421,7 @@  discard block
 block discarded – undo
2421 2421
 			$Connection = new Connection();
2422 2422
 			$sth = $Connection->db->prepare($query);
2423 2423
                         $sth->execute();
2424
-                } catch(PDOException $e) {
2424
+                } catch (PDOException $e) {
2425 2425
                         return "error : ".$e->getMessage();
2426 2426
                 }
2427 2427
 	}
@@ -2432,7 +2432,7 @@  discard block
 block discarded – undo
2432 2432
 			$Connection = new Connection();
2433 2433
 			$sth = $Connection->db->prepare($query);
2434 2434
                         $sth->execute(array(':version' => $version));
2435
-                } catch(PDOException $e) {
2435
+                } catch (PDOException $e) {
2436 2436
                         return "error : ".$e->getMessage();
2437 2437
                 }
2438 2438
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2446,7 +2446,7 @@  discard block
 block discarded – undo
2446 2446
 			$Connection = new Connection();
2447 2447
 			$sth = $Connection->db->prepare($query);
2448 2448
                         $sth->execute(array(':version' => $version));
2449
-                } catch(PDOException $e) {
2449
+                } catch (PDOException $e) {
2450 2450
                         return "error : ".$e->getMessage();
2451 2451
                 }
2452 2452
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2462,7 +2462,7 @@  discard block
 block discarded – undo
2462 2462
 			$Connection = new Connection();
2463 2463
 			$sth = $Connection->db->prepare($query);
2464 2464
                         $sth->execute(array(':version' => $version));
2465
-                } catch(PDOException $e) {
2465
+                } catch (PDOException $e) {
2466 2466
                         return "error : ".$e->getMessage();
2467 2467
                 }
2468 2468
 	}
@@ -2474,7 +2474,7 @@  discard block
 block discarded – undo
2474 2474
 			$Connection = new Connection();
2475 2475
 			$sth = $Connection->db->prepare($query);
2476 2476
                         $sth->execute(array(':version' => $version));
2477
-                } catch(PDOException $e) {
2477
+                } catch (PDOException $e) {
2478 2478
                         return "error : ".$e->getMessage();
2479 2479
                 }
2480 2480
 	}
@@ -2490,7 +2490,7 @@  discard block
 block discarded – undo
2490 2490
 			$Connection = new Connection();
2491 2491
 			$sth = $Connection->db->prepare($query);
2492 2492
                         $sth->execute();
2493
-                } catch(PDOException $e) {
2493
+                } catch (PDOException $e) {
2494 2494
                         return "error : ".$e->getMessage();
2495 2495
                 }
2496 2496
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2505,7 +2505,7 @@  discard block
 block discarded – undo
2505 2505
 			$Connection = new Connection();
2506 2506
 			$sth = $Connection->db->prepare($query);
2507 2507
                         $sth->execute();
2508
-                } catch(PDOException $e) {
2508
+                } catch (PDOException $e) {
2509 2509
                         return "error : ".$e->getMessage();
2510 2510
                 }
2511 2511
 	}
@@ -2520,7 +2520,7 @@  discard block
 block discarded – undo
2520 2520
 			$Connection = new Connection();
2521 2521
 			$sth = $Connection->db->prepare($query);
2522 2522
                         $sth->execute();
2523
-                } catch(PDOException $e) {
2523
+                } catch (PDOException $e) {
2524 2524
                         return "error : ".$e->getMessage();
2525 2525
                 }
2526 2526
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2535,7 +2535,7 @@  discard block
 block discarded – undo
2535 2535
 			$Connection = new Connection();
2536 2536
 			$sth = $Connection->db->prepare($query);
2537 2537
                         $sth->execute();
2538
-                } catch(PDOException $e) {
2538
+                } catch (PDOException $e) {
2539 2539
                         return "error : ".$e->getMessage();
2540 2540
                 }
2541 2541
 	}
@@ -2551,7 +2551,7 @@  discard block
 block discarded – undo
2551 2551
 			$Connection = new Connection();
2552 2552
 			$sth = $Connection->db->prepare($query);
2553 2553
                         $sth->execute();
2554
-                } catch(PDOException $e) {
2554
+                } catch (PDOException $e) {
2555 2555
                         return "error : ".$e->getMessage();
2556 2556
                 }
2557 2557
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2566,7 +2566,7 @@  discard block
 block discarded – undo
2566 2566
 			$Connection = new Connection();
2567 2567
 			$sth = $Connection->db->prepare($query);
2568 2568
                         $sth->execute();
2569
-                } catch(PDOException $e) {
2569
+                } catch (PDOException $e) {
2570 2570
                         return "error : ".$e->getMessage();
2571 2571
                 }
2572 2572
 	}
@@ -2581,7 +2581,7 @@  discard block
 block discarded – undo
2581 2581
 			$Connection = new Connection();
2582 2582
 			$sth = $Connection->db->prepare($query);
2583 2583
                         $sth->execute();
2584
-                } catch(PDOException $e) {
2584
+                } catch (PDOException $e) {
2585 2585
                         return "error : ".$e->getMessage();
2586 2586
                 }
2587 2587
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
 			$Connection = new Connection();
2597 2597
 			$sth = $Connection->db->prepare($query);
2598 2598
                         $sth->execute();
2599
-                } catch(PDOException $e) {
2599
+                } catch (PDOException $e) {
2600 2600
                         return "error : ".$e->getMessage();
2601 2601
                 }
2602 2602
 	}
@@ -2611,7 +2611,7 @@  discard block
 block discarded – undo
2611 2611
 			$Connection = new Connection();
2612 2612
 			$sth = $Connection->db->prepare($query);
2613 2613
                         $sth->execute();
2614
-                } catch(PDOException $e) {
2614
+                } catch (PDOException $e) {
2615 2615
                         return "error : ".$e->getMessage();
2616 2616
                 }
2617 2617
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2626,7 +2626,7 @@  discard block
 block discarded – undo
2626 2626
 			$Connection = new Connection();
2627 2627
 			$sth = $Connection->db->prepare($query);
2628 2628
                         $sth->execute();
2629
-                } catch(PDOException $e) {
2629
+                } catch (PDOException $e) {
2630 2630
                         return "error : ".$e->getMessage();
2631 2631
                 }
2632 2632
 	}
@@ -2641,7 +2641,7 @@  discard block
 block discarded – undo
2641 2641
 			$Connection = new Connection();
2642 2642
 			$sth = $Connection->db->prepare($query);
2643 2643
                         $sth->execute();
2644
-                } catch(PDOException $e) {
2644
+                } catch (PDOException $e) {
2645 2645
                         return "error : ".$e->getMessage();
2646 2646
                 }
2647 2647
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2656,7 +2656,7 @@  discard block
 block discarded – undo
2656 2656
 			$Connection = new Connection();
2657 2657
 			$sth = $Connection->db->prepare($query);
2658 2658
                         $sth->execute();
2659
-                } catch(PDOException $e) {
2659
+                } catch (PDOException $e) {
2660 2660
                         return "error : ".$e->getMessage();
2661 2661
                 }
2662 2662
 	}
@@ -2671,7 +2671,7 @@  discard block
 block discarded – undo
2671 2671
 			$Connection = new Connection();
2672 2672
 			$sth = $Connection->db->prepare($query);
2673 2673
                         $sth->execute();
2674
-                } catch(PDOException $e) {
2674
+                } catch (PDOException $e) {
2675 2675
                         return "error : ".$e->getMessage();
2676 2676
                 }
2677 2677
 	}
@@ -2686,7 +2686,7 @@  discard block
 block discarded – undo
2686 2686
 			$Connection = new Connection();
2687 2687
 			$sth = $Connection->db->prepare($query);
2688 2688
                         $sth->execute();
2689
-                } catch(PDOException $e) {
2689
+                } catch (PDOException $e) {
2690 2690
                         return "error : ".$e->getMessage();
2691 2691
                 }
2692 2692
 	}
Please login to merge, or discard this patch.
Braces   +931 added lines, -322 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
19 19
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
20
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
20
+		if ($referer != '') {
21
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
22
+		}
21 23
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
22 24
 		curl_setopt($ch, CURLOPT_FILE, $fp);
23 25
 		curl_exec($ch);
@@ -28,12 +30,16 @@  discard block
 block discarded – undo
28 30
 	public static function gunzip($in_file,$out_file_name = '') {
29 31
 		//echo $in_file.' -> '.$out_file_name."\n";
30 32
 		$buffer_size = 4096; // read 4kb at a time
31
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
33
+		if ($out_file_name == '') {
34
+			$out_file_name = str_replace('.gz', '', $in_file);
35
+		}
32 36
 		if ($in_file != '' && file_exists($in_file)) {
33 37
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
36
-			else {
38
+			if (function_exists('gzopen')) {
39
+				$file = gzopen($in_file,'rb');
40
+			} elseif (function_exists('gzopen64')) {
41
+				$file = gzopen64($in_file,'rb');
42
+			} else {
37 43
 				echo 'gzopen not available';
38 44
 				die;
39 45
 			}
@@ -54,8 +60,12 @@  discard block
 block discarded – undo
54 60
 			if ($res === TRUE) {
55 61
 				$zip->extractTo($path);
56 62
 				$zip->close();
57
-			} else return false;
58
-		} else return false;
63
+			} else {
64
+				return false;
65
+			}
66
+		} else {
67
+			return false;
68
+		}
59 69
 	}
60 70
 	
61 71
 	public static function connect_sqlite($database) {
@@ -70,7 +80,9 @@  discard block
 block discarded – undo
70 80
 	public static function retrieve_route_sqlite_to_dest($database_file) {
71 81
 		global $globalDebug, $globalTransaction;
72 82
 		//$query = 'TRUNCATE TABLE routes';
73
-		if ($globalDebug) echo " - Delete previous routes from DB -";
83
+		if ($globalDebug) {
84
+			echo " - Delete previous routes from DB -";
85
+		}
74 86
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
75 87
 		$Connection = new Connection();
76 88
 		try {
@@ -81,7 +93,9 @@  discard block
 block discarded – undo
81 93
                         return "error : ".$e->getMessage();
82 94
                 }
83 95
 
84
-    		if ($globalDebug) echo " - Add routes to DB -";
96
+    		if ($globalDebug) {
97
+    			echo " - Add routes to DB -";
98
+    		}
85 99
     		update_db::connect_sqlite($database_file);
86 100
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
87 101
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
@@ -96,15 +110,21 @@  discard block
 block discarded – undo
96 110
 		$Connection = new Connection();
97 111
 		$sth_dest = $Connection->db->prepare($query_dest);
98 112
 		try {
99
-			if ($globalTransaction) $Connection->db->beginTransaction();
113
+			if ($globalTransaction) {
114
+				$Connection->db->beginTransaction();
115
+			}
100 116
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 117
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 118
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
103 119
 				$sth_dest->execute($query_dest_values);
104 120
             		}
105
-			if ($globalTransaction) $Connection->db->commit();
121
+			if ($globalTransaction) {
122
+				$Connection->db->commit();
123
+			}
106 124
 		} catch(PDOException $e) {
107
-			if ($globalTransaction) $Connection->db->rollBack(); 
125
+			if ($globalTransaction) {
126
+				$Connection->db->rollBack();
127
+			}
108 128
 			return "error : ".$e->getMessage();
109 129
 		}
110 130
                 return '';
@@ -112,7 +132,9 @@  discard block
 block discarded – undo
112 132
 	public static function retrieve_route_oneworld($database_file) {
113 133
 		global $globalDebug, $globalTransaction;
114 134
 		//$query = 'TRUNCATE TABLE routes';
115
-		if ($globalDebug) echo " - Delete previous routes from DB -";
135
+		if ($globalDebug) {
136
+			echo " - Delete previous routes from DB -";
137
+		}
116 138
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
117 139
 		$Connection = new Connection();
118 140
 		try {
@@ -123,14 +145,18 @@  discard block
 block discarded – undo
123 145
                         return "error : ".$e->getMessage();
124 146
                 }
125 147
 
126
-    		if ($globalDebug) echo " - Add routes to DB -";
148
+    		if ($globalDebug) {
149
+    			echo " - Add routes to DB -";
150
+    		}
127 151
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 152
 		$Spotter = new Spotter();
129 153
 		if ($fh = fopen($database_file,"r")) {
130 154
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 155
 			$Connection = new Connection();
132 156
 			$sth_dest = $Connection->db->prepare($query_dest);
133
-			if ($globalTransaction) $Connection->db->beginTransaction();
157
+			if ($globalTransaction) {
158
+				$Connection->db->beginTransaction();
159
+			}
134 160
 			while (!feof($fh)) {
135 161
 				$line = fgetcsv($fh,9999,',');
136 162
 				if ($line[0] != '') {
@@ -139,13 +165,17 @@  discard block
 block discarded – undo
139 165
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
140 166
 							$sth_dest->execute($query_dest_values);
141 167
 						} catch(PDOException $e) {
142
-							if ($globalTransaction) $Connection->db->rollBack(); 
168
+							if ($globalTransaction) {
169
+								$Connection->db->rollBack();
170
+							}
143 171
 							return "error : ".$e->getMessage();
144 172
 						}
145 173
 					}
146 174
 				}
147 175
 			}
148
-			if ($globalTransaction) $Connection->db->commit();
176
+			if ($globalTransaction) {
177
+				$Connection->db->commit();
178
+			}
149 179
 		}
150 180
                 return '';
151 181
 	}
@@ -153,7 +183,9 @@  discard block
 block discarded – undo
153 183
 	public static function retrieve_route_skyteam($database_file) {
154 184
 		global $globalDebug, $globalTransaction;
155 185
 		//$query = 'TRUNCATE TABLE routes';
156
-		if ($globalDebug) echo " - Delete previous routes from DB -";
186
+		if ($globalDebug) {
187
+			echo " - Delete previous routes from DB -";
188
+		}
157 189
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
158 190
 		$Connection = new Connection();
159 191
 		try {
@@ -164,7 +196,9 @@  discard block
 block discarded – undo
164 196
                         return "error : ".$e->getMessage();
165 197
                 }
166 198
 
167
-    		if ($globalDebug) echo " - Add routes to DB -";
199
+    		if ($globalDebug) {
200
+    			echo " - Add routes to DB -";
201
+    		}
168 202
 
169 203
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 204
 		$Spotter = new Spotter();
@@ -173,7 +207,9 @@  discard block
 block discarded – undo
173 207
 			$Connection = new Connection();
174 208
 			$sth_dest = $Connection->db->prepare($query_dest);
175 209
 			try {
176
-				if ($globalTransaction) $Connection->db->beginTransaction();
210
+				if ($globalTransaction) {
211
+					$Connection->db->beginTransaction();
212
+				}
177 213
 				while (!feof($fh)) {
178 214
 					$line = fgetcsv($fh,9999,',');
179 215
 					if ($line[0] != '') {
@@ -184,9 +220,13 @@  discard block
 block discarded – undo
184 220
 						}
185 221
 					}
186 222
 				}
187
-				if ($globalTransaction) $Connection->db->commit();
223
+				if ($globalTransaction) {
224
+					$Connection->db->commit();
225
+				}
188 226
 			} catch(PDOException $e) {
189
-				if ($globalTransaction) $Connection->db->rollBack(); 
227
+				if ($globalTransaction) {
228
+					$Connection->db->rollBack();
229
+				}
190 230
 				return "error : ".$e->getMessage();
191 231
 			}
192 232
 		}
@@ -229,11 +269,16 @@  discard block
 block discarded – undo
229 269
 		$sth_dest = $Connection->db->prepare($query_dest);
230 270
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
231 271
 		try {
232
-			if ($globalTransaction) $Connection->db->beginTransaction();
272
+			if ($globalTransaction) {
273
+				$Connection->db->beginTransaction();
274
+			}
233 275
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
234 276
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235
-				if ($values['UserString4'] == 'M') $type = 'military';
236
-				else $type = null;
277
+				if ($values['UserString4'] == 'M') {
278
+					$type = 'military';
279
+				} else {
280
+					$type = null;
281
+				}
237 282
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
238 283
 				$sth_dest->execute($query_dest_values);
239 284
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -241,7 +286,9 @@  discard block
 block discarded – undo
241 286
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 287
 				}
243 288
             		}
244
-			if ($globalTransaction) $Connection->db->commit();
289
+			if ($globalTransaction) {
290
+				$Connection->db->commit();
291
+			}
245 292
 		} catch(PDOException $e) {
246 293
 			return "error : ".$e->getMessage();
247 294
 		}
@@ -278,7 +325,9 @@  discard block
 block discarded – undo
278 325
 			$Connection = new Connection();
279 326
 			$sth_dest = $Connection->db->prepare($query_dest);
280 327
 			try {
281
-				if ($globalTransaction) $Connection->db->beginTransaction();
328
+				if ($globalTransaction) {
329
+					$Connection->db->beginTransaction();
330
+				}
282 331
             			while (!feof($fh)) {
283 332
             				$values = array();
284 333
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -289,7 +338,9 @@  discard block
 block discarded – undo
289 338
             				// Check if we can find ICAO, else set it to GLID
290 339
             				$aircraft_name_split = explode(' ',$aircraft_name);
291 340
             				$search_more = '';
292
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
341
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
342
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
343
+            				}
293 344
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
294 345
             				$sth_search = $Connection->db->prepare($query_search);
295 346
 					try {
@@ -302,7 +353,9 @@  discard block
 block discarded – undo
302 353
 					} catch(PDOException $e) {
303 354
 						return "error : ".$e->getMessage();
304 355
 					}
305
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
356
+					if (!isset($values['ICAOTypeCode'])) {
357
+						$values['ICAOTypeCode'] = 'GLID';
358
+					}
306 359
 					// Add data to db
307 360
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 361
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
@@ -311,7 +364,9 @@  discard block
 block discarded – undo
311 364
 						$sth_dest->execute($query_dest_values);
312 365
 					}
313 366
 				}
314
-				if ($globalTransaction) $Connection->db->commit();
367
+				if ($globalTransaction) {
368
+					$Connection->db->commit();
369
+				}
315 370
 			} catch(PDOException $e) {
316 371
 				return "error : ".$e->getMessage();
317 372
 			}
@@ -347,7 +402,9 @@  discard block
 block discarded – undo
347 402
 			$Connection = new Connection();
348 403
 			$sth_dest = $Connection->db->prepare($query_dest);
349 404
 			try {
350
-				if ($globalTransaction) $Connection->db->beginTransaction();
405
+				if ($globalTransaction) {
406
+					$Connection->db->beginTransaction();
407
+				}
351 408
 				$tmp = fgetcsv($fh,9999,',',"'");
352 409
             			while (!feof($fh)) {
353 410
             				$line = fgetcsv($fh,9999,',',"'");
@@ -360,13 +417,17 @@  discard block
 block discarded – undo
360 417
             				// Check if we can find ICAO, else set it to GLID
361 418
             				$aircraft_name_split = explode(' ',$aircraft_name);
362 419
             				$search_more = '';
363
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
420
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
421
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
422
+            				}
364 423
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
365 424
             				$sth_search = $Connection->db->prepare($query_search);
366 425
 					try {
367 426
                                     		$sth_search->execute();
368 427
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
369
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
428
+	            				if (isset($result['icao']) && $result['icao'] != '') {
429
+	            					$values['ICAOTypeCode'] = $result['icao'];
430
+	            				}
370 431
 					} catch(PDOException $e) {
371 432
 						return "error : ".$e->getMessage();
372 433
 					}
@@ -379,7 +440,9 @@  discard block
 block discarded – undo
379 440
 						$sth_dest->execute($query_dest_values);
380 441
 					}
381 442
 				}
382
-				if ($globalTransaction) $Connection->db->commit();
443
+				if ($globalTransaction) {
444
+					$Connection->db->commit();
445
+				}
383 446
 			} catch(PDOException $e) {
384 447
 				return "error : ".$e->getMessage();
385 448
 			}
@@ -418,7 +481,9 @@  discard block
 block discarded – undo
418 481
 			$sth_dest = $Connection->db->prepare($query_dest);
419 482
 			$sth_modes = $Connection->db->prepare($query_modes);
420 483
 			try {
421
-				if ($globalTransaction) $Connection->db->beginTransaction();
484
+				if ($globalTransaction) {
485
+					$Connection->db->beginTransaction();
486
+				}
422 487
 				$tmp = fgetcsv($fh,9999,',','"');
423 488
             			while (!feof($fh)) {
424 489
             				$line = fgetcsv($fh,9999,',','"');
@@ -428,16 +493,22 @@  discard block
 block discarded – undo
428 493
             				    $values['registration'] = $line[0];
429 494
             				    $values['base'] = $line[4];
430 495
             				    $values['owner'] = $line[5];
431
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
432
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+            				    if ($line[6] == '') {
497
+            				    	$values['date_first_reg'] = null;
498
+            				    } else {
499
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
500
+					    }
433 501
 					    $values['cancel'] = $line[7];
434 502
 					} elseif ($country == 'EI') {
435 503
 					    // TODO : add modeS & reg to aircraft_modes
436 504
             				    $values['registration'] = $line[0];
437 505
             				    $values['base'] = $line[3];
438 506
             				    $values['owner'] = $line[2];
439
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
440
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
507
+            				    if ($line[1] == '') {
508
+            				    	$values['date_first_reg'] = null;
509
+            				    } else {
510
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
511
+					    }
441 512
 					    $values['cancel'] = '';
442 513
 					    $values['modes'] = $line[7];
443 514
 					    $values['icao'] = $line[8];
@@ -456,16 +527,22 @@  discard block
 block discarded – undo
456 527
             				    $values['registration'] = $line[3];
457 528
             				    $values['base'] = null;
458 529
             				    $values['owner'] = $line[5];
459
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
460
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
530
+            				    if ($line[18] == '') {
531
+            				    	$values['date_first_reg'] = null;
532
+            				    } else {
533
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
534
+					    }
461 535
 					    $values['cancel'] = '';
462 536
 					} elseif ($country == 'VH') {
463 537
 					    // TODO : add modeS & reg to aircraft_modes
464 538
             				    $values['registration'] = $line[0];
465 539
             				    $values['base'] = null;
466 540
             				    $values['owner'] = $line[12];
467
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
468
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
541
+            				    if ($line[28] == '') {
542
+            				    	$values['date_first_reg'] = null;
543
+            				    } else {
544
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
545
+					    }
469 546
 
470 547
 					    $values['cancel'] = $line[39];
471 548
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -484,29 +561,41 @@  discard block
 block discarded – undo
484 561
             				    $values['registration'] = $line[0];
485 562
             				    $values['base'] = null;
486 563
             				    $values['owner'] = $line[8];
487
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
488
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
564
+            				    if ($line[7] == '') {
565
+            				    	$values['date_first_reg'] = null;
566
+            				    } else {
567
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
568
+					    }
489 569
 					    $values['cancel'] = '';
490 570
 					} elseif ($country == 'PP') {
491 571
             				    $values['registration'] = $line[0];
492 572
             				    $values['base'] = null;
493 573
             				    $values['owner'] = $line[4];
494
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
495
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
574
+            				    if ($line[6] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
578
+					    }
496 579
 					    $values['cancel'] = $line[7];
497 580
 					} elseif ($country == 'E7') {
498 581
             				    $values['registration'] = $line[0];
499 582
             				    $values['base'] = null;
500 583
             				    $values['owner'] = $line[4];
501
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
502
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
584
+            				    if ($line[5] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
588
+					    }
503 589
 					    $values['cancel'] = '';
504 590
 					} elseif ($country == '8Q') {
505 591
             				    $values['registration'] = $line[0];
506 592
             				    $values['base'] = null;
507 593
             				    $values['owner'] = $line[3];
508
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
509
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
594
+            				    if ($line[7] == '') {
595
+            				    	$values['date_first_reg'] = null;
596
+            				    } else {
597
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
598
+					    }
510 599
 					    $values['cancel'] = '';
511 600
 					} elseif ($country == 'ZK') {
512 601
             				    $values['registration'] = $line[0];
@@ -551,7 +640,9 @@  discard block
 block discarded – undo
551 640
 						$sth_modes->execute($query_modes_values);
552 641
 					}
553 642
 				}
554
-				if ($globalTransaction) $Connection->db->commit();
643
+				if ($globalTransaction) {
644
+					$Connection->db->commit();
645
+				}
555 646
 			} catch(PDOException $e) {
556 647
 				return "error : ".$e->getMessage();
557 648
 			}
@@ -685,25 +776,45 @@  discard block
 block discarded – undo
685 776
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
686 777
 		$Connection = new Connection();
687 778
 		$sth_dest = $Connection->db->prepare($query_dest);
688
-		if ($globalTransaction) $Connection->db->beginTransaction();
779
+		if ($globalTransaction) {
780
+			$Connection->db->beginTransaction();
781
+		}
689 782
   
690 783
 		$i = 0;
691 784
 		while($row = sparql_fetch_array($result))
692 785
 		{
693 786
 			if ($i >= 1) {
694 787
 			//print_r($row);
695
-			if (!isset($row['iata'])) $row['iata'] = '';
696
-			if (!isset($row['icao'])) $row['icao'] = '';
697
-			if (!isset($row['type'])) $row['type'] = '';
698
-			if (!isset($row['altitude'])) $row['altitude'] = '';
788
+			if (!isset($row['iata'])) {
789
+				$row['iata'] = '';
790
+			}
791
+			if (!isset($row['icao'])) {
792
+				$row['icao'] = '';
793
+			}
794
+			if (!isset($row['type'])) {
795
+				$row['type'] = '';
796
+			}
797
+			if (!isset($row['altitude'])) {
798
+				$row['altitude'] = '';
799
+			}
699 800
 			if (isset($row['city_bis'])) {
700 801
 				$row['city'] = $row['city_bis'];
701 802
 			}
702
-			if (!isset($row['city'])) $row['city'] = '';
703
-			if (!isset($row['country'])) $row['country'] = '';
704
-			if (!isset($row['homepage'])) $row['homepage'] = '';
705
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
706
-			if (!isset($row['name'])) continue;
803
+			if (!isset($row['city'])) {
804
+				$row['city'] = '';
805
+			}
806
+			if (!isset($row['country'])) {
807
+				$row['country'] = '';
808
+			}
809
+			if (!isset($row['homepage'])) {
810
+				$row['homepage'] = '';
811
+			}
812
+			if (!isset($row['wikipedia_page'])) {
813
+				$row['wikipedia_page'] = '';
814
+			}
815
+			if (!isset($row['name'])) {
816
+				continue;
817
+			}
707 818
 			if (!isset($row['image'])) {
708 819
 				$row['image'] = '';
709 820
 				$row['image_thumb'] = '';
@@ -739,7 +850,9 @@  discard block
 block discarded – undo
739 850
 
740 851
 			$i++;
741 852
 		}
742
-		if ($globalTransaction) $Connection->db->commit();
853
+		if ($globalTransaction) {
854
+			$Connection->db->commit();
855
+		}
743 856
 		echo "Delete duplicate rows...\n";
744 857
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
745 858
 		try {
@@ -751,7 +864,9 @@  discard block
 block discarded – undo
751 864
                 }
752 865
 
753 866
 
754
-		if ($globalDebug) echo "Insert Not available Airport...\n";
867
+		if ($globalDebug) {
868
+			echo "Insert Not available Airport...\n";
869
+		}
755 870
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
756 871
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
757 872
 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
@@ -778,7 +893,9 @@  discard block
 block discarded – undo
778 893
 		$delimiter = ',';
779 894
 		$out_file = $tmp_dir.'airports.csv';
780 895
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
781
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
896
+		if (!file_exists($out_file) || !is_readable($out_file)) {
897
+			return FALSE;
898
+		}
782 899
 		echo "Add data from ourairports.com...\n";
783 900
 
784 901
 		$header = NULL;
@@ -788,8 +905,9 @@  discard block
 block discarded – undo
788 905
 			//$Connection->db->beginTransaction();
789 906
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
790 907
 			{
791
-				if(!$header) $header = $row;
792
-				else {
908
+				if(!$header) {
909
+					$header = $row;
910
+				} else {
793 911
 					$data = array();
794 912
 					$data = array_combine($header, $row);
795 913
 					try {
@@ -827,7 +945,9 @@  discard block
 block discarded – undo
827 945
 		echo "Download data from another free database...\n";
828 946
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
829 947
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
830
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
948
+		if (!file_exists($out_file) || !is_readable($out_file)) {
949
+			return FALSE;
950
+		}
831 951
 		update_db::unzip($out_file);
832 952
 		$header = NULL;
833 953
 		echo "Add data from another free database...\n";
@@ -838,8 +958,9 @@  discard block
 block discarded – undo
838 958
 			//$Connection->db->beginTransaction();
839 959
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
840 960
 			{
841
-				if(!$header) $header = $row;
842
-				else {
961
+				if(!$header) {
962
+					$header = $row;
963
+				} else {
843 964
 					$data = $row;
844 965
 
845 966
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -1015,7 +1136,9 @@  discard block
 block discarded – undo
1015 1136
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1016 1137
 		{
1017 1138
 			$i = 0;
1018
-			if ($globalTransaction) $Connection->db->beginTransaction();
1139
+			if ($globalTransaction) {
1140
+				$Connection->db->beginTransaction();
1141
+			}
1019 1142
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1020 1143
 			{
1021 1144
 				if ($i > 0) {
@@ -1028,7 +1151,9 @@  discard block
 block discarded – undo
1028 1151
 					}
1029 1152
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1030 1153
 					if (!empty($result_search)) {
1031
-						if ($globalDebug) echo '.';
1154
+						if ($globalDebug) {
1155
+							echo '.';
1156
+						}
1032 1157
 							//if ($globalDBdriver == 'mysql') {
1033 1158
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1034 1159
 							//} else {
@@ -1050,8 +1175,12 @@  discard block
 block discarded – undo
1050 1175
 						}
1051 1176
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1052 1177
 						if (!empty($result_search_mfr)) {
1053
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1054
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1178
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1179
+								$data[16] = $data[23];
1180
+							}
1181
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1182
+								$data[16] = $data[15];
1183
+							}
1055 1184
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1056 1185
 							try {
1057 1186
 								$sthf = $Connection->db->prepare($queryf);
@@ -1062,7 +1191,9 @@  discard block
 block discarded – undo
1062 1191
 						}
1063 1192
 					}
1064 1193
 					if (strtotime($data[29]) > time()) {
1065
-						if ($globalDebug) echo 'i';
1194
+						if ($globalDebug) {
1195
+							echo 'i';
1196
+						}
1066 1197
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1067 1198
 						try {
1068 1199
 							$sth = $Connection->db->prepare($query);
@@ -1073,13 +1204,19 @@  discard block
 block discarded – undo
1073 1204
 					}
1074 1205
 				}
1075 1206
 				if ($i % 90 == 0) {
1076
-					if ($globalTransaction) $Connection->db->commit();
1077
-					if ($globalTransaction) $Connection->db->beginTransaction();
1207
+					if ($globalTransaction) {
1208
+						$Connection->db->commit();
1209
+					}
1210
+					if ($globalTransaction) {
1211
+						$Connection->db->beginTransaction();
1212
+					}
1078 1213
 				}
1079 1214
 				$i++;
1080 1215
 			}
1081 1216
 			fclose($handle);
1082
-			if ($globalTransaction) $Connection->db->commit();
1217
+			if ($globalTransaction) {
1218
+				$Connection->db->commit();
1219
+			}
1083 1220
 		}
1084 1221
 		print_r($mfr);
1085 1222
 		return '';
@@ -1104,11 +1241,15 @@  discard block
 block discarded – undo
1104 1241
 			$i = 0;
1105 1242
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1106 1243
 			//$Connection->db->beginTransaction();
1107
-			if ($globalTransaction) $Connection->db->beginTransaction();
1244
+			if ($globalTransaction) {
1245
+				$Connection->db->beginTransaction();
1246
+			}
1108 1247
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1109 1248
 			{
1110 1249
 				if ($i > 0) {
1111
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1250
+					if ($data[1] == 'NULL') {
1251
+						$data[1] = $data[0];
1252
+					}
1112 1253
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1113 1254
 					try {
1114 1255
 						$sth = $Connection->db->prepare($query);
@@ -1120,7 +1261,9 @@  discard block
 block discarded – undo
1120 1261
 				$i++;
1121 1262
 			}
1122 1263
 			fclose($handle);
1123
-			if ($globalTransaction) $Connection->db->commit();
1264
+			if ($globalTransaction) {
1265
+				$Connection->db->commit();
1266
+			}
1124 1267
 		}
1125 1268
 		return '';
1126 1269
         }
@@ -1141,7 +1284,9 @@  discard block
 block discarded – undo
1141 1284
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1142 1285
 		{
1143 1286
 			$i = 0;
1144
-			if ($globalTransaction) $Connection->db->beginTransaction();
1287
+			if ($globalTransaction) {
1288
+				$Connection->db->beginTransaction();
1289
+			}
1145 1290
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1146 1291
 			{
1147 1292
 				if ($i > 0) {
@@ -1157,7 +1302,9 @@  discard block
 block discarded – undo
1157 1302
 				$i++;
1158 1303
 			}
1159 1304
 			fclose($handle);
1160
-			if ($globalTransaction) $Connection->db->commit();
1305
+			if ($globalTransaction) {
1306
+				$Connection->db->commit();
1307
+			}
1161 1308
 		}
1162 1309
 		return '';
1163 1310
         }
@@ -1182,7 +1329,9 @@  discard block
 block discarded – undo
1182 1329
 			$i = 0;
1183 1330
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1184 1331
 			//$Connection->db->beginTransaction();
1185
-			if ($globalTransaction) $Connection->db->beginTransaction();
1332
+			if ($globalTransaction) {
1333
+				$Connection->db->beginTransaction();
1334
+			}
1186 1335
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1187 1336
 			{
1188 1337
 				if ($i > 0) {
@@ -1197,7 +1346,9 @@  discard block
 block discarded – undo
1197 1346
 				$i++;
1198 1347
 			}
1199 1348
 			fclose($handle);
1200
-			if ($globalTransaction) $Connection->db->commit();
1349
+			if ($globalTransaction) {
1350
+				$Connection->db->commit();
1351
+			}
1201 1352
 		}
1202 1353
 		return '';
1203 1354
         }
@@ -1222,7 +1373,9 @@  discard block
 block discarded – undo
1222 1373
 			$i = 0;
1223 1374
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1224 1375
 			//$Connection->db->beginTransaction();
1225
-			if ($globalTransaction) $Connection->db->beginTransaction();
1376
+			if ($globalTransaction) {
1377
+				$Connection->db->beginTransaction();
1378
+			}
1226 1379
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1227 1380
 			{
1228 1381
 				if ($i > 0) {
@@ -1237,7 +1390,9 @@  discard block
 block discarded – undo
1237 1390
 				$i++;
1238 1391
 			}
1239 1392
 			fclose($handle);
1240
-			if ($globalTransaction) $Connection->db->commit();
1393
+			if ($globalTransaction) {
1394
+				$Connection->db->commit();
1395
+			}
1241 1396
 		}
1242 1397
 		return '';
1243 1398
         }
@@ -1256,7 +1411,9 @@  discard block
 block discarded – undo
1256 1411
 		$Connection = new Connection();
1257 1412
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1258 1413
 		{
1259
-			if ($globalTransaction) $Connection->db->beginTransaction();
1414
+			if ($globalTransaction) {
1415
+				$Connection->db->beginTransaction();
1416
+			}
1260 1417
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1261 1418
 			{
1262 1419
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1271,7 +1428,9 @@  discard block
 block discarded – undo
1271 1428
 				}
1272 1429
 			}
1273 1430
 			fclose($handle);
1274
-			if ($globalTransaction) $Connection->db->commit();
1431
+			if ($globalTransaction) {
1432
+				$Connection->db->commit();
1433
+			}
1275 1434
 		}
1276 1435
 		return '';
1277 1436
         }
@@ -1422,7 +1581,9 @@  discard block
 block discarded – undo
1422 1581
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1423 1582
 		{
1424 1583
 			$i = 0;
1425
-			if ($globalTransaction) $Connection->db->beginTransaction();
1584
+			if ($globalTransaction) {
1585
+				$Connection->db->beginTransaction();
1586
+			}
1426 1587
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1427 1588
 			{
1428 1589
 				$i++;
@@ -1450,7 +1611,9 @@  discard block
 block discarded – undo
1450 1611
 				}
1451 1612
 			}
1452 1613
 			fclose($handle);
1453
-			if ($globalTransaction) $Connection->db->commit();
1614
+			if ($globalTransaction) {
1615
+				$Connection->db->commit();
1616
+			}
1454 1617
 		}
1455 1618
 		return '';
1456 1619
         }
@@ -1473,7 +1636,9 @@  discard block
 block discarded – undo
1473 1636
 		$Connection = new Connection();
1474 1637
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1475 1638
 		{
1476
-			if ($globalTransaction) $Connection->db->beginTransaction();
1639
+			if ($globalTransaction) {
1640
+				$Connection->db->beginTransaction();
1641
+			}
1477 1642
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1478 1643
 			{
1479 1644
 				if(count($row) > 1) {
@@ -1487,7 +1652,9 @@  discard block
 block discarded – undo
1487 1652
 				}
1488 1653
 			}
1489 1654
 			fclose($handle);
1490
-			if ($globalTransaction) $Connection->db->commit();
1655
+			if ($globalTransaction) {
1656
+				$Connection->db->commit();
1657
+			}
1491 1658
 		}
1492 1659
 		return '';
1493 1660
         }
@@ -1507,8 +1674,9 @@  discard block
 block discarded – undo
1507 1674
 	        }
1508 1675
 
1509 1676
 
1510
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1511
-		else {
1677
+		if ($globalDBdriver == 'mysql') {
1678
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1679
+		} else {
1512 1680
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1513 1681
 			$query = "CREATE EXTENSION postgis";
1514 1682
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1527,20 +1695,30 @@  discard block
 block discarded – undo
1527 1695
 		global $tmp_dir, $globalDebug;
1528 1696
 		include_once('class.create_db.php');
1529 1697
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1530
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1698
+		if ($globalDebug) {
1699
+			echo "NOTAM from FlightAirMap website : Download...";
1700
+		}
1531 1701
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1532 1702
 		$error = '';
1533 1703
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1534
-			if ($globalDebug) echo "Gunzip...";
1704
+			if ($globalDebug) {
1705
+				echo "Gunzip...";
1706
+			}
1535 1707
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1536
-			if ($globalDebug) echo "Add to DB...";
1708
+			if ($globalDebug) {
1709
+				echo "Add to DB...";
1710
+			}
1537 1711
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1538 1712
 			$NOTAM = new NOTAM();
1539 1713
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1540
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1714
+		} else {
1715
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1716
+		}
1541 1717
 		if ($error != '') {
1542 1718
 			return $error;
1543
-		} elseif ($globalDebug) echo "Done\n";
1719
+		} elseif ($globalDebug) {
1720
+			echo "Done\n";
1721
+		}
1544 1722
 		return '';
1545 1723
 	}
1546 1724
 
@@ -1594,67 +1772,111 @@  discard block
 block discarded – undo
1594 1772
 		//if ($globalDebug) echo "IVAO : Download...";
1595 1773
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1596 1774
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1597
-			if ($globalDebug) echo "Unzip...";
1775
+			if ($globalDebug) {
1776
+				echo "Unzip...";
1777
+			}
1598 1778
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1599
-			if ($globalDebug) echo "Add to DB...";
1779
+			if ($globalDebug) {
1780
+				echo "Add to DB...";
1781
+			}
1600 1782
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1601
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1783
+			if ($globalDebug) {
1784
+				echo "Copy airlines logos to airlines images directory...";
1785
+			}
1602 1786
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1603
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1604
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1605
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1787
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1788
+					$error = "Failed to copy airlines logo.";
1789
+				}
1790
+			} else {
1791
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1792
+			}
1793
+		} else {
1794
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1795
+		}
1606 1796
 		if ($error != '') {
1607 1797
 			return $error;
1608
-		} elseif ($globalDebug) echo "Done\n";
1798
+		} elseif ($globalDebug) {
1799
+			echo "Done\n";
1800
+		}
1609 1801
 		return '';
1610 1802
 	}
1611 1803
 
1612 1804
 	public static function update_routes() {
1613 1805
 		global $tmp_dir, $globalDebug;
1614 1806
 		$error = '';
1615
-		if ($globalDebug) echo "Routes : Download...";
1807
+		if ($globalDebug) {
1808
+			echo "Routes : Download...";
1809
+		}
1616 1810
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1617 1811
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1618
-			if ($globalDebug) echo "Gunzip...";
1812
+			if ($globalDebug) {
1813
+				echo "Gunzip...";
1814
+			}
1619 1815
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1620
-			if ($globalDebug) echo "Add to DB...";
1816
+			if ($globalDebug) {
1817
+				echo "Add to DB...";
1818
+			}
1621 1819
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1622
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1820
+		} else {
1821
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1822
+		}
1623 1823
 		if ($error != '') {
1624 1824
 			return $error;
1625
-		} elseif ($globalDebug) echo "Done\n";
1825
+		} elseif ($globalDebug) {
1826
+			echo "Done\n";
1827
+		}
1626 1828
 		return '';
1627 1829
 	}
1628 1830
 	public static function update_oneworld() {
1629 1831
 		global $tmp_dir, $globalDebug;
1630 1832
 		$error = '';
1631
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1833
+		if ($globalDebug) {
1834
+			echo "Schedules Oneworld : Download...";
1835
+		}
1632 1836
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1633 1837
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1634
-			if ($globalDebug) echo "Gunzip...";
1838
+			if ($globalDebug) {
1839
+				echo "Gunzip...";
1840
+			}
1635 1841
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1636
-			if ($globalDebug) echo "Add to DB...";
1842
+			if ($globalDebug) {
1843
+				echo "Add to DB...";
1844
+			}
1637 1845
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1638
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1846
+		} else {
1847
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1848
+		}
1639 1849
 		if ($error != '') {
1640 1850
 			return $error;
1641
-		} elseif ($globalDebug) echo "Done\n";
1851
+		} elseif ($globalDebug) {
1852
+			echo "Done\n";
1853
+		}
1642 1854
 		return '';
1643 1855
 	}
1644 1856
 	public static function update_skyteam() {
1645 1857
 		global $tmp_dir, $globalDebug;
1646 1858
 		$error = '';
1647
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1859
+		if ($globalDebug) {
1860
+			echo "Schedules Skyteam : Download...";
1861
+		}
1648 1862
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1649 1863
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1650
-			if ($globalDebug) echo "Gunzip...";
1864
+			if ($globalDebug) {
1865
+				echo "Gunzip...";
1866
+			}
1651 1867
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1652
-			if ($globalDebug) echo "Add to DB...";
1868
+			if ($globalDebug) {
1869
+				echo "Add to DB...";
1870
+			}
1653 1871
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1654
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1872
+		} else {
1873
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1874
+		}
1655 1875
 		if ($error != '') {
1656 1876
 			return $error;
1657
-		} elseif ($globalDebug) echo "Done\n";
1877
+		} elseif ($globalDebug) {
1878
+			echo "Done\n";
1879
+		}
1658 1880
 		return '';
1659 1881
 	}
1660 1882
 	public static function update_ModeS() {
@@ -1671,355 +1893,619 @@  discard block
 block discarded – undo
1671 1893
 			exit;
1672 1894
 		} elseif ($globalDebug) echo "Done\n";
1673 1895
 */
1674
-		if ($globalDebug) echo "Modes : Download...";
1675
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1896
+		if ($globalDebug) {
1897
+			echo "Modes : Download...";
1898
+		}
1899
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1676 1900
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1677 1901
 
1678 1902
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1679 1903
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1680
-			if ($globalDebug) echo "Unzip...";
1681
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1904
+			if ($globalDebug) {
1905
+				echo "Unzip...";
1906
+			}
1907
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1682 1908
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1683
-			if ($globalDebug) echo "Add to DB...";
1909
+			if ($globalDebug) {
1910
+				echo "Add to DB...";
1911
+			}
1684 1912
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1685 1913
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1686
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1914
+		} else {
1915
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1916
+		}
1687 1917
 		if ($error != '') {
1688 1918
 			return $error;
1689
-		} elseif ($globalDebug) echo "Done\n";
1919
+		} elseif ($globalDebug) {
1920
+			echo "Done\n";
1921
+		}
1690 1922
 		return '';
1691 1923
 	}
1692 1924
 
1693 1925
 	public static function update_ModeS_faa() {
1694 1926
 		global $tmp_dir, $globalDebug;
1695
-		if ($globalDebug) echo "Modes FAA: Download...";
1927
+		if ($globalDebug) {
1928
+			echo "Modes FAA: Download...";
1929
+		}
1696 1930
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1697 1931
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1698
-			if ($globalDebug) echo "Unzip...";
1932
+			if ($globalDebug) {
1933
+				echo "Unzip...";
1934
+			}
1699 1935
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1700
-			if ($globalDebug) echo "Add to DB...";
1936
+			if ($globalDebug) {
1937
+				echo "Add to DB...";
1938
+			}
1701 1939
 			$error = update_db::modes_faa();
1702
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1940
+		} else {
1941
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1942
+		}
1703 1943
 		if ($error != '') {
1704 1944
 			return $error;
1705
-		} elseif ($globalDebug) echo "Done\n";
1945
+		} elseif ($globalDebug) {
1946
+			echo "Done\n";
1947
+		}
1706 1948
 		return '';
1707 1949
 	}
1708 1950
 
1709 1951
 	public static function update_ModeS_flarm() {
1710 1952
 		global $tmp_dir, $globalDebug;
1711
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1953
+		if ($globalDebug) {
1954
+			echo "Modes Flarmnet: Download...";
1955
+		}
1712 1956
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1713 1957
 		if (file_exists($tmp_dir.'data.fln')) {
1714
-			if ($globalDebug) echo "Add to DB...";
1958
+			if ($globalDebug) {
1959
+				echo "Add to DB...";
1960
+			}
1715 1961
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1716
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1962
+		} else {
1963
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1964
+		}
1717 1965
 		if ($error != '') {
1718 1966
 			return $error;
1719
-		} elseif ($globalDebug) echo "Done\n";
1967
+		} elseif ($globalDebug) {
1968
+			echo "Done\n";
1969
+		}
1720 1970
 		return '';
1721 1971
 	}
1722 1972
 
1723 1973
 	public static function update_ModeS_ogn() {
1724 1974
 		global $tmp_dir, $globalDebug;
1725
-		if ($globalDebug) echo "Modes OGN: Download...";
1975
+		if ($globalDebug) {
1976
+			echo "Modes OGN: Download...";
1977
+		}
1726 1978
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1727 1979
 		if (file_exists($tmp_dir.'ogn.csv')) {
1728
-			if ($globalDebug) echo "Add to DB...";
1980
+			if ($globalDebug) {
1981
+				echo "Add to DB...";
1982
+			}
1729 1983
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1730
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1984
+		} else {
1985
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1986
+		}
1731 1987
 		if ($error != '') {
1732 1988
 			return $error;
1733
-		} elseif ($globalDebug) echo "Done\n";
1989
+		} elseif ($globalDebug) {
1990
+			echo "Done\n";
1991
+		}
1734 1992
 		return '';
1735 1993
 	}
1736 1994
 
1737 1995
 	public static function update_owner() {
1738 1996
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1739 1997
 		
1740
-		if ($globalDebug) echo "Owner France: Download...";
1998
+		if ($globalDebug) {
1999
+			echo "Owner France: Download...";
2000
+		}
1741 2001
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1742 2002
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1743
-			if ($globalDebug) echo "Add to DB...";
2003
+			if ($globalDebug) {
2004
+				echo "Add to DB...";
2005
+			}
1744 2006
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1745
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2007
+		} else {
2008
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2009
+		}
1746 2010
 		if ($error != '') {
1747 2011
 			return $error;
1748
-		} elseif ($globalDebug) echo "Done\n";
2012
+		} elseif ($globalDebug) {
2013
+			echo "Done\n";
2014
+		}
1749 2015
 		
1750
-		if ($globalDebug) echo "Owner Ireland: Download...";
2016
+		if ($globalDebug) {
2017
+			echo "Owner Ireland: Download...";
2018
+		}
1751 2019
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1752 2020
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1753
-			if ($globalDebug) echo "Add to DB...";
2021
+			if ($globalDebug) {
2022
+				echo "Add to DB...";
2023
+			}
1754 2024
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1755
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2025
+		} else {
2026
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2027
+		}
1756 2028
 		if ($error != '') {
1757 2029
 			return $error;
1758
-		} elseif ($globalDebug) echo "Done\n";
1759
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2030
+		} elseif ($globalDebug) {
2031
+			echo "Done\n";
2032
+		}
2033
+		if ($globalDebug) {
2034
+			echo "Owner Switzerland: Download...";
2035
+		}
1760 2036
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1761 2037
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1762
-			if ($globalDebug) echo "Add to DB...";
2038
+			if ($globalDebug) {
2039
+				echo "Add to DB...";
2040
+			}
1763 2041
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1764
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2042
+		} else {
2043
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2044
+		}
1765 2045
 		if ($error != '') {
1766 2046
 			return $error;
1767
-		} elseif ($globalDebug) echo "Done\n";
1768
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2047
+		} elseif ($globalDebug) {
2048
+			echo "Done\n";
2049
+		}
2050
+		if ($globalDebug) {
2051
+			echo "Owner Czech Republic: Download...";
2052
+		}
1769 2053
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1770 2054
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1771
-			if ($globalDebug) echo "Add to DB...";
2055
+			if ($globalDebug) {
2056
+				echo "Add to DB...";
2057
+			}
1772 2058
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1773
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2059
+		} else {
2060
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2061
+		}
1774 2062
 		if ($error != '') {
1775 2063
 			return $error;
1776
-		} elseif ($globalDebug) echo "Done\n";
1777
-		if ($globalDebug) echo "Owner Australia: Download...";
2064
+		} elseif ($globalDebug) {
2065
+			echo "Done\n";
2066
+		}
2067
+		if ($globalDebug) {
2068
+			echo "Owner Australia: Download...";
2069
+		}
1778 2070
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1779 2071
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1780
-			if ($globalDebug) echo "Add to DB...";
2072
+			if ($globalDebug) {
2073
+				echo "Add to DB...";
2074
+			}
1781 2075
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1782
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2076
+		} else {
2077
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2078
+		}
1783 2079
 		if ($error != '') {
1784 2080
 			return $error;
1785
-		} elseif ($globalDebug) echo "Done\n";
1786
-		if ($globalDebug) echo "Owner Austria: Download...";
2081
+		} elseif ($globalDebug) {
2082
+			echo "Done\n";
2083
+		}
2084
+		if ($globalDebug) {
2085
+			echo "Owner Austria: Download...";
2086
+		}
1787 2087
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1788 2088
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1789
-			if ($globalDebug) echo "Add to DB...";
2089
+			if ($globalDebug) {
2090
+				echo "Add to DB...";
2091
+			}
1790 2092
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1791
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2093
+		} else {
2094
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2095
+		}
1792 2096
 		if ($error != '') {
1793 2097
 			return $error;
1794
-		} elseif ($globalDebug) echo "Done\n";
1795
-		if ($globalDebug) echo "Owner Chile: Download...";
2098
+		} elseif ($globalDebug) {
2099
+			echo "Done\n";
2100
+		}
2101
+		if ($globalDebug) {
2102
+			echo "Owner Chile: Download...";
2103
+		}
1796 2104
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1797 2105
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1798
-			if ($globalDebug) echo "Add to DB...";
2106
+			if ($globalDebug) {
2107
+				echo "Add to DB...";
2108
+			}
1799 2109
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1800
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2110
+		} else {
2111
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2112
+		}
1801 2113
 		if ($error != '') {
1802 2114
 			return $error;
1803
-		} elseif ($globalDebug) echo "Done\n";
1804
-		if ($globalDebug) echo "Owner Colombia: Download...";
2115
+		} elseif ($globalDebug) {
2116
+			echo "Done\n";
2117
+		}
2118
+		if ($globalDebug) {
2119
+			echo "Owner Colombia: Download...";
2120
+		}
1805 2121
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1806 2122
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1807
-			if ($globalDebug) echo "Add to DB...";
2123
+			if ($globalDebug) {
2124
+				echo "Add to DB...";
2125
+			}
1808 2126
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1809
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2127
+		} else {
2128
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2129
+		}
1810 2130
 		if ($error != '') {
1811 2131
 			return $error;
1812
-		} elseif ($globalDebug) echo "Done\n";
1813
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2132
+		} elseif ($globalDebug) {
2133
+			echo "Done\n";
2134
+		}
2135
+		if ($globalDebug) {
2136
+			echo "Owner Bosnia Herzegobina: Download...";
2137
+		}
1814 2138
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1815 2139
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1816
-			if ($globalDebug) echo "Add to DB...";
2140
+			if ($globalDebug) {
2141
+				echo "Add to DB...";
2142
+			}
1817 2143
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1818
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2144
+		} else {
2145
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2146
+		}
1819 2147
 		if ($error != '') {
1820 2148
 			return $error;
1821
-		} elseif ($globalDebug) echo "Done\n";
1822
-		if ($globalDebug) echo "Owner Brazil: Download...";
2149
+		} elseif ($globalDebug) {
2150
+			echo "Done\n";
2151
+		}
2152
+		if ($globalDebug) {
2153
+			echo "Owner Brazil: Download...";
2154
+		}
1823 2155
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1824 2156
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1825
-			if ($globalDebug) echo "Add to DB...";
2157
+			if ($globalDebug) {
2158
+				echo "Add to DB...";
2159
+			}
1826 2160
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1827
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2161
+		} else {
2162
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2163
+		}
1828 2164
 		if ($error != '') {
1829 2165
 			return $error;
1830
-		} elseif ($globalDebug) echo "Done\n";
1831
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2166
+		} elseif ($globalDebug) {
2167
+			echo "Done\n";
2168
+		}
2169
+		if ($globalDebug) {
2170
+			echo "Owner Cayman Islands: Download...";
2171
+		}
1832 2172
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1833 2173
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1834
-			if ($globalDebug) echo "Add to DB...";
2174
+			if ($globalDebug) {
2175
+				echo "Add to DB...";
2176
+			}
1835 2177
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1836
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2178
+		} else {
2179
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2180
+		}
1837 2181
 		if ($error != '') {
1838 2182
 			return $error;
1839
-		} elseif ($globalDebug) echo "Done\n";
1840
-		if ($globalDebug) echo "Owner Croatia: Download...";
2183
+		} elseif ($globalDebug) {
2184
+			echo "Done\n";
2185
+		}
2186
+		if ($globalDebug) {
2187
+			echo "Owner Croatia: Download...";
2188
+		}
1841 2189
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1842 2190
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1843
-			if ($globalDebug) echo "Add to DB...";
2191
+			if ($globalDebug) {
2192
+				echo "Add to DB...";
2193
+			}
1844 2194
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1845
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2195
+		} else {
2196
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2197
+		}
1846 2198
 		if ($error != '') {
1847 2199
 			return $error;
1848
-		} elseif ($globalDebug) echo "Done\n";
1849
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2200
+		} elseif ($globalDebug) {
2201
+			echo "Done\n";
2202
+		}
2203
+		if ($globalDebug) {
2204
+			echo "Owner Luxembourg: Download...";
2205
+		}
1850 2206
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1851 2207
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1852
-			if ($globalDebug) echo "Add to DB...";
2208
+			if ($globalDebug) {
2209
+				echo "Add to DB...";
2210
+			}
1853 2211
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1854
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2212
+		} else {
2213
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2214
+		}
1855 2215
 		if ($error != '') {
1856 2216
 			return $error;
1857
-		} elseif ($globalDebug) echo "Done\n";
1858
-		if ($globalDebug) echo "Owner Maldives: Download...";
2217
+		} elseif ($globalDebug) {
2218
+			echo "Done\n";
2219
+		}
2220
+		if ($globalDebug) {
2221
+			echo "Owner Maldives: Download...";
2222
+		}
1859 2223
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1860 2224
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1861
-			if ($globalDebug) echo "Add to DB...";
2225
+			if ($globalDebug) {
2226
+				echo "Add to DB...";
2227
+			}
1862 2228
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1863
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2229
+		} else {
2230
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2231
+		}
1864 2232
 		if ($error != '') {
1865 2233
 			return $error;
1866
-		} elseif ($globalDebug) echo "Done\n";
1867
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2234
+		} elseif ($globalDebug) {
2235
+			echo "Done\n";
2236
+		}
2237
+		if ($globalDebug) {
2238
+			echo "Owner New Zealand: Download...";
2239
+		}
1868 2240
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1869 2241
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1870
-			if ($globalDebug) echo "Add to DB...";
2242
+			if ($globalDebug) {
2243
+				echo "Add to DB...";
2244
+			}
1871 2245
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1872
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2246
+		} else {
2247
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2248
+		}
1873 2249
 		if ($error != '') {
1874 2250
 			return $error;
1875
-		} elseif ($globalDebug) echo "Done\n";
1876
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2251
+		} elseif ($globalDebug) {
2252
+			echo "Done\n";
2253
+		}
2254
+		if ($globalDebug) {
2255
+			echo "Owner Papua New Guinea: Download...";
2256
+		}
1877 2257
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1878 2258
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1879
-			if ($globalDebug) echo "Add to DB...";
2259
+			if ($globalDebug) {
2260
+				echo "Add to DB...";
2261
+			}
1880 2262
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1881
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2263
+		} else {
2264
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2265
+		}
1882 2266
 		if ($error != '') {
1883 2267
 			return $error;
1884
-		} elseif ($globalDebug) echo "Done\n";
1885
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2268
+		} elseif ($globalDebug) {
2269
+			echo "Done\n";
2270
+		}
2271
+		if ($globalDebug) {
2272
+			echo "Owner Slovakia: Download...";
2273
+		}
1886 2274
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1887 2275
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1888
-			if ($globalDebug) echo "Add to DB...";
2276
+			if ($globalDebug) {
2277
+				echo "Add to DB...";
2278
+			}
1889 2279
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1890
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2280
+		} else {
2281
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2282
+		}
1891 2283
 		if ($error != '') {
1892 2284
 			return $error;
1893
-		} elseif ($globalDebug) echo "Done\n";
1894
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2285
+		} elseif ($globalDebug) {
2286
+			echo "Done\n";
2287
+		}
2288
+		if ($globalDebug) {
2289
+			echo "Owner Ecuador: Download...";
2290
+		}
1895 2291
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1896 2292
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1897
-			if ($globalDebug) echo "Add to DB...";
2293
+			if ($globalDebug) {
2294
+				echo "Add to DB...";
2295
+			}
1898 2296
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1899
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2297
+		} else {
2298
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2299
+		}
1900 2300
 		if ($error != '') {
1901 2301
 			return $error;
1902
-		} elseif ($globalDebug) echo "Done\n";
1903
-		if ($globalDebug) echo "Owner Iceland: Download...";
2302
+		} elseif ($globalDebug) {
2303
+			echo "Done\n";
2304
+		}
2305
+		if ($globalDebug) {
2306
+			echo "Owner Iceland: Download...";
2307
+		}
1904 2308
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1905 2309
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1906
-			if ($globalDebug) echo "Add to DB...";
2310
+			if ($globalDebug) {
2311
+				echo "Add to DB...";
2312
+			}
1907 2313
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1908
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2314
+		} else {
2315
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2316
+		}
1909 2317
 		if ($error != '') {
1910 2318
 			return $error;
1911
-		} elseif ($globalDebug) echo "Done\n";
1912
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2319
+		} elseif ($globalDebug) {
2320
+			echo "Done\n";
2321
+		}
2322
+		if ($globalDebug) {
2323
+			echo "Owner Isle of Man: Download...";
2324
+		}
1913 2325
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1914 2326
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1915
-			if ($globalDebug) echo "Add to DB...";
2327
+			if ($globalDebug) {
2328
+				echo "Add to DB...";
2329
+			}
1916 2330
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1917
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2331
+		} else {
2332
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2333
+		}
1918 2334
 		if ($error != '') {
1919 2335
 			return $error;
1920
-		} elseif ($globalDebug) echo "Done\n";
2336
+		} elseif ($globalDebug) {
2337
+			echo "Done\n";
2338
+		}
1921 2339
 		if ($globalMasterSource) {
1922
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2340
+			if ($globalDebug) {
2341
+				echo "ModeS Netherlands: Download...";
2342
+			}
1923 2343
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1924 2344
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1925
-				if ($globalDebug) echo "Add to DB...";
2345
+				if ($globalDebug) {
2346
+					echo "Add to DB...";
2347
+				}
1926 2348
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1927
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2349
+			} else {
2350
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2351
+			}
1928 2352
 			if ($error != '') {
1929 2353
 				return $error;
1930
-			} elseif ($globalDebug) echo "Done\n";
1931
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2354
+			} elseif ($globalDebug) {
2355
+				echo "Done\n";
2356
+			}
2357
+			if ($globalDebug) {
2358
+				echo "ModeS Denmark: Download...";
2359
+			}
1932 2360
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1933 2361
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1934
-				if ($globalDebug) echo "Add to DB...";
2362
+				if ($globalDebug) {
2363
+					echo "Add to DB...";
2364
+				}
1935 2365
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1936
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2366
+			} else {
2367
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2368
+			}
1937 2369
 			if ($error != '') {
1938 2370
 				return $error;
1939
-			} elseif ($globalDebug) echo "Done\n";
1940
-		} elseif ($globalDebug) echo "Done\n";
2371
+			} elseif ($globalDebug) {
2372
+				echo "Done\n";
2373
+			}
2374
+		} elseif ($globalDebug) {
2375
+			echo "Done\n";
2376
+		}
1941 2377
 		return '';
1942 2378
 	}
1943 2379
 
1944 2380
 	public static function update_translation() {
1945 2381
 		global $tmp_dir, $globalDebug;
1946 2382
 		$error = '';
1947
-		if ($globalDebug) echo "Translation : Download...";
2383
+		if ($globalDebug) {
2384
+			echo "Translation : Download...";
2385
+		}
1948 2386
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1949 2387
 		if (file_exists($tmp_dir.'translation.zip')) {
1950
-			if ($globalDebug) echo "Unzip...";
2388
+			if ($globalDebug) {
2389
+				echo "Unzip...";
2390
+			}
1951 2391
 			update_db::unzip($tmp_dir.'translation.zip');
1952
-			if ($globalDebug) echo "Add to DB...";
2392
+			if ($globalDebug) {
2393
+				echo "Add to DB...";
2394
+			}
1953 2395
 			$error = update_db::translation();
1954
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2396
+		} else {
2397
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2398
+		}
1955 2399
 		if ($error != '') {
1956 2400
 			return $error;
1957
-		} elseif ($globalDebug) echo "Done\n";
2401
+		} elseif ($globalDebug) {
2402
+			echo "Done\n";
2403
+		}
1958 2404
 		return '';
1959 2405
 	}
1960 2406
 
1961 2407
 	public static function update_translation_fam() {
1962 2408
 		global $tmp_dir, $globalDebug;
1963
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2409
+		if ($globalDebug) {
2410
+			echo "Translation from FlightAirMap website : Download...";
2411
+		}
1964 2412
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1965 2413
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1966
-			if ($globalDebug) echo "Gunzip...";
2414
+			if ($globalDebug) {
2415
+				echo "Gunzip...";
2416
+			}
1967 2417
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1968
-			if ($globalDebug) echo "Add to DB...";
2418
+			if ($globalDebug) {
2419
+				echo "Add to DB...";
2420
+			}
1969 2421
 			$error = update_db::translation_fam();
1970
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2422
+		} else {
2423
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2424
+		}
1971 2425
 		if ($error != '') {
1972 2426
 			return $error;
1973
-		} elseif ($globalDebug) echo "Done\n";
2427
+		} elseif ($globalDebug) {
2428
+			echo "Done\n";
2429
+		}
1974 2430
 		return '';
1975 2431
 	}
1976 2432
 	public static function update_ModeS_fam() {
1977 2433
 		global $tmp_dir, $globalDebug;
1978
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2434
+		if ($globalDebug) {
2435
+			echo "ModeS from FlightAirMap website : Download...";
2436
+		}
1979 2437
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1980 2438
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1981
-			if ($globalDebug) echo "Gunzip...";
2439
+			if ($globalDebug) {
2440
+				echo "Gunzip...";
2441
+			}
1982 2442
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1983
-			if ($globalDebug) echo "Add to DB...";
2443
+			if ($globalDebug) {
2444
+				echo "Add to DB...";
2445
+			}
1984 2446
 			$error = update_db::modes_fam();
1985
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2447
+		} else {
2448
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2449
+		}
1986 2450
 		if ($error != '') {
1987 2451
 			return $error;
1988
-		} elseif ($globalDebug) echo "Done\n";
2452
+		} elseif ($globalDebug) {
2453
+			echo "Done\n";
2454
+		}
1989 2455
 		return '';
1990 2456
 	}
1991 2457
 	public static function update_owner_fam() {
1992 2458
 		global $tmp_dir, $globalDebug, $globalOwner;
1993
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2459
+		if ($globalDebug) {
2460
+			echo "owner from FlightAirMap website : Download...";
2461
+		}
1994 2462
 		if ($globalOwner === TRUE) {
1995 2463
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1996 2464
 		} else {
1997 2465
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1998 2466
 		}
1999 2467
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2000
-			if ($globalDebug) echo "Gunzip...";
2468
+			if ($globalDebug) {
2469
+				echo "Gunzip...";
2470
+			}
2001 2471
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
2002
-			if ($globalDebug) echo "Add to DB...";
2472
+			if ($globalDebug) {
2473
+				echo "Add to DB...";
2474
+			}
2003 2475
 			$error = update_db::owner_fam();
2004
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2476
+		} else {
2477
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2478
+		}
2005 2479
 		if ($error != '') {
2006 2480
 			return $error;
2007
-		} elseif ($globalDebug) echo "Done\n";
2481
+		} elseif ($globalDebug) {
2482
+			echo "Done\n";
2483
+		}
2008 2484
 		return '';
2009 2485
 	}
2010 2486
 	public static function update_routes_fam() {
2011 2487
 		global $tmp_dir, $globalDebug;
2012
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2488
+		if ($globalDebug) {
2489
+			echo "Routes from FlightAirMap website : Download...";
2490
+		}
2013 2491
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2014 2492
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2015
-			if ($globalDebug) echo "Gunzip...";
2493
+			if ($globalDebug) {
2494
+				echo "Gunzip...";
2495
+			}
2016 2496
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
2017
-			if ($globalDebug) echo "Add to DB...";
2497
+			if ($globalDebug) {
2498
+				echo "Add to DB...";
2499
+			}
2018 2500
 			$error = update_db::routes_fam();
2019
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2501
+		} else {
2502
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2503
+		}
2020 2504
 		if ($error != '') {
2021 2505
 			return $error;
2022
-		} elseif ($globalDebug) echo "Done\n";
2506
+		} elseif ($globalDebug) {
2507
+			echo "Done\n";
2508
+		}
2023 2509
 		return '';
2024 2510
 	}
2025 2511
 	public static function update_marine_identity_fam() {
@@ -2029,14 +2515,22 @@  discard block
 block discarded – undo
2029 2515
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2030 2516
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2031 2517
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2032
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2518
+				if ($globalDebug) {
2519
+					echo "Marine identity from FlightAirMap website : Download...";
2520
+				}
2033 2521
 				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2034 2522
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2035
-					if ($globalDebug) echo "Gunzip...";
2523
+					if ($globalDebug) {
2524
+						echo "Gunzip...";
2525
+					}
2036 2526
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2037
-					if ($globalDebug) echo "Add to DB...";
2527
+					if ($globalDebug) {
2528
+						echo "Add to DB...";
2529
+					}
2038 2530
 					$error = update_db::marine_identity_fam();
2039
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2531
+				} else {
2532
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
2533
+				}
2040 2534
 				if ($error != '') {
2041 2535
 					return $error;
2042 2536
 				} elseif ($globalDebug) {
@@ -2049,17 +2543,25 @@  discard block
 block discarded – undo
2049 2543
 	}
2050 2544
 	public static function update_banned_fam() {
2051 2545
 		global $tmp_dir, $globalDebug;
2052
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2546
+		if ($globalDebug) {
2547
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2548
+		}
2053 2549
 		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2054 2550
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2055 2551
 			//if ($globalDebug) echo "Gunzip...";
2056 2552
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2057
-			if ($globalDebug) echo "Add to DB...";
2553
+			if ($globalDebug) {
2554
+				echo "Add to DB...";
2555
+			}
2058 2556
 			$error = update_db::banned_fam();
2059
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2557
+		} else {
2558
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2559
+		}
2060 2560
 		if ($error != '') {
2061 2561
 			return $error;
2062
-		} elseif ($globalDebug) echo "Done\n";
2562
+		} elseif ($globalDebug) {
2563
+			echo "Done\n";
2564
+		}
2063 2565
 		return '';
2064 2566
 	}
2065 2567
 
@@ -2067,7 +2569,9 @@  discard block
 block discarded – undo
2067 2569
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2068 2570
 		include_once('class.create_db.php');
2069 2571
 		$error = '';
2070
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2572
+		if ($globalDebug) {
2573
+			echo "Airspace from FlightAirMap website : Download...";
2574
+		}
2071 2575
 		if ($globalDBdriver == 'mysql') {
2072 2576
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2073 2577
 		} else {
@@ -2083,9 +2587,13 @@  discard block
 block discarded – undo
2083 2587
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2084 2588
 				}
2085 2589
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2086
-					if ($globalDebug) echo "Gunzip...";
2590
+					if ($globalDebug) {
2591
+						echo "Gunzip...";
2592
+					}
2087 2593
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
2088
-					if ($globalDebug) echo "Add to DB...";
2594
+					if ($globalDebug) {
2595
+						echo "Add to DB...";
2596
+					}
2089 2597
 					$Connection = new Connection();
2090 2598
 					if ($Connection->tableExists('airspace')) {
2091 2599
 						$query = 'DROP TABLE airspace';
@@ -2098,31 +2606,47 @@  discard block
 block discarded – undo
2098 2606
 		    			}
2099 2607
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2100 2608
 					update_db::insert_airspace_version($airspace_md5);
2101
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2609
+				} else {
2610
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2611
+				}
2102 2612
 			}
2103
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2613
+		} else {
2614
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2615
+		}
2104 2616
 		if ($error != '') {
2105 2617
 			return $error;
2106
-		} elseif ($globalDebug) echo "Done\n";
2618
+		} elseif ($globalDebug) {
2619
+			echo "Done\n";
2620
+		}
2107 2621
 		return '';
2108 2622
 	}
2109 2623
 
2110 2624
 	public static function update_tle() {
2111 2625
 		global $tmp_dir, $globalDebug;
2112
-		if ($globalDebug) echo "Download TLE : Download...";
2626
+		if ($globalDebug) {
2627
+			echo "Download TLE : Download...";
2628
+		}
2113 2629
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2114 2630
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2115 2631
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2116 2632
 		foreach ($alltle as $filename) {
2117
-			if ($globalDebug) echo "downloading ".$filename.'...';
2633
+			if ($globalDebug) {
2634
+				echo "downloading ".$filename.'...';
2635
+			}
2118 2636
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2119 2637
 			if (file_exists($tmp_dir.$filename)) {
2120
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2638
+				if ($globalDebug) {
2639
+					echo "Add to DB ".$filename."...";
2640
+				}
2121 2641
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2122
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2642
+			} else {
2643
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2644
+			}
2123 2645
 			if ($error != '') {
2124 2646
 				echo $error."\n";
2125
-			} elseif ($globalDebug) echo "Done\n";
2647
+			} elseif ($globalDebug) {
2648
+				echo "Done\n";
2649
+			}
2126 2650
 		}
2127 2651
 		return '';
2128 2652
 	}
@@ -2130,10 +2654,14 @@  discard block
 block discarded – undo
2130 2654
 	public static function update_models() {
2131 2655
 		global $tmp_dir, $globalDebug;
2132 2656
 		$error = '';
2133
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2657
+		if ($globalDebug) {
2658
+			echo "Models from FlightAirMap website : Download...";
2659
+		}
2134 2660
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2135 2661
 		if (file_exists($tmp_dir.'models.md5sum')) {
2136
-			if ($globalDebug) echo "Check files...\n";
2662
+			if ($globalDebug) {
2663
+				echo "Check files...\n";
2664
+			}
2137 2665
 			$newmodelsdb = array();
2138 2666
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2139 2667
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2152,25 +2680,35 @@  discard block
 block discarded – undo
2152 2680
 			}
2153 2681
 			$diff = array_diff($newmodelsdb,$modelsdb);
2154 2682
 			foreach ($diff as $key => $value) {
2155
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2683
+				if ($globalDebug) {
2684
+					echo 'Downloading model '.$key.' ...'."\n";
2685
+				}
2156 2686
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2157 2687
 				
2158 2688
 			}
2159 2689
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2160
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2690
+		} else {
2691
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2692
+		}
2161 2693
 		if ($error != '') {
2162 2694
 			return $error;
2163
-		} elseif ($globalDebug) echo "Done\n";
2695
+		} elseif ($globalDebug) {
2696
+			echo "Done\n";
2697
+		}
2164 2698
 		return '';
2165 2699
 	}
2166 2700
 
2167 2701
 	public static function update_space_models() {
2168 2702
 		global $tmp_dir, $globalDebug;
2169 2703
 		$error = '';
2170
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2704
+		if ($globalDebug) {
2705
+			echo "Space models from FlightAirMap website : Download...";
2706
+		}
2171 2707
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2172 2708
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2173
-			if ($globalDebug) echo "Check files...\n";
2709
+			if ($globalDebug) {
2710
+				echo "Check files...\n";
2711
+			}
2174 2712
 			$newmodelsdb = array();
2175 2713
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2176 2714
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2189,25 +2727,35 @@  discard block
 block discarded – undo
2189 2727
 			}
2190 2728
 			$diff = array_diff($newmodelsdb,$modelsdb);
2191 2729
 			foreach ($diff as $key => $value) {
2192
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2730
+				if ($globalDebug) {
2731
+					echo 'Downloading space model '.$key.' ...'."\n";
2732
+				}
2193 2733
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2194 2734
 				
2195 2735
 			}
2196 2736
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2197
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2737
+		} else {
2738
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2739
+		}
2198 2740
 		if ($error != '') {
2199 2741
 			return $error;
2200
-		} elseif ($globalDebug) echo "Done\n";
2742
+		} elseif ($globalDebug) {
2743
+			echo "Done\n";
2744
+		}
2201 2745
 		return '';
2202 2746
 	}
2203 2747
 
2204 2748
 	public static function update_vehicules_models() {
2205 2749
 		global $tmp_dir, $globalDebug;
2206 2750
 		$error = '';
2207
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2751
+		if ($globalDebug) {
2752
+			echo "Vehicules models from FlightAirMap website : Download...";
2753
+		}
2208 2754
 		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2209 2755
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2210
-			if ($globalDebug) echo "Check files...\n";
2756
+			if ($globalDebug) {
2757
+				echo "Check files...\n";
2758
+			}
2211 2759
 			$newmodelsdb = array();
2212 2760
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2213 2761
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2226,15 +2774,21 @@  discard block
 block discarded – undo
2226 2774
 			}
2227 2775
 			$diff = array_diff($newmodelsdb,$modelsdb);
2228 2776
 			foreach ($diff as $key => $value) {
2229
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2777
+				if ($globalDebug) {
2778
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
2779
+				}
2230 2780
 				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2231 2781
 				
2232 2782
 			}
2233 2783
 			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2234
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2784
+		} else {
2785
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2786
+		}
2235 2787
 		if ($error != '') {
2236 2788
 			return $error;
2237
-		} elseif ($globalDebug) echo "Done\n";
2789
+		} elseif ($globalDebug) {
2790
+			echo "Done\n";
2791
+		}
2238 2792
 		return '';
2239 2793
 	}
2240 2794
 
@@ -2277,7 +2831,9 @@  discard block
 block discarded – undo
2277 2831
                 }
2278 2832
 
2279 2833
 		$error = '';
2280
-		if ($globalDebug) echo "Notam : Download...";
2834
+		if ($globalDebug) {
2835
+			echo "Notam : Download...";
2836
+		}
2281 2837
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2282 2838
 		if (file_exists($tmp_dir.'notam.rss')) {
2283 2839
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2292,14 +2848,30 @@  discard block
 block discarded – undo
2292 2848
 				$data['fir'] = $q[0];
2293 2849
 				$data['code'] = $q[1];
2294 2850
 				$ifrvfr = $q[2];
2295
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2296
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2297
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2298
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2299
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2300
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2301
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2302
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2851
+				if ($ifrvfr == 'IV') {
2852
+					$data['rules'] = 'IFR/VFR';
2853
+				}
2854
+				if ($ifrvfr == 'I') {
2855
+					$data['rules'] = 'IFR';
2856
+				}
2857
+				if ($ifrvfr == 'V') {
2858
+					$data['rules'] = 'VFR';
2859
+				}
2860
+				if ($q[4] == 'A') {
2861
+					$data['scope'] = 'Airport warning';
2862
+				}
2863
+				if ($q[4] == 'E') {
2864
+					$data['scope'] = 'Enroute warning';
2865
+				}
2866
+				if ($q[4] == 'W') {
2867
+					$data['scope'] = 'Navigation warning';
2868
+				}
2869
+				if ($q[4] == 'AE') {
2870
+					$data['scope'] = 'Airport/Enroute warning';
2871
+				}
2872
+				if ($q[4] == 'AW') {
2873
+					$data['scope'] = 'Airport/Navigation warning';
2874
+				}
2303 2875
 				//$data['scope'] = $q[4];
2304 2876
 				$data['lower_limit'] = $q[5];
2305 2877
 				$data['upper_limit'] = $q[6];
@@ -2307,8 +2879,12 @@  discard block
 block discarded – undo
2307 2879
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2308 2880
 				$latitude = $Common->convertDec($las,'latitude');
2309 2881
 				$longitude = $Common->convertDec($lns,'longitude');
2310
-				if ($lac == 'S') $latitude = '-'.$latitude;
2311
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2882
+				if ($lac == 'S') {
2883
+					$latitude = '-'.$latitude;
2884
+				}
2885
+				if ($lnc == 'W') {
2886
+					$longitude = '-'.$longitude;
2887
+				}
2312 2888
 				$data['center_latitude'] = $latitude;
2313 2889
 				$data['center_longitude'] = $longitude;
2314 2890
 				$data['radius'] = intval($radius);
@@ -2338,10 +2914,14 @@  discard block
 block discarded – undo
2338 2914
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2339 2915
 				unset($data);
2340 2916
 			} 
2341
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2917
+		} else {
2918
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2919
+		}
2342 2920
 		if ($error != '') {
2343 2921
 			return $error;
2344
-		} elseif ($globalDebug) echo "Done\n";
2922
+		} elseif ($globalDebug) {
2923
+			echo "Done\n";
2924
+		}
2345 2925
 		return '';
2346 2926
 	}
2347 2927
 	
@@ -2366,7 +2946,9 @@  discard block
 block discarded – undo
2366 2946
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2367 2947
 		$airspace_json = json_decode($airspace_lst,true);
2368 2948
 		foreach ($airspace_json['records'] as $airspace) {
2369
-			if ($globalDebug) echo $airspace['name']."...\n";
2949
+			if ($globalDebug) {
2950
+				echo $airspace['name']."...\n";
2951
+			}
2370 2952
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2371 2953
 			if (file_exists($tmp_dir.$airspace['name'])) {
2372 2954
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2410,8 +2992,11 @@  discard block
 block discarded – undo
2410 2992
                         return "error : ".$e->getMessage();
2411 2993
                 }
2412 2994
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2413
-                if ($row['nb'] > 0) return false;
2414
-                else return true;
2995
+                if ($row['nb'] > 0) {
2996
+                	return false;
2997
+                } else {
2998
+                	return true;
2999
+                }
2415 3000
 	}
2416 3001
 
2417 3002
 	public static function insert_last_update() {
@@ -2436,8 +3021,11 @@  discard block
 block discarded – undo
2436 3021
                         return "error : ".$e->getMessage();
2437 3022
                 }
2438 3023
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2439
-                if ($row['nb'] > 0) return true;
2440
-                else return false;
3024
+                if ($row['nb'] > 0) {
3025
+                	return true;
3026
+                } else {
3027
+                	return false;
3028
+                }
2441 3029
 	}
2442 3030
 
2443 3031
 	public static function check_marine_identity_version($version) {
@@ -2450,8 +3038,11 @@  discard block
 block discarded – undo
2450 3038
                         return "error : ".$e->getMessage();
2451 3039
                 }
2452 3040
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2453
-                if ($row['nb'] > 0) return true;
2454
-                else return false;
3041
+                if ($row['nb'] > 0) {
3042
+                	return true;
3043
+                } else {
3044
+                	return false;
3045
+                }
2455 3046
 	}
2456 3047
 
2457 3048
 
@@ -2494,8 +3085,11 @@  discard block
 block discarded – undo
2494 3085
                         return "error : ".$e->getMessage();
2495 3086
                 }
2496 3087
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2497
-                if ($row['nb'] > 0) return false;
2498
-                else return true;
3088
+                if ($row['nb'] > 0) {
3089
+                	return false;
3090
+                } else {
3091
+                	return true;
3092
+                }
2499 3093
 	}
2500 3094
 
2501 3095
 	public static function insert_last_notam_update() {
@@ -2524,8 +3118,11 @@  discard block
 block discarded – undo
2524 3118
                         return "error : ".$e->getMessage();
2525 3119
                 }
2526 3120
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2527
-                if ($row['nb'] > 0) return false;
2528
-                else return true;
3121
+                if ($row['nb'] > 0) {
3122
+                	return false;
3123
+                } else {
3124
+                	return true;
3125
+                }
2529 3126
 	}
2530 3127
 
2531 3128
 	public static function insert_last_airspace_update() {
@@ -2555,8 +3152,11 @@  discard block
 block discarded – undo
2555 3152
                         return "error : ".$e->getMessage();
2556 3153
                 }
2557 3154
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2558
-                if ($row['nb'] > 0) return false;
2559
-                else return true;
3155
+                if ($row['nb'] > 0) {
3156
+                	return false;
3157
+                } else {
3158
+                	return true;
3159
+                }
2560 3160
 	}
2561 3161
 
2562 3162
 	public static function insert_last_owner_update() {
@@ -2585,8 +3185,11 @@  discard block
 block discarded – undo
2585 3185
                         return "error : ".$e->getMessage();
2586 3186
                 }
2587 3187
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2588
-                if ($row['nb'] > 0) return false;
2589
-                else return true;
3188
+                if ($row['nb'] > 0) {
3189
+                	return false;
3190
+                } else {
3191
+                	return true;
3192
+                }
2590 3193
 	}
2591 3194
 
2592 3195
 	public static function insert_last_schedules_update() {
@@ -2615,8 +3218,11 @@  discard block
 block discarded – undo
2615 3218
                         return "error : ".$e->getMessage();
2616 3219
                 }
2617 3220
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2618
-                if ($row['nb'] > 0) return false;
2619
-                else return true;
3221
+                if ($row['nb'] > 0) {
3222
+                	return false;
3223
+                } else {
3224
+                	return true;
3225
+                }
2620 3226
 	}
2621 3227
 
2622 3228
 	public static function insert_last_tle_update() {
@@ -2645,8 +3251,11 @@  discard block
 block discarded – undo
2645 3251
                         return "error : ".$e->getMessage();
2646 3252
                 }
2647 3253
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2648
-                if ($row['nb'] > 0) return false;
2649
-                else return true;
3254
+                if ($row['nb'] > 0) {
3255
+                	return false;
3256
+                } else {
3257
+                	return true;
3258
+                }
2650 3259
 	}
2651 3260
 
2652 3261
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
require/class.Image.php 4 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -254,6 +254,7 @@  discard block
 block discarded – undo
254 254
 	*
255 255
 	* @param String $aircraft_registration the registration of the aircraft
256 256
 	* @param String $aircraft_name type of the aircraft
257
+	* @param string $type
257 258
 	* @return Array the aircraft thumbnail, orignal url and copyright
258 259
 	*
259 260
 	*/
@@ -287,6 +288,7 @@  discard block
 block discarded – undo
287 288
 	*
288 289
 	* @param String $registration the registration of the aircraft
289 290
 	* @param String $name type of the aircraft
291
+	* @param string $type
290 292
 	* @return Array the aircraft thumbnail, orignal url and copyright
291 293
 	*
292 294
 	*/
@@ -325,6 +327,7 @@  discard block
 block discarded – undo
325 327
 	*
326 328
 	* @param String $aircraft_registration the registration of the aircraft
327 329
 	* @param String $aircraft_name type of the aircraft
330
+	* @param string $type
328 331
 	* @return Array the aircraft thumbnail, orignal url and copyright
329 332
 	*
330 333
 	*/
@@ -367,6 +370,7 @@  discard block
 block discarded – undo
367 370
 	*
368 371
 	* @param String $aircraft_registration the registration of the aircraft
369 372
 	* @param String $aircraft_name type of the aircraft
373
+	* @param string $type
370 374
 	* @return Array the aircraft thumbnail, orignal url and copyright
371 375
 	*
372 376
 	*/
@@ -401,6 +405,7 @@  discard block
 block discarded – undo
401 405
 	*
402 406
 	* @param String $registration the registration of the aircraft
403 407
 	* @param String $name type of the aircraft
408
+	* @param string $type
404 409
 	* @return Array the aircraft thumbnail, orignal url and copyright
405 410
 	*
406 411
 	*/
@@ -429,6 +434,10 @@  discard block
 block discarded – undo
429 434
 		return false;
430 435
 	}
431 436
 
437
+	/**
438
+	 * @param string $type
439
+	 * @param string $aircraft_icao
440
+	 */
432 441
 	public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) {
433 442
 		$Common = new Common();
434 443
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
@@ -450,6 +459,7 @@  discard block
 block discarded – undo
450 459
 	*
451 460
 	* @param String $aircraft_registration the registration of the aircraft
452 461
 	* @param String $aircraft_name type of the aircraft
462
+	* @param string $type
453 463
 	* @return Array the aircraft thumbnail, orignal url and copyright
454 464
 	*
455 465
 	*/
@@ -482,6 +492,7 @@  discard block
 block discarded – undo
482 492
 	*
483 493
 	* @param String $aircraft_registration the registration of the aircraft
484 494
 	* @param String $aircraft_name type of the aircraft
495
+	* @param string $type
485 496
 	* @return Array the aircraft thumbnail, orignal url and copyright
486 497
 	*
487 498
 	*/
@@ -507,6 +518,7 @@  discard block
 block discarded – undo
507 518
 	*
508 519
 	* @param String $registration the registration of the aircraft/mmsi
509 520
 	* @param String $name name
521
+	* @param string $type
510 522
 	* @return Array the aircraft thumbnail, orignal url and copyright
511 523
 	*
512 524
 	*/
@@ -568,6 +580,7 @@  discard block
 block discarded – undo
568 580
 	*
569 581
 	* @param String $registration the registration of the aircraft
570 582
 	* @param String $name type of the aircraft
583
+	* @param string $type
571 584
 	* @return Array the aircraft thumbnail, orignal url and copyright
572 585
 	*
573 586
 	*/
Please login to merge, or discard this patch.
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	/**
15
-	* Gets the images based on the aircraft registration
16
-	*
17
-	* @return Array the images list
18
-	*
19
-	*/
15
+	 * Gets the images based on the aircraft registration
16
+	 *
17
+	 * @return Array the images list
18
+	 *
19
+	 */
20 20
 	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
21 21
 	{
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	/**
40
-	* Gets the images based on the ship name
41
-	*
42
-	* @return Array the images list
43
-	*
44
-	*/
40
+	 * Gets the images based on the ship name
41
+	 *
42
+	 * @return Array the images list
43
+	 *
44
+	 */
45 45
 	public function getMarineImage($mmsi,$imo = '',$name = '')
46 46
 	{
47 47
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 
70 70
 	/**
71
-	* Gets the image copyright based on the Exif data
72
-	*
73
-	* @return String image copyright
74
-	*
75
-	*/
71
+	 * Gets the image copyright based on the Exif data
72
+	 *
73
+	 * @return String image copyright
74
+	 *
75
+	 */
76 76
 	public function getExifCopyright($url) {
77 77
 		$exif = exif_read_data($url);
78 78
 		$copyright = '';
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	}
88 88
 
89 89
 	/**
90
-	* Adds the images based on the aircraft registration
91
-	*
92
-	* @return String either success or error
93
-	*
94
-	*/
90
+	 * Adds the images based on the aircraft registration
91
+	 *
92
+	 * @return String either success or error
93
+	 *
94
+	 */
95 95
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
96 96
 	{
97 97
 		global $globalDebug,$globalAircraftImageFetch;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	}
120 120
 
121 121
 	/**
122
-	* Adds the images based on the marine name
123
-	*
124
-	* @return String either success or error
125
-	*
126
-	*/
122
+	 * Adds the images based on the marine name
123
+	 *
124
+	 * @return String either success or error
125
+	 *
126
+	 */
127 127
 	public function addMarineImage($mmsi,$imo = '',$name = '')
128 128
 	{
129 129
 		global $globalDebug,$globalMarineImageFetch;
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 
162 162
 	/**
163
-	* Gets the aircraft image
164
-	*
165
-	* @param String $aircraft_registration the registration of the aircraft
166
-	* @return Array the aircraft thumbnail, orignal url and copyright
167
-	*
168
-	*/
163
+	 * Gets the aircraft image
164
+	 *
165
+	 * @param String $aircraft_registration the registration of the aircraft
166
+	 * @return Array the aircraft thumbnail, orignal url and copyright
167
+	 *
168
+	 */
169 169
 	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
170 170
 	{
171 171
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 	}
210 210
 
211 211
 	/**
212
-	* Gets the vessel image
213
-	*
214
-	* @param String $mmsi the vessel mmsi
215
-	* @param String $imo the vessel imo
216
-	* @param String $name the vessel name
217
-	* @return Array the aircraft thumbnail, orignal url and copyright
218
-	*
219
-	*/
212
+	 * Gets the vessel image
213
+	 *
214
+	 * @param String $mmsi the vessel mmsi
215
+	 * @param String $imo the vessel imo
216
+	 * @param String $name the vessel name
217
+	 * @return Array the aircraft thumbnail, orignal url and copyright
218
+	 *
219
+	 */
220 220
 	public function findMarineImage($mmsi,$imo = '',$name = '')
221 221
 	{
222 222
 		global $globalMarineImageSources;
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 	/**
253
-	* Gets the aircraft image from Planespotters
254
-	*
255
-	* @param String $aircraft_registration the registration of the aircraft
256
-	* @param String $aircraft_name type of the aircraft
257
-	* @return Array the aircraft thumbnail, orignal url and copyright
258
-	*
259
-	*/
253
+	 * Gets the aircraft image from Planespotters
254
+	 *
255
+	 * @param String $aircraft_registration the registration of the aircraft
256
+	 * @param String $aircraft_name type of the aircraft
257
+	 * @return Array the aircraft thumbnail, orignal url and copyright
258
+	 *
259
+	 */
260 260
 	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
261 261
 		$Common = new Common();
262 262
 		// If aircraft registration is only number, also check with aircraft model
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 	/**
286
-	* Gets the aircraft image from Deviantart
287
-	*
288
-	* @param String $registration the registration of the aircraft
289
-	* @param String $name type of the aircraft
290
-	* @return Array the aircraft thumbnail, orignal url and copyright
291
-	*
292
-	*/
286
+	 * Gets the aircraft image from Deviantart
287
+	 *
288
+	 * @param String $registration the registration of the aircraft
289
+	 * @param String $name type of the aircraft
290
+	 * @return Array the aircraft thumbnail, orignal url and copyright
291
+	 *
292
+	 */
293 293
 	public function fromDeviantart($type,$registration, $name='') {
294 294
 		$Common = new Common();
295 295
 		if ($type == 'aircraft') {
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
 	}
322 322
 
323 323
 	/**
324
-	* Gets the aircraft image from JetPhotos
325
-	*
326
-	* @param String $aircraft_registration the registration of the aircraft
327
-	* @param String $aircraft_name type of the aircraft
328
-	* @return Array the aircraft thumbnail, orignal url and copyright
329
-	*
330
-	*/
324
+	 * Gets the aircraft image from JetPhotos
325
+	 *
326
+	 * @param String $aircraft_registration the registration of the aircraft
327
+	 * @param String $aircraft_name type of the aircraft
328
+	 * @return Array the aircraft thumbnail, orignal url and copyright
329
+	 *
330
+	 */
331 331
 	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
332 332
 		$Common = new Common();
333 333
 		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
@@ -363,13 +363,13 @@  discard block
 block discarded – undo
363 363
 	}
364 364
 
365 365
 	/**
366
-	* Gets the aircraft image from PlanePictures
367
-	*
368
-	* @param String $aircraft_registration the registration of the aircraft
369
-	* @param String $aircraft_name type of the aircraft
370
-	* @return Array the aircraft thumbnail, orignal url and copyright
371
-	*
372
-	*/
366
+	 * Gets the aircraft image from PlanePictures
367
+	 *
368
+	 * @param String $aircraft_registration the registration of the aircraft
369
+	 * @param String $aircraft_name type of the aircraft
370
+	 * @return Array the aircraft thumbnail, orignal url and copyright
371
+	 *
372
+	 */
373 373
 	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
374 374
 		$Common = new Common();
375 375
 		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 	}
398 398
 
399 399
 	/**
400
-	* Gets the aircraft image from Flickr
401
-	*
402
-	* @param String $registration the registration of the aircraft
403
-	* @param String $name type of the aircraft
404
-	* @return Array the aircraft thumbnail, orignal url and copyright
405
-	*
406
-	*/
400
+	 * Gets the aircraft image from Flickr
401
+	 *
402
+	 * @param String $registration the registration of the aircraft
403
+	 * @param String $name type of the aircraft
404
+	 * @return Array the aircraft thumbnail, orignal url and copyright
405
+	 *
406
+	 */
407 407
 	public function fromFlickr($type,$registration,$name='') {
408 408
 		$Common = new Common();
409 409
 		if ($type == 'aircraft') {
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
 	}
447 447
 
448 448
 	/**
449
-	* Gets the aircraft image from Bing
450
-	*
451
-	* @param String $aircraft_registration the registration of the aircraft
452
-	* @param String $aircraft_name type of the aircraft
453
-	* @return Array the aircraft thumbnail, orignal url and copyright
454
-	*
455
-	*/
449
+	 * Gets the aircraft image from Bing
450
+	 *
451
+	 * @param String $aircraft_registration the registration of the aircraft
452
+	 * @param String $aircraft_name type of the aircraft
453
+	 * @return Array the aircraft thumbnail, orignal url and copyright
454
+	 *
455
+	 */
456 456
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
457 457
 		global $globalImageBingKey;
458 458
 		$Common = new Common();
@@ -478,13 +478,13 @@  discard block
 block discarded – undo
478 478
 	}
479 479
 
480 480
 	/**
481
-	* Gets the aircraft image from airport-data
482
-	*
483
-	* @param String $aircraft_registration the registration of the aircraft
484
-	* @param String $aircraft_name type of the aircraft
485
-	* @return Array the aircraft thumbnail, orignal url and copyright
486
-	*
487
-	*/
481
+	 * Gets the aircraft image from airport-data
482
+	 *
483
+	 * @param String $aircraft_registration the registration of the aircraft
484
+	 * @param String $aircraft_name type of the aircraft
485
+	 * @return Array the aircraft thumbnail, orignal url and copyright
486
+	 *
487
+	 */
488 488
 	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
489 489
 		$Common = new Common();
490 490
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
 	}
504 504
 
505 505
 	/**
506
-	* Gets image from WikiMedia
507
-	*
508
-	* @param String $registration the registration of the aircraft/mmsi
509
-	* @param String $name name
510
-	* @return Array the aircraft thumbnail, orignal url and copyright
511
-	*
512
-	*/
506
+	 * Gets image from WikiMedia
507
+	 *
508
+	 * @param String $registration the registration of the aircraft/mmsi
509
+	 * @param String $name name
510
+	 * @return Array the aircraft thumbnail, orignal url and copyright
511
+	 *
512
+	 */
513 513
 	public function fromWikimedia($type,$registration,$name='') {
514 514
 		$Common = new Common();
515 515
 		if ($type == 'aircraft') {
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 	}
565 565
 
566 566
 	/**
567
-	* Gets the aircraft image from custom url
568
-	*
569
-	* @param String $registration the registration of the aircraft
570
-	* @param String $name type of the aircraft
571
-	* @return Array the aircraft thumbnail, orignal url and copyright
572
-	*
573
-	*/
567
+	 * Gets the aircraft image from custom url
568
+	 *
569
+	 * @param String $registration the registration of the aircraft
570
+	 * @param String $name type of the aircraft
571
+	 * @return Array the aircraft thumbnail, orignal url and copyright
572
+	 *
573
+	 */
574 574
 	public function fromCustomSource($type,$registration,$name='') {
575 575
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
576 576
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 	* @return Array the images list
18 18
 	*
19 19
 	*/
20
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
20
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
21 21
 	{
22
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
22
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
23
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
24
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
25 25
 		$reg = $registration;
26 26
 		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
27 27
 		$reg = trim($reg);
28
-		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
28
+		$query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
29 29
 			FROM spotter_image 
30 30
 			WHERE spotter_image.registration = :registration LIMIT 1";
31 31
 		$sth = $this->db->prepare($query);
32 32
 		$sth->execute(array(':registration' => $reg));
33 33
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
34 34
 		if (!empty($result)) return $result;
35
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
35
+		elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao);
36 36
 		else return array();
37 37
 	}
38 38
 
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
 	* @return Array the images list
43 43
 	*
44 44
 	*/
45
-	public function getMarineImage($mmsi,$imo = '',$name = '')
45
+	public function getMarineImage($mmsi, $imo = '', $name = '')
46 46
 	{
47
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
48
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
49
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
47
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
48
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
49
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
50 50
 		$name = trim($name);
51
-		$query  = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
51
+		$query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
52 52
 			FROM marine_image 
53 53
 			WHERE marine_image.mmsi = :mmsi";
54 54
 		$query_data = array(':mmsi' => $mmsi);
55 55
 		if ($imo != '') {
56 56
 			$query .= " AND marine_image.imo = :imo";
57
-			$query_data = array_merge($query_data,array(':imo' => $imo));
57
+			$query_data = array_merge($query_data, array(':imo' => $imo));
58 58
 		}
59 59
 		if ($name != '') {
60 60
 			$query .= " AND marine_image.name = :name";
61
-			$query_data = array_merge($query_data,array(':name' => $name));
61
+			$query_data = array_merge($query_data, array(':name' => $name));
62 62
 		}
63 63
 		$query .= " LIMIT 1";
64 64
 		$sth = $this->db->prepare($query);
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
80 80
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
81 81
 		if ($copyright != '') {
82
-			$copyright = str_replace('Copyright ','',$copyright);
83
-			$copyright = str_replace('© ','',$copyright);
84
-			$copyright = str_replace('(c) ','',$copyright);
82
+			$copyright = str_replace('Copyright ', '', $copyright);
83
+			$copyright = str_replace('© ', '', $copyright);
84
+			$copyright = str_replace('(c) ', '', $copyright);
85 85
 		}
86 86
 		return $copyright;
87 87
 	}
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
 	* @return String either success or error
93 93
 	*
94 94
 	*/
95
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
95
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
96 96
 	{
97
-		global $globalDebug,$globalAircraftImageFetch;
97
+		global $globalDebug, $globalAircraftImageFetch;
98 98
 		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
99
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
99
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
100 100
 		$registration = trim($registration);
101 101
 		//getting the aircraft image
102 102
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
103 103
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
104 104
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
105
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
105
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
106 106
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
107 107
 		if ($image_url['original'] != '') {
108 108
 			if ($globalDebug) echo 'Found !'."\n";
109
-			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
109
+			$query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
110 110
 			try {
111 111
 				$sth = $this->db->prepare($query);
112
-				$sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
113
-			} catch(PDOException $e) {
112
+				$sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
113
+			} catch (PDOException $e) {
114 114
 				echo $e->getMessage()."\n";
115 115
 				return "error";
116 116
 			}
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
 	* @return String either success or error
125 125
 	*
126 126
 	*/
127
-	public function addMarineImage($mmsi,$imo = '',$name = '')
127
+	public function addMarineImage($mmsi, $imo = '', $name = '')
128 128
 	{
129
-		global $globalDebug,$globalMarineImageFetch;
129
+		global $globalDebug, $globalMarineImageFetch;
130 130
 		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return '';
131
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
132
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
133
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
131
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
132
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
133
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
134 134
 		$name = trim($name);
135 135
 		$Marine = new Marine($this->db);
136 136
 		if ($imo == '' || $name == '') {
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 
145 145
 		//getting the aircraft image
146 146
 		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
147
-		$image_url = $this->findMarineImage($mmsi,$imo,$name);
147
+		$image_url = $this->findMarineImage($mmsi, $imo, $name);
148 148
 		if ($image_url['original'] != '') {
149 149
 			if ($globalDebug) echo 'Found !'."\n";
150
-			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
150
+			$query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
151 151
 			try {
152 152
 				$sth = $this->db->prepare($query);
153
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
154
-			} catch(PDOException $e) {
153
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
154
+			} catch (PDOException $e) {
155 155
 				echo $e->getMessage()."\n";
156 156
 				return "error";
157 157
 			}
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
172 172
 		$Spotter = new Spotter($this->db);
173 173
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
174
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
174
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
175 175
 		if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) {
176
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
176
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
177 177
 			$aircraft_registration = urlencode(trim($aircraft_registration));
178 178
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
179 179
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -187,25 +187,25 @@  discard block
 block discarded – undo
187 187
 			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
188 188
 			else $aircraft_name = '';
189 189
 			$aircraft_registration = $aircraft_icao;
190
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
190
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
191 191
 		unset($Spotter);
192
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
192
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
193 193
 		foreach ($globalAircraftImageSources as $source) {
194 194
 			$source = strtolower($source);
195
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
196
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
197
-			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
198
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
199
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
200
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
201
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
202
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
203
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
204
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
195
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao);
196
+			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name);
197
+			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name);
198
+			if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name);
199
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name);
200
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name);
201
+			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name);
202
+			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name);
203
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name);
204
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name);
205 205
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
206 206
 		}
207 207
 		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
208
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
208
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
209 209
 	}
210 210
 
211 211
 	/**
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 	* @return Array the aircraft thumbnail, orignal url and copyright
218 218
 	*
219 219
 	*/
220
-	public function findMarineImage($mmsi,$imo = '',$name = '')
220
+	public function findMarineImage($mmsi, $imo = '', $name = '')
221 221
 	{
222 222
 		global $globalMarineImageSources;
223
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
223
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
224 224
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
225
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
225
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
226 226
 		$name = trim($name);
227
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
227
+		if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
228 228
 		/*
229 229
 		$Marine = new Marine($this->db);
230 230
 		if ($imo == '' || $name == '') {
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
 		}
237 237
 		unset($Marine);
238 238
 		*/
239
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
239
+		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing');
240 240
 		foreach ($globalMarineImageSources as $source) {
241 241
 			$source = strtolower($source);
242
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
243
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
244
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
245
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
246
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
242
+			if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name);
243
+			if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name);
244
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name);
245
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name);
246
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name);
247 247
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
248 248
 		}
249
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
249
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
250 250
 	}
251 251
 
252 252
 	/**
@@ -257,24 +257,24 @@  discard block
 block discarded – undo
257 257
 	* @return Array the aircraft thumbnail, orignal url and copyright
258 258
 	*
259 259
 	*/
260
-	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
260
+	public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') {
261 261
 		$Common = new Common();
262 262
 		// If aircraft registration is only number, also check with aircraft model
263
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
264
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
263
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
264
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
265 265
 		} else {
266 266
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
267
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
267
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
268 268
 		}
269 269
 		$data = $Common->getData($url);
270 270
 		if ($xml = simplexml_load_string($data)) {
271 271
 			if (isset($xml->channel->item)) {
272 272
 				$image_url = array();
273
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
273
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
274 274
 				$image_url['thumbnail'] = $thumbnail_url;
275
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
276
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
277
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
275
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
276
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
277
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
278 278
 				$image_url['source'] = 'planespotters';
279 279
 				return $image_url;
280 280
 			}
@@ -290,29 +290,29 @@  discard block
 block discarded – undo
290 290
 	* @return Array the aircraft thumbnail, orignal url and copyright
291 291
 	*
292 292
 	*/
293
-	public function fromDeviantart($type,$registration, $name='') {
293
+	public function fromDeviantart($type, $registration, $name = '') {
294 294
 		$Common = new Common();
295 295
 		if ($type == 'aircraft') {
296 296
 			// If aircraft registration is only number, also check with aircraft model
297
-			if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') {
298
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
297
+			if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') {
298
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
299 299
 			} else {
300
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
300
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
301 301
 			}
302 302
 		} elseif ($type == 'marine') {
303
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
303
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
304 304
 		}
305 305
 
306 306
 		$data = $Common->getData($url);
307 307
 		if ($xml = simplexml_load_string($data)) {
308 308
 			if (isset($xml->channel->item->link)) {
309 309
 				$image_url = array();
310
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
310
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
311 311
 				$image_url['thumbnail'] = $thumbnail_url;
312
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
312
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
313 313
 				$image_url['original'] = $original_url;
314
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
315
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
314
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
315
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
316 316
 				$image_url['source'] = 'deviantart';
317 317
 				return $image_url;
318 318
 			}
@@ -328,32 +328,32 @@  discard block
 block discarded – undo
328 328
 	* @return Array the aircraft thumbnail, orignal url and copyright
329 329
 	*
330 330
 	*/
331
-	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
331
+	public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') {
332 332
 		$Common = new Common();
333
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
333
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
334 334
 		$data = $Common->getData($url);
335 335
 		$dom = new DOMDocument();
336 336
 		@$dom->loadHTML($data);
337 337
 		$all_pics = array();
338
-		foreach($dom->getElementsByTagName('img') as $image) {
338
+		foreach ($dom->getElementsByTagName('img') as $image) {
339 339
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
340 340
 				$all_pics[] = $image->getAttribute('src');
341 341
 			}
342 342
 		}
343 343
 		$all_authors = array();
344
-		foreach($dom->getElementsByTagName('meta') as $author) {
344
+		foreach ($dom->getElementsByTagName('meta') as $author) {
345 345
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
346 346
 				$all_authors[] = $author->getAttribute('content');
347 347
 			}
348 348
 		}
349 349
 		$all_ref = array();
350
-		foreach($dom->getElementsByTagName('a') as $link) {
350
+		foreach ($dom->getElementsByTagName('a') as $link) {
351 351
 			$all_ref[] = $link->getAttribute('href');
352 352
 		}
353 353
 		if (isset($all_pics[0])) {
354 354
 			$image_url = array();
355 355
 			$image_url['thumbnail'] = $all_pics[0];
356
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
356
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
357 357
 			$image_url['copyright'] = $all_authors[0];
358 358
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
359 359
 			$image_url['source'] = 'JetPhotos';
@@ -370,24 +370,24 @@  discard block
 block discarded – undo
370 370
 	* @return Array the aircraft thumbnail, orignal url and copyright
371 371
 	*
372 372
 	*/
373
-	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
373
+	public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') {
374 374
 		$Common = new Common();
375
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
375
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
376 376
 		$data = $Common->getData($url);
377 377
 		$dom = new DOMDocument();
378 378
 		@$dom->loadHTML($data);
379 379
 		$all_pics = array();
380
-		foreach($dom->getElementsByTagName('img') as $image) {
380
+		foreach ($dom->getElementsByTagName('img') as $image) {
381 381
 			$all_pics[] = $image->getAttribute('src');
382 382
 		}
383 383
 		$all_links = array();
384
-		foreach($dom->getElementsByTagName('a') as $link) {
385
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
384
+		foreach ($dom->getElementsByTagName('a') as $link) {
385
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
386 386
 		}
387
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) {
387
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) {
388 388
 			$image_url = array();
389 389
 			$image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1];
390
-			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]);
390
+			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]);
391 391
 			$image_url['copyright'] = $all_links[6]['text'];
392 392
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
393 393
 			$image_url['source'] = 'PlanePictures';
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	* @return Array the aircraft thumbnail, orignal url and copyright
405 405
 	*
406 406
 	*/
407
-	public function fromFlickr($type,$registration,$name='') {
407
+	public function fromFlickr($type, $registration, $name = '') {
408 408
 		$Common = new Common();
409 409
 		if ($type == 'aircraft') {
410 410
 			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
 		$data = $Common->getData($url);
417 417
 		if ($xml = simplexml_load_string($data)) {
418 418
 			if (isset($xml->channel->item)) {
419
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
419
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
420 420
 				$image_url = array();
421 421
 				$image_url['thumbnail'] = $original_url;
422 422
 				$image_url['original'] = $original_url;
423
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
424
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
423
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
424
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
425 425
 				$image_url['source'] = 'flickr';
426 426
 				return $image_url;
427 427
 			}
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		return false;
430 430
 	}
431 431
 
432
-	public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) {
432
+	public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) {
433 433
 		$Common = new Common();
434 434
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
435 435
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	* @return Array the aircraft thumbnail, orignal url and copyright
454 454
 	*
455 455
 	*/
456
-	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
456
+	public function fromBing($type, $aircraft_registration, $aircraft_name = '') {
457 457
 		global $globalImageBingKey;
458 458
 		$Common = new Common();
459 459
 		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
 			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
465 465
 			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
466 466
 		}
467
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
468
-		$data = $Common->getData($url,'get','',$headers);
467
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
468
+		$data = $Common->getData($url, 'get', '', $headers);
469 469
 		$result = json_decode($data);
470 470
 		if (isset($result->d->results[0]->MediaUrl)) {
471 471
 			$image_url = array();
@@ -490,14 +490,14 @@  discard block
 block discarded – undo
490 490
 	* @return Array the aircraft thumbnail, orignal url and copyright
491 491
 	*
492 492
 	*/
493
-	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
493
+	public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') {
494 494
 		$Common = new Common();
495 495
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
496 496
 		$data = $Common->getData($url);
497 497
 		$result = json_decode($data);
498 498
 		if (isset($result->count) && $result->count > 0) {
499 499
 			$image_url = array();
500
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
500
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
501 501
 			$image_url['source_website'] = $result->data[0]->link;
502 502
 			$image_url['thumbnail'] = $result->data[0]->image;
503 503
 			$image_url['copyright'] = $result->data[0]->photographer;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	* @return Array the aircraft thumbnail, orignal url and copyright
516 516
 	*
517 517
 	*/
518
-	public function fromWikimedia($type,$registration,$name='') {
518
+	public function fromWikimedia($type, $registration, $name = '') {
519 519
 		$Common = new Common();
520 520
 		if ($type == 'aircraft') {
521 521
 			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 		$result = json_decode($data);
529 529
 		if (isset($result->query->search[0]->title)) {
530 530
 			$fileo = $result->query->search[0]->title;
531
-			if (substr($fileo,-3) == 'pdf') return false;
531
+			if (substr($fileo, -3) == 'pdf') return false;
532 532
 			$file = urlencode($fileo);
533 533
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
534 534
 			$data2 = $Common->getData($url2);
@@ -553,11 +553,11 @@  discard block
 block discarded – undo
553 553
 				if (isset($result2->query->pages)) {
554 554
 					foreach ($result2->query->pages as $page) {
555 555
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
556
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
556
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
557 557
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
558 558
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
559 559
 							}
560
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
560
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
561 561
 							return $image_url;
562 562
 						}
563 563
 					}
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	* @return Array the aircraft thumbnail, orignal url and copyright
577 577
 	*
578 578
 	*/
579
-	public function fromCustomSource($type,$registration,$name='') {
579
+	public function fromCustomSource($type, $registration, $name = '') {
580 580
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
581 581
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
582 582
 		if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') {
@@ -593,15 +593,15 @@  discard block
 block discarded – undo
593 593
 					print_r($source);
594 594
 					print_r($customsources);
595 595
 				}
596
-				$url = str_replace('{registration}',$registration,$source['original']);
597
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
596
+				$url = str_replace('{registration}', $registration, $source['original']);
597
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
598 598
 				if ($Common->urlexist($url)) {
599 599
 					$image_url = array();
600 600
 					$image_url['thumbnail'] = $url_thumbnail;
601 601
 					$image_url['original'] = $url;
602 602
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
603 603
 					else $exifCopyright = '';
604
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
604
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
605 605
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
606 606
 					else $image_url['copyright'] = $source['source_website'];
607 607
 					$image_url['source_website'] = $source['source_website'];
@@ -625,19 +625,19 @@  discard block
 block discarded – undo
625 625
 					print_r($source);
626 626
 					print_r($customsources);
627 627
 				}
628
-				$url = str_replace('{registration}',$registration,$source['original']);
629
-				$url = str_replace('{mmsi}',$registration,$url);
630
-				$url = str_replace('{name}',$name,$url);
631
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
632
-				$url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail);
633
-				$url_thumbnail = str_replace('{name}',$name,$url_thumbnail);
628
+				$url = str_replace('{registration}', $registration, $source['original']);
629
+				$url = str_replace('{mmsi}', $registration, $url);
630
+				$url = str_replace('{name}', $name, $url);
631
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
632
+				$url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail);
633
+				$url_thumbnail = str_replace('{name}', $name, $url_thumbnail);
634 634
 				if ($Common->urlexist($url)) {
635 635
 					$image_url = array();
636 636
 					$image_url['thumbnail'] = $url_thumbnail;
637 637
 					$image_url['original'] = $url;
638 638
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
639 639
 					else $exifCopyright = '';
640
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
640
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
641 641
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
642 642
 					else $image_url['copyright'] = $source['source_website'];
643 643
 					$image_url['source_website'] = $source['source_website'];
Please login to merge, or discard this patch.
Braces   +208 added lines, -77 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24 24
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
25 25
 		$reg = $registration;
26
-		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
26
+		if ($reg == '' && $aircraft_icao != '') {
27
+			$reg = $aircraft_icao.$airline_icao;
28
+		}
27 29
 		$reg = trim($reg);
28 30
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
29 31
 			FROM spotter_image 
@@ -31,9 +33,13 @@  discard block
 block discarded – undo
31 33
 		$sth = $this->db->prepare($query);
32 34
 		$sth->execute(array(':registration' => $reg));
33 35
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
34
-		if (!empty($result)) return $result;
35
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
36
-		else return array();
36
+		if (!empty($result)) {
37
+			return $result;
38
+		} elseif ($registration != '') {
39
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
40
+		} else {
41
+			return array();
42
+		}
37 43
 	}
38 44
 
39 45
 	/**
@@ -76,8 +82,11 @@  discard block
 block discarded – undo
76 82
 	public function getExifCopyright($url) {
77 83
 		$exif = exif_read_data($url);
78 84
 		$copyright = '';
79
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
80
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
85
+		if (isset($exif['COMPUTED']['copyright'])) {
86
+			$copyright = $exif['COMPUTED']['copyright'];
87
+		} elseif (isset($exif['copyright'])) {
88
+			$copyright = $exif['copyright'];
89
+		}
81 90
 		if ($copyright != '') {
82 91
 			$copyright = str_replace('Copyright ','',$copyright);
83 92
 			$copyright = str_replace('© ','',$copyright);
@@ -95,17 +104,27 @@  discard block
 block discarded – undo
95 104
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
96 105
 	{
97 106
 		global $globalDebug,$globalAircraftImageFetch;
98
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
107
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
108
+			return '';
109
+		}
99 110
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
100 111
 		$registration = trim($registration);
101 112
 		//getting the aircraft image
102
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
103
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
104
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
113
+		if ($globalDebug && $registration != '') {
114
+			echo 'Try to find an aircraft image for '.$registration.'...';
115
+		} elseif ($globalDebug && $aircraft_icao != '') {
116
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
117
+		} elseif ($globalDebug && $airline_icao != '') {
118
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
119
+		}
105 120
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
106
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
121
+		if ($registration == '' && $aircraft_icao != '') {
122
+			$registration = $aircraft_icao.$airline_icao;
123
+		}
107 124
 		if ($image_url['original'] != '') {
108
-			if ($globalDebug) echo 'Found !'."\n";
125
+			if ($globalDebug) {
126
+				echo 'Found !'."\n";
127
+			}
109 128
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
110 129
 			try {
111 130
 				$sth = $this->db->prepare($query);
@@ -114,7 +133,9 @@  discard block
 block discarded – undo
114 133
 				echo $e->getMessage()."\n";
115 134
 				return "error";
116 135
 			}
117
-		} elseif ($globalDebug) echo "Not found :'(\n";
136
+		} elseif ($globalDebug) {
137
+			echo "Not found :'(\n";
138
+		}
118 139
 		return "success";
119 140
 	}
120 141
 
@@ -127,7 +148,9 @@  discard block
 block discarded – undo
127 148
 	public function addMarineImage($mmsi,$imo = '',$name = '')
128 149
 	{
129 150
 		global $globalDebug,$globalMarineImageFetch;
130
-		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return '';
151
+		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) {
152
+			return '';
153
+		}
131 154
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
132 155
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
133 156
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
@@ -137,16 +160,22 @@  discard block
 block discarded – undo
137 160
 			$identity = $Marine->getIdentity($mmsi);
138 161
 			if (isset($identity[0]['mmsi'])) {
139 162
 				$imo = $identity[0]['imo'];
140
-				if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name'];
163
+				if ($identity[0]['ship_name'] != '') {
164
+					$name = $identity[0]['ship_name'];
165
+				}
141 166
 			}
142 167
 		}
143 168
 		unset($Marine);
144 169
 
145 170
 		//getting the aircraft image
146
-		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
171
+		if ($globalDebug && $name != '') {
172
+			echo 'Try to find an vessel image for '.$name.'...';
173
+		}
147 174
 		$image_url = $this->findMarineImage($mmsi,$imo,$name);
148 175
 		if ($image_url['original'] != '') {
149
-			if ($globalDebug) echo 'Found !'."\n";
176
+			if ($globalDebug) {
177
+				echo 'Found !'."\n";
178
+			}
150 179
 			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
151 180
 			try {
152 181
 				$sth = $this->db->prepare($query);
@@ -155,7 +184,9 @@  discard block
 block discarded – undo
155 184
 				echo $e->getMessage()."\n";
156 185
 				return "error";
157 186
 			}
158
-		} elseif ($globalDebug) echo "Not found :'(\n";
187
+		} elseif ($globalDebug) {
188
+			echo "Not found :'(\n";
189
+		}
159 190
 		return "success";
160 191
 	}
161 192
 
@@ -170,41 +201,85 @@  discard block
 block discarded – undo
170 201
 	{
171 202
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
172 203
 		$Spotter = new Spotter($this->db);
173
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
204
+		if (!isset($globalIVAO)) {
205
+			$globalIVAO = FALSE;
206
+		}
174 207
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
175 208
 		if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) {
176
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
209
+			if (strpos($aircraft_registration,'/') !== false) {
210
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
211
+			}
177 212
 			$aircraft_registration = urlencode(trim($aircraft_registration));
178 213
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
179
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
180
-			else $aircraft_name = '';
181
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
182
-			else $aircraft_icao = '';
183
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
184
-			else $airline_icao = '';
214
+			if (isset($aircraft_info[0]['aircraft_name'])) {
215
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
216
+			} else {
217
+				$aircraft_name = '';
218
+			}
219
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
220
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
221
+			} else {
222
+				$aircraft_icao = '';
223
+			}
224
+			if (isset($aircraft_info[0]['airline_icao'])) {
225
+				$airline_icao = $aircraft_info[0]['airline_icao'];
226
+			} else {
227
+				$airline_icao = '';
228
+			}
185 229
 		} elseif ($aircraft_icao != '') {
186 230
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
187
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
188
-			else $aircraft_name = '';
231
+			if (isset($aircraft_info[0]['type'])) {
232
+				$aircraft_name = $aircraft_info[0]['type'];
233
+			} else {
234
+				$aircraft_name = '';
235
+			}
189 236
 			$aircraft_registration = $aircraft_icao;
190
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
237
+		} else {
238
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
239
+		}
191 240
 		unset($Spotter);
192
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
241
+		if (!isset($globalAircraftImageSources)) {
242
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
243
+		}
193 244
 		foreach ($globalAircraftImageSources as $source) {
194 245
 			$source = strtolower($source);
195
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
196
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
197
-			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
198
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
199
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
200
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
201
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
202
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
203
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
204
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
205
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
206
-		}
207
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
246
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
247
+				$images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
248
+			}
249
+			if ($source == 'planespotters' && !$globalIVAO) {
250
+				$images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
251
+			}
252
+			if ($source == 'flickr') {
253
+				$images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
254
+			}
255
+			if ($source == 'bing') {
256
+				$images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
257
+			}
258
+			if ($source == 'deviantart') {
259
+				$images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
260
+			}
261
+			if ($source == 'wikimedia') {
262
+				$images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
263
+			}
264
+			if ($source == 'jetphotos' && !$globalIVAO) {
265
+				$images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
266
+			}
267
+			if ($source == 'planepictures' && !$globalIVAO) {
268
+				$images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
269
+			}
270
+			if ($source == 'airportdata' && !$globalIVAO) {
271
+				$images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
272
+			}
273
+			if ($source == 'customsources') {
274
+				$images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
275
+			}
276
+			if (isset($images_array) && $images_array['original'] != '') {
277
+				return $images_array;
278
+			}
279
+		}
280
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
281
+			return $this->findAircraftImage($aircraft_icao);
282
+		}
208 283
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
209 284
 	}
210 285
 
@@ -224,7 +299,9 @@  discard block
 block discarded – undo
224 299
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
225 300
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
226 301
 		$name = trim($name);
227
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
302
+		if (strlen($name) < 4) {
303
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
304
+		}
228 305
 		/*
229 306
 		$Marine = new Marine($this->db);
230 307
 		if ($imo == '' || $name == '') {
@@ -236,15 +313,29 @@  discard block
 block discarded – undo
236 313
 		}
237 314
 		unset($Marine);
238 315
 		*/
239
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
316
+		if (!isset($globalMarineImageSources)) {
317
+			$globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
318
+		}
240 319
 		foreach ($globalMarineImageSources as $source) {
241 320
 			$source = strtolower($source);
242
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
243
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
244
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
245
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
246
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
247
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
321
+			if ($source == 'flickr') {
322
+				$images_array = $this->fromFlickr('marine',$mmsi,$name);
323
+			}
324
+			if ($source == 'bing') {
325
+				$images_array = $this->fromBing('marine',$mmsi,$name);
326
+			}
327
+			if ($source == 'deviantart') {
328
+				$images_array = $this->fromDeviantart('marine',$mmsi,$name);
329
+			}
330
+			if ($source == 'wikimedia') {
331
+				$images_array = $this->fromWikimedia('marine',$mmsi,$name);
332
+			}
333
+			if ($source == 'customsources') {
334
+				$images_array = $this->fromCustomSource('marine',$mmsi,$name);
335
+			}
336
+			if (isset($images_array) && $images_array['original'] != '') {
337
+				return $images_array;
338
+			}
248 339
 		}
249 340
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
250 341
 	}
@@ -407,11 +498,17 @@  discard block
 block discarded – undo
407 498
 	public function fromFlickr($type,$registration,$name='') {
408 499
 		$Common = new Common();
409 500
 		if ($type == 'aircraft') {
410
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
411
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
501
+			if ($name != '') {
502
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
503
+			} else {
504
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
505
+			}
412 506
 		} elseif ($type == 'marine') {
413
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
414
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
507
+			if ($name != '') {
508
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
509
+			} else {
510
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
511
+			}
415 512
 		}
416 513
 		$data = $Common->getData($url);
417 514
 		if ($xml = simplexml_load_string($data)) {
@@ -456,13 +553,21 @@  discard block
 block discarded – undo
456 553
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
457 554
 		global $globalImageBingKey;
458 555
 		$Common = new Common();
459
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
556
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
557
+			return false;
558
+		}
460 559
 		if ($type == 'aircraft') {
461
-			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
462
-			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
560
+			if ($aircraft_name != '') {
561
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
562
+			} else {
563
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
564
+			}
463 565
 		} elseif ($type == 'marine') {
464
-			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
465
-			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
566
+			if ($aircraft_name != '') {
567
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
568
+			} else {
569
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
570
+			}
466 571
 		}
467 572
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
468 573
 		$data = $Common->getData($url,'get','',$headers);
@@ -518,17 +623,25 @@  discard block
 block discarded – undo
518 623
 	public function fromWikimedia($type,$registration,$name='') {
519 624
 		$Common = new Common();
520 625
 		if ($type == 'aircraft') {
521
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
522
-			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
626
+			if ($name != '') {
627
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
628
+			} else {
629
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
630
+			}
523 631
 		} elseif ($type == 'marine') {
524
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
525
-			else return false;
632
+			if ($name != '') {
633
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
634
+			} else {
635
+				return false;
636
+			}
526 637
 		}
527 638
 		$data = $Common->getData($url);
528 639
 		$result = json_decode($data);
529 640
 		if (isset($result->query->search[0]->title)) {
530 641
 			$fileo = $result->query->search[0]->title;
531
-			if (substr($fileo,-3) == 'pdf') return false;
642
+			if (substr($fileo,-3) == 'pdf') {
643
+				return false;
644
+			}
532 645
 			$file = urlencode($fileo);
533 646
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
534 647
 			$data2 = $Common->getData($url2);
@@ -599,18 +712,27 @@  discard block
 block discarded – undo
599 712
 					$image_url = array();
600 713
 					$image_url['thumbnail'] = $url_thumbnail;
601 714
 					$image_url['original'] = $url;
602
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
603
-					else $exifCopyright = '';
604
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
605
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
606
-					else $image_url['copyright'] = $source['source_website'];
715
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
716
+						$exifCopyright = $this->getExifCopyright($url);
717
+					} else {
718
+						$exifCopyright = '';
719
+					}
720
+					if ($exifCopyright  != '') {
721
+						$image_url['copyright'] = $exifCopyright;
722
+					} elseif (isset($source['copyright'])) {
723
+						$image_url['copyright'] = $source['copyright'];
724
+					} else {
725
+						$image_url['copyright'] = $source['source_website'];
726
+					}
607 727
 					$image_url['source_website'] = $source['source_website'];
608 728
 					$image_url['source'] = $source['source'];
609 729
 					return $image_url;
610 730
 				}
611 731
 			}
612 732
 			return false;
613
-		} else return false;
733
+		} else {
734
+			return false;
735
+		}
614 736
 		if (!empty($globalMarineImageCustomSources) && $type == 'marine') {
615 737
 			$customsources = array();
616 738
 			if (!isset($globalMarineImageCustomSources[0])) {
@@ -635,18 +757,27 @@  discard block
 block discarded – undo
635 757
 					$image_url = array();
636 758
 					$image_url['thumbnail'] = $url_thumbnail;
637 759
 					$image_url['original'] = $url;
638
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
639
-					else $exifCopyright = '';
640
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
641
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
642
-					else $image_url['copyright'] = $source['source_website'];
760
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
761
+						$exifCopyright = $this->getExifCopyright($url);
762
+					} else {
763
+						$exifCopyright = '';
764
+					}
765
+					if ($exifCopyright  != '') {
766
+						$image_url['copyright'] = $exifCopyright;
767
+					} elseif (isset($source['copyright'])) {
768
+						$image_url['copyright'] = $source['copyright'];
769
+					} else {
770
+						$image_url['copyright'] = $source['source_website'];
771
+					}
643 772
 					$image_url['source_website'] = $source['source_website'];
644 773
 					$image_url['source'] = $source['source'];
645 774
 					return $image_url;
646 775
 				}
647 776
 			}
648 777
 			return false;
649
-		} else return false;
778
+		} else {
779
+			return false;
780
+		}
650 781
 	}
651 782
 }
652 783
 
Please login to merge, or discard this patch.