Completed
Push — master ( 87b863...3be42e )
by Yannick
104:15 queued 75:58
created
statistics-sub-menu.php 1 patch
Braces   +110 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,7 +6,13 @@  discard block
 block discarded – undo
6 6
 	if (!isset($type) || $type != 'satellite') {
7 7
 ?>
8 8
 		<form id="changedate" method="post">
9
-			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') echo $year.'-'; ?><?php if (isset($month) && $month != '') echo $month; ?>" />
9
+			<input type="month" name="date" onchange="statsdatechange(this);" value="<?php if (isset($year) && $year != '') {
10
+	echo $year.'-';
11
+}
12
+?><?php if (isset($month) && $month != '') {
13
+	echo $month;
14
+}
15
+?>" />
10 16
 		</form>
11 17
 <?php
12 18
 	}
@@ -38,7 +44,9 @@  discard block
 block discarded – undo
38 44
 						print '<option disabled>──────────</option>';
39 45
 					}
40 46
 					$Stats = new Stats();
41
-					if (!isset($filter_name)) $filter_name = '';
47
+					if (!isset($filter_name)) {
48
+						$filter_name = '';
49
+					}
42 50
 					$airlines = $Stats->getAllAirlineNames($filter_name);
43 51
 					foreach($airlines as $airline) {
44 52
 						if ($airline['airline_icao'] != '') {
@@ -69,10 +77,22 @@  discard block
 block discarded – undo
69 77
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
70 78
 		    </a>
71 79
 		    <ul class="dropdown-menu">
72
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Aircraft"); ?></a></li>
73
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Registration"); ?></a></li>
74
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Manufacturer"); ?></a></li>
75
-			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Country"); ?></a></li>
80
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
81
+	echo '/'.$airline_icao;
82
+}
83
+?>"><?php echo _("Aircraft"); ?></a></li>
84
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
85
+	echo '/'.$airline_icao;
86
+}
87
+?>"><?php echo _("Registration"); ?></a></li>
88
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
89
+	echo '/'.$airline_icao;
90
+}
91
+?>"><?php echo _("Manufacturer"); ?></a></li>
92
+			<li><a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
93
+	echo '/'.$airline_icao;
94
+}
95
+?>"><?php echo _("Country"); ?></a></li>
76 96
 		    </ul>
77 97
 		</li>
78 98
 		<li class="dropdown">
@@ -83,12 +103,21 @@  discard block
 block discarded – undo
83 103
 <?php
84 104
 		if (!isset($airline_icao) || $airline_icao == 'all') {
85 105
 ?>
86
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline"); ?></a></li>
87
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Airline by Country"); ?></a></li>
106
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
107
+	echo '/'.$airline_icao;
108
+}
109
+?>"><?php echo _("Airline"); ?></a></li>
110
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
111
+	echo '/'.$airline_icao;
112
+}
113
+?>"><?php echo _("Airline by Country"); ?></a></li>
88 114
 <?php
89 115
 		}
90 116
 ?>
91
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Callsign"); ?></a></li>
117
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
118
+	echo '/'.$airline_icao;
119
+}
120
+?>"><?php echo _("Callsign"); ?></a></li>
92 121
 		    </ul>
93 122
 		</li>
94 123
 		<li class="dropdown">
@@ -96,10 +125,22 @@  discard block
 block discarded – undo
96 125
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
97 126
 		    </a>
98 127
 		    <ul class="dropdown-menu" role="menu">
99
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport"); ?></a></li>
100
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
101
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport"); ?></a></li>
102
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
128
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
129
+	echo '/'.$airline_icao;
130
+}
131
+?>"><?php echo _("Departure Airport"); ?></a></li>
132
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
133
+	echo '/'.$airline_icao;
134
+}
135
+?>"><?php echo _("Departure Airport by Country"); ?></a></li>
136
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
137
+	echo '/'.$airline_icao;
138
+}
139
+?>"><?php echo _("Arrival Airport"); ?></a></li>
140
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
141
+	echo '/'.$airline_icao;
142
+}
143
+?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
103 144
 		    </ul>
104 145
 		</li>
105 146
 		<li class="dropdown">
@@ -107,8 +148,14 @@  discard block
 block discarded – undo
107 148
 		      <?php echo _("Route"); ?> <span class="caret"></span>
108 149
 		    </a>
109 150
 		    <ul class="dropdown-menu" role="menu">
110
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Airport"); ?></a></li>
111
-		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Route by Waypoint"); ?></a></li>
151
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-airport<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
152
+	echo '/'.$airline_icao;
153
+}
154
+?>"><?php echo _("Route by Airport"); ?></a></li>
155
+		      <li><a href="<?php print $globalURL; ?>/statistics/route-waypoint<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
156
+	echo '/'.$airline_icao;
157
+}
158
+?>"><?php echo _("Route by Waypoint"); ?></a></li>
112 159
 		    </ul>
113 160
 		</li>
114 161
 		<li class="dropdown">
@@ -116,8 +163,14 @@  discard block
 block discarded – undo
116 163
 		      <?php echo _("Date &amp; Time"); ?> <span class="caret"></span>
117 164
 		    </a>
118 165
 		    <ul class="dropdown-menu" role="menu">
119
-		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Date"); ?></a></li>
120
-			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>"><?php echo _("Time"); ?></a></li>
166
+		      <li><a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
167
+	echo '/'.$airline_icao;
168
+}
169
+?>"><?php echo _("Date"); ?></a></li>
170
+			  <li><a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
171
+	echo '/'.$airline_icao;
172
+}
173
+?>"><?php echo _("Time"); ?></a></li>
121 174
 		    </ul>
122 175
 		</li>
123 176
 		<?php
@@ -173,9 +226,18 @@  discard block
 block discarded – undo
173 226
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
174 227
 		    </a>
175 228
 		    <ul class="dropdown-menu">
176
-			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
177
-			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
178
-			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
229
+			<li><a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
230
+	echo '/'.$airline_icao;
231
+}
232
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Aircraft"); ?></a></li>
233
+			<li><a href="<?php print $globalURL; ?>/statistics/registration<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
234
+	echo '/'.$airline_icao;
235
+}
236
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Registration"); ?></a></li>
237
+			<li><a href="<?php print $globalURL; ?>/statistics/manufacturer<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
238
+	echo '/'.$airline_icao;
239
+}
240
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Manufacturer"); ?></a></li>
179 241
 			<!-- <li><a href="<?php print $globalURL; ?>/statistics/country"><?php echo _("Country"); ?></a></li> -->
180 242
 		    </ul>
181 243
 		</li>
@@ -187,12 +249,21 @@  discard block
 block discarded – undo
187 249
 <?php
188 250
 		if (!isset($airline_icao) || $airline_icao == 'all') {
189 251
 ?>
190
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
191
-		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
252
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
253
+	echo '/'.$airline_icao;
254
+}
255
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline"); ?></a></li>
256
+		      <li><a href="<?php print $globalURL; ?>/statistics/airline-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
257
+	echo '/'.$airline_icao;
258
+}
259
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Airline by Country"); ?></a></li>
192 260
 <?php
193 261
 		}
194 262
 ?>
195
-		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
263
+		      <li><a href="<?php print $globalURL; ?>/statistics/callsign<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
264
+	echo '/'.$airline_icao;
265
+}
266
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Callsign"); ?></a></li>
196 267
 		    </ul>
197 268
 		</li>
198 269
 		<li class="dropdown">
@@ -200,10 +271,22 @@  discard block
 block discarded – undo
200 271
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
201 272
 		    </a>
202 273
 		    <ul class="dropdown-menu" role="menu">
203
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
204
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
205
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
206
-		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
274
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
275
+	echo '/'.$airline_icao;
276
+}
277
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport"); ?></a></li>
278
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-departure-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
279
+	echo '/'.$airline_icao;
280
+}
281
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Departure Airport by Country"); ?></a></li>
282
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
283
+	echo '/'.$airline_icao;
284
+}
285
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport"); ?></a></li>
286
+		      <li><a href="<?php print $globalURL; ?>/statistics/airport-arrival-country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
287
+	echo '/'.$airline_icao;
288
+}
289
+?>/<?php echo $year.'/'.$month.'/'; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
207 290
 		    </ul>
208 291
 		</li>
209 292
 		<!--
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +143 added lines, -48 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (SpotterLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (SpotterLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -126,8 +130,11 @@  discard block
 block discarded – undo
126 130
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
127 131
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
128 132
 		}
129
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
130
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
133
+		if ($filter_query_where == '' && $where) {
134
+			$filter_query_where = ' WHERE';
135
+		} elseif ($filter_query_where != '' && $and) {
136
+			$filter_query_where .= ' AND';
137
+		}
131 138
 		if ($filter_query_where != '') {
132 139
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
133 140
 		}
@@ -168,9 +175,13 @@  discard block
 block discarded – undo
168 175
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
169 176
 			}
170 177
 		}
171
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
178
+		if ($orderby_query == '') {
179
+			$orderby_query = ' ORDER BY date DESC';
180
+		}
172 181
 
173
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
182
+		if (!isset($globalLiveInterval)) {
183
+			$globalLiveInterval = '200';
184
+		}
174 185
 		if ($globalDBdriver == 'mysql') {
175 186
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
176 187
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -193,7 +204,9 @@  discard block
 block discarded – undo
193 204
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
194 205
 		date_default_timezone_set('UTC');
195 206
 		$filter_query = $this->getFilter($filter,true,true);
196
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
207
+		if (!isset($globalLiveInterval)) {
208
+			$globalLiveInterval = '200';
209
+		}
197 210
 		if ($globalDBdriver == 'mysql') {
198 211
 			if (isset($globalArchive) && $globalArchive === TRUE) {
199 212
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -244,8 +257,12 @@  discard block
 block discarded – undo
244 257
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
245 258
 		$filter_query = $this->getFilter($filter,true,true);
246 259
 
247
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
248
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
260
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
261
+			$globalLiveInterval = '200';
262
+		}
263
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
264
+			$globalMap3DAircraftsLimit = '300';
265
+		}
249 266
 		if ($globalDBdriver == 'mysql') {
250 267
 			if (isset($globalArchive) && $globalArchive === TRUE) {
251 268
 				/*
@@ -256,25 +273,41 @@  discard block
 block discarded – undo
256 273
 				*/
257 274
 				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
258 275
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id ";
259
-				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
260
-				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
276
+				if ($usecoord) {
277
+					$query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
278
+				}
279
+				if ($id != '') {
280
+					$query .= "OR spotter_archive.flightaware_id = :id ";
281
+				}
261 282
 				$query .= "UNION
262 283
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
263 284
 				FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
264
-				if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
265
-				if ($id != '') $query .= " OR spotter_live.flightaware_id = :id";
285
+				if ($usecoord) {
286
+					$query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
287
+				}
288
+				if ($id != '') {
289
+					$query .= " OR spotter_live.flightaware_id = :id";
290
+				}
266 291
 				$query .= ") AS spotter 
267 292
 				WHERE latitude <> '0' AND longitude <> '0' 
268 293
 				ORDER BY flightaware_id, date";
269
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
294
+				if ($limit) {
295
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
296
+				}
270 297
 			} else {
271 298
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
272 299
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
273
-				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
274
-				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
300
+				if ($usecoord) {
301
+					$query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
302
+				}
303
+				if ($id != '') {
304
+					$query .= "OR spotter_live.flightaware_id = :id ";
305
+				}
275 306
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
276 307
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
277
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
308
+				if ($limit) {
309
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
310
+				}
278 311
 			}
279 312
 		} else {
280 313
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -286,28 +319,46 @@  discard block
 block discarded – undo
286 319
                                */
287 320
 				$query  = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
288 321
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id ";
289
-				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
290
-				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
322
+				if ($usecoord) {
323
+					$query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
324
+				}
325
+				if ($id != '') {
326
+					$query .= "OR spotter_archive.flightaware_id = :id ";
327
+				}
291 328
 				$query .= "UNION
292 329
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
293 330
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
294
-				if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
295
-				if ($id != '') $query .= " OR spotter_live.flightaware_id = :id";
331
+				if ($usecoord) {
332
+					$query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
333
+				}
334
+				if ($id != '') {
335
+					$query .= " OR spotter_live.flightaware_id = :id";
336
+				}
296 337
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
297 338
 				$query .= "ORDER BY flightaware_id, date";
298
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
339
+				if ($limit) {
340
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
341
+				}
299 342
 			} else {
300 343
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
301 344
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date ";
302
-				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
303
-				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
345
+				if ($usecoord) {
346
+					$query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
347
+				}
348
+				if ($id != '') {
349
+					$query .= "OR spotter_live.flightaware_id = :id ";
350
+				}
304 351
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
305 352
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
306
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
353
+				if ($limit) {
354
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
355
+				}
307 356
 			}
308 357
 		}
309 358
 		$query_values = array();
310
-		if ($id != '') $query_values = array(':id' => $id);
359
+		if ($id != '') {
360
+			$query_values = array(':id' => $id);
361
+		}
311 362
 		try {
312 363
 			$sth = $this->db->prepare($query);
313 364
 			$sth->execute($query_values);
@@ -330,7 +381,9 @@  discard block
 block discarded – undo
330 381
 		global $globalDBdriver, $globalLiveInterval;
331 382
 		$filter_query = $this->getFilter($filter,true,true);
332 383
 
333
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
+		if (!isset($globalLiveInterval)) {
385
+			$globalLiveInterval = '200';
386
+		}
334 387
 		if ($globalDBdriver == 'mysql') {
335 388
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
336 389
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -360,7 +413,9 @@  discard block
 block discarded – undo
360 413
 	{
361 414
 		global $globalDBdriver, $globalLiveInterval;
362 415
 		$Spotter = new Spotter($this->db);
363
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
416
+		if (!isset($globalLiveInterval)) {
417
+			$globalLiveInterval = '200';
418
+		}
364 419
 		$filter_query = $this->getFilter($filter);
365 420
 
366 421
 		if (is_array($coord)) {
@@ -368,7 +423,9 @@  discard block
 block discarded – undo
368 423
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
369 424
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
370 425
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
371
-		} else return array();
426
+		} else {
427
+			return array();
428
+		}
372 429
 		if ($globalDBdriver == 'mysql') {
373 430
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
374 431
 		} else {
@@ -389,7 +446,9 @@  discard block
 block discarded – undo
389 446
 	{
390 447
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
391 448
 		$Spotter = new Spotter($this->db);
392
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
449
+		if (!isset($globalLiveInterval)) {
450
+			$globalLiveInterval = '200';
451
+		}
393 452
 		$filter_query = $this->getFilter($filter,true,true);
394 453
 
395 454
 		if (is_array($coord)) {
@@ -397,7 +456,9 @@  discard block
 block discarded – undo
397 456
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
398 457
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
399 458
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
400
-		} else return array();
459
+		} else {
460
+			return array();
461
+		}
401 462
 		if ($globalDBdriver == 'mysql') {
402 463
 			if (isset($globalArchive) && $globalArchive === TRUE) {
403 464
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -624,11 +685,15 @@  discard block
 block discarded – undo
624 685
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
625 686
 		if ($globalDBdriver == 'mysql') {
626 687
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
627
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
688
+			if ($liveinterval) {
689
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
690
+			}
628 691
 			$query .= ' ORDER BY date';
629 692
 		} else {
630 693
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
631
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
694
+			if ($liveinterval) {
695
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
696
+			}
632 697
 			$query .= ' ORDER BY date';
633 698
 		}
634 699
 
@@ -723,7 +788,9 @@  discard block
 block discarded – undo
723 788
 				$i++;
724 789
 				$j++;
725 790
 				if ($j == 30) {
726
-					if ($globalDebug) echo ".";
791
+					if ($globalDebug) {
792
+						echo ".";
793
+					}
727 794
 				    	try {
728 795
 						
729 796
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -1076,7 +1143,9 @@  discard block
 block discarded – undo
1076 1143
 			{
1077 1144
 				return false;
1078 1145
 			}
1079
-		} else return '';
1146
+		} else {
1147
+			return '';
1148
+		}
1080 1149
 
1081 1150
 		if ($longitude != '')
1082 1151
 		{
@@ -1084,7 +1153,9 @@  discard block
 block discarded – undo
1084 1153
 			{
1085 1154
 				return false;
1086 1155
 			}
1087
-		} else return '';
1156
+		} else {
1157
+			return '';
1158
+		}
1088 1159
 
1089 1160
 		if ($waypoints != '')
1090 1161
 		{
@@ -1100,14 +1171,18 @@  discard block
 block discarded – undo
1100 1171
 			{
1101 1172
 				return false;
1102 1173
 			}
1103
-		} else $altitude = 0;
1174
+		} else {
1175
+			$altitude = 0;
1176
+		}
1104 1177
 		if ($altitude_real != '')
1105 1178
 		{
1106 1179
 			if (!is_numeric($altitude_real))
1107 1180
 			{
1108 1181
 				return false;
1109 1182
 			}
1110
-		} else $altitude_real = 0;
1183
+		} else {
1184
+			$altitude_real = 0;
1185
+		}
1111 1186
 
1112 1187
 		if ($heading != '')
1113 1188
 		{
@@ -1115,7 +1190,9 @@  discard block
 block discarded – undo
1115 1190
 			{
1116 1191
 				return false;
1117 1192
 			}
1118
-		} else $heading = 0;
1193
+		} else {
1194
+			$heading = 0;
1195
+		}
1119 1196
 
1120 1197
 		if ($groundspeed != '')
1121 1198
 		{
@@ -1123,9 +1200,13 @@  discard block
 block discarded – undo
1123 1200
 			{
1124 1201
 				return false;
1125 1202
 			}
1126
-		} else $groundspeed = 0;
1203
+		} else {
1204
+			$groundspeed = 0;
1205
+		}
1127 1206
 		date_default_timezone_set('UTC');
1128
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1207
+		if ($date == '') {
1208
+			$date = date("Y-m-d H:i:s", time());
1209
+		}
1129 1210
 
1130 1211
         
1131 1212
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1170,14 +1251,24 @@  discard block
 block discarded – undo
1170 1251
 		$arrival_airport_country = '';
1171 1252
 		
1172 1253
             	
1173
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1174
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1175
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1176
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1254
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1255
+            		$squawk = NULL;
1256
+            	}
1257
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1258
+            		$verticalrate = NULL;
1259
+            	}
1260
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1261
+            		$groundspeed = 0;
1262
+            	}
1263
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1264
+            		$heading = 0;
1265
+            	}
1177 1266
 		
1178 1267
 		$query = '';
1179 1268
 		if ($globalArchive) {
1180
-			if ($globalDebug) echo '-- Delete previous data -- ';
1269
+			if ($globalDebug) {
1270
+				echo '-- Delete previous data -- ';
1271
+			}
1181 1272
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1182 1273
 		}
1183 1274
 
@@ -1194,10 +1285,14 @@  discard block
 block discarded – undo
1194 1285
 			return "error : ".$e->getMessage();
1195 1286
 		}
1196 1287
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1197
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1288
+		    if ($globalDebug) {
1289
+		    	echo '(Add to SBS archive : ';
1290
+		    }
1198 1291
 		    $SpotterArchive = new SpotterArchive($this->db);
1199 1292
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1200
-		    if ($globalDebug) echo $result.')';
1293
+		    if ($globalDebug) {
1294
+		    	echo $result.')';
1295
+		    }
1201 1296
 		} elseif ($globalDebug && $putinarchive !== true) {
1202 1297
 			echo '(Not adding to archive)';
1203 1298
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
js/map.3d.js.php 1 patch
Braces   +47 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,21 +5,30 @@  discard block
 block discarded – undo
5 5
 
6 6
 document.cookie =  'MapFormat=3d; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
7 7
 <?php
8
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
9
-	else $MapType = $globalMapProvider;
10
-//	unset($_COOKIE['MapType']);
8
+	if (isset($_COOKIE['MapType'])) {
9
+		$MapType = $_COOKIE['MapType'];
10
+	} else {
11
+		$MapType = $globalMapProvider;
12
+	}
13
+	//	unset($_COOKIE['MapType']);
11 14
 
12 15
 	if ($MapType != 'Mapbox' && $MapType != 'OpenStreetMap' && $MapType != 'Bing-Aerial' && $MapType != 'Bing-Hybrid' && $MapType != 'Bing-Road' && $MapType != 'offline' && $MapType != 'ArcGIS-Streetmap' && $MapType != 'ArcGIS-Satellite' && $MapType != 'NatGeo-Street') {
13
-		if (isset($globalBingMapKey) && $globalBingMapKey != '') $MapType = 'Bing-Aerial';
14
-		else $MapType = 'OpenStreetMap';
16
+		if (isset($globalBingMapKey) && $globalBingMapKey != '') {
17
+			$MapType = 'Bing-Aerial';
18
+		} else {
19
+			$MapType = 'OpenStreetMap';
20
+		}
15 21
 	}
16 22
 	if (($MapType == 'Bing-Aerial' || $MapType == 'Bing-Hybrid' || $MapType == 'Bing-Road') && (!isset($globalBingMapKey) || $globalBingMapKey == '')) {
17 23
 		$MapType = 'OpenStreetMap';
18 24
 	}
19 25
 	if ($MapType == 'Mapbox') {
20
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
21
-		else $MapBoxId = $_COOKIE['MapTypeId'];
22
-?>
26
+		if ($_COOKIE['MapTypeId'] == 'default') {
27
+			$MapBoxId = $globalMapboxId;
28
+		} else {
29
+			$MapBoxId = $_COOKIE['MapTypeId'];
30
+		}
31
+		?>
23 32
 	var imProv = Cesium.MapboxImageryProvider({
24 33
 		credit: 'Map data © OpenStreetMap contributors, ' +
25 34
 	      'CC-BY-SA, ' +
@@ -86,13 +95,23 @@  discard block
 block discarded – undo
86 95
 		credit : 'Imagery courtesy Natural Earth'
87 96
 	});
88 97
 <?php
89
-	}  elseif (isset($globalMapCustomLayer[$MapType])) {
98
+	} elseif (isset($globalMapCustomLayer[$MapType])) {
90 99
 		$customid = $MapType;
91 100
 ?>
92 101
 	var imProv = Cesium.createOpenStreetMapImageryProvider({
93 102
 		url : '<?php print $globalMapCustomLayer[$customid]['url']; ?>',
94
-		maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '99'; ?>,
95
-		minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
103
+		maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
104
+	print $globalMapCustomLayer[$customid]['maxZoom'];
105
+} else {
106
+	print '99';
107
+}
108
+?>,
109
+		minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
110
+	print $globalMapCustomLayer[$customid]['minZoom'];
111
+} else {
112
+	print '0';
113
+}
114
+?>,
96 115
 		credit: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
97 116
 	});
98 117
 <?php
@@ -376,7 +395,12 @@  discard block
 block discarded – undo
376 395
 	imageryProvider : imProv,
377 396
 	timeline : archive,
378 397
 	animation : false,
379
-	shadows : <?php if ((isset($globalMap3DShadows) && $globalMap3DShadows === FALSE) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'true')) print 'false'; else print 'true'; ?>,
398
+	shadows : <?php if ((isset($globalMap3DShadows) && $globalMap3DShadows === FALSE) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'true')) {
399
+	print 'false';
400
+} else {
401
+	print 'true';
402
+}
403
+?>,
380 404
 	infoBox : false,
381 405
 	navigationHelpButton : false,
382 406
 	geocoder : false,
@@ -390,8 +414,11 @@  discard block
 block discarded – undo
390 414
 	if (isset($_COOKIE['lastcentercoord']) || (isset($globalCenterLatitude) && isset($globalCenterLongitude) && $globalCenterLatitude != '' && $globalCenterLongitude != '')) {
391 415
 		if (isset($_COOKIE['lastcentercoord'])) {
392 416
 			$lastcentercoord = explode(',',$_COOKIE['lastcentercoord']);
393
-			if (!isset($lastcentercoord[3])) $zoom = $lastcentercoord[2]*1000000.0;
394
-			else $zoom = $lastcentercoord[3];
417
+			if (!isset($lastcentercoord[3])) {
418
+				$zoom = $lastcentercoord[2]*1000000.0;
419
+			} else {
420
+				$zoom = $lastcentercoord[3];
421
+			}
395 422
 			$viewcenterlatitude = $lastcentercoord[0];
396 423
 			$viewcenterlongitude = $lastcentercoord[1];
397 424
 		} else {
@@ -473,7 +500,12 @@  discard block
 block discarded – undo
473 500
 ?>
474 501
 
475 502
 update_locationsLayer();
476
-setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
503
+setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) {
504
+	print $globalMapRefresh*1000*2;
505
+} else {
506
+	print '60000';
507
+}
508
+?>);
477 509
 viewer.camera.moveEnd.addEventListener(function() { 
478 510
 <?php
479 511
 	if (isset($globalMapUseBbox) && $globalMapUseBbox) {
Please login to merge, or discard this patch.
airspace-geojson.php 1 patch
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -68,12 +68,22 @@
 block discarded – undo
68 68
 		} else {
69 69
 			$geom = geoPHP::load(stream_get_contents($row['wkb']));
70 70
 		}
71
-		if (isset($properties['type'])) $properties['type'] = trim($properties['type']);
72
-		elseif (isset($properties['class'])) $properties['type'] = trim($properties['class']);
73
-		if (isset($properties['ogr_fid'])) $properties['id'] = $properties['ogr_fid'];
74
-		elseif (isset($properties['ogc_fid'])) $properties['id'] = $properties['ogc_fid'];
75
-		if (isset($properties['ceiling'])) $properties['tops'] = $properties['ceiling'];
76
-		if (isset($properties['floor'])) $properties['base'] = $properties['floor'];
71
+		if (isset($properties['type'])) {
72
+			$properties['type'] = trim($properties['type']);
73
+		} elseif (isset($properties['class'])) {
74
+			$properties['type'] = trim($properties['class']);
75
+		}
76
+		if (isset($properties['ogr_fid'])) {
77
+			$properties['id'] = $properties['ogr_fid'];
78
+		} elseif (isset($properties['ogc_fid'])) {
79
+			$properties['id'] = $properties['ogc_fid'];
80
+		}
81
+		if (isset($properties['ceiling'])) {
82
+			$properties['tops'] = $properties['ceiling'];
83
+		}
84
+		if (isset($properties['floor'])) {
85
+			$properties['base'] = $properties['floor'];
86
+		}
77 87
 		if (isset($properties['tops'])) {
78 88
 			if (preg_match('/^FL(\s)*(?<alt>\d+)/',strtoupper($properties['tops']),$matches)) {
79 89
 				$properties['upper_limit'] = round($matches['alt']*100*0.38048);
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +407 added lines, -145 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54 54
 		} catch(Exception $e) {
55
-			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
55
+			if ($globalDebug) {
56
+				echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
57
+			}
56 58
 			$GeoidClass = FALSE;
57 59
 		}
58 60
 	}
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 	$dbc = $this->db;
72 74
 	$this->all_flights[$id]['schedule_check'] = true;
73 75
 	if ($globalSchedulesFetch) {
74
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
76
+	if ($globalDebug) {
77
+		echo 'Getting schedule info...'."\n";
78
+	}
75 79
 	$Spotter = new Spotter($dbc);
76 80
 	$Schedule = new Schedule($dbc);
77 81
 	$Translation = new Translation($dbc);
@@ -82,7 +86,9 @@  discard block
 block discarded – undo
82 86
 	    if ($Schedule->checkSchedule($operator) == 0) {
83 87
 		$schedule = $Schedule->fetchSchedule($operator);
84 88
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
89
+		    if ($globalDebug) {
90
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
91
+		    }
86 92
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87 93
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88 94
 		    // Should also check if route schedule = route from DB
@@ -91,7 +97,9 @@  discard block
 block discarded – undo
91 97
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92 98
 			    if (trim($airport_icao) != '') {
93 99
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
100
+				if ($globalDebug) {
101
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
102
+				}
95 103
 			    }
96 104
 			}
97 105
 		    }
@@ -100,20 +108,30 @@  discard block
 block discarded – undo
100 108
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101 109
 			    if (trim($airport_icao) != '') {
102 110
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
111
+				if ($globalDebug) {
112
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
113
+				}
104 114
 			    }
105 115
 			}
106 116
 		    }
