Completed
Push — master ( c1d943...56b04e )
by Yannick
07:43
created
scripts/daemon-spotter.php 1 patch
Braces   +547 added lines, -189 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 
17
-if (!isset($globalDebug)) $globalDebug = FALSE;
17
+if (!isset($globalDebug)) {
18
+	$globalDebug = FALSE;
19
+}
18 20
 
19 21
 // Check if schema is at latest version
20 22
 $Connection = new Connection();
@@ -54,13 +56,22 @@  discard block
 block discarded – undo
54 56
     $globalSources = array();
55 57
     $globalSources[] = array('host' => $options['source']);
56 58
 }
57
-if (isset($options['server'])) $globalServer = TRUE;
58
-if (isset($options['idsource'])) $id_source = $options['idsource'];
59
-else $id_source = 1;
59
+if (isset($options['server'])) {
60
+	$globalServer = TRUE;
61
+}
62
+if (isset($options['idsource'])) {
63
+	$id_source = $options['idsource'];
64
+} else {
65
+	$id_source = 1;
66
+}
60 67
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
68
+    if ($globalDebug) {
69
+    	echo "Using Server Mode\n";
70
+    }
62 71
     $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
72
+} else {
73
+	$SI=new SpotterImport($Connection->db);
74
+}
64 75
 //$APRS=new APRS($Connection->db);
65 76
 $SBS=new SBS();
66 77
 $ACARS=new ACARS($Connection->db);
@@ -78,7 +89,9 @@  discard block
 block discarded – undo
78 89
 }
79 90
 
80 91
 // let's try and connect
81
-if ($globalDebug) echo "Connecting...\n";
92
+if ($globalDebug) {
93
+	echo "Connecting...\n";
94
+}
82 95
 $use_aprs = false;
83 96
 $aprs_full = false;
84 97
 $reset = 0;
@@ -87,7 +100,9 @@  discard block
 block discarded – undo
87 100
     $ip = gethostbyname($host);
88 101
     $s = socket_create(AF_INET, SOCK_STREAM, 0);
89 102
     $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
103
+    if (!socket_set_nonblock($s)) {
104
+    	echo "Unable to set nonblock on socket\n";
105
+    }
91 106
     if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92 107
         return $s;
93 108
     }
@@ -115,7 +130,9 @@  discard block
 block discarded – undo
115 130
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 131
     global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117 132
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
133
+    if ($globalDebug) {
134
+    	echo 'Connect to all...'."\n";
135
+    }
119 136
     foreach ($hosts as $id => $value) {
120 137
 	$host = $value['host'];
121 138
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,27 +142,37 @@  discard block
 block discarded – undo
125 142
         	//$formats[$id] = 'deltadbtxt';
126 143
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 144
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
145
+        	if ($globalDebug) {
146
+        		echo "Connect to deltadb source (".$host.")...\n";
147
+        	}
129 148
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 149
         	//$formats[$id] = 'vatsimtxt';
131 150
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 151
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
152
+        	if ($globalDebug) {
153
+        		echo "Connect to vatsim source (".$host.")...\n";
154
+        	}
134 155
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 156
         	//$formats[$id] = 'aircraftlistjson';
136 157
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 158
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
159
+        	if ($globalDebug) {
160
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
161
+        	}
139 162
     	    } else if (preg_match('/opensky/i',$host)) {
140 163
         	//$formats[$id] = 'aircraftlistjson';
141 164
         	$globalSources[$id]['format'] = 'opensky';
142 165
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
166
+        	if ($globalDebug) {
167
+        		echo "Connect to opensky source (".$host.")...\n";
168
+        	}
144 169
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145 170
         	//$formats[$id] = 'radarvirtueljson';
146 171
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 172
         	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
173
+        	if ($globalDebug) {
174
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
175
+        	}
149 176
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150 177
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 178
         	    exit(0);
@@ -154,7 +181,9 @@  discard block
 block discarded – undo
154 181
         	//$formats[$id] = 'planeupdatefaa';
155 182
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 183
         	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
186
+        	}
158 187
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159 188
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 189
         	    exit(0);
@@ -163,26 +192,36 @@  discard block
 block discarded – undo
163 192
         	//$formats[$id] = 'phpvmacars';
164 193
         	$globalSources[$id]['format'] = 'phpvmacars';
165 194
         	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
195
+        	if ($globalDebug) {
196
+        		echo "Connect to phpvmacars source (".$host.")...\n";
197
+        	}
167 198
             } else if (preg_match('/VAM-json.php$/i',$host)) {
168 199
         	//$formats[$id] = 'phpvmacars';
169 200
         	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
201
+        	if ($globalDebug) {
202
+        		echo "Connect to Vam source (".$host.")...\n";
203
+        	}
171 204
             } else if (preg_match('/whazzup/i',$host)) {
172 205
         	//$formats[$id] = 'whazzup';
173 206
         	$globalSources[$id]['format'] = 'whazzup';
174 207
         	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
208
+        	if ($globalDebug) {
209
+        		echo "Connect to whazzup source (".$host.")...\n";
210
+        	}
176 211
             } else if (preg_match('/recentpireps/i',$host)) {
177 212
         	//$formats[$id] = 'pirepsjson';
178 213
         	$globalSources[$id]['format'] = 'pirepsjson';
179 214
         	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
215
+        	if ($globalDebug) {
216
+        		echo "Connect to pirepsjson source (".$host.")...\n";
217
+        	}
181 218
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182 219
         	//$formats[$id] = 'fr24json';
183 220
         	$globalSources[$id]['format'] = 'fr24json';
184 221
         	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to fr24 source (".$host.")...\n";
224
+        	}
186 225
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187 226
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188 227
         	    exit(0);
@@ -191,10 +230,14 @@  discard block
 block discarded – undo
191 230
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 231
         	//$formats[$id] = 'tsv';
193 232
         	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
233
+        	if ($globalDebug) {
234
+        		echo "Connect to tsv source (".$host.")...\n";
235
+        	}
195 236
             }
196 237
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
238
+        	if ($globalDebug) {
239
+        		echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
+        	}
198 241
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199 242
 	    $hostport = explode(':',$host);
200 243
 	    if (isset($hostport[1])) {
@@ -231,17 +274,25 @@  discard block
 block discarded – undo
231 274
         		//$formats[$id] = 'beast';
232 275
         		$globalSources[$id]['format'] = 'beast';
233 276
 		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
277
+		    } else {
278
+		    	$globalSources[$id]['format'] = 'sbs';
279
+		    }
235 280
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 281
 		}
237
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
282
+		if ($globalDebug) {
283
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
284
+		}
238 285
             } else {
239
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
286
+		if ($globalDebug) {
287
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
288
+		}
240 289
     	    }
241 290
         }
242 291
     }
243 292
 }
244
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
293
+if (!isset($globalMinFetch)) {
294
+	$globalMinFetch = 15;
295
+}
245 296
 
246 297
 // Initialize all
247 298
 $status = array();
@@ -249,13 +300,19 @@  discard block
 block discarded – undo
249 300
 $formats = array();
250 301
 $last_exec = array();
251 302
 $time = time();
252
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
253
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254
-else $timeout = 20;
303
+if (isset($globalSourcesTimeout)) {
304
+	$timeout = $globalSourcesTimeOut;
305
+} else if (isset($globalSBS1TimeOut)) {
306
+	$timeout = $globalSBS1TimeOut;
307
+} else {
308
+	$timeout = 20;
309
+}
255 310
 $errno = '';
256 311
 $errstr='';
257 312
 
258
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
313
+if (!isset($globalDaemon)) {
314
+	$globalDaemon = TRUE;
315
+}
259 316
 /* Initiate connections to all the hosts simultaneously */
260 317
 //connect_all($hosts);
261 318
 //connect_all($globalSources);
@@ -275,7 +332,9 @@  discard block
 block discarded – undo
275 332
     if (isset($source['format']) && $source['format'] == 'aprs') {
276 333
 	$aprs_connect = 0;
277 334
 	$use_aprs = true;
278
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
335
+	if (isset($source['port']) && $source['port'] == '10152') {
336
+		$aprs_full = true;
337
+	}
279 338
 	break;
280 339
     }
281 340
 }
@@ -286,23 +345,43 @@  discard block
 block discarded – undo
286 345
 	$aprs_connect = 0;
287 346
 	$aprs_keep = 120;
288 347
 	$aprs_last_tx = time();
289
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
290
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
291
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
292
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
293
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
294
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
295
-	if ($aprs_full) $aprs_filter = '';
348
+	if (isset($globalAPRSversion)) {
349
+		$aprs_version = $globalAPRSversion;
350
+	} else {
351
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
352
+	}
353
+	if (isset($globalAPRSssid)) {
354
+		$aprs_ssid = $globalAPRSssid;
355
+	} else {
356
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
357
+	}
358
+	if (isset($globalAPRSfilter)) {
359
+		$aprs_filter = $globalAPRSfilter;
360
+	} else {
361
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
362
+	}
363
+	if ($aprs_full) {
364
+		$aprs_filter = '';
365
+	}
296 366
 
297
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
298
-	else $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n";
299
-}
367
+	if ($aprs_filter != '') {
368
+		$aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
369
+	} else {
370
+		$aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n";
371
+	}
372
+	}
300 373
 
301 374
 // connected - lets do some work
302
-if ($globalDebug) echo "Connected!\n";
375
+if ($globalDebug) {
376
+	echo "Connected!\n";
377
+}
303 378
 sleep(1);
304
-if ($globalDebug) echo "SCAN MODE \n\n";
305
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
379
+if ($globalDebug) {
380
+	echo "SCAN MODE \n\n";
381
+}
382
+if (!isset($globalCronEnd)) {
383
+	$globalCronEnd = 60;
384
+}
306 385
 $endtime = time()+$globalCronEnd;
307 386
 $i = 1;
308 387
 $tt = array();
@@ -316,20 +395,28 @@  discard block
 block discarded – undo
316 395
 
317 396
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
318 397
 while ($i > 0) {
319
-    if (!$globalDaemon) $i = $endtime-time();
398
+    if (!$globalDaemon) {
399
+    	$i = $endtime-time();
400
+    }
320 401
     // Delete old ATC
321 402
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
322
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
403
+	if ($globalDebug) {
404
+		echo 'Delete old ATC...'."\n";
405
+	}
323 406
         $ATC->deleteOldATC();
324 407
     }
325 408
     
326 409
     if (count($last_exec) > 0) {
327 410
 	$max = $globalMinFetch;
328 411
 	foreach ($last_exec as $last) {
329
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
412
+	    if ((time() - $last['last']) < $max) {
413
+	    	$max = time() - $last['last'];
414
+	    }
330 415
 	}
331 416
 	if ($max != $globalMinFetch) {
332
-	    if ($globalDebug) echo 'Sleeping...'."\n";
417
+	    if ($globalDebug) {
418
+	    	echo 'Sleeping...'."\n";
419
+	    }
333 420
 	    sleep($globalMinFetch-$max+2);
334 421
 	}
335 422
     }
@@ -338,11 +425,15 @@  discard block
 block discarded – undo
338 425
     //foreach ($formats as $id => $value) {
