Completed
Push — master ( 2ab225...cf2b25 )
by Yannick
08:54 queued 42s
created
require/class.SpotterImport.php 1 patch
Braces   +324 added lines, -115 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 	$dbc = $this->db;
54 54
 	$this->all_flights[$id]['schedule_check'] = true;
55 55
 	if ($globalSchedulesFetch) {
56
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
56
+	if ($globalDebug) {
57
+		echo 'Getting schedule info...'."\n";
58
+	}
57 59
 	$Spotter = new Spotter($dbc);
58 60
 	$Schedule = new Schedule($dbc);
59 61
 	$Translation = new Translation($dbc);
@@ -64,7 +66,9 @@  discard block
 block discarded – undo
64 66
 	    if ($Schedule->checkSchedule($operator) == 0) {
65 67
 		$schedule = $Schedule->fetchSchedule($operator);
66 68
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
67
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
69
+		    if ($globalDebug) {
70
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
71
+		    }
68 72
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69 73
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
70 74
 		    // Should also check if route schedule = route from DB
@@ -73,7 +77,9 @@  discard block
 block discarded – undo
73 77
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
74 78
 			    if (trim($airport_icao) != '') {
75 79
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
76
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
80
+				if ($globalDebug) {
81
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
82
+				}
77 83
 			    }
78 84
 			}
79 85
 		    }
@@ -82,17 +88,25 @@  discard block
 block discarded – undo
82 88
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
83 89
 			    if (trim($airport_icao) != '') {
84 90
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
85
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
91
+				if ($globalDebug) {
92
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
93
+				}
86 94
 			    }
87 95
 			}
88 96
 		    }
89 97
 		    $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']);
90 98
 		}
91
-	    } else $scheduleexist = true;
92
-	} else $scheduleexist = true;
99
+	    } else {
100
+	    	$scheduleexist = true;
101
+	    }
102
+	} else {
103
+		$scheduleexist = true;
104
+	}
93 105
 	// close connection, at least one way will work ?
94 106
        if ($scheduleexist) {
95
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
107
+		if ($globalDebug) {
108
+			echo "-> get arrival/departure airport info for ".$ident."\n";
109
+		}
96 110
     		$sch = $Schedule->getSchedule($operator);
97 111
 		$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']));
98 112
        }
@@ -114,7 +128,9 @@  discard block
 block discarded – undo
114 128
 
115 129
     public function checkAll() {
116 130
 	global $globalDebug;
117
-	if ($globalDebug) echo "Update last seen flights data...\n";
131
+	if ($globalDebug) {
132
+		echo "Update last seen flights data...\n";
133
+	}
118 134
 	foreach ($this->all_flights as $key => $flight) {
119 135
 	    if (isset($this->all_flights[$key]['id'])) {
120 136
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
@@ -127,24 +143,32 @@  discard block
 block discarded – undo
127 143
 
128 144
     public function arrival($key) {
129 145
 	global $globalClosestMinDist, $globalDebug;
130
-	if ($globalDebug) echo 'Update arrival...'."\n";
146
+	if ($globalDebug) {
147
+		echo 'Update arrival...'."\n";
148
+	}
131 149
 	$Spotter = new Spotter($this->db);
132 150
         $airport_icao = '';
133 151
         $airport_time = '';
134
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
152
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
153
+        	$globalClosestMinDist = 50;
154
+        }
135 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
136 156
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
137 157
     	    if (isset($closestAirports[0])) {
138 158
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139 159
         	    $airport_icao = $closestAirports[0]['icao'];
140 160
         	    $airport_time = $this->all_flights[$key]['datetime'];
141
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
161
+        	    if ($globalDebug) {
162
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
163
+        	    }
142 164
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
143 165
         	    foreach ($closestAirports as $airport) {
144 166
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
145 167
         		    $airport_icao = $airport['icao'];
146 168
         		    $airport_time = $this->all_flights[$key]['datetime'];
147
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
+        		    if ($globalDebug) {
170
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
171
+        		    }
148 172
         		    break;
149 173
         		}
150 174
         	    }
@@ -152,14 +176,20 @@  discard block
 block discarded – undo
152 176
         		$airport_icao = $closestAirports[0]['icao'];
153 177
         		$airport_time = $this->all_flights[$key]['datetime'];
154 178
         	} else {
155
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
179
+        		if ($globalDebug) {
180
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
181
+        		}
156 182
         	}
157 183
     	    } else {
158
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
184
+    		    if ($globalDebug) {
185
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
186
+    		    }
159 187
     	    }
160 188
 
161 189
         } else {
162
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
190
+        	if ($globalDebug) {
191
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
192
+        	}
163 193
         }
164 194
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
165 195
     }
@@ -169,12 +199,16 @@  discard block
 block discarded – undo
169 199
     public function del() {
170 200
 	global $globalDebug;
171 201
 	// Delete old infos
172
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
202
+	if ($globalDebug) {
203
+		echo 'Delete old values and update latest data...'."\n";
204
+	}
173 205
 	foreach ($this->all_flights as $key => $flight) {
174 206
     	    if (isset($flight['lastupdate'])) {
175 207
         	if ($flight['lastupdate'] < (time()-3000)) {
176 208
             	    if (isset($this->all_flights[$key]['id'])) {
177
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
209
+            		if ($globalDebug) {
210
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
211
+            		}
178 212
 			/*
179 213
 			$SpotterLive = new SpotterLive();
180 214
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -184,7 +218,9 @@  discard block
 block discarded – undo
184 218
             		$Spotter = new Spotter($this->db);
185 219
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
186 220
 				$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']);
187
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
221
+				if ($globalDebug && $result != 'success') {
222
+					echo '!!! ERROR : '.$result."\n";
223
+				}
188 224
 			}
189 225
 			// Put in archive
190 226
 //			$Spotter->db = null;
@@ -198,8 +234,10 @@  discard block
 block discarded – undo
198 234
     public function add($line) {
199 235
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights;
200 236
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
201
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
202
-/*
237
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
238
+		$globalCoordMinChange = '0.02';
239
+	}
240
+	/*
203 241
 	$Spotter = new Spotter();
204 242
 	$dbc = $Spotter->db;
205 243
 	$SpotterLive = new SpotterLive($dbc);
@@ -227,11 +265,15 @@  discard block
 block discarded – undo
227 265
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
228 266
 		    $current_date = date('Y-m-d');
229 267
 		    $source = $line['source_name'];
230
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
268
+		    if ($source == '' || $line['format_source'] == 'aprs') {
269
+		    	$source = $line['format_source'];
270
+		    }
231 271
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
232 272
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
233 273
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
234
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
274
+		    } else {
275
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
276
+		    }
235 277
 		}
236 278
 		
237 279
 		/*
@@ -247,8 +289,11 @@  discard block
 block discarded – undo
247 289
 		//$this->db = $dbc;
248 290
 
249 291
 		$hex = trim($line['hex']);
250
-	        if (!isset($line['id'])) $id = trim($line['hex']);
251
-	        else $id = trim($line['id']);
292
+	        if (!isset($line['id'])) {
293
+	        	$id = trim($line['hex']);
294
+	        } else {
295
+	        	$id = trim($line['id']);
296
+	        }
252 297
 		
253 298
 		//print_r($this->all_flights);
254 299
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
@@ -263,13 +308,20 @@  discard block
 block discarded – undo
263 308
 			$Spotter = new Spotter($this->db);
264 309
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
265 310
 			$Spotter->db = null;
266
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
311
+			if ($globalDebugTimeElapsed) {
312
+				echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
+			}
267 314
 
268 315
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
269
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
270
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
271
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
272
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
316
+			    if ($line['aircraft_type'] == 'PARA_GLIDER') {
317
+			    	$aircraft_icao = 'GLID';
318
+			    } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
319
+			    	$aircraft_icao = 'UHEL';
320
+			    } elseif ($line['aircraft_type'] == 'TOW_PLANE') {
321
+			    	$aircraft_icao = 'TOWPLANE';
322
+			    } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
323
+			    	$aircraft_icao = 'POWAIRC';
324
+			    }
273 325
 			}
274 326
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
275 327
 		    } else if (isset($line['aircraft_name'])) {
@@ -277,21 +329,36 @@  discard block
 block discarded – undo
277 329
 			$Spotter = new Spotter($this->db);
278 330
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
279 331
 			$Spotter->db = null;
280
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
281
-			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
282
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
332
+			if ($aircraft_icao != '') {
333
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
334
+			} else {
335
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
336
+			}
337
+		    } else {
338
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
339
+		    }
283 340
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', '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));
284 341
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
285 342
 		    if (!isset($line['id'])) {
286
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
287
-//			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')));
343
+			if (!isset($globalDaemon)) {
344
+				$globalDaemon = TRUE;
345
+			}
346
+			//			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')));
288 347
 //			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')));
289
-			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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
348
+			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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
349
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
350
+			}
290 351
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
291
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
352
+		     } else {
353
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
354
+		     }
292 355
 
293
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
294
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
356
+		    if ($globalDebug) {
357
+		    	echo "*********** New aircraft hex : ".$hex." ***********\n";
358
+		    }
359
+		    if ($globalAllFlights !== FALSE) {
360
+		    	$dataFound = true;
361
+		    }
295 362
 		}
296 363
 		
297 364
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
@@ -299,8 +366,11 @@  discard block
 block discarded – undo
299 366
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
300 367
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301 368
 		    } else {
302
-				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";
303
-				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";
369
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
370
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
371
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
372
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
373
+				}
304 374
 				/*
305 375
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
306 376
 				print_r($this->all_flights[$id]);
@@ -332,15 +402,25 @@  discard block
 block discarded – undo
332 402
 			$timeelapsed = microtime(true);
333 403
             		$Spotter = new Spotter($this->db);
334 404
             		$fromsource = NULL;
335
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
336
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
337
-			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
338
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
339
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
405
+            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
406
+            			$fromsource = $globalAirlinesSource;
407
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
408
+            			$fromsource = 'vatsim';
409
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
410
+				$fromsource = 'ivao';
411
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
412
+				$fromsource = 'vatsim';
413
+			} elseif (isset($globalIVAO) && $globalIVAO) {
414
+				$fromsource = 'ivao';
415
+			}
340 416
             		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
341
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
417
+			if ($globalDebug && $result != 'success') {
418
+				echo '!!! ERROR : '.$result."\n";
419
+			}
342 420
 			$Spotter->db = null;
343
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
421
+			if ($globalDebugTimeElapsed) {
422
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
423
+			}
344 424
 		    }
345 425
 
346 426
 /*
@@ -351,7 +431,9 @@  discard block
 block discarded – undo
351 431
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
352 432
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
353 433
   */
354
-		    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']));
434
+		    if (!isset($this->all_flights[$id]['id'])) {
435
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
436
+		    }
355 437
 
356 438
 		    //$putinarchive = true;
357 439
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -368,7 +450,9 @@  discard block
 block discarded – undo
368 450
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
369 451
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
370 452
 		    		$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' => ''));
371
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
453
+				if ($globalDebugTimeElapsed) {
454
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
455
+				}
372 456
 
373 457
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
374 458
 			$timeelapsed = microtime(true);
@@ -381,7 +465,9 @@  discard block
 block discarded – undo
381 465
 				$Translation->db = null;
382 466
 			}
383 467
 			$Spotter->db = null;
384
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
468
+			if ($globalDebugTimeElapsed) {
469
+				echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
470
+			}
385 471
 
386 472
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
387 473
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -390,9 +476,13 @@  discard block
 block discarded – undo
390 476
 		    		$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']));
391 477
 		    	    }
392 478
 			}
393
-			if (!isset($globalFork)) $globalFork = TRUE;
479
+			if (!isset($globalFork)) {
480
+				$globalFork = TRUE;
481
+			}
394 482
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
395
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
483
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
484
+					$this->get_Schedule($id,trim($line['ident']));
485
+				}
396 486
 			}
397 487
 		    }
398 488
 		}
@@ -408,16 +498,23 @@  discard block
 block discarded – undo
408 498
 		    // use datetime
409 499
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
410 500
 			$speed = $speed*3.6;
411
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
412
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
501
+			if ($speed < 1000) {
502
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
503
+			}
504
+  			if ($globalDebug) {
505
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
506
+  			}
413 507
 		    }
414 508
 		}
415 509
 
416 510
 
417 511
 
418 512
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
419
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
420
-	    	    else unset($timediff);
513
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
514
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
515
+	    	    } else {
516
+	    	    	unset($timediff);
517
+	    	    }
421 518
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
422 519
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
423 520
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -425,21 +522,31 @@  discard block
 block discarded – undo
425 522
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
426 523
 				$this->all_flights[$id]['putinarchive'] = true;
427 524
 				
428
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
525
+				if ($globalDebug) {
526
+					echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
527
+				}
429 528
 				$timeelapsed = microtime(true);
430 529
 				$Spotter = new Spotter($this->db);
431 530
 				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
432
-				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
531
+				if (!empty($all_country)) {
532
+					$this->all_flights[$id]['over_country'] = $all_country['iso2'];
533
+				}
433 534
 				$Spotter->db = null;
434
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
535
+				if ($globalDebugTimeElapsed) {
536
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
537
+				}
435 538
 				$this->tmd = 0;
436
-				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
539
+				if ($globalDebug) {
540
+					echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
541
+				}
437 542
 			    }
438 543
 			}
439 544
 
440 545
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
441 546
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
442
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
547
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
548
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
549
+				}
443 550
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
444 551
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
445 552
 				    $dataFound = true;
@@ -461,9 +568,13 @@  discard block
 block discarded – undo
461 568
 			    */
462 569
 			}
463 570
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
464
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
571
+			    if ($line['longitude'] > 180) {
572
+			    	$line['longitude'] = $line['longitude'] - 360;
573
+			    }
465 574
 			    //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) {
466
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
575
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
576
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
577
+				}
467 578
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
468 579
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
469 580
 				    $dataFound = true;