107 117
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
108 118
 		}
109
-	    } else $scheduleexist = true;
110
-	} else $scheduleexist = true;
119
+	    } else {
120
+	    	$scheduleexist = true;
121
+	    }
122
+	} else {
123
+		$scheduleexist = true;
124
+	}
111 125
 	// close connection, at least one way will work ?
112 126
        if ($scheduleexist) {
113
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
127
+		if ($globalDebug) {
128
+			echo "-> get arrival/departure airport info for ".$ident."\n";
129
+		}
114 130
     		$sch = $Schedule->getSchedule($operator);
115 131
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
132
+		if ($this->all_flights[$id]['addedSpotter'] == 1) {
133
+			$Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
134
+		}
117 135
        }
118 136
 	$Spotter->db = null;
119 137
 	$Schedule->db = null;
@@ -133,14 +151,18 @@  discard block
 block discarded – undo
133 151
 
134 152
     public function checkAll() {
135 153
 	global $globalDebug, $globalNoImport;
136
-	if ($globalDebug) echo "Update last seen flights data...\n";
154
+	if ($globalDebug) {
155
+		echo "Update last seen flights data...\n";
156
+	}
137 157
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
138 158
 	    foreach ($this->all_flights as $key => $flight) {
139 159
 		if (isset($this->all_flights[$key]['id'])) {
140 160
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141 161
     		    $Spotter = new Spotter($this->db);
142 162
         	    $real_arrival = $this->arrival($key);
143
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
163
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) {
164
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
165
+        	    }
144 166
         	}
145 167
 	    }
146 168
 	}
@@ -148,24 +170,32 @@  discard block
 block discarded – undo
148 170
 
149 171
     public function arrival($key) {
150 172
 	global $globalClosestMinDist, $globalDebug;
151
-	if ($globalDebug) echo 'Update arrival...'."\n";
173
+	if ($globalDebug) {
174
+		echo 'Update arrival...'."\n";
175
+	}
152 176
 	$Spotter = new Spotter($this->db);
153 177
         $airport_icao = '';
154 178
         $airport_time = '';
155
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
179
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
180
+        	$globalClosestMinDist = 50;
181
+        }
156 182
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157 183
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
158 184
     	    if (isset($closestAirports[0])) {
159 185
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160 186
         	    $airport_icao = $closestAirports[0]['icao'];
161 187
         	    $airport_time = $this->all_flights[$key]['datetime'];
162
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
188
+        	    if ($globalDebug) {
189
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
190
+        	    }
163 191
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
164 192
         	    foreach ($closestAirports as $airport) {
165 193
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
166 194
         		    $airport_icao = $airport['icao'];
167 195
         		    $airport_time = $this->all_flights[$key]['datetime'];
168
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
196
+        		    if ($globalDebug) {
197
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
198
+        		    }
169 199
         		    break;
170 200
         		}
171 201
         	    }
@@ -173,14 +203,20 @@  discard block
 block discarded – undo
173 203
         		$airport_icao = $closestAirports[0]['icao'];
174 204
         		$airport_time = $this->all_flights[$key]['datetime'];
175 205
         	} else {
176
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
206
+        		if ($globalDebug) {
207
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
208
+        		}
177 209
         	}
178 210
     	    } else {
179
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
211
+    		    if ($globalDebug) {
212
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
213
+    		    }
180 214
     	    }
181 215
 
182 216
         } else {
183
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
217
+        	if ($globalDebug) {
218
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
219
+        	}
184 220
         }
185 221
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
186 222
     }
@@ -190,7 +226,9 @@  discard block
 block discarded – undo
190 226
     public function del() {
191 227
 	global $globalDebug, $globalNoImport, $globalNoDB;
192 228
 	// Delete old infos
193
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
229
+	if ($globalDebug) {
230
+		echo 'Delete old values and update latest data...'."\n";
231
+	}
194 232
 	foreach ($this->all_flights as $key => $flight) {
195 233
 	    if (isset($flight['lastupdate'])) {
196 234
 		if ($flight['lastupdate'] < (time()-1800)) {
@@ -204,17 +242,23 @@  discard block
 block discarded – undo
204 242
 	global $globalDebug, $globalNoImport, $globalNoDB;
205 243
 	// Delete old infos
206 244
 	if (isset($this->all_flights[$key]['id'])) {
207
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
245
+		if ($globalDebug) {
246
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
247
+		}
208 248
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
209 249
 			$real_arrival = $this->arrival($key);
210 250
 			$Spotter = new Spotter($this->db);
211 251
 			$SpotterLive = new SpotterLive($this->db);
212 252
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
213 253
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
214
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
254
+				if ($globalDebug && $result != 'success') {
255
+					echo '!!! ERROR : '.$result."\n";
256
+				}
215 257
 				$this->all_flights[$key]['putinarchive'] = true;
216 258
 				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']);
217
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
259
+				if ($globalDebug && $result != 'success') {
260
+					echo '!!! ERROR : '.$result."\n";
261
+				}
218 262
 			}
219 263
 			$Spotter->db = null;
220 264
 			$SpotterLive->db = null;
@@ -226,9 +270,13 @@  discard block
 block discarded – undo
226 270
     public function add($line) {
227 271
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
228 272
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
229
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
230
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
231
-/*
273
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
274
+		$globalCoordMinChange = '0.01';
275
+	}
276
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
277
+		$globalAircraftMaxUpdate = 3000;
278
+	}
279
+	/*
232 280
 	$Spotter = new Spotter();
233 281
 	$dbc = $Spotter->db;
234 282
 	$SpotterLive = new SpotterLive($dbc);
@@ -250,19 +298,28 @@  discard block
 block discarded – undo
250 298
 	// SBS format is CSV format
251 299
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
252 300
 	    //print_r($line);
253
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
301
+	    if (isset($line['hex'])) {
302
+	    	$line['hex'] = strtoupper($line['hex']);
303
+	    }
254 304
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
255 305
 
256 306
 		// Increment message number
257 307
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
258 308
 		    $current_date = date('Y-m-d');
259
-		    if (isset($line['source_name'])) $source = $line['source_name'];
260
-		    else $source = '';
261
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
309
+		    if (isset($line['source_name'])) {
310
+		    	$source = $line['source_name'];
311
+		    } else {
312
+		    	$source = '';
313
+		    }
314
+		    if ($source == '' || $line['format_source'] == 'aprs') {
315
+		    	$source = $line['format_source'];
316
+		    }
262 317
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
263 318
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
264 319
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
265
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
320
+		    } else {
321
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
322
+		    }
266 323
 		}
267 324
 		
268 325
 		/*
@@ -278,23 +335,38 @@  discard block
 block discarded – undo
278 335
 		//$this->db = $dbc;
279 336
 
280 337
 		//$hex = trim($line['hex']);
281
-	        if (!isset($line['id'])) $id = trim($line['hex']);
282
-	        else $id = trim($line['id']);
338
+	        if (!isset($line['id'])) {
339
+	        	$id = trim($line['hex']);
340
+	        } else {
341
+	        	$id = trim($line['id']);
342
+	        }
283 343
 		
284 344
 		if (!isset($this->all_flights[$id])) {
285
-		    if ($globalDebug) echo 'New flight...'."\n";
345
+		    if ($globalDebug) {
346
+		    	echo 'New flight...'."\n";
347
+		    }
286 348
 		    $this->all_flights[$id] = array();
287 349
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
288 350
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
289
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
351
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
352
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
353
+		    }
290 354
 		    if (!isset($line['id'])) {
291
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
292
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
355
+			if (!isset($globalDaemon)) {
356
+				$globalDaemon = TRUE;
357
+			}
358
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
293 359
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
294
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
360
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
361
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
362
+			}
295 363
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
296
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
297
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
364
+		     } else {
365
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
366
+		     }
367
+		    if ($globalAllFlights !== FALSE) {
368
+		    	$dataFound = true;
369
+		    }
298 370
 		}
299 371
 		if (isset($line['source_type']) && $line['source_type'] != '') {
300 372
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -316,12 +388,20 @@  discard block
 block discarded – undo
316 388
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
317 389
 			    }
318 390
 			    $Spotter->db = null;
319
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
320
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
391
+			    if ($globalDebugTimeElapsed) {
392
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
393
+			    }
394
+			    if ($aircraft_icao != '') {
395
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
396
+			    }
321 397
 			}
322 398
 		    }
323
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
324
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
399
+		    if ($globalAllFlights !== FALSE) {
400
+		    	$dataFound = true;
401
+		    }
402
+		    if ($globalDebug) {
403
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
404
+		    }
325 405
 		}
326 406
 	        if (isset($line['id']) && !isset($line['hex'])) {
327 407
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -330,7 +410,9 @@  discard block
 block discarded – undo
330 410
 			$icao = $line['aircraft_icao'];
331 411
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
332 412
 				$Spotter = new Spotter($this->db);
333
-				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
413
+				if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
414
+					$icao = $Spotter->aircraft_correct_icaotype[$icao];
415
+				}
334 416
 				$Spotter->db = null;
335 417
 			}
336 418
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
@@ -340,15 +422,24 @@  discard block
 block discarded – undo
340 422
 				$Spotter = new Spotter($this->db);
341 423
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
342 424
 				$Spotter->db = null;
343
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
425
+				if ($aircraft_icao != '') {
426
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
427
+				}
344 428
 			}
345 429
 		}
346 430
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
347
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
348
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
349
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
350
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
351
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
431
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
432
+				$aircraft_icao = 'GLID';
433
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
434
+				$aircraft_icao = 'UHEL';
435
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
436
+				$aircraft_icao = 'TOWPLANE';
437
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
438
+				$aircraft_icao = 'POWAIRC';
439
+			}
440
+			if (isset($aircraft_icao)) {
441
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
442
+			}
352 443
 		}
353 444
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
354 445
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -358,8 +449,11 @@  discard block
 block discarded – undo
358 449
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
359 450
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
360 451
 		    } else {
361
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
362
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
452
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
453
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
454
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
455
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
456
+				}
363 457
 				/*
364 458
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
365 459
 				print_r($this->all_flights[$id]);
@@ -368,16 +462,22 @@  discard block
 block discarded – undo
368 462
 				return '';
369 463
 		    }
370 464
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
371
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
465
+			if ($globalDebug) {
466
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
467
+			}
372 468
 			return '';
373 469
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
374
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
470
+			if ($globalDebug) {
471
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
472
+			}
375 473
 			return '';
376 474
 		} elseif (!isset($line['datetime'])) {
377 475
 			date_default_timezone_set('UTC');
378 476
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
379 477
 		} else {
380
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
478
+			if ($globalDebug) {
479
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
480
+			}
381 481
 			return '';
382 482
 		}
383 483
 
@@ -398,30 +498,48 @@  discard block
 block discarded – undo
398 498
 
399 499
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
400 500
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
401
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
501
+				if ($globalDebug) {
502
+					echo '---!!!! New ident, reset aircraft data...'."\n";
503
+				}
402 504
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
403 505
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
404
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
405
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
406
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
506
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
507
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
508
+				} elseif (isset($line['id'])) {
509
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
510
+				} elseif (isset($this->all_flights[$id]['ident'])) {
511
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
512
+				}
407 513
 			} else {
408 514
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
409 515
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
410 516
 				$timeelapsed = microtime(true);
411 517
             			$Spotter = new Spotter($this->db);
412 518
             			$fromsource = NULL;
413
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
414
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
415
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
416
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
417
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
519
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
520
+            				$fromsource = $globalAirlinesSource;
521
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
522
+            				$fromsource = 'vatsim';
523
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
524
+					$fromsource = 'ivao';
525
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
526
+					$fromsource = 'vatsim';
527
+				} elseif (isset($globalIVAO) && $globalIVAO) {
528
+					$fromsource = 'ivao';
529
+				}
418 530
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
419
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
531
+				if ($globalDebug && $result != 'success') {
532
+					echo '!!! ERROR : '.$result."\n";
533
+				}
420 534
 				$Spotter->db = null;
421
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
535
+				if ($globalDebugTimeElapsed) {
536
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
537
+				}
422 538
 			    }
423 539
 			}
424
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
540
+		    } else {
541
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
542
+		    }
425 543
 		    
426 544
 /*
427 545
 		    if (!isset($line['id'])) {
@@ -431,7 +549,9 @@  discard block
 block discarded – undo
431 549
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
432 550
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
433 551
   */
434
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
552
+		    if (!isset($this->all_flights[$id]['id'])) {
553
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
554
+		    }
435 555
 
436 556
 		    //$putinarchive = true;
437 557
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -449,7 +569,9 @@  discard block
 block discarded – undo
449 569
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
450 570
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
451 571
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
452
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
572
+				if ($globalDebugTimeElapsed) {
573
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
574
+				}
453 575
                         }
454 576
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
455 577
 			$timeelapsed = microtime(true);
@@ -463,7 +585,9 @@  discard block
 block discarded – undo
463 585
 				$Translation->db = null;
464 586
 			    }
465 587
 			    $Spotter->db = null;
466
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
588
+			    if ($globalDebugTimeElapsed) {
589
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
590
+			    }
467 591
                     	}
468 592
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
469 593
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -472,9 +596,13 @@  discard block
 block discarded – undo
472 596
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
473 597
 		    	    }
474 598
 			}
475
-			if (!isset($globalFork)) $globalFork = TRUE;
599
+			if (!isset($globalFork)) {
600
+				$globalFork = TRUE;
601
+			}
476 602
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
477
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
603
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
604
+					$this->get_Schedule($id,trim($line['ident']));
605
+				}
478 606
 			}
479 607
 		    }
480 608
 		}
@@ -492,9 +620,13 @@  discard block
 block discarded – undo
492 620
 			$speed = $speed*3.6;
493 621
 			if ($speed < 1000) {
494 622
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
495
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
623
+	  			if ($globalDebug) {
624
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
625
+	  			}
496 626
 	  		} else {
497
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
627
+	  			if ($globalDebug) {
628
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
629
+	  			}
498 630
 	  		}
499 631
 		    }
500 632
 		}
@@ -503,13 +635,21 @@  discard block
 block discarded – undo
503 635
 
504 636
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
505 637
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
506
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
638
+	    	    	if ($globalDebug) {
639
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
640
+	    	    	}
507 641
 	    	    	return false;
508 642
 	    	    }
509
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
510
-	    	    else unset($timediff);
511
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
512
-	    	    else unset($timediff_archive);
643
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
644
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
645
+	    	    } else {
646
+	    	    	unset($timediff);
647
+	    	    }
648
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
649
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
650
+	    	    } else {
651
+	    	    	unset($timediff_archive);
652
+	    	    }
513 653
 	    	    if ($this->tmd > 5
514 654
 	    	        || (isset($line['format_source']) 
515 655
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -546,16 +686,25 @@  discard block
 block discarded – undo
546 686
 				$this->all_flights[$id]['putinarchive'] = true;
547 687
 				$this->tmd = 0;
548 688
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
549
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
689
+				    if ($globalDebug) {
690
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
691
+				    }
550 692
 				    $timeelapsed = microtime(true);
551 693
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
552 694
 					$Spotter = new Spotter($this->db);
553 695
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
554
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
555
-					else $this->all_flights[$id]['over_country'] = '';
696
+					if (!empty($all_country)) {
697
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
698
+					} else {
699
+						$this->all_flights[$id]['over_country'] = '';
700
+					}
556 701
 					$Spotter->db = null;
557
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
558
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
702
+					if ($globalDebugTimeElapsed) {
703
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
704
+					}
705
+					if ($globalDebug) {
706
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
707
+					}
559 708
 				    }
560 709
 				}
561 710
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -601,7 +750,9 @@  discard block
 block discarded – undo
601 750
 			    */
602 751
 			}
603 752
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
604
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
753
+			    if ($line['longitude'] > 180) {
754
+			    	$line['longitude'] = $line['longitude'] - 360;
755
+			    }
605 756
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
606 757
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
607 758
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -638,7 +789,9 @@  discard block
 block discarded – undo
638 789
 		    }
639 790
 		}
640 791
 		if (isset($line['last_update']) && $line['last_update'] != '') {
641
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
792
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
793
+		    	$dataFound = true;
794
+		    }
642 795
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
643 796
 		}
644 797
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -660,35 +813,53 @@  discard block
 block discarded – undo
660 813
 			// Here we force archive of flight because after ground it's a new one (or should be)
661 814
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
662 815
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
663
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
664
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
665
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
816
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
817
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
818
+			} elseif (isset($line['id'])) {
819
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
820
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
821
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
822
+			}
823
+		    }
824
+		    if ($line['ground'] != 1) {
825
+		    	$line['ground'] = 0;
666 826
 		    }
667
-		    if ($line['ground'] != 1) $line['ground'] = 0;
668 827
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
669 828
 		    //$dataFound = true;
670 829
 		}
671 830
 		if (isset($line['squawk']) && $line['squawk'] != '') {
672 831
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
673
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
832
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
833
+			    	$this->all_flights[$id]['putinarchive'] = true;
834
+			    }
674 835
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
675 836
 			    $highlight = '';
676
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
677
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
678
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
837
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
838
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
839
+			    }
840
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
841
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
842
+			    }
843
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
844
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
845
+			    }
679 846
 			    if ($highlight != '') {
680 847
 				$timeelapsed = microtime(true);
681 848
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
682 849
 				    $Spotter = new Spotter($this->db);
683 850
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
684 851
 				    $Spotter->db = null;
685
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
852
+				    if ($globalDebugTimeElapsed) {
853
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
854
+				    }
686 855
 				}
687 856
 				//$putinarchive = true;
688 857
 				//$highlight = '';
689 858
 			    }
690 859
 			    
691
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
860
+		    } else {
861
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
862
+		    }
692 863
 		    //$dataFound = true;
693 864
 		}
694 865
 
@@ -701,19 +872,27 @@  discard block
 block discarded – undo
701 872
 				}
702 873
 			}
703 874
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
704
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
875
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
876
+				$this->all_flights[$id]['putinarchive'] = true;
877
+			}
705 878
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
706 879
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
707 880
 			//$dataFound = true;
708 881
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
709 882
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
710 883
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
711
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
884
+				if ($globalDebug) {
885
+					echo '--- Reset because of altitude'."\n";
886
+				}
712 887
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
713 888
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
714
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
715
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
716
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
889
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
890
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
891
+				} elseif (isset($line['id'])) {
892
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
893
+				} elseif (isset($this->all_flights[$id]['ident'])) {
894
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
895
+				}
717 896
 			}
718 897
 		    }
719 898
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -724,22 +903,32 @@  discard block
 block discarded – undo
724 903
 		}
725 904
 		
726 905
 		if (isset($line['heading']) && $line['heading'] != '') {
727
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
906
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
907
+		    	$this->all_flights[$id]['putinarchive'] = true;
908
+		    }
728 909
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
729 910
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
730 911
 		    //$dataFound = true;
731 912
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
732 913
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
733 914
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
734
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
735
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
915
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
916
+		    	$this->all_flights[$id]['putinarchive'] = true;
917
+		    }
918
+  		    if ($globalDebug) {
919
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
920
+  		    }
736 921
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
737 922
   		    // If not enough messages and ACARS set heading to 0
738 923
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
739 924
   		}
740
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
741
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
742
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
925
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
926
+			$dataFound = false;
927
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
928
+			$dataFound = false;
929
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) {
930
+			$dataFound = false;
931
+		}
743 932
 
744 933
 //		print_r($this->all_flights[$id]);
745 934
 		//gets the callsign from the last hour
@@ -756,23 +945,38 @@  discard block
 block discarded – undo
756 945
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
757 946
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
758 947
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
759
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
948
+				    if ($globalDebug) {
949
+				    	echo "Check if aircraft is already in DB...";
950
+				    }
760 951
 				    $timeelapsed = microtime(true);
761 952
 				    $SpotterLive = new SpotterLive($this->db);
762 953
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
763 954
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
764
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
955
+					if ($globalDebugTimeElapsed) {
956
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
957
+					}
765 958
 				    } elseif (isset($line['id'])) {
766 959
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
767
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
960
+					if ($globalDebugTimeElapsed) {
961
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
962
+					}
768 963
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
769 964
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
770
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
771
-				    } else $recent_ident = '';
965
+					if ($globalDebugTimeElapsed) {
966
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
967
+					}
968
+				    } else {
969
+				    	$recent_ident = '';
970
+				    }
772 971
 				    $SpotterLive->db=null;
773
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
774
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
775
-				} else $recent_ident = '';
972
+				    if ($globalDebug && $recent_ident == '') {
973
+				    	echo " Not in DB.\n";
974
+				    } elseif ($globalDebug && $recent_ident != '') {
975
+				    	echo " Already in DB.\n";
976
+				    }
977
+				} else {
978
+					$recent_ident = '';
979
+				}
776 980
 			    } else {
777 981
 				$recent_ident = '';
778 982
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -780,7 +984,9 @@  discard block
 block discarded – undo
780 984
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
781 985
 			    if($recent_ident == "")
782 986
 			    {
783
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
987
+				if ($globalDebug) {
988
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
989
+				}
784 990
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
785 991
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
786 992
 				//adds the spotter data for the archive
@@ -824,31 +1030,49 @@  discard block
 block discarded – undo
824 1030
 				
825 1031
 				if (!$ignoreImport) {
826 1032
 				    $highlight = '';
827
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
828
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
829
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
830
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1033
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1034
+				    	$highlight = 'Squawk 7500 : Hijack';
1035
+				    }
1036
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1037
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1038
+				    }
1039
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1040
+				    	$highlight = 'Squawk 7700 : Emergency';
1041
+				    }
1042
+				    if (!isset($this->all_flights[$id]['id'])) {
1043
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1044
+				    }
831 1045
 				    $timeelapsed = microtime(true);
832 1046
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
833 1047
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
834 1048
 					    $Spotter = new Spotter($this->db);
835 1049
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
836 1050
 					    $Spotter->db = null;
837
-					    if ($globalDebug && isset($result)) echo $result."\n";
1051
+					    if ($globalDebug && isset($result)) {
1052
+					    	echo $result."\n";
1053
+					    }
838 1054
 					}
839 1055
 				    }
840
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1056
+				    if ($globalDebugTimeElapsed) {
1057
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1058
+				    }
841 1059
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
842 1060
 
843 1061
 				    // Add source stat in DB
844 1062
 				    $Stats = new Stats($this->db);
845 1063
 				    if (!empty($this->stats)) {
846
-					if ($globalDebug) echo 'Add source stats : ';
1064
+					if ($globalDebug) {
1065
+						echo 'Add source stats : ';
1066
+					}
847 1067
 				        foreach($this->stats as $date => $data) {
848 1068
 					    foreach($data as $source => $sourced) {
849 1069
 					        //print_r($sourced);
850
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
851
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1070
+				    	        if (isset($sourced['polar'])) {
1071
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1072
+				    	        }
1073
+				    	        if (isset($sourced['hist'])) {
1074
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1075
+				    	        }
852 1076
 				    		if (isset($sourced['msg'])) {
853 1077
 				    		    if (time() - $sourced['msg']['date'] > 10) {
854 1078
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -861,13 +1085,17 @@  discard block
 block discarded – undo
861 1085
 			    			unset($this->stats[$date]);
862 1086
 			    		    }
863 1087
 				    	}
864
-				    	if ($globalDebug) echo 'Done'."\n";
1088
+				    	if ($globalDebug) {
1089
+				    		echo 'Done'."\n";
1090
+				    	}
865 1091
 
866 1092
 				    }
867 1093
 				    $Stats->db = null;
868 1094
 				    }
869 1095
 				    $this->del();
870
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1096
+				} elseif ($globalDebug) {
1097
+					echo 'Ignore data'."\n";
1098
+				}
871 1099
 				//$ignoreImport = false;
872 1100
 				$this->all_flights[$id]['addedSpotter'] = 1;
873 1101
 				//print_r($this->all_flights[$id]);
@@ -884,7 +1112,9 @@  discard block
 block discarded – undo
884 1112
 			*/
885 1113
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
886 1114
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
887
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1115
+				    if ($globalDebug) {
1116
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1117
+				    }
888 1118
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
889 1119
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
890 1120
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -893,7 +1123,9 @@  discard block
 block discarded – undo
893 1123
 					    $SpotterLive->db=null;
894 1124
 					}
895 1125
 				    }
896
-				    if ($globalDebug) echo " Done\n";
1126
+				    if ($globalDebug) {
1127
+				    	echo " Done\n";
1128
+				    }
897 1129
 				    $this->last_delete = time();
898 1130
 				}
899 1131
 			    } else {
@@ -920,11 +1152,17 @@  discard block
 block discarded – undo
920 1152
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
921 1153
 		    if ($globalDebug) {
922 1154
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
923
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
924
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1155
+				if (isset($this->all_flights[$id]['source_name'])) {
1156
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
1157
+				} else {
1158
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1159
+				}
925 1160
 			} else {
926
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
927
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1161
+				if (isset($this->all_flights[$id]['source_name'])) {
1162
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1163
+				} else {
1164
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1165
+				}
928 1166
 			}
929 1167
 		    }
930 1168
 		    $ignoreImport = false;
@@ -970,22 +1208,30 @@  discard block
 block discarded – undo
970 1208
 
971 1209
 		    if (!$ignoreImport) {
972 1210
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
973
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1211
+				if (!isset($this->all_flights[$id]['id'])) {
1212
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1213
+				}
974 1214
 				$timeelapsed = microtime(true);
975 1215
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
976 1216
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
977
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1217
+					if ($globalDebug) {
1218
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1219
+					}
978 1220
 					$SpotterLive = new SpotterLive($this->db);
979 1221
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
980 1222
 					$SpotterLive->db = null;
981
-					if ($globalDebug) echo $result."\n";
1223
+					if ($globalDebug) {
1224
+						echo $result."\n";
1225
+					}
982 1226
 				    }
983 1227
 				}
984 1228
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
985 1229
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
986 1230
 				}
987 1231
 				$this->all_flights[$id]['putinarchive'] = false;
988
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1232
+				if ($globalDebugTimeElapsed) {
1233
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1234
+				}
989 1235
 
990 1236
 				// Put statistics in $this->stats variable
991 1237
 				//if ($line['format_source'] != 'aprs') {
@@ -993,7 +1239,9 @@  discard block
 block discarded – undo
993 1239
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
994 1240
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
995 1241
 					$source = $this->all_flights[$id]['source_name'];
996
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1242
+					if ($source == '') {
1243
+						$source = $this->all_flights[$id]['format_source'];
1244
+					}
997 1245
 					if (!isset($this->source_location[$source])) {
998 1246
 						$Location = new Source($this->db);
999 1247
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -1014,7 +1262,9 @@  discard block
 block discarded – undo
1014 1262
 					$stats_heading = round($stats_heading/22.5);
1015 1263
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1016 1264
 					$current_date = date('Y-m-d');
1017
-					if ($stats_heading == 16) $stats_heading = 0;
1265
+					if ($stats_heading == 16) {
1266
+						$stats_heading = 0;
1267
+					}
1018 1268
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1019 1269
 						for ($i=0;$i<=15;$i++) {
1020 1270
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1032,7 +1282,9 @@  discard block
 block discarded – undo
1032 1282
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1033 1283
 						    end($this->stats[$current_date][$source]['hist']);
1034 1284
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1035
-						} else $mini = 0;
1285
+						} else {
1286
+							$mini = 0;
1287
+						}
1036 1288
 						for ($i=$mini;$i<=$distance;$i+=10) {
1037 1289
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1038 1290
 						}
@@ -1044,19 +1296,27 @@  discard block
 block discarded – undo
1044 1296
 				}
1045 1297
 
1046 1298
 				$this->all_flights[$id]['lastupdate'] = time();
1047
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1299
+				if ($this->all_flights[$id]['putinarchive']) {
1300
+					$send = true;
1301
+				}
1048 1302
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1049
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1303
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1304
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1305
+			}
1050 1306
 			//$this->del();
1051 1307
 			
1052 1308
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1053 1309
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1054
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1310
+				if ($globalDebug) {
1311
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1312
+				}
1055 1313
 				$SpotterLive = new SpotterLive($this->db);