339 426
     foreach ($globalSources as $id => $value) {
340 427
 	date_default_timezone_set('UTC');
341
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
428
+	if (!isset($last_exec[$id]['last'])) {
429
+		$last_exec[$id]['last'] = 0;
430
+	}
342 431
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
343 432
 	    //$buffer = $Common->getData($hosts[$id]);
344 433
 	    $buffer = $Common->getData($value['host']);
345
-	    if ($buffer != '') $reset = 0;
434
+	    if ($buffer != '') {
435
+	    	$reset = 0;
436
+	    }
346 437
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347 438
 	    $buffer = explode('\n',$buffer);
348 439
 	    foreach ($buffer as $line) {
@@ -351,19 +442,38 @@  discard block
 block discarded – undo
351 442
 	            $data = array();
352 443
 	            $data['hex'] = $line[1]; // hex
353 444
 	            $data['ident'] = $line[2]; // ident
354
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
445
+	            if (isset($line[3])) {
446
+	            	$data['altitude'] = $line[3];
447
+	            }
448
+	            // altitude
449
+	            if (isset($line[4])) {
450
+	            	$data['speed'] = $line[4];
451
+	            }
452
+	            // speed
453
+	            if (isset($line[5])) {
454
+	            	$data['heading'] = $line[5];
455
+	            }
456
+	            // heading
457
+	            if (isset($line[6])) {
458
+	            	$data['latitude'] = $line[6];
459
+	            }
460
+	            // lat
461
+	            if (isset($line[7])) {
462
+	            	$data['longitude'] = $line[7];
463
+	            }
464
+	            // long
359 465
 	            $data['verticalrate'] = ''; // vertical rate
360 466
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361 467
 	            $data['emergency'] = ''; // emergency
362 468
 		    $data['datetime'] = date('Y-m-d H:i:s');
363 469
 		    $data['format_source'] = 'deltadbtxt';
364 470
     		    $data['id_source'] = $id_source;
365
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
471
+		    if (isset($value['name']) && $value['name'] != '') {
472
+		    	$data['source_name'] = $value['name'];
473
+		    }
474
+		    if (isset($value['sourcestats'])) {
475
+		    	$data['sourcestats'] = $value['sourcestats'];
476
+		    }
367 477
     		    $SI->add($data);
368 478
 		    unset($data);
369 479
     		}
@@ -381,16 +491,28 @@  discard block
 block discarded – undo
381 491
     		    $line = explode(':', $line);
382 492
     		    if (count($line) > 30 && $line[0] != 'callsign') {
383 493
 			$data = array();
384
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
385
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
494
+			if (isset($line[37]) && $line[37] != '') {
495
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
496
+			} else {
497
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
498
+			}
386 499
 			$data['pilot_id'] = $line[1];
387 500
 			$data['pilot_name'] = $line[2];
388 501
 			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
389 502
 			$data['ident'] = $line[0]; // ident
390
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
503
+			if ($line[7] != '' && $line[7] != 0) {
504
+				$data['altitude'] = $line[7];
505
+			}
506
+			// altitude
391 507
 			$data['speed'] = $line[8]; // speed
392
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
393
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
508
+			if (isset($line[45])) {
509
+				$data['heading'] = $line[45];
510
+			}
511
+			// heading
512
+			elseif (isset($line[38])) {
513
+				$data['heading'] = $line[38];
514
+			}
515
+			// heading
394 516
 			$data['latitude'] = $line[5]; // lat
395 517
 	        	$data['longitude'] = $line[6]; // long
396 518
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -406,7 +528,9 @@  discard block
 block discarded – undo
406 528
 			$data['frequency'] = $line[4];
407 529
 			$data['type'] = $line[18];
408 530
 			$data['range'] = $line[19];
409
-			if (isset($line[35])) $data['info'] = $line[35];
531
+			if (isset($line[35])) {
532
+				$data['info'] = $line[35];
533
+			}
410 534
     			$data['id_source'] = $id_source;
411 535
 	    		//$data['arrival_airport_time'] = ;
412 536
 	    		if ($line[9] != '') {
@@ -420,23 +544,38 @@  discard block
 block discarded – undo
420 544
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
421 545
 	    		*/
422 546
 	    		$data['format_source'] = $value['format'];
423
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
424
-    			if ($line[3] == 'PILOT') $SI->add($data);
425
-			elseif ($line[3] == 'ATC') {
547
+			if (isset($value['name']) && $value['name'] != '') {
548
+				$data['source_name'] = $value['name'];
549
+			}
550
+    			if ($line[3] == 'PILOT') {
551
+    				$SI->add($data);
552
+    			} elseif ($line[3] == 'ATC') {
426 553
 				//print_r($data);
427 554
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
428 555
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
429 556
 				$typec = substr($data['ident'],-3);
430
-				if ($typec == 'APP') $data['type'] = 'Approach';
431
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
432
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
433
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
434
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
435
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
436
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
437
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
438
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
439
-				if (!isset($data['source_name'])) $data['source_name'] = '';
557
+				if ($typec == 'APP') {
558
+					$data['type'] = 'Approach';
559
+				} elseif ($typec == 'TWR') {
560
+					$data['type'] = 'Tower';
561
+				} elseif ($typec == 'OBS') {
562
+					$data['type'] = 'Observer';
563
+				} elseif ($typec == 'GND') {
564
+					$data['type'] = 'Ground';
565
+				} elseif ($typec == 'DEL') {
566
+					$data['type'] = 'Delivery';
567
+				} elseif ($typec == 'DEP') {
568
+					$data['type'] = 'Departure';
569
+				} elseif ($typec == 'FSS') {
570
+					$data['type'] = 'Flight Service Station';
571
+				} elseif ($typec == 'CTR') {
572
+					$data['type'] = 'Control Radar or Centre';
573
+				} elseif ($data['type'] == '') {
574
+					$data['type'] = 'Observer';
575
+				}
576
+				if (!isset($data['source_name'])) {
577
+					$data['source_name'] = '';
578
+				}
440 579
 				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
441 580
 			}
442 581
     			unset($data);
@@ -456,26 +595,55 @@  discard block
 block discarded – undo
456 595
 		foreach ($all_data['acList'] as $line) {
457 596
 		    $data = array();
458 597
 		    $data['hex'] = $line['Icao']; // hex
459
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
460
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
461
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
462
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
463
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
464
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
598
+		    if (isset($line['Call'])) {
599
+		    	$data['ident'] = $line['Call'];
600
+		    }
601
+		    // ident
602
+		    if (isset($line['Alt'])) {
603
+		    	$data['altitude'] = $line['Alt'];
604
+		    }
605
+		    // altitude
606
+		    if (isset($line['Spd'])) {
607
+		    	$data['speed'] = $line['Spd'];
608
+		    }
609
+		    // speed
610
+		    if (isset($line['Trak'])) {
611
+		    	$data['heading'] = $line['Trak'];
612
+		    }
613
+		    // heading
614
+		    if (isset($line['Lat'])) {
615
+		    	$data['latitude'] = $line['Lat'];
616
+		    }
617
+		    // lat
618
+		    if (isset($line['Long'])) {
619
+		    	$data['longitude'] = $line['Long'];
620
+		    }
621
+		    // long
465 622
 		    //$data['verticalrate'] = $line['']; // verticale rate
466
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
623
+		    if (isset($line['Sqk'])) {
624
+		    	$data['squawk'] = $line['Sqk'];
625
+		    }
626
+		    // squawk
467 627
 		    $data['emergency'] = ''; // emergency
468
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
628
+		    if (isset($line['Reg'])) {
629
+		    	$data['registration'] = $line['Reg'];
630
+		    }
469 631
 		    /*
470 632
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
471 633
 		    else $data['datetime'] = date('Y-m-d H:i:s');
472 634
 		    */
473 635
 		    $data['datetime'] = date('Y-m-d H:i:s');
474
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
636
+		    if (isset($line['Type'])) {
637
+		    	$data['aircraft_icao'] = $line['Type'];
638
+		    }
475 639
 	    	    $data['format_source'] = 'aircraftlistjson';
476 640
 		    $data['id_source'] = $id_source;
477
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
478
-		    if (isset($data['datetime'])) $SI->add($data);
641
+		    if (isset($value['name']) && $value['name'] != '') {
642
+		    	$data['source_name'] = $value['name'];
643
+		    }
644
+		    if (isset($data['datetime'])) {
645
+		    	$SI->add($data);
646
+		    }
479 647
 		    unset($data);
480 648
 		}
481 649
 	    } else {
@@ -495,7 +663,9 @@  discard block
 block discarded – undo
495 663
 		    $data['datetime'] = date('Y-m-d H:i:s');
496 664
 	    	    $data['format_source'] = 'aircraftlistjson';
497 665
     		    $data['id_source'] = $id_source;
498
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
666
+		    if (isset($value['name']) && $value['name'] != '') {
667
+		    	$data['source_name'] = $value['name'];
668
+		    }
499 669
 		    $SI->add($data);
500 670
 		    unset($data);
501 671
 		}
@@ -531,7 +701,9 @@  discard block
 block discarded – undo
531 701
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
532 702
 	    	    $data['format_source'] = 'planeupdatefaa';
533 703
     		    $data['id_source'] = $id_source;
534
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
704
+		    if (isset($value['name']) && $value['name'] != '') {
705
+		    	$data['source_name'] = $value['name'];
706
+		    }
535 707
 		    $SI->add($data);
536 708
 		    unset($data);
537 709
 		}
@@ -571,7 +743,9 @@  discard block
 block discarded – undo
571 743
 	    //$buffer = $Common->getData($hosts[$id]);
572 744
 	    $buffer = $Common->getData($value['host']);
573 745
 	    $all_data = json_decode($buffer,true);
574
-	    if (!empty($all_data)) $reset = 0;
746
+	    if (!empty($all_data)) {
747
+	    	$reset = 0;
748
+	    }
575 749
 	    foreach ($all_data as $key => $line) {
576 750
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
577 751
 		    $data = array();
@@ -592,7 +766,9 @@  discard block
 block discarded – undo
592 766
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
593 767
 	    	    $data['format_source'] = 'fr24json';
594 768
     		    $data['id_source'] = $id_source;
595
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
769
+		    if (isset($value['name']) && $value['name'] != '') {
770
+		    	$data['source_name'] = $value['name'];
771
+		    }
596 772
 		    $SI->add($data);
597 773
 		    unset($data);
598 774
 		}
@@ -616,23 +792,39 @@  discard block
 block discarded – undo
616 792
 		    if (isset($line['inf'])) {
617 793
 			$data = array();
618 794
 			$data['hex'] = $line['inf']['ia'];
619
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
795
+			if (isset($line['inf']['cs'])) {
796
+				$data['ident'] = $line['inf']['cs'];
797
+			}
798
+			//$line[13]
620 799
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
621
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
622
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
800
+	    		if (isset($line['inf']['gs'])) {
801
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
802
+	    		}
803
+	    		// speed
804
+	    		if (isset($line['inf']['tr'])) {
805
+	    			$data['heading'] = $line['inf']['tr'];
806
+	    		}
807
+	    		// heading
623 808
 	    		$data['latitude'] = $line['pt'][0]; // lat
624 809
 	    		$data['longitude'] = $line['pt'][1]; // long
625 810
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
626
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
811
+	    		if (isset($line['inf']['sq'])) {
812
+	    			$data['squawk'] = $line['inf']['sq'];
813
+	    		}
814
+	    		// squawk
627 815
 	    		//$data['aircraft_icao'] = $line[8];
628
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
816
+	    		if (isset($line['inf']['rc'])) {
817
+	    			$data['registration'] = $line['inf']['rc'];
818
+	    		}
629 819
 			//$data['departure_airport_iata'] = $line[11];
630 820
 			//$data['arrival_airport_iata'] = $line[12];
631 821
 	    		//$data['emergency'] = ''; // emergency
632 822
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
633 823
 	    		$data['format_source'] = 'radarvirtueljson';
634 824
     			$data['id_source'] = $id_source;
635
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
825
+			if (isset($value['name']) && $value['name'] != '') {
826
+				$data['source_name'] = $value['name'];
827
+			}
636 828
 			$SI->add($data);
637 829
 			unset($data);
638 830
 		    }
@@ -653,29 +845,62 @@  discard block
 block discarded – undo
653 845
 		    $data['id'] = $line['id'];
654 846
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
655 847
 		    $data['ident'] = $line['callsign']; // ident
656
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
658
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
659
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
660
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
661
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
848
+		    if (isset($line['pilotid'])) {
849
+		    	$data['pilot_id'] = $line['pilotid'];
850
+		    }
851
+		    // pilot id
852
+		    if (isset($line['name'])) {
853
+		    	$data['pilot_name'] = $line['name'];
854
+		    }
855
+		    // pilot name
856
+		    if (isset($line['alt'])) {
857
+		    	$data['altitude'] = $line['alt'];
858
+		    }
859
+		    // altitude
860
+		    if (isset($line['gs'])) {
861
+		    	$data['speed'] = $line['gs'];
862
+		    }
863
+		    // speed
864
+		    if (isset($line['heading'])) {
865
+		    	$data['heading'] = $line['heading'];
866
+		    }
867
+		    // heading
868
+		    if (isset($line['route'])) {
869
+		    	$data['waypoints'] = $line['route'];
870
+		    }
871
+		    // route
662 872
 		    $data['latitude'] = $line['lat']; // lat
663 873
 		    $data['longitude'] = $line['lon']; // long
664 874
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
665 875
 		    //$data['squawk'] = $line['squawk']; // squawk
666 876
 		    //$data['emergency'] = ''; // emergency
667
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
668
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
669
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
877
+		    if (isset($line['depicao'])) {
878
+		    	$data['departure_airport_icao'] = $line['depicao'];
879
+		    }
880
+		    if (isset($line['deptime'])) {
881
+		    	$data['departure_airport_time'] = $line['deptime'];
882
+		    }
883
+		    if (isset($line['arricao'])) {
884
+		    	$data['arrival_airport_icao'] = $line['arricao'];
885
+		    }
670 886
 		    //$data['arrival_airport_time'] = $line['arrtime'];
671
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
672
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
673
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
674
-		    else $data['info'] = '';
887
+		    if (isset($line['aircraft'])) {
888
+		    	$data['aircraft_icao'] = $line['aircraft'];
889
+		    }
890
+		    if (isset($line['transponder'])) {
891
+		    	$data['squawk'] = $line['transponder'];
892
+		    }
893
+		    if (isset($line['atis'])) {
894
+		    	$data['info'] = $line['atis'];
895
+		    } else {
896
+		    	$data['info'] = '';
897
+		    }
675 898
 		    $data['format_source'] = 'pireps';
676 899
     		    $data['id_source'] = $id_source;
677 900
 		    $data['datetime'] = date('Y-m-d H:i:s');
678
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
901
+		    if (isset($value['name']) && $value['name'] != '') {
902
+		    	$data['source_name'] = $value['name'];
903
+		    }
679 904
 		    if ($line['icon'] == 'plane') {
680 905
 			$SI->add($data);
681 906
 		    //    print_r($data);
@@ -684,15 +909,25 @@  discard block
 block discarded – undo
684 909
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
685 910
 			$typec = substr($data['ident'],-3);
686 911
 			$data['type'] = '';
687
-			if ($typec == 'APP') $data['type'] = 'Approach';
688
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
689
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
690
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
691
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
692
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
693
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
694
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
695
-			else $data['type'] = 'Observer';
912
+			if ($typec == 'APP') {
913
+				$data['type'] = 'Approach';
914
+			} elseif ($typec == 'TWR') {
915
+				$data['type'] = 'Tower';
916
+			} elseif ($typec == 'OBS') {
917
+				$data['type'] = 'Observer';
918
+			} elseif ($typec == 'GND') {
919
+				$data['type'] = 'Ground';
920
+			} elseif ($typec == 'DEL') {
921
+				$data['type'] = 'Delivery';
922
+			} elseif ($typec == 'DEP') {
923
+				$data['type'] = 'Departure';
924
+			} elseif ($typec == 'FSS') {
925
+				$data['type'] = 'Flight Service Station';
926
+			} elseif ($typec == 'CTR') {
927
+				$data['type'] = 'Control Radar or Centre';
928
+			} else {
929
+				$data['type'] = 'Observer';
930
+			}
696 931
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
697 932
 		    }
698 933
 		    unset($data);
@@ -703,7 +938,9 @@  discard block
 block discarded – undo
703 938
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
704 939
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705 940
 	    //$buffer = $Common->getData($hosts[$id]);
706
-	    if ($globalDebug) echo 'Get Data...'."\n";
941
+	    if ($globalDebug) {
942
+	    	echo 'Get Data...'."\n";
943
+	    }
707 944
 	    $buffer = $Common->getData($value['host']);
708 945
 	    $all_data = json_decode($buffer,true);
709 946
 	    if ($buffer != '' && is_array($all_data)) {
@@ -711,10 +948,16 @@  discard block
 block discarded – undo
711 948
 		foreach ($all_data as $line) {
712 949
 	    	    $data = array();
713 950
 	    	    //$data['id'] = $line['id']; // id not usable
714
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
951
+	    	    if (isset($line['pilotid'])) {
952
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
953
+	    	    }
715 954
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
716
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
955
+	    	    if (isset($line['pilotname'])) {
956
+	    	    	$data['pilot_name'] = $line['pilotname'];
957
+	    	    }
958
+	    	    if (isset($line['pilotid'])) {
959
+	    	    	$data['pilot_id'] = $line['pilotid'];
960
+	    	    }
718 961
 	    	    $data['ident'] = $line['flightnum']; // ident
719 962
 	    	    $data['altitude'] = $line['alt']; // altitude
720 963
 	    	    $data['speed'] = $line['gs']; // speed
@@ -732,27 +975,41 @@  discard block
 block discarded – undo
732 975
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
733 976
     		    $data['arrival_airport_time'] = $line['arrtime'];
734 977
     		    $data['registration'] = $line['aircraft'];
735
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
978
+		    if (isset($line['route'])) {
979
+		    	$data['waypoints'] = $line['route'];
980
+		    }
981
+		    // route
736 982
 		    if (isset($line['aircraftname'])) {
737 983
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
738 984
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
739 985
 	    		$aircraft_data = explode('-',$line['aircraftname']);
740
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742
-	    		else {
986
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
987
+	    			$data['aircraft_icao'] = $aircraft_data[0];
988
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
989
+	    			$data['aircraft_icao'] = $aircraft_data[1];
990
+	    		} else {
743 991
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
744
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
992
+	    		    if (isset($aircraft_data[1])) {
993
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
994
+	    		    } else {
995
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
996
+	    		    }
746 997
 	    		}
747 998
 	    	    }
748
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
999
+    		    if (isset($line['route'])) {
1000
+    		    	$data['waypoints'] = $line['route'];
1001
+    		    }
749 1002
     		    $data['id_source'] = $id_source;
750 1003
 	    	    $data['format_source'] = 'phpvmacars';
751
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1004
+		    if (isset($value['name']) && $value['name'] != '') {
1005
+		    	$data['source_name'] = $value['name'];
1006
+		    }
752 1007
 		    $SI->add($data);
753 1008
 		    unset($data);
754 1009
 		}
755
-		if ($globalDebug) echo 'No more data...'."\n";
1010
+		if ($globalDebug) {
1011
+			echo 'No more data...'."\n";
1012
+		}
756 1013
 		unset($buffer);
757 1014
 		unset($all_data);
758 1015
 	    }
@@ -760,7 +1017,9 @@  discard block
 block discarded – undo
760 1017
     	    $last_exec[$id]['last'] = time();
761 1018
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
762 1019
 	    //$buffer = $Common->getData($hosts[$id]);
763
-	    if ($globalDebug) echo 'Get Data...'."\n";
1020
+	    if ($globalDebug) {
1021
+	    	echo 'Get Data...'."\n";
1022
+	    }
764 1023
 	    $buffer = $Common->getData($value['host']);
765 1024
 	    $all_data = json_decode($buffer,true);
766 1025
 	    if ($buffer != '' && is_array($all_data)) {
@@ -789,15 +1048,22 @@  discard block
 block discarded – undo
789 1048
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
790 1049
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
791 1050
     		    //$data['registration'] = $line['aircraft'];
792
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1051
+		    if (isset($line['route'])) {
1052
+		    	$data['waypoints'] = $line['route'];
1053
+		    }
1054
+		    // route
793 1055
 	    	    $data['aircraft_icao'] = $line['plane_type'];
794 1056
     		    $data['id_source'] = $id_source;
795 1057
 	    	    $data['format_source'] = 'vam';
796
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1058
+		    if (isset($value['name']) && $value['name'] != '') {
1059
+		    	$data['source_name'] = $value['name'];
1060
+		    }
797 1061
 		    $SI->add($data);
798 1062
 		    unset($data);
799 1063
 		}
800
-		if ($globalDebug) echo 'No more data...'."\n";
1064
+		if ($globalDebug) {
1065
+			echo 'No more data...'."\n";
1066
+		}
801 1067
 		unset($buffer);
802 1068
 		unset($all_data);
803 1069
 	    }
@@ -805,7 +1071,9 @@  discard block
 block discarded – undo
805 1071
     	    $last_exec[$id]['last'] = time();
806 1072
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
807 1073
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
808
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1074
+	    if (function_exists('pcntl_fork')) {
1075
+	    	pcntl_signal_dispatch();
1076
+	    }
809 1077
     	    //$last_exec[$id]['last'] = time();
810 1078
 
811 1079
 	    //$read = array( $sockets[$id] );
@@ -813,7 +1081,9 @@  discard block
 block discarded – undo
813 1081
 	    $write = NULL;
814 1082
 	    $e = NULL;
815 1083
 	    $n = socket_select($read, $write, $e, $timeout);
816
-	    if ($e != NULL) var_dump($e);
1084
+	    if ($e != NULL) {
1085
+	    	var_dump($e);
1086
+	    }
817 1087
 	    if ($n > 0) {
818 1088
 		$reset = 0;
819 1089
 		foreach ($read as $nb => $r) {
@@ -835,7 +1105,9 @@  discard block
 block discarded – undo
835 1105
 		    if ($buffer != '') {
836 1106
 			$tt[$format] = 0;
837 1107
 			if ($format == 'acarssbs3') {
838
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1108
+                    	    if ($globalDebug) {
1109
+                    	    	echo 'ACARS : '.$buffer."\n";
1110
+                    	    }
839 1111
 			    $ACARS->add(trim($buffer));
840 1112
 			    $ACARS->deleteLiveAcarsData();
841 1113
 			} elseif ($format == 'raw') {
@@ -844,9 +1116,15 @@  discard block
 block discarded – undo
844 1116
 			    if (is_array($data)) {
845 1117
 				$data['datetime'] = date('Y-m-d H:i:s');
846 1118
 				$data['format_source'] = 'raw';
847
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
848
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
849
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1119
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1120
+					$data['source_name'] = $globalSources[$nb]['name'];
1121
+				}
1122
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1123
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1124
+    				}
1125
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1126
+                                	$SI->add($data);
1127
+                                }
850 1128
                             }
851 1129
                         } elseif ($format == 'flightgearsp') {
852 1130
                     	    //echo $buffer."\n";
@@ -864,11 +1142,15 @@  discard block
 block discarded – undo
864 1142
 				$data['speed'] = round($line[5]*1.94384);
865 1143
 				$data['datetime'] = date('Y-m-d H:i:s');
866 1144
 				$data['format_source'] = 'flightgearsp';
867
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1145
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1146
+					$SI->add($data);
1147
+				}
868 1148
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
869 1149
 			    }