@@ -494,7 +605,9 @@  discard block
 block discarded – undo
494 605
 		    }
495 606
 		}
496 607
 		if (isset($line['last_update']) && $line['last_update'] != '') {
497
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
608
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
609
+		    	$dataFound = true;
610
+		    }
498 611
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
499 612
 		}
500 613
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -516,11 +629,17 @@  discard block
 block discarded – undo
516 629
 			// Here we force archive of flight because after ground it's a new one (or should be)
517 630
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
518 631
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
519
-			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'].'-'.date('YmdGi')));
520
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
521
-			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']));
632
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
633
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
634
+			} elseif (isset($line['id'])) {
635
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
636
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
637
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
638
+			}
639
+		    }
640
+		    if ($line['ground'] != 1) {
641
+		    	$line['ground'] = 0;
522 642
 		    }
523
-		    if ($line['ground'] != 1) $line['ground'] = 0;
524 643
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
525 644
 		    //$dataFound = true;
526 645
 		}
@@ -528,28 +647,40 @@  discard block
 block discarded – undo
528 647
 		    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'])) {
529 648
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
530 649
 			    $highlight = '';
531
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
532
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
533
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
650
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
651
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
652
+			    }
653
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
654
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
655
+			    }
656
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
657
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
658
+			    }
534 659
 			    if ($highlight != '') {
535 660
 				$timeelapsed = microtime(true);
536 661
 				$Spotter = new Spotter($this->db);
537 662
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
538 663
 				$Spotter->db = null;
539
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
664
+				if ($globalDebugTimeElapsed) {
665
+					echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
666
+				}
540 667
 
541 668
 				$this->all_flights[$id]['putinarchive'] = true;
542 669
 				//$putinarchive = true;
543 670
 				//$highlight = '';
544 671
 			    }
545 672
 			    
546
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
673
+		    } else {
674
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
675
+		    }
547 676
 		    //$dataFound = true;
548 677
 		}
549 678
 
550 679
 		if (isset($line['altitude']) && $line['altitude'] != '') {
551 680
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
552
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
681
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) {
682
+				$this->all_flights[$id]['putinarchive'] = true;
683
+			}
553 684
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
554 685
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
555 686
 			//$dataFound = true;
@@ -561,21 +692,30 @@  discard block
 block discarded – undo
561 692
 		}
562 693
 		
563 694
 		if (isset($line['heading']) && $line['heading'] != '') {
564
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
695
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) {
696
+		    	$this->all_flights[$id]['putinarchive'] = true;
697
+		    }
565 698
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
566 699
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
567 700
 		    //$dataFound = true;
568 701
   		} 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']) {
569 702
   		    $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']);
570 703
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
571
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
572
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
704
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) {
705
+		    	$this->all_flights[$id]['putinarchive'] = true;
706
+		    }
707
+  		    if ($globalDebug) {
708
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
709
+  		    }
573 710
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
574 711
   		    // If not enough messages and ACARS set heading to 0
575 712
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
576 713
   		}
577
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
578
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
714
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
715
+			$dataFound = false;
716
+		} elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
717
+			$dataFound = false;
718
+		}
579 719
 
580 720
 //		print_r($this->all_flights[$id]);
581 721
 		//gets the callsign from the last hour
@@ -590,23 +730,36 @@  discard block
 block discarded – undo
590 730
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
591 731
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
592 732
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
593
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
733
+				if ($globalDebug) {
734
+					echo "Check if aircraft is already in DB...";
735
+				}
594 736
 				$timeelapsed = microtime(true);
595 737
 				$SpotterLive = new SpotterLive($this->db);
596 738
 				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' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
597 739
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
598
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
740
+				    if ($globalDebugTimeElapsed) {
741
+				    	echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
742
+				    }
599 743
 				} elseif (isset($line['id'])) {
600 744
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
601
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
745
+				    if ($globalDebugTimeElapsed) {
746
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
747
+				    }
602 748
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
603 749
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
604
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
605
-				} else $recent_ident = '';
750
+				    if ($globalDebugTimeElapsed) {
751
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
752
+				    }
753
+				} else {
754
+					$recent_ident = '';
755
+				}
606 756
 				$SpotterLive->db=null;
607 757
 
608
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
609
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
758
+				if ($globalDebug && $recent_ident == '') {
759
+					echo " Not in DB.\n";
760
+				} elseif ($globalDebug && $recent_ident != '') {
761
+					echo " Already in DB.\n";
762
+				}
610 763
 			    } else {
611 764
 				$recent_ident = '';
612 765
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -614,7 +767,9 @@  discard block
 block discarded – undo
614 767
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
615 768
 			    if($recent_ident == "")
616 769
 			    {
617
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
770
+				if ($globalDebug) {
771
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
772
+				}
618 773
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
619 774
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
620 775
 				//adds the spotter data for the archive
@@ -658,26 +813,44 @@  discard block
 block discarded – undo
658 813
 				
659 814
 				if (!$ignoreImport) {
660 815
 				    $highlight = '';
661
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
662
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
663
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
664
-				    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')));
816
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
817
+				    	$highlight = 'Squawk 7500 : Hijack';
818
+				    }
819
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
820
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
821
+				    }
822
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
823
+				    	$highlight = 'Squawk 7700 : Emergency';
824
+				    }
825
+				    if (!isset($this->all_flights[$id]['id'])) {
826
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
827
+				    }
665 828
 				    $timeelapsed = microtime(true);
666 829
 				    $Spotter = new Spotter($this->db);
667 830
 				    $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]['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']);
668 831
 				    $Spotter->db = null;
669
-				    if ($globalDebug && isset($result)) echo $result."\n";
670
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
832
+				    if ($globalDebug && isset($result)) {
833
+				    	echo $result."\n";
834
+				    }
835
+				    if ($globalDebugTimeElapsed) {
836
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
837
+				    }
671 838
 				    
672 839
 				    // Add source stat in DB
673 840
 				    $Stats = new Stats($this->db);
674 841
 				    if (!empty($this->stats)) {
675
-					if ($globalDebug) echo 'Add source stats : ';
842
+					if ($globalDebug) {
843
+						echo 'Add source stats : ';
844
+					}
676 845
 				        foreach($this->stats as $date => $data) {
677 846
 					    foreach($data as $source => $sourced) {
678 847
 					        //print_r($sourced);
679
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
680
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
848
+				    	        if (isset($sourced['polar'])) {
849
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
850
+				    	        }
851
+				    	        if (isset($sourced['hist'])) {
852
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
853
+				    	        }
681 854
 				    		if (isset($sourced['msg'])) {
682 855
 				    		    if (time() - $sourced['msg']['date'] > 10) {
683 856
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -690,13 +863,17 @@  discard block
 block discarded – undo
690 863
 			    			unset($this->stats[$date]);
691 864
 			    		    }
692 865
 				    	}
693
-				    	if ($globalDebug) echo 'Done'."\n";
866
+				    	if ($globalDebug) {
867
+				    		echo 'Done'."\n";
868
+				    	}
694 869
 
695 870
 				    }
696 871
 				    $Stats->db = null;
697 872
 				    
698 873
 				    $this->del();
699
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
874
+				} elseif ($globalDebug) {
875
+					echo 'Ignore data'."\n";
876
+				}
700 877
 				//$ignoreImport = false;
701 878
 				$this->all_flights[$id]['addedSpotter'] = 1;
702 879
 				//print_r($this->all_flights[$id]);
@@ -713,12 +890,16 @@  discard block
 block discarded – undo
713 890
 			*/
714 891
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
715 892
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
716
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
893
+				    if ($globalDebug) {
894
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
895
+				    }
717 896
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
718 897
 				    $SpotterLive = new SpotterLive($this->db);
719 898
 				    $SpotterLive->deleteLiveSpotterData();
720 899
 				    $SpotterLive->db=null;
721
-				    if ($globalDebug) echo " Done\n";
900
+				    if ($globalDebug) {
901
+				    	echo " Done\n";
902
+				    }
722 903
 				    $this->last_delete = time();
723 904
 				}
724 905
 			    } else {
@@ -741,11 +922,17 @@  discard block
 block discarded – undo
741 922
 		    //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";
742 923
 		    if ($globalDebug) {
743 924
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
744
-				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";
745
-				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";
925
+				if (isset($this->all_flights[$id]['source_name'])) {
926
+					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";
927
+				} else {
928
+					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";
929
+				}
746 930
 			} else {
747
-				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";
748
-				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";
931
+				if (isset($this->all_flights[$id]['source_name'])) {
932
+					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";
933
+				} else {
934
+					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";
935
+				}
749 936
 			}
750 937
 		    }
751 938
 		    $ignoreImport = false;
@@ -791,19 +978,25 @@  discard block
 block discarded – undo
791 978
 
792 979
 		    if (!$ignoreImport) {
793 980
 			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'])) {
794
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
981
+				if ($globalDebug) {
982
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
983
+				}
795 984
 				$timeelapsed = microtime(true);
796 985
 				$SpotterLive = new SpotterLive($this->db);
797 986
 				$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]['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']);
798 987
 				$SpotterLive->db = null;
799
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
988
+				if ($globalDebugTimeElapsed) {
989
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
990
+				}
800 991
 
801 992
 				// Put statistics in $this->stats variable
802 993
 				//if ($line['format_source'] != 'aprs') {
803 994
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
804 995
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
805 996
 					$source = $this->all_flights[$id]['source_name'];
806
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
997
+					if ($source == '') {
998
+						$source = $this->all_flights[$id]['format_source'];
999
+					}
807 1000
 					if (!isset($this->source_location[$source])) {
808 1001
 						$Location = new Source();
809 1002
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -824,7 +1017,9 @@  discard block
 block discarded – undo
824 1017
 					$stats_heading = round($stats_heading/22.5);
825 1018
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
826 1019
 					$current_date = date('Y-m-d');
827
-					if ($stats_heading == 16) $stats_heading = 0;
1020
+					if ($stats_heading == 16) {
1021
+						$stats_heading = 0;
1022
+					}
828 1023
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
829 1024
 						for ($i=0;$i<=15;$i++) {
830 1025
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -842,7 +1037,9 @@  discard block
 block discarded – undo
842 1037
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
843 1038
 						    end($this->stats[$current_date][$source]['hist']);
844 1039
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
845
-						} else $mini = 0;
1040
+						} else {
1041
+							$mini = 0;
1042
+						}
846 1043
 						for ($i=$mini;$i<=$distance;$i+=10) {
847 1044
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
848 1045
 						}
@@ -853,20 +1050,30 @@  discard block
 block discarded – undo
853 1050
 				}
854 1051
 
855 1052
 				$this->all_flights[$id]['lastupdate'] = time();
856
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1053
+				if ($this->all_flights[$id]['putinarchive']) {
1054
+					$send = true;
1055
+				}
857 1056
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
858
-				if ($globalDebug) echo $result."\n";
859
-			} 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";
1057
+				if ($globalDebug) {
1058
+					echo $result."\n";
1059
+				}
1060
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1061
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1062
+			}
860 1063
 			//$this->del();
861 1064
 			
862 1065
 			
863 1066
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
864
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1067
+			    if ($globalDebug) {
1068
+			    	echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1069
+			    }
865 1070
 			    $SpotterLive = new SpotterLive($this->db);
866 1071
 			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
867 1072
 			    $SpotterLive->db = null;
868 1073
 			    //SpotterLive->deleteLiveSpotterData();
869
-			    if ($globalDebug) echo " Done\n";
1074
+			    if ($globalDebug) {
1075
+			    	echo " Done\n";
1076
+			    }
870 1077
 			    $this->last_delete_hourly = time();
871 1078
 			}
872 1079
 			
@@ -874,7 +1081,9 @@  discard block
 block discarded – undo
874 1081
 		    //$ignoreImport = false;
875 1082
 		}
876 1083
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
877
-		if ($send) return $this->all_flights[$id];
1084
+		if ($send) {
1085
+			return $this->all_flights[$id];
1086
+		}
878 1087
 	    }
879 1088
 	}
880 1089
     }
Please login to merge, or discard this patch.
require/class.Spotter.php 1 patch
Braces   +731 added lines, -255 removed lines patch added patch discarded remove patch
@@ -69,7 +69,9 @@  discard block
 block discarded – undo
69 69
 				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
70 70
 			}
71 71
 		}
72
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
72
+		if (is_array($globalFilter)) {
73
+			$filter = array_merge($filter,$globalFilter);
74
+		}
73 75
 		$filter_query_join = '';
74 76
 		$filter_query_where = '';
75 77
 		foreach($filters as $flt) {
@@ -122,8 +124,11 @@  discard block
 block discarded – undo
122 124
 				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
123 125
 			}
124 126
 		}
125
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
126
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
127
+		if ($filter_query_where == '' && $where) {
128
+			$filter_query_where = ' WHERE';
129
+		} elseif ($filter_query_where != '' && $and) {
130
+			$filter_query_where .= ' AND';
131
+		}
127 132
 		$filter_query = $filter_query_join.$filter_query_where;
128 133
 		return $filter_query;
129 134
 	}
@@ -143,10 +148,18 @@  discard block
 block discarded – undo
143 148
 		$Image = new Image($this->db);
144 149
 		$Schedule = new Schedule($this->db);
145 150
 		$ACARS = new ACARS($this->db);
146
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
147
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
148
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
149
-		if (!isset($globalVAM)) $globalVAM = FALSE;
151
+		if (!isset($globalIVAO)) {
152
+			$globalIVAO = FALSE;
153
+		}
154
+		if (!isset($globalVATSIM)) {
155
+			$globalVATSIM = FALSE;
156
+		}
157
+		if (!isset($globalphpVMS)) {
158
+			$globalphpVMS = FALSE;
159
+		}
160
+		if (!isset($globalVAM)) {
161
+			$globalVAM = FALSE;
162
+		}
150 163
 		date_default_timezone_set('UTC');