1056 1314
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1057 1315
 				$SpotterLive->db = null;
1058 1316
 				//SpotterLive->deleteLiveSpotterData();
1059
-				if ($globalDebug) echo " Done\n";
1317
+				if ($globalDebug) {
1318
+					echo " Done\n";
1319
+				}
1060 1320
 				$this->last_delete_hourly = time();
1061 1321
 			    } else {
1062 1322
 				$this->del();
@@ -1068,7 +1328,9 @@  discard block
 block discarded – undo
1068 1328
 		    //$ignoreImport = false;
1069 1329
 		}
1070 1330
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1071
-		if ($send) return $this->all_flights[$id];
1331
+		if ($send) {
1332
+			return $this->all_flights[$id];
1333
+		}
1072 1334
 	    }
1073 1335
 	}
1074 1336
     }
Please login to merge, or discard this patch.
require/class.Language.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,9 @@  discard block
 block discarded – undo
86 86
 			return $result;
87 87
 		}
88 88
 		$handle = @opendir(dirname(__FILE__).'/../locale');
89
-		if ($handle === false) return $result;
89
+		if ($handle === false) {
90
+			return $result;
91
+		}
90 92
 		while (false !== ($file = readdir($handle))) {
91 93
 			$path = dirname(__FILE__).'/../locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
92 94
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -113,7 +115,9 @@  discard block
 block discarded – undo
113 115
 		$allAvailableLanguages = array();
114 116
 		$currentLocal = setlocale(LC_ALL, 0);
115 117
 		foreach ($available as $lang) {
116
-			if (isset($this->all_languages[$lang]) && (setlocale(LC_ALL,$this->getLocale($lang)) || $lang = 'en_GB')) $allAvailableLanguages[$lang] = $this->all_languages[$lang];
118
+			if (isset($this->all_languages[$lang]) && (setlocale(LC_ALL,$this->getLocale($lang)) || $lang = 'en_GB')) {
119
+				$allAvailableLanguages[$lang] = $this->all_languages[$lang];
120
+			}
117 121
 		}
118 122
 		setlocale(LC_ALL,$currentLocal);
119 123
 		return $allAvailableLanguages;
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +507 added lines, -186 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -803,12 +855,16 @@  discard block
 block discarded – undo
803 855
 		if ($globalDBdriver == 'mysql') {
804 856
 			if (!$Connection->tableExists('tle')) {
805 857
 				$error .= create_db::import_file('../db/tle.sql');
806
-				if ($error != '') return $error;
858
+				if ($error != '') {
859
+					return $error;
860
+				}
807 861
 			}
808 862
 		} else {
809 863
 			if (!$Connection->tableExists('tle')) {
810 864
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
811
-				if ($error != '') return $error;
865
+				if ($error != '') {
866
+					return $error;
867
+				}
812 868
 			}
813 869
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
814 870
 			try {
@@ -848,7 +904,9 @@  discard block
 block discarded – undo
848 904
 		} else {
849 905
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 906
 		}
851
-		if ($error != '') return 'Import airlines.sql : '.$error;
907
+		if ($error != '') {
908
+			return 'Import airlines.sql : '.$error;
909
+		}
852 910
 		if (!$Connection->checkColumnName('airlines','forsource')) {
853 911
 			// Add forsource to airlines
854 912
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1331,20 +1389,28 @@  discard block
 block discarded – undo
1331 1389
 		}
1332 1390
 		if ($globalDBdriver == 'mysql') {
1333 1391
 			$error .= create_db::import_file('../db/airlines.sql');
1334
-			if ($error != '') return $error;
1392
+			if ($error != '') {
1393
+				return $error;
1394
+			}
1335 1395
 		} else {
1336 1396
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1337
-			if ($error != '') return $error;
1397
+			if ($error != '') {
1398
+				return $error;
1399
+			}
1338 1400
 		}
1339 1401
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1340 1402
 			include_once(dirname(__FILE__).'/class.update_db.php');
1341 1403
 			if (isset($globalVATSIM) && $globalVATSIM) {
1342 1404
 				$error .= update_db::update_vatsim();
1343
-				if ($error != '') return $error;
1405
+				if ($error != '') {
1406
+					return $error;
1407
+				}
1344 1408
 			}
1345 1409
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1346 1410
 				$error .= update_db::update_IVAO();
1347
-				if ($error != '') return $error;
1411
+				if ($error != '') {
1412
+					return $error;
1413
+				}
1348 1414
 			}
1349 1415
 		}
1350 1416
 
@@ -1607,41 +1673,65 @@  discard block
 block discarded – undo
1607 1673
 		if ($globalDBdriver == 'mysql') {
1608 1674
 			if (!$Connection->tableExists('tracker_output')) {
1609 1675
 				$error .= create_db::import_file('../db/tracker_output.sql');
1610
-				if ($error != '') return $error;
1676
+				if ($error != '') {
1677
+					return $error;
1678
+				}
1611 1679
 			}
1612 1680
 			if (!$Connection->tableExists('tracker_live')) {
1613 1681
 				$error .= create_db::import_file('../db/tracker_live.sql');
1614
-				if ($error != '') return $error;
1682
+				if ($error != '') {
1683
+					return $error;
1684
+				}
1615 1685
 			}
1616 1686
 			if (!$Connection->tableExists('marine_output')) {
1617 1687
 				$error .= create_db::import_file('../db/marine_output.sql');
1618
-				if ($error != '') return $error;
1688
+				if ($error != '') {
1689
+					return $error;
1690
+				}
1619 1691
 			}
1620 1692
 			if (!$Connection->tableExists('marine_live')) {
1621 1693
 				$error .= create_db::import_file('../db/marine_live.sql');
1622
-				if ($error != '') return $error;
1694
+				if ($error != '') {
1695
+					return $error;
1696
+				}
1623 1697
 			}
1624 1698
 			if (!$Connection->tableExists('marine_identity')) {
1625 1699
 				$error .= create_db::import_file('../db/marine_identity.sql');
1626
-				if ($error != '') return $error;
1700
+				if ($error != '') {
1701
+					return $error;
1702
+				}
1627 1703
 			}
1628 1704
 			if (!$Connection->tableExists('marine_mid')) {
1629 1705
 				$error .= create_db::import_file('../db/marine_mid.sql');
1630
-				if ($error != '') return $error;
1706
+				if ($error != '') {
1707
+					return $error;
1708
+				}
1631 1709
 			}
1632 1710
 		} else {
1633 1711
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1634
-			if ($error != '') return $error;
1712
+			if ($error != '') {
1713
+				return $error;
1714
+			}
1635 1715
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1636
-			if ($error != '') return $error;
1716
+			if ($error != '') {
1717
+				return $error;
1718
+			}
1637 1719
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1638
-			if ($error != '') return $error;
1720
+			if ($error != '') {
1721
+				return $error;
1722
+			}
1639 1723
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1640
-			if ($error != '') return $error;
1724
+			if ($error != '') {
1725
+				return $error;
1726
+			}
1641 1727
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1642
-			if ($error != '') return $error;
1728
+			if ($error != '') {
1729
+				return $error;
1730
+			}
1643 1731
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1644
-			if ($error != '') return $error;
1732
+			if ($error != '') {
1733
+				return $error;
1734
+			}
1645 1735
 		}
1646 1736
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1647 1737
 		try {
@@ -1660,39 +1750,61 @@  discard block
 block discarded – undo
1660 1750
 		if ($globalDBdriver == 'mysql') {
1661 1751
 			if (!$Connection->tableExists('marine_image')) {
1662 1752
 				$error .= create_db::import_file('../db/marine_image.sql');
1663
-				if ($error != '') return $error;
1753
+				if ($error != '') {
1754
+					return $error;
1755
+				}
1664 1756
 			}
1665 1757
 			if (!$Connection->tableExists('marine_archive')) {
1666 1758
 				$error .= create_db::import_file('../db/marine_archive.sql');
1667
-				if ($error != '') return $error;
1759
+				if ($error != '') {
1760
+					return $error;
1761
+				}
1668 1762
 			}
1669 1763
 			if (!$Connection->tableExists('marine_archive_output')) {
1670 1764
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1671
-				if ($error != '') return $error;
1765
+				if ($error != '') {
1766
+					return $error;
1767
+				}
1672 1768
 			}
1673 1769
 			if (!$Connection->tableExists('tracker_archive')) {
1674 1770
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1675
-				if ($error != '') return $error;
1771
+				if ($error != '') {
1772
+					return $error;
1773
+				}
1676 1774
 			}
1677 1775
 			if (!$Connection->tableExists('tracker_archive_output')) {
1678 1776
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1679
-				if ($error != '') return $error;
1777
+				if ($error != '') {
1778
+					return $error;
1779
+				}
1680 1780
 			}
1681 1781
 			if (!$Connection->tableExists('marine_archive_output')) {
1682 1782
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1683
-				if ($error != '') return $error;
1783
+				if ($error != '') {
1784
+					return $error;
1785
+				}
1684 1786
 			}
1685 1787
 		} else {
1686 1788
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1687
-			if ($error != '') return $error;
1789
+			if ($error != '') {
1790
+				return $error;
1791
+			}
1688 1792
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1689
-			if ($error != '') return $error;
1793
+			if ($error != '') {
1794
+				return $error;
1795
+			}
1690 1796
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1691
-			if ($error != '') return $error;
1797
+			if ($error != '') {
1798
+				return $error;
1799
+			}
1692 1800
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1693
-			if ($error != '') return $error;
1801
+			if ($error != '') {
1802
+				return $error;
1803
+			}
1694 1804
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1695
-			if ($error != '') return $error;
1805
+			if ($error != '') {
1806
+				return $error;
1807
+			}
1696 1808
 		}
1697 1809
 		if ($globalDBdriver == 'mysql') {
1698 1810
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2063,7 +2175,9 @@  discard block
 block discarded – undo
2063 2175
 		if ($globalDBdriver == 'mysql') {
2064 2176
 			if (!$Connection->tableExists('tracker_archive_output')) {
2065 2177
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2066
-				if ($error != '') return $error;
2178
+				if ($error != '') {
2179
+					return $error;
2180
+				}
2067 2181
 			}
2068 2182
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2069 2183
 		} else {
@@ -2091,14 +2205,22 @@  discard block
 block discarded – undo
2091 2205
 		$error = '';
2092 2206
 		if ($globalDBdriver == 'mysql') {
2093 2207
 			$error .= create_db::import_file('../db/airport.sql');
2094
-			if ($error != '') return $error;
2208
+			if ($error != '') {
2209
+				return $error;
2210
+			}
2095 2211
 			$error .= create_db::import_file('../db/airlines.sql');
2096
-			if ($error != '') return $error;
2212
+			if ($error != '') {
2213
+				return $error;
2214
+			}
2097 2215
 		} else {
2098 2216
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2099
-			if ($error != '') return $error;
2217
+			if ($error != '') {
2218
+				return $error;
2219
+			}
2100 2220
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2101
-			if ($error != '') return $error;
2221
+			if ($error != '') {
2222
+				return $error;
2223
+			}
2102 2224
 		}
2103 2225
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2104 2226
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2115,7 +2237,9 @@  discard block
 block discarded – undo
2115 2237
 				$error .= update_db::update_vatsim();
2116 2238
 			}
2117 2239
 		}
2118
-		if ($error != '') return $error;
2240
+		if ($error != '') {
2241
+			return $error;
2242
+		}
2119 2243
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2120 2244
 		try {
2121 2245
 			$sth = $Connection->db->prepare($query);
@@ -2133,10 +2257,14 @@  discard block
 block discarded – undo
2133 2257
 		if (!$Connection->tableExists('satellite')) {
2134 2258
 			if ($globalDBdriver == 'mysql') {
2135 2259
 				$error .= create_db::import_file('../db/satellite.sql');
2136
-				if ($error != '') return $error;
2260
+				if ($error != '') {
2261
+					return $error;
2262
+				}
2137 2263
 			} else {
2138 2264
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2139
-				if ($error != '') return $error;
2265
+				if ($error != '') {
2266
+					return $error;
2267
+				}
2140 2268
 			}
2141 2269
 		}
2142 2270
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2156,37 +2284,53 @@  discard block
 block discarded – undo
2156 2284
 		if (!$Connection->tableExists('stats_marine')) {
2157 2285
 			if ($globalDBdriver == 'mysql') {
2158 2286
 				$error .= create_db::import_file('../db/stats_marine.sql');
2159
-				if ($error != '') return $error;
2287
+				if ($error != '') {
2288
+					return $error;
2289
+				}
2160 2290
 			} else {
2161 2291
 				$error .= create_db::import_file('../db/pgsql/stats_marine.sql');
2162
-				if ($error != '') return $error;
2292
+				if ($error != '') {
2293
+					return $error;
2294
+				}
2163 2295
 			}
2164 2296
 		}
2165 2297
 		if (!$Connection->tableExists('stats_marine_country')) {
2166 2298
 			if ($globalDBdriver == 'mysql') {
2167 2299
 				$error .= create_db::import_file('../db/stats_marine_country.sql');
2168
-				if ($error != '') return $error;
2300
+				if ($error != '') {
2301
+					return $error;
2302
+				}
2169 2303
 			} else {
2170 2304
 				$error .= create_db::import_file('../db/pgsql/stats_marine_country.sql');
2171
-				if ($error != '') return $error;
2305
+				if ($error != '') {
2306
+					return $error;
2307
+				}
2172 2308
 			}
2173 2309
 		}
2174 2310
 		if (!$Connection->tableExists('stats_tracker')) {
2175 2311
 			if ($globalDBdriver == 'mysql') {
2176 2312
 				$error .= create_db::import_file('../db/stats_tracker.sql');
2177
-				if ($error != '') return $error;
2313
+				if ($error != '') {
2314
+					return $error;
2315
+				}
2178 2316
 			} else {
2179 2317
 				$error .= create_db::import_file('../db/pgsql/stats_tracker.sql');
2180
-				if ($error != '') return $error;
2318
+				if ($error != '') {
2319
+					return $error;
2320
+				}
2181 2321
 			}
2182 2322
 		}
2183 2323
 		if (!$Connection->tableExists('stats_tracker_country')) {
2184 2324
 			if ($globalDBdriver == 'mysql') {
2185 2325
 				$error .= create_db::import_file('../db/stats_tracker_country.sql');
2186
-				if ($error != '') return $error;
2326
+				if ($error != '') {
2327
+					return $error;
2328
+				}
2187 2329
 			} else {
2188 2330
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql');
2189
-				if ($error != '') return $error;
2331
+				if ($error != '') {
2332
+					return $error;
2333
+				}
2190 2334
 			}
2191 2335
 		}
2192 2336
 		$query = "UPDATE config SET value = '47' WHERE name = 'schema_version'";
@@ -2206,10 +2350,14 @@  discard block
 block discarded – undo
2206 2350
 		if (!$Connection->tableExists('stats_marine_type')) {
2207 2351
 			if ($globalDBdriver == 'mysql') {
2208 2352
 				$error .= create_db::import_file('../db/stats_marine_type.sql');
2209
-				if ($error != '') return $error;
2353
+				if ($error != '') {
2354
+					return $error;
2355
+				}
2210 2356
 			} else {
2211 2357
 				$error .= create_db::import_file('../db/pgsql/stats_marine_type.sql');
2212
-				if ($error != '') return $error;
2358
+				if ($error != '') {
2359
+					return $error;
2360
+				}
2213 2361
 			}
2214 2362
 		}
2215 2363
 		$query = "UPDATE config SET value = '48' WHERE name = 'schema_version'";
@@ -2229,10 +2377,14 @@  discard block
 block discarded – undo
2229 2377
 		if (!$Connection->tableExists('stats_tracker_type')) {
2230 2378
 			if ($globalDBdriver == 'mysql') {
2231 2379
 				$error .= create_db::import_file('../db/stats_tracker_type.sql');
2232
-				if ($error != '') return $error;
2380
+				if ($error != '') {
2381
+					return $error;
2382
+				}
2233 2383
 			} else {
2234 2384
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_type.sql');
2235
-				if ($error != '') return $error;
2385
+				if ($error != '') {
2386
+					return $error;
2387
+				}
2236 2388
 			}
2237 2389
 		}
2238 2390
 		$query = "UPDATE config SET value = '49' WHERE name = 'schema_version'";
@@ -2251,10 +2403,14 @@  discard block
 block discarded – undo
2251 2403
 		$error = '';
2252 2404
 		if ($globalDBdriver == 'mysql') {
2253 2405
 			$error .= create_db::import_file('../db/airport.sql');
2254
-			if ($error != '') return $error;
2406
+			if ($error != '') {
2407
+				return $error;
2408
+			}
2255 2409
 		} else {
2256 2410
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2257
-			if ($error != '') return $error;
2411
+			if ($error != '') {
2412
+				return $error;
2413
+			}
2258 2414
 		}
2259 2415
 		$query = "UPDATE config SET value = '50' WHERE name = 'schema_version'";
2260 2416
 		try {
@@ -2272,14 +2428,22 @@  discard block
 block discarded – undo
2272 2428
 		$error = '';
2273 2429
 		if ($globalDBdriver == 'mysql') {
2274 2430
 			$error .= create_db::import_file('../db/aircraft.sql');
2275
-			if ($error != '') return $error;
2431
+			if ($error != '') {
2432
+				return $error;
2433
+			}
2276 2434
 			$error .= create_db::import_file('../db/aircraft_block.sql');
2277
-			if ($error != '') return $error;
2435
+			if ($error != '') {
2436
+				return $error;
2437
+			}
2278 2438
 		} else {
2279 2439
 			$error .= create_db::import_file('../db/pgsql/aircraft.sql');
2280
-			if ($error != '') return $error;
2440
+			if ($error != '') {
2441
+				return $error;
2442
+			}
2281 2443
 			$error .= create_db::import_file('../db/pgsql/aircraft_block.sql');
2282
-			if ($error != '') return $error;
2444
+			if ($error != '') {
2445
+				return $error;
2446
+			}
2283 2447
 		}
2284 2448
 		$query = "UPDATE config SET value = '51' WHERE name = 'schema_version'";
2285 2449
 		try {
@@ -2301,8 +2465,11 @@  discard block
 block discarded – undo
2301 2465
 			if ($Connection->tableExists('aircraft')) {
2302 2466
 				if (!$Connection->tableExists('config')) {
2303 2467
 					$version = '1';
2304
-					if ($update) return self::update_from_1();
2305
-					else return $version;
2468
+					if ($update) {
2469
+						return self::update_from_1();
2470
+					} else {
2471
+						return $version;
2472
+					}
2306 2473
 				} else {
2307 2474
 					$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2308 2475
 					try {
@@ -2315,207 +2482,361 @@  discard block
 block discarded – undo
2315 2482
 					if ($update) {
2316 2483
 						if ($result['value'] == '2') {
2317 2484
 							$error = self::update_from_2();
2318
-							if ($error != '') return $error;
2319
-							else return self::check_version(true);
2485
+							if ($error != '') {
2486
+								return $error;
2487
+							} else {
2488
+								return self::check_version(true);
2489
+							}
2320 2490
 						} elseif ($result['value'] == '3') {
2321 2491
 							$error = self::update_from_3();
2322
-							if ($error != '') return $error;
2323
-							else return self::check_version(true);
2492
+							if ($error != '') {
2493
+								return $error;
2494
+							} else {
2495
+								return self::check_version(true);
2496
+							}
2324 2497
 						} elseif ($result['value'] == '4') {
2325 2498
 							$error = self::update_from_4();
2326
-							if ($error != '') return $error;
2327
-							else return self::check_version(true);
2499
+							if ($error != '') {
2500
+								return $error;
2501
+							} else {
2502
+								return self::check_version(true);
2503
+							}
2328 2504
 						} elseif ($result['value'] == '5') {
2329 2505
 							$error = self::update_from_5();
2330
-							if ($error != '') return $error;
2331
-							else return self::check_version(true);
2506
+							if ($error != '') {
2507
+								return $error;
2508
+							} else {
2509
+								return self::check_version(true);
2510
+							}
2332 2511
 						} elseif ($result['value'] == '6') {
2333 2512
 							$error = self::update_from_6();
2334
-							if ($error != '') return $error;
2335
-							else return self::check_version(true);
2513
+							if ($error != '') {
2514
+								return $error;
2515
+							} else {
2516
+								return self::check_version(true);
2517
+							}
2336 2518
 						} elseif ($result['value'] == '7') {
2337 2519
 							$error = self::update_from_7();
2338
-							if ($error != '') return $error;
2339
-							else return self::check_version(true);
2520
+							if ($error != '') {
2521
+								return $error;
2522
+							} else {
2523
+								return self::check_version(true);
2524
+							}
2340 2525
 						} elseif ($result['value'] == '8') {
2341 2526
 							$error = self::update_from_8();
2342
-							if ($error != '') return $error;
2343
-							else return self::check_version(true);
2527
+							if ($error != '') {
2528
+								return $error;
2529
+							} else {
2530
+								return self::check_version(true);
2531
+							}
2344 2532
 						} elseif ($result['value'] == '9') {
2345 2533
 							$error = self::update_from_9();
2346
-							if ($error != '') return $error;
2347
-							else return self::check_version(true);
2534
+							if ($error != '') {
2535
+								return $error;
2536
+							} else {
2537
+								return self::check_version(true);
2538
+							}
2348 2539
 						} elseif ($result['value'] == '10') {
2349 2540
 							$error = self::update_from_10();
2350
-							if ($error != '') return $error;
2351
-							else return self::check_version(true);
2541
+							if ($error != '') {
2542
+								return $error;
2543
+							} else {
2544
+								return self::check_version(true);
2545
+							}
2352 2546
 						} elseif ($result['value'] == '11') {
2353 2547
 							$error = self::update_from_11();
2354
-							if ($error != '') return $error;
2355
-							else return self::check_version(true);
2548
+							if ($error != '') {
2549
+								return $error;
2550
+							} else {
2551
+								return self::check_version(true);
2552
+							}
2356 2553
 						} elseif ($result['value'] == '12') {
2357 2554
 							$error = self::update_from_12();
2358
-							if ($error != '') return $error;
2359
-							else return self::check_version(true);
2555
+							if ($error != '') {
2556
+								return $error;
2557
+							} else {
2558
+								return self::check_version(true);
2559
+							}
2360 2560
 						} elseif ($result['value'] == '13') {
2361 2561
 							$error = self::update_from_13();
2362
-							if ($error != '') return $error;
2363
-							else return self::check_version(true);
2562
+							if ($error != '') {
2563
+								return $error;
2564
+							} else {
2565
+								return self::check_version(true);
2566
+							}
2364 2567
 						} elseif ($result['value'] == '14') {
2365 2568
 							$error = self::update_from_14();
2366
-							if ($error != '') return $error;
2367
-							else return self::check_version(true);
2569
+							if ($error != '') {
2570
+								return $error;
2571
+							} else {
2572
+								return self::check_version(true);
2573
+							}
2368 2574
 						} elseif ($result['value'] == '15') {
2369 2575
 							$error = self::update_from_15();
2370
-							if ($error != '') return $error;
2371
-							else return self::check_version(true);
2576
+							if ($error != '') {
2577
+								return $error;
2578
+							} else {
2579
+								return self::check_version(true);
2580
+							}
2372 2581
 						} elseif ($result['value'] == '16') {
2373 2582
 							$error = self::update_from_16();
2374
-							if ($error != '') return $error;
2375
-							else return self::check_version(true);
2583
+							if ($error != '') {
2584
+								return $error;
2585
+							} else {
2586
+								return self::check_version(true);
2587
+							}
2376 2588
 						} elseif ($result['value'] == '17') {
2377 2589
 							$error = self::update_from_17();
2378
-							if ($error != '') return $error;
2379
-							else return self::check_version(true);
2590
+							if ($error != '') {
2591
+								return $error;
2592
+							} else {
2593
+								return self::check_version(true);
2594
+							}
2380 2595
 						} elseif ($result['value'] == '18') {
2381 2596
 							$error = self::update_from_18();
2382
-							if ($error != '') return $error;
2383
-							else return self::check_version(true);
2597
+							if ($error != '') {
2598
+								return $error;
2599
+							} else {
2600
+								return self::check_version(true);
2601
+							}
2384 2602
 						} elseif ($result['value'] == '19') {
2385 2603
 							$error = self::update_from_19();
2386
-							if ($error != '') return $error;
2387
-							else return self::check_version(true);
2604
+							if ($error != '') {
2605
+								return $error;
2606
+							} else {
2607
+								return self::check_version(true);
2608
+							}
2388 2609
 						} elseif ($result['value'] == '20') {
2389 2610
 							$error = self::update_from_20();
2390
-							if ($error != '') return $error;
2391
-							else return self::check_version(true);
2611
+							if ($error != '') {
2612
+								return $error;
2613
+							} else {
2614
+								return self::check_version(true);
2615
+							}
2392 2616
 						} elseif ($result['value'] == '21') {
2393 2617
 							$error = self::update_from_21();
2394
-							if ($error != '') return $error;
2395
-							else return self::check_version(true);
2618
+							if ($error != '') {
2619
+								return $error;
2620
+							} else {
2621
+								return self::check_version(true);
2622
+							}
2396 2623
 						} elseif ($result['value'] == '22') {
2397 2624
 							$error = self::update_from_22();
2398
-							if ($error != '') return $error;
2399
-							else return self::check_version(true);
2625
+							if ($error != '') {
2626
+								return $error;
2627
+							} else {
2628
+								return self::check_version(true);
2629
+							}
2400 2630
 						} elseif ($result['value'] == '23') {
2401 2631
 							$error = self::update_from_23();
2402
-							if ($error != '') return $error;
2403
-							else return self::check_version(true);
2632
+							if ($error != '') {
2633
+								return $error;
2634
+							} else {
2635
+								return self::check_version(true);
2636
+							}
2404 2637
 						} elseif ($result['value'] == '24') {
2405 2638
 							$error = self::update_from_24();
2406
-							if ($error != '') return $error;
2407
-							else return self::check_version(true);
2639
+							if ($error != '') {
2640
+								return $error;
2641
+							} else {
2642
+								return self::check_version(true);
2643
+							}
2408 2644
 						} elseif ($result['value'] == '25') {
2409 2645
 							$error = self::update_from_25();
2410
-							if ($error != '') return $error;
2411
-							else return self::check_version(true);
2646
+							if ($error != '') {
2647
+								return $error;
2648
+							} else {
2649
+								return self::check_version(true);
2650
+							}
2412 2651
 						} elseif ($result['value'] == '26') {
2413 2652
 							$error = self::update_from_26();
2414
-							if ($error != '') return $error;
2415
-							else return self::check_version(true);
2653
+							if ($error != '') {
2654
+								return $error;
2655
+							} else {
2656
+								return self::check_version(true);
2657
+							}
2416 2658
 						} elseif ($result['value'] == '27') {
2417 2659
 							$error = self::update_from_27();
2418
-							if ($error != '') return $error;
2419
-							else return self::check_version(true);
2660
+							if ($error != '') {
2661
+								return $error;
2662
+							} else {
2663
+								return self::check_version(true);
2664
+							}
2420 2665
 						} elseif ($result['value'] == '28') {
2421 2666
 							$error = self::update_from_28();
2422
-							if ($error != '') return $error;
2423
-							else return self::check_version(true);
2667
+							if ($error != '') {
2668
+								return $error;
2669
+							} else {
2670
+								return self::check_version(true);
2671
+							}
2424 2672
 						} elseif ($result['value'] == '29') {
2425 2673
 							$error = self::update_from_29();
2426
-							if ($error != '') return $error;
2427
-							else return self::check_version(true);
2674
+							if ($error != '') {
2675
+								return $error;
2676
+							} else {
2677
+								return self::check_version(true);
2678
+							}
2428 2679
 						} elseif ($result['value'] == '30') {
2429 2680
 							$error = self::update_from_30();
2430
-							if ($error != '') return $error;
2431
-							else return self::check_version(true);
2681
+							if ($error != '') {
2682
+								return $error;
2683
+							} else {
2684
+								return self::check_version(true);
2685
+							}
2432 2686
 						} elseif ($result['value'] == '31') {
2433 2687
 							$error = self::update_from_31();
2434
-							if ($error != '') return $error;
2435
-							else return self::check_version(true);
2688
+							if ($error != '') {
2689
+								return $error;
2690
+							} else {
2691
+								return self::check_version(true);
2692
+							}
2436 2693
 						} elseif ($result['value'] == '32') {
2437 2694
 							$error = self::update_from_32();
2438
-							if ($error != '') return $error;
2439
-							else return self::check_version(true);
2695
+							if ($error != '') {
2696
+								return $error;
2697
+							} else {
2698
+								return self::check_version(true);
2699
+							}
2440 2700
 						} elseif ($result['value'] == '33') {
2441 2701
 							$error = self::update_from_33();
2442
-							if ($error != '') return $error;
2443
-							else return self::check_version(true);
2702
+							if ($error != '') {
2703
+								return $error;
2704
+							} else {
2705
+								return self::check_version(true);
2706
+							}
2444 2707
 						} elseif ($result['value'] == '34') {
2445 2708
 							$error = self::update_from_34();
2446
-							if ($error != '') return $error;
2447
-							else return self::check_version(true);
2709
+							if ($error != '') {
2710
+								return $error;
2711
+							} else {
2712
+								return self::check_version(true);
2713
+							}
2448 2714
 						} elseif ($result['value'] == '35') {
2449 2715
 							$error = self::update_from_35();
2450
-							if ($error != '') return $error;
2451
-							else return self::check_version(true);
2716
+							if ($error != '') {
2717
+								return $error;
2718
+							} else {
2719
+								return self::check_version(true);
2720
+							}
2452 2721
 						} elseif ($result['value'] == '36') {
2453 2722
 							$error = self::update_from_36();
2454
-							if ($error != '') return $error;
2455
-							else return self::check_version(true);
2723
+							if ($error != '') {
2724
+								return $error;
2725
+							} else {
2726
+								return self::check_version(true);
2727
+							}
2456 2728
 						} elseif ($result['value'] == '37') {
2457 2729
 							$error = self::update_from_37();
2458
-							if ($error != '') return $error;
2459
-							else return self::check_version(true);
2730
+							if ($error != '') {
2731
+								return $error;
2732
+							} else {
2733
+								return self::check_version(true);
2734
+							}
2460 2735
 						} elseif ($result['value'] == '38') {
2461 2736
 							$error = self::update_from_38();
2462
-							if ($error != '') return $error;
2463
-							else return self::check_version(true);
2737
+							if ($error != '') {
2738
+								return $error;
2739
+							} else {
2740
+								return self::check_version(true);
2741
+							}
2464 2742
 						} elseif ($result['value'] == '39') {
2465 2743
 							$error = self::update_from_39();
2466
-							if ($error != '') return $error;
2467
-							else return self::check_version(true);
2744
+							if ($error != '') {
2745
+								return $error;
2746
+							} else {
2747
+								return self::check_version(true);
2748
+							}
2468 2749
 						} elseif ($result['value'] == '40') {
2469 2750
 							$error = self::update_from_40();
2470
-							if ($error != '') return $error;
2471
-							else return self::check_version(true);
2751
+							if ($error != '') {
2752
+								return $error;
2753
+							} else {
2754
+								return self::check_version(true);
2755
+							}
2472 2756
 						} elseif ($result['value'] == '41') {
2473 2757
 							$error = self::update_from_41();
2474
-							if ($error != '') return $error;
2475
-							else return self::check_version(true);
2758
+							if ($error != '') {
2759
+								return $error;
2760
+							} else {
2761
+								return self::check_version(true);
2762
+							}
2476 2763
 						} elseif ($result['value'] == '42') {
2477 2764
 							$error = self::update_from_42();
2478
-							if ($error != '') return $error;
2479
-							else return self::check_version(true);
2765
+							if ($error != '') {
2766
+								return $error;
2767
+							} else {
2768
+								return self::check_version(true);
2769
+							}
2480 2770
 						} elseif ($result['value'] == '43') {
2481 2771
 							$error = self::update_from_43();
2482
-							if ($error != '') return $error;
2483
-							else return self::check_version(true);
2772
+							if ($error != '') {
2773
+								return $error;
2774
+							} else {
2775
+								return self::check_version(true);
2776
+							}
2484 2777
 						} elseif ($result['value'] == '44') {
2485 2778
 							$error = self::update_from_44();
2486
-							if ($error != '') return $error;
2487
-							else return self::check_version(true);
2779
+							if ($error != '') {
2780
+								return $error;
2781
+							} else {
2782
+								return self::check_version(true);
2783
+							}
2488 2784
 						} elseif ($result['value'] == '45') {
2489 2785
 							$error = self::update_from_45();
2490
-							if ($error != '') return $error;
2491
-							else return self::check_version(true);
2786
+							if ($error != '') {
2787
+								return $error;
2788
+							} else {
2789
+								return self::check_version(true);
2790
+							}
2492 2791
 						} elseif ($result['value'] == '46') {
2493 2792
 							$error = self::update_from_46();
2494
-							if ($error != '') return $error;
2495
-							else return self::check_version(true);
2793
+							if ($error != '') {
2794
+								return $error;
2795
+							} else {
2796
+								return self::check_version(true);
2797
+							}
2496 2798
 						} elseif ($result['value'] == '47') {
2497 2799
 							$error = self::update_from_47();
2498
-							if ($error != '') return $error;
2499
-							else return self::check_version(true);
2800
+							if ($error != '') {
2801
+								return $error;
2802
+							} else {
2803
+								return self::check_version(true);
2804
+							}
2500 2805
 						} elseif ($result['value'] == '48') {
2501 2806
 							$error = self::update_from_48();
2502
-							if ($error != '') return $error;
2503
-							else return self::check_version(true);
2807
+							if ($error != '') {
2808
+								return $error;
2809
+							} else {
2810
+								return self::check_version(true);
2811
+							}
2504 2812
 						} elseif ($result['value'] == '49') {
2505 2813
 							$error = self::update_from_49();
2506
-							if ($error != '') return $error;
2507
-							else return self::check_version(true);
2814
+							if ($error != '') {
2815
+								return $error;
2816
+							} else {
2817
+								return self::check_version(true);
2818
+							}
2508 2819
 						} elseif ($result['value'] == '50') {
2509 2820
 							$error = self::update_from_50();
2510
-							if ($error != '') return $error;
2511
-							else return self::check_version(true);
2512
-						} else return '';
2821
+							if ($error != '') {
2822
+								return $error;
2823
+							} else {
2824
+								return self::check_version(true);
2825
+							}
2826
+						} else {
2827
+							return '';
2828
+						}
2513 2829
 					} else {
2514
-						if (isset($result['value']) && $result['value'] != '') return $result['value'];
2515
-						else return 0;
2830
+						if (isset($result['value']) && $result['value'] != '') {
2831
+							return $result['value'];
2832
+						} else {
2833
+							return 0;
2834
+						}
2516 2835
 					}
2517 2836
 				}
2518
-			} else return $version;
2837
+			} else {
2838
+				return $version;
2839
+			}
2519 2840
 		}
2520 2841
 	}
2521 2842
 }
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +599 added lines, -161 removed lines patch added patch discarded remove patch
@@ -4,11 +4,19 @@  discard block
 block discarded – undo
