Completed
Push — master ( e8aabf...bcd2cf )
by Yannick
07:24
created
require/class.ATC.php 1 patch
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,20 +20,27 @@  discard block
 block discarded – undo
20 20
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 	    if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 		foreach($globalStatsFilters[$globalFilterName] as $source) {
23
-			if (isset($source['source'])) $filter['source'][] = $source['source'];
23
+			if (isset($source['source'])) {
24
+				$filter['source'][] = $source['source'];
25
+			}
24 26
 		}
25 27
 	    } else {
26 28
 		$filter = $globalStatsFilters[$globalFilterName];
27 29
 	    }
28 30
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
31
+	if (is_array($globalFilter)) {
32
+		$filter = array_merge($filter,$globalFilter);
33
+	}
30 34
 	$filter_query_join = '';
31 35
 	$filter_query_where = '';
32 36
 	if (isset($filter['source']) && !empty($filter['source'])) {
33 37
 	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
34 38
 	}
35
-	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36
-	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
39
+	if ($filter_query_where == '' && $where) {
40
+		$filter_query_where = ' WHERE';
41
+	} elseif ($filter_query_where != '' && $and) {
42
+		$filter_query_where .= ' AND';
43
+	}
37 44
 	$filter_query = $filter_query_join.$filter_query_where;
38 45
 	return $filter_query;
39 46
     }
@@ -57,7 +64,9 @@  discard block
 block discarded – undo
57 64
     		$info = str_replace('^','<br />',$info);
58 65
     		$info = str_replace('&amp;sect;','',$info);
59 66
     		$info = str_replace('"','',$info);
60
-    		if ($type == '') $type = NULL;
67
+    		if ($type == '') {
68
+    			$type = NULL;
69
+    		}
61 70
                 $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
62 71
                 $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
63 72
                  try {
Please login to merge, or discard this patch.
live-santa-czml.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
30 30
 $output .= ',"clock": {"currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"';
31
-if (!isset($_GET['now'])) $output .= ',"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z"';
31
+if (!isset($_GET['now'])) {
32
+	$output .= ',"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z"';
33
+}
32 34
 $output .= '}';
33 35
 //$output .= ',"clock": {"currentTime" : "'.date("c",time()).'","multiplier" : 300,"range" : "UNBOUNDED","step": "TICK_DEPENDENT"}';
34 36
 //$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
@@ -37,7 +39,9 @@  discard block
 block discarded – undo
37 39
 $output .= '},';
38 40
 $output .= '{';
39 41
 $output .= '"id": "santaclaus",';
40
-if (!isset($_GET['now'])) $output .= '"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z",';
42
+if (!isset($_GET['now'])) {
43
+	$output .= '"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z",';
44
+}
41 45
 $output .= '"properties": {';
42 46
 // Not yet supported in CZML with Cesium
43 47
 $output .= '},';
Please login to merge, or discard this patch.
js/map.js.php 1 patch
Braces   +128 added lines, -33 removed lines patch added patch discarded remove patch
@@ -6,8 +6,11 @@  discard block
 block discarded – undo
6 6
 //$_COOKIE['MapFormat'] = '2d';
7 7
 
8 8
 // Compressed GeoJson is used if true
9
-if (!isset($globalJsonCompress)) $compress = true;
10
-else $compress = $globalJsonCompress;
9
+if (!isset($globalJsonCompress)) {
10
+	$compress = true;
11
+} else {
12
+	$compress = $globalJsonCompress;
13
+}
11 14
 ?>
12 15
 <?php
13 16
 	if (isset($_GET['archive'])) {
@@ -19,8 +22,11 @@  discard block
 block discarded – undo
19 22
 		//$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10));
20 23
 		//$lastupd = 20;
21 24
 		$lastupd = $_GET['archivespeed']*$archiveupdatetime;
22
-		if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
23
-		else $enddate = time();
25
+		if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
26
+			$enddate = $_GET['enddate'];
27
+		} else {
28
+			$enddate = time();
29
+		}
24 30
 		setcookie("archive_begin",$begindate);
25 31
 		setcookie("archive_end",$enddate);
26 32
 		setcookie("archive_update",$lastupd);
@@ -127,7 +133,17 @@  discard block
 block discarded – undo
127 133
 	}
128 134
 
129 135
 	//create the map
130
-	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom);
136
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
137
+	print $latitude;
138
+} else {
139
+	print $globalCenterLatitude;
140
+}
141
+?>,<?php if (isset($longitude)) {
142
+	print $longitude;
143
+} else {
144
+	print $globalCenterLongitude;
145
+}
146
+?>], zoom);
131 147
 <?php
132 148
 	} else {
133 149
 ?>
@@ -140,9 +156,19 @@  discard block
 block discarded – undo
140 156
 	     || navigator.userAgent.match(/BlackBerry/i)
141 157
 	     || navigator.userAgent.match(/Windows Phone/i))
142 158
 	{
143
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
159
+		var zoom = <?php if (isset($globalLiveZoom)) {
160
+	print $globalLiveZoom-1;
161
+} else {
162
+	print '8';
163
+}
164
+?>;
144 165
 	} else {
145
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
166
+		var zoom = <?php if (isset($globalLiveZoom)) {
167
+	print $globalLiveZoom;
168
+} else {
169
+	print '9';
170
+}
171
+?>;
146 172
 	}
147 173
 
148 174
 	//create the map
@@ -167,16 +193,27 @@  discard block
 block discarded – undo
167 193
 	bounds = L.latLngBounds(southWest,northEast);
168 194
 	//a few title layers
169 195
 <?php
170
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
171
-	else $MapType = $globalMapProvider;
196
+	if (isset($_COOKIE['MapType'])) {
197
+		$MapType = $_COOKIE['MapType'];
198
+	} else {
199
+		$MapType = $globalMapProvider;
200
+	}
172 201
 
173 202
 	if ($MapType == 'Mapbox') {
174
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
175
-		else $MapBoxId = $_COOKIE['MapTypeId'];
176
-?>
203
+		if ($_COOKIE['MapTypeId'] == 'default') {
204
+			$MapBoxId = $globalMapboxId;
205
+		} else {
206
+			$MapBoxId = $_COOKIE['MapTypeId'];
207
+		}
208
+		?>
177 209
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
178 210
 	    maxZoom: 18,
179
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
211
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
212
+	print 'false';
213
+} else {
214
+	print 'true';
215
+}
216
+?>,
180 217
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
181 218
 	      '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
182 219
 	      'Imagery © <a href="http://mapbox.com">Mapbox</a>',
@@ -188,7 +225,12 @@  discard block
 block discarded – undo
188 225
 ?>
189 226
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
190 227
 	    maxZoom: 18,
191
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
228
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
229
+	print 'false';
230
+} else {
231
+	print 'true';
232
+}
233
+?>,
192 234
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
193 235
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
194 236
 	}).addTo(map);
@@ -234,20 +276,26 @@  discard block
 block discarded – undo
234 276
 	map.addLayer(yandexLayer);
235 277
 <?php
236 278
 	} elseif ($MapType == 'Bing-Aerial') {
237
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
238
-?>
279
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
280
+			setcookie('MapType','OpenStreetMap');
281
+		}
282
+		?>
239 283
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
240 284
 	map.addLayer(bingLayer);
241 285
 <?php
242 286
 	} elseif ($MapType == 'Bing-Hybrid') {
243
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
244
-?>
287
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
288
+			setcookie('MapType','OpenStreetMap');
289
+		}
290
+		?>
245 291
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
246 292
 	map.addLayer(bingLayer);
247 293
 <?php
248 294
 	} elseif ($MapType == 'Bing-Road') {
249
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
250
-?>
295
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
296
+			setcookie('MapType','OpenStreetMap');
297
+		}
298
+		?>
251 299
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
252 300
 	map.addLayer(bingLayer);
253 301
 <?php
@@ -295,7 +343,12 @@  discard block
 block discarded – undo
295 343
 		}
296 344
 	} elseif ($globalBounding == 'circle') {
297 345
 ?>
298
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
346
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
347
+	print $globalBoundingCircleSize;
348
+} else {
349
+	print '70000';
350
+}
351
+?>,{
299 352
 	    color: '#92C7D1',
300 353
 	    fillColor: '#92C7D1',
301 354
 	    fillOpacity: 0.3,
@@ -354,8 +407,11 @@  discard block
 block discarded – undo
354 407
 
355 408
 	function update_airportsLayer() {
356 409
 	    <?php
357
-		if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom'];
358
-		else $getZoom = '7';
410
+		if (isset($_COOKIE['AirportZoom'])) {
411
+			$getZoom = $_COOKIE['AirportZoom'];
412
+		} else {
413
+			$getZoom = '7';
414
+		}
359 415
 	    ?>
360 416
 	    //if (map.getZoom() <= <?php print $getZoom; ?>) {
361 417
 		if (typeof airportsLayer != 'undefined') {
@@ -689,9 +745,13 @@  discard block
 block discarded – undo
689 745
 		    if (callsign != ""){ markerLabel += callsign; }
690 746
 		    if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; }
691 747
 <?php
692
-	if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor'];
693
-	elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor;
694
-	else $IconColor = '1a3151';
748
+	if (isset($_COOKIE['IconColor'])) {
749
+		$IconColor = $_COOKIE['IconColor'];
750
+	} elseif (isset($globalAircraftIconColor)) {
751
+		$IconColor = $globalAircraftIconColor;
752
+	} else {
753
+		$IconColor = '1a3151';
754
+	}
695 755
 	if (!isset($ident) && !isset($flightaware_id)) {
696 756
 ?>
697 757
 		    info_update(feature.properties.fc);
@@ -739,7 +799,12 @@  discard block
 block discarded – undo
739 799
 <?php
740 800
 		} else {
741 801
 ?>
742
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
802
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
803
+	print $archiveupdatetime*1000;
804
+} else {
805
+	print $globalMapRefresh*1000+20000;
806
+}
807
+?>+feature.properties.sqt*1000);
743 808
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
744 809
 <?php
745 810
 		}
@@ -786,7 +851,12 @@  discard block
 block discarded – undo
786 851
 <?php
787 852
 		} else {
788 853
 ?>
789
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
854
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
855
+	print $archiveupdatetime*1000;
856
+} else {
857
+	print $globalMapRefresh*1000+20000;
858
+}
859
+?>+feature.properties.sqt*1000);
790 860
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
791 861
 <?php
792 862
 		}
@@ -832,7 +902,12 @@  discard block
 block discarded – undo
832 902
 <?php
833 903
 		} else {
834 904
 ?>
835
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
905
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
906
+	print $archiveupdatetime*1000;
907
+} else {
908
+	print $globalMapRefresh*1000+20000;
909
+}
910
+?>+feature.properties.sqt*1000);
836 911
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
837 912
 <?php
838 913
 		}
@@ -1173,14 +1248,24 @@  discard block
 block discarded – undo
1173 1248
 	if (isset($_GET['archive'])) {
1174 1249
 ?>
1175 1250
 //then load it again every 30 seconds
1176
-//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
1251
+//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
1252
+	print ($globalMapRefresh*1000)/2;
1253
+} else {
1254
+	print '15000';
1255
+}
1256
+?>);
1177 1257
 reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php print $archiveupdatetime*1000; ?>);
1178 1258
 <?php
1179 1259
 	} else {
1180 1260
 ?>
1181 1261
 //then load it again every 30 seconds
1182 1262
 reloadPage = setInterval(
1183
-    function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
1263
+    function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
1264
+	print $globalMapRefresh*1000;
1265
+} else {
1266
+	print '30000';
1267
+}
1268
+?>);
1184 1269
 var currentdate = new Date(Date.UTC());
1185 1270
 var currentyear = new Date().getFullYear();
1186 1271
 var begindate = new Date(Date.UTC(currentyear,12,24,2,0,0,0));
@@ -1192,7 +1277,12 @@  discard block
 block discarded – undo
1192 1277
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
1193 1278
 ?>
1194 1279
 update_polarLayer();
1195
-setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
1280
+setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) {
1281
+	print $globalMapRefresh*1000*2;
1282
+} else {
1283
+	print '60000';
1284
+}
1285
+?>);
1196 1286
 <?php
1197 1287
 		}
1198 1288
 ?>