870 1150
                         } elseif ($format == 'acars') {
871
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1151
+                    	    if ($globalDebug) {
1152
+                    	    	echo 'ACARS : '.$buffer."\n";
1153
+                    	    }
872 1154
 			    $ACARS->add(trim($buffer));
873 1155
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
874 1156
 			    $ACARS->deleteLiveAcarsData();
@@ -889,7 +1171,9 @@  discard block
 block discarded – undo
889 1171
 				    $aircraft_type = $line[10];
890 1172
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
891 1173
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
892
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1174
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1175
+				    	$SI->add($data);
1176
+				    }
893 1177
 				}
894 1178
 			    }
895 1179
 			} elseif ($format == 'beast') {
@@ -905,21 +1189,43 @@  discard block
 block discarded – undo
905 1189
     				$data['hex'] = $lined['hexid'];
906 1190
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907 1191
     				$data['datetime'] = date('Y-m-d H:i:s');;
908
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
911
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
912
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
913
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
914
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1192
+    				if (isset($lined['ident'])) {
1193
+    					$data['ident'] = $lined['ident'];
1194
+    				}
1195
+    				if (isset($lined['lat'])) {
1196
+    					$data['latitude'] = $lined['lat'];
1197
+    				}
1198
+    				if (isset($lined['lon'])) {
1199
+    					$data['longitude'] = $lined['lon'];
1200
+    				}
1201
+    				if (isset($lined['speed'])) {
1202
+    					$data['speed'] = $lined['speed'];
1203
+    				}
1204
+    				if (isset($lined['squawk'])) {
1205
+    					$data['squawk'] = $lined['squawk'];
1206
+    				}
1207
+    				if (isset($lined['alt'])) {
1208
+    					$data['altitude'] = $lined['alt'];
1209
+    				}
1210
+    				if (isset($lined['heading'])) {
1211
+    					$data['heading'] = $lined['heading'];
1212
+    				}
915 1213
     				$data['id_source'] = $id_source;
916 1214
     				$data['format_source'] = 'tsv';
917
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
918
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
919
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1215
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1216
+    					$data['source_name'] = $globalSources[$nb]['name'];
1217
+    				}
1218
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1219
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1220
+    				}
1221
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1222
+    					$SI->add($data);
1223
+    				}
920 1224
     				unset($lined);
921 1225
     				unset($data);