4 4
 if (isset($_SESSION['error'])) {
5 5
 	header('Content-Encoding: none;');
6 6
 	echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.';
7
-	if (isset($_SESSION['error'])) unset($_SESSION['error']);
8
-	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
9
-	if (isset($_SESSION['next'])) unset($_SESSION['next']);
10
-	if (isset($_SESSION['install'])) unset($_SESSION['install']);
11
-}
7
+	if (isset($_SESSION['error'])) {
8
+		unset($_SESSION['error']);
9
+	}
10
+	if (isset($_SESSION['errorlst'])) {
11
+		unset($_SESSION['errorlst']);
12
+	}
13
+	if (isset($_SESSION['next'])) {
14
+		unset($_SESSION['next']);
15
+	}
16
+	if (isset($_SESSION['install'])) {
17
+		unset($_SESSION['install']);
18
+	}
19
+	}
12 20
 /*
13 21
 if (isset($_SESSION['errorlst'])) {
14 22
 	header('Content-Encoding: none;');
@@ -114,7 +122,9 @@  discard block
 block discarded – undo
114 122
 		if (count($alllng) != count($availablelng)) {
115 123
 			$notavailable = array();
116 124
 			foreach($alllng as $lng) {
117
-				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
125
+				if (!isset($availablelng[$lng])) {
126
+					$notavailable[] = $lng;
127
+				}
118 128
 			}
119 129
 			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
120 130
 		}
@@ -175,31 +185,49 @@  discard block
 block discarded – undo
175 185
 			</div>
176 186
 			<p>
177 187
 				<label for="dbhost">Database hostname</label>
178
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
188
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
189
+	print $globalDBhost;
190
+}
191
+?>" />
179 192
 			</p>
180 193
 			<p>
181 194
 				<label for="dbport">Database port</label>
182
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
195
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
196
+	print $globalDBport;
197
+}
198
+?>" />
183 199
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
184 200
 			</p>
185 201
 			<p>
186 202
 				<label for="dbname">Database name</label>
187
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
203
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
204
+	print $globalDBname;
205
+}
206
+?>" />
188 207
 			</p>
189 208
 			<p>
190 209
 				<label for="dbuser">Database user</label>
191
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
210
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
211
+	print $globalDBuser;
212
+}
213
+?>" />
192 214
 			</p>
193 215
 			<p>
194 216
 				<label for="dbuserpass">Database user password</label>
195
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
217
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
218
+	print $globalDBpass;
219
+}
220
+?>" />
196 221
 			</p>
197 222
 		</fieldset>
198 223
 		<fieldset id="site">
199 224
 			<legend>Site configuration</legend>
200 225
 			<p>
201 226
 				<label for="sitename">Site name</label>
202
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
227
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
228
+	print $globalName;
229
+}
230
+?>" />
203 231
 			</p>
204 232
 			<p>
205 233
 				<label for="siteurl">Site directory</label>
@@ -212,18 +240,27 @@  discard block
 block discarded – undo
212 240
 					}
213 241
 				    }
214 242
 				?>
215
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
243
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
244
+	print $globalURL;
245
+}
246
+?>" />
216 247
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
217 248
 				<p class="help-block">Can be empty</p>
218 249
 			</p>
219 250
 			<p>
220 251
 				<label for="timezone">Timezone</label>
221
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
252
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
253
+	print $globalTimezone;
254
+}
255
+?>" />
222 256
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
223 257
 			</p>
224 258
 			<p>
225 259
 				<label for="language">Language</label>
226
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
260
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
261
+	print $globalLanguage;
262
+}
263
+?>" />
227 264
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
228 265
 			</p>
229 266
 		</fieldset>
@@ -243,11 +280,17 @@  discard block
 block discarded – undo
243 280
 			<div id="mapbox_data">
244 281
 				<p>
245 282
 					<label for="mapboxid">Mapbox id</label>
246
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
283
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
284
+	print $globalMapboxId;
285
+}
286
+?>" />
247 287
 				</p>
248 288
 				<p>
249 289
 					<label for="mapboxtoken">Mapbox token</label>
250
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
290
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
291
+	print $globalMapboxToken;
292
+}
293
+?>" />
251 294
 				</p>
252 295
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
253 296
 			</div>
@@ -255,7 +298,10 @@  discard block
 block discarded – undo
255 298
 			<div id="google_data">
256 299
 				<p>
257 300
 					<label for="googlekey">Google API key</label>
258
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
301
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
302
+	print $globalGoogleAPIKey;
303
+}
304
+?>" />
259 305
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
260 306
 				</p>
261 307
 			</div>
@@ -263,7 +309,10 @@  discard block
 block discarded – undo
263 309
 			<div id="bing_data">
264 310
 				<p>
265 311
 					<label for="bingkey">Bing Map key</label>
266
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
312
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
313
+	print $globalBingMapKey;
314
+}
315
+?>" />
267 316
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
268 317
 				</p>
269 318
 			</div>
@@ -271,7 +320,10 @@  discard block
 block discarded – undo
271 320
 			<div id="mapquest_data">
272 321
 				<p>
273 322
 					<label for="mapquestkey">MapQuest key</label>
274
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
323
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
324
+	print $globalMapQuestKey;
325
+}
326
+?>" />
275 327
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
276 328
 				</p>
277 329
 			</div>
@@ -279,11 +331,17 @@  discard block
 block discarded – undo
279 331
 			<div id="here_data">
280 332
 				<p>
281 333
 					<label for="hereappid">Here App_Id</label>
282
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
334
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
335
+	print $globalHereappId;
336
+}
337
+?>" />
283 338
 				</p>
284 339
 				<p>
285 340
 					<label for="hereappcode">Here App_Code</label>
286
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
341
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
342
+	print $globalHereappCode;
343
+}
344
+?>" />
287 345
 				</p>
288 346
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
289 347
 			</div>
@@ -291,7 +349,10 @@  discard block
 block discarded – undo
291 349
 			<div id="openweathermap_data">
292 350
 				<p>
293 351
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
294
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
352
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
353
+	print $globalOpenWeatherMapKey;
354
+}
355
+?>" />
295 356
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
296 357
 				</p>
297 358
 			</div>
@@ -320,42 +381,86 @@  discard block
 block discarded – undo
320 381
 			<legend>Coverage area</legend>
321 382
 			<p>
322 383
 				<label for="latitudemax">The maximum latitude (north)</label>
323
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
384
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
385
+	print $globalLatitudeMax;
386
+}
387
+?>" />
324 388
 			</p>
325 389
 			<p>
326 390
 				<label for="latitudemin">The minimum latitude (south)</label>
327
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
391
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
392
+	print $globalLatitudeMin;
393
+}
394
+?>" />
328 395
 			</p>
329 396
 			<p>
330 397
 				<label for="longitudemax">The maximum longitude (west)</label>
331
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
398
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
399
+	print $globalLongitudeMax;
400
+}
401
+?>" />
332 402
 			</p>
333 403
 			<p>
334 404
 				<label for="longitudemin">The minimum longitude (east)</label>
335
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
405
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
406
+	print $globalLongitudeMin;
407
+}
408
+?>" />
336 409
 			</p>
337 410
 			<p>
338 411
 				<label for="latitudecenter">The latitude center</label>
339
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
412
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
413
+	print $globalCenterLatitude;
414
+}
415
+?>" />
340 416
 			</p>
341 417
 			<p>
342 418
 				<label for="longitudecenter">The longitude center</label>
343
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
419
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
420
+	print $globalCenterLongitude;
421
+}
422
+?>" />
344 423
 			</p>
345 424
 			<p>
346 425
 				<label for="livezoom">Default Zoom on live map</label>
347
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
426
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
427
+	print $globalLiveZoom;
428
+} else {
429
+	print '9';
430
+}
431
+?>" />
348 432
 			</p>
349 433
 			<p>
350 434
 				<label for="squawk_country">Country for squawk usage</label>
351 435
 				<select name="squawk_country" id="squawk_country">
352
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
353
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
354
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
355
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
356
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
357
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
358
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
436
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
437
+	print ' selected ';
438
+}
439
+?>>UK</option>
440
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
441
+	print ' selected ';
442
+}
443
+?>>NZ</option>
444
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
445
+	print ' selected ';
446
+}
447
+?>>US</option>
448
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
449
+	print ' selected ';
450
+}
451
+?>>AU</option>
452
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
453
+	print ' selected ';
454
+}
455
+?>>NL</option>
456
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
457
+	print ' selected ';
458
+}
459
+?>>FR</option>
460
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
461
+	print ' selected ';
462
+}
463
+?>>TR</option>
359 464
 				</select>
360 465
 			</p>
361 466
 		</fieldset>
@@ -364,15 +469,24 @@  discard block
 block discarded – undo
364 469
 			<p><i>Only put in DB flights that are inside a circle</i></p>
365 470
 			<p>
366 471
 				<label for="latitude">Center latitude</label>
367
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
472
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
473
+	echo $globalDistanceIgnore['latitude'];
474
+}
475
+?>" />
368 476
 			</p>
369 477
 			<p>
370 478
 				<label for="longitude">Center longitude</label>
371
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
479
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
480
+	echo $globalDistanceIgnore['longitude'];
481
+}
482
+?>" />
372 483
 			</p>
373 484
 			<p>
374 485
 				<label for="Distance">Distance (in km)</label>
375
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
486
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
487
+	echo $globalDistanceIgnore['distance'];
488
+}
489
+?>" />
376 490
 			</p>
377 491
 		</fieldset>
378 492
 		<fieldset id="sourceloc">
@@ -488,11 +602,17 @@  discard block
 block discarded – undo
488 602
 			<div id="flightaware_data">
489 603
 				<p>
490 604
 					<label for="flightawareusername">FlightAware username</label>
491
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
605
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
606
+	print $globalFlightAwareUsername;
607
+}
608
+?>" />
492 609
 				</p>
493 610
 				<p>
494 611
 					<label for="flightawarepassword">FlightAware password/API key</label>
495
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
612
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
613
+	print $globalFlightAwarePassword;
614
+}
615
+?>" />
496 616
 				</p>
497 617
 			</div>
498 618
 -->
@@ -534,7 +654,10 @@  discard block
 block discarded – undo
534 654
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
535 655
 								?>
536 656
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
537
-								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
657
+								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
658
+	print $source['port'];
659
+}
660
+?>" /></td>
538 661
 								<?php
539 662
 								    } else {
540 663
 									$hostport = explode(':',$source['host']);
@@ -553,36 +676,114 @@  discard block
 block discarded – undo
553 676
 								?>
554 677
 								<td>
555 678
 									<select name="format[]" id="format">
556
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
557
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
558
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
559
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
560
-										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
561
-										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option>
562
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
563
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
564
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
565
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
566
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
567
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
568
-										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
569
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
570
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
571
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
572
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
573
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
574
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
575
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
576
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
577
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
578
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
679
+										<option value="auto" <?php if (!isset($source['format'])) {
680
+	print 'selected';
681
+}
682
+?>>Auto</option>
683
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
684
+	print 'selected';
685
+}
686
+?>>SBS</option>
687
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
688
+	print 'selected';
689
+}
690
+?>>TSV</option>
691
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
692
+	print 'selected';
693
+}
694
+?>>Raw</option>
695
+										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') {
696
+	print 'selected';
697
+}
698
+?>>Dump1090 aircraft.json</option>
699
+										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') {
700
+	print 'selected';
701
+}
702
+?>>Planefinder client</option>
703
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
704
+	print 'selected';
705
+}
706
+?>>APRS</option>
707
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
708
+	print 'selected';
709
+}
710
+?>>Radarcape deltadb.txt</option>
711
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
712
+	print 'selected';
713
+}
714
+?>>Vatsim</option>
715
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
716
+	print 'selected';
717
+}
718
+?>>Virtual Radar Server AircraftList.json</option>
719
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
720
+	print 'selected';
721
+}
722
+?>>Virtual Radar Server TCP</option>
723
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
724
+	print 'selected';
725
+}
726
+?>>phpVMS</option>
727
+										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
728
+	print 'selected';
729
+}
730
+?>>Virtual Airline Operations System (VAOS)</option>
731
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
732
+	print 'selected';
733
+}
734
+?>>Virtual Airlines Manager</option>
735
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
736
+	print 'selected';
737
+}
738
+?>>IVAO</option>
739
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
740
+	print 'selected';
741
+}
742
+?>>FlightGear Multiplayer</option>
743
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
744
+	print 'selected';
745
+}
746
+?>>FlightGear Singleplayer</option>
747
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
748
+	print 'selected';
749
+}
750
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
751
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
752
+	print 'selected';
753
+}
754
+?>>ACARS SBS-3 over TCP</option>
755
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
756
+	print 'selected';
757
+}
758
+?>>NMEA AIS over TCP</option>
759
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
760
+	print 'selected';
761
+}
762
+?>>AirWhere website</option>
763
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
764
+	print 'selected';
765
+}
766
+?>>HidnSeek Callback</option>
767
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
768
+	print 'selected';
769
+}
770
+?>>Blitzortung</option>
579 771
 									</select>
580 772
 								</td>
581 773
 								<td>
582
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
774
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
775
+	print $source['name'];
776
+}
777
+?>" />
583 778
 								</td>
584
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
585
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
779
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
780
+	print 'checked';
781
+}
782
+?> /></td>
783
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
784
+	print 'checked';
785
+}
786
+?> /></td>
586 787
 								<td>
587 788
 									<select name="timezones[]" id="timezones">
588 789
 								<?php
@@ -592,7 +793,9 @@  discard block
 block discarded – undo
592 793
 											print '<option selected>'.$timezones.'</option>';
593 794
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
594 795
 											print '<option selected>'.$timezones.'</option>';
595
-										} else print '<option>'.$timezones.'</option>';
796
+										} else {
797
+											print '<option>'.$timezones.'</option>';
798
+										}
596 799
 									}
597 800
 								?>
598 801
 									</select>
@@ -645,7 +848,9 @@  discard block
 block discarded – undo
645 848
 									foreach($timezonelist as $timezones){
646 849
 										if ($timezones == 'UTC') {
647 850
 											print '<option selected>'.$timezones.'</option>';
648
-										} else print '<option>'.$timezones.'</option>';
851
+										} else {
852
+											print '<option>'.$timezones.'</option>';
853
+										}
649 854
 									}
650 855
 								?>
651 856
 									</select>
@@ -670,11 +875,17 @@  discard block
 block discarded – undo
670 875
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
671 876
 					<p>
672 877
 						<label for="acarshost">ACARS UDP host</label>
673
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
878
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
879
+	print $globalACARSHost;
880
+}
881
+?>" />
674 882
 					</p>
675 883
 					<p>
676 884
 						<label for="acarsport">ACARS UDP port</label>
677
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
885
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
886
+	print $globalACARSPort;
887
+}
888
+?>" />
678 889
 					</p>
679 890
 				</fieldset>
680 891
 			</div>
@@ -700,17 +911,38 @@  discard block
 block discarded – undo
700 911
 				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
701 912
 				    <td>
702 913
 					<select name="newslang[]">
703
-					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
704
-					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
914
+					    <option value="en"<?php if ($lng == 'en') {
915
+	print ' selected';
916
+}
917
+?>>English</option>
918
+					    <option value="fr"<?php if ($lng == 'fr') {
919
+	print ' selected';
920
+}
921
+?>>French</option>
705 922
 					</select>
706 923
 				    </td>
707 924
 				    <td>
708 925
 					<select name="newstype[]">
709
-					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
710
-					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
711
-					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
712
-					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
713
-					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
926
+					    <option value="global"<?php if ($type == 'global') {
927
+	print ' selected';
928
+}
929
+?>>Global</option>
930
+					    <option value="aircraft"<?php if ($type == 'aircraft') {
931
+	print ' selected';
932
+}
933
+?>>Aircraft</option>
934
+					    <option value="marine"<?php if ($type == 'marine') {
935
+	print ' selected';
936
+}
937
+?>>Marine</option>
938
+					    <option value="tracker"<?php if ($type == 'tracker') {
939
+	print ' selected';
940
+}
941
+?>>Tracker</option>
942
+					    <option value="satellite"<?php if ($type == 'Satellite') {
943
+	print ' selected';
944
+}
945
+?>>Satellite</option>
714 946
 					</select>
715 947
 				    </td>
716 948
 				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
@@ -852,13 +1084,19 @@  discard block
 block discarded – undo
852 1084
 			<div id="schedules_options">
853 1085
 				<p>
854 1086
 					<label for="britishairways">British Airways API Key</label>
855
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
1087
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
1088
+	print $globalBritishAirwaysKey;
1089
+}
1090
+?>" />
856 1091
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
857 1092
 				</p>
858 1093
 				<!--
859 1094
 				<p>
860 1095
 					<label for="transavia">Transavia Test API Consumer Key</label>
861
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
1096
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
1097
+	print $globalTransaviaKey;
1098
+}
1099
+?>" />
862 1100
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
863 1101
 				</p>
864 1102
 				-->
@@ -867,10 +1105,16 @@  discard block
 block discarded – undo
867 1105
 						<b>Lufthansa API Key</b>
868 1106
 						<p>
869 1107
 							<label for="lufthansakey">Key</label>
870
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
1108
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
1109
+	print $globalLufthansaKey['key'];
1110
+}
1111
+?>" />
871 1112
 						</p><p>
872 1113
 							<label for="lufthansasecret">Secret</label>
873
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
1114
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
1115
+	print $globalLufthansaKey['secret'];
1116
+}
1117
+?>" />
874 1118
 						</p>
875 1119
 					</div>
876 1120
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -880,11 +1124,17 @@  discard block
 block discarded – undo
880 1124
 						<b>FlightAware API Key</b>
881 1125
 						<p>
882 1126
 							<label for="flightawareusername">Username</label>
883
-							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
1127
+							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
1128
+	print $globalFlightAwareUsername;
1129
+}
1130
+?>" />
884 1131
 						</p>
885 1132
 						<p>
886 1133
 							<label for="flightawarepassword">API key</label>
887
-							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
1134
+							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
1135
+	print $globalFlightAwarePassword;
1136
+}
1137
+?>" />
888 1138
 						</p>
889 1139
 					</div>
890 1140
 					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
@@ -901,10 +1151,22 @@  discard block
 block discarded – undo
901 1151
 				<p>
902 1152
 					<label for="mapmatchingsource">Map Matching source</label>
903 1153
 					<select name="mapmatchingsource" id="mapmatchingsource">
904
-						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
905
-						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
906
-						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option>
907
-						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
1154
+						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) {
1155
+	print 'selected="selected" ';
1156
+}
1157
+?>>FlightAirMap Map Matching</option>
1158
+						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') {
1159
+	print 'selected="selected" ';
1160
+}
1161
+?>>GraphHopper</option>
1162
+						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') {
1163
+	print 'selected="selected" ';
1164
+}
1165
+?>>OSMR</option>
1166
+						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') {
1167
+	print 'selected="selected" ';
1168
+}
1169
+?>>Mapbox</option>
908 1170
 					</select>
909 1171
 					<p class="help-block">Mapbox need the API Key defined in map section.</p>
910 1172
 					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
@@ -912,7 +1174,10 @@  discard block
 block discarded – undo
912 1174
 				<br />
913 1175
 				<p>
914 1176
 					<label for="graphhopper">GraphHopper API Key</label>
915
-					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
1177
+					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) {
1178
+	print $globalGraphHopperKey;
1179
+}
1180
+?>" />
916 1181
 					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
917 1182
 				</p>
918 1183
 			</div>
@@ -930,7 +1195,10 @@  discard block
 block discarded – undo
930 1195
 			</p>
931 1196
 			<p>
932 1197
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
933
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1198
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
1199
+	print $globalNOTAMSource;
1200
+}
1201
+?>" />
934 1202
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
935 1203
 			</p>
936 1204
 			<br />
@@ -946,14 +1214,20 @@  discard block
 block discarded – undo
946 1214
 			<div id="metarsrc">
947 1215
 				<p>
948 1216
 					<label for="metarsource">URL of your METAR source</label>
949
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1217
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
1218
+	print $globalMETARurl;
1219
+}
1220
+?>" />
950 1221
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
951 1222
 				</p>
952 1223
 			</div>
953 1224
 			<br />
954 1225
 			<p>
955 1226
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
956
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1227
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
1228
+	print $globalBitlyAccessToken;
1229
+}
1230
+?>" />
957 1231
 			</p>
958 1232
 			<br />
959 1233
 			<p>
@@ -969,11 +1243,26 @@  discard block
 block discarded – undo
969 1243
 			<p>
970 1244
 				<label for="geoid_source">Geoid Source</label>
971 1245
 				<select name="geoid_source" id="geoid_source">
972
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
973
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
974
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
975
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
976
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1246
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
1247
+	print ' selected="selected"';
1248
+}
1249
+?>>EGM96 15' (2.1MB)</option>
1250
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
1251
+	print ' selected="selected"';
1252
+}
1253
+?>>EGM96 5' (19MB)</option>
1254
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
1255
+	print ' selected="selected"';
1256
+}
1257
+?>>EGM2008 5' (19MB)</option>
1258
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
1259
+	print ' selected="selected"';
1260
+}
1261
+?>>EGM2008 2.5' (75MB)</option>
1262
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
1263
+	print ' selected="selected"';
1264
+}
1265
+?>>EGM2008 1' (470MB)</option>
977 1266
 				</select>
978 1267
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
979 1268
 			</p>
@@ -995,7 +1284,12 @@  discard block
 block discarded – undo
995 1284
 			</p>
996 1285
 			<p>
997 1286
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
998
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1287
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1288
+	print $globalArchiveMonths;
1289
+} else {
1290
+	echo '1';
1291
+}
1292
+?>" />
999 1293
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
1000 1294
 			</p>
1001 1295
 			<p>
@@ -1005,12 +1299,22 @@  discard block
 block discarded – undo
1005 1299
 			</p>
1006 1300
 			<p>
1007 1301
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
1008
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1302
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1303
+	print $globalArchiveKeepMonths;
1304
+} else {
1305
+	echo '1';
1306
+}
1307
+?>" />
1009 1308
 				<p class="help-block">0 to disable</p>
1010 1309
 			</p>
1011 1310
 			<p>
1012 1311
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
1013
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1312
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1313
+	print $globalArchiveKeepTrackMonths;
1314
+} else {
1315
+	echo '1';
1316
+}
1317
+?>" />
1014 1318
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
1015 1319
 			</p>
1016 1320
 			<br />
@@ -1020,7 +1324,12 @@  discard block
 block discarded – undo
1020 1324
 				<p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p>
1021 1325
 				<div id="cronends"> 
1022 1326
 					<label for="cronend">Run script for xx seconds</label>
1023
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1327
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1328
+	print $globalCronEnd;
1329
+} else {
1330
+	print '0';
1331
+}
1332
+?>" />
1024 1333
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
1025 1334
 				</div>
1026 1335
 			</p>
@@ -1073,20 +1382,40 @@  discard block
 block discarded – undo
1073 1382
 			<br />
1074 1383
 			<p>
1075 1384
 				<label for="refresh">Show flights detected since xxx seconds</label>
1076
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1385
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1386
+	echo $globalLiveInterval;
1387
+} else {
1388
+	echo '200';
1389
+}
1390
+?>" />
1077 1391
 			</p>
1078 1392
 			<p>
1079 1393
 				<label for="maprefresh">Live map refresh (in seconds)</label>
1080
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1394
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1395
+	echo $globalMapRefresh;
1396
+} else {
1397
+	echo '30';
1398
+}
1399
+?>" />
1081 1400
 			</p>
1082 1401
 			<p>
1083 1402
 				<label for="mapidle">Map idle timeout (in minutes)</label>
1084
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1403
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1404
+	echo $globalMapIdleTimeout;
1405
+} else {
1406
+	echo '30';
1407
+}
1408
+?>" />
1085 1409
 				<p class="help-block">0 to disable</p>
1086 1410
 			</p>
1087 1411
 			<p>
1088 1412
 				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1089
-				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1413
+				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) {
1414
+	echo $globalMinFetch;
1415
+} else {
1416
+	echo '20';
1417
+}
1418
+?>" />
1090 1419
 			</p>
1091 1420
 			<p>
1092 1421
 				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
@@ -1100,12 +1429,20 @@  discard block
 block discarded – undo
1100 1429
 			<br />
1101 1430
 			<p>
1102 1431
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1103
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1432
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1433
+	echo $globalClosestMinDist;
1434
+} else {
1435
+	echo '50';
1436
+}
1437
+?>" />
1104 1438
 			</p>
1105 1439
 			<br />
1106 1440
 			<p>
1107 1441
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1108
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1442
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1443
+	echo $globalAircraftSize;
1444
+}
1445
+?>" />
1109 1446
 			</p>
1110 1447
 			<br />
1111 1448
 			<p>
@@ -1124,7 +1461,12 @@  discard block
 block discarded – undo
1124 1461
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
1125 1462
 			?>
1126 1463
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1127
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1464
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1465
+	echo $globalAircraftIconColor;
1466
+} else {
1467
+	echo '1a3151';
1468
+}
1469
+?>" />
1128 1470
 			<?php
1129 1471
 				if (!is_writable('../cache')) {
1130 1472
 			?>
@@ -1142,14 +1484,27 @@  discard block
 block discarded – undo
1142 1484
 			<p>
1143 1485
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1144 1486
 				<div class="range">
1145
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1146
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1487
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1488
+	echo $globalAirportZoom;
1489
+} else {
1490
+	echo '7';
1491
+}
1492
+?>" />
1493
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1494
+	echo $globalAirportZoom;
1495
+} else {
1496
+	echo '7';
1497
+}
1498
+?></output>
1147 1499
 				</div>
1148 1500
 			</p>
1149 1501
 			<br />
1150 1502
 			<p>
1151 1503
 				<label for="customcss">Custom CSS web path</label>
1152
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1504
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1505
+	echo $globalCustomCSS;
1506
+}
1507
+?>" />
1153 1508
 			</p>
1154 1509
 		</fieldset>
1155 1510
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -1176,8 +1531,12 @@  discard block
 block discarded – undo
1176 1531
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1177 1532
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1178 1533
 
1179
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1180
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1534
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1535
+		$error .= 'Mysql driver for PDO must be loaded';
1536
+	}
1537
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1538
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1539
+	}
1181 1540
 	
1182 1541
 	$_SESSION['database_root'] = $dbroot;
1183 1542
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1245,15 +1604,23 @@  discard block
 block discarded – undo
1245 1604
 	$source_city = $_POST['source_city'];
1246 1605
 	$source_country = $_POST['source_country'];
1247 1606
 	$source_ref = $_POST['source_ref'];
1248
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1249
-	else $source_id = array();
1607
+	if (isset($source_id)) {
1608
+		$source_id = $_POST['source_id'];
1609
+	} else {
1610
+		$source_id = array();
1611
+	}
1250 1612
 	
1251 1613
 	$sources = array();
1252 1614
 	foreach ($source_name as $keys => $name) {
1253
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1254
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1615
+	    if (isset($source_id[$keys])) {
1616
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1617
+	    } else {
1618
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1619
+	    }
1620
+	}
1621
+	if (count($sources) > 0) {
1622
+		$_SESSION['sources'] = $sources;
1255 1623
 	}
1256
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1257 1624
 
1258 1625
 	$newsurl = $_POST['newsurl'];
1259 1626
 	$newslng = $_POST['newslang'];
@@ -1266,7 +1633,9 @@  discard block
 block discarded – undo
1266 1633
 		$lng = $newslng[$newskey];
1267 1634
 		if (isset($newsfeeds[$type][$lng])) {
1268 1635
 		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1269
-		} else $newsfeeds[$type][$lng] = array($url);
1636
+		} else {
1637
+			$newsfeeds[$type][$lng] = array($url);
1638
+		}
1270 1639
 	    }
1271 1640
 	}
1272 1641
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
@@ -1290,17 +1659,29 @@  discard block
 block discarded – undo
1290 1659
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1291 1660
 
1292 1661
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1293
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1294
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1662
+	if ($globalaircraft == 'aircraft') {
1663
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1664
+	} else {
1665
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1666
+	}
1295 1667
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1296
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1297
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1668
+	if ($globaltracker == 'tracker') {
1669
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1670
+	} else {
1671
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1672
+	}
1298 1673
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1299
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1300
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1674
+	if ($globalmarine == 'marine') {
1675
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1676
+	} else {
1677
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1678
+	}
1301 1679
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1302
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1303
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1680
+	if ($globalsatellite == 'satellite') {
1681
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1682
+	} else {
1683
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1684
+	}
1304 1685
 
1305 1686
 /*	
1306 1687
 	$globalSBS1Hosts = array();
@@ -1322,23 +1703,37 @@  discard block
 block discarded – undo
1322 1703
 	$name = $_POST['name'];
1323 1704
 	$format = $_POST['format'];
1324 1705
 	$timezones = $_POST['timezones'];
1325
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1326
-	else $sourcestats = array();
1327
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1328
-	else $noarchive = array();
1706
+	if (isset($_POST['sourcestats'])) {
1707
+		$sourcestats = $_POST['sourcestats'];
1708
+	} else {
1709
+		$sourcestats = array();
1710
+	}
1711
+	if (isset($_POST['noarchive'])) {
1712
+		$noarchive = $_POST['noarchive'];
1713
+	} else {
1714
+		$noarchive = array();
1715
+	}
1329 1716
 	$gSources = array();
1330 1717
 	$forcepilots = false;
1331 1718
 	foreach ($host as $key => $h) {
1332
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1333
-		else $cov = 'FALSE';
1334
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1335
-		else $arch = 'FALSE';
1719
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1720
+			$cov = 'TRUE';
1721
+		} else {
1722
+			$cov = 'FALSE';
1723
+		}
1724
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1725
+			$arch = 'TRUE';
1726
+		} else {
1727
+			$arch = 'FALSE';
1728
+		}
1336 1729
 		if (strpos($format[$key],'_callback')) {
1337 1730
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1338 1731
 		} elseif ($h != '' || $name[$key] != '') {
1339 1732
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1340 1733
 		}
1341
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1734
+		if ($format[$key] == 'airwhere') {
1735
+			$forcepilots = true;
1736
+		}
1342 1737
 	}
1343 1738
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1344 1739
 
@@ -1369,7 +1764,9 @@  discard block
 block discarded – undo
1369 1764
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1370 1765
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1371 1766
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1372
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1767
+	} else {
1768
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1769
+	}
1373 1770
 
1374 1771
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1375 1772
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1410,7 +1807,9 @@  discard block
 block discarded – undo
1410 1807
 
1411 1808
 	// Create in settings.php keys not yet configurable if not already here
1412 1809
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1413
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1810
+	if (!isset($globalDebug)) {
1811
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1812
+	}
1414 1813
 
1415 1814
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1416 1815
 	if ($resetyearstats == 'resetyearstats') {
@@ -1453,37 +1852,56 @@  discard block
 block discarded – undo
1453 1852
 	}
1454 1853
 */