@@ -1208,7 +1298,12 @@  discard block
 block discarded – undo
1208 1298
 	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
1209 1299
 ?>
1210 1300
 update_atcLayer();
1211
-setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
1301
+setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) {
1302
+	print $globalMapRefresh*1000*2;
1303
+} else {
1304
+	print '60000';
1305
+}
1306
+?>);
1212 1307
 <?php
1213 1308
 	}
1214 1309
 ?>
Please login to merge, or discard this patch.
live-santa-geojson.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,8 +22,11 @@
 block discarded – undo
22 22
 $j = 0;
23 23
 $prev_satname = '';
24 24
 $timearray = array();
25
-if (isset($_GET['now'])) $begin = time();
26
-else $begin = strtotime(date("Y").'-12-24T02:00:00Z');
25
+if (isset($_GET['now'])) {
26
+	$begin = time();
27
+} else {
28
+	$begin = strtotime(date("Y").'-12-24T02:00:00Z');
29
+}
27 30
 for ($i =0; $i <= 288; $i++) {
28 31
 	$timearray[] = ($begin + $i*300)*1000;
29 32
 }
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Braces   +386 added lines, -134 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
         }
@@ -59,7 +61,9 @@  discard block
 block discarded – undo
59 61
                 }
60 62
         }
61 63
 	public function getAllAirlineNames($filter_name = '') {
62
-		if ($filter_name == '') $filter_name = $this->filter_name;
64
+		if ($filter_name == '') {
65
+			$filter_name = $this->filter_name;
66
+		}
63 67
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
64 68
                  try {
65 69
                         $sth = $this->db->prepare($query);
@@ -71,7 +75,9 @@  discard block
 block discarded – undo
71 75
                 return $all;
72 76
         }
73 77
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
74
-		if ($filter_name == '') $filter_name = $this->filter_name;
78
+		if ($filter_name == '') {
79
+			$filter_name = $this->filter_name;
80
+		}
75 81
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
76 82
                  try {
77 83
                         $sth = $this->db->prepare($query);
@@ -83,7 +89,9 @@  discard block
 block discarded – undo
83 89
                 return $all;
84 90
         }
85 91
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
86
-		if ($filter_name == '') $filter_name = $this->filter_name;
92
+		if ($filter_name == '') {
93
+			$filter_name = $this->filter_name;
94
+		}
87 95
                 $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";
88 96
                  try {
89 97
                         $sth = $this->db->prepare($query);
@@ -95,7 +103,9 @@  discard block
 block discarded – undo
95 103
                 return $all;
96 104
         }
97 105
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
98
-		if ($filter_name == '') $filter_name = $this->filter_name;
106
+		if ($filter_name == '') {
107
+			$filter_name = $this->filter_name;
108
+		}
99 109
                 $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";
100 110
                  try {
101 111
                         $sth = $this->db->prepare($query);
@@ -110,9 +120,14 @@  discard block
 block discarded – undo
110 120
 
111 121
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') {
112 122
 		global $globalStatsFilters;
113
-		if ($filter_name == '') $filter_name = $this->filter_name;
114
-		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";
115
-		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";
123
+		if ($filter_name == '') {
124
+			$filter_name = $this->filter_name;
125
+		}
126
+		if ($limit) {
127
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";
128
+		} else {
129
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name 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";
130
+		}
116 131
                  try {
117 132
                         $sth = $this->db->prepare($query);
118 133
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -132,9 +147,14 @@  discard block
 block discarded – undo
132 147
 	}
133 148
 	public function countAllAirlineCountries($limit = true,$filter_name = '') {
134 149
 		global $globalStatsFilters;
135
-		if ($filter_name == '') $filter_name = $this->filter_name;
136
-		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";
137
-		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";
150
+		if ($filter_name == '') {
151
+			$filter_name = $this->filter_name;
152
+		}
153
+		if ($limit) {
154
+			$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";
155
+		} else {
156
+			$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";
157
+		}
138 158
                  try {
139 159
                         $sth = $this->db->prepare($query);
140 160
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -154,9 +174,14 @@  discard block
 block discarded – undo
154 174
 	}
155 175
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') {
156 176
 		global $globalStatsFilters;
157
-		if ($filter_name == '') $filter_name = $this->filter_name;
158
-		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";
159
-		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";
177
+		if ($filter_name == '') {
178
+			$filter_name = $this->filter_name;
179
+		}
180
+		if ($limit) {
181
+			$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";
182
+		} else {
183
+			$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";
184
+		}
160 185
                  try {
161 186
                         $sth = $this->db->prepare($query);
162 187
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -177,9 +202,14 @@  discard block
 block discarded – undo
177 202
 
178 203
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') {
179 204
 		global $globalStatsFilters;
180
-		if ($filter_name == '') $filter_name = $this->filter_name;
181
-		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";
182
-		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";
205
+		if ($filter_name == '') {
206
+			$filter_name = $this->filter_name;
207
+		}
208
+		if ($limit) {
209
+			$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";
210
+		} else {
211
+			$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";
212
+		}
183 213
                  try {
184 214
                         $sth = $this->db->prepare($query);
185 215
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -199,9 +229,14 @@  discard block
 block discarded – undo
199 229
 	}
200 230
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') {
201 231
 		global $globalStatsFilters;
202
-		if ($filter_name == '') $filter_name = $this->filter_name;
203
-		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";
204
-		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";
232
+		if ($filter_name == '') {
233
+			$filter_name = $this->filter_name;
234
+		}
235
+		if ($limit) {
236
+			$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";
237
+		} else {
238
+			$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";
239
+		}
205 240
                  try {
206 241
                         $sth = $this->db->prepare($query);
207 242
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -222,9 +257,14 @@  discard block
 block discarded – undo
222 257
 
223 258
 	public function countAllAirlines($limit = true,$filter_name = '') {
224 259
 		global $globalStatsFilters;
225
-		if ($filter_name == '') $filter_name = $this->filter_name;
226
-		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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
227
-		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 ORDER BY airline_count DESC";
260
+		if ($filter_name == '') {
261
+			$filter_name = $this->filter_name;
262
+		}
263
+		if ($limit) {
264
+			$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 ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
265
+		} else {
266
+			$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 ORDER BY airline_count DESC";
267
+		}
228 268
                  try {
229 269
                         $sth = $this->db->prepare($query);
230 270
                         $sth->execute(array(':filter_name' => $filter_name));
@@ -245,9 +285,14 @@  discard block
 block discarded – undo
245 285
 	}
246 286
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') {
247 287
 		global $globalStatsFilters;
248
-		if ($filter_name == '') $filter_name = $this->filter_name;
249
-		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";
250
-		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";
288
+		if ($filter_name == '') {
289
+			$filter_name = $this->filter_name;
290
+		}
291
+		if ($limit) {
292
+			$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";
293
+		} else {
294
+			$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";
295
+		}
251 296
                  try {
252 297
                         $sth = $this->db->prepare($query);
253 298
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -267,9 +312,14 @@  discard block
 block discarded – undo
267 312
 	}
268 313
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') {
269 314
 		global $globalStatsFilters;
270
-		if ($filter_name == '') $filter_name = $this->filter_name;
271
-		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";
272
-		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";
315
+		if ($filter_name == '') {
316
+			$filter_name = $this->filter_name;
317
+		}
318
+		if ($limit) {
319
+			$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";
320
+		} else {
321
+			$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";
322
+		}
273 323
 		 try {
274 324
 			$sth = $this->db->prepare($query);
275 325
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -289,10 +339,15 @@  discard block
 block discarded – undo
289 339
 	}
290 340
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '') {
291 341
 		$Connection = new Connection();
292
-		if ($filter_name == '') $filter_name = $this->filter_name;
342
+		if ($filter_name == '') {
343
+			$filter_name = $this->filter_name;
344
+		}
293 345
 		if ($Connection->tableExists('countries')) {
294
-			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";
295
-			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";
346
+			if ($limit) {
347
+				$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";
348
+			} else {
349
+				$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";
350
+			}
296 351
 			 try {
297 352
 				$sth = $this->db->prepare($query);
298 353
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -313,9 +368,14 @@  discard block
 block discarded – undo
313 368
 	}
314 369
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '') {
315 370
 		global $globalStatsFilters;
316
-		if ($filter_name == '') $filter_name = $this->filter_name;
317
-		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";
318
-		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";
371
+		if ($filter_name == '') {
372
+			$filter_name = $this->filter_name;
373
+		}
374
+		if ($limit) {
375
+			$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";
376
+		} else {
377
+			$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";
378
+		}
319 379
                  try {
320 380
                         $sth = $this->db->prepare($query);
321 381
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -335,9 +395,14 @@  discard block
 block discarded – undo
335 395
 	}
336 396
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') {
337 397
 		global $globalStatsFilters;
338
-		if ($filter_name == '') $filter_name = $this->filter_name;
339
-		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";
340
-		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";
398
+		if ($filter_name == '') {
399
+			$filter_name = $this->filter_name;
400
+		}
401
+		if ($limit) {
402
+			$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";
403
+		} else {
404
+			$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";
405
+		}
341 406
                  try {
342 407
                         $sth = $this->db->prepare($query);
343 408
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -357,9 +422,14 @@  discard block
 block discarded – undo
357 422
 	}
358 423
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') {
359 424
 		global $globalStatsFilters;
360
-		if ($filter_name == '') $filter_name = $this->filter_name;
361
-		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";
362
-		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";
425
+		if ($filter_name == '') {
426
+			$filter_name = $this->filter_name;
427
+		}
428
+		if ($limit) {
429
+			$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";
430
+		} else {
431
+			$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";
432
+		}
363 433
                  try {
364 434
                         $sth = $this->db->prepare($query);
365 435
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -385,7 +455,9 @@  discard block
 block discarded – undo
385 455
         			$icao = $value['airport_departure_icao'];
386 456
         			if (isset($all[$icao])) {
387 457
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
388
-        			} else $all[$icao] = $value;
458
+        			} else {
459
+        				$all[$icao] = $value;
460
+        			}
389 461
         		}
390 462
         		$count = array();
391 463
         		foreach ($all as $key => $row) {
@@ -397,9 +469,14 @@  discard block
 block discarded – undo
397 469
 	}
398 470
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') {
399 471
 		global $globalStatsFilters;
400
-		if ($filter_name == '') $filter_name = $this->filter_name;
401
-		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";
402
-		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";
472
+		if ($filter_name == '') {
473
+			$filter_name = $this->filter_name;
474
+		}
475
+		if ($limit) {
476
+			$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";
477
+		} else {
478
+			$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";
479
+		}
403 480
 		try {
404 481
 			$sth = $this->db->prepare($query);
405 482
 			$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -425,7 +502,9 @@  discard block
 block discarded – undo
425 502
         			$icao = $value['airport_arrival_icao'];
426 503
         			if (isset($all[$icao])) {
427 504
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
428
-        			} else $all[$icao] = $value;
505
+        			} else {
506
+        				$all[$icao] = $value;
507
+        			}
429 508
         		}
430 509
         		$count = array();
431 510
         		foreach ($all as $key => $row) {
@@ -438,13 +517,21 @@  discard block
 block discarded – undo
438 517
 	}
439 518
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
440 519
 		global $globalDBdriver, $globalStatsFilters;
441
-		if ($filter_name == '') $filter_name = $this->filter_name;
520
+		if ($filter_name == '') {
521
+			$filter_name = $this->filter_name;
522
+		}
442 523
 		if ($globalDBdriver == 'mysql') {
443
-			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";
444
-			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";
524
+			if ($limit) {
525
+				$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";
526
+			} else {
527
+				$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";
528
+			}
445 529
 		} else {
446
-			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";
447
-			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";
530
+			if ($limit) {
531
+				$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";
532
+			} else {
533
+				$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";
534
+			}
448 535
 		}
449 536
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
450 537
                  try {
@@ -468,7 +555,9 @@  discard block
 block discarded – undo
468 555
 	
469 556
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
470 557
 		global $globalStatsFilters;
471
-		if ($filter_name == '') $filter_name = $this->filter_name;
558
+		if ($filter_name == '') {
559
+			$filter_name = $this->filter_name;
560
+		}
472 561
 		$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";
473 562
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
474 563
                  try {
@@ -490,7 +579,9 @@  discard block
 block discarded – undo
490 579
 	}
491 580
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
492 581
 		global $globalDBdriver, $globalStatsFilters;
493
-		if ($filter_name == '') $filter_name = $this->filter_name;
582
+		if ($filter_name == '') {
583
+			$filter_name = $this->filter_name;
584
+		}
494 585
 		if ($globalDBdriver == 'mysql') {
495 586
 			$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";
496 587
 		} else {
@@ -516,7 +607,9 @@  discard block
 block discarded – undo
516 607
 	}
517 608
 	public function countAllDates($stats_airline = '',$filter_name = '') {
518 609
 		global $globalStatsFilters;
519
-		if ($filter_name == '') $filter_name = $this->filter_name;
610
+		if ($filter_name == '') {
611
+			$filter_name = $this->filter_name;
612
+		}
520 613
 		$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";
521 614
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
522 615
                  try {
@@ -538,7 +631,9 @@  discard block
 block discarded – undo
538 631
 	}
539 632
 	public function countAllDatesByAirlines($filter_name = '') {
540 633
 		global $globalStatsFilters;
541
-		if ($filter_name == '') $filter_name = $this->filter_name;
634
+		if ($filter_name == '') {
635
+			$filter_name = $this->filter_name;
636
+		}
542 637
 		$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";
543 638
 		$query_data = array('filter_name' => $filter_name);
544 639
                  try {
@@ -560,7 +655,9 @@  discard block
 block discarded – undo
560 655
 	}
561 656
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
562 657
 		global $globalStatsFilters;
563
-		if ($filter_name == '') $filter_name = $this->filter_name;
658
+		if ($filter_name == '') {
659
+			$filter_name = $this->filter_name;
660
+		}
564 661
 	    	$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";
565 662
                  try {
566 663
                         $sth = $this->db->prepare($query);
@@ -581,7 +678,9 @@  discard block
 block discarded – undo
581 678
 	}
582 679
 	public function countAllMilitaryMonths($filter_name = '') {
583 680
 		global $globalStatsFilters;
584
-		if ($filter_name == '') $filter_name = $this->filter_name;
681
+		if ($filter_name == '') {
682
+			$filter_name = $this->filter_name;
683
+		}
585 684
 	    	$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";
586 685
                  try {
587 686
                         $sth = $this->db->prepare($query);
@@ -602,9 +701,14 @@  discard block
 block discarded – undo
602 701
 	}
603 702
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
604 703
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
605
-		if ($filter_name == '') $filter_name = $this->filter_name;
606
-		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";
607
-		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";
704
+		if ($filter_name == '') {
705
+			$filter_name = $this->filter_name;
706
+		}
707
+		if ($limit) {
708
+			$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";
709
+		} else {
710
+			$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";
711
+		}
608 712
 		if ($orderby == 'hour') {
609 713
 			/*
610 714
 			if ($globalDBdriver == 'mysql') {
@@ -613,7 +717,9 @@  discard block
 block discarded – undo
613 717
 			*/
614 718
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
615 719
 		}
616
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
720
+		if ($orderby == 'count') {
721
+			$query .= " ORDER BY hour_count DESC";
722
+		}
617 723
                  try {
618 724
                         $sth = $this->db->prepare($query);
619 725
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -634,7 +740,9 @@  discard block
 block discarded – undo
634 740
 	
635 741
 	public function countOverallFlights($stats_airline = '', $filter_name = '') {
636 742
 		global $globalStatsFilters;
637
-		if ($filter_name == '') $filter_name = $this->filter_name;
743
+		if ($filter_name == '') {
744
+			$filter_name = $this->filter_name;
745
+		}
638 746
 		$all = $this->getSumStats('flights_bymonth',date('Y'),$stats_airline,$filter_name);
639 747
 		if (empty($all)) {
640 748
 			$filters = array('airlines' => array($stats_airline));
@@ -648,7 +756,9 @@  discard block
 block discarded – undo
648 756
 	}
649 757
 	public function countOverallMilitaryFlights($filter_name = '') {
650 758
 		global $globalStatsFilters;
651
-		if ($filter_name == '') $filter_name = $this->filter_name;
759
+		if ($filter_name == '') {
760
+			$filter_name = $this->filter_name;
761
+		}
652 762
 		$all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name);
653 763
 		if (empty($all)) {
654 764
 		        $filters = array();
@@ -662,7 +772,9 @@  discard block
 block discarded – undo
662 772
 	}
663 773
 	public function countOverallArrival($stats_airline = '',$filter_name = '') {
664 774
 		global $globalStatsFilters;
665
-		if ($filter_name == '') $filter_name = $this->filter_name;
775
+		if ($filter_name == '') {
776
+			$filter_name = $this->filter_name;
777
+		}
666 778
 		$all = $this->getSumStats('realarrivals_bymonth',date('Y'),$stats_airline,$filter_name);
667 779
 		if (empty($all)) {
668 780
 			$filters = array('airlines' => array($stats_airline));
@@ -676,7 +788,9 @@  discard block
 block discarded – undo
676 788
 	}
677 789
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '') {
678 790
 		global $globalStatsFilters;
679
-		if ($filter_name == '') $filter_name = $this->filter_name;
791
+		if ($filter_name == '') {
792
+			$filter_name = $this->filter_name;
793
+		}
680 794
 		$all = $this->getSumStats('aircrafts_bymonth',date('Y'),$stats_airline,$filter_name);
681 795
 		if (empty($all)) {
682 796
 			$filters = array('airlines' => array($stats_airline));
@@ -690,7 +804,9 @@  discard block
 block discarded – undo
690 804
 	}
691 805
 	public function countOverallAirlines($filter_name = '') {
692 806
 		global $globalStatsFilters;
693
-		if ($filter_name == '') $filter_name = $this->filter_name;
807
+		if ($filter_name == '') {
808
+			$filter_name = $this->filter_name;
809
+		}
694 810
 		$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
695 811
                  try {
696 812
                         $sth = $this->db->prepare($query);
@@ -713,7 +829,9 @@  discard block
 block discarded – undo
713 829
 	}
714 830
 	public function countOverallOwners($stats_airline = '',$filter_name = '') {
715 831
 		global $globalStatsFilters;
716
-		if ($filter_name == '') $filter_name = $this->filter_name;
832
+		if ($filter_name == '') {
833
+			$filter_name = $this->filter_name;
834
+		}
717 835
 		/*
718 836
 		$query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";
719 837
                  try {
@@ -738,7 +856,9 @@  discard block
 block discarded – undo
738 856
 	}
739 857
 	public function countOverallPilots($stats_airline = '',$filter_name = '') {
740 858
 		global $globalStatsFilters;
741
-		if ($filter_name == '') $filter_name = $this->filter_name;
859
+		if ($filter_name == '') {
860
+			$filter_name = $this->filter_name;
861
+		}
742 862
 		$all = $this->getSumStats('pilots_bymonth',date('Y'),$stats_airline,$filter_name);
743 863
 		if (empty($all)) {
744 864
 			$filters = array('airlines' => array($stats_airline));
@@ -752,7 +872,9 @@  discard block
 block discarded – undo
752 872
 	}
753 873
 
754 874
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
755
-		if ($filter_name == '') $filter_name = $this->filter_name;
875
+		if ($filter_name == '') {
876
+			$filter_name = $this->filter_name;
877
+		}
756 878
 		$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";
757 879
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
758 880
                  try {
@@ -765,7 +887,9 @@  discard block
 block discarded – undo
765 887
                 return $all;
766 888
 	}
767 889
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
768
-		if ($filter_name == '') $filter_name = $this->filter_name;
890
+		if ($filter_name == '') {
891
+			$filter_name = $this->filter_name;
892
+		}
769 893
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
770 894
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
771 895
                  try {
@@ -778,7 +902,9 @@  discard block
 block discarded – undo
778 902
                 return $all;
779 903
         }
780 904
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') {
781
-		if ($filter_name == '') $filter_name = $this->filter_name;
905
+		if ($filter_name == '') {
906
+			$filter_name = $this->filter_name;
907
+		}
782 908
     		global $globalArchiveMonths, $globalDBdriver;
783 909
     		if ($globalDBdriver == 'mysql') {
784 910
 	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -797,7 +923,9 @@  discard block
 block discarded – undo
797 923
         }
798 924
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
799 925
     		global $globalArchiveMonths, $globalDBdriver;
800
-		if ($filter_name == '') $filter_name = $this->filter_name;
926
+		if ($filter_name == '') {
927
+			$filter_name = $this->filter_name;
928
+		}
801 929
     		if ($globalDBdriver == 'mysql') {
802 930
 			$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";
803 931
 		} else {
@@ -815,7 +943,9 @@  discard block
 block discarded – undo
815 943
         }
816 944
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
817 945
     		global $globalArchiveMonths, $globalDBdriver;
818
-		if ($filter_name == '') $filter_name = $this->filter_name;
946
+		if ($filter_name == '') {
947
+			$filter_name = $this->filter_name;
948
+		}
819 949
     		if ($globalDBdriver == 'mysql') {
820 950
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
821 951
                 } else {
@@ -832,7 +962,9 @@  discard block
 block discarded – undo
832 962
         }
833 963
 	public function getStatsAirlineTotal($filter_name = '') {
834 964
     		global $globalArchiveMonths, $globalDBdriver;
835
-		if ($filter_name == '') $filter_name = $this->filter_name;
965
+		if ($filter_name == '') {
966
+			$filter_name = $this->filter_name;
967
+		}
836 968
     		if ($globalDBdriver == 'mysql') {
837 969
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
838 970
                 } else {
@@ -849,7 +981,9 @@  discard block
 block discarded – undo
849 981
         }
850 982
 	public function getStatsOwnerTotal($filter_name = '') {
851 983
     		global $globalArchiveMonths, $globalDBdriver;
852
-		if ($filter_name == '') $filter_name = $this->filter_name;
984
+		if ($filter_name == '') {
985
+			$filter_name = $this->filter_name;
986
+		}
853 987
     		if ($globalDBdriver == 'mysql') {
854 988
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
855 989
 		} else {
@@ -866,7 +1000,9 @@  discard block
 block discarded – undo
866 1000
         }
867 1001
 	public function getStatsPilotTotal($filter_name = '') {
868 1002
     		global $globalArchiveMonths, $globalDBdriver;
869
-		if ($filter_name == '') $filter_name = $this->filter_name;
1003
+		if ($filter_name == '') {
1004
+			$filter_name = $this->filter_name;
1005
+		}
870 1006
     		if ($globalDBdriver == 'mysql') {
871 1007
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
872 1008
             	} else {
@@ -884,7 +1020,9 @@  discard block
 block discarded – undo
884 1020
 
885 1021
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
886 1022
 		global $globalDBdriver;
887
-		if ($filter_name == '') $filter_name = $this->filter_name;
1023
+		if ($filter_name == '') {
1024
+			$filter_name = $this->filter_name;
1025
+		}
888 1026
 		if ($globalDBdriver == 'mysql') {
889 1027
 			$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";
890 1028
                 } else {
@@ -900,7 +1038,9 @@  discard block
 block discarded – undo
900 1038
         }
901 1039
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
902 1040
 		global $globalDBdriver;
903
-		if ($filter_name == '') $filter_name = $this->filter_name;
1041
+		if ($filter_name == '') {
1042
+			$filter_name = $this->filter_name;
1043
+		}
904 1044
 		if ($globalDBdriver == 'mysql') {
905 1045
 			$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";
906 1046
 		} else {
@@ -1383,47 +1523,69 @@  discard block
 block discarded – undo
1383 1523
 			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1384 1524
 		} else {
1385 1525
 		*/
1386
-			if ($globalDebug) echo 'Update stats !'."\n";
1387
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1526
+			if ($globalDebug) {
1527
+				echo 'Update stats !'."\n";
1528
+			}
1529
+			if ($globalDebug) {
1530
+				echo 'Count all aircraft types...'."\n";
1531
+			}
1388 1532
 			if (isset($last_update[0]['value'])) {
1389 1533
 				$last_update_day = $last_update[0]['value'];
1390
-			} else $last_update_day = '2012-12-12 12:12:12';
1534
+			} else {
1535
+				$last_update_day = '2012-12-12 12:12:12';
1536
+			}
1391 1537
 			$Spotter = new Spotter($this->db);
1392 1538
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1393 1539
 			foreach ($alldata as $number) {
1394 1540
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer']);
1395 1541
 			}
1396
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1542
+			if ($globalDebug) {
1543
+				echo 'Count all airlines...'."\n";
1544
+			}
1397 1545
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1398 1546
 			foreach ($alldata as $number) {
1399 1547
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1400 1548
 			}
1401
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1549
+			if ($globalDebug) {
1550
+				echo 'Count all registrations...'."\n";
1551
+			}
1402 1552
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1403 1553
 			foreach ($alldata as $number) {
1404 1554
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1405 1555
 			}
1406
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1556
+			if ($globalDebug) {
1557
+				echo 'Count all callsigns...'."\n";
1558
+			}
1407 1559
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1408 1560
 			foreach ($alldata as $number) {
1409 1561
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1410 1562
 			}
1411
-			if ($globalDebug) echo 'Count all owners...'."\n";
1563
+			if ($globalDebug) {
1564
+				echo 'Count all owners...'."\n";
1565
+			}
1412 1566
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1413 1567
 			foreach ($alldata as $number) {
1414 1568
 				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1415 1569
 			}
1416
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1570
+			if ($globalDebug) {
1571
+				echo 'Count all pilots...'."\n";
1572
+			}
1417 1573
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1418 1574
 			foreach ($alldata as $number) {
1419 1575
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source']);
1420 1576
 			}
1421 1577
 			
1422
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1578
+			if ($globalDebug) {
1579
+				echo 'Count all departure airports...'."\n";
1580
+			}
1423 1581
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1424
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1582
+			if ($globalDebug) {
1583
+				echo 'Count all detected departure airports...'."\n";
1584
+			}
1425 1585
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1426
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1586
+			if ($globalDebug) {
1587
+				echo 'Order departure airports...'."\n";
1588
+			}
1427 1589
 	        	$alldata = array();
1428 1590
 	        	
1429 1591
     			foreach ($pall as $value) {
@@ -1434,7 +1596,9 @@  discard block
 block discarded – undo
1434 1596
     				$icao = $value['airport_departure_icao'];
1435 1597
         			if (isset($alldata[$icao])) {
1436 1598
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1437
-        			} else $alldata[$icao] = $value;
1599
+        			} else {
1600
+        				$alldata[$icao] = $value;
1601
+        			}
1438 1602
 			}
1439 1603
     			$count = array();
1440 1604
     			foreach ($alldata as $key => $row) {
@@ -1444,11 +1608,17 @@  discard block
 block discarded – undo
1444 1608
 			foreach ($alldata as $number) {
1445 1609
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1446 1610
 			}
1447
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1611
+			if ($globalDebug) {
1612
+				echo 'Count all arrival airports...'."\n";
1613
+			}
1448 1614
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1449
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1615
+			if ($globalDebug) {
1616
+				echo 'Count all detected arrival airports...'."\n";
1617
+			}
1450 1618
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1451
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1619
+			if ($globalDebug) {
1620
+				echo 'Order arrival airports...'."\n";
1621
+			}
1452 1622
 	        	$alldata = array();
1453 1623
     			foreach ($pall as $value) {
1454 1624
 	        		$icao = $value['airport_arrival_icao'];
@@ -1458,7 +1628,9 @@  discard block
 block discarded – undo
1458 1628
     				$icao = $value['airport_arrival_icao'];
1459 1629
         			if (isset($alldata[$icao])) {
1460 1630
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1461
-	        		} else $alldata[$icao] = $value;
1631
+	        		} else {
1632
+	        			$alldata[$icao] = $value;
1633
+	        		}
1462 1634
     			}
1463 1635
         		$count = array();
1464 1636
         		foreach ($alldata as $key => $row) {
@@ -1469,7 +1641,9 @@  discard block
 block discarded – undo
1469 1641
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1470 1642
 			}
1471 1643
 			if ($Connection->tableExists('countries')) {
1472
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1644
+				if ($globalDebug) {
1645
+					echo 'Count all flights by countries...'."\n";
1646
+				}
1473 1647
 				$SpotterArchive = new SpotterArchive();
1474 1648
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1475 1649
 				foreach ($alldata as $number) {
@@ -1481,46 +1655,66 @@  discard block
 block discarded – undo
1481 1655
 			// Add by month using getstat if month finish...
1482 1656
 
1483 1657
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1484
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1658
+			if ($globalDebug) {
1659
+				echo 'Count all flights by months...'."\n";
1660
+			}
1485 1661
 			$Spotter = new Spotter($this->db);
1486 1662
 			$alldata = $Spotter->countAllMonths();
1487 1663
 			$lastyear = false;
1488 1664
 			foreach ($alldata as $number) {
1489
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1665
+				if ($number['year_name'] != date('Y')) {
1666
+					$lastyear = true;
1667
+				}
1490 1668
 				$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'])));
1491 1669
 			}
1492
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1670
+			if ($globalDebug) {
1671
+				echo 'Count all military flights by months...'."\n";
1672
+			}
1493 1673
 			$alldata = $Spotter->countAllMilitaryMonths();
1494 1674
 			foreach ($alldata as $number) {
1495 1675
 				$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'])));
1496 1676
 			}
1497
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1677
+			if ($globalDebug) {
1678
+				echo 'Count all owners by months...'."\n";
1679
+			}
1498 1680
 			$alldata = $Spotter->countAllMonthsOwners();
1499 1681
 			foreach ($alldata as $number) {
1500 1682
 				$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'])));
1501 1683
 			}
1502
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1684
+			if ($globalDebug) {
1685
+				echo 'Count all pilots by months...'."\n";
1686
+			}
1503 1687
 			$alldata = $Spotter->countAllMonthsPilots();
1504 1688
 			foreach ($alldata as $number) {
1505 1689
 				$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'])));
1506 1690
 			}
1507
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1691
+			if ($globalDebug) {
1692
+				echo 'Count all airlines by months...'."\n";
1693
+			}
1508 1694
 			$alldata = $Spotter->countAllMonthsAirlines();
1509 1695
 			foreach ($alldata as $number) {
1510 1696
 				$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'])));
1511 1697
 			}
1512
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1698
+			if ($globalDebug) {
1699
+				echo 'Count all aircrafts by months...'."\n";
1700
+			}
1513 1701
 			$alldata = $Spotter->countAllMonthsAircrafts();
1514 1702
 			foreach ($alldata as $number) {
1515 1703
 				$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'])));
1516 1704
 			}
1517
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1705
+			if ($globalDebug) {
1706
+				echo 'Count all real arrivals by months...'."\n";
1707
+			}
1518 1708
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1519 1709
 			foreach ($alldata as $number) {
1520 1710
 				$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'])));
1521 1711
 			}
1522
-			if ($globalDebug) echo 'Airports data...'."\n";
1523
-			if ($globalDebug) echo '...Departure'."\n";
1712
+			if ($globalDebug) {
1713
+				echo 'Airports data...'."\n";
1714
+			}
1715
+			if ($globalDebug) {
1716
+				echo '...Departure'."\n";
1717
+			}
1524 1718
 			$this->deleteStatAirport('daily');
1525 1719
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1526 1720
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1640,37 +1834,53 @@  discard block
 block discarded – undo
1640 1834
 
1641 1835
 			// Count by airlines
1642 1836
 			echo '--- Stats by airlines ---'."\n";
1643
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1837
+			if ($globalDebug) {
1838
+				echo 'Count all aircraft types by airlines...'."\n";
1839
+			}
1644 1840
 			$Spotter = new Spotter($this->db);
1645 1841
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1646 1842
 			foreach ($alldata as $number) {
1647 1843
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao']);
1648 1844
 			}
1649
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1845
+			if ($globalDebug) {
1846
+				echo 'Count all aircraft registrations by airlines...'."\n";
1847
+			}
1650 1848
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1651 1849
 			foreach ($alldata as $number) {
1652 1850
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao']);
1653 1851
 			}
1654
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1852
+			if ($globalDebug) {
1853
+				echo 'Count all callsigns by airlines...'."\n";
1854
+			}
1655 1855
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1656 1856
 			foreach ($alldata as $number) {
1657 1857
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1658 1858
 			}
1659
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1859
+			if ($globalDebug) {
1860
+				echo 'Count all owners by airlines...'."\n";
1861
+			}
1660 1862
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1661 1863
 			foreach ($alldata as $number) {
1662 1864
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao']);
1663 1865
 			}
1664
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1866
+			if ($globalDebug) {
1867
+				echo 'Count all pilots by airlines...'."\n";
1868
+			}
1665 1869
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1666 1870
 			foreach ($alldata as $number) {
1667 1871
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source']);
1668 1872
 			}
1669
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1873
+			if ($globalDebug) {
1874
+				echo 'Count all departure airports by airlines...'."\n";
1875
+			}
1670 1876
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1671
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1877
+			if ($globalDebug) {
1878
+				echo 'Count all detected departure airports by airlines...'."\n";
1879
+			}
1672 1880
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1673
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1881
+			if ($globalDebug) {
1882
+				echo 'Order detected departure airports by airlines...'."\n";
1883
+			}
1674 1884
 	        	//$alldata = array();
1675 1885
     			foreach ($dall as $value) {
1676 1886
     				$icao = $value['airport_departure_icao'];
@@ -1691,11 +1901,17 @@  discard block
 block discarded – undo
1691 1901
 			foreach ($alldata as $number) {
1692 1902
 				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']);
1693 1903
 			}
1694
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1904
+			if ($globalDebug) {
1905
+				echo 'Count all arrival airports by airlines...'."\n";
1906
+			}
1695 1907
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1696
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1908
+			if ($globalDebug) {
1909
+				echo 'Count all detected arrival airports by airlines...'."\n";
1910
+			}
1697 1911
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1698
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1912
+			if ($globalDebug) {
1913
+				echo 'Order arrival airports by airlines...'."\n";
1914
+			}
1699 1915
 	        	//$alldata = array();
1700 1916
     			foreach ($dall as $value) {
1701 1917
     				$icao = $value['airport_arrival_icao'];
@@ -1716,35 +1932,49 @@  discard block
 block discarded – undo
1716 1932
                         foreach ($alldata as $number) {
1717 1933
 				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']);
1718 1934
 			}
1719
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1935
+			if ($globalDebug) {
1936
+				echo 'Count all flights by months by airlines...'."\n";
1937
+			}
1720 1938
 			$Spotter = new Spotter($this->db);
1721 1939
 			$alldata = $Spotter->countAllMonthsByAirlines();
1722 1940
 			$lastyear = false;
1723 1941
 			foreach ($alldata as $number) {
1724
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1942
+				if ($number['year_name'] != date('Y')) {
1943
+					$lastyear = true;
1944
+				}
1725 1945
 				$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']);
1726 1946
 			}
1727
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1947
+			if ($globalDebug) {
1948
+				echo 'Count all owners by months by airlines...'."\n";
1949
+			}
1728 1950
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1729 1951
 			foreach ($alldata as $number) {
1730 1952
 				$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']);
1731 1953
 			}
1732
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1954
+			if ($globalDebug) {
1955
+				echo 'Count all pilots by months by airlines...'."\n";
1956
+			}
1733 1957
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1734 1958
 			foreach ($alldata as $number) {
1735 1959
 				$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']);
1736 1960
 			}
1737
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1961
+			if ($globalDebug) {
1962
+				echo 'Count all aircrafts by months by airlines...'."\n";
1963
+			}
1738 1964
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1739 1965
 			foreach ($alldata as $number) {
1740 1966
 				$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']);
1741 1967
 			}
1742
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1968
+			if ($globalDebug) {
1969
+				echo 'Count all real arrivals by months by airlines...'."\n";
1970
+			}
1743 1971
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1744 1972
 			foreach ($alldata as $number) {
1745 1973
 				$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']);
1746 1974
 			}
1747
-			if ($globalDebug) echo '...Departure'."\n";
1975
+			if ($globalDebug) {
1976
+				echo '...Departure'."\n";
1977
+			}
1748 1978
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1749 1979
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1750 1980
     			foreach ($dall as $value) {
@@ -1767,7 +1997,9 @@  discard block
 block discarded – undo
1767 1997
 			foreach ($alldata as $number) {
1768 1998
 				$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']);
1769 1999
 			}
1770
-			if ($globalDebug) echo '...Arrival'."\n";
2000
+			if ($globalDebug) {
2001
+				echo '...Arrival'."\n";
2002
+			}
1771 2003
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1772 2004
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1773 2005
     			foreach ($dall as $value) {
@@ -1791,13 +2023,19 @@  discard block
 block discarded – undo
1791 2023
 				$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']);
1792 2024
 			}
1793 2025
 
1794
-			if ($globalDebug) echo 'Flights data...'."\n";
1795
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2026
+			if ($globalDebug) {
2027
+				echo 'Flights data...'."\n";
2028
+			}
2029
+			if ($globalDebug) {
2030
+				echo '-> countAllDatesLastMonth...'."\n";
2031
+			}
1796 2032
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1797 2033
 			foreach ($alldata as $number) {
1798 2034
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1799 2035
 			}
1800
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2036
+			if ($globalDebug) {
2037
+				echo '-> countAllDates...'."\n";
2038
+			}
1801 2039
 			//$previousdata = $this->countAllDatesByAirlines();
1802 2040
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1803 2041
 			$values = array();
@@ -1810,14 +2048,18 @@  discard block
 block discarded – undo
1810 2048
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1811 2049
 			}
1812 2050
 			
1813
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2051
+			if ($globalDebug) {
2052
+				echo '-> countAllHours...'."\n";
2053
+			}
1814 2054
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1815 2055
 			foreach ($alldata as $number) {
1816 2056
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1817 2057
 			}
1818 2058
 			
1819 2059
 
1820
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2060
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2061
+				$globalStatsFilters = array();
2062
+			}
1821 2063
 			foreach ($globalStatsFilters as $name => $filter) {
1822 2064
 				//$filter_name = $filter['name'];
1823 2065
 				$filter_name = $name;
@@ -1825,10 +2067,14 @@  discard block
 block discarded – undo
1825 2067
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1826 2068
 				if (isset($last_update[0]['value'])) {
1827 2069
 					$last_update_day = $last_update[0]['value'];
1828
-				} else $last_update_day = '2012-12-12 12:12:12';
2070
+				} else {
2071
+					$last_update_day = '2012-12-12 12:12:12';
2072
+				}
1829 2073
 
1830 2074
 				// Count by filter
1831
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2075
+				if ($globalDebug) {
2076
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2077
+				}
1832 2078
 				$Spotter = new Spotter($this->db);
1833 2079
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1834 2080
 				foreach ($alldata as $number) {
@@ -1866,7 +2112,9 @@  discard block
 block discarded – undo
1866 2112
 	    				$icao = $value['airport_departure_icao'];
1867 2113
         				if (isset($alldata[$icao])) {
1868 2114
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1869
-        				} else $alldata[$icao] = $value;
2115
+        				} else {
2116
+        					$alldata[$icao] = $value;
2117
+        				}
1870 2118
 				}
1871 2119
 	    			$count = array();
1872 2120
     				foreach ($alldata as $key => $row) {
@@ -1887,7 +2135,9 @@  discard block
 block discarded – undo
1887 2135
 	    				$icao = $value['airport_arrival_icao'];
1888 2136
         				if (isset($alldata[$icao])) {
1889 2137
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1890
-		        		} else $alldata[$icao] = $value;
2138
+		        		} else {
2139
+		        			$alldata[$icao] = $value;
2140
+		        		}
1891 2141
 	    			}
1892 2142
         			$count = array();
1893 2143
         			foreach ($alldata as $key => $row) {
@@ -1901,7 +2151,9 @@  discard block
 block discarded – undo
1901 2151
 				$alldata = $Spotter->countAllMonths($filter);
1902 2152
 				$lastyear = false;
1903 2153
 				foreach ($alldata as $number) {
1904
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2154
+					if ($number['year_name'] != date('Y')) {
2155
+						$lastyear = true;
2156
+					}
1905 2157
 					$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);
1906 2158
 				}
1907 2159
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.
statistics.php 1 patch
Braces   +44 added lines, -24 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 $Stats = new Stats();
7 7
 $title = _("Statistics");
8 8
 
9
-if (!isset($filter_name)) $filter_name = '';
9
+if (!isset($filter_name)) {
10
+	$filter_name = '';
11
+}
10 12
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11 13
 if ($airline_icao == 'all') {
12 14
 	unset($_COOKIE['stats_airline_icao']);
@@ -15,8 +17,10 @@  discard block
 block discarded – undo
15 17
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
16 18
 	$airline_icao = $_COOKIE['stats_airline_icao'];
17 19
 } elseif ($airline_icao == '' && isset($globalFilter)) {
18
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
19
-}
20
+	if (isset($globalFilter['airline'])) {
21
+		$airline_icao = $globalFilter['airline'][0];
22
+	}
23
+	}
20 24
 setcookie('stats_airline_icao',$airline_icao);
21 25
 require_once('header.php');
22 26
 
@@ -36,7 +40,9 @@  discard block
 block discarded – undo
36 40
 	if (isset($last_update[0]['value'])) {
37 41
 		date_default_timezone_set('UTC');
38 42
 		$lastupdate = strtotime($last_update[0]['value']);
39
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
43
+		if (isset($globalTimezone) && $globalTimezone != '') {
44
+			date_default_timezone_set($globalTimezone);
45
+		}
40 46
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
41 47
 	}
42 48
     ?>
@@ -89,8 +95,9 @@  discard block
 block discarded – undo
89 95
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
90 96
                  <?php
91 97
                   $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name);
92
-		    if (count($aircraft_array) == 0) print _("No data available");
93
-		    else {
98
+		    if (count($aircraft_array) == 0) {
99
+		    	print _("No data available");
100
+		    } else {
94 101
 
95 102
                     print '<div id="chart1" class="chart" width="100%"></div>
96 103
                     <script> 
@@ -186,8 +193,9 @@  discard block
 block discarded – undo
186 193
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
187 194
 <?php
188 195
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name);
189
-	if (count($pilot_array) == 0) print _("No data available");
190
-	else {
196
+	if (count($pilot_array) == 0) {
197
+		print _("No data available");
198
+	} else {
191 199
 	    print '<div id="chart7" class="chart" width="100%"></div>
192 200
                     <script> 
193 201
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -232,8 +240,9 @@  discard block
 block discarded – undo
232 240
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
233 241
 <?php
234 242
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name);
235
-	if (count($owner_array) == 0) print _("No data available");
236
-	else {
243
+	if (count($owner_array) == 0) {
244
+		print _("No data available");
245
+	} else {
237 246
 	    print '<div id="chart7" class="chart" width="100%"></div>
238 247
                     <script> 
239 248
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -279,8 +288,9 @@  discard block
 block discarded – undo
279 288
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
280 289
 <?php
281 290
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
282
-	if (count($flightover_array) == 0) print _("No data available");
283
-	else {
291
+	if (count($flightover_array) == 0) {
292
+		print _("No data available");
293
+	} else {
284 294
 	    print '<div id="chart10" class="chart" width="100%"></div>
285 295
                     <script> 
286 296
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -424,8 +434,9 @@  discard block
 block discarded – undo
424 434
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
425 435
                 <?php
426 436
                   $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
427
-		    if (count($year_array) == 0) print _("No data available");
428
-		    else {
437
+		    if (count($year_array) == 0) {
438
+		    	print _("No data available");
439
+		    } else {
429 440
                   print '<div id="chart8" class="chart" width="100%"></div>
430 441
                     <script> 
431 442
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -470,8 +481,9 @@  discard block
 block discarded – undo
470 481
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
471 482
                 <?php
472 483
                   $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
473
-		    if (count($month_array) == 0) print _("No data available");
474
-		    else {
484
+		    if (count($month_array) == 0) {
485
+		    	print _("No data available");
486
+		    } else {
475 487
                   print '<div id="chart9" class="chart" width="100%"></div>
476 488
                     <script> 
477 489
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -516,8 +528,9 @@  discard block
 block discarded – undo
516 528
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
517 529
                 <?php
518 530
                     $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
519
-		    if (empty($date_array)) print _("No data available");
520
-		    else {
531
+		    if (empty($date_array)) {
532
+		    	print _("No data available");
533
+		    } else {
521 534
                   print '<div id="chart5" class="chart" width="100%"></div>
522 535
                     <script> 
523 536
                         google.load("visualization", "1", {packages:["corechart"]});
@@ -563,8 +576,9 @@  discard block
 block discarded – undo
563 576
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
564 577
                 <?php
565 578
                   $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
566
-		    if (empty($hour_array)) print _("No data available");
567
-		    else {
579
+		    if (empty($hour_array)) {
580
+		    	print _("No data available");
581
+		    } else {
568 582
 
569 583
                   print '<div id="chart6" class="chart" width="100%"></div>
570 584
                     <script> 
@@ -632,8 +646,11 @@  discard block
 block discarded – undo
632 646
 					$distance = $distance;
633 647
 					$unit = 'km';
634 648
 				}
635
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
636
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
649
+        			if (!isset($polar_data)) {
650
+        				$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
651
+        			} else {
652
+        	    			$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
653
+        	    		}
637 654
         		    }
638 655
         	?>
639 656
             <div class="col-md-6">
@@ -680,8 +697,11 @@  discard block
 block discarded – undo
680 697
         		foreach ($msg as $eachmsg) {
681 698
         		    //$eachmsg = $msg[0];
682 699
         		    $data = $eachmsg['source_data'];
683
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
684
-        		    else $max = 500;
700
+        		    if ($data > 500) {
701
+        		    	$max = (round(($data+100)/100))*100;
702
+        		    } else {
703
+        		    	$max = 500;
704
+        		    }
685 705
         	?>
686 706
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
687 707
         	<script>
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +139 added lines, -54 removed lines patch added patch discarded remove patch
@@ -18,26 +18,49 @@  discard block
 block discarded – undo
18 18
 }
19 19
 header('Content-Type: text/javascript');
20 20
 
21
-if (!isset($globalJsonCompress)) $compress = true;
22
-else $compress = $globalJsonCompress;
21
+if (!isset($globalJsonCompress)) {
22
+	$compress = true;
23
+} else {
24
+	$compress = $globalJsonCompress;
25
+}
23 26
 
24 27
 $from_archive = false;
25 28
 $min = true;
26 29
 $allhistory = false;
27 30
 $filter['source'] = array();
28
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
29
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
30
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
31
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
32
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
33
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
34
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
35
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
36
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
31
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
32
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
33
+}
34
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
35
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
36
+}
37
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
38
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
39
+}
40
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
41
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
42
+}
43
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
44
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
45
+}
46
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
47
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
48
+}
49
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
50
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
51
+}
52
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
53
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
54
+}
55
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
56
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
57
+}
37 58
 
38 59
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
39 60
 	$min = true;
40
-} else $min = false;
61
+} else {
62
+	$min = false;
63
+}
41 64
 
42 65
 if (isset($_GET['ident'])) {
43 66
 	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
@@ -87,20 +110,30 @@  discard block
 block discarded – undo
87 110
 	}
88 111
 */
89 112
 	$flightcnt = count($spotter_array);
90
-	if ($flightcnt == '') $flightcnt = 0;
91
-} else $flightcnt = 0;
113
+	if ($flightcnt == '') {
114
+		$flightcnt = 0;
115
+	}
116
+	} else {
117
+	$flightcnt = 0;
118
+}
92 119
 
93 120
 $sqltime = round(microtime(true)-$begintime,2);
94 121
 
95
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
96
-else $usenextlatlon = true;
122
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
123
+	$usenextlatlon = false;
124
+} else {
125
+	$usenextlatlon = true;
126
+}
97 127
 $j = 0;
98 128
 $prev_flightaware_id = '';
99 129
 $aircrafts_shadow = array();
100 130
 $output = '{';
101 131
 	$output .= '"type": "FeatureCollection",';
102
-		if ($min) $output .= '"minimal": "true",';
103
-		else $output .= '"minimal": "false",';
132
+		if ($min) {
133
+			$output .= '"minimal": "true",';
134
+		} else {
135
+			$output .= '"minimal": "false",';
136
+		}
104 137
 		$output .= '"fc": "'.$flightcnt.'",';
105 138
 		$output .= '"sqt": "'.$sqltime.'",';
106 139
 
@@ -137,11 +170,16 @@  discard block
 block discarded – undo
137 170
 						//$output .= '"sqt": "'.$sqltime.'",';
138 171
 						$output .= '"id": "'.$spotter_item['flightaware_id'].'",';
139 172
 						$output .= '"properties": {';
140
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
141
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
173
+							if ($compress) {
174
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
175
+							} else {
176
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
177
+							}
142 178
 							$output .= '"fc": "'.$flightcnt.'",';
143 179
 							$output .= '"sqt": "'.$sqltime.'",';
144
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
180
+							if (isset($begindate)) {
181
+								$output .= '"archive_date": "'.$begindate.'",';
182
+							}
145 183
 
146 184
 /*
147 185
 							if ($min) $output .= '"minimal": "true",';
@@ -149,13 +187,21 @@  discard block
 block discarded – undo
149 187
 */
150 188
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
151 189
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
152
-							if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",';
153
-							else $output .= '"callsign": "'.$spotter_item['ident'].'",';
190
+							if ($compress) {
191
+								$output .= '"c": "'.$spotter_item['ident'].'",';
192
+							} else {
193
+								$output .= '"callsign": "'.$spotter_item['ident'].'",';
194
+							}
154 195
 						} else {
155
-							if ($compress) $output .= '"c": "NA",';
156
-							else $output .= '"callsign": "NA",';
196
+							if ($compress) {
197
+								$output .= '"c": "NA",';
198
+							} else {
199
+								$output .= '"callsign": "NA",';
200
+							}
201
+						}
202
+						if (isset($spotter_item['registration'])) {
203
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
157 204
 						}
158
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
159 205
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
160 206
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
161 207
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -168,25 +214,37 @@  discard block
 block discarded – undo
168 214
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
169 215
 						}
170 216
 						if (!isset($spotter_item['aircraft_shadow'])) {
171
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
172
-							else {
217
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
218
+								$spotter_item['aircraft_shadow'] = '';
219
+							} else {
173 220
 								$aircraft_icao = $spotter_item['aircraft_icao'];
174
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
175
-								else {
221
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
222
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
223
+								} else {
176 224
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
177
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
178
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
179
-									else $spotter_item['aircraft_shadow'] = '';
225
+									if (count($aircraft_info) > 0) {
226
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
227
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
228
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
229
+									} else {
230
+										$spotter_item['aircraft_shadow'] = '';
231
+									}
180 232
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
181 233
 								}
182 234
 							}
183 235
 						}
184 236
 						if ($spotter_item['aircraft_shadow'] == '') {
185
-							if ($compress) $output .= '"as": "default.png",';
186
-							else $output .= '"aircraft_shadow": "default.png",';
237
+							if ($compress) {
238
+								$output .= '"as": "default.png",';
239
+							} else {
240
+								$output .= '"aircraft_shadow": "default.png",';
241
+							}
187 242
 						} else {
188
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
189
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
243
+							if ($compress) {
244
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
245
+							} else {
246
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
247
+							}
190 248
 						}
191 249
 						if (isset($spotter_item['airline_name'])) {
192 250
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -194,8 +252,11 @@  discard block
 block discarded – undo
194 252
 							$output .= '"airline_name": "NA",';
195 253
 						}
196 254
 						if (isset($spotter_item['departure_airport'])) {
197
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
198
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
255
+							if ($compress) {
256
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
257
+							} else {
258
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
259
+							}
199 260
 						}
200 261
 						if (isset($spotter_item['departure_airport_city'])) {
201 262
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -207,8 +268,11 @@  discard block
 block discarded – undo
207 268
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
208 269
 						}
209 270
 						if (isset($spotter_item['arrival_airport'])) {
210
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
211
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
271
+							if ($compress) {
272
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
273
+							} else {
274
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
275
+							}
212 276
 						}
213 277
 						if (isset($spotter_item['arrival_airport_city'])) {
214 278
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -226,10 +290,16 @@  discard block
 block discarded – undo
226 290
 							$output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",';
227 291
 						}
228 292
 						
229
-						if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
230
-						else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
231
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
232
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
293
+						if ($compress) {
294
+							$output .= '"a": "'.$spotter_item['altitude'].'",';
295
+						} else {
296
+							$output .= '"altitude": "'.$spotter_item['altitude'].'",';
297
+						}
298
+						if ($compress) {
299
+							$output .= '"h": "'.$spotter_item['heading'].'",';
300
+						} else {
301
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
302
+						}
233 303
 						
234 304
 						if (isset($archivespeed)) {
235 305
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -239,7 +309,9 @@  discard block
 block discarded – undo
239 309
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
240 310
 						}
241 311
 
242
-						if (!$min) $output .= '"image": "'.$image.'",';
312
+						if (!$min) {
313
+							$output .= '"image": "'.$image.'",';
314
+						}
243 315
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
244 316
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
245 317
 						}
@@ -247,8 +319,11 @@  discard block
 block discarded – undo
247 319
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
248 320
 						}
249 321
 						if (isset($spotter_item['squawk'])) {
250
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
251
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
322
+							if ($compress) {
323
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
324
+							} else {
325
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
326
+							}
252 327
 						}
253 328
 						if (isset($spotter_item['squawk_usage'])) {
254 329
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -266,8 +341,11 @@  discard block
 block discarded – undo
266 341
 							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
267 342
 						}
268 343
 						// type when not aircraft ?
269
-						if ($compress) $output .= '"t": "aircraft"';
270
-						else $output .= '"type": "aircraft"';
344
+						if ($compress) {
345
+							$output .= '"t": "aircraft"';
346
+						} else {
347
+							$output .= '"type": "aircraft"';
348
+						}
271 349
 						$output .= '},';
272 350
 						$output .= '"geometry": {';
273 351
 							$output .= '"type": "Point",';
@@ -334,7 +412,9 @@  discard block
 block discarded – undo
334 412
 			}
335 413
 */
336 414
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
337
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
415
+				if ($history == '' && isset($_COOKIE['history'])) {
416
+					$history = $_COOKIE['history'];
417
+				}
338 418
 				
339 419
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
340 420
 				|| (!isset($_COOKIE['flightpath']) 
@@ -356,8 +436,11 @@  discard block
 block discarded – undo
356 436
 						$output_history .= ']}},';
357 437
 						$output .= $output_history;
358 438
 					    }
359
-					    if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
360
-					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
439
+					    if ($compress) {
440
+					    	$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
441
+					    } else {
442
+					    	$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
443
+					    }
361 444
 					}
362 445
 					$output_history .= '[';
363 446
 					$output_history .=  $spotter_history['longitude'].', ';
@@ -403,7 +486,9 @@  discard block
 block discarded – undo
403 486
 			$output .= ']';
404 487
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
405 488
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
406
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
489
+			if (isset($begindate)) {
490
+				$output .= '"archive_date": "'.$begindate.'",';
491
+			}
407 492
 			$output .= '"fc": "'.$j.'"';
408 493
 		} else {
409 494
 			$output .= '"features": ';
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +318 added lines, -113 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 	$dbc = $this->db;
54 54
 	$this->all_flights[$id]['schedule_check'] = true;
55 55
 	if ($globalSchedulesFetch) {
56
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
56
+	if ($globalDebug) {
57
+		echo 'Getting schedule info...'."\n";
58
+	}
57 59
 	$Spotter = new Spotter($dbc);
58 60
 	$Schedule = new Schedule($dbc);
59 61
 	$Translation = new Translation($dbc);
@@ -63,7 +65,9 @@  discard block
 block discarded – undo
63 65
 	    if ($Schedule->checkSchedule($operator) == 0) {
64 66
 		$schedule = $Schedule->fetchSchedule($operator);
65 67
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
66
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
68
+		    if ($globalDebug) {
69
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
70
+		    }
67 71
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
68 72
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
69 73
 		    // Should also check if route schedule = route from DB
@@ -72,7 +76,9 @@  discard block
 block discarded – undo
72 76
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
73 77
 			    if ($airport_icao != '') {
74 78
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
75
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
79
+				if ($globalDebug) {
80
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
81
+				}
76 82
 			    }
77 83
 			}
78 84
 		    }
@@ -81,7 +87,9 @@  discard block
 block discarded – undo
81 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
82 88
 			    if ($airport_icao != '') {
83 89
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
84
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
92
+				}
85 93
 			    }
86 94
 			}
87 95
 		    }