922
-    			    } else $error = true;
1226
+    			    } else {
1227
+    			    	$error = true;
1228
+    			    }
923 1229
 			} elseif ($format == 'aprs' && $use_aprs) {
924 1230
 			    if ($aprs_connect == 0) {
925 1231
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -950,32 +1256,46 @@  discard block
 block discarded – undo
950 1256
 				    $data['latitude'] = $line['latitude'];
951 1257
 				    $data['longitude'] = $line['longitude'];
952 1258
 				    //$data['verticalrate'] = $line[16];
953
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
954
-				    else $data['speed'] = 0;
1259
+				    if (isset($line['speed'])) {
1260
+				    	$data['speed'] = $line['speed'];
1261
+				    } else {
1262
+				    	$data['speed'] = 0;
1263
+				    }
955 1264
 				    $data['altitude'] = $line['altitude'];
956
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1265
+				    if (isset($line['heading'])) {
1266
+				    	$data['heading'] = $line['heading'];
1267
+				    }
957 1268
 				    //else $data['heading'] = 0;
958 1269
 				    $data['aircraft_type'] = $line['stealth'];
959
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1270
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1271
+				    	$data['noarchive'] = true;
1272
+				    }
960 1273
     				    $data['id_source'] = $id_source;
961 1274
 				    $data['format_source'] = 'aprs';
962 1275
 				    $data['source_name'] = $line['source'];
963
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1276
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1277
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1278
+    				    }
964 1279
 				    $currentdate = date('Y-m-d H:i:s');
965 1280
 				    $aprsdate = strtotime($data['datetime']);
966 1281
 				    // Accept data if time <= system time + 20s
967
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
968
-				    else {
969
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
970
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1282
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1283
+				    	$send = $SI->add($data);
1284
+				    } else {
1285
+					if ($line['stealth'] != 0) {
1286
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1287
+					} else {
1288
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1289
+					}
971 1290
 				    }
972 1291
 				    unset($data);
973
-				} 
974
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1292
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
975 1293
 					echo '!! Weather Station not yet supported'."\n";
976 1294
 				}
977 1295
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
978
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1296
+				elseif ($line == true && $globalDebug) {
1297
+					echo '!! Failed : '.$buffer."!!\n";
1298
+				}
979 1299
 			    }
980 1300
 			} else {
981 1301
 			    $line = explode(',', $buffer);
@@ -1004,25 +1324,42 @@  discard block
 block discarded – undo
1004 1324
     				$data['ground'] = $line[21];
1005 1325
     				$data['emergency'] = $line[19];
1006 1326
     				$data['format_source'] = 'sbs';
1007
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1008
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1327
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1328
+					$data['source_name'] = $globalSources[$nb]['name'];
1329
+				}
1330
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1331
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1332
+    				}
1009 1333
     				$data['id_source'] = $id_source;
1010
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1011
-    				else $error = true;
1334
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1335
+    					$send = $SI->add($data);
1336
+    				} else {
1337
+    					$error = true;
1338
+    				}
1012 1339
     				unset($data);
1013
-    			    } else $error = true;
1340
+    			    } else {
1341
+    			    	$error = true;
1342
+    			    }
1014 1343
 			    if ($error) {
1015 1344
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1016
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1345
+					if ($globalDebug) {
1346
+						echo "Not a message. Ignoring... \n";
1347
+					}
1017 1348
 				} else {
1018
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1349
+					if ($globalDebug) {
1350
+						echo "Wrong line format. Ignoring... \n";
1351
+					}
1019 1352
 					if ($globalDebug) {
1020 1353
 						echo $buffer;
1021 1354
 						print_r($line);
1022 1355
 					}
1023 1356
 					//socket_close($r);
1024
-					if ($globalDebug) echo "Reconnect after an error...\n";
1025
-					if ($format == 'aprs') $aprs_connect = 0;
1357
+					if ($globalDebug) {
1358
+						echo "Reconnect after an error...\n";
1359
+					}
1360
+					if ($format == 'aprs') {
1361
+						$aprs_connect = 0;
1362
+					}
1026 1363
 					$sourceer[$nb] = $globalSources[$nb];
1027 1364
 					connect_all($sourceer);
1028 1365
 					$sourceer = array();
@@ -1030,10 +1367,14 @@  discard block
 block discarded – undo
1030 1367
 			    }
1031 1368
 			}
1032 1369
 			// Sleep for xxx microseconds
1033
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1370
+			if (isset($globalSBSSleep)) {
1371
+				usleep($globalSBSSleep);
1372
+			}
1034 1373
 		    } else {
1035 1374
 			if ($format == 'flightgearmp') {
1036
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1375
+			    	if ($globalDebug) {
1376
+			    		echo "Reconnect FlightGear MP...";
1377
+			    	}
1037 1378
 				//@socket_close($r);
1038 1379
 				sleep($globalMinFetch);
1039 1380
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1042,10 +1383,15 @@  discard block
 block discarded – undo
1042 1383
 				break;
1043 1384
 				
1044 1385
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1045
-			    if (isset($tt[$format])) $tt[$format]++;
1046
-			    else $tt[$format] = 0;
1386
+			    if (isset($tt[$format])) {
1387
+			    	$tt[$format]++;
1388
+			    } else {
1389
+			    	$tt[$format] = 0;
1390
+			    }
1047 1391
 			    if ($tt[$format] > 30) {
1048
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1392
+				if ($globalDebug) {
1393
+					echo "ERROR : Reconnect ".$format."...";
1394
+				}
1049 1395
 				//@socket_close($r);
1050 1396
 				sleep(2);
1051 1397
 				$aprs_connect = 0;
@@ -1061,12 +1407,18 @@  discard block
 block discarded – undo
1061 1407
 		}
1062 1408
 	    } else {
1063 1409
 		$error = socket_strerror(socket_last_error());
1064
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1410
+		if ($globalDebug) {
1411
+			echo "ERROR : socket_select give this error ".$error . "\n";
1412
+		}
1065 1413
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1066
-			if (isset($globalDebug)) echo "Restarting...\n";
1414
+			if (isset($globalDebug)) {
1415
+				echo "Restarting...\n";
1416
+			}
1067 1417
 			// Restart the script if possible
1068 1418
 			if (is_array($sockets)) {
1069
-			    if ($globalDebug) echo "Shutdown all sockets...";
1419
+			    if ($globalDebug) {
1420
+			    	echo "Shutdown all sockets...";
1421
+			    }
1070 1422
 			    
1071 1423
 			    foreach ($sockets as $sock) {
1072 1424
 				@socket_shutdown($sock,2);
@@ -1074,18 +1426,24 @@  discard block
 block discarded – undo
1074 1426
 			    }
1075 1427
 			    
1076 1428
 			}
1077
-			if ($globalDebug) echo "Restart all connections...";
1429
+			if ($globalDebug) {
1430
+				echo "Restart all connections...";
1431
+			}
1078 1432
 			sleep(2);
1079 1433
 			$time = time();
1080 1434
 			//connect_all($hosts);
1081 1435
 			$aprs_connect = 0;
1082
-			if ($reset > 40) exit('Too many attempts...');
1436
+			if ($reset > 40) {
1437
+				exit('Too many attempts...');
1438
+			}
1083 1439
 			connect_all($globalSources);
1084 1440
 		}
1085 1441
 	    }
1086 1442
 	}
1087 1443
 	if ($globalDaemon === false) {
1088
-	    if ($globalDebug) echo 'Check all...'."\n";
1444
+	    if ($globalDebug) {
1445
+	    	echo 'Check all...'."\n";
1446
+	    }
1089 1447
 	    $SI->checkAll();
1090 1448
 	}
1091 1449
     }
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Braces   +473 added lines, -164 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -80,7 +82,9 @@  discard block
 block discarded – undo
80 82
                 }
81 83
         }