1455 1854
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1456
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1457
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1458
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1459
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1855
+	if ($globalsbs == 'sbs') {
1856
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1857
+	} else {
1858
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1859
+	}
1860
+	if ($globalaprs == 'aprs') {
1861
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1862
+	} else {
1863
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1864
+	}
1460 1865
 	$va = false;
1461 1866
 	if ($globalivao == 'ivao') {
1462 1867
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1463 1868
 		$va = true;
1464
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1869
+	} else {
1870
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1871
+	}
1465 1872
 	if ($globalvatsim == 'vatsim') {
1466 1873
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1467 1874
 		$va = true;
1468
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1875
+	} else {
1876
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1877
+	}
1469 1878
 	if ($globalphpvms == 'phpvms') {
1470 1879
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1471 1880
 		$va = true;
1472
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1881
+	} else {
1882
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1883
+	}
1473 1884
 	if ($globalvam == 'vam') {
1474 1885
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1475 1886
 		$va = true;
1476
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1887
+	} else {
1888
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1889
+	}
1477 1890
 	if ($va) {
1478 1891
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1479
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1892
+	} else {
1893
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1894
+	}
1480 1895
 	if ($globalva == 'va' || $va) {
1481 1896
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1482 1897
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1483 1898
 	} else {
1484 1899
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1485
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1486
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1900
+		if ($forcepilots) {
1901
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1902
+		} else {
1903
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1904
+		}
1487 1905
 	}
1488 1906
 	
1489 1907
 	
@@ -1718,7 +2136,9 @@  discard block
 block discarded – undo
1718 2136
 	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1719 2137
 	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1720 2138
 
1721
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2139
+	if (!isset($globalTransaction)) {
2140
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2141
+	}
1722 2142
 
1723 2143
 	// Set some defaults values...
1724 2144
 	if (!isset($globalAircraftImageSources)) {
@@ -1733,15 +2153,23 @@  discard block
 block discarded – undo
1733 2153
 
1734 2154
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1735 2155
 
1736
-	if ($error == '') settings::modify_settings($settings);
1737
-	if ($error == '') settings::comment_settings($settings_comment);
2156
+	if ($error == '') {
2157
+		settings::modify_settings($settings);
2158
+	}
2159
+	if ($error == '') {
2160
+		settings::comment_settings($settings_comment);
2161
+	}
1738 2162
 	if ($error != '') {
1739 2163
 		print '<div class="info column">'.$error.'</div>';
1740 2164
 		require('../footer.php');
1741 2165
 		exit;
1742 2166
 	} else {
1743
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1744
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
2167
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
2168
+			$_SESSION['waypoints'] = 1;
2169
+		}
2170
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
2171
+			$_SESSION['owner'] = 1;
2172
+		}
1745 2173
 		if (isset($_POST['createdb'])) {
1746 2174
 			$_SESSION['install'] = 'database_create';
1747 2175
 		} else {
@@ -1778,10 +2206,18 @@  discard block
 block discarded – undo
1778 2206
 	$popw = false;
1779 2207
 	foreach ($_SESSION['done'] as $done) {
1780 2208
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1781
-	    if ($done == 'Create database') $pop = true;
1782
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1783
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1784
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
2209
+	    if ($done == 'Create database') {
2210
+	    	$pop = true;
2211
+	    }
2212
+	    if ($_SESSION['install'] == 'database_create') {
2213
+	    	$pop = true;
2214
+	    }
2215
+	    if ($_SESSION['install'] == 'database_import') {
2216
+	    	$popi = true;
2217
+	    }
2218
+	    if ($_SESSION['install'] == 'waypoints') {
2219
+	    	$popw = true;
2220
+	    }
1785 2221
 	}
1786 2222
 	if ($pop) {
1787 2223
 	    sleep(5);
@@ -1792,7 +2228,9 @@  discard block
 block discarded – undo
1792 2228
 	} else if ($popw) {
1793 2229
 	    sleep(5);
1794 2230
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1795
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2231
+	} else {
2232
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2233
+	}
1796 2234
 	print '</div></ul>';
1797 2235
 	print '<div id="error"></div>';
1798 2236
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Braces   +1190 added lines, -412 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
27 27
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
28 28
 		curl_setopt($ch, CURLOPT_TIMEOUT, 200);
29
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
29
+		if ($referer != '') {
30
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
31
+		}
30 32
 		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');
31 33
 		curl_setopt($ch, CURLOPT_FILE, $fp);
32 34
 		curl_exec($ch);
@@ -37,12 +39,16 @@  discard block
 block discarded – undo
37 39
 	public static function gunzip($in_file,$out_file_name = '') {
38 40
 		//echo $in_file.' -> '.$out_file_name."\n";
39 41
 		$buffer_size = 4096; // read 4kb at a time
40
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
42
+		if ($out_file_name == '') {
43
+			$out_file_name = str_replace('.gz', '', $in_file);
44
+		}
41 45
 		if ($in_file != '' && file_exists($in_file)) {
42 46
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
45
-			else {
47
+			if (function_exists('gzopen')) {
48
+				$file = gzopen($in_file,'rb');
49
+			} elseif (function_exists('gzopen64')) {
50
+				$file = gzopen64($in_file,'rb');
51
+			} else {
46 52
 				echo 'gzopen not available';
47 53
 				die;
48 54
 			}
@@ -63,8 +69,12 @@  discard block
 block discarded – undo
63 69
 			if ($res === TRUE) {
64 70
 				$zip->extractTo($path);
65 71
 				$zip->close();
66
-			} else return false;
67
-		} else return false;
72
+			} else {
73
+				return false;
74
+			}
75
+		} else {
76
+			return false;
77
+		}
68 78
 	}
69 79
 	
70 80
 	public static function connect_sqlite($database) {
@@ -79,7 +89,9 @@  discard block
 block discarded – undo
79 89
 	public static function retrieve_route_sqlite_to_dest($database_file) {
80 90
 		global $globalDebug, $globalTransaction;
81 91
 		//$query = 'TRUNCATE TABLE routes';
82
-		if ($globalDebug) echo " - Delete previous routes from DB -";
92
+		if ($globalDebug) {
93
+			echo " - Delete previous routes from DB -";
94
+		}
83 95
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
84 96
 		$Connection = new Connection();
85 97
 		try {
@@ -90,7 +102,9 @@  discard block
 block discarded – undo
90 102
                         return "error : ".$e->getMessage();
91 103
                 }
92 104
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
105
+    		if ($globalDebug) {
106
+    			echo " - Add routes to DB -";
107
+    		}
94 108
     		update_db::connect_sqlite($database_file);
95 109
 		//$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';
96 110
 		$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";
@@ -105,15 +119,21 @@  discard block
 block discarded – undo
105 119
 		$Connection = new Connection();
106 120
 		$sth_dest = $Connection->db->prepare($query_dest);
107 121
 		try {
108
-			if ($globalTransaction) $Connection->db->beginTransaction();
122
+			if ($globalTransaction) {
123
+				$Connection->db->beginTransaction();
124
+			}
109 125
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 126
 				//$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);
111 127
 				$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);
112 128
 				$sth_dest->execute($query_dest_values);
113 129
             		}
114
-			if ($globalTransaction) $Connection->db->commit();
130
+			if ($globalTransaction) {
131
+				$Connection->db->commit();
132
+			}
115 133
 		} catch(PDOException $e) {
116
-			if ($globalTransaction) $Connection->db->rollBack(); 
134
+			if ($globalTransaction) {
135
+				$Connection->db->rollBack();
136
+			}
117 137
 			return "error : ".$e->getMessage();
118 138
 		}
119 139
                 return '';
@@ -121,7 +141,9 @@  discard block
 block discarded – undo
121 141
 	public static function retrieve_route_oneworld($database_file) {
122 142
 		global $globalDebug, $globalTransaction;
123 143
 		//$query = 'TRUNCATE TABLE routes';
124
-		if ($globalDebug) echo " - Delete previous routes from DB -";
144
+		if ($globalDebug) {
145
+			echo " - Delete previous routes from DB -";
146
+		}
125 147
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
126 148
 		$Connection = new Connection();
127 149
 		try {
@@ -132,14 +154,18 @@  discard block
 block discarded – undo
132 154
                         return "error : ".$e->getMessage();
133 155
                 }
134 156
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
157
+    		if ($globalDebug) {
158
+    			echo " - Add routes to DB -";
159
+    		}
136 160
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 161
 		$Spotter = new Spotter();
138 162
 		if ($fh = fopen($database_file,"r")) {
139 163
 			$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)';
140 164
 			$Connection = new Connection();
141 165
 			$sth_dest = $Connection->db->prepare($query_dest);
142
-			if ($globalTransaction) $Connection->db->beginTransaction();
166
+			if ($globalTransaction) {
167
+				$Connection->db->beginTransaction();
168
+			}
143 169
 			while (!feof($fh)) {
144 170
 				$line = fgetcsv($fh,9999,',');
145 171
 				if ($line[0] != '') {
@@ -148,13 +174,17 @@  discard block
 block discarded – undo
148 174
 							$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');
149 175
 							$sth_dest->execute($query_dest_values);
150 176
 						} catch(PDOException $e) {
151
-							if ($globalTransaction) $Connection->db->rollBack(); 
177
+							if ($globalTransaction) {
178
+								$Connection->db->rollBack();
179
+							}
152 180
 							return "error : ".$e->getMessage();
153 181
 						}
154 182
 					}
155 183
 				}
156 184
 			}
157
-			if ($globalTransaction) $Connection->db->commit();
185
+			if ($globalTransaction) {
186
+				$Connection->db->commit();
187
+			}
158 188
 		}
159 189
                 return '';
160 190
 	}
@@ -162,7 +192,9 @@  discard block
 block discarded – undo
162 192
 	public static function retrieve_route_skyteam($database_file) {
163 193
 		global $globalDebug, $globalTransaction;
164 194
 		//$query = 'TRUNCATE TABLE routes';
165
-		if ($globalDebug) echo " - Delete previous routes from DB -";
195
+		if ($globalDebug) {
196
+			echo " - Delete previous routes from DB -";
197
+		}
166 198
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
167 199
 		$Connection = new Connection();
168 200
 		try {
@@ -173,7 +205,9 @@  discard block
 block discarded – undo
173 205
                         return "error : ".$e->getMessage();
174 206
                 }
175 207
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
208
+    		if ($globalDebug) {
209
+    			echo " - Add routes to DB -";
210
+    		}
177 211
 
178 212
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 213
 		$Spotter = new Spotter();
@@ -182,7 +216,9 @@  discard block
 block discarded – undo
182 216
 			$Connection = new Connection();
183 217
 			$sth_dest = $Connection->db->prepare($query_dest);
184 218
 			try {
185
-				if ($globalTransaction) $Connection->db->beginTransaction();
219
+				if ($globalTransaction) {
220
+					$Connection->db->beginTransaction();
221
+				}
186 222
 				while (!feof($fh)) {
187 223
 					$line = fgetcsv($fh,9999,',');
188 224
 					if ($line[0] != '') {
@@ -193,9 +229,13 @@  discard block
 block discarded – undo
193 229
 						}
194 230
 					}
195 231
 				}
196
-				if ($globalTransaction) $Connection->db->commit();
232
+				if ($globalTransaction) {
233
+					$Connection->db->commit();
234
+				}
197 235
 			} catch(PDOException $e) {
198
-				if ($globalTransaction) $Connection->db->rollBack(); 
236
+				if ($globalTransaction) {
237
+					$Connection->db->rollBack();
238
+				}
199 239
 				return "error : ".$e->getMessage();
200 240
 			}
201 241
 		}
@@ -238,11 +278,16 @@  discard block
 block discarded – undo
238 278
 		$sth_dest = $Connection->db->prepare($query_dest);
239 279
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 280
 		try {
241
-			if ($globalTransaction) $Connection->db->beginTransaction();
281
+			if ($globalTransaction) {
282
+				$Connection->db->beginTransaction();
283
+			}
242 284
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 285
 			//$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']);
244
-				if ($values['UserString4'] == 'M') $type = 'military';
245
-				else $type = null;
286
+				if ($values['UserString4'] == 'M') {
287
+					$type = 'military';
288
+				} else {
289
+					$type = null;
290
+				}
246 291
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 292
 				$sth_dest->execute($query_dest_values);
248 293
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -250,7 +295,9 @@  discard block
 block discarded – undo
250 295
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 296
 				}
252 297
             		}
253
-			if ($globalTransaction) $Connection->db->commit();
298
+			if ($globalTransaction) {
299
+				$Connection->db->commit();
300
+			}
254 301
 		} catch(PDOException $e) {
255 302
 			return "error : ".$e->getMessage();
256 303
 		}
@@ -287,7 +334,9 @@  discard block
 block discarded – undo
287 334
 			$Connection = new Connection();
288 335
 			$sth_dest = $Connection->db->prepare($query_dest);
289 336
 			try {
290
-				if ($globalTransaction) $Connection->db->beginTransaction();
337
+				if ($globalTransaction) {
338
+					$Connection->db->beginTransaction();
339
+				}
291 340
             			while (!feof($fh)) {
292 341
             				$values = array();
293 342
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -298,7 +347,9 @@  discard block
 block discarded – undo
298 347
             				// Check if we can find ICAO, else set it to GLID
299 348
             				$aircraft_name_split = explode(' ',$aircraft_name);
300 349
             				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
350
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
351
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
352
+            				}
302 353
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303 354
             				$sth_search = $Connection->db->prepare($query_search);
304 355
 					try {
@@ -311,7 +362,9 @@  discard block
 block discarded – undo
311 362
 					} catch(PDOException $e) {
312 363
 						return "error : ".$e->getMessage();
313 364
 					}
314
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
365
+					if (!isset($values['ICAOTypeCode'])) {
366
+						$values['ICAOTypeCode'] = 'GLID';
367
+					}
315 368
 					// Add data to db
316 369
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 370
 						//$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']);
@@ -320,7 +373,9 @@  discard block
 block discarded – undo
320 373
 						$sth_dest->execute($query_dest_values);
321 374
 					}
322 375
 				}
323
-				if ($globalTransaction) $Connection->db->commit();
376
+				if ($globalTransaction) {
377
+					$Connection->db->commit();
378
+				}
324 379
 			} catch(PDOException $e) {
325 380
 				return "error : ".$e->getMessage();
326 381
 			}
@@ -356,7 +411,9 @@  discard block
 block discarded – undo
356 411
 			$Connection = new Connection();
357 412
 			$sth_dest = $Connection->db->prepare($query_dest);
358 413
 			try {
359
-				if ($globalTransaction) $Connection->db->beginTransaction();
414
+				if ($globalTransaction) {
415
+					$Connection->db->beginTransaction();
416
+				}
360 417
 				$tmp = fgetcsv($fh,9999,',',"'");
361 418
             			while (!feof($fh)) {
362 419
             				$line = fgetcsv($fh,9999,',',"'");
@@ -370,13 +427,17 @@  discard block
 block discarded – undo
370 427
             				// Check if we can find ICAO, else set it to GLID
371 428
             				$aircraft_name_split = explode(' ',$aircraft_name);
372 429
             				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
430
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
431
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
432
+            				}
374 433
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375 434
             				$sth_search = $Connection->db->prepare($query_search);
376 435
 					try {
377 436
                                     		$sth_search->execute();
378 437
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
438
+	            				if (isset($result['icao']) && $result['icao'] != '') {
439
+	            					$values['ICAOTypeCode'] = $result['icao'];
440
+	            				}
380 441
 					} catch(PDOException $e) {
381 442
 						return "error : ".$e->getMessage();
382 443
 					}
@@ -389,7 +450,9 @@  discard block
 block discarded – undo
389 450
 						$sth_dest->execute($query_dest_values);
390 451
 					}
391 452
 				}
392
-				if ($globalTransaction) $Connection->db->commit();
453
+				if ($globalTransaction) {
454
+					$Connection->db->commit();
455
+				}
393 456
 			} catch(PDOException $e) {
394 457
 				return "error : ".$e->getMessage();
395 458
 			}
@@ -428,7 +491,9 @@  discard block
 block discarded – undo
428 491
 			$sth_dest = $Connection->db->prepare($query_dest);
429 492
 			$sth_modes = $Connection->db->prepare($query_modes);
430 493
 			try {
431
-				if ($globalTransaction) $Connection->db->beginTransaction();
494
+				if ($globalTransaction) {
495
+					$Connection->db->beginTransaction();
496
+				}
432 497
 				$tmp = fgetcsv($fh,9999,',','"');
433 498
             			while (!feof($fh)) {
434 499
             				$line = fgetcsv($fh,9999,',','"');
@@ -438,16 +503,22 @@  discard block
 block discarded – undo
438 503
             				    $values['registration'] = $line[0];
439 504
             				    $values['base'] = $line[4];
440 505
             				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+            				    if ($line[6] == '') {
507
+            				    	$values['date_first_reg'] = null;
508
+            				    } else {
509
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
510
+					    }
443 511
 					    $values['cancel'] = $line[7];
444 512
 					} elseif ($country == 'EI') {
445 513
 					    // TODO : add modeS & reg to aircraft_modes
446 514
             				    $values['registration'] = $line[0];
447 515
             				    $values['base'] = $line[3];
448 516
             				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
517
+            				    if ($line[1] == '') {
518
+            				    	$values['date_first_reg'] = null;
519
+            				    } else {
520
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
521
+					    }
451 522
 					    $values['cancel'] = '';
452 523
 					    $values['modes'] = $line[7];
453 524
 					    $values['icao'] = $line[8];
@@ -466,16 +537,22 @@  discard block
 block discarded – undo
466 537
             				    $values['registration'] = $line[3];
467 538
             				    $values['base'] = null;
468 539
             				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
540
+            				    if ($line[18] == '') {
541
+            				    	$values['date_first_reg'] = null;
542
+            				    } else {
543
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
544
+					    }
471 545
 					    $values['cancel'] = '';
472 546
 					} elseif ($country == 'VH') {
473 547
 					    // TODO : add modeS & reg to aircraft_modes
474 548
             				    $values['registration'] = $line[0];
475 549
             				    $values['base'] = null;
476 550
             				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
551
+            				    if ($line[28] == '') {
552
+            				    	$values['date_first_reg'] = null;
553
+            				    } else {
554
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
555
+					    }
479 556
 
480 557
 					    $values['cancel'] = $line[39];
481 558
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -494,29 +571,41 @@  discard block
 block discarded – undo
494 571
             				    $values['registration'] = $line[0];
495 572
             				    $values['base'] = null;
496 573
             				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
574
+            				    if ($line[7] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
578
+					    }
499 579
 					    $values['cancel'] = '';
500 580
 					} elseif ($country == 'PP') {
501 581
             				    $values['registration'] = $line[0];
502 582
             				    $values['base'] = null;
503 583
             				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
584
+            				    if ($line[6] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
588
+					    }
506 589
 					    $values['cancel'] = $line[7];
507 590
 					} elseif ($country == 'E7') {
508 591
             				    $values['registration'] = $line[0];
509 592
             				    $values['base'] = null;
510 593
             				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
594
+            				    if ($line[5] == '') {
595
+            				    	$values['date_first_reg'] = null;
596
+            				    } else {
597
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
598
+					    }
513 599
 					    $values['cancel'] = '';
514 600
 					} elseif ($country == '8Q') {
515 601
             				    $values['registration'] = $line[0];
516 602
             				    $values['base'] = null;
517 603
             				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
604
+            				    if ($line[7] == '') {
605
+            				    	$values['date_first_reg'] = null;
606
+            				    } else {
607
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
608
+					    }
520 609
 					    $values['cancel'] = '';
521 610
 					} elseif ($country == 'ZK') {
522 611
             				    $values['registration'] = $line[0];
@@ -561,7 +650,9 @@  discard block
 block discarded – undo
561 650
 						$sth_modes->execute($query_modes_values);
562 651
 					}
563 652
 				}