151 164
 		
152 165
 		if (!is_string($query))
@@ -193,21 +206,35 @@  discard block
 block discarded – undo
193 206
 			} else {
194 207
 				$temp_array['spotter_id'] = '';
195 208
 			}
196
-			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id'];
197
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
209
+			if (isset($row['flightaware_id'])) {
210
+				$temp_array['flightaware_id'] = $row['flightaware_id'];
211
+			}
212
+			if (isset($row['modes'])) {
213
+				$temp_array['modes'] = $row['modes'];
214
+			}
198 215
 			$temp_array['ident'] = $row['ident'];
199 216
 			if (isset($row['registration']) && $row['registration'] != '') {
200 217
 				$temp_array['registration'] = $row['registration'];
201 218
 			} elseif (isset($temp_array['modes'])) {
202 219
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
203
-			} else $temp_array['registration'] = '';
204
-			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao'];
220
+			} else {
221
+				$temp_array['registration'] = '';
222
+			}
223
+			if (isset($row['aircraft_icao'])) {
224
+				$temp_array['aircraft_type'] = $row['aircraft_icao'];
225
+			}
205 226
 			
206 227
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
207 228
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
208
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
209
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
210
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
229
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
230
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
231
+			}
232
+			if (isset($row['latitude'])) {
233
+				$temp_array['latitude'] = $row['latitude'];
234
+			}
235
+			if (isset($row['longitude'])) {
236
+				$temp_array['longitude'] = $row['longitude'];
237
+			}
211 238
 			/*
212 239
 			if (Connection->tableExists('countries')) {
213 240
 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
@@ -217,8 +244,12 @@  discard block
 block discarded – undo
217 244
 				}
218 245
 			}
219 246
 			*/
220
-			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints'];
221
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
247
+			if (isset($row['waypoints'])) {
248
+				$temp_array['waypoints'] = $row['waypoints'];
249
+			}
250
+			if (isset($row['format_source'])) {
251
+				$temp_array['format_source'] = $row['format_source'];
252
+			}
222 253
 			if (isset($row['route_stop']) && $row['route_stop'] != '') {
223 254
 				$temp_array['route_stop'] = $row['route_stop'];
224 255
 				$allroute = explode(' ',$row['route_stop']);
@@ -234,13 +265,19 @@  discard block
 block discarded – undo
234 265
 					}
235 266
 				}
236 267
 			}
237
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
268
+			if (isset($row['altitude'])) {
269
+				$temp_array['altitude'] = $row['altitude'];
270
+			}
238 271
 			if (isset($row['heading'])) {
239 272
 				$temp_array['heading'] = $row['heading'];
240 273
 				$heading_direction = $this->parseDirection($row['heading']);
241
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
274
+				if (isset($heading_direction[0]['direction_fullname'])) {
275
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
276
+				}
277
+			}
278
+			if (isset($row['ground_speed'])) {
279
+				$temp_array['ground_speed'] = $row['ground_speed'];
242 280
 			}
243
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
244 281
 			$temp_array['image'] = "";
245 282
 			$temp_array['image_thumbnail'] = "";
246 283
 			$temp_array['image_source'] = "";
@@ -248,7 +285,9 @@  discard block
 block discarded – undo
248 285
  
249 286
 			if (isset($row['highlight'])) {
250 287
 				$temp_array['highlight'] = $row['highlight'];
251
-			} else $temp_array['highlight'] = '';
288
+			} else {
289
+				$temp_array['highlight'] = '';
290
+			}
252 291
 			
253 292
 			if (isset($row['date'])) {
254 293
 				$dateArray = $this->parseDateString($row['date']);
@@ -302,7 +341,9 @@  discard block
 block discarded – undo
302 341
 				
303 342
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
304 343
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
305
-					} else $temp_array['aircraft_shadow'] = 'default.png';
344
+					} else {
345
+						$temp_array['aircraft_shadow'] = 'default.png';
346
+					}
306 347
                                 } else {
307 348
                             		$temp_array['aircraft_shadow'] = 'default.png';
308 349
 					$temp_array['aircraft_name'] = 'N/A';
@@ -310,11 +351,17 @@  discard block
 block discarded – undo
310 351
                             	}
311 352
 			}
312 353
 			$fromsource = NULL;
313
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
314
-			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
315
-			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
316
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
317
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
354
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
355
+				$fromsource = $globalAirlinesSource;
356
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
357
+				$fromsource = 'vatsim';
358
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
359
+				$fromsource = 'ivao';
360
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
361
+				$fromsource = 'vatsim';
362
+			} elseif (isset($globalIVAO) && $globalIVAO) {
363
+				$fromsource = 'ivao';
364
+			}
318 365
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
319 366
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
320 367
 					if (is_numeric(substr($row['ident'], 2, 1))) {
@@ -337,12 +384,18 @@  discard block
 block discarded – undo
337 384
 				}
338 385
 			} else {
339 386
 				$temp_array['airline_icao'] = $row['airline_icao'];
340
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
341
-				else $temp_array['airline_iata'] = 'N/A';
387
+				if (isset($row['airline_iata'])) {
388
+					$temp_array['airline_iata'] = $row['airline_iata'];
389
+				} else {
390
+					$temp_array['airline_iata'] = 'N/A';
391
+				}
342 392
 				$temp_array['airline_name'] = $row['airline_name'];
343 393
 				$temp_array['airline_country'] = $row['airline_country'];
344
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
345
-				else $temp_array['airline_callsign'] = 'N/A';
394
+				if (isset($row['airline_callsign'])) {
395
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
396
+				} else {
397
+					$temp_array['airline_callsign'] = 'N/A';
398
+				}
346 399
 				$temp_array['airline_type'] = $row['airline_type'];
347 400
 				if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') {
348 401
 					$airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']);
@@ -369,7 +422,9 @@  discard block
 block discarded – undo
369 422
 			}
370 423
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) {
371 424
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
372
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
425
+				if ($owner_info['owner'] != '') {
426
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
427
+				}
373 428
 				$temp_array['aircraft_base'] = $owner_info['base'];
374 429
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
375 430
 			}
@@ -377,9 +432,14 @@  discard block
 block discarded – undo
377 432
 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
378 433
 			{
379 434
 				if ($globalIVAO) {
380
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
381
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
382
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
435
+					if (isset($temp_array['airline_icao'])) {
436
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
437
+					} else {
438
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
439
+					}
440
+				} else {
441
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
442
+				}
383 443
 				if (count($image_array) > 0) {
384 444
 					$temp_array['image'] = $image_array[0]['image'];
385 445
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -431,7 +491,9 @@  discard block
 block discarded – undo
431 491
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
432 492
 			if ($row['departure_airport_icao'] != '') {
433 493
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
434
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
494
+				if (!isset($departure_airport_array[0]['name'])) {
495
+					$departure_airport_array = $this->getAllAirportInfo('NA');
496
+				}
435 497
 			/*
436 498
 			} elseif ($row['departure_airport_name'] != '') {
437 499
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -439,7 +501,9 @@  discard block
 block discarded – undo
439 501
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
440 502
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
441 503
 			*/
442
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
504
+			} else {
505
+				$departure_airport_array = $this->getAllAirportInfo('NA');
506
+			}
443 507
 			if (isset($departure_airport_array[0]['name'])) {
444 508
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
445 509
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -459,8 +523,12 @@  discard block
 block discarded – undo
459 523
 			
460 524
 			if ($row['arrival_airport_icao'] != '') {
461 525
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
462
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
463
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
526
+				if (count($arrival_airport_array) == 0) {
527
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
528
+				}
529
+			} else {
530
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
531
+			}
464 532
 			if (isset($arrival_airport_array[0]['name'])) {
465 533
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
466 534
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -476,27 +544,45 @@  discard block
 block discarded – undo
476 544
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
477 545
 			}
478 546
 			*/
479
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
480
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
481
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
482
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
483
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
547
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
548
+				$temp_array['pilot_id'] = $row['pilot_id'];
549
+			}
550
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
551
+				$temp_array['pilot_name'] = $row['pilot_name'];
552
+			}
553
+			if (isset($row['source_name']) && $row['source_name'] != '') {
554
+				$temp_array['source_name'] = $row['source_name'];
555
+			}
556
+			if (isset($row['over_country']) && $row['over_country'] != '') {
557
+				$temp_array['over_country'] = $row['over_country'];
558
+			}
559
+			if (isset($row['distance']) && $row['distance'] != '') {
560
+				$temp_array['distance'] = $row['distance'];
561
+			}
484 562
 			if (isset($row['squawk'])) {
485 563
 				$temp_array['squawk'] = $row['squawk'];
486 564
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
487 565
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
488
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
566
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
567
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
568
+					}
489 569
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
490 570
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
491
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
492
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
571
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
572
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
573
+					}
574
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
575
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
576
+				}
493 577
 			}
494 578
     			
495 579
 			$temp_array['query_number_rows'] = $num_rows;
496 580
 			
497 581
 			$spotter_array[] = $temp_array;
498 582
 		}
499
-		if ($num_rows == 0) return array();
583
+		if ($num_rows == 0) {
584
+			return array();
585
+		}
500 586
 		$spotter_array[0]['query_number_rows'] = $num_rows;
501 587
 		return $spotter_array;
502 588
 	}	
@@ -529,7 +615,9 @@  discard block
 block discarded – undo
529 615
 				foreach ($q_array as $q_item){
530 616
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
531 617
 					$additional_query .= " AND (";
532
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
618
+					if (is_int($q_item)) {
619
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
620
+					}
533 621
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
534 622
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
535 623
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -550,7 +638,9 @@  discard block
 block discarded – undo
550 638
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
551 639
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
552 640
 					$translate = $Translation->ident2icao($q_item);
553
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
641
+					if ($translate != $q_item) {
642
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
643
+					}
554 644
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
555 645
 					$additional_query .= ")";
556 646
 				}
@@ -777,7 +867,9 @@  discard block
 block discarded – undo
777 867
 				date_default_timezone_set($globalTimezone);
778 868
 				$datetime = new DateTime();
779 869
 				$offset = $datetime->format('P');
780
-			} else $offset = '+00:00';
870
+			} else {
871
+				$offset = '+00:00';
872
+			}
781 873
 
782 874
 			if ($date_array[1] != "")
783 875
 			{
@@ -809,8 +901,12 @@  discard block
 block discarded – undo
809 901
 			{
810 902
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
811 903
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
812
-			} else $limit_query = "";
813
-		} else $limit_query = "";
904
+			} else {
905
+				$limit_query = "";
906
+			}
907
+		} else {
908
+			$limit_query = "";
909
+		}
814 910
 
815 911
 
816 912
 		if ($sort != "")
@@ -878,8 +974,12 @@  discard block
 block discarded – undo
878 974
 			{
879 975
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
880 976
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
881
-			} else $limit_query = "";
882
-		} else $limit_query = "";
977
+			} else {
978
+				$limit_query = "";
979
+			}
980
+		} else {
981
+			$limit_query = "";
982
+		}
883 983
 		
884 984
 		if ($sort != "")
885 985
 		{
@@ -1203,7 +1303,9 @@  discard block
 block discarded – undo
1203 1303
 		global $global_query;
1204 1304
 		
1205 1305
 		date_default_timezone_set('UTC');
1206
-		if ($id == '') return array();
1306
+		if ($id == '') {
1307
+			return array();
1308
+		}
1207 1309
 		$additional_query = "spotter_output.spotter_id = :id";
1208 1310
 		$query_values = array(':id' => $id);
1209 1311
 
@@ -1940,7 +2042,9 @@  discard block
 block discarded – undo
1940 2042
 		{
1941 2043
 			$highlight = $row['highlight'];
1942 2044
 		}
1943
-		if (isset($highlight)) return $highlight;
2045
+		if (isset($highlight)) {
2046
+			return $highlight;
2047
+		}
1944 2048
 	}
1945 2049
 
1946 2050
 	
@@ -1968,7 +2072,9 @@  discard block
 block discarded – undo
1968 2072
 		$sth->closeCursor();
1969 2073
 		if (count($row) > 0) {
1970 2074
 			return $row['usage'];
1971
-		} else return '';
2075
+		} else {
2076
+			return '';
2077
+		}
1972 2078
 	}
1973 2079
 