@@ -109,7 +117,9 @@  discard block
 block discarded – undo
109 117
 
110 118
     public function checkAll() {
111 119
 	global $globalDebug;
112
-	if ($globalDebug) echo "Update last seen flights data...\n";
120
+	if ($globalDebug) {
121
+		echo "Update last seen flights data...\n";
122
+	}
113 123
 	foreach ($this->all_flights as $key => $flight) {
114 124
 	    if (isset($this->all_flights[$key]['id'])) {
115 125
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
@@ -122,24 +132,32 @@  discard block
 block discarded – undo
122 132
 
123 133
     public function arrival($key) {
124 134
 	global $globalClosestMinDist, $globalDebug;
125
-	if ($globalDebug) echo 'Update arrival...'."\n";
135
+	if ($globalDebug) {
136
+		echo 'Update arrival...'."\n";
137
+	}
126 138
 	$Spotter = new Spotter($this->db);
127 139
         $airport_icao = '';
128 140
         $airport_time = '';
129
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
141
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
142
+        	$globalClosestMinDist = 50;
143
+        }
130 144
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
131 145
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
132 146
     	    if (isset($closestAirports[0])) {
133 147
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
134 148
         	    $airport_icao = $closestAirports[0]['icao'];
135 149
         	    $airport_time = $this->all_flights[$key]['datetime'];
136
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
150
+        	    if ($globalDebug) {
151
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
152
+        	    }
137 153
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
138 154
         	    foreach ($closestAirports as $airport) {
139 155
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
140 156
         		    $airport_icao = $airport['icao'];
141 157
         		    $airport_time = $this->all_flights[$key]['datetime'];
142
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
158
+        		    if ($globalDebug) {
159
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
160
+        		    }
143 161
         		    break;
144 162
         		}
145 163
         	    }
@@ -147,14 +165,20 @@  discard block
 block discarded – undo
147 165
         		$airport_icao = $closestAirports[0]['icao'];
148 166
         		$airport_time = $this->all_flights[$key]['datetime'];
149 167
         	} else {
150
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
168
+        		if ($globalDebug) {
169
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
170
+        		}
151 171
         	}
152 172
     	    } else {
153
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
173
+    		    if ($globalDebug) {
174
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
175
+    		    }
154 176
     	    }
155 177
 
156 178
         } else {
157
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
179
+        	if ($globalDebug) {
180
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
181
+        	}
158 182
         }