564
-				if ($globalTransaction) $Connection->db->commit();
653
+				if ($globalTransaction) {
654
+					$Connection->db->commit();
655
+				}
565 656
 			} catch(PDOException $e) {
566 657
 				return "error : ".$e->getMessage();
567 658
 			}
@@ -697,25 +788,45 @@  discard block
 block discarded – undo
697 788
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
698 789
 		$Connection = new Connection();
699 790
 		$sth_dest = $Connection->db->prepare($query_dest);
700
-		if ($globalTransaction) $Connection->db->beginTransaction();
791
+		if ($globalTransaction) {
792
+			$Connection->db->beginTransaction();
793
+		}
701 794
   
702 795
 		$i = 0;
703 796
 		while($row = sparql_fetch_array($result))
704 797
 		{
705 798
 			if ($i >= 1) {
706 799
 			//print_r($row);
707
-			if (!isset($row['iata'])) $row['iata'] = '';
708
-			if (!isset($row['icao'])) $row['icao'] = '';
709
-			if (!isset($row['type'])) $row['type'] = '';
710
-			if (!isset($row['altitude'])) $row['altitude'] = '';
800
+			if (!isset($row['iata'])) {
801
+				$row['iata'] = '';
802
+			}
803
+			if (!isset($row['icao'])) {
804
+				$row['icao'] = '';
805
+			}
806
+			if (!isset($row['type'])) {
807
+				$row['type'] = '';
808
+			}
809
+			if (!isset($row['altitude'])) {
810
+				$row['altitude'] = '';
811
+			}
711 812
 			if (isset($row['city_bis'])) {
712 813
 				$row['city'] = $row['city_bis'];
713 814
 			}
714
-			if (!isset($row['city'])) $row['city'] = '';
715
-			if (!isset($row['country'])) $row['country'] = '';
716
-			if (!isset($row['homepage'])) $row['homepage'] = '';
717
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
718
-			if (!isset($row['name'])) continue;
815
+			if (!isset($row['city'])) {
816
+				$row['city'] = '';
817
+			}
818
+			if (!isset($row['country'])) {
819
+				$row['country'] = '';
820
+			}
821
+			if (!isset($row['homepage'])) {
822
+				$row['homepage'] = '';
823
+			}
824
+			if (!isset($row['wikipedia_page'])) {
825
+				$row['wikipedia_page'] = '';
826
+			}
827
+			if (!isset($row['name'])) {
828
+				continue;
829
+			}
719 830
 			if (!isset($row['image'])) {
720 831
 				$row['image'] = '';
721 832
 				$row['image_thumb'] = '';
@@ -771,7 +882,9 @@  discard block
 block discarded – undo
771 882
 
772 883
 			$i++;
773 884
 		}
774
-		if ($globalTransaction) $Connection->db->commit();
885
+		if ($globalTransaction) {
886
+			$Connection->db->commit();
887
+		}
775 888
 		/*
776 889
 		echo "Delete duplicate rows...\n";
777 890
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -814,7 +927,9 @@  discard block
 block discarded – undo
814 927
 		$delimiter = ',';
815 928
 		$out_file = $tmp_dir.'airports.csv';
816 929
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
817
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
930
+		if (!file_exists($out_file) || !is_readable($out_file)) {
931
+			return FALSE;
932
+		}
818 933
 		echo "Add data from ourairports.com...\n";
819 934
 
820 935
 		$header = NULL;
@@ -824,8 +939,9 @@  discard block
 block discarded – undo
824 939
 			//$Connection->db->beginTransaction();
825 940
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 941
 			{
827
-				if(!$header) $header = $row;
828
-				else {
942
+				if(!$header) {
943
+					$header = $row;
944
+				} else {
829 945
 					$data = array();
830 946
 					$data = array_combine($header, $row);
831 947
 					try {
@@ -866,7 +982,9 @@  discard block
 block discarded – undo
866 982
 		echo "Download data from another free database...\n";
867 983
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868 984
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
869
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
985
+		if (!file_exists($out_file) || !is_readable($out_file)) {
986
+			return FALSE;
987
+		}
870 988
 		update_db::unzip($out_file);
871 989
 		$header = NULL;
872 990
 		echo "Add data from another free database...\n";
@@ -877,8 +995,9 @@  discard block
 block discarded – undo
877 995
 			//$Connection->db->beginTransaction();
878 996
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 997
 			{
880
-				if(!$header) $header = $row;
881
-				else {
998
+				if(!$header) {
999
+					$header = $row;
1000
+				} else {
882 1001
 					$data = $row;
883 1002
 
884 1003
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1047,7 +1166,9 @@  discard block
 block discarded – undo
1047 1166
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1048 1167
 		{
1049 1168
 			$i = 0;
1050
-			if ($globalTransaction) $Connection->db->beginTransaction();
1169
+			if ($globalTransaction) {
1170
+				$Connection->db->beginTransaction();
1171
+			}
1051 1172
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1052 1173
 			{
1053 1174
 				if ($i > 0) {
@@ -1060,7 +1181,9 @@  discard block
 block discarded – undo
1060 1181
 					}
1061 1182
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1062 1183
 					if (!empty($result_search)) {
1063
-						if ($globalDebug) echo '.';
1184
+						if ($globalDebug) {
1185
+							echo '.';
1186
+						}
1064 1187
 							//if ($globalDBdriver == 'mysql') {
1065 1188
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1066 1189
 							//} else {
@@ -1082,8 +1205,12 @@  discard block
 block discarded – undo
1082 1205
 						}
1083 1206
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1084 1207
 						if (!empty($result_search_mfr)) {
1085
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1086
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1208
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1209
+								$data[16] = $data[23];
1210
+							}
1211
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1212
+								$data[16] = $data[15];
1213
+							}
1087 1214
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1215
 							try {
1089 1216
 								$sthf = $Connection->db->prepare($queryf);
@@ -1094,7 +1221,9 @@  discard block
 block discarded – undo
1094 1221
 						}
1095 1222
 					}
1096 1223
 					if (strtotime($data[29]) > time()) {
1097
-						if ($globalDebug) echo 'i';
1224
+						if ($globalDebug) {
1225
+							echo 'i';
1226
+						}
1098 1227
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1228
 						try {
1100 1229
 							$sth = $Connection->db->prepare($query);
@@ -1105,13 +1234,19 @@  discard block
 block discarded – undo
1105 1234
 					}
1106 1235
 				}
1107 1236
 				if ($i % 90 == 0) {
1108
-					if ($globalTransaction) $Connection->db->commit();
1109
-					if ($globalTransaction) $Connection->db->beginTransaction();
1237
+					if ($globalTransaction) {
1238
+						$Connection->db->commit();
1239
+					}
1240
+					if ($globalTransaction) {
1241
+						$Connection->db->beginTransaction();
1242
+					}
1110 1243
 				}
1111 1244
 				$i++;
1112 1245
 			}
1113 1246
 			fclose($handle);
1114
-			if ($globalTransaction) $Connection->db->commit();
1247
+			if ($globalTransaction) {
1248
+				$Connection->db->commit();
1249
+			}
1115 1250
 		}
1116 1251
 		return '';
1117 1252
 	}
@@ -1131,11 +1266,15 @@  discard block
 block discarded – undo
1131 1266
 		if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE)
1132 1267
 		{
1133 1268
 			$i = 0;
1134
-			if ($globalTransaction) $Connection->db->beginTransaction();
1269
+			if ($globalTransaction) {
1270
+				$Connection->db->beginTransaction();
1271
+			}
1135 1272
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1136 1273
 			{
1137 1274
 				if ($i > 0) {
1138
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1275
+					if ($data[1] == 'NULL') {
1276
+						$data[1] = $data[0];
1277
+					}
1139 1278
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1279
 					try {
1141 1280
 						$sth = $Connection->db->prepare($query);
@@ -1147,7 +1286,9 @@  discard block
 block discarded – undo
1147 1286
 				$i++;
1148 1287
 			}
1149 1288
 			fclose($handle);
1150
-			if ($globalTransaction) $Connection->db->commit();
1289
+			if ($globalTransaction) {
1290
+				$Connection->db->commit();
1291
+			}
1151 1292
 		}
1152 1293
 		return '';
1153 1294
 	}
@@ -1179,11 +1320,15 @@  discard block
 block discarded – undo
1179 1320
 		if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE)
1180 1321
 		{
1181 1322
 			$i = 0;
1182
-			if ($globalTransaction) $Connection->db->beginTransaction();
1323
+			if ($globalTransaction) {
1324
+				$Connection->db->beginTransaction();
1325
+			}
1183 1326
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1184 1327
 			{
1185 1328
 				if ($i > 0) {
1186
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1329
+					if ($data[1] == 'NULL') {
1330
+						$data[1] = $data[0];
1331
+					}
1187 1332
 					$query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1188 1333
 					try {
1189 1334
 						$sth = $Connection->db->prepare($query);
@@ -1195,7 +1340,9 @@  discard block
 block discarded – undo
1195 1340
 				$i++;
1196 1341
 			}
1197 1342
 			fclose($handle);
1198
-			if ($globalTransaction) $Connection->db->commit();
1343
+			if ($globalTransaction) {
1344
+				$Connection->db->commit();
1345
+			}
1199 1346
 		}
1200 1347
 		/*
1201 1348
 		$query = "UNLOCK TABLES";
@@ -1225,7 +1372,9 @@  discard block
 block discarded – undo
1225 1372
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1226 1373
 		{
1227 1374
 			$i = 0;
1228
-			if ($globalTransaction) $Connection->db->beginTransaction();
1375
+			if ($globalTransaction) {
1376
+				$Connection->db->beginTransaction();
1377
+			}
1229 1378
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1230 1379
 			{
1231 1380
 				if ($i > 0) {
@@ -1241,7 +1390,9 @@  discard block
 block discarded – undo
1241 1390
 				$i++;
1242 1391
 			}
1243 1392
 			fclose($handle);
1244
-			if ($globalTransaction) $Connection->db->commit();
1393
+			if ($globalTransaction) {
1394
+				$Connection->db->commit();
1395
+			}
1245 1396
 		}
1246 1397
 		return '';
1247 1398
         }
@@ -1261,7 +1412,9 @@  discard block
 block discarded – undo
1261 1412
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1262 1413
 		{
1263 1414
 			$i = 0;
1264
-			if ($globalTransaction) $Connection->db->beginTransaction();
1415
+			if ($globalTransaction) {
1416
+				$Connection->db->beginTransaction();
1417
+			}
1265 1418
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1266 1419
 			{
1267 1420
 				if ($i > 0) {
@@ -1271,19 +1424,25 @@  discard block
 block discarded – undo
1271 1424
 						$sth = $Connection->db->prepare($query);
1272 1425
 						$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'));
1273 1426
 					} catch(PDOException $e) {
1274
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1427
+						if ($globalDebug) {
1428
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1429
+						}
1275 1430
 						die();
1276 1431
 					}
1277 1432
 				}
1278 1433
 				if ($globalTransaction && $i % 2000 == 0) {
1279 1434
 					$Connection->db->commit();
1280
-					if ($globalDebug) echo '.';
1435
+					if ($globalDebug) {
1436
+						echo '.';
1437
+					}
1281 1438
 					$Connection->db->beginTransaction();
1282 1439
 				}
1283 1440
 				$i++;
1284 1441
 			}
1285 1442
 			fclose($handle);
1286
-			if ($globalTransaction) $Connection->db->commit();
1443
+			if ($globalTransaction) {
1444
+				$Connection->db->commit();
1445
+			}
1287 1446
 		}
1288 1447
 		return '';
1289 1448
 	}
@@ -1303,7 +1462,9 @@  discard block
 block discarded – undo
1303 1462
 		if (($handle = fopen($tmp_dir.'block.tsv', 'r')) !== FALSE)
1304 1463
 		{
1305 1464
 			$i = 0;
1306
-			if ($globalTransaction) $Connection->db->beginTransaction();
1465
+			if ($globalTransaction) {
1466
+				$Connection->db->beginTransaction();
1467
+			}
1307 1468
 			while (($data = fgets($handle, 1000)) !== FALSE)
1308 1469
 			{
1309 1470
 				$query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)';
@@ -1311,18 +1472,24 @@  discard block
 block discarded – undo
1311 1472
 					$sth = $Connection->db->prepare($query);
1312 1473
 					$sth->execute(array(':callSign' => trim($data),':source' => 'website_fam'));
1313 1474
 				} catch(PDOException $e) {
1314
-					if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data;
1475
+					if ($globalDebug) {
1476
+						echo "error: ".$e->getMessage()." - data: ".$data;
1477
+					}
1315 1478
 					die();
1316 1479
 				}
1317 1480
 				if ($globalTransaction && $i % 2000 == 0) {
1318 1481
 					$Connection->db->commit();
1319
-					if ($globalDebug) echo '.';
1482
+					if ($globalDebug) {
1483
+						echo '.';
1484
+					}
1320 1485
 					$Connection->db->beginTransaction();
1321 1486
 				}
1322 1487
 				$i++;
1323 1488
 			}
1324 1489
 			fclose($handle);
1325
-			if ($globalTransaction) $Connection->db->commit();
1490
+			if ($globalTransaction) {
1491
+				$Connection->db->commit();
1492
+			}
1326 1493
 		}
1327 1494
 		return '';
1328 1495
         }
@@ -1347,7 +1514,9 @@  discard block
 block discarded – undo
1347 1514
 			$i = 0;
1348 1515
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1349 1516
 			//$Connection->db->beginTransaction();
1350
-			if ($globalTransaction) $Connection->db->beginTransaction();
1517
+			if ($globalTransaction) {
1518
+				$Connection->db->beginTransaction();
1519
+			}
1351 1520
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1352 1521
 			{
1353 1522
 				if ($i > 0) {
@@ -1363,7 +1532,9 @@  discard block
 block discarded – undo
1363 1532
 				$i++;
1364 1533
 			}
1365 1534
 			fclose($handle);
1366
-			if ($globalTransaction) $Connection->db->commit();
1535
+			if ($globalTransaction) {
1536
+				$Connection->db->commit();
1537
+			}
1367 1538
 		}
1368 1539
 		return '';
1369 1540
         }
@@ -1383,7 +1554,9 @@  discard block
 block discarded – undo
1383 1554
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1384 1555
 		{
1385 1556
 			$i = 0;
1386
-			if ($globalTransaction) $Connection->db->beginTransaction();
1557
+			if ($globalTransaction) {
1558
+				$Connection->db->beginTransaction();
1559
+			}
1387 1560
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1388 1561
 			{
1389 1562
 				if ($i > 0) {
@@ -1400,7 +1573,9 @@  discard block
 block discarded – undo
1400 1573
 				$i++;
1401 1574
 			}
1402 1575
 			fclose($handle);
1403
-			if ($globalTransaction) $Connection->db->commit();
1576
+			if ($globalTransaction) {
1577
+				$Connection->db->commit();
1578
+			}
1404 1579
 		}
1405 1580
 		return '';
1406 1581
 	}
@@ -1419,7 +1594,9 @@  discard block
 block discarded – undo
1419 1594
 		$Connection = new Connection();
1420 1595
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1421 1596
 		{
1422
-			if ($globalTransaction) $Connection->db->beginTransaction();
1597
+			if ($globalTransaction) {
1598
+				$Connection->db->beginTransaction();
1599
+			}
1423 1600
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1424 1601
 			{
1425 1602
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1434,7 +1611,9 @@  discard block
 block discarded – undo
1434 1611
 				}
1435 1612
 			}
1436 1613
 			fclose($handle);
1437
-			if ($globalTransaction) $Connection->db->commit();
1614
+			if ($globalTransaction) {
1615
+				$Connection->db->commit();
1616
+			}
1438 1617
 		}
1439 1618
 		return '';
1440 1619
         }
@@ -1510,9 +1689,14 @@  discard block
 block discarded – undo
1510 1689
 				if ($i > 0 && $data[0] != '') {
1511 1690
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1512 1691
 					$period = str_replace(',','',$data[14]);
1513
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1514
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1515
-					else $launch_date = NULL;
1692
+					if (!empty($period) && strpos($period,'days')) {
1693
+						$period = str_replace(' days','',$period)*24*60;
1694
+					}
1695
+					if ($data[18] != '') {
1696
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1697
+					} else {
1698
+						$launch_date = NULL;
1699
+					}
1516 1700
 					$data = array_map(function($value) {
1517 1701
 						return trim($value) === '' ? null : $value;
1518 1702
 					}, $data);
@@ -1875,7 +2059,9 @@  discard block
 block discarded – undo
1875 2059
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1876 2060
 		{
1877 2061
 			$i = 0;
1878
-			if ($globalTransaction) $Connection->db->beginTransaction();
2062
+			if ($globalTransaction) {
2063
+				$Connection->db->beginTransaction();
2064
+			}
1879 2065
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1880 2066
 			{
1881 2067
 				$i++;
@@ -1903,7 +2089,9 @@  discard block
 block discarded – undo
1903 2089
 				}
1904 2090
 			}
1905 2091
 			fclose($handle);
1906
-			if ($globalTransaction) $Connection->db->commit();
2092
+			if ($globalTransaction) {
2093
+				$Connection->db->commit();
2094
+			}
1907 2095
 		}
1908 2096
 		return '';
1909 2097
 	}
@@ -1946,7 +2134,9 @@  discard block
 block discarded – undo
1946 2134
 		$Connection = new Connection();
1947 2135
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1948 2136
 		{
1949
-			if ($globalTransaction) $Connection->db->beginTransaction();
2137
+			if ($globalTransaction) {
2138
+				$Connection->db->beginTransaction();
2139
+			}
1950 2140
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1951 2141
 			{
1952 2142
 				if(count($row) > 1) {
@@ -1960,7 +2150,9 @@  discard block
 block discarded – undo
1960 2150
 				}
1961 2151
 			}
1962 2152
 			fclose($handle);
1963
-			if ($globalTransaction) $Connection->db->commit();
2153
+			if ($globalTransaction) {
2154
+				$Connection->db->commit();
2155
+			}
1964 2156
 		}
1965 2157
 		return '';
1966 2158
         }
@@ -1980,8 +2172,9 @@  discard block
 block discarded – undo
1980 2172
 	        }
1981 2173
 
1982 2174
 
1983
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1984
-		else {
2175
+		if ($globalDBdriver == 'mysql') {
2176
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2177
+		} else {
1985 2178
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1986 2179
 			$query = "CREATE EXTENSION postgis";
1987 2180
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -2000,7 +2193,9 @@  discard block
 block discarded – undo
2000 2193
 		global $tmp_dir, $globalDebug;
2001 2194
 		include_once('class.create_db.php');
2002 2195
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
2003
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2196
+		if ($globalDebug) {
2197
+			echo "NOTAM from FlightAirMap website : Download...";
2198
+		}
2004 2199
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
2005 2200
 		$error = '';
2006 2201
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
@@ -2010,20 +2205,34 @@  discard block
 block discarded – undo
2010 2205
 				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
2011 2206
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
2012 2207
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
2013
-						if ($globalDebug) echo "Gunzip...";
2208
+						if ($globalDebug) {
2209
+							echo "Gunzip...";
2210
+						}
2014 2211
 						update_db::gunzip($tmp_dir.'notam.txt.gz');
2015
-						if ($globalDebug) echo "Add to DB...";
2212
+						if ($globalDebug) {
2213
+							echo "Add to DB...";
2214
+						}
2016 2215
 						//$error = create_db::import_file($tmp_dir.'notam.sql');
2017 2216
 						$NOTAM = new NOTAM();
2018 2217
 						$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
2019 2218
 						update_db::insert_notam_version($notam_md5);
2020
-					} else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2021
-				} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2022
-			} elseif ($globalDebug) echo "No new version.";
2023
-		} else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2219
+					} else {
2220
+						$error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2221
+					}
2222
+				} else {
2223
+					$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2224
+				}
2225
+			} elseif ($globalDebug) {
2226
+				echo "No new version.";
2227
+			}
2228
+		} else {
2229
+			$error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2230
+		}
2024 2231
 		if ($error != '') {
2025 2232
 			return $error;
2026
-		} elseif ($globalDebug) echo "Done\n";
2233
+		} elseif ($globalDebug) {
2234
+			echo "Done\n";
2235
+		}
2027 2236
 		return '';
2028 2237
 	}
2029 2238
 
@@ -2078,68 +2287,114 @@  discard block
 block discarded – undo
2078 2287
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
2079 2288
 		if (extension_loaded('zip')) {
2080 2289
 			if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
2081
-				if ($globalDebug) echo "Unzip...";
2290
+				if ($globalDebug) {
2291
+					echo "Unzip...";
2292
+				}
2082 2293
 				update_db::unzip($tmp_dir.'ivae_feb2013.zip');
2083
-				if ($globalDebug) echo "Add to DB...";
2294
+				if ($globalDebug) {
2295
+					echo "Add to DB...";
2296
+				}
2084 2297
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2085
-				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2298
+				if ($globalDebug) {
2299
+					echo "Copy airlines logos to airlines images directory...";
2300
+				}
2086 2301
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2087
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2088
-				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2089
-			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2090
-		} else $error = "ZIP module not loaded but required for IVAO.";
2302
+					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2303
+						$error = "Failed to copy airlines logo.";
2304
+					}
2305
+				} else {
2306
+					$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2307
+				}
2308
+			} else {
2309
+				$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2310
+			}
2311
+		} else {
2312
+			$error = "ZIP module not loaded but required for IVAO.";
2313
+		}
2091 2314
 		if ($error != '') {
2092 2315
 			return $error;
2093
-		} elseif ($globalDebug) echo "Done\n";
2316
+		} elseif ($globalDebug) {
2317
+			echo "Done\n";
2318
+		}
2094 2319
 		return '';
2095 2320
 	}
2096 2321
 
2097 2322
 	public static function update_routes() {
2098 2323
 		global $tmp_dir, $globalDebug;
2099 2324
 		$error = '';
2100
-		if ($globalDebug) echo "Routes : Download...";
2325
+		if ($globalDebug) {
2326
+			echo "Routes : Download...";
2327
+		}
2101 2328
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2102 2329
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2103
-			if ($globalDebug) echo "Gunzip...";
2330
+			if ($globalDebug) {
2331
+				echo "Gunzip...";
2332
+			}
2104 2333
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
2105
-			if ($globalDebug) echo "Add to DB...";
2334
+			if ($globalDebug) {
2335
+				echo "Add to DB...";
2336
+			}
2106 2337
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
2107
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2338
+		} else {
2339
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2340
+		}
2108 2341
 		if ($error != '') {
2109 2342
 			return $error;
2110
-		} elseif ($globalDebug) echo "Done\n";
2343
+		} elseif ($globalDebug) {
2344
+			echo "Done\n";
2345
+		}
2111 2346
 		return '';
2112 2347
 	}
2113 2348
 	public static function update_oneworld() {
2114 2349
 		global $tmp_dir, $globalDebug;
2115 2350
 		$error = '';
2116
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2351
+		if ($globalDebug) {
2352
+			echo "Schedules Oneworld : Download...";
2353
+		}
2117 2354
 		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2118 2355
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2119
-			if ($globalDebug) echo "Gunzip...";
2356
+			if ($globalDebug) {
2357
+				echo "Gunzip...";
2358
+			}
2120 2359
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
2121
-			if ($globalDebug) echo "Add to DB...";
2360
+			if ($globalDebug) {
2361
+				echo "Add to DB...";
2362
+			}
2122 2363
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
2123
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2364
+		} else {
2365
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2366
+		}
2124 2367
 		if ($error != '') {
2125 2368
 			return $error;
2126
-		} elseif ($globalDebug) echo "Done\n";
2369
+		} elseif ($globalDebug) {
2370
+			echo "Done\n";
2371
+		}
2127 2372
 		return '';
2128 2373
 	}
2129 2374
 	public static function update_skyteam() {
2130 2375
 		global $tmp_dir, $globalDebug;
2131 2376
 		$error = '';
2132
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2377
+		if ($globalDebug) {
2378
+			echo "Schedules Skyteam : Download...";
2379
+		}
2133 2380
 		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2134 2381
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2135
-			if ($globalDebug) echo "Gunzip...";
2382
+			if ($globalDebug) {
2383
+				echo "Gunzip...";
2384
+			}
2136 2385
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
2137
-			if ($globalDebug) echo "Add to DB...";
2386
+			if ($globalDebug) {
2387
+				echo "Add to DB...";
2388
+			}
2138 2389
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
2139
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2390
+		} else {
2391
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2392
+		}
2140 2393
 		if ($error != '') {
2141 2394
 			return $error;
2142
-		} elseif ($globalDebug) echo "Done\n";
2395
+		} elseif ($globalDebug) {
2396
+			echo "Done\n";
2397
+		}
2143 2398
 		return '';
2144 2399
 	}
2145 2400
 	public static function update_ModeS() {
@@ -2156,340 +2411,590 @@  discard block
 block discarded – undo
2156 2411
 			exit;
2157 2412
 		} elseif ($globalDebug) echo "Done\n";
2158 2413
 */
2159
-		if ($globalDebug) echo "Modes : Download...";
2160
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2414
+		if ($globalDebug) {
2415
+			echo "Modes : Download...";
2416
+		}
2417
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2161 2418
 		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2162 2419
 
2163 2420
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2164 2421
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2165
-			if ($globalDebug) echo "Unzip...";
2166
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2422
+			if ($globalDebug) {
2423
+				echo "Unzip...";
2424
+			}
2425
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2167 2426
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2168
-			if ($globalDebug) echo "Add to DB...";
2427
+			if ($globalDebug) {
2428
+				echo "Add to DB...";
2429
+			}
2169 2430
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2170 2431
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2171
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2432
+		} else {
2433
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2434
+		}
2172 2435
 		if ($error != '') {
2173 2436
 			return $error;
2174
-		} elseif ($globalDebug) echo "Done\n";
2437
+		} elseif ($globalDebug) {
2438
+			echo "Done\n";
2439
+		}
2175 2440
 		return '';
2176 2441
 	}
2177 2442
 
2178 2443
 	public static function update_ModeS_faa() {
2179 2444
 		global $tmp_dir, $globalDebug;
2180
-		if ($globalDebug) echo "Modes FAA: Download...";
2445
+		if ($globalDebug) {
2446
+			echo "Modes FAA: Download...";
2447
+		}
2181 2448
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2182 2449
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2183
-			if ($globalDebug) echo "Unzip...";
2450
+			if ($globalDebug) {
2451
+				echo "Unzip...";
2452
+			}
2184 2453
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2185
-			if ($globalDebug) echo "Add to DB...";
2454
+			if ($globalDebug) {
2455
+				echo "Add to DB...";
2456
+			}
2186 2457
 			$error = update_db::modes_faa();
2187
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2458
+		} else {
2459
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2460
+		}
2188 2461
 		if ($error != '') {
2189 2462
 			return $error;
2190
-		} elseif ($globalDebug) echo "Done\n";
2463
+		} elseif ($globalDebug) {
2464
+			echo "Done\n";
2465
+		}
2191 2466
 		return '';