1974 2080
 	/**
@@ -1993,7 +2099,9 @@  discard block
 block discarded – undo
1993 2099
 		$sth->closeCursor();
1994 2100
 		if (count($row) > 0) {
1995 2101
 			return $row['icao'];
1996
-		} else return '';
2102
+		} else {
2103
+			return '';
2104
+		}
1997 2105
 	}
1998 2106
 
1999 2107
 	/**
@@ -2021,7 +2129,9 @@  discard block
 block discarded – undo
2021 2129
 			$airport_longitude = $row['longitude'];
2022 2130
 			$Common = new Common();
2023 2131
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
2024
-		} else return '';
2132
+		} else {
2133
+			return '';
2134
+		}
2025 2135
 	}
2026 2136
 	
2027 2137
 	/**
@@ -2133,7 +2243,9 @@  discard block
 block discarded – undo
2133 2243
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2134 2244
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2135 2245
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2136
-		} else return array();
2246
+		} else {
2247
+			return array();
2248
+		}
2137 2249
 		if ($globalDBdriver == 'mysql') {
2138 2250
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
2139 2251
 		} else {
@@ -2168,7 +2280,9 @@  discard block
 block discarded – undo
2168 2280
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2169 2281
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2170 2282
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2171
-		} else return array();
2283
+		} else {
2284
+			return array();
2285
+		}
2172 2286
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2173 2287
 		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2174 2288
 		//$query  = "SELECT waypoints.* FROM waypoints";
@@ -2203,7 +2317,9 @@  discard block
 block discarded – undo
2203 2317
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2204 2318
 	{
2205 2319
 		global $globalUseRealAirlines;
2206
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2320
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2321
+			$fromsource = NULL;
2322
+		}
2207 2323
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2208 2324
 		if ($airline_icao == 'NA') {
2209 2325
 			$airline_array = array();
@@ -2272,7 +2388,9 @@  discard block
 block discarded – undo
2272 2388
 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL)
2273 2389
 	{
2274 2390
 		global $globalUseRealAirlines;
2275
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2391
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2392
+			$fromsource = NULL;
2393
+		}
2276 2394
 		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING));
2277 2395
 		$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2278 2396
 		$sth = $this->db->prepare($query);
@@ -2288,7 +2406,9 @@  discard block
 block discarded – undo
2288 2406
 			$sth->execute(array(':fromsource' => $fromsource));
2289 2407
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
2290 2408
 			$sth->closeCursor();
2291
-			if ($row['nb'] == 0) $result = $this->getAllAirlineInfoByName($airline_name);
2409
+			if ($row['nb'] == 0) {
2410
+				$result = $this->getAllAirlineInfoByName($airline_name);
2411
+			}
2292 2412
 		}
2293 2413
 		return $result;
2294 2414
 	}
@@ -2351,15 +2471,20 @@  discard block
 block discarded – undo
2351 2471
 				'A320-211' => 'A320',
2352 2472
 				'747-8i' => 'B748',
2353 2473
 				'A380' => 'A388');
2354
-		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2474
+		if (isset($all_aircraft[$aircraft_type])) {
2475
+			return $all_aircraft[$aircraft_type];
2476
+		}
2355 2477
 
2356 2478
 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2357 2479
 		$aircraft_type = strtoupper($aircraft_type);
2358 2480
 		$sth = $this->db->prepare($query);
2359 2481
 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2360 2482
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2361
-		if (isset($result[0]['icao'])) return $result[0]['icao'];
2362
-		else return '';
2483
+		if (isset($result[0]['icao'])) {
2484
+			return $result[0]['icao'];
2485
+		} else {
2486
+			return '';
2487
+		}
2363 2488
 	}
2364 2489
 	
2365 2490
 	/**
@@ -2382,9 +2507,13 @@  discard block
 block discarded – undo
2382 2507
 		$sth->closeCursor();
2383 2508
 		if (isset($row['icaotypecode'])) {
2384 2509
 			$icao = $row['icaotypecode'];
2385
-			if (isset($this->aircraft_correct_icaotype[$icao])) $icao = $this->aircraft_correct_icaotype[$icao];
2510
+			if (isset($this->aircraft_correct_icaotype[$icao])) {
2511
+				$icao = $this->aircraft_correct_icaotype[$icao];
2512
+			}
2386 2513
 			return $icao;
2387
-		} else return '';
2514
+		} else {
2515
+			return '';
2516
+		}
2388 2517
 	}
2389 2518
 
2390 2519
 	/**
@@ -2407,7 +2536,9 @@  discard block
 block discarded – undo
2407 2536
 		$sth->closeCursor();
2408 2537
 		if (isset($row['icaotypecode'])) {
2409 2538
 			return $row['icaotypecode'];
2410
-		} else return '';
2539
+		} else {
2540
+			return '';
2541
+		}
2411 2542
 	}
2412 2543
 
2413 2544
 	/**
@@ -2453,7 +2584,9 @@  discard block
 block discarded – undo
2453 2584
 		$sth->closeCursor();
2454 2585
 		if (isset($row['operator_correct'])) {
2455 2586
 			return $row['operator_correct'];
2456
-		} else return $operator;
2587
+		} else {
2588
+			return $operator;
2589
+		}
2457 2590
 	}
2458 2591
 
2459 2592
 	/**
@@ -2466,7 +2599,9 @@  discard block
 block discarded – undo
2466 2599
 	public function getRouteInfo($callsign)
2467 2600
 	{
2468 2601
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2469
-                if ($callsign == '') return array();
2602
+                if ($callsign == '') {
2603
+                	return array();
2604
+                }
2470 2605
 		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2471 2606
 		
2472 2607
 		$sth = $this->db->prepare($query);
@@ -2476,7 +2611,9 @@  discard block
 block discarded – undo
2476 2611
 		$sth->closeCursor();
2477 2612
 		if (count($row) > 0) {
2478 2613
 			return $row;
2479
-		} else return array();
2614
+		} else {
2615
+			return array();
2616
+		}
2480 2617
 	}
2481 2618
 	
2482 2619
 	/**
@@ -2529,7 +2666,9 @@  discard block
 block discarded – undo
2529 2666
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
2530 2667
 			$sth->closeCursor();
2531 2668
 			return $result;
2532
-		} else return array();
2669
+		} else {
2670
+			return array();
2671
+		}
2533 2672
 	}
2534 2673
 	
2535 2674
   
@@ -2688,8 +2827,11 @@  discard block
 block discarded – undo
2688 2827
 		$query .= " ORDER BY spotter_output.source_name ASC";
2689 2828
 
2690 2829
 		$sth = $this->db->prepare($query);
2691
-		if (!empty($query_values)) $sth->execute($query_values);
2692
-		else $sth->execute();
2830
+		if (!empty($query_values)) {
2831
+			$sth->execute($query_values);
2832
+		} else {
2833
+			$sth->execute();
2834
+		}
2693 2835
 
2694 2836
 		$source_array = array();
2695 2837
 		$temp_array = array();
@@ -2722,9 +2864,13 @@  discard block
 block discarded – undo
2722 2864
 								WHERE spotter_output.airline_icao <> '' 
2723 2865
 								ORDER BY spotter_output.airline_name ASC";
2724 2866
 			*/
2725
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2726
-			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2727
-			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2867
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2868
+				$forsource = $globalAirlinesSource;
2869
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
2870
+				$forsource = 'vatsim';
2871
+			} elseif (isset($globalIVAO) && $globalIVAO) {
2872
+				$forsource = 'ivao';
2873
+			}
2728 2874
 			if ($forsource === NULL) {
2729 2875
 				$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC";
2730 2876
 				$query_data = array();
@@ -2767,9 +2913,13 @@  discard block
 block discarded – undo
2767 2913
 	{
2768 2914
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2769 2915
 		$filter_query = $this->getFilter($filters,true,true);
2770
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2771
-		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2772
-		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2916
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2917
+			$forsource = $globalAirlinesSource;
2918
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
2919
+			$forsource = 'vatsim';
2920
+		} elseif (isset($globalIVAO) && $globalIVAO) {
2921
+			$forsource = 'ivao';
2922
+		}
2773 2923
 		if ($forsource === NULL) {
2774 2924
 			$query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource IS NULL ORDER BY alliance ASC";
2775 2925
 			$query_data = array();
@@ -3080,7 +3230,9 @@  discard block
 block discarded – undo
3080 3230
 			date_default_timezone_set($globalTimezone);
3081 3231
 			$datetime = new DateTime();
3082 3232
 			$offset = $datetime->format('P');
3083
-		} else $offset = '+00:00';
3233
+		} else {
3234
+			$offset = '+00:00';
3235
+		}
3084 3236
 		if ($airport_icao == '') {
3085 3237
 			if ($globalDBdriver == 'mysql') {
3086 3238
 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -3112,7 +3264,9 @@  discard block
 block discarded – undo
3112 3264
 			date_default_timezone_set($globalTimezone);
3113 3265
 			$datetime = new DateTime();
3114 3266
 			$offset = $datetime->format('P');
3115
-		} else $offset = '+00:00';
3267
+		} else {
3268
+			$offset = '+00:00';
3269
+		}
3116 3270
 		if ($airport_icao == '') {
3117 3271
 			if ($globalDBdriver == 'mysql') {
3118 3272
 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -3145,7 +3299,9 @@  discard block
 block discarded – undo
3145 3299
 			date_default_timezone_set($globalTimezone);
3146 3300
 			$datetime = new DateTime();
3147 3301
 			$offset = $datetime->format('P');
3148
-		} else $offset = '+00:00';
3302
+		} else {
3303
+			$offset = '+00:00';
3304
+		}
3149 3305
 		if ($airport_icao == '') {
3150 3306
 			if ($globalDBdriver == 'mysql') {
3151 3307
 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3184,7 +3340,9 @@  discard block
 block discarded – undo
3184 3340
 			date_default_timezone_set($globalTimezone);
3185 3341
 			$datetime = new DateTime();
3186 3342
 			$offset = $datetime->format('P');
3187
-		} else $offset = '+00:00';
3343
+		} else {
3344
+			$offset = '+00:00';
3345
+		}
3188 3346
 		if ($airport_icao == '') {
3189 3347
 			if ($globalDBdriver == 'mysql') {
3190 3348
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3229,7 +3387,9 @@  discard block
 block discarded – undo
3229 3387
 			date_default_timezone_set($globalTimezone);
3230 3388
 			$datetime = new DateTime();
3231 3389
 			$offset = $datetime->format('P');
3232
-		} else $offset = '+00:00';
3390
+		} else {
3391
+			$offset = '+00:00';
3392
+		}
3233 3393
 		if ($airport_icao == '') {
3234 3394
 			if ($globalDBdriver == 'mysql') {
3235 3395
 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3264,7 +3424,9 @@  discard block
 block discarded – undo
3264 3424
 			date_default_timezone_set($globalTimezone);
3265 3425
 			$datetime = new DateTime();
3266 3426
 			$offset = $datetime->format('P');
3267
-		} else $offset = '+00:00';
3427
+		} else {
3428
+			$offset = '+00:00';
3429
+		}
3268 3430
 		if ($airport_icao == '') {
3269 3431
 			if ($globalDBdriver == 'mysql') {
3270 3432
 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3306,7 +3468,9 @@  discard block
 block discarded – undo
3306 3468
 			date_default_timezone_set($globalTimezone);
3307 3469
 			$datetime = new DateTime();
3308 3470
 			$offset = $datetime->format('P');
3309
-		} else $offset = '+00:00';
3471
+		} else {
3472
+			$offset = '+00:00';
3473
+		}
3310 3474
 		if ($airport_icao == '') {
3311 3475
 			if ($globalDBdriver == 'mysql') {
3312 3476
 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3340,7 +3504,9 @@  discard block
 block discarded – undo
3340 3504
 			date_default_timezone_set($globalTimezone);
3341 3505
 			$datetime = new DateTime();
3342 3506
 			$offset = $datetime->format('P');
3343
-		} else $offset = '+00:00';
3507
+		} else {
3508
+			$offset = '+00:00';
3509
+		}
3344 3510
 		if ($airport_icao == '') {
3345 3511
 			if ($globalDBdriver == 'mysql') {
3346 3512
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3388,7 +3554,9 @@  discard block
 block discarded – undo
3388 3554
 			date_default_timezone_set($globalTimezone);
3389 3555
 			$datetime = new DateTime();
3390 3556
 			$offset = $datetime->format('P');
3391
-		} else $offset = '+00:00';
3557
+		} else {
3558
+			$offset = '+00:00';
3559
+		}
3392 3560
 
3393 3561
 		if ($globalDBdriver == 'mysql') {
3394 3562
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -3508,7 +3676,9 @@  discard block
 block discarded – undo
3508 3676
 	*/	
3509 3677
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3510 3678
 	{
3511
-		if ($groundspeed == '') $groundspeed = NULL;
3679
+		if ($groundspeed == '') {
3680
+			$groundspeed = NULL;
3681
+		}
3512 3682
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
3513 3683
                 $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3514 3684
 
@@ -3558,10 +3728,18 @@  discard block
 block discarded – undo
3558 3728
 		$Image = new Image($this->db);
3559 3729
 		$Common = new Common();
3560 3730
 		
3561
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
3562
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
3563
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3564
-		if (!isset($globalVAM)) $globalVAM = FALSE;
3731
+		if (!isset($globalIVAO)) {
3732
+			$globalIVAO = FALSE;
3733
+		}
3734
+		if (!isset($globalVATSIM)) {
3735
+			$globalVATSIM = FALSE;
3736
+		}
3737
+		if (!isset($globalphpVMS)) {
3738
+			$globalphpVMS = FALSE;
3739
+		}
3740
+		if (!isset($globalVAM)) {
3741
+			$globalVAM = FALSE;
3742
+		}
3565 3743
 		date_default_timezone_set('UTC');
3566 3744
 		
3567 3745
 		//getting the registration
@@ -3574,23 +3752,33 @@  discard block
 block discarded – undo
3574 3752
 				if ($ModeS != '') {
3575 3753
 					$timeelapsed = microtime(true);
3576 3754
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
3577
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3755
+					if ($globalDebugTimeElapsed) {
3756
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3757
+					}
3578 3758
 				} else {
3579 3759
 					$myhex = explode('-',$flightaware_id);
3580 3760
 					if (count($myhex) > 0) {
3581 3761
 						$timeelapsed = microtime(true);
3582 3762
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
3583
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3763
+						if ($globalDebugTimeElapsed) {
3764
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3765
+						}
3584 3766
 					}
3585 3767
 				}
3586 3768
 			}
3587 3769
 		}
3588 3770
 		$fromsource = NULL;
3589
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
3590
-		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim';
3591
-		elseif ($format_source == 'whazzup') $fromsource = 'ivao';
3592
-		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
3593
-		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
3771
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
3772
+			$fromsource = $globalAirlinesSource;
3773
+		} elseif ($format_source == 'vatsimtxt') {
3774
+			$fromsource = 'vatsim';
3775
+		} elseif ($format_source == 'whazzup') {
3776
+			$fromsource = 'ivao';
3777
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
3778
+			$fromsource = 'vatsim';
3779
+		} elseif (isset($globalIVAO) && $globalIVAO) {
3780
+			$fromsource = 'ivao';
3781
+		}
3594 3782
 		//getting the airline information
3595 3783
 		if ($ident != "")
3596 3784
 		{
@@ -3614,15 +3802,21 @@  discard block
 block discarded – undo
3614 3802
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3615 3803
 						$airline_array = $this->getAllAirlineInfo("NA");
3616 3804
 					}