82 84
 	public function getAllAirlineNames($filter_name = '') {
83
-		if ($filter_name == '') $filter_name = $this->filter_name;
85
+		if ($filter_name == '') {
86
+			$filter_name = $this->filter_name;
87
+		}
84 88
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
85 89
                  try {
86 90
                         $sth = $this->db->prepare($query);
@@ -92,7 +96,9 @@  discard block
 block discarded – undo
92 96
                 return $all;
93 97
         }
94 98
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
95
-		if ($filter_name == '') $filter_name = $this->filter_name;
99
+		if ($filter_name == '') {
100
+			$filter_name = $this->filter_name;
101
+		}
96 102
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
97 103
                  try {
98 104
                         $sth = $this->db->prepare($query);
@@ -104,7 +110,9 @@  discard block
 block discarded – undo
104 110
                 return $all;
105 111
         }
106 112
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
107
-		if ($filter_name == '') $filter_name = $this->filter_name;
113
+		if ($filter_name == '') {
114
+			$filter_name = $this->filter_name;
115
+		}
108 116
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
109 117
                  try {
110 118
                         $sth = $this->db->prepare($query);
@@ -116,7 +124,9 @@  discard block
 block discarded – undo
116 124
                 return $all;
117 125
         }
118 126
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
119
-		if ($filter_name == '') $filter_name = $this->filter_name;
127
+		if ($filter_name == '') {
128
+			$filter_name = $this->filter_name;
129
+		}
120 130
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
121 131
                  try {
122 132
                         $sth = $this->db->prepare($query);
@@ -129,7 +139,9 @@  discard block
 block discarded – undo
129 139
         }
130 140
 
131 141
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
132
-		if ($filter_name == '') $filter_name = $this->filter_name;
142
+		if ($filter_name == '') {
143
+			$filter_name = $this->filter_name;
144
+		}
133 145
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
134 146
                  try {
135 147
                         $sth = $this->db->prepare($query);
@@ -142,7 +154,9 @@  discard block
 block discarded – undo
142 154
         }
143 155
 
144 156
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
145
-		if ($filter_name == '') $filter_name = $this->filter_name;
157
+		if ($filter_name == '') {
158
+			$filter_name = $this->filter_name;
159
+		}
146 160
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
147 161
                  try {
148 162
                         $sth = $this->db->prepare($query);
@@ -157,10 +171,15 @@  discard block
 block discarded – undo
157 171
 
158 172
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
159 173
 		global $globalStatsFilters;
160
-		if ($filter_name == '') $filter_name = $this->filter_name;
174
+		if ($filter_name == '') {
175
+			$filter_name = $this->filter_name;
176
+		}
161 177
 		if ($year == '' && $month == '') {
162
-			if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
163
-			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
178
+			if ($limit) {
179
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
180
+			} else {
181
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
182
+			}
164 183
 			try {
165 184
 				$sth = $this->db->prepare($query);
166 185
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -168,7 +187,9 @@  discard block
 block discarded – undo
168 187
 				echo "error : ".$e->getMessage();
169 188
 			}
170 189
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
171
-		} else $all = array();
190
+		} else {
191
+			$all = array();
192
+		}
172 193
                 if (empty($all)) {
173 194
             	    $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
174 195
             	    if ($filter_name != '') {
@@ -182,10 +203,15 @@  discard block
 block discarded – undo
182 203
 	}
183 204
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
184 205
 		global $globalStatsFilters;
185
-		if ($filter_name == '') $filter_name = $this->filter_name;
206
+		if ($filter_name == '') {
207
+			$filter_name = $this->filter_name;
208
+		}
186 209
 		if ($year == '' && $month == '') {
187
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
188
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
210
+			if ($limit) {
211
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
212
+			} else {
213
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
214
+			}
189 215
 			try {
190 216
 				$sth = $this->db->prepare($query);
191 217
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -193,7 +219,9 @@  discard block
 block discarded – undo
193 219
 				echo "error : ".$e->getMessage();
194 220
 			}
195 221
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
196
-		} else $all = array();
222
+		} else {
223
+			$all = array();
224
+		}
197 225
                 if (empty($all)) {
198 226
             		$Spotter = new Spotter($this->db);
199 227
             		$filters = array();
@@ -208,10 +236,15 @@  discard block
 block discarded – undo
208 236
 	}
209 237
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
210 238
 		global $globalStatsFilters;
211
-		if ($filter_name == '') $filter_name = $this->filter_name;
239
+		if ($filter_name == '') {
240
+			$filter_name = $this->filter_name;
241
+		}
212 242
 		if ($year == '' && $month == '') {
213
-			if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
214
-			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
243
+			if ($limit) {
244
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
245
+			} else {
246
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
247
+			}
215 248
 			try {
216 249
 				$sth = $this->db->prepare($query);
217 250
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -219,7 +252,9 @@  discard block
 block discarded – undo
219 252
 				echo "error : ".$e->getMessage();
220 253
 			}
221 254
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
222
-		} else $all = array();
255
+		} else {
256
+			$all = array();
257
+		}
223 258
 		if (empty($all)) {
224 259
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
225 260
 			if ($filter_name != '') {
@@ -234,10 +269,15 @@  discard block
 block discarded – undo
234 269
 
235 270
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
236 271
 		global $globalStatsFilters;
237
-		if ($filter_name == '') $filter_name = $this->filter_name;
272
+		if ($filter_name == '') {
273
+			$filter_name = $this->filter_name;
274
+		}
238 275
 		if ($year == '' && $month == '') {
239
-			if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
240
-			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
276
+			if ($limit) {
277
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
278
+			} else {
279
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
280
+			}
241 281
 			try {
242 282
 				$sth = $this->db->prepare($query);
243 283
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -245,7 +285,9 @@  discard block
 block discarded – undo
245 285
 				echo "error : ".$e->getMessage();
246 286
 			}
247 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
248
-		} else $all = array();
288
+		} else {
289
+			$all = array();
290
+		}
249 291
                 if (empty($all)) {
250 292
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
251 293
 			if ($filter_name != '') {
@@ -259,9 +301,14 @@  discard block
 block discarded – undo
259 301
 	}
260 302
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
261 303
 		global $globalStatsFilters;
262
-		if ($filter_name == '') $filter_name = $this->filter_name;
263
-		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
264
-		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
304
+		if ($filter_name == '') {
305
+			$filter_name = $this->filter_name;
306
+		}
307
+		if ($limit) {
308
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
309
+		} else {
310
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
311
+		}
265 312
                  try {
266 313
                         $sth = $this->db->prepare($query);
267 314
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -283,17 +330,29 @@  discard block
 block discarded – undo
283 330
 
284 331
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
285 332
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
286
-		if ($filter_name == '') $filter_name = $this->filter_name;
333
+		if ($filter_name == '') {
334
+			$filter_name = $this->filter_name;
335
+		}
287 336
 		if ($year == '' && $month == '') {
288
-			if ($globalVATSIM) $forsource = 'vatsim';
289
-			if ($globalIVAO) $forsource = 'ivao';
337
+			if ($globalVATSIM) {
338
+				$forsource = 'vatsim';
339
+			}
340
+			if ($globalIVAO) {
341
+				$forsource = 'ivao';
342
+			}
290 343
 			if (isset($forsource)) {
291
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
292
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
344
+				if ($limit) {
345
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
346
+				} else {
347
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
348
+				}
293 349
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
294 350
 			} else {
295
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
296
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
351
+				if ($limit) {
352
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
353
+				} else {
354
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
355
+				}
297 356
 				$query_values = array(':filter_name' => $filter_name);
298 357
 			}
299 358
 			try {
@@ -303,7 +362,9 @@  discard block
 block discarded – undo
303 362
 				echo "error : ".$e->getMessage();
304 363
 			}
305 364
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
306
-		} else $all = array();
365
+		} else {
366
+			$all = array();
367
+		}
307 368
                 if (empty($all)) {
308 369
 	                $Spotter = new Spotter($this->db);
309 370
             		$filters = array();
@@ -318,10 +379,15 @@  discard block
 block discarded – undo
318 379
 	}
319 380
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
320 381
 		global $globalStatsFilters;
321
-		if ($filter_name == '') $filter_name = $this->filter_name;
382
+		if ($filter_name == '') {
383
+			$filter_name = $this->filter_name;
384
+		}
322 385
 		if ($year == '' && $month == '') {
323
-			if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
324
-			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
386
+			if ($limit) {
387
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
388
+			} else {
389
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
390
+			}
325 391
 			try {
326 392
 				$sth = $this->db->prepare($query);
327 393
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -329,7 +395,9 @@  discard block
 block discarded – undo
329 395
 				echo "error : ".$e->getMessage();
330 396
 			}
331 397
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
332
-		} else $all = array();
398
+		} else {
399
+			$all = array();
400
+		}
333 401
                 if (empty($all)) {
334 402
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
335 403
 			if ($filter_name != '') {
@@ -343,10 +411,15 @@  discard block
 block discarded – undo
343 411
 	}
344 412
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
345 413
 		global $globalStatsFilters;
346
-		if ($filter_name == '') $filter_name = $this->filter_name;
414
+		if ($filter_name == '') {
415
+			$filter_name = $this->filter_name;
416
+		}
347 417
 		if ($year == '' && $month == '') {
348
-			if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
349
-			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
418
+			if ($limit) {
419
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
420
+			} else {
421
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
422
+			}
350 423
 			 try {
351 424
 				$sth = $this->db->prepare($query);
352 425
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -354,7 +427,9 @@  discard block
 block discarded – undo
354 427
 				echo "error : ".$e->getMessage();
355 428
 			}
356 429
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
357
-		} else $all = array();
430
+		} else {
431
+			$all = array();
432
+		}
358 433
 		if (empty($all)) {
359 434
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
360 435
 			if ($filter_name != '') {
@@ -368,11 +443,16 @@  discard block
 block discarded – undo
368 443
 	}
369 444
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
370 445
 		$Connection = new Connection();
371
-		if ($filter_name == '') $filter_name = $this->filter_name;
446
+		if ($filter_name == '') {
447
+			$filter_name = $this->filter_name;
448
+		}
372 449
 		if ($Connection->tableExists('countries')) {
373 450
 			if ($year == '' && $month == '') {
374
-				if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
375
-				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
451
+				if ($limit) {
452
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
453
+				} else {
454
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
455
+				}
376 456
 				 try {
377 457
 					$sth = $this->db->prepare($query);
378 458
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -387,17 +467,24 @@  discard block
 block discarded – undo
387 467
                 }
388 468
                 */
389 469
 				return $all;
390
-			} else return array();
470
+			} else {
471
+				return array();
472
+			}
391 473
 		} else {
392 474
 			return array();
393 475
 		}
394 476
 	}
395 477
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
396 478
 		global $globalStatsFilters;
397
-		if ($filter_name == '') $filter_name = $this->filter_name;
479
+		if ($filter_name == '') {
480
+			$filter_name = $this->filter_name;
481
+		}
398 482
 		if ($year == '' && $month == '') {
399
-			if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
400
-			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
483
+			if ($limit) {
484
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
485
+			} else {
486
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
487
+			}
401 488
 			try {
402 489
 				$sth = $this->db->prepare($query);
403 490
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -405,7 +492,9 @@  discard block
 block discarded – undo
405 492
 				echo "error : ".$e->getMessage();
406 493
 			}
407 494
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
408
-		} else $all = array();
495
+		} else {
496
+			$all = array();
497
+		}
409 498
 		if (empty($all)) {
410 499
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
411 500
 			if ($filter_name != '') {
@@ -420,10 +509,15 @@  discard block
 block discarded – undo
420 509
 
421 510
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
422 511
 		global $globalStatsFilters;
423
-		if ($filter_name == '') $filter_name = $this->filter_name;
512
+		if ($filter_name == '') {
513
+			$filter_name = $this->filter_name;
514
+		}
424 515
 		if ($year == '' && $month == '') {
425
-			if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
426
-			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
516
+			if ($limit) {
517
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
518
+			} else {
519
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
520
+			}
427 521
 			try {
428 522
 				$sth = $this->db->prepare($query);
429 523
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -431,7 +525,9 @@  discard block
 block discarded – undo
431 525
 				echo "error : ".$e->getMessage();
432 526
 			}
433 527
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
434
-		} else $all = array();
528
+		} else {
529
+			$all = array();
530
+		}
435 531
                 if (empty($all)) {
436 532
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
437 533
 			if ($filter_name != '') {
@@ -445,10 +541,15 @@  discard block
 block discarded – undo
445 541
 	}
446 542
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
447 543
 		global $globalStatsFilters;
448
-		if ($filter_name == '') $filter_name = $this->filter_name;
544
+		if ($filter_name == '') {
545
+			$filter_name = $this->filter_name;
546
+		}
449 547
 		if ($year == '' && $month == '') {
450
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
451
-			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
548
+			if ($limit) {
549
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
550
+			} else {
551
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
552
+			}
452 553
 			try {
453 554
 				$sth = $this->db->prepare($query);
454 555
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -456,7 +557,9 @@  discard block
 block discarded – undo
456 557
 				echo "error : ".$e->getMessage();
457 558
 			}
458 559
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
459
-		} else $all = array();
560
+		} else {
561
+			$all = array();
562
+		}
460 563
                 if (empty($all)) {
461 564
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
462 565
             		if ($filter_name != '') {
@@ -477,7 +580,9 @@  discard block
 block discarded – undo
477 580
         			$icao = $value['airport_departure_icao'];
478 581
         			if (isset($all[$icao])) {
479 582
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
480
-        			} else $all[$icao] = $value;
583
+        			} else {
584
+        				$all[$icao] = $value;
585
+        			}
481 586
         		}
482 587
         		$count = array();
483 588
         		foreach ($all as $key => $row) {
@@ -489,10 +594,15 @@  discard block
 block discarded – undo
489 594
 	}
490 595
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
491 596
 		global $globalStatsFilters;
492
-		if ($filter_name == '') $filter_name = $this->filter_name;
597
+		if ($filter_name == '') {
598
+			$filter_name = $this->filter_name;
599
+		}
493 600
 		if ($year == '' && $month == '') {
494
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
495
-			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
601
+			if ($limit) {
602
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
603
+			} else {
604
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
605
+			}
496 606
 			try {
497 607
 				$sth = $this->db->prepare($query);
498 608
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -500,7 +610,9 @@  discard block
 block discarded – undo
500 610
 				echo "error : ".$e->getMessage();
501 611
 			}
502 612
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
503
-		} else $all = array();
613
+		} else {
614
+			$all = array();
615
+		}
504 616
 		if (empty($all)) {
505 617
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
506 618
 			if ($filter_name != '') {
@@ -521,7 +633,9 @@  discard block
 block discarded – undo
521 633
         			$icao = $value['airport_arrival_icao'];
522 634
         			if (isset($all[$icao])) {
523 635
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
524
-        			} else $all[$icao] = $value;
636
+        			} else {
637
+        				$all[$icao] = $value;
638
+        			}
525 639
         		}
526 640
         		$count = array();
527 641
         		foreach ($all as $key => $row) {
@@ -534,13 +648,21 @@  discard block
 block discarded – undo
534 648
 	}
535 649
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
536 650
 		global $globalDBdriver, $globalStatsFilters;
537
-		if ($filter_name == '') $filter_name = $this->filter_name;
651
+		if ($filter_name == '') {
652
+			$filter_name = $this->filter_name;
653
+		}
538 654
 		if ($globalDBdriver == 'mysql') {
539
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
540
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
655
+			if ($limit) {
656
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
657
+			} else {
658
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
659
+			}
541 660
 		} else {
542
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
543
-			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
661
+			if ($limit) {
662
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
663
+			} else {
664
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
665
+			}
544 666
 		}