2192 2467
 	}
2193 2468
 
2194 2469
 	public static function update_ModeS_flarm() {
2195 2470
 		global $tmp_dir, $globalDebug;
2196
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2471
+		if ($globalDebug) {
2472
+			echo "Modes Flarmnet: Download...";
2473
+		}
2197 2474
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2198 2475
 		if (file_exists($tmp_dir.'data.fln')) {
2199
-			if ($globalDebug) echo "Add to DB...";
2476
+			if ($globalDebug) {
2477
+				echo "Add to DB...";
2478
+			}
2200 2479
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2201
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2480
+		} else {
2481
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2482
+		}
2202 2483
 		if ($error != '') {
2203 2484
 			return $error;
2204
-		} elseif ($globalDebug) echo "Done\n";
2485
+		} elseif ($globalDebug) {
2486
+			echo "Done\n";
2487
+		}
2205 2488
 		return '';
2206 2489
 	}
2207 2490
 
2208 2491
 	public static function update_ModeS_ogn() {
2209 2492
 		global $tmp_dir, $globalDebug;
2210
-		if ($globalDebug) echo "Modes OGN: Download...";
2493
+		if ($globalDebug) {
2494
+			echo "Modes OGN: Download...";
2495
+		}
2211 2496
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2212 2497
 		if (file_exists($tmp_dir.'ogn.csv')) {
2213
-			if ($globalDebug) echo "Add to DB...";
2498
+			if ($globalDebug) {
2499
+				echo "Add to DB...";
2500
+			}
2214 2501
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2215
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2502
+		} else {
2503
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2504
+		}
2216 2505
 		if ($error != '') {
2217 2506
 			return $error;
2218
-		} elseif ($globalDebug) echo "Done\n";
2507
+		} elseif ($globalDebug) {
2508
+			echo "Done\n";
2509
+		}
2219 2510
 		return '';
2220 2511
 	}
2221 2512
 
2222 2513
 	public static function update_owner() {
2223 2514
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2224 2515
 		
2225
-		if ($globalDebug) echo "Owner France: Download...";
2516
+		if ($globalDebug) {
2517
+			echo "Owner France: Download...";
2518
+		}
2226 2519
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2227 2520
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2228
-			if ($globalDebug) echo "Add to DB...";
2521
+			if ($globalDebug) {
2522
+				echo "Add to DB...";
2523
+			}
2229 2524
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2230
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2525
+		} else {
2526
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2527
+		}
2231 2528
 		if ($error != '') {
2232 2529
 			return $error;
2233
-		} elseif ($globalDebug) echo "Done\n";
2530
+		} elseif ($globalDebug) {
2531
+			echo "Done\n";
2532
+		}
2234 2533
 		
2235
-		if ($globalDebug) echo "Owner Ireland: Download...";
2534
+		if ($globalDebug) {
2535
+			echo "Owner Ireland: Download...";
2536
+		}
2236 2537
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2237 2538
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2238
-			if ($globalDebug) echo "Add to DB...";
2539
+			if ($globalDebug) {
2540
+				echo "Add to DB...";
2541
+			}
2239 2542
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2240
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2543
+		} else {
2544
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2545
+		}
2241 2546
 		if ($error != '') {
2242 2547
 			return $error;
2243
-		} elseif ($globalDebug) echo "Done\n";
2244
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2548
+		} elseif ($globalDebug) {
2549
+			echo "Done\n";
2550
+		}
2551
+		if ($globalDebug) {
2552
+			echo "Owner Switzerland: Download...";
2553
+		}
2245 2554
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2246 2555
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2247
-			if ($globalDebug) echo "Add to DB...";
2556
+			if ($globalDebug) {
2557
+				echo "Add to DB...";
2558
+			}
2248 2559
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2249
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2560
+		} else {
2561
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2562
+		}
2250 2563
 		if ($error != '') {
2251 2564
 			return $error;
2252
-		} elseif ($globalDebug) echo "Done\n";
2253
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2565
+		} elseif ($globalDebug) {
2566
+			echo "Done\n";
2567
+		}
2568
+		if ($globalDebug) {
2569
+			echo "Owner Czech Republic: Download...";
2570
+		}
2254 2571
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2255 2572
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2256
-			if ($globalDebug) echo "Add to DB...";
2573
+			if ($globalDebug) {
2574
+				echo "Add to DB...";
2575
+			}
2257 2576
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2258
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2577
+		} else {
2578
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2579
+		}
2259 2580
 		if ($error != '') {
2260 2581
 			return $error;
2261
-		} elseif ($globalDebug) echo "Done\n";
2262
-		if ($globalDebug) echo "Owner Australia: Download...";
2582
+		} elseif ($globalDebug) {
2583
+			echo "Done\n";
2584
+		}
2585
+		if ($globalDebug) {
2586
+			echo "Owner Australia: Download...";
2587
+		}
2263 2588
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2264 2589
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2265
-			if ($globalDebug) echo "Add to DB...";
2590
+			if ($globalDebug) {
2591
+				echo "Add to DB...";
2592
+			}
2266 2593
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2267
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2594
+		} else {
2595
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2596
+		}
2268 2597
 		if ($error != '') {
2269 2598
 			return $error;
2270
-		} elseif ($globalDebug) echo "Done\n";
2271
-		if ($globalDebug) echo "Owner Austria: Download...";
2599
+		} elseif ($globalDebug) {
2600
+			echo "Done\n";
2601
+		}
2602
+		if ($globalDebug) {
2603
+			echo "Owner Austria: Download...";
2604
+		}
2272 2605
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2273 2606
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2274
-			if ($globalDebug) echo "Add to DB...";
2607
+			if ($globalDebug) {
2608
+				echo "Add to DB...";
2609
+			}
2275 2610
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2276
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2611
+		} else {
2612
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2613
+		}
2277 2614
 		if ($error != '') {
2278 2615
 			return $error;
2279
-		} elseif ($globalDebug) echo "Done\n";
2280
-		if ($globalDebug) echo "Owner Chile: Download...";
2616
+		} elseif ($globalDebug) {
2617
+			echo "Done\n";
2618
+		}
2619
+		if ($globalDebug) {
2620
+			echo "Owner Chile: Download...";
2621
+		}
2281 2622
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2282 2623
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2283
-			if ($globalDebug) echo "Add to DB...";
2624
+			if ($globalDebug) {
2625
+				echo "Add to DB...";
2626
+			}
2284 2627
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2285
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2628
+		} else {
2629
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2630
+		}
2286 2631
 		if ($error != '') {
2287 2632
 			return $error;
2288
-		} elseif ($globalDebug) echo "Done\n";
2289
-		if ($globalDebug) echo "Owner Colombia: Download...";
2633
+		} elseif ($globalDebug) {
2634
+			echo "Done\n";
2635
+		}
2636
+		if ($globalDebug) {
2637
+			echo "Owner Colombia: Download...";
2638
+		}
2290 2639
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2291 2640
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2292
-			if ($globalDebug) echo "Add to DB...";
2641
+			if ($globalDebug) {
2642
+				echo "Add to DB...";
2643
+			}
2293 2644
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2294
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2645
+		} else {
2646
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2647
+		}
2295 2648
 		if ($error != '') {
2296 2649
 			return $error;
2297
-		} elseif ($globalDebug) echo "Done\n";
2298
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2650
+		} elseif ($globalDebug) {
2651
+			echo "Done\n";
2652
+		}
2653
+		if ($globalDebug) {
2654
+			echo "Owner Bosnia Herzegobina: Download...";
2655
+		}
2299 2656
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2300 2657
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2301
-			if ($globalDebug) echo "Add to DB...";
2658
+			if ($globalDebug) {
2659
+				echo "Add to DB...";
2660
+			}
2302 2661
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2303
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2662
+		} else {
2663
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2664
+		}
2304 2665
 		if ($error != '') {
2305 2666
 			return $error;
2306
-		} elseif ($globalDebug) echo "Done\n";
2307
-		if ($globalDebug) echo "Owner Brazil: Download...";
2667
+		} elseif ($globalDebug) {
2668
+			echo "Done\n";
2669
+		}
2670
+		if ($globalDebug) {
2671
+			echo "Owner Brazil: Download...";
2672
+		}
2308 2673
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2309 2674
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2310
-			if ($globalDebug) echo "Add to DB...";
2675
+			if ($globalDebug) {
2676
+				echo "Add to DB...";
2677
+			}
2311 2678
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2312
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2679
+		} else {
2680
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2681
+		}
2313 2682
 		if ($error != '') {
2314 2683
 			return $error;
2315
-		} elseif ($globalDebug) echo "Done\n";
2316
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2684
+		} elseif ($globalDebug) {
2685
+			echo "Done\n";
2686
+		}
2687
+		if ($globalDebug) {
2688
+			echo "Owner Cayman Islands: Download...";
2689
+		}
2317 2690
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2318 2691
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2319
-			if ($globalDebug) echo "Add to DB...";
2692
+			if ($globalDebug) {
2693
+				echo "Add to DB...";
2694
+			}
2320 2695
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2321
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2696
+		} else {
2697
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2698
+		}
2322 2699
 		if ($error != '') {
2323 2700
 			return $error;
2324
-		} elseif ($globalDebug) echo "Done\n";
2325
-		if ($globalDebug) echo "Owner Croatia: Download...";
2701
+		} elseif ($globalDebug) {
2702
+			echo "Done\n";
2703
+		}
2704
+		if ($globalDebug) {
2705
+			echo "Owner Croatia: Download...";
2706
+		}
2326 2707
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2327 2708
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2328
-			if ($globalDebug) echo "Add to DB...";
2709
+			if ($globalDebug) {
2710
+				echo "Add to DB...";
2711
+			}
2329 2712
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2330
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2713
+		} else {
2714
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2715
+		}
2331 2716
 		if ($error != '') {
2332 2717
 			return $error;
2333
-		} elseif ($globalDebug) echo "Done\n";
2334
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2718
+		} elseif ($globalDebug) {
2719
+			echo "Done\n";
2720
+		}
2721
+		if ($globalDebug) {
2722
+			echo "Owner Luxembourg: Download...";
2723
+		}
2335 2724
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2336 2725
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2337
-			if ($globalDebug) echo "Add to DB...";
2726
+			if ($globalDebug) {
2727
+				echo "Add to DB...";
2728
+			}
2338 2729
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2339
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2730
+		} else {
2731
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2732
+		}
2340 2733
 		if ($error != '') {
2341 2734
 			return $error;
2342
-		} elseif ($globalDebug) echo "Done\n";
2343
-		if ($globalDebug) echo "Owner Maldives: Download...";
2735
+		} elseif ($globalDebug) {
2736
+			echo "Done\n";
2737
+		}
2738
+		if ($globalDebug) {
2739
+			echo "Owner Maldives: Download...";
2740
+		}
2344 2741
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2345 2742
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2346
-			if ($globalDebug) echo "Add to DB...";
2743
+			if ($globalDebug) {
2744
+				echo "Add to DB...";
2745
+			}
2347 2746
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2348
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2747
+		} else {
2748
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2749
+		}
2349 2750
 		if ($error != '') {
2350 2751
 			return $error;
2351
-		} elseif ($globalDebug) echo "Done\n";
2352
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2752
+		} elseif ($globalDebug) {
2753
+			echo "Done\n";
2754
+		}
2755
+		if ($globalDebug) {
2756
+			echo "Owner New Zealand: Download...";
2757
+		}
2353 2758
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2354 2759
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2355
-			if ($globalDebug) echo "Add to DB...";
2760
+			if ($globalDebug) {
2761
+				echo "Add to DB...";
2762
+			}
2356 2763
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2357
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2764
+		} else {
2765
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2766
+		}
2358 2767
 		if ($error != '') {
2359 2768
 			return $error;
2360
-		} elseif ($globalDebug) echo "Done\n";
2361
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2769
+		} elseif ($globalDebug) {
2770
+			echo "Done\n";
2771
+		}
2772
+		if ($globalDebug) {
2773
+			echo "Owner Papua New Guinea: Download...";
2774
+		}
2362 2775
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2363 2776
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2364
-			if ($globalDebug) echo "Add to DB...";
2777
+			if ($globalDebug) {
2778
+				echo "Add to DB...";
2779
+			}
2365 2780
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2366
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2781
+		} else {
2782
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2783
+		}
2367 2784
 		if ($error != '') {
2368 2785
 			return $error;
2369
-		} elseif ($globalDebug) echo "Done\n";
2370
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2786
+		} elseif ($globalDebug) {
2787
+			echo "Done\n";
2788
+		}
2789
+		if ($globalDebug) {
2790
+			echo "Owner Slovakia: Download...";
2791
+		}
2371 2792
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2372 2793
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2373
-			if ($globalDebug) echo "Add to DB...";
2794
+			if ($globalDebug) {
2795
+				echo "Add to DB...";
2796
+			}
2374 2797
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2375
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2798
+		} else {
2799
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2800
+		}
2376 2801
 		if ($error != '') {
2377 2802
 			return $error;
2378
-		} elseif ($globalDebug) echo "Done\n";
2379
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2803
+		} elseif ($globalDebug) {
2804
+			echo "Done\n";
2805
+		}
2806
+		if ($globalDebug) {
2807
+			echo "Owner Ecuador: Download...";
2808
+		}
2380 2809
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2381 2810
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2382
-			if ($globalDebug) echo "Add to DB...";
2811
+			if ($globalDebug) {
2812
+				echo "Add to DB...";
2813
+			}
2383 2814
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2384
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2815
+		} else {
2816
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2817
+		}
2385 2818
 		if ($error != '') {
2386 2819
 			return $error;
2387
-		} elseif ($globalDebug) echo "Done\n";
2388
-		if ($globalDebug) echo "Owner Iceland: Download...";
2820
+		} elseif ($globalDebug) {
2821
+			echo "Done\n";
2822
+		}
2823
+		if ($globalDebug) {
2824
+			echo "Owner Iceland: Download...";
2825
+		}
2389 2826
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2390 2827
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2391
-			if ($globalDebug) echo "Add to DB...";
2828
+			if ($globalDebug) {
2829
+				echo "Add to DB...";
2830
+			}
2392 2831
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2393
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2832
+		} else {
2833
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2834
+		}
2394 2835
 		if ($error != '') {
2395 2836
 			return $error;
2396
-		} elseif ($globalDebug) echo "Done\n";
2397
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2837
+		} elseif ($globalDebug) {
2838
+			echo "Done\n";
2839
+		}
2840
+		if ($globalDebug) {
2841
+			echo "Owner Isle of Man: Download...";
2842
+		}
2398 2843
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2399 2844
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2400
-			if ($globalDebug) echo "Add to DB...";
2845
+			if ($globalDebug) {
2846
+				echo "Add to DB...";
2847
+			}
2401 2848
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2402
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2849
+		} else {
2850
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2851
+		}
2403 2852
 		if ($error != '') {
2404 2853
 			return $error;
2405
-		} elseif ($globalDebug) echo "Done\n";
2854
+		} elseif ($globalDebug) {
2855
+			echo "Done\n";
2856
+		}
2406 2857
 		if ($globalMasterSource) {
2407
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2858
+			if ($globalDebug) {
2859
+				echo "ModeS Netherlands: Download...";
2860
+			}
2408 2861
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2409 2862
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2410
-				if ($globalDebug) echo "Add to DB...";
2863
+				if ($globalDebug) {
2864
+					echo "Add to DB...";
2865
+				}
2411 2866
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2412
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2867
+			} else {
2868
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2869
+			}
2413 2870
 			if ($error != '') {
2414 2871
 				return $error;
2415
-			} elseif ($globalDebug) echo "Done\n";
2416
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2872
+			} elseif ($globalDebug) {
2873
+				echo "Done\n";
2874
+			}
2875
+			if ($globalDebug) {
2876
+				echo "ModeS Denmark: Download...";
2877
+			}
2417 2878
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2418 2879
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2419
-				if ($globalDebug) echo "Add to DB...";
2880
+				if ($globalDebug) {
2881
+					echo "Add to DB...";
2882
+				}
2420 2883
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2421
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2884
+			} else {
2885
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2886
+			}
2422 2887
 			if ($error != '') {
2423 2888
 				return $error;
2424
-			} elseif ($globalDebug) echo "Done\n";
2425
-		} elseif ($globalDebug) echo "Done\n";
2889
+			} elseif ($globalDebug) {
2890
+				echo "Done\n";
2891
+			}
2892
+		} elseif ($globalDebug) {
2893
+			echo "Done\n";
2894
+		}
2426 2895
 		return '';
2427 2896
 	}
2428 2897
 
2429 2898
 	public static function update_translation() {
2430 2899
 		global $tmp_dir, $globalDebug;
2431 2900
 		$error = '';
2432
-		if ($globalDebug) echo "Translation : Download...";
2901
+		if ($globalDebug) {
2902
+			echo "Translation : Download...";
2903
+		}
2433 2904
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2434 2905
 		if (file_exists($tmp_dir.'translation.zip')) {
2435
-			if ($globalDebug) echo "Unzip...";
2906
+			if ($globalDebug) {
2907
+				echo "Unzip...";
2908
+			}
2436 2909
 			update_db::unzip($tmp_dir.'translation.zip');
2437
-			if ($globalDebug) echo "Add to DB...";
2910
+			if ($globalDebug) {
2911
+				echo "Add to DB...";
2912
+			}
2438 2913
 			$error = update_db::translation();
2439
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2914
+		} else {
2915
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2916
+		}
2440 2917
 		if ($error != '') {
2441 2918
 			return $error;
2442
-		} elseif ($globalDebug) echo "Done\n";
2919
+		} elseif ($globalDebug) {
2920
+			echo "Done\n";
2921
+		}
2443 2922
 		return '';
2444 2923
 	}
2445 2924
 
2446 2925
 	public static function update_translation_fam() {
2447 2926
 		global $tmp_dir, $globalDebug;
2448 2927
 		$error = '';
2449
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2928
+		if ($globalDebug) {
2929
+			echo "Translation from FlightAirMap website : Download...";
2930
+		}
2450 2931
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2451 2932
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2452 2933
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2453 2934
 			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2454 2935
 			$translation_md5 = $translation_md5_file[0];
2455 2936
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2456
-				if ($globalDebug) echo "Gunzip...";
2937
+				if ($globalDebug) {
2938
+					echo "Gunzip...";
2939
+				}
2457 2940
 				update_db::gunzip($tmp_dir.'translation.tsv.gz');
2458
-				if ($globalDebug) echo "Add to DB...";
2941
+				if ($globalDebug) {
2942
+					echo "Add to DB...";
2943
+				}
2459 2944
 				$error = update_db::translation_fam();
2460
-			} else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2461
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2945
+			} else {
2946
+				$error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2947
+			}
2948
+		} else {
2949
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2950
+		}
2462 2951
 		if ($error != '') {
2463 2952
 			return $error;
2464
-		} elseif ($globalDebug) echo "Done\n";
2953
+		} elseif ($globalDebug) {
2954
+			echo "Done\n";
2955
+		}
2465 2956
 		return '';
2466 2957
 	}
2467 2958
 	public static function update_ModeS_fam() {
2468 2959
 		global $tmp_dir, $globalDebug;
2469 2960
 		$error = '';
2470
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2961
+		if ($globalDebug) {
2962
+			echo "ModeS from FlightAirMap website : Download...";
2963
+		}
2471 2964
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2472 2965
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2473 2966
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2474 2967
 			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2475 2968
 			$modes_md5 = $modes_md5_file[0];
2476 2969
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2477
-				if ($globalDebug) echo "Gunzip...";
2970
+				if ($globalDebug) {
2971
+					echo "Gunzip...";
2972
+				}
2478 2973
 				update_db::gunzip($tmp_dir.'modes.tsv.gz');
2479
-				if ($globalDebug) echo "Add to DB...";
2974
+				if ($globalDebug) {
2975
+					echo "Add to DB...";
2976
+				}
2480 2977
 				$error = update_db::modes_fam();
2481
-			} else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2482
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2978
+			} else {
2979
+				$error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2980
+			}
2981
+		} else {
2982
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2983
+		}
2483 2984
 		if ($error != '') {
2484 2985
 			return $error;
2485
-		} elseif ($globalDebug) echo "Done\n";
2986
+		} elseif ($globalDebug) {
2987
+			echo "Done\n";
2988
+		}
2486 2989
 		return '';
2487 2990
 	}
2488 2991
 
2489 2992
 	public static function update_airlines_fam() {
2490 2993
 		global $tmp_dir, $globalDebug;
2491 2994
 		$error = '';
2492
-		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2995
+		if ($globalDebug) {
2996
+			echo "Airlines from FlightAirMap website : Download...";
2997
+		}
2493 2998
 		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2494 2999
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2495 3000
 			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
@@ -2498,26 +3003,42 @@  discard block
 block discarded – undo
2498 3003
 				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2499 3004
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2500 3005
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2501
-						if ($globalDebug) echo "Gunzip...";
3006
+						if ($globalDebug) {
3007
+							echo "Gunzip...";
3008
+						}
2502 3009
 						update_db::gunzip($tmp_dir.'airlines.tsv.gz');
2503
-						if ($globalDebug) echo "Add to DB...";
3010
+						if ($globalDebug) {
3011
+							echo "Add to DB...";
3012
+						}
2504 3013
 						$error = update_db::airlines_fam();
2505 3014
 						update_db::insert_airlines_version($airlines_md5);
2506
-					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2507
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2508
-			} elseif ($globalDebug) echo "No update.";
2509
-		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
3015
+					} else {
3016
+						$error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
3017
+					}
3018
+			    } else {
3019
+			    	$error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
3020
+			    }
3021
+			} elseif ($globalDebug) {
3022
+				echo "No update.";
3023
+			}
3024
+		} else {
3025
+			$error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
3026
+		}
2510 3027
 		if ($error != '') {
2511 3028
 			return $error;
2512 3029
 		} else {
2513
-			if ($globalDebug) echo "Done\n";
3030
+			if ($globalDebug) {
3031
+				echo "Done\n";
3032
+			}
2514 3033
 		}
2515 3034
 		return '';
2516 3035
 	}
2517 3036
 
2518 3037
 	public static function update_owner_fam() {
2519 3038
 		global $tmp_dir, $globalDebug, $globalOwner;
2520
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
3039
+		if ($globalDebug) {
3040
+			echo "owner from FlightAirMap website : Download...";
3041
+		}
2521 3042
 		$error = '';
2522 3043
 		if ($globalOwner === TRUE) {
2523 3044
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
@@ -2530,55 +3051,89 @@  discard block
 block discarded – undo
2530 3051
 			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2531 3052
 			$owners_md5 = $owners_md5_file[0];
2532 3053
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2533
-				if ($globalDebug) echo "Gunzip...";
3054
+				if ($globalDebug) {
3055
+					echo "Gunzip...";
3056
+				}
2534 3057
 				update_db::gunzip($tmp_dir.'owners.tsv.gz');
2535
-				if ($globalDebug) echo "Add to DB...";
3058
+				if ($globalDebug) {
3059
+					echo "Add to DB...";
3060
+				}
2536 3061
 				$error = update_db::owner_fam();
2537
-			} else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2538
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3062
+			} else {
3063
+				$error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
3064
+			}
3065
+		} else {
3066
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3067
+		}
2539 3068
 		if ($error != '') {
2540 3069
 			return $error;
2541
-		} elseif ($globalDebug) echo "Done\n";
3070
+		} elseif ($globalDebug) {
3071
+			echo "Done\n";
3072
+		}
2542 3073
 		return '';
2543 3074
 	}
2544 3075
 	public static function update_routes_fam() {
2545 3076
 		global $tmp_dir, $globalDebug;
2546
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
3077
+		if ($globalDebug) {
3078
+			echo "Routes from FlightAirMap website : Download...";
3079
+		}
2547 3080
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2548 3081
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2549 3082
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2550 3083
 			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2551 3084
 			$routes_md5 = $routes_md5_file[0];
2552 3085
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2553
-				if ($globalDebug) echo "Gunzip...";
3086
+				if ($globalDebug) {
3087
+					echo "Gunzip...";
3088
+				}
2554 3089
 				update_db::gunzip($tmp_dir.'routes.tsv.gz');
2555
-				if ($globalDebug) echo "Add to DB...";
3090
+				if ($globalDebug) {
3091
+					echo "Add to DB...";
3092
+				}
2556 3093
 				$error = update_db::routes_fam();
2557
-			} else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2558
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3094
+			} else {
3095
+				$error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
3096
+			}
3097
+		} else {
3098
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3099
+		}
2559 3100
 		if ($error != '') {
2560 3101
 			return $error;
2561
-		} elseif ($globalDebug) echo "Done\n";
3102
+		} elseif ($globalDebug) {
3103
+			echo "Done\n";
3104
+		}
2562 3105
 		return '';
2563 3106
 	}
2564 3107
 	public static function update_block_fam() {
2565 3108
 		global $tmp_dir, $globalDebug;
2566
-		if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download...";
3109
+		if ($globalDebug) {
3110
+			echo "Blocked aircraft from FlightAirMap website : Download...";
3111
+		}
2567 3112
 		update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz');
2568 3113
 		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5');
2569 3114
 		if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) {
2570 3115
 			$block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2571 3116
 			$block_md5 = $block_md5_file[0];
2572 3117
 			if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) {
2573
-				if ($globalDebug) echo "Gunzip...";
3118
+				if ($globalDebug) {
3119
+					echo "Gunzip...";
3120
+				}
2574 3121
 				update_db::gunzip($tmp_dir.'block.tsv.gz');
2575
-				if ($globalDebug) echo "Add to DB...";
3122
+				if ($globalDebug) {
3123
+					echo "Add to DB...";
3124
+				}
2576 3125
 				$error = update_db::block_fam();
2577
-			} else $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed.";
2578
-		} else $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed.";
3126
+			} else {
3127
+				$error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed.";
3128
+			}
3129
+		} else {
3130
+			$error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed.";
3131
+		}
2579 3132
 		if ($error != '') {
2580 3133
 			return $error;
2581
-		} elseif ($globalDebug) echo "Done\n";
3134
+		} elseif ($globalDebug) {
3135
+			echo "Done\n";
3136
+		}
2582 3137
 		return '';
2583 3138
 	}
2584 3139
 	public static function update_marine_identity_fam() {
@@ -2588,21 +3143,33 @@  discard block
 block discarded – undo
2588 3143
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2589 3144
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2590 3145
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2591
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
3146
+				if ($globalDebug) {
3147
+					echo "Marine identity from FlightAirMap website : Download...";
3148
+				}
2592 3149
 				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2593 3150
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2594 3151
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2595
-						if ($globalDebug) echo "Gunzip...";
3152
+						if ($globalDebug) {
3153
+							echo "Gunzip...";
3154
+						}
2596 3155
 						update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2597
-						if ($globalDebug) echo "Add to DB...";
3156
+						if ($globalDebug) {
3157
+							echo "Add to DB...";
3158
+						}
2598 3159
 						$error = update_db::marine_identity_fam();
2599
-					} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
2600
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3160
+					} else {
3161
+						$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
3162
+					}
3163
+				} else {
3164
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3165
+				}
2601 3166
 				if ($error != '') {
2602 3167
 					return $error;
2603 3168
 				} else {
2604 3169
 					update_db::insert_marine_identity_version($marine_identity_md5);
2605
-					if ($globalDebug) echo "Done\n";
3170
+					if ($globalDebug) {
3171
+						echo "Done\n";
3172
+					}
2606 3173
 				}
2607 3174
 			}
2608 3175
 		}
@@ -2616,21 +3183,33 @@  discard block
 block discarded – undo
2616 3183
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2617 3184
 			$satellite_md5 = $satellite_md5_file[0];