3617
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3805
+					if ($globalDebugTimeElapsed) {
3806
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3807
+					}
3618 3808
 
3619 3809
 				} else {
3620 3810
 					$timeelapsed = microtime(true);
3621 3811
 					$airline_array = $this->getAllAirlineInfo("NA");
3622
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3812
+					if ($globalDebugTimeElapsed) {
3813
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3814
+					}
3623 3815
 				}
3624 3816
 			}
3625
-		} else $airline_array = array();
3817
+		} else {
3818
+			$airline_array = array();
3819
+		}
3626 3820
 		
3627 3821
 		//getting the aircraft information
3628 3822
 		$aircraft_array = array();
@@ -3636,27 +3830,37 @@  discard block
 block discarded – undo
3636 3830
 				{
3637 3831
 					$timeelapsed = microtime(true);
3638 3832
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3639
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3833
+					if ($globalDebugTimeElapsed) {
3834
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3835
+					}
3640 3836
 				} else {
3641 3837
 					$timeelapsed = microtime(true);
3642 3838
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3643
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3839
+					if ($globalDebugTimeElapsed) {
3840
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3841
+					}
3644 3842
 				}
3645 3843
 			}
3646 3844
 		} else {
3647 3845
 			if ($ModeS != '') {
3648 3846
 				$timeelapsed = microtime(true);
3649 3847
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3650
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3848
+				if ($globalDebugTimeElapsed) {
3849
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3850
+				}
3651 3851
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3652 3852
 				{
3653 3853
 					$timeelapsed = microtime(true);
3654 3854
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3655
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3855
+					if ($globalDebugTimeElapsed) {
3856
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3857
+					}
3656 3858
 				} else {
3657 3859
 					$timeelapsed = microtime(true);
3658 3860
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3659
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3861
+					if ($globalDebugTimeElapsed) {
3862
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3863
+					}
3660 3864
 				}
3661 3865
 			}
3662 3866
 		}
@@ -3672,7 +3876,9 @@  discard block
 block discarded – undo
3672 3876
 			} else {
3673 3877
 				$timeelapsed = microtime(true);
3674 3878
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3675
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3879
+				if ($globalDebugTimeElapsed) {
3880
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3881
+				}
3676 3882
 			}
3677 3883
 		}
3678 3884
 		
@@ -3687,7 +3893,9 @@  discard block
 block discarded – undo
3687 3893
 			} else {
3688 3894
 				$timeelapsed = microtime(true);
3689 3895
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3690
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3896
+				if ($globalDebugTimeElapsed) {
3897
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3898
+				}
3691 3899
 			}
3692 3900
 		}
3693 3901
 
@@ -3721,7 +3929,9 @@  discard block
 block discarded – undo
3721 3929
 			{
3722 3930
 				return false;
3723 3931
 			}
3724
-		} else $altitude = 0;
3932
+		} else {
3933
+			$altitude = 0;
3934
+		}
3725 3935
 		
3726 3936
 		if ($heading != "")
3727 3937
 		{
@@ -3740,17 +3950,21 @@  discard block
 block discarded – undo
3740 3950
 		}
3741 3951
 
3742 3952
     
3743
-		if ($date == "" || strtotime($date) < time()-20*60))
3953
+		if ($date == "" || strtotime($date) < time()-20*60) {
3954
+			)
3744 3955
 		{
3745 3956
 			$date = date("Y-m-d H:i:s", time());
3746 3957
 		}
3958
+		}
3747 3959
 
3748 3960
 		//getting the aircraft image
3749 3961
 		if (($registration != "" || $registration != 'NA') && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM)
3750 3962
 		{
3751 3963
 			$timeelapsed = microtime(true);
3752 3964
 			$image_array = $Image->getSpotterImage($registration);
3753
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3965
+			if ($globalDebugTimeElapsed) {
3966
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3967
+			}
3754 3968
 			if (!isset($image_array[0]['registration']))
3755 3969
 			{
3756 3970
 				//echo "Add image !!!! \n";
@@ -3758,14 +3972,21 @@  discard block
 block discarded – undo
3758 3972
 			}
3759 3973
 			$timeelapsed = microtime(true);
3760 3974
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3761
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3762
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3975
+			if ($globalDebugTimeElapsed) {
3976
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3977
+			}
3978
+			if ($owner_info['owner'] != '') {
3979
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
3980
+			}
3763 3981
 		}
3764 3982
     
3765 3983
 		if ($globalIVAO && $aircraft_icao != '')
3766 3984
 		{
3767
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3768
-            		else $airline_icao = '';
3985
+            		if (isset($airline_array[0]['icao'])) {
3986
+            			$airline_icao = $airline_array[0]['icao'];
3987
+            		} else {
3988
+            			$airline_icao = '';
3989
+            		}
3769 3990
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3770 3991
 			if (!isset($image_array[0]['registration']))
3771 3992
 			{
@@ -3810,16 +4031,28 @@  discard block
 block discarded – undo
3810 4031
                 {
3811 4032
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3812 4033
                 }
3813
-                if ($registration == '') $registration = 'NA';
4034
+                if ($registration == '') {
4035
+                	$registration = 'NA';
4036
+                }
3814 4037
                 if ($latitude == '' && $longitude == '') {
3815 4038
             		$latitude = 0;
3816 4039
             		$longitude = 0;
3817 4040
             	}
3818
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3819
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3820
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3821
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3822
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
4041
+                if ($squawk == '' || $Common->isInteger($squawk) === false) {
4042
+                	$squawk = NULL;
4043
+                }
4044
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) {
4045
+                	$verticalrate = NULL;
4046
+                }
4047
+                if ($heading == '' || $Common->isInteger($heading) === false) {
4048
+                	$heading = 0;
4049
+                }
4050
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
4051
+                	$groundspeed = 0;
4052
+                }
4053
+                if (!isset($aircraft_owner)) {
4054
+                	$aircraft_owner = NULL;
4055
+                }
3823 4056
                 $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3824 4057
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3825 4058
 
@@ -3830,9 +4063,13 @@  discard block
 block discarded – undo
3830 4063
 		if ($airline_type == '') {
3831 4064
 			$timeelapsed = microtime(true);
3832 4065
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3833
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4066
+			if ($globalDebugTimeElapsed) {
4067
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4068
+			}
4069
+		}
4070
+		if ($airline_type == null) {
4071
+			$airline_type = '';
3834 4072
 		}
3835
-		if ($airline_type == null) $airline_type = '';
3836 4073
                 $aircraft_type = $aircraft_array[0]['type'];
3837 4074
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3838 4075
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -3996,7 +4233,9 @@  discard block
 block discarded – undo
3996 4233
 			}
3997 4234
 		}
3998 4235
 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
3999
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4236
+		if ($limit) {
4237
+			$query .= " LIMIT 10 OFFSET 0";
4238
+		}
4000 4239
 
4001 4240
 		$sth = $this->db->prepare($query);
4002 4241
 		$sth->execute($query_values);
@@ -4069,7 +4308,9 @@  discard block
 block discarded – undo
4069 4308
 		}
4070 4309
 		
4071 4310
 		$query .= " GROUP BY spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4072
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4311
+		if ($limit) {
4312
+			$query .= " LIMIT 10 OFFSET 0";
4313
+		}
4073 4314
       
4074 4315
 		
4075 4316
 		$sth = $this->db->prepare($query);
@@ -4113,7 +4354,9 @@  discard block
 block discarded – undo
4113 4354
 			}
4114 4355
 		}
4115 4356
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4116
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4357
+		if ($limit) {
4358
+			$query .= " LIMIT 10 OFFSET 0";
4359
+		}
4117 4360
       
4118 4361
 		
4119 4362
 		$sth = $this->db->prepare($query);
@@ -4189,7 +4432,9 @@  discard block
 block discarded – undo
4189 4432
 			}
4190 4433
 		}
4191 4434
 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
4192
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4435
+		if ($limit) {
4436
+			$query .= " LIMIT 10 OFFSET 0";
4437
+		}
4193 4438
 		
4194 4439
 		$sth = $this->db->prepare($query);
4195 4440
 		$sth->execute($query_values);
@@ -4231,7 +4476,9 @@  discard block
 block discarded – undo
4231 4476
 			}
4232 4477
 		}
4233 4478
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC";
4234
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4479
+		if ($limit) {
4480
+			$query .= " LIMIT 10 OFFSET 0";
4481
+		}
4235 4482
       
4236 4483
 		
4237 4484
 		$sth = $this->db->prepare($query);
@@ -4474,7 +4721,9 @@  discard block
 block discarded – undo
4474 4721
 			date_default_timezone_set($globalTimezone);
4475 4722
 			$datetime = new DateTime($date);
4476 4723
 			$offset = $datetime->format('P');
4477
-		} else $offset = '+00:00';
4724
+		} else {
4725
+			$offset = '+00:00';
4726
+		}
4478 4727
 
4479 4728
 		if ($globalDBdriver == 'mysql') {
4480 4729
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -4522,7 +4771,9 @@  discard block
 block discarded – undo
4522 4771
 			date_default_timezone_set($globalTimezone);
4523 4772
 			$datetime = new DateTime($date);
4524 4773
 			$offset = $datetime->format('P');
4525
-		} else $offset = '+00:00';
4774
+		} else {
4775
+			$offset = '+00:00';
4776
+		}
4526 4777
 		
4527 4778
 		if ($globalDBdriver == 'mysql') {
4528 4779
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4611,8 +4862,11 @@  discard block
 block discarded – undo
4611 4862
 		$sth = $this->db->prepare($query);
4612 4863
 		$sth->execute(array(':owner' => $owner));
4613 4864
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4614
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4615
-		else return $result[0]['duration'];
4865
+		if (is_int($result[0]['duration'])) {
4866
+			return gmdate('H:i:s',$result[0]['duration']);
4867
+		} else {
4868
+			return $result[0]['duration'];
4869
+		}
4616 4870
 	}
4617 4871
 