159 183
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
160 184
     }
@@ -164,12 +188,16 @@  discard block
 block discarded – undo
164 188
     public function del() {
165 189
 	global $globalDebug;
166 190
 	// Delete old infos
167
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
191
+	if ($globalDebug) {
192
+		echo 'Delete old values and update latest data...'."\n";
193
+	}
168 194
 	foreach ($this->all_flights as $key => $flight) {
169 195
     	    if (isset($flight['lastupdate'])) {
170 196
         	if ($flight['lastupdate'] < (time()-3000)) {
171 197
             	    if (isset($this->all_flights[$key]['id'])) {
172
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
198
+            		if ($globalDebug) {
199
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
200
+            		}
173 201
 			/*
174 202
 			$SpotterLive = new SpotterLive();
175 203
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -179,7 +207,9 @@  discard block
 block discarded – undo
179 207
             		$Spotter = new Spotter($this->db);
180 208
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
181 209
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
182
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
210
+				if ($globalDebug && $result != 'success') {
211
+					echo '!!! ERROR : '.$result."\n";
212
+				}
183 213
 			}
184 214
 			// Put in archive
185 215
 //			$Spotter->db = null;
@@ -193,8 +223,10 @@  discard block
 block discarded – undo
193 223
     public function add($line) {
194 224
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights;
195 225
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
196
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
197
-/*
226
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
227
+		$globalCoordMinChange = '0.02';
228
+	}
229
+	/*
198 230
 	$Spotter = new Spotter();
199 231
 	$dbc = $Spotter->db;
200 232
 	$SpotterLive = new SpotterLive($dbc);
@@ -222,11 +254,15 @@  discard block
 block discarded – undo
222 254
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
223 255
 		    $current_date = date('Y-m-d');
224 256
 		    $source = $line['source_name'];
225
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
257
+		    if ($source == '' || $line['format_source'] == 'aprs') {
258
+		    	$source = $line['format_source'];
259
+		    }
226 260
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
227 261
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
228 262
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
229
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
263
+		    } else {
264
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
265
+		    }
230 266
 		}
231 267
 		
232 268
 		/*
@@ -242,8 +278,11 @@  discard block
 block discarded – undo
242 278
 		//$this->db = $dbc;
243 279
 
244 280
 		$hex = trim($line['hex']);
245
-	        if (!isset($line['id'])) $id = trim($line['hex']);
246
-	        else $id = trim($line['id']);
281
+	        if (!isset($line['id'])) {
282
+	        	$id = trim($line['hex']);
283
+	        } else {
284
+	        	$id = trim($line['id']);
285
+	        }
247 286
 		
248 287
 		//print_r($this->all_flights);
249 288
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
@@ -258,13 +297,20 @@  discard block
 block discarded – undo
258 297
 			$Spotter = new Spotter($this->db);
259 298
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
260 299
 			$Spotter->db = null;
261
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
300
+			if ($globalDebugTimeElapsed) {
301
+				echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
+			}
262 303
 
263 304
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
264
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
265
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
266
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
267
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
305
+			    if ($line['aircraft_type'] == 'PARA_GLIDER') {
306
+			    	$aircraft_icao = 'GLID';
307
+			    } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
308
+			    	$aircraft_icao = 'UHEL';
309
+			    } elseif ($line['aircraft_type'] == 'TOW_PLANE') {
310
+			    	$aircraft_icao = 'TOWPLANE';
311
+			    } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
312
+			    	$aircraft_icao = 'POWAIRC';
313
+			    }
268 314
 			}
269 315
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
270 316
 		    } else if (isset($line['aircraft_name'])) {
@@ -272,29 +318,47 @@  discard block
 block discarded – undo
272 318
 			$Spotter = new Spotter($this->db);
273 319
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
274 320
 			$Spotter->db = null;
275
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
276
-			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
277
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
321
+			if ($aircraft_icao != '') {
322
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
323
+			} else {
324
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
325
+			}
326
+		    } else {
327
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
328
+		    }
278 329
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
279 330
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280 331
 		    if (!isset($line['id'])) {
281
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
282
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
332
+			if (!isset($globalDaemon)) {
333
+				$globalDaemon = TRUE;
334
+			}
335
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
283 336
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
284
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
337
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
338
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
339
+			}
285 340
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
286
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
341
+		     } else {
342
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
343
+		     }
287 344
 
288
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
289
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
345
+		    if ($globalDebug) {
346
+		    	echo "*********** New aircraft hex : ".$hex." ***********\n";
347
+		    }
348
+		    if ($globalAllFlights !== FALSE) {
349
+		    	$dataFound = true;
350
+		    }
290 351
 		}
291 352
 		
292 353
 		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
293 354
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
294 355
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
295 356
 		    } else {
296
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
297
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
357
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
358
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
359
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
360
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
361
+				}
298 362
 				/*
299 363
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
300 364
 				print_r($this->all_flights[$id]);
@@ -302,7 +366,9 @@  discard block
 block discarded – undo
302 366
 				*/
303 367
 				return '';
304 368
 		    }
305
-		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
369
+		} else {
370
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
371
+		}
306 372
 
307 373
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
308 374
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
@@ -323,15 +389,25 @@  discard block
 block discarded – undo
323 389
 			$timeelapsed = microtime(true);
324 390
             		$Spotter = new Spotter($this->db);
325 391
             		$fromsource = NULL;
326
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
327
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
328
-			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
329
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
330
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
392
+            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
393
+            			$fromsource = $globalAirlinesSource;
394
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
395
+            			$fromsource = 'vatsim';
396
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
397
+				$fromsource = 'ivao';
398
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
399
+				$fromsource = 'vatsim';
400
+			} elseif (isset($globalIVAO) && $globalIVAO) {
401
+				$fromsource = 'ivao';
402
+			}
331 403
             		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
332
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
404
+			if ($globalDebug && $result != 'success') {
405
+				echo '!!! ERROR : '.$result."\n";
406
+			}
333 407
 			$Spotter->db = null;
334
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
408
+			if ($globalDebugTimeElapsed) {
409
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
410
+			}
335 411
 		    }
336 412
 
337 413
 /*
@@ -342,7 +418,9 @@  discard block
 block discarded – undo
342 418
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
343 419
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
344 420
   */
345
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
421
+		    if (!isset($this->all_flights[$id]['id'])) {
422
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
423
+		    }
346 424
 
347 425
 		    //$putinarchive = true;
348 426
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -359,7 +437,9 @@  discard block
 block discarded – undo
359 437
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
360 438
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
361 439
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
362
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
440
+				if ($globalDebugTimeElapsed) {
441
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
442
+				}
363 443
 
364 444
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
365 445
 			$timeelapsed = microtime(true);
@@ -372,7 +452,9 @@  discard block
 block discarded – undo
372 452
 				$Translation->db = null;
373 453
 			}