2618 3185
 			if (!update_db::check_satellite_version($satellite_md5)) {
2619
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
3186
+				if ($globalDebug) {
3187
+					echo "Satellite from FlightAirMap website : Download...";
3188
+				}
2620 3189
 				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2621 3190
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2622 3191
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2623
-						if ($globalDebug) echo "Gunzip...";
3192
+						if ($globalDebug) {
3193
+							echo "Gunzip...";
3194
+						}
2624 3195
 						update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2625
-						if ($globalDebug) echo "Add to DB...";
3196
+						if ($globalDebug) {
3197
+							echo "Add to DB...";
3198
+						}
2626 3199
 						$error = update_db::satellite_fam();
2627
-					} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
2628
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3200
+					} else {
3201
+						$error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
3202
+					}
3203
+				} else {
3204
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3205
+				}
2629 3206
 				if ($error != '') {
2630 3207
 					return $error;
2631 3208
 				} else {
2632 3209
 					update_db::insert_satellite_version($satellite_md5);
2633
-					if ($globalDebug) echo "Done\n";
3210
+					if ($globalDebug) {
3211
+						echo "Done\n";
3212
+					}
2634 3213
 				}
2635 3214
 			}
2636 3215
 		}
@@ -2638,17 +3217,25 @@  discard block
 block discarded – undo
2638 3217
 	}
2639 3218
 	public static function update_banned_fam() {
2640 3219
 		global $tmp_dir, $globalDebug;
2641
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
3220
+		if ($globalDebug) {
3221
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
3222
+		}
2642 3223
 		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2643 3224
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2644 3225
 			//if ($globalDebug) echo "Gunzip...";
2645 3226
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2646
-			if ($globalDebug) echo "Add to DB...";
3227
+			if ($globalDebug) {
3228
+				echo "Add to DB...";
3229
+			}
2647 3230
 			$error = update_db::banned_fam();
2648
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3231
+		} else {
3232
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3233
+		}
2649 3234
 		if ($error != '') {
2650 3235
 			return $error;
2651
-		} elseif ($globalDebug) echo "Done\n";
3236
+		} elseif ($globalDebug) {
3237
+			echo "Done\n";
3238
+		}
2652 3239
 		return '';
2653 3240
 	}
2654 3241
 
@@ -2656,7 +3243,9 @@  discard block
 block discarded – undo
2656 3243
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2657 3244
 		include_once('class.create_db.php');
2658 3245
 		$error = '';
2659
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
3246
+		if ($globalDebug) {
3247
+			echo "Airspace from FlightAirMap website : Download...";
3248
+		}
2660 3249
 		if ($globalDBdriver == 'mysql') {
2661 3250
 			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2662 3251
 		} else {
@@ -2673,9 +3262,13 @@  discard block
 block discarded – undo
2673 3262
 				}
2674 3263
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2675 3264
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
2676
-						if ($globalDebug) echo "Gunzip...";
3265
+						if ($globalDebug) {
3266
+							echo "Gunzip...";
3267
+						}
2677 3268
 						update_db::gunzip($tmp_dir.'airspace.sql.gz');
2678
-						if ($globalDebug) echo "Add to DB...";
3269
+						if ($globalDebug) {
3270
+							echo "Add to DB...";
3271
+						}
2679 3272
 						$Connection = new Connection();
2680 3273
 						if ($Connection->tableExists('airspace')) {
2681 3274
 							$query = 'DROP TABLE airspace';
@@ -2688,20 +3281,30 @@  discard block
 block discarded – undo
2688 3281
 						}
2689 3282
 						$error = create_db::import_file($tmp_dir.'airspace.sql');
2690 3283
 						update_db::insert_airspace_version($airspace_md5);
2691
-					} else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
2692
-				} else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3284
+					} else {
3285
+						$error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
3286
+					}
3287
+				} else {
3288
+					$error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3289
+				}
2693 3290
 			}
2694
-		} else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3291
+		} else {
3292
+			$error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3293
+		}
2695 3294
 		if ($error != '') {
2696 3295
 			return $error;
2697
-		} elseif ($globalDebug) echo "Done\n";
3296
+		} elseif ($globalDebug) {
3297
+			echo "Done\n";
3298
+		}
2698 3299
 		return '';
2699 3300
 	}
2700 3301
 
2701 3302
 	public static function update_geoid_fam() {
2702 3303
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2703 3304
 		$error = '';
2704
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3305
+		if ($globalDebug) {
3306
+			echo "Geoid from FlightAirMap website : Download...";
3307
+		}
2705 3308
 		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2706 3309
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2707 3310
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2710,76 +3313,120 @@  discard block
 block discarded – undo
2710 3313
 				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2711 3314
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2712 3315
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2713
-						if ($globalDebug) echo "Gunzip...";
3316
+						if ($globalDebug) {
3317
+							echo "Gunzip...";
3318
+						}
2714 3319
 						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2715 3320
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2716 3321
 							update_db::insert_geoid_version($geoid_md5);
2717
-						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
2718
-					} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
2719
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2720
-			} elseif ($globalDebug) echo 'No new version'."\n";
2721
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3322
+						} else {
3323
+							$error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
3324
+						}
3325
+					} else {
3326
+						$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
3327
+					}
3328
+				} else {
3329
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3330
+				}
3331
+			} elseif ($globalDebug) {
3332
+				echo 'No new version'."\n";
3333
+			}
3334
+		} else {
3335
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3336
+		}
2722 3337
 		if ($error != '') {
2723 3338
 			return $error;
2724
-		} elseif ($globalDebug) echo "Done\n";
3339
+		} elseif ($globalDebug) {
3340
+			echo "Done\n";
3341
+		}
2725 3342
 		return '';
2726 3343
 	}
2727 3344
 
2728 3345
 	public static function update_tle() {
2729 3346
 		global $tmp_dir, $globalDebug;
2730
-		if ($globalDebug) echo "Download TLE : Download...";
3347
+		if ($globalDebug) {
3348
+			echo "Download TLE : Download...";
3349
+		}
2731 3350
 		$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',
2732 3351
 		'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',
2733 3352
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2734 3353
 		foreach ($alltle as $filename) {
2735
-			if ($globalDebug) echo "downloading ".$filename.'...';
3354
+			if ($globalDebug) {
3355
+				echo "downloading ".$filename.'...';
3356
+			}
2736 3357
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2737 3358
 			if (file_exists($tmp_dir.$filename)) {
2738
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3359
+				if ($globalDebug) {
3360
+					echo "Add to DB ".$filename."...";
3361
+				}
2739 3362
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2740
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3363
+			} else {
3364
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3365
+			}
2741 3366
 			if ($error != '') {
2742 3367
 				echo $error."\n";
2743
-			} elseif ($globalDebug) echo "Done\n";
3368
+			} elseif ($globalDebug) {
3369
+				echo "Done\n";
3370
+			}
2744 3371
 		}
2745 3372
 		return '';
2746 3373
 	}
2747 3374
 
2748 3375
 	public static function update_ucsdb() {
2749 3376
 		global $tmp_dir, $globalDebug;
2750
-		if ($globalDebug) echo "Download UCS DB : Download...";
3377
+		if ($globalDebug) {
3378
+			echo "Download UCS DB : Download...";
3379
+		}
2751 3380
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2752 3381
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2753
-			if ($globalDebug) echo "Add to DB...";
3382
+			if ($globalDebug) {
3383
+				echo "Add to DB...";
3384
+			}
2754 3385
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2755
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3386
+		} else {
3387
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt'." doesn't exist. Download failed.";
3388
+		}
2756 3389
 		if ($error != '') {
2757 3390
 			echo $error."\n";
2758
-		} elseif ($globalDebug) echo "Done\n";
3391
+		} elseif ($globalDebug) {
3392
+			echo "Done\n";
3393
+		}
2759 3394
 		return '';
2760 3395
 	}
2761 3396
 
2762 3397
 	public static function update_celestrak() {
2763 3398
 		global $tmp_dir, $globalDebug;
2764
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3399
+		if ($globalDebug) {
3400
+			echo "Download Celestrak DB : Download...";
3401
+		}
2765 3402
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2766 3403
 		if (file_exists($tmp_dir.'satcat.txt')) {
2767
-			if ($globalDebug) echo "Add to DB...";
3404
+			if ($globalDebug) {
3405
+				echo "Add to DB...";
3406
+			}
2768 3407
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2769
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3408
+		} else {
3409
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3410
+		}
2770 3411
 		if ($error != '') {
2771 3412
 			echo $error."\n";
2772
-		} elseif ($globalDebug) echo "Done\n";
3413
+		} elseif ($globalDebug) {
3414
+			echo "Done\n";
3415
+		}
2773 3416
 		return '';
2774 3417
 	}
2775 3418
 
2776 3419
 	public static function update_models() {
2777 3420
 		global $tmp_dir, $globalDebug;
2778 3421
 		$error = '';
2779
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3422
+		if ($globalDebug) {
3423
+			echo "Models from FlightAirMap website : Download...";
3424
+		}
2780 3425
 		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2781 3426
 		if (file_exists($tmp_dir.'models.md5sum')) {
2782
-			if ($globalDebug) echo "Check files...\n";
3427
+			if ($globalDebug) {
3428
+				echo "Check files...\n";
3429
+			}
2783 3430
 			$newmodelsdb = array();
2784 3431
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2785 3432
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2798,19 +3445,29 @@  discard block
 block discarded – undo
2798 3445
 			}
2799 3446
 			$diff = array_diff($newmodelsdb,$modelsdb);
2800 3447
 			foreach ($diff as $key => $value) {
2801
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3448
+				if ($globalDebug) {
3449
+					echo 'Downloading model '.$key.' ...'."\n";
3450
+				}
2802 3451
 				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2803 3452
 				
2804 3453
 			}
2805 3454
 			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2806
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3455
+		} else {
3456
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3457
+		}
2807 3458
 		if ($error != '') {
2808 3459
 			return $error;
2809
-		} elseif ($globalDebug) echo "Done\n";
2810
-		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
3460
+		} elseif ($globalDebug) {
3461
+			echo "Done\n";
3462
+		}
3463
+		if ($globalDebug) {
3464
+			echo "glTF 2.0 Models from FlightAirMap website : Download...";
3465
+		}
2811 3466
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2812 3467
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2813
-			if ($globalDebug) echo "Check files...\n";
3468
+			if ($globalDebug) {
3469
+				echo "Check files...\n";
3470
+			}
2814 3471
 			$newmodelsdb = array();
2815 3472
 			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2816 3473
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2829,25 +3486,35 @@  discard block
 block discarded – undo
2829 3486
 			}
2830 3487
 			$diff = array_diff($newmodelsdb,$modelsdb);
2831 3488
 			foreach ($diff as $key => $value) {
2832
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3489
+				if ($globalDebug) {
3490
+					echo 'Downloading model '.$key.' ...'."\n";
3491
+				}
2833 3492
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2834 3493
 				
2835 3494
 			}
2836 3495
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2837
-		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3496
+		} else {
3497
+			$error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3498
+		}
2838 3499
 		if ($error != '') {
2839 3500
 			return $error;
2840
-		} elseif ($globalDebug) echo "Done\n";
3501
+		} elseif ($globalDebug) {
3502
+			echo "Done\n";
3503
+		}
2841 3504
 		return '';
2842 3505
 	}
2843 3506
 
2844 3507
 	public static function update_liveries() {
2845 3508
 		global $tmp_dir, $globalDebug;
2846 3509
 		$error = '';
2847
-		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
3510
+		if ($globalDebug) {
3511
+			echo "Liveries from FlightAirMap website : Download...";
3512
+		}
2848 3513
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2849 3514
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2850
-			if ($globalDebug) echo "Check files...\n";
3515
+			if ($globalDebug) {
3516
+				echo "Check files...\n";
3517
+			}
2851 3518
 			$newmodelsdb = array();
2852 3519
 			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2853 3520
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2866,25 +3533,35 @@  discard block
 block discarded – undo
2866 3533
 			}
2867 3534
 			$diff = array_diff($newmodelsdb,$modelsdb);
2868 3535
 			foreach ($diff as $key => $value) {
2869
-				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
3536
+				if ($globalDebug) {
3537
+					echo 'Downloading liveries '.$key.' ...'."\n";
3538
+				}
2870 3539
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2871 3540
 				
2872 3541
 			}
2873 3542
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2874
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3543
+		} else {
3544
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3545
+		}
2875 3546
 		if ($error != '') {
2876 3547
 			return $error;
2877
-		} elseif ($globalDebug) echo "Done\n";
3548
+		} elseif ($globalDebug) {
3549
+			echo "Done\n";
3550
+		}
2878 3551
 		return '';
2879 3552
 	}
2880 3553
 
2881 3554
 	public static function update_space_models() {
2882 3555
 		global $tmp_dir, $globalDebug;
2883 3556
 		$error = '';
2884
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3557
+		if ($globalDebug) {
3558
+			echo "Space models from FlightAirMap website : Download...";
3559
+		}
2885 3560
 		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2886 3561
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2887
-			if ($globalDebug) echo "Check files...\n";
3562
+			if ($globalDebug) {
3563
+				echo "Check files...\n";
3564
+			}
2888 3565
 			$newmodelsdb = array();
2889 3566
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2890 3567
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2903,25 +3580,35 @@  discard block
 block discarded – undo
2903 3580
 			}
2904 3581
 			$diff = array_diff($newmodelsdb,$modelsdb);
2905 3582
 			foreach ($diff as $key => $value) {
2906
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3583
+				if ($globalDebug) {
3584
+					echo 'Downloading space model '.$key.' ...'."\n";
3585
+				}
2907 3586
 				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2908 3587
 				
2909 3588
 			}
2910 3589
 			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2911
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3590
+		} else {
3591
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3592
+		}
2912 3593
 		if ($error != '') {
2913 3594
 			return $error;
2914
-		} elseif ($globalDebug) echo "Done\n";
3595
+		} elseif ($globalDebug) {
3596
+			echo "Done\n";
3597
+		}
2915 3598
 		return '';
2916 3599
 	}
2917 3600
 
2918 3601
 	public static function update_vehicules_models() {
2919 3602
 		global $tmp_dir, $globalDebug;
2920 3603
 		$error = '';
2921
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3604
+		if ($globalDebug) {
3605
+			echo "Vehicules models from FlightAirMap website : Download...";
3606
+		}
2922 3607
 		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2923 3608
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2924
-			if ($globalDebug) echo "Check files...\n";
3609
+			if ($globalDebug) {
3610
+				echo "Check files...\n";
3611
+			}
2925 3612
 			$newmodelsdb = array();
2926 3613
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2927 3614
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2940,15 +3627,21 @@  discard block
 block discarded – undo
2940 3627
 			}
2941 3628
 			$diff = array_diff($newmodelsdb,$modelsdb);
2942 3629
 			foreach ($diff as $key => $value) {
2943
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3630
+				if ($globalDebug) {
3631
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3632
+				}
2944 3633
 				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2945 3634
 				
2946 3635
 			}
2947 3636
 			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2948
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3637
+		} else {
3638
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3639
+		}
2949 3640
 		if ($error != '') {
2950 3641
 			return $error;
2951
-		} elseif ($globalDebug) echo "Done\n";
3642
+		} elseif ($globalDebug) {
3643
+			echo "Done\n";
3644
+		}
2952 3645
 		return '';
2953 3646
 	}
2954 3647
 
@@ -3021,7 +3714,9 @@  discard block
 block discarded – undo
3021 3714
                 }
3022 3715
 
3023 3716
 		$error = '';
3024
-		if ($globalDebug) echo "Notam : Download...";
3717
+		if ($globalDebug) {
3718
+			echo "Notam : Download...";
3719
+		}
3025 3720
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
3026 3721
 		if (file_exists($tmp_dir.'notam.rss')) {
3027 3722
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -3036,14 +3731,30 @@  discard block
 block discarded – undo
3036 3731
 				$data['fir'] = $q[0];
3037 3732
 				$data['code'] = $q[1];
3038 3733
 				$ifrvfr = $q[2];
3039
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
3040
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
3041
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
3042
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
3043
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
3044
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
3045
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
3046
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3734
+				if ($ifrvfr == 'IV') {
3735
+					$data['rules'] = 'IFR/VFR';
3736
+				}
3737
+				if ($ifrvfr == 'I') {
3738
+					$data['rules'] = 'IFR';
3739
+				}
3740
+				if ($ifrvfr == 'V') {
3741
+					$data['rules'] = 'VFR';
3742
+				}
3743
+				if ($q[4] == 'A') {
3744
+					$data['scope'] = 'Airport warning';
3745
+				}
3746
+				if ($q[4] == 'E') {
3747
+					$data['scope'] = 'Enroute warning';
3748
+				}
3749
+				if ($q[4] == 'W') {
3750
+					$data['scope'] = 'Navigation warning';
3751
+				}
3752
+				if ($q[4] == 'AE') {
3753
+					$data['scope'] = 'Airport/Enroute warning';
3754
+				}
3755
+				if ($q[4] == 'AW') {
3756
+					$data['scope'] = 'Airport/Navigation warning';
3757
+				}
3047 3758
 				//$data['scope'] = $q[4];
3048 3759
 				$data['lower_limit'] = $q[5];
3049 3760
 				$data['upper_limit'] = $q[6];
@@ -3051,8 +3762,12 @@  discard block
 block discarded – undo
3051 3762
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
3052 3763
 				$latitude = $Common->convertDec($las,'latitude');
3053 3764
 				$longitude = $Common->convertDec($lns,'longitude');
3054
-				if ($lac == 'S') $latitude = '-'.$latitude;
3055
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3765
+				if ($lac == 'S') {
3766
+					$latitude = '-'.$latitude;
3767
+				}
3768
+				if ($lnc == 'W') {
3769
+					$longitude = '-'.$longitude;
3770
+				}
3056 3771
 				$data['center_latitude'] = $latitude;
3057 3772
 				$data['center_longitude'] = $longitude;
3058 3773
 				$data['radius'] = intval($radius);
@@ -3082,10 +3797,14 @@  discard block
 block discarded – undo
3082 3797
 				$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']);
3083 3798
 				unset($data);
3084 3799
 			} 
3085
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3800
+		} else {
3801
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3802
+		}
3086 3803
 		if ($error != '') {
3087 3804
 			return $error;
3088
-		} elseif ($globalDebug) echo "Done\n";
3805
+		} elseif ($globalDebug) {
3806
+			echo "Done\n";
3807
+		}
3089 3808
 		return '';
3090 3809
 	}
3091 3810
 	
@@ -3110,7 +3829,9 @@  discard block
 block discarded – undo
3110 3829
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3111 3830
 		$airspace_json = json_decode($airspace_lst,true);
3112 3831
 		foreach ($airspace_json['records'] as $airspace) {
3113
-			if ($globalDebug) echo $airspace['name']."...\n";
3832
+			if ($globalDebug) {
3833
+				echo $airspace['name']."...\n";
3834
+			}
3114 3835
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3115 3836
 			if (file_exists($tmp_dir.$airspace['name'])) {
3116 3837
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -3154,8 +3875,11 @@  discard block
 block discarded – undo
3154 3875
                         return "error : ".$e->getMessage();
3155 3876
                 }
3156 3877
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3157
-                if ($row['nb'] > 0) return false;
3158
-                else return true;
3878
+                if ($row['nb'] > 0) {
3879
+                	return false;
3880
+                } else {
3881
+                	return true;
3882
+                }
3159 3883
 	}
3160 3884
 
3161 3885
 	public static function insert_last_update() {
@@ -3180,8 +3904,11 @@  discard block
 block discarded – undo
3180 3904
                         return "error : ".$e->getMessage();
3181 3905
                 }
3182 3906
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3183
-                if ($row['nb'] > 0) return true;
3184
-                else return false;
3907
+                if ($row['nb'] > 0) {
3908
+                	return true;
3909
+                } else {
3910
+                	return false;
3911
+                }
3185 3912
 	}
3186 3913
 
3187 3914
 	public static function check_geoid_version($version) {
@@ -3194,8 +3921,11 @@  discard block
 block discarded – undo
3194 3921
                         return "error : ".$e->getMessage();
3195 3922
                 }
3196 3923
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3197
-                if ($row['nb'] > 0) return true;
3198
-                else return false;
3924
+                if ($row['nb'] > 0) {
3925
+                	return true;
3926
+                } else {
3927
+                	return false;
3928
+                }
3199 3929
 	}
3200 3930
 
3201 3931
 	public static function check_marine_identity_version($version) {
@@ -3208,8 +3938,11 @@  discard block
 block discarded – undo
3208 3938
 			return "error : ".$e->getMessage();
3209 3939
 		}
3210 3940
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3211
-		if ($row['nb'] > 0) return true;
3212
-		else return false;
3941
+		if ($row['nb'] > 0) {
3942
+			return true;
3943
+		} else {
3944
+			return false;
3945
+		}
3213 3946
 	}
3214 3947
 
3215 3948
 	public static function check_satellite_version($version) {
@@ -3222,8 +3955,11 @@  discard block
 block discarded – undo
3222 3955
 			return "error : ".$e->getMessage();
3223 3956
 		}
3224 3957
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3225
-		if ($row['nb'] > 0) return true;
3226
-		else return false;
3958
+		if ($row['nb'] > 0) {
3959
+			return true;
3960
+		} else {
3961
+			return false;
3962
+		}
3227 3963
 	}
3228 3964
 
3229 3965
 	public static function check_airlines_version($version) {
@@ -3236,8 +3972,11 @@  discard block
 block discarded – undo
3236 3972
 			return "error : ".$e->getMessage();
3237 3973
 		}
3238 3974
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3239
-		if ($row['nb'] > 0) return true;
3240
-		else return false;
3975
+		if ($row['nb'] > 0) {
3976
+			return true;
3977
+		} else {
3978
+			return false;
3979
+		}
3241 3980
 	}
3242 3981
 
3243 3982
 	public static function check_notam_version($version) {
@@ -3250,8 +3989,11 @@  discard block
 block discarded – undo
3250 3989
 			return "error : ".$e->getMessage();
3251 3990
 		}
3252 3991
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3253
-		if ($row['nb'] > 0) return true;
3254
-		else return false;
3992
+		if ($row['nb'] > 0) {
3993
+			return true;
3994
+		} else {
3995
+			return false;
3996
+		}
3255 3997
 	}
3256 3998
 
3257 3999
 	public static function insert_airlines_version($version) {
@@ -3341,8 +4083,11 @@  discard block
 block discarded – undo
3341 4083
                         return "error : ".$e->getMessage();
3342 4084
                 }
3343 4085
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3344
-                if ($row['nb'] > 0) return false;
3345
-                else return true;
4086
+                if ($row['nb'] > 0) {
4087
+                	return false;
4088
+                } else {
4089
+                	return true;
4090
+                }
3346 4091
 	}
3347 4092
 
3348 4093
 	public static function insert_last_notam_update() {
@@ -3372,8 +4117,11 @@  discard block
 block discarded – undo
3372 4117
                         return "error : ".$e->getMessage();
3373 4118
                 }
3374 4119
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3375
-                if ($row['nb'] > 0) return false;
3376
-                else return true;
4120
+                if ($row['nb'] > 0) {
4121
+                	return false;
4122
+                } else {
4123
+                	return true;
4124
+                }
3377 4125
 	}
3378 4126
 
3379 4127
 	public static function insert_last_airspace_update() {
@@ -3403,8 +4151,11 @@  discard block
 block discarded – undo
3403 4151
                         return "error : ".$e->getMessage();
3404 4152
                 }
3405 4153
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3406
-                if ($row['nb'] > 0) return false;
3407
-                else return true;
4154
+                if ($row['nb'] > 0) {
4155
+                	return false;
4156
+                } else {
4157
+                	return true;
4158
+                }
3408 4159
 	}
3409 4160
 
3410 4161
 	public static function insert_last_geoid_update() {
@@ -3434,8 +4185,11 @@  discard block
 block discarded – undo
3434 4185
 			return "error : ".$e->getMessage();
3435 4186
 		}
3436 4187
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3437
-		if ($row['nb'] > 0) return false;
3438
-		else return true;
4188
+		if ($row['nb'] > 0) {
4189
+			return false;
4190
+		} else {
4191
+			return true;
4192
+		}
3439 4193
 	}
3440 4194
 
3441 4195
 	public static function insert_last_owner_update() {
@@ -3465,8 +4219,11 @@  discard block
 block discarded – undo
3465 4219
 			return "error : ".$e->getMessage();
3466 4220
 		}
3467 4221
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3468
-		if ($row['nb'] > 0) return false;
3469
-		else return true;
4222
+		if ($row['nb'] > 0) {
4223
+			return false;
4224
+		} else {
4225
+			return true;
4226
+		}
3470 4227
 	}
3471 4228
 
3472 4229
 	public static function insert_last_fires_update() {
@@ -3496,8 +4253,11 @@  discard block
 block discarded – undo
3496 4253
 			return "error : ".$e->getMessage();
3497 4254
 		}
3498 4255
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3499
-		if ($row['nb'] > 0) return false;
3500
-		else return true;
4256
+		if ($row['nb'] > 0) {
4257
+			return false;
4258
+		} else {
4259
+			return true;
4260
+		}
3501 4261
 	}
3502 4262
 
3503 4263
 	public static function insert_last_airlines_update() {
@@ -3527,8 +4287,11 @@  discard block
 block discarded – undo
3527 4287
                         return "error : ".$e->getMessage();
3528 4288
                 }
3529 4289
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3530
-                if ($row['nb'] > 0) return false;
3531
-                else return true;
4290
+                if ($row['nb'] > 0) {
4291
+                	return false;
4292
+                } else {
4293
+                	return true;
4294
+                }
3532 4295
 	}
3533 4296
 
3534 4297
 	public static function insert_last_schedules_update() {
@@ -3558,8 +4321,11 @@  discard block
 block discarded – undo
3558 4321
 			return "error : ".$e->getMessage();
3559 4322
 		}
3560 4323
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3561
-		if ($row['nb'] > 0) return false;
3562
-		else return true;
4324
+		if ($row['nb'] > 0) {
4325
+			return false;
4326
+		} else {
4327
+			return true;
4328
+		}
3563 4329
 	}
3564 4330
 
3565 4331
 	public static function insert_last_tle_update() {
@@ -3589,8 +4355,11 @@  discard block
 block discarded – undo
3589 4355
 			return "error : ".$e->getMessage();
3590 4356
 		}
3591 4357
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3592
-		if ($row['nb'] > 0) return false;
3593
-		else return true;
4358
+		if ($row['nb'] > 0) {
4359
+			return false;
4360
+		} else {
4361
+			return true;
4362
+		}
3594 4363
 	}
3595 4364
 
3596 4365
 	public static function insert_last_ucsdb_update() {
@@ -3620,8 +4389,11 @@  discard block
 block discarded – undo
3620 4389
 			return "error : ".$e->getMessage();
3621 4390
 		}
3622 4391
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3623
-		if ($row['nb'] > 0) return false;
3624
-		else return true;
4392
+		if ($row['nb'] > 0) {
4393
+			return false;
4394
+		} else {
4395
+			return true;
4396
+		}
3625 4397
 	}
3626 4398
 
3627 4399
 	public static function insert_last_celestrak_update() {
@@ -3651,8 +4423,11 @@  discard block
 block discarded – undo
3651 4423
 			return "error : ".$e->getMessage();
3652 4424
 		}
3653 4425
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3654
-		if ($row['nb'] > 0) return false;
3655
-		else return true;
4426
+		if ($row['nb'] > 0) {
4427
+			return false;
4428
+		} else {
4429
+			return true;
4430
+		}
3656 4431
 	}
3657 4432
 
3658 4433
 	public static function check_last_satellite_update() {
@@ -3670,8 +4445,11 @@  discard block
 block discarded – undo
3670 4445
 			return "error : ".$e->getMessage();
3671 4446
 		}
3672 4447
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3673
-		if ($row['nb'] > 0) return false;
3674
-		else return true;
4448
+		if ($row['nb'] > 0) {
4449
+			return false;
4450
+		} else {
4451
+			return true;
4452
+		}
3675 4453
 	}
3676 4454
 
3677 4455
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.