4618 4872
 	/**
@@ -4630,8 +4884,11 @@  discard block
 block discarded – undo
4630 4884
 		$sth = $this->db->prepare($query);
4631 4885
 		$sth->execute(array(':pilot' => $pilot));
4632 4886
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4633
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4634
-		else return $result[0]['duration'];
4887
+		if (is_int($result[0]['duration'])) {
4888
+			return gmdate('H:i:s',$result[0]['duration']);
4889
+		} else {
4890
+			return $result[0]['duration'];
4891
+		}
4635 4892
 	}
4636 4893
 
4637 4894
 	/**
@@ -4836,7 +5093,9 @@  discard block
 block discarded – undo
4836 5093
 		}
4837 5094
 		$query .= " GROUP BY spotter_output.airline_country
4838 5095
 					ORDER BY airline_country_count DESC";
4839
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5096
+		if ($limit) {
5097
+			$query .= " LIMIT 10 OFFSET 0";
5098
+		}
4840 5099
       
4841 5100
 		$sth = $this->db->prepare($query);
4842 5101
 		$sth->execute($query_values);
@@ -4864,7 +5123,9 @@  discard block
 block discarded – undo
4864 5123
 		global $globalDBdriver;
4865 5124
 		//$filter_query = $this->getFilter($filters,true,true);
4866 5125
 		$Connection= new Connection($this->db);
4867
-		if (!$Connection->tableExists('countries')) return array();
5126
+		if (!$Connection->tableExists('countries')) {
5127
+			return array();
5128
+		}
4868 5129
 		/*
4869 5130
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
4870 5131
 					FROM countries c, spotter_output s
@@ -4896,7 +5157,9 @@  discard block
 block discarded – undo
4896 5157
 		}
4897 5158
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spotter_live".$filter_query.") l ON c.iso2 = l.over_country ";
4898 5159
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
4899
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5160
+		if ($limit) {
5161
+			$query .= " LIMIT 10 OFFSET 0";
5162
+		}
4900 5163
       
4901 5164
 		
4902 5165
 		$sth = $this->db->prepare($query);
@@ -4973,7 +5236,9 @@  discard block
 block discarded – undo
4973 5236
 		}
4974 5237
 
4975 5238
 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
4976
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5239
+		if ($limit) {
5240
+			$query .= " LIMIT 10 OFFSET 0";
5241
+		}
4977 5242
  
4978 5243
 		$sth = $this->db->prepare($query);
4979 5244
 		$sth->execute($query_values);
@@ -5047,7 +5312,9 @@  discard block
 block discarded – undo
5047 5312
 		}
5048 5313
 
5049 5314
 		$query .= " GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5050
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5315
+		if ($limit) {
5316
+			$query .= " LIMIT 10 OFFSET 0";
5317
+		}
5051 5318
  
5052 5319
 		$sth = $this->db->prepare($query);
5053 5320
 		$sth->execute($query_values);
@@ -5094,7 +5361,9 @@  discard block
 block discarded – undo
5094 5361
 		}
5095 5362
 
5096 5363
 		$query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5097
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5364
+		if ($limit) {
5365
+			$query .= " LIMIT 10 OFFSET 0";
5366
+		}
5098 5367
  
5099 5368
 		$sth = $this->db->prepare($query);
5100 5369
 		$sth->execute();
@@ -5147,7 +5416,9 @@  discard block
 block discarded – undo
5147 5416
 			if($row['registration'] != "")
5148 5417
 			{
5149 5418
 				$image_array = $Image->getSpotterImage($row['registration']);
5150
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5419
+				if (isset($image_array[0]['image_thumbnail'])) {
5420
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5421
+				}
5151 5422
 			}
5152 5423
 			$temp_array['registration_count'] = $row['registration_count'];
5153 5424
 
@@ -5222,7 +5493,9 @@  discard block
 block discarded – undo
5222 5493
 			if($row['registration'] != "")
5223 5494
 			{
5224 5495
 				$image_array = $Image->getSpotterImage($row['registration']);
5225
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5496
+				if (isset($image_array[0]['image_thumbnail'])) {
5497
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5498
+				}
5226 5499
 			}
5227 5500
 			$temp_array['registration_count'] = $row['registration_count'];
5228 5501
 
@@ -5329,7 +5602,9 @@  discard block
 block discarded – undo
5329 5602
 			if($row['registration'] != "")
5330 5603
 			{
5331 5604
 				$image_array = $Image->getSpotterImage($row['registration']);
5332
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5605
+				if (isset($image_array[0]['image_thumbnail'])) {
5606
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5607
+				}
5333 5608
 			}
5334 5609
 			$temp_array['registration_count'] = $row['registration_count'];
5335 5610
 			$aircraft_array[] = $temp_array;
@@ -5454,7 +5729,9 @@  discard block
 block discarded – undo
5454 5729
 			date_default_timezone_set($globalTimezone);
5455 5730
 			$datetime = new DateTime($date);
5456 5731
 			$offset = $datetime->format('P');
5457
-		} else $offset = '+00:00';
5732
+		} else {
5733
+			$offset = '+00:00';
5734
+		}
5458 5735
 
5459 5736
 		if ($globalDBdriver == 'mysql') {
5460 5737
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -5501,7 +5778,9 @@  discard block
 block discarded – undo
5501 5778
 			date_default_timezone_set($globalTimezone);
5502 5779
 			$datetime = new DateTime($date);
5503 5780
 			$offset = $datetime->format('P');
5504
-		} else $offset = '+00:00';
5781
+		} else {
5782
+			$offset = '+00:00';
5783
+		}
5505 5784
 
5506 5785
 		if ($globalDBdriver == 'mysql') {
5507 5786
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
@@ -5530,7 +5809,9 @@  discard block
 block discarded – undo
5530 5809
 			if($row['registration'] != "")
5531 5810
 			{
5532 5811
 				$image_array = $Image->getSpotterImage($row['registration']);
5533
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5812
+				if (isset($image_array[0]['image_thumbnail'])) {
5813
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5814
+				}
5534 5815
 			}
5535 5816
 			$temp_array['registration_count'] = $row['registration_count'];
5536 5817
  
@@ -5555,7 +5836,9 @@  discard block
 block discarded – undo
5555 5836
 			date_default_timezone_set($globalTimezone);
5556 5837
 			$datetime = new DateTime($date);
5557 5838
 			$offset = $datetime->format('P');
5558
-		} else $offset = '+00:00';
5839
+		} else {
5840
+			$offset = '+00:00';
5841
+		}
5559 5842
 
5560 5843
 		if ($globalDBdriver == 'mysql') {
5561 5844
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -5692,8 +5975,11 @@  discard block
 block discarded – undo
5692 5975
 			if($row['registration'] != "")
5693 5976
 			{
5694 5977
 				$image_array = $Image->getSpotterImage($row['registration']);
5695
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5696
-				else $temp_array['image_thumbnail'] = '';
5978
+				if (isset($image_array[0]['image_thumbnail'])) {
5979
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5980
+				} else {
5981
+					$temp_array['image_thumbnail'] = '';
5982
+				}
5697 5983
 			}
5698 5984
 			$temp_array['registration_count'] = $row['registration_count'];
5699 5985
 			$aircraft_array[] = $temp_array;
@@ -5736,8 +6022,11 @@  discard block
 block discarded – undo
5736 6022
 			if($row['registration'] != "")
5737 6023
 			{
5738 6024
 				$image_array = $Image->getSpotterImage($row['registration']);
5739
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5740
-				else $temp_array['image_thumbnail'] = '';
6025
+				if (isset($image_array[0]['image_thumbnail'])) {
6026
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6027
+				} else {
6028
+					$temp_array['image_thumbnail'] = '';
6029
+				}
5741 6030
 			}
5742 6031
 			$temp_array['registration_count'] = $row['registration_count'];
5743 6032
 			$aircraft_array[] = $temp_array;
@@ -5780,8 +6069,11 @@  discard block
 block discarded – undo
5780 6069
 			if($row['registration'] != "")
5781 6070
 			{
5782 6071
 				$image_array = $Image->getSpotterImage($row['registration']);
5783
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5784
-				else $temp_array['image_thumbnail'] = '';
6072
+				if (isset($image_array[0]['image_thumbnail'])) {
6073
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6074
+				} else {
6075
+					$temp_array['image_thumbnail'] = '';
6076
+				}
5785 6077
 			}
5786 6078
 			$temp_array['registration_count'] = $row['registration_count'];
5787 6079
 			$aircraft_array[] = $temp_array;
@@ -5930,7 +6222,9 @@  discard block
 block discarded – undo
5930 6222
 			if($row['registration'] != "")
5931 6223
 			{
5932 6224
 				$image_array = $Image->getSpotterImage($row['registration']);
5933
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6225
+				if (isset($image_array[0]['image_thumbnail'])) {
6226
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6227
+				}
5934 6228
 			}
5935 6229
 			$temp_array['registration_count'] = $row['registration_count'];
5936 6230
           
@@ -6047,7 +6341,9 @@  discard block
 block discarded – undo
6047 6341
 			if($row['registration'] != "")
6048 6342
 			{
6049 6343
 				$image_array = $Image->getSpotterImage($row['registration']);
6050
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6344
+				if (isset($image_array[0]['image_thumbnail'])) {
6345
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6346
+				}
6051 6347
 			}
6052 6348
 			$temp_array['registration_count'] = $row['registration_count'];
6053 6349
           
@@ -6213,7 +6509,9 @@  discard block
 block discarded – undo
6213 6509
 			}
6214 6510
 		}
6215 6511
 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6216
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6512
+		if ($limit) {
6513
+			$query .= " LIMIT 10 OFFSET 0";
6514
+		}
6217 6515
 		
6218 6516
 		$sth = $this->db->prepare($query);
6219 6517
 		$sth->execute($query_values);
@@ -6232,7 +6530,9 @@  discard block
 block discarded – undo
6232 6530
 			if($row['registration'] != "")
6233 6531
 			{
6234 6532
 				$image_array = $Image->getSpotterImage($row['registration']);
6235
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6533
+				if (isset($image_array[0]['image_thumbnail'])) {
6534
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6535
+				}
6236 6536
 			}
6237 6537
           
6238 6538
 			$aircraft_array[] = $temp_array;
@@ -6273,7 +6573,9 @@  discard block
 block discarded – undo
6273 6573
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6274 6574
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6275 6575
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6276
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6576
+		if ($limit) {
6577
+			$query .= " LIMIT 10 OFFSET 0";
6578
+		}
6277 6579
 		
6278 6580
 		$sth = $this->db->prepare($query);
6279 6581
 		$sth->execute();
@@ -6293,7 +6595,9 @@  discard block
 block discarded – undo
6293 6595
 			if($row['registration'] != "")
6294 6596
 			{
6295 6597
 				$image_array = $Image->getSpotterImage($row['registration']);
6296
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6598
+				if (isset($image_array[0]['image_thumbnail'])) {
6599
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6600
+				}
6297 6601
 			}
6298 6602
           
6299 6603
 			$aircraft_array[] = $temp_array;
@@ -6359,7 +6663,9 @@  discard block
 block discarded – undo
6359 6663
 		}
6360 6664
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6361 6665
 				ORDER BY airport_departure_icao_count DESC";
6362
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6666
+		if ($limit) {
6667
+			$query .= " LIMIT 10 OFFSET 0";
6668
+		}
6363 6669
 
6364 6670
 		$sth = $this->db->prepare($query);
6365 6671
 		$sth->execute($query_values);
@@ -6410,7 +6716,9 @@  discard block
 block discarded – undo
6410 6716
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6411 6717
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6412 6718
 				ORDER BY airport_departure_icao_count DESC";
6413
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6719
+		if ($limit) {
6720
+			$query .= " LIMIT 10 OFFSET 0";
6721
+		}
6414 6722
       
6415 6723
 		$sth = $this->db->prepare($query);
6416 6724
 		$sth->execute();
@@ -6488,7 +6796,9 @@  discard block
 block discarded – undo
6488 6796
 		}
6489 6797
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6490 6798
 				ORDER BY airport_departure_icao_count DESC";
6491
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6799
+		if ($limit) {
6800
+			$query .= " LIMIT 10 OFFSET 0";
6801
+		}
6492 6802
     		//echo $query;
6493 6803
 		$sth = $this->db->prepare($query);
6494 6804
 		$sth->execute($query_values);
@@ -6540,7 +6850,9 @@  discard block
 block discarded – undo
6540 6850
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6541 6851
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6542 6852
 				ORDER BY airport_departure_icao_count DESC";
6543
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6853
+		if ($limit) {
6854
+			$query .= " LIMIT 10 OFFSET 0";
6855
+		}
6544 6856
       
6545 6857
 		$sth = $this->db->prepare($query);
6546 6858
 		$sth->execute();
@@ -6935,7 +7247,9 @@  discard block
 block discarded – undo
6935 7247
 			date_default_timezone_set($globalTimezone);
6936 7248
 			$datetime = new DateTime($date);
6937 7249
 			$offset = $datetime->format('P');
6938
-		} else $offset = '+00:00';
7250
+		} else {
7251
+			$offset = '+00:00';
7252
+		}
6939 7253
 
6940 7254
 		if ($globalDBdriver == 'mysql') {
6941 7255
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
@@ -6985,7 +7299,9 @@  discard block
 block discarded – undo
6985 7299
 			date_default_timezone_set($globalTimezone);
6986 7300
 			$datetime = new DateTime($date);
6987 7301
 			$offset = $datetime->format('P');
6988
-		} else $offset = '+00:00';
7302
+		} else {
7303
+			$offset = '+00:00';
7304
+		}
6989 7305
 
6990 7306
 		if ($globalDBdriver == 'mysql') {
6991 7307
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -7334,7 +7650,9 @@  discard block
 block discarded – undo
7334 7650
 		}
7335 7651
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7336 7652
 					ORDER BY airport_arrival_icao_count DESC";
7337
-		if ($limit) $query .= " LIMIT 10";
7653
+		if ($limit) {
7654
+			$query .= " LIMIT 10";
7655
+		}
7338 7656
       
7339 7657
 		
7340 7658
 		$sth = $this->db->prepare($query);
@@ -7354,7 +7672,9 @@  discard block
 block discarded – undo
7354 7672
 			if ($icaoaskey) {
7355 7673
 				$icao = $row['arrival_airport_icao'];
7356 7674
 				$airport_array[$icao] = $temp_array;
7357
-			} else $airport_array[] = $temp_array;
7675
+			} else {
7676
+				$airport_array[] = $temp_array;
7677
+			}
7358 7678
 		}
7359 7679
 
7360 7680
 		return $airport_array;
@@ -7391,7 +7711,9 @@  discard block
 block discarded – undo
7391 7711
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7392 7712
                 $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7393 7713
 					ORDER BY airport_arrival_icao_count DESC";
7394
-		if ($limit) $query .= " LIMIT 10";
7714
+		if ($limit) {
7715
+			$query .= " LIMIT 10";
7716
+		}
7395 7717
       
7396 7718
 		
7397 7719
 		$sth = $this->db->prepare($query);
@@ -7412,7 +7734,9 @@  discard block
 block discarded – undo
7412 7734
 			if ($icaoaskey) {
7413 7735
 				$icao = $row['arrival_airport_icao'];
7414 7736
 				$airport_array[$icao] = $temp_array;
7415
-			} else $airport_array[] = $temp_array;
7737
+			} else {
7738
+				$airport_array[] = $temp_array;
7739
+			}
7416 7740
 		}
7417 7741
 
7418 7742
 		return $airport_array;
@@ -7475,7 +7799,9 @@  discard block
 block discarded – undo
7475 7799
 		}
7476 7800
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7477 7801
 					ORDER BY airport_arrival_icao_count DESC";
7478
-		if ($limit) $query .= " LIMIT 10";
7802
+		if ($limit) {
7803
+			$query .= " LIMIT 10";
7804
+		}
7479 7805
       
7480 7806
 		
7481 7807
 		$sth = $this->db->prepare($query);
@@ -7494,7 +7820,9 @@  discard block
 block discarded – undo
7494 7820
 			if ($icaoaskey) {
7495 7821
 				$icao = $row['arrival_airport_icao'];
7496 7822
 				$airport_array[$icao] = $temp_array;
7497
-			} else $airport_array[] = $temp_array;
7823
+			} else {
7824
+				$airport_array[] = $temp_array;
7825
+			}
7498 7826
 		}
7499 7827
 
7500 7828
 		return $airport_array;
@@ -7531,7 +7859,9 @@  discard block
 block discarded – undo
7531 7859
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7532 7860
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7533 7861
 					ORDER BY airport_arrival_icao_count DESC";
7534
-		if ($limit) $query .= " LIMIT 10";
7862
+		if ($limit) {
7863
+			$query .= " LIMIT 10";
7864
+		}
7535 7865
       
7536 7866
 		
7537 7867
 		$sth = $this->db->prepare($query);
@@ -7552,7 +7882,9 @@  discard block
 block discarded – undo
7552 7882
 			if ($icaoaskey) {
7553 7883
 				$icao = $row['arrival_airport_icao'];
7554 7884
 				$airport_array[$icao] = $temp_array;
7555
-			} else $airport_array[] = $temp_array;
7885
+			} else {
7886
+				$airport_array[] = $temp_array;
7887
+			}
7556 7888
 		}
7557 7889
 
7558 7890
 		return $airport_array;
@@ -7933,7 +8265,9 @@  discard block
 block discarded – undo
7933 8265
 			date_default_timezone_set($globalTimezone);
7934 8266
 			$datetime = new DateTime($date);
7935 8267
 			$offset = $datetime->format('P');
7936
-		} else $offset = '+00:00';
8268
+		} else {
8269
+			$offset = '+00:00';
8270
+		}
7937 8271
 
7938 8272
 		if ($globalDBdriver == 'mysql') {
7939 8273
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
@@ -7983,7 +8317,9 @@  discard block
 block discarded – undo
7983 8317
 			date_default_timezone_set($globalTimezone);
7984 8318
 			$datetime = new DateTime($date);
7985 8319
 			$offset = $datetime->format('P');
7986
-		} else $offset = '+00:00';
8320
+		} else {
8321
+			$offset = '+00:00';
8322
+		}
7987 8323
 
7988 8324
 		if ($globalDBdriver == 'mysql') {
7989 8325
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -8374,7 +8710,9 @@  discard block
 block discarded – undo
8374 8710
 		}
8375 8711
 		$query .= " GROUP BY spotter_output.arrival_airport_country
8376 8712
 					ORDER BY airport_arrival_country_count DESC";
8377
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
8713
+		if ($limit) {
8714
+			$query .= " LIMIT 10 OFFSET 0";
8715
+		}
8378 8716
       
8379 8717
 		
8380 8718
 		$sth = $this->db->prepare($query);
@@ -8661,7 +8999,9 @@  discard block
 block discarded – undo
8661 8999
 			date_default_timezone_set($globalTimezone);
8662 9000
 			$datetime = new DateTime($date);
8663 9001
 			$offset = $datetime->format('P');
8664
-		} else $offset = '+00:00';
9002
+		} else {
9003
+			$offset = '+00:00';
9004
+		}
8665 9005
 		
8666 9006
 		if ($globalDBdriver == 'mysql') {
8667 9007
 			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
@@ -8917,12 +9257,18 @@  discard block
 block discarded – undo
8917 9257
 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
8918 9258
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
8919 9259
 		 if ($olderthanmonths > 0) {
8920
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
8921
-			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9260
+			if ($globalDBdriver == 'mysql') {
9261
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9262
+			} else {
9263
+				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9264
+			}
8922 9265
 		}
8923 9266
 		if ($sincedate != '') {
8924
-			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'";
8925
-			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9267
+			if ($globalDBdriver == 'mysql') {
9268
+				$query .= " AND spotter_output.date > '".$sincedate."'";
9269
+			} else {
9270
+				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9271
+			}
8926 9272
 		}
8927 9273
 		$query_values = array();
8928 9274
 		if ($year != '') {
@@ -8953,7 +9299,9 @@  discard block
 block discarded – undo
8953 9299
 			}
8954 9300
 		}
8955 9301
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
8956
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9302
+		if ($limit) {
9303
+			$query .= " LIMIT 10 OFFSET 0";
9304
+		}
8957 9305
       		
8958 9306
 		$sth = $this->db->prepare($query);
8959 9307
 		$sth->execute($query_values);
@@ -8987,15 +9335,23 @@  discard block
 block discarded – undo
8987 9335
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
8988 9336
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
8989 9337
 		 if ($olderthanmonths > 0) {
8990
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
8991
-			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9338
+			if ($globalDBdriver == 'mysql') {
9339
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9340
+			} else {
9341
+				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9342
+			}
8992 9343
 		}
8993 9344
 		if ($sincedate != '') {
8994
-			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' ";
8995
-			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9345
+			if ($globalDBdriver == 'mysql') {
9346
+				$query .= "AND spotter_output.date > '".$sincedate."' ";
9347
+			} else {
9348
+				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9349
+			}
8996 9350
 		}
8997 9351
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
8998
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9352
+		if ($limit) {
9353
+			$query .= " LIMIT 10 OFFSET 0";
9354
+		}
8999 9355
       		
9000 9356
 		$sth = $this->db->prepare($query);
9001 9357
 		$sth->execute();
@@ -9032,7 +9388,9 @@  discard block
 block discarded – undo
9032 9388
 			date_default_timezone_set($globalTimezone);
9033 9389
 			$datetime = new DateTime();
9034 9390
 			$offset = $datetime->format('P');
9035
-		} else $offset = '+00:00';
9391
+		} else {
9392
+			$offset = '+00:00';
9393
+		}
9036 9394
 
9037 9395
 		if ($globalDBdriver == 'mysql') {
9038 9396
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9081,7 +9439,9 @@  discard block
 block discarded – undo
9081 9439
 			date_default_timezone_set($globalTimezone);
9082 9440
 			$datetime = new DateTime();
9083 9441
 			$offset = $datetime->format('P');
9084
-		} else $offset = '+00:00';
9442
+		} else {
9443
+			$offset = '+00:00';
9444
+		}
9085 9445
 		$filter_query = $this->getFilter($filters,true,true);
9086 9446
 		if ($globalDBdriver == 'mysql') {
9087 9447
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9130,7 +9490,9 @@  discard block
 block discarded – undo
9130 9490
 			date_default_timezone_set($globalTimezone);
9131 9491
 			$datetime = new DateTime();
9132 9492
 			$offset = $datetime->format('P');
9133
-		} else $offset = '+00:00';
9493
+		} else {
9494
+			$offset = '+00:00';
9495
+		}
9134 9496
 		$filter_query = $this->getFilter($filters,true,true);
9135 9497
 		if ($globalDBdriver == 'mysql') {
9136 9498
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9176,7 +9538,9 @@  discard block
 block discarded – undo
9176 9538
 			date_default_timezone_set($globalTimezone);
9177 9539
 			$datetime = new DateTime();
9178 9540
 			$offset = $datetime->format('P');
9179
-		} else $offset = '+00:00';
9541
+		} else {
9542
+			$offset = '+00:00';
9543
+		}
9180 9544
 		$filter_query = $this->getFilter($filters,true,true);
9181 9545
 		if ($globalDBdriver == 'mysql') {
9182 9546
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9224,7 +9588,9 @@  discard block
 block discarded – undo
9224 9588
 			date_default_timezone_set($globalTimezone);
9225 9589
 			$datetime = new DateTime();
9226 9590
 			$offset = $datetime->format('P');
9227
-		} else $offset = '+00:00';
9591
+		} else {
9592
+			$offset = '+00:00';
9593
+		}
9228 9594
 		
9229 9595
 		if ($globalDBdriver == 'mysql') {
9230 9596
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9272,7 +9638,9 @@  discard block
 block discarded – undo
9272 9638
 			date_default_timezone_set($globalTimezone);
9273 9639
 			$datetime = new DateTime();
9274 9640
 			$offset = $datetime->format('P');
9275
-		} else $offset = '+00:00';
9641
+		} else {
9642
+			$offset = '+00:00';
9643
+		}
9276 9644
 
9277 9645
 		if ($globalDBdriver == 'mysql') {
9278 9646
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9319,7 +9687,9 @@  discard block
 block discarded – undo
9319 9687
 			date_default_timezone_set($globalTimezone);
9320 9688
 			$datetime = new DateTime();
9321 9689
 			$offset = $datetime->format('P');
9322
-		} else $offset = '+00:00';
9690
+		} else {
9691
+			$offset = '+00:00';
9692
+		}
9323 9693
 
9324 9694
 		if ($globalDBdriver == 'mysql') {
9325 9695
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9367,7 +9737,9 @@  discard block
 block discarded – undo
9367 9737
 			date_default_timezone_set($globalTimezone);
9368 9738
 			$datetime = new DateTime();
9369 9739
 			$offset = $datetime->format('P');
9370
-		} else $offset = '+00:00';
9740
+		} else {
9741
+			$offset = '+00:00';
9742
+		}
9371 9743
 		$filter_query = $this->getFilter($filters,true,true);
9372 9744
 		if ($globalDBdriver == 'mysql') {
9373 9745
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9412,7 +9784,9 @@  discard block
 block discarded – undo
9412 9784
 			date_default_timezone_set($globalTimezone);
9413 9785
 			$datetime = new DateTime();
9414 9786
 			$offset = $datetime->format('P');
9415
-		} else $offset = '+00:00';
9787
+		} else {
9788
+			$offset = '+00:00';
9789
+		}
9416 9790
 		$filter_query = $this->getFilter($filters,true,true);
9417 9791
 
9418 9792
 		if ($globalDBdriver == 'mysql') {
@@ -9459,7 +9833,9 @@  discard block
 block discarded – undo
9459 9833
 			date_default_timezone_set($globalTimezone);
9460 9834
 			$datetime = new DateTime();
9461 9835
 			$offset = $datetime->format('P');
9462
-		} else $offset = '+00:00';
9836
+		} else {
9837
+			$offset = '+00:00';
9838
+		}
9463 9839
 
9464 9840
 		if ($globalDBdriver == 'mysql') {
9465 9841
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
@@ -9505,7 +9881,9 @@  discard block
 block discarded – undo
9505 9881
 			date_default_timezone_set($globalTimezone);
9506 9882
 			$datetime = new DateTime();
9507 9883
 			$offset = $datetime->format('P');
9508
-		} else $offset = '+00:00';
9884
+		} else {
9885
+			$offset = '+00:00';
9886
+		}
9509 9887
 		$filter_query = $this->getFilter($filters,true,true);
9510 9888
 
9511 9889
 		if ($globalDBdriver == 'mysql') {
@@ -9552,7 +9930,9 @@  discard block
 block discarded – undo
9552 9930
 			date_default_timezone_set($globalTimezone);
9553 9931
 			$datetime = new DateTime();
9554 9932
 			$offset = $datetime->format('P');
9555
-		} else $offset = '+00:00';
9933
+		} else {
9934
+			$offset = '+00:00';
9935
+		}
9556 9936
 
9557 9937
 		if ($globalDBdriver == 'mysql') {
9558 9938
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
@@ -9599,7 +9979,9 @@  discard block
 block discarded – undo
9599 9979
 			date_default_timezone_set($globalTimezone);
9600 9980
 			$datetime = new DateTime();
9601 9981
 			$offset = $datetime->format('P');
9602
-		} else $offset = '+00:00';
9982
+		} else {
9983
+			$offset = '+00:00';
9984
+		}
9603 9985
 
9604 9986
 		if ($globalDBdriver == 'mysql') {
9605 9987
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
@@ -9644,7 +10026,9 @@  discard block
 block discarded – undo
9644 10026
 			date_default_timezone_set($globalTimezone);
9645 10027
 			$datetime = new DateTime();
9646 10028
 			$offset = $datetime->format('P');
9647
-		} else $offset = '+00:00';
10029
+		} else {
10030
+			$offset = '+00:00';
10031
+		}
9648 10032
 		$filter_query = $this->getFilter($filters,true,true);
9649 10033
 
9650 10034
 		if ($globalDBdriver == 'mysql') {
@@ -9692,7 +10076,9 @@  discard block
 block discarded – undo
9692 10076
 			date_default_timezone_set($globalTimezone);
9693 10077
 			$datetime = new DateTime();
9694 10078
 			$offset = $datetime->format('P');
9695
-		} else $offset = '+00:00';
10079
+		} else {
10080
+			$offset = '+00:00';
10081
+		}
9696 10082
 
9697 10083
 		if ($globalDBdriver == 'mysql') {
9698 10084
 			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
@@ -9738,7 +10124,9 @@  discard block
 block discarded – undo
9738 10124
 			date_default_timezone_set($globalTimezone);
9739 10125
 			$datetime = new DateTime();
9740 10126
 			$offset = $datetime->format('P');
9741
-		} else $offset = '+00:00';
10127
+		} else {
10128
+			$offset = '+00:00';
10129
+		}
9742 10130
 		$filter_query = $this->getFilter($filters,true,true);
9743 10131
 
9744 10132
 		if ($globalDBdriver == 'mysql') {
@@ -9786,7 +10174,9 @@  discard block
 block discarded – undo
9786 10174
 			date_default_timezone_set($globalTimezone);
9787 10175
 			$datetime = new DateTime();
9788 10176
 			$offset = $datetime->format('P');
9789
-		} else $offset = '+00:00';
10177
+		} else {
10178
+			$offset = '+00:00';
10179
+		}
9790 10180
 
9791 10181
 		if ($globalDBdriver == 'mysql') {
9792 10182
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
@@ -9833,7 +10223,9 @@  discard block
 block discarded – undo
9833 10223
 			date_default_timezone_set($globalTimezone);
9834 10224
 			$datetime = new DateTime();
9835 10225
 			$offset = $datetime->format('P');
9836
-		} else $offset = '+00:00';
10226
+		} else {
10227
+			$offset = '+00:00';
10228
+		}
9837 10229
 		$filter_query = $this->getFilter($filters,true,true);
9838 10230
 		if ($globalDBdriver == 'mysql') {
9839 10231
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -9882,7 +10274,9 @@  discard block
 block discarded – undo
9882 10274
 			date_default_timezone_set($globalTimezone);
9883 10275
 			$datetime = new DateTime();
9884 10276
 			$offset = $datetime->format('P');
9885
-		} else $offset = '+00:00';
10277
+		} else {
10278
+			$offset = '+00:00';
10279
+		}
9886 10280
 
9887 10281
 		$orderby_sql = '';
9888 10282
 		if ($orderby == "hour")
@@ -9948,7 +10342,9 @@  discard block
 block discarded – undo
9948 10342
 			date_default_timezone_set($globalTimezone);
9949 10343
 			$datetime = new DateTime();
9950 10344
 			$offset = $datetime->format('P');
9951
-		} else $offset = '+00:00';
10345
+		} else {
10346
+			$offset = '+00:00';
10347
+		}
9952 10348
 
9953 10349
 		$orderby_sql = '';
9954 10350
 		if ($orderby == "hour")
@@ -10015,7 +10411,9 @@  discard block
 block discarded – undo
10015 10411
 			date_default_timezone_set($globalTimezone);
10016 10412
 			$datetime = new DateTime();
10017 10413
 			$offset = $datetime->format('P');
10018
-		} else $offset = '+00:00';
10414
+		} else {
10415
+			$offset = '+00:00';
10416
+		}
10019 10417
 
10020 10418
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
10021 10419
 
@@ -10066,7 +10464,9 @@  discard block
 block discarded – undo
10066 10464
 			date_default_timezone_set($globalTimezone);
10067 10465
 			$datetime = new DateTime();
10068 10466
 			$offset = $datetime->format('P');
10069
-		} else $offset = '+00:00';
10467
+		} else {
10468
+			$offset = '+00:00';
10469
+		}
10070 10470
 
10071 10471
 		if ($globalDBdriver == 'mysql') {
10072 10472
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10113,7 +10513,9 @@  discard block
 block discarded – undo
10113 10513
 			date_default_timezone_set($globalTimezone);
10114 10514
 			$datetime = new DateTime();
10115 10515
 			$offset = $datetime->format('P');
10116
-		} else $offset = '+00:00';
10516
+		} else {
10517
+			$offset = '+00:00';
10518
+		}
10117 10519
 
10118 10520
 		if ($globalDBdriver == 'mysql') {
10119 10521
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10160,7 +10562,9 @@  discard block
 block discarded – undo
10160 10562
 			date_default_timezone_set($globalTimezone);
10161 10563
 			$datetime = new DateTime();
10162 10564
 			$offset = $datetime->format('P');
10163
-		} else $offset = '+00:00';
10565
+		} else {
10566
+			$offset = '+00:00';
10567
+		}
10164 10568
 
10165 10569
 		if ($globalDBdriver == 'mysql') {
10166 10570
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10208,7 +10612,9 @@  discard block
 block discarded – undo
10208 10612
 			date_default_timezone_set($globalTimezone);
10209 10613
 			$datetime = new DateTime();
10210 10614
 			$offset = $datetime->format('P');
10211
-		} else $offset = '+00:00';
10615
+		} else {
10616
+			$offset = '+00:00';
10617
+		}
10212 10618
 
10213 10619
 		if ($globalDBdriver == 'mysql') {
10214 10620
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10256,7 +10662,9 @@  discard block
 block discarded – undo
10256 10662
 			date_default_timezone_set($globalTimezone);
10257 10663
 			$datetime = new DateTime($date);
10258 10664
 			$offset = $datetime->format('P');
10259
-		} else $offset = '+00:00';
10665
+		} else {
10666
+			$offset = '+00:00';
10667
+		}
10260 10668
 
10261 10669
 		if ($globalDBdriver == 'mysql') {
10262 10670
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10304,7 +10712,9 @@  discard block
 block discarded – undo
10304 10712
 			date_default_timezone_set($globalTimezone);
10305 10713
 			$datetime = new DateTime();
10306 10714
 			$offset = $datetime->format('P');
10307
-		} else $offset = '+00:00';
10715
+		} else {
10716
+			$offset = '+00:00';
10717
+		}
10308 10718
 
10309 10719
 		if ($globalDBdriver == 'mysql') {
10310 10720
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10351,7 +10761,9 @@  discard block
 block discarded – undo
10351 10761
 			date_default_timezone_set($globalTimezone);
10352 10762
 			$datetime = new DateTime();
10353 10763
 			$offset = $datetime->format('P');
10354
-		} else $offset = '+00:00';
10764
+		} else {
10765
+			$offset = '+00:00';
10766
+		}
10355 10767
 
10356 10768
 		if ($globalDBdriver == 'mysql') {
10357 10769
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10398,7 +10810,9 @@  discard block
 block discarded – undo
10398 10810
 			date_default_timezone_set($globalTimezone);
10399 10811
 			$datetime = new DateTime();
10400 10812
 			$offset = $datetime->format('P');
10401
-		} else $offset = '+00:00';
10813
+		} else {
10814
+			$offset = '+00:00';
10815
+		}
10402 10816
 
10403 10817
 		if ($globalDBdriver == 'mysql') {
10404 10818
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10448,7 +10862,9 @@  discard block
 block discarded – undo
10448 10862
 			date_default_timezone_set($globalTimezone);
10449 10863
 			$datetime = new DateTime();
10450 10864
 			$offset = $datetime->format('P');
10451
-		} else $offset = '+00:00';
10865
+		} else {
10866
+			$offset = '+00:00';
10867
+		}
10452 10868
 
10453 10869
 		if ($globalDBdriver == 'mysql') {
10454 10870
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10495,7 +10911,9 @@  discard block
 block discarded – undo
10495 10911
 			date_default_timezone_set($globalTimezone);
10496 10912
 			$datetime = new DateTime();
10497 10913
 			$offset = $datetime->format('P');
10498
-		} else $offset = '+00:00';
10914
+		} else {
10915
+			$offset = '+00:00';
10916
+		}
10499 10917
 
10500 10918
 		if ($globalDBdriver == 'mysql') {
10501 10919
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10706,8 +11124,11 @@  discard block
 block discarded – undo
10706 11124
 				$query_values = array_merge($query_values,array(':month' => $month));
10707 11125
 			}
10708 11126
 		}
10709
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
10710
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11127
+		if (empty($query_values)) {
11128
+			$queryi .= $this->getFilter($filters);
11129
+		} else {
11130
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11131
+		}
10711 11132
 		
10712 11133
 		//echo $query;
10713 11134
 		$sth = $this->db->prepare($queryi);
@@ -10786,8 +11207,11 @@  discard block
 block discarded – undo
10786 11207
 				$query_values = array_merge($query_values,array(':month' => $month));
10787 11208
 			}
10788 11209
 		}
10789
-                if ($query == '') $queryi .= $this->getFilter($filters);
10790
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11210
+                if ($query == '') {
11211
+                	$queryi .= $this->getFilter($filters);
11212
+                } else {
11213
+                	$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11214
+                }
10791 11215
 
10792 11216
 
10793 11217
 		$sth = $this->db->prepare($queryi);
@@ -10810,7 +11234,9 @@  discard block
 block discarded – undo
10810 11234
 			date_default_timezone_set($globalTimezone);
10811 11235
 			$datetime = new DateTime();
10812 11236
 			$offset = $datetime->format('P');
10813
-		} else $offset = '+00:00';
11237
+		} else {
11238
+			$offset = '+00:00';
11239
+		}
10814 11240
 
10815 11241
 		if ($globalDBdriver == 'mysql') {
10816 11242
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10996,7 +11422,9 @@  discard block
 block discarded – undo
10996 11422
 	*/