374 454
 			$Spotter->db = null;
375
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
455
+			if ($globalDebugTimeElapsed) {
456
+				echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
457
+			}
376 458
 
377 459
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
378 460
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -381,9 +463,13 @@  discard block
 block discarded – undo
381 463
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
382 464
 		    	    }
383 465
 			}
384
-			if (!isset($globalFork)) $globalFork = TRUE;
466
+			if (!isset($globalFork)) {
467
+				$globalFork = TRUE;
468
+			}
385 469
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
386
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
470
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
471
+					$this->get_Schedule($id,trim($line['ident']));
472
+				}
387 473
 			}
388 474
 		    }
389 475
 		}
@@ -399,16 +485,23 @@  discard block
 block discarded – undo
399 485
 		    // use datetime
400 486
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
401 487
 			$speed = $speed*3.6;
402
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
403
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
488
+			if ($speed < 1000) {
489
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
490
+			}
491
+  			if ($globalDebug) {
492
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
493
+  			}
404 494
 		    }
405 495
 		}
406 496
 
407 497
 
408 498
 
409 499
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
410
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
411
-	    	    else unset($timediff);
500
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
501
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
502
+	    	    } else {
503
+	    	    	unset($timediff);
504
+	    	    }
412 505
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
413 506
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
414 507
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -416,21 +509,31 @@  discard block
 block discarded – undo