545 667
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
546 668
                  try {
@@ -564,7 +686,9 @@  discard block
 block discarded – undo
564 686
 	
565 687
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
566 688
 		global $globalStatsFilters;
567
-		if ($filter_name == '') $filter_name = $this->filter_name;
689
+		if ($filter_name == '') {
690
+			$filter_name = $this->filter_name;
691
+		}
568 692
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
569 693
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
570 694
                  try {
@@ -586,7 +710,9 @@  discard block
 block discarded – undo
586 710
 	}
587 711
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
588 712
 		global $globalDBdriver, $globalStatsFilters;
589
-		if ($filter_name == '') $filter_name = $this->filter_name;
713
+		if ($filter_name == '') {
714
+			$filter_name = $this->filter_name;
715
+		}
590 716
 		if ($globalDBdriver == 'mysql') {
591 717
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
592 718
 		} else {
@@ -612,7 +738,9 @@  discard block
 block discarded – undo
612 738
 	}
613 739
 	public function countAllDates($stats_airline = '',$filter_name = '') {
614 740
 		global $globalStatsFilters;
615
-		if ($filter_name == '') $filter_name = $this->filter_name;
741
+		if ($filter_name == '') {
742
+			$filter_name = $this->filter_name;
743
+		}
616 744
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
617 745
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
618 746
                  try {
@@ -634,7 +762,9 @@  discard block
 block discarded – undo
634 762
 	}
635 763
 	public function countAllDatesByAirlines($filter_name = '') {
636 764
 		global $globalStatsFilters;
637
-		if ($filter_name == '') $filter_name = $this->filter_name;
765
+		if ($filter_name == '') {
766
+			$filter_name = $this->filter_name;
767
+		}
638 768
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
639 769
 		$query_data = array('filter_name' => $filter_name);
640 770
                  try {
@@ -656,7 +786,9 @@  discard block
 block discarded – undo
656 786
 	}
657 787
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
658 788
 		global $globalStatsFilters;
659
-		if ($filter_name == '') $filter_name = $this->filter_name;
789
+		if ($filter_name == '') {
790
+			$filter_name = $this->filter_name;
791
+		}
660 792
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
661 793
                  try {
662 794
                         $sth = $this->db->prepare($query);
@@ -679,7 +811,9 @@  discard block
 block discarded – undo
679 811
 	}
680 812
 	public function countAllMilitaryMonths($filter_name = '') {
681 813
 		global $globalStatsFilters;
682
-		if ($filter_name == '') $filter_name = $this->filter_name;
814
+		if ($filter_name == '') {
815
+			$filter_name = $this->filter_name;
816
+		}
683 817
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
684 818
                  try {
685 819
                         $sth = $this->db->prepare($query);
@@ -700,9 +834,14 @@  discard block
 block discarded – undo
700 834
 	}
701 835
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
702 836
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
703
-		if ($filter_name == '') $filter_name = $this->filter_name;
704
-		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
705
-		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
837
+		if ($filter_name == '') {
838
+			$filter_name = $this->filter_name;
839
+		}
840
+		if ($limit) {
841
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
842
+		} else {
843
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
844
+		}
706 845
 		if ($orderby == 'hour') {
707 846
 			/*
708 847
 			if ($globalDBdriver == 'mysql') {
@@ -711,7 +850,9 @@  discard block
 block discarded – undo
711 850
 			*/
712 851
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
713 852
 		}
714
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
853
+		if ($orderby == 'count') {
854
+			$query .= " ORDER BY hour_count DESC";
855
+		}
715 856
                  try {
716 857
                         $sth = $this->db->prepare($query);
717 858
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -732,8 +873,12 @@  discard block
 block discarded – undo
732 873
 	
733 874
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
734 875
 		global $globalStatsFilters;
735
-		if ($filter_name == '') $filter_name = $this->filter_name;
736
-		if ($year == '') $year = date('Y');
876
+		if ($filter_name == '') {
877
+			$filter_name = $this->filter_name;
878
+		}
879
+		if ($year == '') {
880
+			$year = date('Y');
881
+		}
737 882
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
738 883
 		if (empty($all)) {
739 884
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
@@ -748,8 +893,12 @@  discard block
 block discarded – undo
748 893
 	}
749 894
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
750 895
 		global $globalStatsFilters;
751
-		if ($filter_name == '') $filter_name = $this->filter_name;
752
-		if ($year == '') $year = date('Y');
896
+		if ($filter_name == '') {
897
+			$filter_name = $this->filter_name;
898
+		}
899
+		if ($year == '') {
900
+			$year = date('Y');
901
+		}
753 902
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
754 903
 		if (empty($all)) {
755 904
 		        $filters = array();
@@ -765,8 +914,12 @@  discard block
 block discarded – undo
765 914
 	}
766 915
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
767 916
 		global $globalStatsFilters;
768
-		if ($filter_name == '') $filter_name = $this->filter_name;
769
-		if ($year == '') $year = date('Y');
917
+		if ($filter_name == '') {
918
+			$filter_name = $this->filter_name;
919
+		}
920
+		if ($year == '') {
921
+			$year = date('Y');
922
+		}
770 923
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
771 924
 		if (empty($all)) {
772 925
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
@@ -781,7 +934,9 @@  discard block
 block discarded – undo
781 934
 	}
782 935
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
783 936
 		global $globalStatsFilters;
784
-		if ($filter_name == '') $filter_name = $this->filter_name;
937
+		if ($filter_name == '') {
938
+			$filter_name = $this->filter_name;
939
+		}
785 940
 		if ($year == '' && $month == '') {
786 941
 			$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
787 942
 			try {
@@ -792,7 +947,9 @@  discard block
 block discarded – undo
792 947
 			}
793 948
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
794 949
 			$all = $result[0]['nb'];
795
-		} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
950
+		} else {
951
+			$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
952
+		}
796 953
 		if (empty($all)) {
797 954
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
798 955
 			if ($filter_name != '') {
@@ -806,7 +963,9 @@  discard block
 block discarded – undo
806 963
 	}
807 964
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
808 965
 		global $globalStatsFilters;
809
-		if ($filter_name == '') $filter_name = $this->filter_name;
966
+		if ($filter_name == '') {
967
+			$filter_name = $this->filter_name;
968
+		}
810 969
 		if ($year == '' && $month == '') {
811 970
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
812 971
 			try {
@@ -817,7 +976,9 @@  discard block
 block discarded – undo
817 976
 			}
818 977
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
819 978
 			$all = $result[0]['nb_airline'];
820
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
979
+		} else {
980
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
981
+		}
821 982
 		if (empty($all)) {
822 983
             		$filters = array();
823 984
 			$filters = array('year' => $year,'month' => $month);
@@ -832,7 +993,9 @@  discard block
 block discarded – undo
832 993
 	}
833 994
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
834 995
 		global $globalStatsFilters;
835
-		if ($filter_name == '') $filter_name = $this->filter_name;
996
+		if ($filter_name == '') {
997
+			$filter_name = $this->filter_name;
998
+		}
836 999
 		if ($year == '' && $month == '') {
837 1000
 			$query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
838 1001
 			$query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
@@ -860,7 +1023,9 @@  discard block
 block discarded – undo
860 1023
 	}
861 1024
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
862 1025
 		global $globalStatsFilters;
863
-		if ($filter_name == '') $filter_name = $this->filter_name;
1026
+		if ($filter_name == '') {
1027
+			$filter_name = $this->filter_name;
1028
+		}
864 1029
 		//if ($year == '') $year = date('Y');
865 1030
 		if ($year == '' && $month == '') {
866 1031
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -889,7 +1054,9 @@  discard block
 block discarded – undo
889 1054
 	}
890 1055
 
891 1056
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
892
-		if ($filter_name == '') $filter_name = $this->filter_name;
1057
+		if ($filter_name == '') {
1058
+			$filter_name = $this->filter_name;
1059
+		}
893 1060
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
894 1061
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
895 1062
                  try {
@@ -902,7 +1069,9 @@  discard block
 block discarded – undo
902 1069
                 return $all;
903 1070
 	}
904 1071
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
905
-		if ($filter_name == '') $filter_name = $this->filter_name;
1072
+		if ($filter_name == '') {
1073
+			$filter_name = $this->filter_name;
1074
+		}
906 1075
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
907 1076
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
908 1077
                  try {
@@ -915,7 +1084,9 @@  discard block
 block discarded – undo
915 1084
                 return $all;
916 1085
         }
917 1086
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
918
-		if ($filter_name == '') $filter_name = $this->filter_name;
1087
+		if ($filter_name == '') {
1088
+			$filter_name = $this->filter_name;
1089
+		}
919 1090
     		global $globalArchiveMonths, $globalDBdriver;
920 1091
     		if ($globalDBdriver == 'mysql') {
921 1092
     			if ($month == '') {
@@ -945,7 +1116,9 @@  discard block
 block discarded – undo
945 1116
         }
946 1117
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
947 1118
     		global $globalArchiveMonths, $globalDBdriver;
948
-		if ($filter_name == '') $filter_name = $this->filter_name;
1119
+		if ($filter_name == '') {
1120
+			$filter_name = $this->filter_name;
1121
+		}
949 1122
     		if ($globalDBdriver == 'mysql') {
950 1123
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
951 1124
 		} else {
@@ -963,7 +1136,9 @@  discard block
 block discarded – undo
963 1136
         }
964 1137
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
965 1138
     		global $globalArchiveMonths, $globalDBdriver;
966
-		if ($filter_name == '') $filter_name = $this->filter_name;
1139
+		if ($filter_name == '') {
1140
+			$filter_name = $this->filter_name;
1141
+		}
967 1142
     		if ($globalDBdriver == 'mysql') {
968 1143
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
969 1144
                 } else {
@@ -980,7 +1155,9 @@  discard block
 block discarded – undo
980 1155
         }
981 1156
 	public function getStatsAirlineTotal($filter_name = '') {
982 1157
     		global $globalArchiveMonths, $globalDBdriver;
983
-		if ($filter_name == '') $filter_name = $this->filter_name;
1158
+		if ($filter_name == '') {
1159
+			$filter_name = $this->filter_name;
1160
+		}
984 1161
     		if ($globalDBdriver == 'mysql') {
985 1162
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
986 1163
                 } else {
@@ -997,7 +1174,9 @@  discard block
 block discarded – undo
997 1174
         }
998 1175
 	public function getStatsOwnerTotal($filter_name = '') {
999 1176
     		global $globalArchiveMonths, $globalDBdriver;
1000
-		if ($filter_name == '') $filter_name = $this->filter_name;
1177
+		if ($filter_name == '') {
1178
+			$filter_name = $this->filter_name;
1179
+		}
1001 1180
     		if ($globalDBdriver == 'mysql') {
1002 1181
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1003 1182
 		} else {
@@ -1014,7 +1193,9 @@  discard block
 block discarded – undo
1014 1193
         }
1015 1194
 	public function getStatsOwner($owner_name,$filter_name = '') {
1016 1195
     		global $globalArchiveMonths, $globalDBdriver;
1017
-		if ($filter_name == '') $filter_name = $this->filter_name;
1196
+		if ($filter_name == '') {
1197
+			$filter_name = $this->filter_name;
1198
+		}
1018 1199
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1019 1200
                  try {
1020 1201
                         $sth = $this->db->prepare($query);
@@ -1023,12 +1204,17 @@  discard block
 block discarded – undo
1023 1204
                         echo "error : ".$e->getMessage();
1024 1205
                 }
1025 1206
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1026
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1027
-                else return 0;
1207
+                if (isset($all[0]['cnt'])) {
1208
+                	return $all[0]['cnt'];
1209
+                } else {
1210
+                	return 0;
1211
+                }
1028 1212
         }
1029 1213
 	public function getStatsPilotTotal($filter_name = '') {
1030 1214
     		global $globalArchiveMonths, $globalDBdriver;
1031
-		if ($filter_name == '') $filter_name = $this->filter_name;
1215
+		if ($filter_name == '') {
1216
+			$filter_name = $this->filter_name;
1217
+		}
1032 1218
     		if ($globalDBdriver == 'mysql') {
1033 1219
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1034 1220
             	} else {
@@ -1045,7 +1231,9 @@  discard block
 block discarded – undo
1045 1231
         }
1046 1232
 	public function getStatsPilot($pilot,$filter_name = '') {
1047 1233
     		global $globalArchiveMonths, $globalDBdriver;
1048
-		if ($filter_name == '') $filter_name = $this->filter_name;
1234
+		if ($filter_name == '') {
1235
+			$filter_name = $this->filter_name;
1236
+		}
1049 1237
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1050 1238
                  try {
1051 1239
                         $sth = $this->db->prepare($query);
@@ -1054,13 +1242,18 @@  discard block
 block discarded – undo
1054 1242
                         echo "error : ".$e->getMessage();
1055 1243
                 }
1056 1244
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1057
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1058
-                else return 0;
1245
+                if (isset($all[0]['cnt'])) {
1246
+                	return $all[0]['cnt'];
1247
+                } else {
1248
+                	return 0;
1249
+                }
1059 1250
         }
1060 1251
 
1061 1252
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1062 1253
 		global $globalDBdriver;
1063
-		if ($filter_name == '') $filter_name = $this->filter_name;
1254
+		if ($filter_name == '') {
1255
+			$filter_name = $this->filter_name;
1256
+		}
1064 1257
 		if ($globalDBdriver == 'mysql') {
1065 1258
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
1066 1259
                 } else {
@@ -1076,7 +1269,9 @@  discard block
 block discarded – undo
1076 1269
         }
1077 1270
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1078 1271
 		global $globalDBdriver;
1079
-		if ($filter_name == '') $filter_name = $this->filter_name;
1272
+		if ($filter_name == '') {
1273
+			$filter_name = $this->filter_name;
1274
+		}
1080 1275
 		if ($globalDBdriver == 'mysql') {
1081 1276
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1082 1277
 		} else {
@@ -1462,10 +1657,14 @@  discard block
 block discarded – undo
1462 1657
     		$Connection = new Connection();
1463 1658
     		date_default_timezone_set('UTC');
1464 1659
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1465
-			if ($globalDebug) echo 'Update stats !'."\n";
1660
+			if ($globalDebug) {
1661
+				echo 'Update stats !'."\n";
1662
+			}
1466 1663
 			if (isset($last_update[0]['value'])) {
1467 1664
 				$last_update_day = $last_update[0]['value'];
1468
-			} else $last_update_day = '2012-12-12 12:12:12';
1665
+			} else {
1666
+				$last_update_day = '2012-12-12 12:12:12';
1667
+			}
1469 1668
 			$reset = false;
1470 1669
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
1471 1670
 			if ($globalStatsResetYear) {
@@ -1474,42 +1673,60 @@  discard block
 block discarded – undo
1474 1673
 			}
1475 1674
 			$Spotter = new Spotter($this->db);
1476 1675
 
1477
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1676
+			if ($globalDebug) {
1677
+				echo 'Count all aircraft types...'."\n";
1678
+			}
1478 1679
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1479 1680
 			foreach ($alldata as $number) {
1480 1681
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1481 1682
 			}
1482
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1683
+			if ($globalDebug) {
1684
+				echo 'Count all airlines...'."\n";
1685
+			}
1483 1686
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1484 1687
 			foreach ($alldata as $number) {
1485 1688
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1486 1689
 			}
1487
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1690
+			if ($globalDebug) {
1691
+				echo 'Count all registrations...'."\n";
1692
+			}
1488 1693
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1489 1694
 			foreach ($alldata as $number) {
1490 1695
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1491 1696
 			}
1492
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1697
+			if ($globalDebug) {
1698
+				echo 'Count all callsigns...'."\n";
1699
+			}
1493 1700
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1494 1701
 			foreach ($alldata as $number) {
1495 1702
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1496 1703
 			}
1497
-			if ($globalDebug) echo 'Count all owners...'."\n";
1704
+			if ($globalDebug) {
1705
+				echo 'Count all owners...'."\n";
1706
+			}
1498 1707
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1499 1708
 			foreach ($alldata as $number) {
1500 1709
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1501 1710
 			}
1502
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1711
+			if ($globalDebug) {
1712
+				echo 'Count all pilots...'."\n";
1713
+			}
1503 1714
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1504 1715
 			foreach ($alldata as $number) {
1505 1716
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1506 1717
 			}
1507 1718
 			
1508
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1719
+			if ($globalDebug) {
1720
+				echo 'Count all departure airports...'."\n";
1721
+			}
1509 1722
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1510
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1723
+			if ($globalDebug) {
1724
+				echo 'Count all detected departure airports...'."\n";
1725
+			}
1511 1726
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1512
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1727
+			if ($globalDebug) {
1728
+				echo 'Order departure airports...'."\n";
1729
+			}
1513 1730
 	        	$alldata = array();
1514 1731
 	        	
1515 1732
     			foreach ($pall as $value) {
@@ -1520,7 +1737,9 @@  discard block
 block discarded – undo
1520 1737
     				$icao = $value['airport_departure_icao'];
1521 1738
         			if (isset($alldata[$icao])) {
1522 1739
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1523
-        			} else $alldata[$icao] = $value;
1740
+        			} else {
1741
+        				$alldata[$icao] = $value;
1742
+        			}
1524 1743
 			}
1525 1744
     			$count = array();
1526 1745
     			foreach ($alldata as $key => $row) {
@@ -1530,11 +1749,17 @@  discard block
 block discarded – undo
1530 1749
 			foreach ($alldata as $number) {
1531 1750
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1532 1751
 			}
1533
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1752
+			if ($globalDebug) {
1753
+				echo 'Count all arrival airports...'."\n";
1754
+			}
1534 1755
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1535
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1756
+			if ($globalDebug) {
1757
+				echo 'Count all detected arrival airports...'."\n";
1758
+			}
1536 1759
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1537
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1760
+			if ($globalDebug) {
1761
+				echo 'Order arrival airports...'."\n";
1762
+			}
1538 1763
 	        	$alldata = array();
1539 1764
     			foreach ($pall as $value) {
1540 1765
 	        		$icao = $value['airport_arrival_icao'];
@@ -1544,7 +1769,9 @@  discard block
 block discarded – undo
1544 1769
     				$icao = $value['airport_arrival_icao'];
1545 1770
         			if (isset($alldata[$icao])) {
1546 1771
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1547
-	        		} else $alldata[$icao] = $value;
1772
+	        		} else {
1773
+	        			$alldata[$icao] = $value;
1774
+	        		}
1548 1775
     			}
1549 1776
         		$count = array();
1550 1777
         		foreach ($alldata as $key => $row) {
@@ -1555,7 +1782,9 @@  discard block
 block discarded – undo
1555 1782
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1556 1783
 			}
1557 1784
 			if ($Connection->tableExists('countries')) {
1558
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1785
+				if ($globalDebug) {
1786
+					echo 'Count all flights by countries...'."\n";
1787
+				}
1559 1788
 				$SpotterArchive = new SpotterArchive();
1560 1789
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1561 1790
 				foreach ($alldata as $number) {
@@ -1567,46 +1796,66 @@  discard block
 block discarded – undo
1567 1796
 			// Add by month using getstat if month finish...
1568 1797
 
1569 1798
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1570
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1799
+			if ($globalDebug) {
1800
+				echo 'Count all flights by months...'."\n";
1801
+			}
1571 1802
 			$Spotter = new Spotter($this->db);
1572 1803
 			$alldata = $Spotter->countAllMonths();
1573 1804
 			$lastyear = false;
1574 1805
 			foreach ($alldata as $number) {
1575
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1806
+				if ($number['year_name'] != date('Y')) {
1807
+					$lastyear = true;
1808
+				}
1576 1809
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1577 1810
 			}
1578
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1811
+			if ($globalDebug) {
1812
+				echo 'Count all military flights by months...'."\n";
1813
+			}
1579 1814
 			$alldata = $Spotter->countAllMilitaryMonths();
1580 1815
 			foreach ($alldata as $number) {
1581 1816
 				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1582 1817
 			}
1583
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1818
+			if ($globalDebug) {
1819
+				echo 'Count all owners by months...'."\n";
1820
+			}
1584 1821
 			$alldata = $Spotter->countAllMonthsOwners();
1585 1822
 			foreach ($alldata as $number) {
1586 1823
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1587 1824
 			}
1588
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1825
+			if ($globalDebug) {
1826
+				echo 'Count all pilots by months...'."\n";
1827
+			}
1589 1828
 			$alldata = $Spotter->countAllMonthsPilots();
1590 1829
 			foreach ($alldata as $number) {
1591 1830
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1592 1831
 			}
1593
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1832
+			if ($globalDebug) {
1833
+				echo 'Count all airlines by months...'."\n";
1834
+			}
1594 1835
 			$alldata = $Spotter->countAllMonthsAirlines();
1595 1836
 			foreach ($alldata as $number) {
1596 1837
 				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1597 1838
 			}
1598
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1839
+			if ($globalDebug) {
1840
+				echo 'Count all aircrafts by months...'."\n";
1841
+			}
1599 1842
 			$alldata = $Spotter->countAllMonthsAircrafts();
1600 1843
 			foreach ($alldata as $number) {
1601 1844
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1602 1845
 			}
1603
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1846
+			if ($globalDebug) {
1847
+				echo 'Count all real arrivals by months...'."\n";
1848
+			}
1604 1849
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1605 1850
 			foreach ($alldata as $number) {
1606 1851
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1607 1852
 			}
1608
-			if ($globalDebug) echo 'Airports data...'."\n";
1609
-			if ($globalDebug) echo '...Departure'."\n";
1853
+			if ($globalDebug) {
1854
+				echo 'Airports data...'."\n";
1855
+			}
1856
+			if ($globalDebug) {
1857
+				echo '...Departure'."\n";
1858
+			}
1610 1859
 			$this->deleteStatAirport('daily');
1611 1860
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1612 1861
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1727,44 +1976,62 @@  discard block
 block discarded – undo
1727 1976
 			// Count by airlines
1728 1977
 			echo '--- Stats by airlines ---'."\n";
1729 1978
 			if ($Connection->tableExists('countries')) {
1730
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1979
+				if ($globalDebug) {
1980
+					echo 'Count all flights by countries by airlines...'."\n";
1981
+				}
1731 1982
 				$SpotterArchive = new SpotterArchive();
1732 1983
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1733 1984
 				foreach ($alldata as $number) {
1734 1985
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1735 1986
 				}
1736 1987
 			}
1737
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1988
+			if ($globalDebug) {
1989
+				echo 'Count all aircraft types by airlines...'."\n";
1990
+			}
1738 1991
 			$Spotter = new Spotter($this->db);
1739 1992
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1740 1993
 			foreach ($alldata as $number) {
1741 1994
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1742 1995
 			}
1743
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1996
+			if ($globalDebug) {
1997
+				echo 'Count all aircraft registrations by airlines...'."\n";
1998
+			}
1744 1999
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1745 2000
 			foreach ($alldata as $number) {
1746 2001
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1747 2002
 			}
1748
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2003
+			if ($globalDebug) {
2004
+				echo 'Count all callsigns by airlines...'."\n";
2005
+			}
1749 2006
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1750 2007
 			foreach ($alldata as $number) {
1751 2008
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1752 2009
 			}
1753
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2010
+			if ($globalDebug) {
2011
+				echo 'Count all owners by airlines...'."\n";
2012
+			}
1754 2013
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1755 2014
 			foreach ($alldata as $number) {
1756 2015
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1757 2016
 			}
1758
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2017
+			if ($globalDebug) {
2018
+				echo 'Count all pilots by airlines...'."\n";
2019
+			}
1759 2020
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1760 2021
 			foreach ($alldata as $number) {
1761 2022
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1762 2023
 			}
1763
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2024
+			if ($globalDebug) {
2025
+				echo 'Count all departure airports by airlines...'."\n";
2026
+			}
1764 2027
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1765
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2028
+			if ($globalDebug) {
2029
+				echo 'Count all detected departure airports by airlines...'."\n";
2030
+			}
1766 2031
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1767
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2032
+			if ($globalDebug) {
2033
+				echo 'Order detected departure airports by airlines...'."\n";
2034
+			}
1768 2035
 	        	//$alldata = array();
1769 2036
     			foreach ($dall as $value) {
1770 2037
     				$icao = $value['airport_departure_icao'];
@@ -1785,11 +2052,17 @@  discard block
 block discarded – undo
1785 2052
 			foreach ($alldata as $number) {
1786 2053
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
1787 2054
 			}
1788
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2055
+			if ($globalDebug) {
2056
+				echo 'Count all arrival airports by airlines...'."\n";
2057
+			}
1789 2058
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1790
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2059
+			if ($globalDebug) {
2060
+				echo 'Count all detected arrival airports by airlines...'."\n";
2061
+			}
1791 2062
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1792
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2063
+			if ($globalDebug) {
2064
+				echo 'Order arrival airports by airlines...'."\n";
2065
+			}
1793 2066
 	        	//$alldata = array();
1794 2067
     			foreach ($dall as $value) {
1795 2068
     				$icao = $value['airport_arrival_icao'];
@@ -1808,37 +2081,53 @@  discard block
 block discarded – undo
1808 2081
     			}
1809 2082
     			$alldata = $pall;
1810 2083
                         foreach ($alldata as $number) {
1811
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
2084
+				if ($number['airline_icao'] != '') {
2085
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
2086
+				}
2087
+			}
2088
+			if ($globalDebug) {
2089
+				echo 'Count all flights by months by airlines...'."\n";
1812 2090
 			}
1813
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1814 2091
 			$Spotter = new Spotter($this->db);
1815 2092
 			$alldata = $Spotter->countAllMonthsByAirlines();
1816 2093
 			$lastyear = false;
1817 2094
 			foreach ($alldata as $number) {
1818
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2095
+				if ($number['year_name'] != date('Y')) {
2096
+					$lastyear = true;
2097
+				}
1819 2098
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1820 2099
 			}
1821
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2100
+			if ($globalDebug) {
2101
+				echo 'Count all owners by months by airlines...'."\n";
2102
+			}
1822 2103
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1823 2104
 			foreach ($alldata as $number) {
1824 2105
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1825 2106
 			}
1826
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2107
+			if ($globalDebug) {
2108
+				echo 'Count all pilots by months by airlines...'."\n";
2109
+			}
1827 2110
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1828 2111
 			foreach ($alldata as $number) {
1829 2112
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1830 2113
 			}
1831
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2114
+			if ($globalDebug) {
2115
+				echo 'Count all aircrafts by months by airlines...'."\n";
2116
+			}
1832 2117
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1833 2118
 			foreach ($alldata as $number) {
1834 2119
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1835 2120
 			}
1836
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2121
+			if ($globalDebug) {
2122
+				echo 'Count all real arrivals by months by airlines...'."\n";
2123
+			}
1837 2124
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1838 2125
 			foreach ($alldata as $number) {
1839 2126
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1840 2127
 			}
1841
-			if ($globalDebug) echo '...Departure'."\n";
2128
+			if ($globalDebug) {
2129
+				echo '...Departure'."\n";
2130
+			}
1842 2131
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1843 2132
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1844 2133
     			foreach ($dall as $value) {
@@ -1861,7 +2150,9 @@  discard block
 block discarded – undo
1861 2150
 			foreach ($alldata as $number) {
1862 2151
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
1863 2152
 			}
1864
-			if ($globalDebug) echo '...Arrival'."\n";
2153
+			if ($globalDebug) {
2154
+				echo '...Arrival'."\n";
2155
+			}
1865 2156
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1866 2157
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1867 2158
     			foreach ($dall as $value) {
@@ -1885,13 +2176,19 @@  discard block
 block discarded – undo
1885 2176
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
1886 2177
 			}
1887 2178
 
1888
-			if ($globalDebug) echo 'Flights data...'."\n";
1889
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2179
+			if ($globalDebug) {
2180
+				echo 'Flights data...'."\n";
2181
+			}
2182
+			if ($globalDebug) {
2183
+				echo '-> countAllDatesLastMonth...'."\n";
2184
+			}
1890 2185
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1891 2186
 			foreach ($alldata as $number) {
1892 2187
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1893 2188
 			}
1894
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2189
+			if ($globalDebug) {
2190
+				echo '-> countAllDates...'."\n";
2191
+			}
1895 2192
 			//$previousdata = $this->countAllDatesByAirlines();
1896 2193
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1897 2194
 			$values = array();
@@ -1904,7 +2201,9 @@  discard block
 block discarded – undo
1904 2201
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1905 2202
 			}
1906 2203
 			
1907
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2204
+			if ($globalDebug) {
2205
+				echo '-> countAllHours...'."\n";
2206
+			}
1908 2207
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1909 2208
 			foreach ($alldata as $number) {
1910 2209
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1912,7 +2211,9 @@  discard block
 block discarded – undo
1912 2211
 			
1913 2212
 
1914 2213
 			// Stats by filters
1915
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2214
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2215
+				$globalStatsFilters = array();
2216
+			}
1916 2217
 			foreach ($globalStatsFilters as $name => $filter) {
1917 2218
 				//$filter_name = $filter['name'];
1918 2219
 				$filter_name = $name;
@@ -1936,7 +2237,9 @@  discard block
 block discarded – undo
1936 2237
 				
1937 2238
 
1938 2239
 				// Count by filter
1939
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2240
+				if ($globalDebug) {
2241
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2242
+				}
1940 2243
 				$Spotter = new Spotter($this->db);
1941 2244
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1942 2245
 				foreach ($alldata as $number) {
@@ -1973,7 +2276,9 @@  discard block
 block discarded – undo
1973 2276
 	    				$icao = $value['airport_departure_icao'];
1974 2277
         				if (isset($alldata[$icao])) {
1975 2278
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1976
-        				} else $alldata[$icao] = $value;
2279
+        				} else {
2280
+        					$alldata[$icao] = $value;
2281
+        				}
1977 2282
 				}
1978 2283
 	    			$count = array();
1979 2284
     				foreach ($alldata as $key => $row) {
@@ -1994,7 +2299,9 @@  discard block
 block discarded – undo
1994 2299
 	    				$icao = $value['airport_arrival_icao'];
1995 2300
         				if (isset($alldata[$icao])) {
1996 2301
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1997
-		        		} else $alldata[$icao] = $value;
2302
+		        		} else {
2303
+		        			$alldata[$icao] = $value;
2304
+		        		}
1998 2305
 	    			}
1999 2306
         			$count = array();
2000 2307
         			foreach ($alldata as $key => $row) {
@@ -2008,7 +2315,9 @@  discard block
 block discarded – undo
2008 2315
 				$alldata = $Spotter->countAllMonths($filter);
2009 2316
 				$lastyear = false;
2010 2317
 				foreach ($alldata as $number) {
2011
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2318
+					if ($number['year_name'] != date('Y')) {
2319
+						$lastyear = true;
2320
+					}
2012 2321
 					$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2013 2322
 				}
2014 2323
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Braces   +86 added lines, -35 removed lines patch added patch discarded remove patch
@@ -102,7 +102,9 @@  discard block
 block discarded – undo
102 102
 	
103 103
 	/* Check that end was found and body has at least one byte. */
104 104
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
105
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
105
+	    if ($globalDebug) {
106
+	    	echo '!!! APRS invalid : '.$input."\n";
107
+	    }
106 108
 	    return false;
107 109
 	}
108 110
 	
@@ -111,23 +113,31 @@  discard block
 block discarded – undo
111 113
 	$body_len = strlen($body);
112 114
 	$header = substr($input,0,$splitpos);
113 115
 	//$header_len = strlen($header);
114
-	if ($debug) echo 'header : '.$header."\n";
116
+	if ($debug) {
117
+		echo 'header : '.$header."\n";
118
+	}
115 119
 	
116 120
 	/* Parse source, target and path. */
117 121
 	//FLRDF0A52>APRS,qAS,LSTB
118 122
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
119 123
 	    $ident = $matches[1];
120 124
 	    $all_elements = $matches[2];
121
-	    if ($debug) echo 'ident : '.$ident."\n";
125
+	    if ($debug) {
126
+	    	echo 'ident : '.$ident."\n";
127
+	    }
122 128
 	    $result['ident'] = $ident;
123
-	} else return false;
129
+	} else {
130
+		return false;
131
+	}
124 132
 	$elements = explode(',',$all_elements);
125 133
 	$source = end($elements);
126 134
 	$result['source'] = $source;
127 135
 	foreach ($elements as $element) {
128 136
 	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
129 137
 	        //echo "ok";
130
-	        if ($element == 'TCPIP*') return false;
138
+	        if ($element == 'TCPIP*') {
139
+	        	return false;
140
+	        }
131 141
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
132 142
 		return false;
133 143
 	    }
@@ -194,7 +204,9 @@  discard block
 block discarded – undo
194 204
 		//$symbol_table = $matches[4];
195 205
 		$lat = intval($lat_deg);
196 206
 		$lon = intval($lon_deg);
197
-		if ($lat > 89 || $lon > 179) return false;
207
+		if ($lat > 89 || $lon > 179) {
208
+			return false;
209
+		}
198 210
 	    
199 211
 	    /*
200 212
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -204,8 +216,12 @@  discard block
 block discarded – undo
204 216
 	    */
205 217
 		$latitude = $lat + floatval($lat_min)/60;
206 218
 		$longitude = $lon + floatval($lon_min)/60;
207
-		if ($sind == 'S') $latitude = 0-$latitude;
208
-		if ($wind == 'W') $longitude = 0-$longitude;
219
+		if ($sind == 'S') {
220
+			$latitude = 0-$latitude;
221
+		}
222
+		if ($wind == 'W') {
223
+			$longitude = 0-$longitude;
224
+		}
209 225
 		$result['latitude'] = $latitude;
210 226
 		$result['longitude'] = $longitude;
211 227
 		$body_parse = substr($body_parse,18);
@@ -235,7 +251,9 @@  discard block
 block discarded – undo
235 251
 		//}
236 252
 		//echo $body_parse;
237 253
 		$result['symbol_code'] = $symbol_code;
238
-		if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
254
+		if (isset($this->symbols[$symbol_code])) {
255
+			$result['symbol'] = $this->symbols[$symbol_code];
256
+		}
239 257
 		if ($symbol_code != '_') {
240 258
 		    //$body_parse = substr($body_parse,1);
241 259
 		    //$body_parse = trim($body_parse);
@@ -245,7 +263,9 @@  discard block
 block discarded – undo
245 263
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
246 264
 		    	    $course = substr($body_parse,0,3);
247 265
 		    	    $tmp_s = intval($course);
248
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
266
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
267
+		    	    	$result['heading'] = intval($course);
268
+		    	    }
249 269
 		    	    $speed = substr($body_parse,4,3);
250 270
 		    	    $result['speed'] = round($speed*1.852);
251 271
 		    	    $body_parse = substr($body_parse,7);
@@ -280,10 +300,16 @@  discard block
 block discarded – undo
280 300
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
281 301
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
282 302
 			    
283
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
284
-				else $result['latitude'] += $lat_off;
285
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
286
-				else $result['longitude'] += $lon_off;
303
+				if ($result['latitude'] < 0) {
304
+					$result['latitude'] -= $lat_off;
305
+				} else {
306
+					$result['latitude'] += $lat_off;
307
+				}
308
+				if ($result['longitude'] < 0) {
309
+					$result['longitude'] -= $lon_off;
310
+				} else {
311
+					$result['longitude'] += $lon_off;
312
+				}
287 313
 			    }
288 314
 		            $body_parse = substr($body_parse,6);
289 315
 		    }
@@ -296,27 +322,48 @@  discard block
 block discarded – undo
296 322
 			$address = substr($id,2);
297 323
 			//print_r($matches);
298 324
 			$addressType = (intval(substr($id,0,2),16))&3;
299
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
300
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
301
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
302
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
325
+			if ($addressType == 0) {
326
+				$result['addresstype'] = "RANDOM";
327
+			} elseif ($addressType == 1) {
328
+				$result['addresstype'] = "ICAO";
329
+			} elseif ($addressType == 2) {
330
+				$result['addresstype'] = "FLARM";
331
+			} elseif ($addressType == 3) {
332
+				$result['addresstype'] = "OGN";
333
+			}
303 334
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
304 335
 			$result['aircrafttype_code'] = $aircraftType;
305
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
306
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
307
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
308
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
309
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
310
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
311
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
312
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
313
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
314
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
315
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
316
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
317
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
318
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
319
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
336
+			if ($aircraftType == 0) {
337
+				$result['aircrafttype'] = "UNKNOWN";
338
+			} elseif ($aircraftType == 1) {
339
+				$result['aircrafttype'] = "GLIDER";
340
+			} elseif ($aircraftType == 2) {
341
+				$result['aircrafttype'] = "TOW_PLANE";
342
+			} elseif ($aircraftType == 3) {
343
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
344
+			} elseif ($aircraftType == 4) {
345
+				$result['aircrafttype'] = "PARACHUTE";
346
+			} elseif ($aircraftType == 5) {
347
+				$result['aircrafttype'] = "DROP_PLANE";
348
+			} elseif ($aircraftType == 6) {
349
+				$result['aircrafttype'] = "HANG_GLIDER";
350
+			} elseif ($aircraftType == 7) {
351
+				$result['aircrafttype'] = "PARA_GLIDER";
352
+			} elseif ($aircraftType == 8) {
353
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
354
+			} elseif ($aircraftType == 9) {
355
+				$result['aircrafttype'] = "JET_AIRCRAFT";
356
+			} elseif ($aircraftType == 10) {
357
+				$result['aircrafttype'] = "UFO";
358
+			} elseif ($aircraftType == 11) {
359
+				$result['aircrafttype'] = "BALLOON";
360
+			} elseif ($aircraftType == 12) {
361
+				$result['aircrafttype'] = "AIRSHIP";
362
+			} elseif ($aircraftType == 13) {
363
+				$result['aircrafttype'] = "UAV";
364
+			} elseif ($aircraftType == 15) {
365
+				$result['aircrafttype'] = "STATIC_OBJECT";
366
+			}
320 367
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
321 368
 			$result['stealth'] = $stealth;
322 369
 			$result['address'] = $address;
@@ -358,8 +405,12 @@  discard block
 block discarded – undo
358 405
 		}
359 406
 	    }
360 407
 	//}
361
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
362
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
408
+	if (isset($result['latitude'])) {
409
+		$result['latitude'] = round($result['latitude'],4);
410
+	}
411
+	if (isset($result['longitude'])) {
412
+		$result['longitude'] = round($result['longitude'],4);
413
+	}
363 414
 	//print_r($result);
364 415
 	return $result;
365 416
     }
Please login to merge, or discard this patch.