10997 11423
 	public function parseDirection($direction = 0)
10998 11424
 	{
10999
-		if ($direction == '') $direction = 0;
11425
+		if ($direction == '') {
11426
+			$direction = 0;
11427
+		}
11000 11428
 		$direction_array = array();
11001 11429
 		$temp_array = array();
11002 11430
 
@@ -11097,7 +11525,9 @@  discard block
 block discarded – undo
11097 11525
 		if (isset($result->AirlineFlightInfoResult))
11098 11526
 		{
11099 11527
 			$registration = $result->AirlineFlightInfoResult->tailnumber;
11100
-		} else return '';
11528
+		} else {
11529
+			return '';
11530
+		}
11101 11531
 		
11102 11532
 		$registration = $this->convertAircraftRegistration($registration);
11103 11533
 		
@@ -11126,7 +11556,9 @@  discard block
 block discarded – undo
11126 11556
 		if (count($row) > 0) {
11127 11557
 		    //return $row['Registration'];
11128 11558
 		    return $row['registration'];
11129
-		} else return '';
11559
+		} else {
11560
+			return '';
11561
+		}
11130 11562
 	
11131 11563
 	}
11132 11564
 
@@ -11149,9 +11581,14 @@  discard block
 block discarded – undo
11149 11581
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11150 11582
 		$sth->closeCursor();