416 509
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
417 510
 				$this->all_flights[$id]['putinarchive'] = true;
418 511
 				
419
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
512
+				if ($globalDebug) {
513
+					echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
514
+				}
420 515
 				$timeelapsed = microtime(true);
421 516
 				$Spotter = new Spotter($this->db);
422 517
 				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
423
-				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
518
+				if (!empty($all_country)) {
519
+					$this->all_flights[$id]['over_country'] = $all_country['iso2'];
520
+				}
424 521
 				$Spotter->db = null;
425
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
522
+				if ($globalDebugTimeElapsed) {
523
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
524
+				}
426 525
 				$this->tmd = 0;
427
-				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
526
+				if ($globalDebug) {
527
+					echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
528
+				}
428 529
 			    }
429 530
 			}
430 531
 
431 532
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
432 533
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
433
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
534
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
535
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
536
+				}
434 537
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
435 538
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
436 539
 				    $dataFound = true;
@@ -452,9 +555,13 @@  discard block
 block discarded – undo
452 555
 			    */
453 556
 			}
454 557
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
455
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
558
+			    if ($line['longitude'] > 180) {
559
+			    	$line['longitude'] = $line['longitude'] - 360;
560
+			    }
456 561
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
457
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
562
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
563
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
564
+				}
458 565
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
459 566
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
460 567
 				    $dataFound = true;
@@ -485,7 +592,9 @@  discard block
 block discarded – undo
485 592
 		    }
486 593
 		}
487 594
 		if (isset($line['last_update']) && $line['last_update'] != '') {
488
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
595
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
596
+		    	$dataFound = true;
597
+		    }
489 598
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
490 599
 		}
491 600
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -507,11 +616,17 @@  discard block
 block discarded – undo
507 616
 			// Here we force archive of flight because after ground it's a new one (or should be)
508 617
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
509 618
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
510
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
511
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
512
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
619
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
620
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
621
+			} elseif (isset($line['id'])) {
622
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
623
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
624
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
625
+			}
626
+		    }
627
+		    if ($line['ground'] != 1) {
628
+		    	$line['ground'] = 0;
513 629
 		    }
514
-		    if ($line['ground'] != 1) $line['ground'] = 0;
515 630
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
516 631
 		    //$dataFound = true;
517 632
 		}
@@ -519,28 +634,40 @@  discard block
 block discarded – undo
519 634
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
520 635
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
521 636
 			    $highlight = '';
522
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
523
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
524
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
637
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
638
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
639
+			    }
640
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
641
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
642
+			    }
643
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
644
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
645
+			    }
525 646
 			    if ($highlight != '') {
526 647
 				$timeelapsed = microtime(true);
527 648
 				$Spotter = new Spotter($this->db);
528 649
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
529 650
 				$Spotter->db = null;
530
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
651
+				if ($globalDebugTimeElapsed) {
652
+					echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
653
+				}
531 654
 
532 655
 				$this->all_flights[$id]['putinarchive'] = true;
533 656
 				//$putinarchive = true;
534 657
 				//$highlight = '';
535 658
 			    }
536 659
 			    
537
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
660
+		    } else {
661
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
662
+		    }
538 663
 		    //$dataFound = true;
539 664
 		}
540 665
 
541 666
 		if (isset($line['altitude']) && $line['altitude'] != '') {
542 667
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
543
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
668
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) {
669
+				$this->all_flights[$id]['putinarchive'] = true;
670
+			}
544 671
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
545 672
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
546 673
 			//$dataFound = true;
@@ -552,21 +679,30 @@  discard block
 block discarded – undo
552 679
 		}
553 680
 		
554 681
 		if (isset($line['heading']) && $line['heading'] != '') {
555
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
682
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) {
683
+		    	$this->all_flights[$id]['putinarchive'] = true;
684
+		    }
556 685
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
557 686
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
558 687
 		    //$dataFound = true;
559 688
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
560 689
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
561 690
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
562
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
563
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
691
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) {
692
+		    	$this->all_flights[$id]['putinarchive'] = true;
693
+		    }
694
+  		    if ($globalDebug) {
695
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
696
+  		    }
564 697
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
565 698
   		    // If not enough messages and ACARS set heading to 0
566 699
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
567 700
   		}
568
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
569
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
701
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
702
+			$dataFound = false;
703
+		} elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
704
+			$dataFound = false;
705
+		}
570 706
 
571 707
 //		print_r($this->all_flights[$id]);
572 708
 		//gets the callsign from the last hour
@@ -581,23 +717,36 @@  discard block
 block discarded – undo
581 717
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
582 718
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
583 719
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
584
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
720
+				if ($globalDebug) {
721
+					echo "Check if aircraft is already in DB...";
722
+				}
585 723
 				$timeelapsed = microtime(true);
586 724
 				$SpotterLive = new SpotterLive($this->db);
587 725
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
588 726
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
589
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
727
+				    if ($globalDebugTimeElapsed) {
728
+				    	echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
729
+				    }
590 730
 				} elseif (isset($line['id'])) {
591 731
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
592
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
732
+				    if ($globalDebugTimeElapsed) {
733
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
734
+				    }
593 735
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
594 736
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
595
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
596
-				} else $recent_ident = '';
737
+				    if ($globalDebugTimeElapsed) {
738
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
739
+				    }
740
+				} else {
741
+					$recent_ident = '';
742
+				}
597 743
 				$SpotterLive->db=null;
598 744
 