11151 11583
 		if (count($row) > 0) {
11152
-		    if ($row['type_flight'] == null) return '';
11153
-		    else return $row['type_flight'];
11154
-		} else return '';
11584
+		    if ($row['type_flight'] == null) {
11585
+		    	return '';
11586
+		    } else {
11587
+		    	return $row['type_flight'];
11588
+		    }
11589
+		} else {
11590
+			return '';
11591
+		}
11155 11592
 	
11156 11593
 	}
11157 11594
 
@@ -11169,7 +11606,9 @@  discard block
 block discarded – undo
11169 11606
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11170 11607
 	
11171 11608
 		$Connection = new Connection($this->db);
11172
-		if (!$Connection->tableExists('countries')) return '';
11609
+		if (!$Connection->tableExists('countries')) {
11610
+			return '';
11611
+		}
11173 11612
 	
11174 11613
 		try {
11175 11614
 			/*
@@ -11189,9 +11628,13 @@  discard block
 block discarded – undo
11189 11628
 			$sth->closeCursor();
11190 11629
 			if (count($row) > 0) {
11191 11630
 				return $row;
11192
-			} else return '';
11631
+			} else {
11632
+				return '';
11633
+			}
11193 11634
 		} catch (PDOException $e) {
11194
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
11635
+			if (isset($globalDebug) && $globalDebug) {
11636
+				echo 'Error : '.$e->getMessage()."\n";
11637
+			}
11195 11638
 			return '';
11196 11639
 		}
11197 11640
 	
@@ -11209,7 +11652,9 @@  discard block
 block discarded – undo
11209 11652
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
11210 11653
 	
11211 11654
 		$Connection = new Connection($this->db);
11212
-		if (!$Connection->tableExists('countries')) return '';
11655
+		if (!$Connection->tableExists('countries')) {
11656
+			return '';
11657
+		}
11213 11658
 	
11214 11659
 		try {
11215 11660
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -11221,9 +11666,13 @@  discard block
 block discarded – undo
11221 11666
 			$sth->closeCursor();
11222 11667
 			if (count($row) > 0) {
11223 11668
 				return $row;
11224
-			} else return '';
11669
+			} else {
11670
+				return '';
11671
+			}
11225 11672
 		} catch (PDOException $e) {
11226
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
11673
+			if (isset($globalDebug) && $globalDebug) {
11674
+				echo 'Error : '.$e->getMessage()."\n";
11675
+			}
11227 11676
 			return '';
11228 11677
 		}
11229 11678
 	
@@ -11473,7 +11922,9 @@  discard block
 block discarded – undo
11473 11922
 	{
11474 11923
 		global $globalBitlyAccessToken;
11475 11924
 		
11476
-		if ($globalBitlyAccessToken == '') return $url;
11925
+		if ($globalBitlyAccessToken == '') {
11926
+			return $url;
11927
+		}
11477 11928
         
11478 11929
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
11479 11930
 		
@@ -11622,7 +12073,9 @@  discard block
 block discarded – undo
11622 12073
 		
11623 12074
 
11624 12075
 		// routes
11625
-		if ($globalDebug) print "Routes...\n";
12076
+		if ($globalDebug) {
12077
+			print "Routes...\n";
12078
+		}
11626 12079
 		if ($globalDBdriver == 'mysql') {
11627 12080
 			$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
11628 12081
 		} else {
@@ -11641,7 +12094,9 @@  discard block
 block discarded – undo
11641 12094
 			}
11642 12095
 		}
11643 12096
 		
11644
-		if ($globalDebug) print "Airlines...\n";
12097
+		if ($globalDebug) {
12098
+			print "Airlines...\n";
12099
+		}
11645 12100
 		//airlines
11646 12101
 		if ($globalDBdriver == 'mysql') {
11647 12102
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
@@ -11655,10 +12110,15 @@  discard block
 block discarded – undo
11655 12110
 			if (is_numeric(substr($row['ident'], -1, 1)))
11656 12111
 			{
11657 12112
 				$fromsource = NULL;
11658
-				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
11659
-				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
11660
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
11661
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
12113
+				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
12114
+					$fromsource = 'vatsim';
12115
+				} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
12116
+					$fromsource = 'ivao';
12117
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
12118
+					$fromsource = 'vatsim';
12119
+				} elseif (isset($globalIVAO) && $globalIVAO) {
12120
+					$fromsource = 'ivao';
12121
+				}
11662 12122
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
11663 12123
 				if (isset($airline_array[0]['name'])) {
11664 12124
 					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
@@ -11668,13 +12128,17 @@  discard block
 block discarded – undo
11668 12128
 			}
11669 12129
 		}
11670 12130
 
11671
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
12131
+		if ($globalDebug) {
12132
+			print "Remove Duplicate in aircraft_modes...\n";
12133
+		}
11672 12134
 		//duplicate modes
11673 12135
 		$query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL";
11674 12136
 		$sth = $this->db->prepare($query);
11675 12137
 		$sth->execute();
11676 12138
 		
11677
-		if ($globalDebug) print "Aircraft...\n";
12139
+		if ($globalDebug) {
12140
+			print "Aircraft...\n";
12141
+		}
11678 12142
 		//aircraft
11679 12143
 		if ($globalDBdriver == 'mysql') {
11680 12144
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -11717,26 +12181,38 @@  discard block
 block discarded – undo
11717 12181
 				 if (isset($closestAirports[0])) {
11718 12182
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
11719 12183
 						$airport_icao = $closestAirports[0]['icao'];
11720
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12184
+						if ($globalDebug) {
12185
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12186
+						}
11721 12187
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
11722 12188
 						foreach ($closestAirports as $airport) {
11723 12189
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
11724 12190
 								$airport_icao = $airport['icao'];
11725
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12191
+								if ($globalDebug) {
12192
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12193
+								}
11726 12194
 								break;
11727 12195
 							}
11728 12196
 						}
11729 12197
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
11730 12198
 						$airport_icao = $closestAirports[0]['icao'];
11731
-						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12199
+						if ($globalDebug) {
12200
+							echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12201
+						}
11732 12202
 					} else {
11733
-						if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12203
+						if ($globalDebug) {
12204
+							echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12205
+						}
11734 12206
 					}
11735 12207
 				} else {
11736
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12208
+					if ($globalDebug) {
12209
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12210
+					}
11737 12211
 				}
11738 12212
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
11739
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
12213
+					if ($globalDebug) {
12214
+						echo "Updating airport to ".$airport_icao."...\n";
12215
+					}
11740 12216
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
11741 12217
 					$sthu = $this->db->prepare($update_query);
11742 12218
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.