599
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
600
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
745
+				if ($globalDebug && $recent_ident == '') {
746
+					echo " Not in DB.\n";
747
+				} elseif ($globalDebug && $recent_ident != '') {
748
+					echo " Already in DB.\n";
749
+				}
601 750
 			    } else {
602 751
 				$recent_ident = '';
603 752
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -605,7 +754,9 @@  discard block
 block discarded – undo
605 754
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
606 755
 			    if($recent_ident == "")
607 756
 			    {
608
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
757
+				if ($globalDebug) {
758
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
759
+				}
609 760
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
610 761
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
611 762
 				//adds the spotter data for the archive
@@ -649,26 +800,44 @@  discard block
 block discarded – undo
649 800
 				
650 801
 				if (!$ignoreImport) {
651 802
 				    $highlight = '';
652
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
653
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
654
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
655
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
803
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
804
+				    	$highlight = 'Squawk 7500 : Hijack';
805
+				    }
806
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
807
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
808
+				    }
809
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
810
+				    	$highlight = 'Squawk 7700 : Emergency';
811
+				    }
812
+				    if (!isset($this->all_flights[$id]['id'])) {
813
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
814
+				    }
656 815
 				    $timeelapsed = microtime(true);
657 816
 				    $Spotter = new Spotter($this->db);
658 817
 				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
659 818
 				    $Spotter->db = null;
660
-				    if ($globalDebug && isset($result)) echo $result."\n";
661
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
819
+				    if ($globalDebug && isset($result)) {
820
+				    	echo $result."\n";
821
+				    }
822
+				    if ($globalDebugTimeElapsed) {
823
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
824
+				    }
662 825
 				    
663 826
 				    // Add source stat in DB
664 827
 				    $Stats = new Stats($this->db);
665 828
 				    if (!empty($this->stats)) {
666
-					if ($globalDebug) echo 'Add source stats : ';
829
+					if ($globalDebug) {
830
+						echo 'Add source stats : ';
831
+					}
667 832
 				        foreach($this->stats as $date => $data) {
668 833
 					    foreach($data as $source => $sourced) {
669 834
 					        //print_r($sourced);
670
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
671
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
835
+				    	        if (isset($sourced['polar'])) {
836
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
837
+				    	        }
838
+				    	        if (isset($sourced['hist'])) {
839
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
840
+				    	        }
672 841
 				    		if (isset($sourced['msg'])) {
673 842
 				    		    if (time() - $sourced['msg']['date'] > 10) {
674 843
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -681,13 +850,17 @@  discard block
 block discarded – undo
681 850
 			    			unset($this->stats[$date]);
682 851
 			    		    }
683 852
 				    	}
684
-				    	if ($globalDebug) echo 'Done'."\n";
853
+				    	if ($globalDebug) {
854
+				    		echo 'Done'."\n";
855
+				    	}
685 856
 
686 857
 				    }
687 858
 				    $Stats->db = null;
688 859
 				    
689 860
 				    $this->del();
690
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
861
+				} elseif ($globalDebug) {
862
+					echo 'Ignore data'."\n";
863
+				}
691 864
 				//$ignoreImport = false;
692 865
 				$this->all_flights[$id]['addedSpotter'] = 1;
693 866
 				//print_r($this->all_flights[$id]);
@@ -704,12 +877,16 @@  discard block
 block discarded – undo
704 877
 			*/
705 878
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
706 879
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
707
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
880
+				    if ($globalDebug) {
881
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
882
+				    }
708 883
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
709 884
 				    $SpotterLive = new SpotterLive($this->db);
710 885
 				    $SpotterLive->deleteLiveSpotterData();
711 886
 				    $SpotterLive->db=null;
712
-				    if ($globalDebug) echo " Done\n";
887
+				    if ($globalDebug) {
888
+				    	echo " Done\n";
889
+				    }
713 890
 				    $this->last_delete = time();
714 891
 				}
715 892
 			    } else {
@@ -732,11 +909,17 @@  discard block
 block discarded – undo
732 909
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
733 910
 		    if ($globalDebug) {
734 911
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
735
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
736
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
912
+				if (isset($this->all_flights[$id]['source_name'])) {
913
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
914
+				} else {
915
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
916
+				}
737 917
 			} else {
738
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
739
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
918
+				if (isset($this->all_flights[$id]['source_name'])) {
919
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
920
+				} else {
921
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
922
+				}
740 923
 			}
741 924
 		    }
742 925
 		    $ignoreImport = false;
@@ -782,19 +965,25 @@  discard block
 block discarded – undo
782 965
 
783 966
 		    if (!$ignoreImport) {
784 967
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
785
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
968
+				if ($globalDebug) {
969
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
970
+				}
786 971
 				$timeelapsed = microtime(true);
787 972
 				$SpotterLive = new SpotterLive($this->db);
788 973
 				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
789 974
 				$SpotterLive->db = null;
790
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
975
+				if ($globalDebugTimeElapsed) {
976
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
977
+				}
791 978
 
792 979
 				// Put statistics in $this->stats variable
793 980
 				//if ($line['format_source'] != 'aprs') {
794 981
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
795 982
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
796 983
 					$source = $this->all_flights[$id]['source_name'];
797
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
984
+					if ($source == '') {
985
+						$source = $this->all_flights[$id]['format_source'];
986
+					}
798 987
 					if (!isset($this->source_location[$source])) {
799 988
 						$Location = new Source();
800 989
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -815,7 +1004,9 @@  discard block
 block discarded – undo
815 1004
 					$stats_heading = round($stats_heading/22.5);
816 1005
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
817 1006
 					$current_date = date('Y-m-d');
818
-					if ($stats_heading == 16) $stats_heading = 0;
1007
+					if ($stats_heading == 16) {
1008
+						$stats_heading = 0;
1009
+					}
819 1010
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
820 1011
 						for ($i=0;$i<=15;$i++) {
821 1012
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -833,7 +1024,9 @@  discard block
 block discarded – undo
833 1024
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
834 1025
 						    end($this->stats[$current_date][$source]['hist']);
835 1026
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
836
-						} else $mini = 0;
1027
+						} else {
1028
+							$mini = 0;
1029
+						}
837 1030
 						for ($i=$mini;$i<=$distance;$i+=10) {
838 1031
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
839 1032
 						}
@@ -844,20 +1037,30 @@  discard block
 block discarded – undo
844 1037
 				}
845 1038
 
846 1039
 				$this->all_flights[$id]['lastupdate'] = time();
847
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1040
+				if ($this->all_flights[$id]['putinarchive']) {
1041
+					$send = true;
1042
+				}
848 1043
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
849
-				if ($globalDebug) echo $result."\n";
850
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1044
+				if ($globalDebug) {
1045
+					echo $result."\n";
1046
+				}
1047
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1048
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1049
+			}
851 1050
 			//$this->del();
852 1051
 			
853 1052
 			
854 1053
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
855
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1054
+			    if ($globalDebug) {
1055
+			    	echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1056
+			    }
856 1057
 			    $SpotterLive = new SpotterLive($this->db);
857 1058
 			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
858 1059
 			    $SpotterLive->db = null;
859 1060
 			    //SpotterLive->deleteLiveSpotterData();
860
-			    if ($globalDebug) echo " Done\n";
1061
+			    if ($globalDebug) {
1062
+			    	echo " Done\n";
1063
+			    }
861 1064
 			    $this->last_delete_hourly = time();
862 1065
 			}
863 1066
 			
@@ -865,7 +1068,9 @@  discard block
 block discarded – undo
865 1068
 		    //$ignoreImport = false;
866 1069
 		}
867 1070
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
868
-		if ($send) return $this->all_flights[$id];
1071
+		if ($send) {
1072
+			return $this->all_flights[$id];
1073
+		}
869 1074
 	    }
870 1075
 	}
871 1076
     }
Please login to merge, or discard this patch.
live-czml.php 1 patch
Braces   +62 added lines, -21 removed lines patch added patch discarded remove patch
@@ -40,22 +40,43 @@  discard block
 block discarded – undo
40 40
 }
41 41
 header('Content-Type: text/javascript');
42 42
 
43
-if (!isset($globalJsonCompress)) $compress = true;
44
-else $compress = $globalJsonCompress;
43
+if (!isset($globalJsonCompress)) {
44
+	$compress = true;
45
+} else {
46
+	$compress = $globalJsonCompress;
47
+}
45 48
 
46 49
 $from_archive = false;
47 50
 $min = false;
48 51
 $allhistory = false;
49 52
 $filter['source'] = array();
50
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
51
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
52
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
53
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
54
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
55
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
56
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
57
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
58
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
53
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
54
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
55
+}
56
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
57
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
58
+}
59
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
60
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
+}
62
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
63
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
64
+}
65
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
66
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
67
+}
68
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
69
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
70
+}
71
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
72
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
73
+}
74
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
75
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
+}
77
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
78
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
79
+}
59 80
 /*
60 81
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
61 82
 	$min = true;
@@ -132,8 +153,12 @@  discard block
 block discarded – undo
132 153
 	} else {
133 154
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
134 155
 	}
135
-	if ($flightcnt == '') $flightcnt = 0;
136
-} else $flightcnt = 0;
156
+	if ($flightcnt == '') {
157
+		$flightcnt = 0;
158
+	}
159
+	} else {
160
+	$flightcnt = 0;
161
+}
137 162
 
138 163
 $sqltime = round(microtime(true)-$begintime,2);
139 164
 $minitime = time();
@@ -156,7 +181,9 @@  discard block
 block discarded – undo
156 181
 $j = 0;
157 182
 $prev_flightaware_id = '';
158 183
 $speed = 1;
159
-if (isset($archivespeed)) $speed = $archivespeed;
184
+if (isset($archivespeed)) {
185
+	$speed = $archivespeed;
186
+}
160 187
 $output = '[';
161 188
 $output .= '{"id" : "document", "name" : "fam","version" : "1.0"';
162 189
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "LOOP_STOP","step": "SYSTEM_CLOCK_MULTIPLIER"}';
@@ -226,7 +253,9 @@  discard block
 block discarded – undo
226 253
 					$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
227 254
 					$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
228 255
 					$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
229
-				} else $aircraft_shadow = '';
256
+				} else {
257
+					$aircraft_shadow = '';
258
+				}
230 259
 				if ($aircraft_shadow != '') {
231 260
 					if (isset($modelsdb[$aircraft_shadow])) {
232 261
 						$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20 ,';
@@ -323,7 +352,9 @@  discard block
 block discarded – undo
323 352
 						$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20,';
324 353
 						$output .= '"heightReference": "'.$heightrelative.'"},';
325 354
 							//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
326
-						if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
355
+						if ($spotter_item['aircraft_icao'] != '') {
356
+							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
357
+						}
327 358
 						$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
328 359
 					}
329 360
 				} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
@@ -335,7 +366,9 @@  discard block
 block discarded – undo
335 366
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20,';
336 367
 					$output .= '"heightReference": "'.$heightrelative.'"},';
337 368
 					//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
338
-					if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
369
+					if ($spotter_item['aircraft_icao'] != '') {
370
+						$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
371
+					}
339 372
 					$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
340 373
 				}
341 374
 
@@ -343,7 +376,9 @@  discard block
 block discarded – undo
343 376
 				$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20,';
344 377
 				$output .= '"heightReference": "'.$heightrelative.'"},';
345 378
 				//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
346
-				if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
379
+				if ($spotter_item['aircraft_icao'] != '') {
380
+					$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
381
+				}
347 382
 				$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
348 383
 			}
349 384
 	//		$output .= '"heightReference": "CLAMP_TO_GROUND",';
@@ -356,8 +391,12 @@  discard block
 block discarded – undo
356 391
 	//		$output .= '"interpolationDegree" : 5,';
357 392
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
358 393
 			$output .= '"cartographicDegrees": [';
359
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
360
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
394
+			if ($minitime > strtotime($spotter_item['date'])) {
395
+				$minitime = strtotime($spotter_item['date']);
396
+			}
397
+			if ($maxitime < strtotime($spotter_item['date'])) {
398
+				$maxitime = strtotime($spotter_item['date']);
399
+			}
361 400
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
362 401
 			$output .= $spotter_item['longitude'].', ';
363 402
 			$output .= $spotter_item['latitude'].', ';
@@ -371,7 +410,9 @@  discard block
 block discarded – undo
371 410
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
372 411
 		} else {
373 412
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
374
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
413
+			if ($maxitime < strtotime($spotter_item['date'])) {
414
+				$maxitime = strtotime($spotter_item['date']);
415
+			}
375 416
 			if ($spotter_item['ground_speed'] == 0) {
376 417
 				$output .= $prevlong.', ';
377 418
 				$output .= $prevlat.', ';
Please login to merge, or discard this patch.