Completed
Push — master ( e6c083...dab432 )
by Yannick
31:25
created
require/class.ATC.php 1 patch
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@  discard block
 block discarded – undo
7 7
 	public function __construct($dbc = null) {
8 8
 		$Connection = new Connection($dbc);
9 9
 		$this->db = $Connection->db;
10
-		if ($this->db === null) die('Error: No DB connection. (ATC)');
10
+		if ($this->db === null) {
11
+			die('Error: No DB connection. (ATC)');
12
+		}
11 13
 	}
12 14
 
13 15
 	/**
@@ -20,20 +22,27 @@  discard block
 block discarded – undo
20 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 24
 				foreach($globalStatsFilters[$globalFilterName] as $source) {
23
-					if (isset($source['source'])) $filter['source'][] = $source['source'];
25
+					if (isset($source['source'])) {
26
+						$filter['source'][] = $source['source'];
27
+					}
24 28
 				}
25 29
 			} else {
26 30
 				$filter = $globalStatsFilters[$globalFilterName];
27 31
 			}
28 32
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) {
34
+			$filter = array_merge($filter,$globalFilter);
35
+		}
30 36
 		$filter_query_join = '';
31 37
 		$filter_query_where = '';
32 38
 		if (isset($filter['source']) && !empty($filter['source'])) {
33 39
 			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
34 40
 		}
35
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
41
+		if ($filter_query_where == '' && $where) {
42
+			$filter_query_where = ' WHERE';
43
+		} elseif ($filter_query_where != '' && $and) {
44
+			$filter_query_where .= ' AND';
45
+		}
37 46
 		$filter_query = $filter_query_join.$filter_query_where;
38 47
 		return $filter_query;
39 48
 	}
@@ -90,7 +99,9 @@  discard block
 block discarded – undo
90 99
 		$info = str_replace('^','<br />',$info);
91 100
 		$info = str_replace('&amp;sect;','',$info);
92 101
 		$info = str_replace('"','',$info);
93
-		if ($type == '') $type = NULL;
102
+		if ($type == '') {
103
+			$type = NULL;
104
+		}
94 105
 		$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)";
95 106
 		$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);
96 107
 		try {
@@ -106,7 +117,9 @@  discard block
 block discarded – undo
106 117
 		$info = str_replace('^','<br />',$info);
107 118
 		$info = str_replace('&amp;sect;','',$info);
108 119
 		$info = str_replace('"','',$info);
109
-		if ($type == '') $type = NULL;
120
+		if ($type == '') {
121
+			$type = NULL;
122
+		}
110 123
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
111 124
 		$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);
112 125
 		try {
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Braces   +110 added lines, -37 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (TrackerLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (TrackerLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -77,8 +81,11 @@  discard block
 block discarded – undo
77 81
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78 82
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
79 83
 		}
80
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
84
+		if ($filter_query_where == '' && $where) {
85
+			$filter_query_where = ' WHERE';
86
+		} elseif ($filter_query_where != '' && $and) {
87
+			$filter_query_where .= ' AND';
88
+		}
82 89
 		if ($filter_query_where != '') {
83 90
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84 91
 		}
@@ -120,7 +127,9 @@  discard block
 block discarded – undo
120 127
 			}
121 128
 		}
122 129
 
123
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
130
+		if (!isset($globalLiveInterval)) {
131
+			$globalLiveInterval = '200';
132
+		}
124 133
 		if ($globalDBdriver == 'mysql') {
125 134
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
126 135
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -145,7 +154,9 @@  discard block
 block discarded – undo
145 154
 
146 155
 		$filter_query = $this->getFilter($filter,true,true);
147 156
 
148
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
157
+		if (!isset($globalLiveInterval)) {
158
+			$globalLiveInterval = '200';
159
+		}
149 160
 		if ($globalDBdriver == 'mysql') {
150 161
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
151 162
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -190,50 +201,74 @@  discard block
 block discarded – undo
190 201
 		}
191 202
 		$filter_query = $this->getFilter($filter,true,true);
192 203
 
193
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
-		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
204
+		if (!isset($globalLiveInterval)) {
205
+			$globalLiveInterval = '200';
206
+		}
207
+		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') {
208
+			$globalMap3DTrackersLimit = '300';
209
+		}
195 210
 		if ($globalDBdriver == 'mysql') {
196 211
 			if (isset($globalArchive) && $globalArchive) {
197 212
 				$query  = "SELECT * FROM (
198 213
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
199 214
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
200
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
215
+				if ($usecoord) {
216
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
217
+				}
201 218
 				$query .= "UNION
202 219
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
203 220
 					FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
204
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
221
+				if ($usecoord) {
222
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
223
+				}
205 224
 				$query .= ") AS tracker
206 225
 				    WHERE latitude <> '0' AND longitude <> '0' 
207 226
 				    ORDER BY famtrackid, date";
208
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
227
+				if ($limit) {
228
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
229
+				}
209 230
 			} else {
210 231
 				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
211 232
 				    FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
212
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
233
+				if ($usecoord) {
234
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
235
+				}
213 236
 				$query .= "AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
214 237
 				    ORDER BY tracker_live.famtrackid, tracker_live.date";
215
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
238
+				if ($limit) {
239
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
240
+				}
216 241
 			}
217 242
 		} else {
218 243
 			if (isset($globalArchive) && $globalArchive) {
219 244
 				$query  = "SELECT * FROM (
220 245
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
221 246
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
222
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
247
+				if ($usecoord) {
248
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
249
+				}
223 250
 				$query .= "UNION
224 251
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
225 252
 					FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date";
226
-				if ($usecoord) $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
253
+				if ($usecoord) {
254
+					$query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
255
+				}
227 256
 				$query .= ") AS tracker
228 257
 				    WHERE latitude <> '0' AND longitude <> '0' 
229 258
 				    ORDER BY famtrackid, date";
230
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
259
+				if ($limit) {
260
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
261
+				}
231 262
 			} else {
232 263
 				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
233 264
 				    FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' ";
234
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
265
+				if ($usecoord) {
266
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
267
+				}
235 268
 				$query .= "ORDER BY tracker_live.famtrackid, tracker_live.date";
236
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
269
+				if ($limit) {
270
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
271
+				}
237 272
 			}
238 273
 		}
239 274
 
@@ -259,7 +294,9 @@  discard block
 block discarded – undo
259 294
 		global $globalDBdriver, $globalLiveInterval;
260 295
 		$filter_query = $this->getFilter($filter,true,true);
261 296
 
262
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
297
+		if (!isset($globalLiveInterval)) {
298
+			$globalLiveInterval = '200';
299
+		}
263 300
 		if ($globalDBdriver == 'mysql') {
264 301
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
265 302
 		} else {
@@ -287,7 +324,9 @@  discard block
 block discarded – undo
287 324
 	{
288 325
 		global $globalDBdriver, $globalLiveInterval;
289 326
 		$Tracker = new Tracker($this->db);
290
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
327
+		if (!isset($globalLiveInterval)) {
328
+			$globalLiveInterval = '200';
329
+		}
291 330
 		$filter_query = $this->getFilter($filter);
292 331
 
293 332
 		if (is_array($coord)) {
@@ -295,7 +334,9 @@  discard block
 block discarded – undo
295 334
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296 335
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
297 336
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
298
-		} else return array();
337
+		} else {
338
+			return array();
339
+		}
299 340
 		if ($globalDBdriver == 'mysql') {
300 341
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
301 342
 		} else {
@@ -315,7 +356,9 @@  discard block
 block discarded – undo
315 356
 	{
316 357
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
317 358
 		$Tracker = new Tracker($this->db);
318
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
359
+		if (!isset($globalLiveInterval)) {
360
+			$globalLiveInterval = '200';
361
+		}
319 362
 		$filter_query = $this->getFilter($filter,true,true);
320 363
 
321 364
 		if (is_array($coord)) {
@@ -323,7 +366,9 @@  discard block
 block discarded – undo
323 366
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324 367
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325 368
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326
-		} else return array();
369
+		} else {
370
+			return array();
371
+		}
327 372
 		/*
328 373
 		if ($globalDBdriver == 'mysql') {
329 374
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
@@ -557,11 +602,15 @@  discard block
 block discarded – undo
557 602
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
558 603
 		if ($globalDBdriver == 'mysql') {
559 604
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
560
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
605
+			if ($liveinterval) {
606
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
607
+			}
561 608
 			$query .= ' ORDER BY date';
562 609
 		} else {
563 610
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
564
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
611
+			if ($liveinterval) {
612
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
613
+			}
565 614
 			$query .= ' ORDER BY date';
566 615
 		}
567 616
 
@@ -656,7 +705,9 @@  discard block
 block discarded – undo
656 705
 				$i++;
657 706
 				$j++;
658 707
 				if ($j == 30) {
659
-					if ($globalDebug) echo ".";
708
+					if ($globalDebug) {
709
+						echo ".";
710
+					}
660 711
 				    	try {
661 712
 						
662 713
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -903,7 +954,9 @@  discard block
 block discarded – undo
903 954
 			{
904 955
 				return false;
905 956
 			}
906
-		} else return '';
957
+		} else {
958
+			return '';
959
+		}
907 960
 
908 961
 		if ($longitude != '')
909 962
 		{
@@ -911,7 +964,9 @@  discard block
 block discarded – undo
911 964
 			{
912 965
 				return false;
913 966
 			}
914
-		} else return '';
967
+		} else {
968
+			return '';
969
+		}
915 970
 
916 971
 		if ($altitude != '')
917 972
 		{
@@ -919,7 +974,9 @@  discard block
 block discarded – undo
919 974
 			{
920 975
 				return false;
921 976
 			}
922
-		} else $altitude = 0;
977
+		} else {
978
+			$altitude = 0;
979
+		}
923 980
 
924 981
 		if ($heading != '')
925 982
 		{
@@ -927,7 +984,9 @@  discard block
 block discarded – undo
927 984
 			{
928 985
 				return false;
929 986
 			}
930
-		} else $heading = 0;
987
+		} else {
988
+			$heading = 0;
989
+		}
931 990
 
932 991
 		if ($groundspeed != '')
933 992
 		{
@@ -935,9 +994,13 @@  discard block
 block discarded – undo
935 994
 			{
936 995
 				return false;
937 996
 			}
938
-		} else $groundspeed = 0;
997
+		} else {
998
+			$groundspeed = 0;
999
+		}
939 1000
 		date_default_timezone_set('UTC');
940
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1001
+		if ($date == '') {
1002
+			$date = date("Y-m-d H:i:s", time());
1003
+		}
941 1004
 
942 1005
         
943 1006
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -953,12 +1016,18 @@  discard block
 block discarded – undo
953 1016
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
954 1017
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
955 1018
 
956
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1019
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1020
+            		$groundspeed = 0;
1021
+            	}
1022
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1023
+            		$heading = 0;
1024
+            	}
958 1025
             	
959 1026
 		$query = '';
960 1027
 		if ($globalArchive) {
961
-			if ($globalDebug) echo '-- Delete previous data -- ';
1028
+			if ($globalDebug) {
1029
+				echo '-- Delete previous data -- ';
1030
+			}
962 1031
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
963 1032
 		}
964 1033
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -977,10 +1046,14 @@  discard block
 block discarded – undo
977 1046
                 echo 'noarchive : '.$noarchive."\n";
978 1047
                 */
979 1048
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
980
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
1049
+		    if ($globalDebug) {
1050
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
1051
+		    }
981 1052
 		    $TrackerArchive = new TrackerArchive($this->db);
982 1053
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
983
-		    if ($globalDebug) echo $result.')';
1054
+		    if ($globalDebug) {
1055
+		    	echo $result.')';
1056
+		    }
984 1057
 		}
985 1058
 
986 1059
 		return "success";
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +122 added lines, -41 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (SpotterLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (SpotterLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -123,8 +127,11 @@  discard block
 block discarded – undo
123 127
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
124 128
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
125 129
 		}
126
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
127
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
130
+		if ($filter_query_where == '' && $where) {
131
+			$filter_query_where = ' WHERE';
132
+		} elseif ($filter_query_where != '' && $and) {
133
+			$filter_query_where .= ' AND';
134
+		}
128 135
 		if ($filter_query_where != '') {
129 136
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
130 137
 		}
@@ -165,9 +172,13 @@  discard block
 block discarded – undo
165 172
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
166 173
 			}
167 174
 		}
168
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
175
+		if ($orderby_query == '') {
176
+			$orderby_query = ' ORDER BY date DESC';
177
+		}
169 178
 
170
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
179
+		if (!isset($globalLiveInterval)) {
180
+			$globalLiveInterval = '200';
181
+		}
171 182
 		if ($globalDBdriver == 'mysql') {
172 183
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
173 184
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -190,7 +201,9 @@  discard block
 block discarded – undo
190 201
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
191 202
 		date_default_timezone_set('UTC');
192 203
 		$filter_query = $this->getFilter($filter,true,true);
193
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
204
+		if (!isset($globalLiveInterval)) {
205
+			$globalLiveInterval = '200';
206
+		}
194 207
 		if ($globalDBdriver == 'mysql') {
195 208
 			if (isset($globalArchive) && $globalArchive === TRUE) {
196 209
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -240,8 +253,12 @@  discard block
 block discarded – undo
240 253
 		}
241 254
 		$filter_query = $this->getFilter($filter,true,true);
242 255
 
243
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
244
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
256
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
257
+			$globalLiveInterval = '200';
258
+		}
259
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
260
+			$globalMap3DAircraftsLimit = '300';
261
+		}
245 262
 		if ($globalDBdriver == 'mysql') {
246 263
 			if (isset($globalArchive) && $globalArchive === TRUE) {
247 264
 				/*
@@ -252,22 +269,32 @@  discard block
 block discarded – undo
252 269
 				*/
253 270
 				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
254 271
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id ";
255
-				if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
272
+				if ($usecoord) {
273
+					$query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
274
+				}
256 275
 				$query .= "UNION
257 276
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
258 277
 				FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
259
-				if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
278
+				if ($usecoord) {
279
+					$query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
280
+				}
260 281
 				$query .= ") AS spotter 
261 282
 				WHERE latitude <> '0' AND longitude <> '0' 
262 283
 				ORDER BY flightaware_id, date";
263
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
284
+				if ($limit) {
285
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
286
+				}
264 287
 			} else {
265 288
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
266 289
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
267
-				if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
290
+				if ($usecoord) {
291
+					$query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
292
+				}
268 293
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
269 294
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
270
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
295
+				if ($limit) {
296
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
297
+				}
271 298
 			}
272 299
 		} else {
273 300
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -279,21 +306,31 @@  discard block
 block discarded – undo
279 306
                                */
280 307
 				$query  = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
281 308
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id ";
282
-				if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
309
+				if ($usecoord) {
310
+					$query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
311
+				}
283 312
 				$query .= "UNION
284 313
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
285 314
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
286
-				if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
315
+				if ($usecoord) {
316
+					$query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
317
+				}
287 318
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
288 319
 				$query .= "ORDER BY flightaware_id, date";
289
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
320
+				if ($limit) {
321
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
322
+				}
290 323
 			} else {
291 324
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
292 325
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date ";
293
-				if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
326
+				if ($usecoord) {
327
+					$query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
328
+				}
294 329
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
295 330
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
296
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
331
+				if ($limit) {
332
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
333
+				}
297 334
 			}
298 335
 		}
299 336
 		try {
@@ -318,7 +355,9 @@  discard block
 block discarded – undo
318 355
 		global $globalDBdriver, $globalLiveInterval;
319 356
 		$filter_query = $this->getFilter($filter,true,true);
320 357
 
321
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
358
+		if (!isset($globalLiveInterval)) {
359
+			$globalLiveInterval = '200';
360
+		}
322 361
 		if ($globalDBdriver == 'mysql') {
323 362
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
324 363
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -348,7 +387,9 @@  discard block
 block discarded – undo
348 387
 	{
349 388
 		global $globalDBdriver, $globalLiveInterval;
350 389
 		$Spotter = new Spotter($this->db);
351
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
390
+		if (!isset($globalLiveInterval)) {
391
+			$globalLiveInterval = '200';
392
+		}
352 393
 		$filter_query = $this->getFilter($filter);
353 394
 
354 395
 		if (is_array($coord)) {
@@ -356,7 +397,9 @@  discard block
 block discarded – undo
356 397
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
357 398
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
358 399
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
359
-		} else return array();
400
+		} else {
401
+			return array();
402
+		}
360 403
 		if ($globalDBdriver == 'mysql') {
361 404
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
362 405
 		} else {
@@ -377,7 +420,9 @@  discard block
 block discarded – undo
377 420
 	{
378 421
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
379 422
 		$Spotter = new Spotter($this->db);
380
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
423
+		if (!isset($globalLiveInterval)) {
424
+			$globalLiveInterval = '200';
425
+		}
381 426
 		$filter_query = $this->getFilter($filter,true,true);
382 427
 
383 428
 		if (is_array($coord)) {
@@ -385,7 +430,9 @@  discard block
 block discarded – undo
385 430
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
386 431
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
387 432
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
388
-		} else return array();
433
+		} else {
434
+			return array();
435
+		}
389 436
 		if ($globalDBdriver == 'mysql') {
390 437
 			if (isset($globalArchive) && $globalArchive === TRUE) {
391 438
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -612,11 +659,15 @@  discard block
 block discarded – undo
612 659
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
613 660
 		if ($globalDBdriver == 'mysql') {
614 661
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
615
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
662
+			if ($liveinterval) {
663
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
664
+			}
616 665
 			$query .= ' ORDER BY date';
617 666
 		} else {
618 667
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
619
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
668
+			if ($liveinterval) {
669
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
670
+			}
620 671
 			$query .= ' ORDER BY date';
621 672
 		}
622 673
 
@@ -711,7 +762,9 @@  discard block
 block discarded – undo
711 762
 				$i++;
712 763
 				$j++;
713 764
 				if ($j == 30) {
714
-					if ($globalDebug) echo ".";
765
+					if ($globalDebug) {
766
+						echo ".";
767
+					}
715 768
 				    	try {
716 769
 						
717 770
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -1018,7 +1071,9 @@  discard block
 block discarded – undo
1018 1071
 			{
1019 1072
 				return false;
1020 1073
 			}
1021
-		} else return '';
1074
+		} else {
1075
+			return '';
1076
+		}
1022 1077
 
1023 1078
 		if ($longitude != '')
1024 1079
 		{
@@ -1026,7 +1081,9 @@  discard block
 block discarded – undo
1026 1081
 			{
1027 1082
 				return false;
1028 1083
 			}
1029
-		} else return '';
1084
+		} else {
1085
+			return '';
1086
+		}
1030 1087
 
1031 1088
 		if ($waypoints != '')
1032 1089
 		{
@@ -1042,14 +1099,18 @@  discard block
 block discarded – undo
1042 1099
 			{
1043 1100
 				return false;
1044 1101
 			}
1045
-		} else $altitude = 0;
1102
+		} else {
1103
+			$altitude = 0;
1104
+		}
1046 1105
 		if ($altitude_real != '')
1047 1106
 		{
1048 1107
 			if (!is_numeric($altitude_real))
1049 1108
 			{
1050 1109
 				return false;
1051 1110
 			}
1052
-		} else $altitude_real = 0;
1111
+		} else {
1112
+			$altitude_real = 0;
1113
+		}
1053 1114
 
1054 1115
 		if ($heading != '')
1055 1116
 		{
@@ -1057,7 +1118,9 @@  discard block
 block discarded – undo
1057 1118
 			{
1058 1119
 				return false;
1059 1120
 			}
1060
-		} else $heading = 0;
1121
+		} else {
1122
+			$heading = 0;
1123
+		}
1061 1124
 
1062 1125
 		if ($groundspeed != '')
1063 1126
 		{
@@ -1065,9 +1128,13 @@  discard block
 block discarded – undo
1065 1128
 			{
1066 1129
 				return false;
1067 1130
 			}
1068
-		} else $groundspeed = 0;
1131
+		} else {
1132
+			$groundspeed = 0;
1133
+		}
1069 1134
 		date_default_timezone_set('UTC');
1070
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1135
+		if ($date == '') {
1136
+			$date = date("Y-m-d H:i:s", time());
1137
+		}
1071 1138
 
1072 1139
         
1073 1140
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1112,14 +1179,24 @@  discard block
 block discarded – undo
1112 1179
 		$arrival_airport_country = '';
1113 1180
 		
1114 1181
             	
1115
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1116
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1117
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1118
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1182
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1183
+            		$squawk = NULL;
1184
+            	}
1185
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1186
+            		$verticalrate = NULL;
1187
+            	}
1188
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1189
+            		$groundspeed = 0;
1190
+            	}
1191
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1192
+            		$heading = 0;
1193
+            	}
1119 1194
 		
1120 1195
 		$query = '';
1121 1196
 		if ($globalArchive) {
1122
-			if ($globalDebug) echo '-- Delete previous data -- ';
1197
+			if ($globalDebug) {
1198
+				echo '-- Delete previous data -- ';
1199
+			}
1123 1200
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1124 1201
 		}
1125 1202
 
@@ -1136,10 +1213,14 @@  discard block
 block discarded – undo
1136 1213
 			return "error : ".$e->getMessage();
1137 1214
 		}
1138 1215
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1139
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1216
+		    if ($globalDebug) {
1217
+		    	echo '(Add to SBS archive : ';
1218
+		    }
1140 1219
 		    $SpotterArchive = new SpotterArchive($this->db);
1141 1220
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1142
-		    if ($globalDebug) echo $result.')';
1221
+		    if ($globalDebug) {
1222
+		    	echo $result.')';
1223
+		    }
1143 1224
 		} elseif ($globalDebug && $putinarchive !== true) {
1144 1225
 			echo '(Not adding to archive)';
1145 1226
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +401 added lines, -143 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54 54
 		} catch(Exception $e) {
55
-			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
55
+			if ($globalDebug) {
56
+				echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
57
+			}
56 58
 			$GeoidClass = FALSE;
57 59
 		}
58 60
 	}
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 	$dbc = $this->db;
72 74
 	$this->all_flights[$id]['schedule_check'] = true;
73 75
 	if ($globalSchedulesFetch) {
74
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
76
+	if ($globalDebug) {
77
+		echo 'Getting schedule info...'."\n";
78
+	}
75 79
 	$Spotter = new Spotter($dbc);
76 80
 	$Schedule = new Schedule($dbc);
77 81
 	$Translation = new Translation($dbc);
@@ -82,7 +86,9 @@  discard block
 block discarded – undo
82 86
 	    if ($Schedule->checkSchedule($operator) == 0) {
83 87
 		$schedule = $Schedule->fetchSchedule($operator);
84 88
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
89
+		    if ($globalDebug) {
90
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
91
+		    }
86 92
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87 93
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88 94
 		    // Should also check if route schedule = route from DB
@@ -91,7 +97,9 @@  discard block
 block discarded – undo
91 97
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92 98
 			    if (trim($airport_icao) != '') {
93 99
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
100
+				if ($globalDebug) {
101
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
102
+				}
95 103
 			    }
96 104
 			}
97 105
 		    }
@@ -100,17 +108,25 @@  discard block
 block discarded – undo
100 108
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101 109
 			    if (trim($airport_icao) != '') {
102 110
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
111
+				if ($globalDebug) {
112
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
113
+				}
104 114
 			    }
105 115
 			}
106 116
 		    }
107 117
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
108 118
 		}
109
-	    } else $scheduleexist = true;
110
-	} else $scheduleexist = true;
119
+	    } else {
120
+	    	$scheduleexist = true;
121
+	    }
122
+	} else {
123
+		$scheduleexist = true;
124
+	}
111 125
 	// close connection, at least one way will work ?
112 126
        if ($scheduleexist) {
113
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
127
+		if ($globalDebug) {
128
+			echo "-> get arrival/departure airport info for ".$ident."\n";
129
+		}
114 130
     		$sch = $Schedule->getSchedule($operator);
115 131
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116 132
        }
@@ -132,14 +148,18 @@  discard block
 block discarded – undo
132 148
 
133 149
     public function checkAll() {
134 150
 	global $globalDebug, $globalNoImport;
135
-	if ($globalDebug) echo "Update last seen flights data...\n";
151
+	if ($globalDebug) {
152
+		echo "Update last seen flights data...\n";
153
+	}
136 154
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
137 155
 	    foreach ($this->all_flights as $key => $flight) {
138 156
 		if (isset($this->all_flights[$key]['id'])) {
139 157
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140 158
     		    $Spotter = new Spotter($this->db);
141 159
         	    $real_arrival = $this->arrival($key);
142
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
160
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) {
161
+        	    	$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']);
162
+        	    }
143 163
         	}
144 164
 	    }
145 165
 	}
@@ -147,24 +167,32 @@  discard block
 block discarded – undo
147 167
 
148 168
     public function arrival($key) {
149 169
 	global $globalClosestMinDist, $globalDebug;
150
-	if ($globalDebug) echo 'Update arrival...'."\n";
170
+	if ($globalDebug) {
171
+		echo 'Update arrival...'."\n";
172
+	}
151 173
 	$Spotter = new Spotter($this->db);
152 174
         $airport_icao = '';
153 175
         $airport_time = '';
154
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
176
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
177
+        	$globalClosestMinDist = 50;
178
+        }
155 179
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156 180
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157 181
     	    if (isset($closestAirports[0])) {
158 182
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159 183
         	    $airport_icao = $closestAirports[0]['icao'];
160 184
         	    $airport_time = $this->all_flights[$key]['datetime'];
161
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        	    if ($globalDebug) {
186
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
187
+        	    }
162 188
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
163 189
         	    foreach ($closestAirports as $airport) {
164 190
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
165 191
         		    $airport_icao = $airport['icao'];
166 192
         		    $airport_time = $this->all_flights[$key]['datetime'];
167
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
193
+        		    if ($globalDebug) {
194
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
195
+        		    }
168 196
         		    break;
169 197
         		}
170 198
         	    }
@@ -172,14 +200,20 @@  discard block
 block discarded – undo
172 200
         		$airport_icao = $closestAirports[0]['icao'];
173 201
         		$airport_time = $this->all_flights[$key]['datetime'];
174 202
         	} else {
175
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
203
+        		if ($globalDebug) {
204
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
205
+        		}
176 206
         	}
177 207
     	    } else {
178
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
208
+    		    if ($globalDebug) {
209
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
210
+    		    }
179 211
     	    }
180 212
 
181 213
         } else {
182
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
214
+        	if ($globalDebug) {
215
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
216
+        	}
183 217
         }
184 218
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185 219
     }
@@ -189,7 +223,9 @@  discard block
 block discarded – undo
189 223
     public function del() {
190 224
 	global $globalDebug, $globalNoImport, $globalNoDB;
191 225
 	// Delete old infos
192
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
226
+	if ($globalDebug) {
227
+		echo 'Delete old values and update latest data...'."\n";
228
+	}
193 229
 	foreach ($this->all_flights as $key => $flight) {
194 230
 	    if (isset($flight['lastupdate'])) {
195 231
 		if ($flight['lastupdate'] < (time()-5900)) {
@@ -203,13 +239,17 @@  discard block
 block discarded – undo
203 239
 	global $globalDebug, $globalNoImport, $globalNoDB;
204 240
 	// Delete old infos
205 241
 	if (isset($this->all_flights[$key]['id'])) {
206
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
242
+		if ($globalDebug) {
243
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
244
+		}
207 245
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
208 246
 			$real_arrival = $this->arrival($key);
209 247
 			$Spotter = new Spotter($this->db);
210 248
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
211 249
 				$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']);
212
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
250
+				if ($globalDebug && $result != 'success') {
251
+					echo '!!! ERROR : '.$result."\n";
252
+				}
213 253
 			}
214 254
 		}
215 255
 	}
@@ -219,9 +259,13 @@  discard block
 block discarded – undo
219 259
     public function add($line) {
220 260
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass;
221 261
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
222
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
223
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
224
-/*
262
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
263
+		$globalCoordMinChange = '0.01';
264
+	}
265
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
266
+		$globalAircraftMaxUpdate = 3000;
267
+	}
268
+	/*
225 269
 	$Spotter = new Spotter();
226 270
 	$dbc = $Spotter->db;
227 271
 	$SpotterLive = new SpotterLive($dbc);
@@ -243,19 +287,28 @@  discard block
 block discarded – undo
243 287
 	// SBS format is CSV format
244 288
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245 289
 	    //print_r($line);
246
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
290
+	    if (isset($line['hex'])) {
291
+	    	$line['hex'] = strtoupper($line['hex']);
292
+	    }
247 293
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
248 294
 
249 295
 		// Increment message number
250 296
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
251 297
 		    $current_date = date('Y-m-d');
252
-		    if (isset($line['source_name'])) $source = $line['source_name'];
253
-		    else $source = '';
254
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
298
+		    if (isset($line['source_name'])) {
299
+		    	$source = $line['source_name'];
300
+		    } else {
301
+		    	$source = '';
302
+		    }
303
+		    if ($source == '' || $line['format_source'] == 'aprs') {
304
+		    	$source = $line['format_source'];
305
+		    }
255 306
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
256 307
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
257 308
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
258
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
309
+		    } else {
310
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
311
+		    }
259 312
 		}
260 313
 		
261 314
 		/*
@@ -271,23 +324,38 @@  discard block
 block discarded – undo
271 324
 		//$this->db = $dbc;
272 325
 
273 326
 		//$hex = trim($line['hex']);
274
-	        if (!isset($line['id'])) $id = trim($line['hex']);
275
-	        else $id = trim($line['id']);
327
+	        if (!isset($line['id'])) {
328
+	        	$id = trim($line['hex']);
329
+	        } else {
330
+	        	$id = trim($line['id']);
331
+	        }
276 332
 		
277 333
 		if (!isset($this->all_flights[$id])) {
278
-		    if ($globalDebug) echo 'New flight...'."\n";
334
+		    if ($globalDebug) {
335
+		    	echo 'New flight...'."\n";
336
+		    }
279 337
 		    $this->all_flights[$id] = array();
280 338
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281 339
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
282
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
340
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
341
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
342
+		    }
283 343
 		    if (!isset($line['id'])) {
284
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285
-//			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')));
344
+			if (!isset($globalDaemon)) {
345
+				$globalDaemon = TRUE;
346
+			}
347
+			//			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')));
286 348
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
287
-			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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
349
+			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' || $line['format_source'] === 'famaprs')) {
350
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
351
+			}
288 352
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
353
+		     } else {
354
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
355
+		     }
356
+		    if ($globalAllFlights !== FALSE) {
357
+		    	$dataFound = true;
358
+		    }
291 359
 		}
292 360
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293 361
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -309,12 +377,20 @@  discard block
 block discarded – undo
309 377
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310 378
 			    }
311 379
 			    $Spotter->db = null;
312
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
380
+			    if ($globalDebugTimeElapsed) {
381
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
382
+			    }
383
+			    if ($aircraft_icao != '') {
384
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
385
+			    }
314 386
 			}
315 387
 		    }
316
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
317
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
388
+		    if ($globalAllFlights !== FALSE) {
389
+		    	$dataFound = true;
390
+		    }
391
+		    if ($globalDebug) {
392
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
393
+		    }
318 394
 		}
319 395
 	        if (isset($line['id']) && !isset($line['hex'])) {
320 396
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -323,7 +399,9 @@  discard block
 block discarded – undo
323 399
 			$icao = $line['aircraft_icao'];
324 400
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
325 401
 				$Spotter = new Spotter($this->db);
326
-				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
402
+				if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
403
+					$icao = $Spotter->aircraft_correct_icaotype[$icao];
404
+				}
327 405
 				$Spotter->db = null;
328 406
 			}
329 407
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
@@ -334,15 +412,24 @@  discard block
 block discarded – undo
334 412
 				$Spotter = new Spotter($this->db);
335 413
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
336 414
 				$Spotter->db = null;
337
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
415
+				if ($aircraft_icao != '') {
416
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
417
+				}
338 418
 			}
339 419
 		}
340 420
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
341
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
342
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
343
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
344
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
345
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
421
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
422
+				$aircraft_icao = 'GLID';
423
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
424
+				$aircraft_icao = 'UHEL';
425
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
426
+				$aircraft_icao = 'TOWPLANE';
427
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
428
+				$aircraft_icao = 'POWAIRC';
429
+			}
430
+			if (isset($aircraft_icao)) {
431
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
432
+			}
346 433
 		}
347 434
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
348 435
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -352,8 +439,11 @@  discard block
 block discarded – undo
352 439
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
353 440
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
354 441
 		    } else {
355
-				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";
356
-				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";
442
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
443
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
444
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
445
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
446
+				}
357 447
 				/*
358 448
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
359 449
 				print_r($this->all_flights[$id]);
@@ -362,16 +452,22 @@  discard block
 block discarded – undo
362 452
 				return '';
363 453
 		    }
364 454
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
365
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
455
+			if ($globalDebug) {
456
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
457
+			}
366 458
 			return '';
367 459
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
368
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
460
+			if ($globalDebug) {
461
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
462
+			}
369 463
 			return '';
370 464
 		} elseif (!isset($line['datetime'])) {
371 465
 			date_default_timezone_set('UTC');
372 466
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
373 467
 		} else {
374
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
468
+			if ($globalDebug) {
469
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
470
+			}
375 471
 			return '';
376 472
 		}
377 473
 
@@ -392,30 +488,48 @@  discard block
 block discarded – undo
392 488
 
393 489
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
394 490
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
395
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
491
+				if ($globalDebug) {
492
+					echo '---!!!! New ident, reset aircraft data...'."\n";
493
+				}
396 494
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
397 495
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
398
-				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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
399
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
400
-				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']));
496
+				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' || $line['format_source'] === 'famaprs')) {
497
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
498
+				} elseif (isset($line['id'])) {
499
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
500
+				} elseif (isset($this->all_flights[$id]['ident'])) {
501
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
502
+				}
401 503
 			} else {
402 504
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
403 505
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
404 506
 				$timeelapsed = microtime(true);
405 507
             			$Spotter = new Spotter($this->db);
406 508
             			$fromsource = NULL;
407
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
408
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
409
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
410
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
411
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
509
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
510
+            				$fromsource = $globalAirlinesSource;
511
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
512
+            				$fromsource = 'vatsim';
513
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
514
+					$fromsource = 'ivao';
515
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
516
+					$fromsource = 'vatsim';
517
+				} elseif (isset($globalIVAO) && $globalIVAO) {
518
+					$fromsource = 'ivao';
519
+				}
412 520
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
413
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
521
+				if ($globalDebug && $result != 'success') {
522
+					echo '!!! ERROR : '.$result."\n";
523
+				}
414 524
 				$Spotter->db = null;
415
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
525
+				if ($globalDebugTimeElapsed) {
526
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
527
+				}
416 528
 			    }
417 529
 			}
418
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
530
+		    } else {
531
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
532
+		    }
419 533
 		    
420 534
 /*
421 535
 		    if (!isset($line['id'])) {
@@ -425,7 +539,9 @@  discard block
 block discarded – undo
425 539
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
426 540
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
427 541
   */
428
-		    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']));
542
+		    if (!isset($this->all_flights[$id]['id'])) {
543
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
544
+		    }
429 545
 
430 546
 		    //$putinarchive = true;
431 547
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -443,7 +559,9 @@  discard block
 block discarded – undo
443 559
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
444 560
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
445 561
 		    		$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' => ''));
446
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
562
+				if ($globalDebugTimeElapsed) {
563
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
564
+				}
447 565
                         }
448 566
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
449 567
 			$timeelapsed = microtime(true);
@@ -457,7 +575,9 @@  discard block
 block discarded – undo
457 575
 				$Translation->db = null;
458 576
 			    }
459 577
 			    $Spotter->db = null;
460
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
578
+			    if ($globalDebugTimeElapsed) {
579
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
580
+			    }
461 581
                     	}
462 582
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
463 583
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -466,9 +586,13 @@  discard block
 block discarded – undo
466 586
 		    		$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']));
467 587
 		    	    }
468 588
 			}
469
-			if (!isset($globalFork)) $globalFork = TRUE;
589
+			if (!isset($globalFork)) {
590
+				$globalFork = TRUE;
591
+			}
470 592
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
471
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
593
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
594
+					$this->get_Schedule($id,trim($line['ident']));
595
+				}
472 596
 			}
473 597
 		    }
474 598
 		}
@@ -486,9 +610,13 @@  discard block
 block discarded – undo
486 610
 			$speed = $speed*3.6;
487 611
 			if ($speed < 1000) {
488 612
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
489
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
613
+	  			if ($globalDebug) {
614
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
615
+	  			}
490 616
 	  		} else {
491
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
617
+	  			if ($globalDebug) {
618
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
619
+	  			}
492 620
 	  		}
493 621
 		    }
494 622
 		}
@@ -497,13 +625,21 @@  discard block
 block discarded – undo
497 625
 
498 626
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
499 627
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
500
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
628
+	    	    	if ($globalDebug) {
629
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
630
+	    	    	}
501 631
 	    	    	return false;
502 632
 	    	    }
503
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
504
-	    	    else unset($timediff);
505
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
506
-	    	    else unset($timediff_archive);
633
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
634
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
635
+	    	    } else {
636
+	    	    	unset($timediff);
637
+	    	    }
638
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
639
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
640
+	    	    } else {
641
+	    	    	unset($timediff_archive);
642
+	    	    }
507 643
 	    	    if ($this->tmd > 5
508 644
 	    	        || (isset($line['format_source']) 
509 645
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -539,16 +675,25 @@  discard block
 block discarded – undo
539 675
 				$this->all_flights[$id]['putinarchive'] = true;
540 676
 				$this->tmd = 0;
541 677
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
542
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
678
+				    if ($globalDebug) {
679
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
680
+				    }
543 681
 				    $timeelapsed = microtime(true);
544 682
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
545 683
 					$Spotter = new Spotter($this->db);
546 684
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
547
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
548
-					else $this->all_flights[$id]['over_country'] = '';
685
+					if (!empty($all_country)) {
686
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
687
+					} else {
688
+						$this->all_flights[$id]['over_country'] = '';
689
+					}
549 690
 					$Spotter->db = null;
550
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
551
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
691
+					if ($globalDebugTimeElapsed) {
692
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
693
+					}
694
+					if ($globalDebug) {
695
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
696
+					}
552 697
 				    }
553 698
 				}
554 699
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -594,7 +739,9 @@  discard block
 block discarded – undo
594 739
 			    */
595 740
 			}
596 741
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
597
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
742
+			    if ($line['longitude'] > 180) {
743
+			    	$line['longitude'] = $line['longitude'] - 360;
744
+			    }
598 745
 			    //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) {
599 746
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
600 747
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -631,7 +778,9 @@  discard block
 block discarded – undo
631 778
 		    }
632 779
 		}
633 780
 		if (isset($line['last_update']) && $line['last_update'] != '') {
634
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
781
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
782
+		    	$dataFound = true;
783
+		    }
635 784
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
636 785
 		}
637 786
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -653,35 +802,53 @@  discard block
 block discarded – undo
653 802
 			// Here we force archive of flight because after ground it's a new one (or should be)
654 803
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
655 804
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
656
-			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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
657
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
658
-			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']));
805
+			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' || $line['format_source'] === 'famaprs')) {
806
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
807
+			} elseif (isset($line['id'])) {
808
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
809
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
810
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
811
+			}
812
+		    }
813
+		    if ($line['ground'] != 1) {
814
+		    	$line['ground'] = 0;
659 815
 		    }
660
-		    if ($line['ground'] != 1) $line['ground'] = 0;
661 816
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
662 817
 		    //$dataFound = true;
663 818
 		}
664 819
 		if (isset($line['squawk']) && $line['squawk'] != '') {
665 820
 		    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'])) {
666
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
821
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
822
+			    	$this->all_flights[$id]['putinarchive'] = true;
823
+			    }
667 824
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
668 825
 			    $highlight = '';
669
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
670
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
671
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
826
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
827
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
828
+			    }
829
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
830
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
831
+			    }
832
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
833
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
834
+			    }
672 835
 			    if ($highlight != '') {
673 836
 				$timeelapsed = microtime(true);
674 837
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
675 838
 				    $Spotter = new Spotter($this->db);
676 839
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
677 840
 				    $Spotter->db = null;
678
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
841
+				    if ($globalDebugTimeElapsed) {
842
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
843
+				    }
679 844
 				}
680 845
 				//$putinarchive = true;
681 846
 				//$highlight = '';
682 847
 			    }
683 848
 			    
684
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
849
+		    } else {
850
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
851
+		    }
685 852
 		    //$dataFound = true;
686 853
 		}
687 854
 
@@ -694,19 +861,27 @@  discard block
 block discarded – undo
694 861
 				}
695 862
 			}
696 863
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
697
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
864
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
865
+				$this->all_flights[$id]['putinarchive'] = true;
866
+			}
698 867
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
699 868
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
700 869
 			//$dataFound = true;
701 870
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
702 871
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
703 872
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
704
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
873
+				if ($globalDebug) {
874
+					echo '--- Reset because of altitude'."\n";
875
+				}
705 876
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
706 877
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
707
-				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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
708
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
709
-				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']));
878
+				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' || $line['format_source'] === 'famaprs')) {
879
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
880
+				} elseif (isset($line['id'])) {
881
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
882
+				} elseif (isset($this->all_flights[$id]['ident'])) {
883
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
884
+				}
710 885
 			}
711 886
 		    }
712 887
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -717,22 +892,32 @@  discard block
 block discarded – undo
717 892
 		}
718 893
 		
719 894
 		if (isset($line['heading']) && $line['heading'] != '') {
720
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
895
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
896
+		    	$this->all_flights[$id]['putinarchive'] = true;
897
+		    }
721 898
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
722 899
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
723 900
 		    //$dataFound = true;
724 901
   		} 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']) {
725 902
   		    $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']);
726 903
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
727
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
728
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
904
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
905
+		    	$this->all_flights[$id]['putinarchive'] = true;
906
+		    }
907
+  		    if ($globalDebug) {
908
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
909
+  		    }
729 910
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
730 911
   		    // If not enough messages and ACARS set heading to 0
731 912
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
732 913
   		}
733
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
734
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
735
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
914
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
915
+			$dataFound = false;
916
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
917
+			$dataFound = false;
918
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) {
919
+			$dataFound = false;
920
+		}
736 921
 
737 922
 //		print_r($this->all_flights[$id]);
738 923
 		//gets the callsign from the last hour
@@ -749,23 +934,38 @@  discard block
 block discarded – undo
749 934
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
750 935
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
751 936
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
752
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
937
+				    if ($globalDebug) {
938
+				    	echo "Check if aircraft is already in DB...";
939
+				    }
753 940
 				    $timeelapsed = microtime(true);
754 941
 				    $SpotterLive = new SpotterLive($this->db);
755 942
 				    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' || $line['format_source'] === 'famaprs')) {
756 943
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
757
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
944
+					if ($globalDebugTimeElapsed) {
945
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
946
+					}
758 947
 				    } elseif (isset($line['id'])) {
759 948
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
760
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
949
+					if ($globalDebugTimeElapsed) {
950
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
951
+					}
761 952
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
762 953
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
763
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
764
-				    } else $recent_ident = '';
954
+					if ($globalDebugTimeElapsed) {
955
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
956
+					}
957
+				    } else {
958
+				    	$recent_ident = '';
959
+				    }
765 960
 				    $SpotterLive->db=null;
766
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
767
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
768
-				} else $recent_ident = '';
961
+				    if ($globalDebug && $recent_ident == '') {
962
+				    	echo " Not in DB.\n";
963
+				    } elseif ($globalDebug && $recent_ident != '') {
964
+				    	echo " Already in DB.\n";
965
+				    }
966
+				} else {
967
+					$recent_ident = '';
968
+				}
769 969
 			    } else {
770 970
 				$recent_ident = '';
771 971
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -773,7 +973,9 @@  discard block
 block discarded – undo
773 973
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
774 974
 			    if($recent_ident == "")
775 975
 			    {
776
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
976
+				if ($globalDebug) {
977
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
978
+				}
777 979
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
778 980
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
779 981
 				//adds the spotter data for the archive
@@ -817,31 +1019,49 @@  discard block
 block discarded – undo
817 1019
 				
818 1020
 				if (!$ignoreImport) {
819 1021
 				    $highlight = '';
820
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
821
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
822
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
823
-				    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')));
1022
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1023
+				    	$highlight = 'Squawk 7500 : Hijack';
1024
+				    }
1025
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1026
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1027
+				    }
1028
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1029
+				    	$highlight = 'Squawk 7700 : Emergency';
1030
+				    }
1031
+				    if (!isset($this->all_flights[$id]['id'])) {
1032
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1033
+				    }
824 1034
 				    $timeelapsed = microtime(true);
825 1035
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
826 1036
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
827 1037
 					    $Spotter = new Spotter($this->db);
828 1038
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
829 1039
 					    $Spotter->db = null;
830
-					    if ($globalDebug && isset($result)) echo $result."\n";
1040
+					    if ($globalDebug && isset($result)) {
1041
+					    	echo $result."\n";
1042
+					    }
831 1043
 					}
832 1044
 				    }
833
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1045
+				    if ($globalDebugTimeElapsed) {
1046
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1047
+				    }
834 1048
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
835 1049
 
836 1050
 				    // Add source stat in DB
837 1051
 				    $Stats = new Stats($this->db);
838 1052
 				    if (!empty($this->stats)) {
839
-					if ($globalDebug) echo 'Add source stats : ';
1053
+					if ($globalDebug) {
1054
+						echo 'Add source stats : ';
1055
+					}
840 1056
 				        foreach($this->stats as $date => $data) {
841 1057
 					    foreach($data as $source => $sourced) {
842 1058
 					        //print_r($sourced);
843
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
844
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1059
+				    	        if (isset($sourced['polar'])) {
1060
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1061
+				    	        }
1062
+				    	        if (isset($sourced['hist'])) {
1063
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1064
+				    	        }
845 1065
 				    		if (isset($sourced['msg'])) {
846 1066
 				    		    if (time() - $sourced['msg']['date'] > 10) {
847 1067
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -854,13 +1074,17 @@  discard block
 block discarded – undo
854 1074
 			    			unset($this->stats[$date]);
855 1075
 			    		    }
856 1076
 				    	}
857
-				    	if ($globalDebug) echo 'Done'."\n";
1077
+				    	if ($globalDebug) {
1078
+				    		echo 'Done'."\n";
1079
+				    	}
858 1080
 
859 1081
 				    }
860 1082
 				    $Stats->db = null;
861 1083
 				    }
862 1084
 				    $this->del();
863
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1085
+				} elseif ($globalDebug) {
1086
+					echo 'Ignore data'."\n";
1087
+				}
864 1088
 				//$ignoreImport = false;
865 1089
 				$this->all_flights[$id]['addedSpotter'] = 1;
866 1090
 				//print_r($this->all_flights[$id]);
@@ -877,7 +1101,9 @@  discard block
 block discarded – undo
877 1101
 			*/
878 1102
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
879 1103
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
880
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1104
+				    if ($globalDebug) {
1105
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1106
+				    }
881 1107
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
882 1108
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
883 1109
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -886,7 +1112,9 @@  discard block
 block discarded – undo
886 1112
 					    $SpotterLive->db=null;
887 1113
 					}
888 1114
 				    }
889
-				    if ($globalDebug) echo " Done\n";
1115
+				    if ($globalDebug) {
1116
+				    	echo " Done\n";
1117
+				    }
890 1118
 				    $this->last_delete = time();
891 1119
 				}
892 1120
 			    } else {
@@ -913,11 +1141,17 @@  discard block
 block discarded – undo
913 1141
 		    //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";
914 1142
 		    if ($globalDebug) {
915 1143
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
916
-				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";
917
-				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";
1144
+				if (isset($this->all_flights[$id]['source_name'])) {
1145
+					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";
1146
+				} else {
1147
+					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";
1148
+				}
918 1149
 			} else {
919
-				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";
920
-				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";
1150
+				if (isset($this->all_flights[$id]['source_name'])) {
1151
+					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";
1152
+				} else {
1153
+					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";
1154
+				}
921 1155
 			}
922 1156
 		    }
923 1157
 		    $ignoreImport = false;
@@ -963,22 +1197,30 @@  discard block
 block discarded – undo
963 1197
 
964 1198
 		    if (!$ignoreImport) {
965 1199
 			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'])) {
966
-				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')));
1200
+				if (!isset($this->all_flights[$id]['id'])) {
1201
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1202
+				}
967 1203
 				$timeelapsed = microtime(true);
968 1204
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
969 1205
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
970
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1206
+					if ($globalDebug) {
1207
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1208
+					}
971 1209
 					$SpotterLive = new SpotterLive($this->db);
972 1210
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
973 1211
 					$SpotterLive->db = null;
974
-					if ($globalDebug) echo $result."\n";
1212
+					if ($globalDebug) {
1213
+						echo $result."\n";
1214
+					}
975 1215
 				    }
976 1216
 				}
977 1217
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
978 1218
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
979 1219
 				}
980 1220
 				$this->all_flights[$id]['putinarchive'] = false;
981
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1221
+				if ($globalDebugTimeElapsed) {
1222
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1223
+				}
982 1224
 
983 1225
 				// Put statistics in $this->stats variable
984 1226
 				//if ($line['format_source'] != 'aprs') {
@@ -986,7 +1228,9 @@  discard block
 block discarded – undo
986 1228
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
987 1229
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
988 1230
 					$source = $this->all_flights[$id]['source_name'];
989
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1231
+					if ($source == '') {
1232
+						$source = $this->all_flights[$id]['format_source'];
1233
+					}
990 1234
 					if (!isset($this->source_location[$source])) {
991 1235
 						$Location = new Source($this->db);
992 1236
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -1007,7 +1251,9 @@  discard block
 block discarded – undo
1007 1251
 					$stats_heading = round($stats_heading/22.5);
1008 1252
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1009 1253
 					$current_date = date('Y-m-d');
1010
-					if ($stats_heading == 16) $stats_heading = 0;
1254
+					if ($stats_heading == 16) {
1255
+						$stats_heading = 0;
1256
+					}
1011 1257
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1012 1258
 						for ($i=0;$i<=15;$i++) {
1013 1259
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1025,7 +1271,9 @@  discard block
 block discarded – undo
1025 1271
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1026 1272
 						    end($this->stats[$current_date][$source]['hist']);
1027 1273
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1028
-						} else $mini = 0;
1274
+						} else {
1275
+							$mini = 0;
1276
+						}
1029 1277
 						for ($i=$mini;$i<=$distance;$i+=10) {
1030 1278
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1031 1279
 						}
@@ -1037,19 +1285,27 @@  discard block
 block discarded – undo
1037 1285
 				}
1038 1286
 
1039 1287
 				$this->all_flights[$id]['lastupdate'] = time();
1040
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1288
+				if ($this->all_flights[$id]['putinarchive']) {
1289
+					$send = true;
1290
+				}
1041 1291
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1042
-			} 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";
1292
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1293
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1294
+			}
1043 1295
 			//$this->del();
1044 1296
 			
1045 1297
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1046 1298
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1047
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1299
+				if ($globalDebug) {
1300
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1301
+				}
1048 1302
 				$SpotterLive = new SpotterLive($this->db);
1049 1303
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1050 1304
 				$SpotterLive->db = null;
1051 1305
 				//SpotterLive->deleteLiveSpotterData();
1052
-				if ($globalDebug) echo " Done\n";
1306
+				if ($globalDebug) {
1307
+					echo " Done\n";
1308
+				}
1053 1309
 				$this->last_delete_hourly = time();
1054 1310
 			    } else {
1055 1311
 				$this->del();
@@ -1061,7 +1317,9 @@  discard block
 block discarded – undo
1061 1317
 		    //$ignoreImport = false;
1062 1318
 		}
1063 1319
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1064
-		if ($send) return $this->all_flights[$id];
1320
+		if ($send) {
1321
+			return $this->all_flights[$id];
1322
+		}
1065 1323
 	    }
1066 1324
 	}
1067 1325
     }
Please login to merge, or discard this patch.
sitemap.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,9 @@  discard block
 block discarded – undo
34 34
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
35 35
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
36 36
 		$aircraft_types = $Stats->getAllAircraftTypes();
37
-		if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
37
+		if (empty($aircraft_types)) {
38
+			$aircraft_types = $Spotter->getAllAircraftTypes();
39
+		}
38 40
 		foreach($aircraft_types as $aircraft_item)
39 41
 		{
40 42
 			$output .= '<url>';
@@ -84,7 +86,9 @@  discard block
 block discarded – undo
84 86
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
85 87
 
86 88
 		$airport_names = $Stats->getAllAirportNames();
87
-		if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
89
+		if (empty($airport_names)) {
90
+			$airport_names = $Spotter->getAllAirportNames();
91
+		}
88 92
 		foreach($airport_names as $airport_item)
89 93
 		{
90 94
 			$output .= '<url>';
@@ -99,7 +103,9 @@  discard block
 block discarded – undo
99 103
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
100 104
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
101 105
 	$manufacturer_names = $Stats->getAllManufacturers();
102
-	if (empty($manufacturer_names)) $manufacturer_names = $Spotter->getAllManufacturers();
106
+	if (empty($manufacturer_names)) {
107
+		$manufacturer_names = $Spotter->getAllManufacturers();
108
+	}
103 109
 	foreach($manufacturer_names as $manufacturer_item)
104 110
 	{
105 111
 		$output .= '<url>';
Please login to merge, or discard this patch.
statistics-country.php 1 patch
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,7 +4,9 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Language.php');
5 5
 $Stats = new Stats();
6 6
 
7
-if (!isset($filter_name)) $filter_name = '';
7
+if (!isset($filter_name)) {
8
+	$filter_name = '';
9
+}
8 10
 $type = 'aircraft';
9 11
 if (isset($_GET['marine'])) {
10 12
 	$type = 'marine';
@@ -21,8 +23,10 @@  discard block
 block discarded – undo
21 23
 }
22 24
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
23 25
 if ($airline_icao == '' && isset($globalFilter)) {
24
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25
-}
26
+    if (isset($globalFilter['airline'])) {
27
+    	$airline_icao = $globalFilter['airline'][0];
28
+    }
29
+    }
26 30
 
27 31
 require_once('header.php');
28 32
 include('statistics-sub-menu.php'); 
@@ -64,10 +68,14 @@  discard block
 block discarded – undo
64 68
 $flightover_data = '';
65 69
 foreach($flightover_array as $flightover_item)
66 70
 {
67
-	if ($type == 'aircraft') $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
68
-	elseif ($type == 'marine') $flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
69
-	elseif ($type == 'tracker') $flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
70
-}
71
+	if ($type == 'aircraft') {
72
+		$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
73
+	} elseif ($type == 'marine') {
74
+		$flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
75
+	} elseif ($type == 'tracker') {
76
+		$flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
77
+	}
78
+	}
71 79
 $flightover_data = substr($flightover_data, 0, -1);
72 80
 print $flightover_data;
73 81
 print '];';
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +457 added lines, -168 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -803,12 +855,16 @@  discard block
 block discarded – undo
803 855
 		if ($globalDBdriver == 'mysql') {
804 856
 			if (!$Connection->tableExists('tle')) {
805 857
 				$error .= create_db::import_file('../db/tle.sql');
806
-				if ($error != '') return $error;
858
+				if ($error != '') {
859
+					return $error;
860
+				}
807 861
 			}
808 862
 		} else {
809 863
 			if (!$Connection->tableExists('tle')) {
810 864
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
811
-				if ($error != '') return $error;
865
+				if ($error != '') {
866
+					return $error;
867
+				}
812 868
 			}
813 869
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
814 870
 			try {
@@ -848,7 +904,9 @@  discard block
 block discarded – undo
848 904
 		} else {
849 905
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 906
 		}
851
-		if ($error != '') return 'Import airlines.sql : '.$error;
907
+		if ($error != '') {
908
+			return 'Import airlines.sql : '.$error;
909
+		}
852 910
 		if (!$Connection->checkColumnName('airlines','forsource')) {
853 911
 			// Add forsource to airlines
854 912
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1331,20 +1389,28 @@  discard block
 block discarded – undo
1331 1389
 		}
1332 1390
 		if ($globalDBdriver == 'mysql') {
1333 1391
 			$error .= create_db::import_file('../db/airlines.sql');
1334
-			if ($error != '') return $error;
1392
+			if ($error != '') {
1393
+				return $error;
1394
+			}
1335 1395
 		} else {
1336 1396
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1337
-			if ($error != '') return $error;
1397
+			if ($error != '') {
1398
+				return $error;
1399
+			}
1338 1400
 		}
1339 1401
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1340 1402
 			include_once(dirname(__FILE__).'/class.update_db.php');
1341 1403
 			if (isset($globalVATSIM) && $globalVATSIM) {
1342 1404
 				$error .= update_db::update_vatsim();
1343
-				if ($error != '') return $error;
1405
+				if ($error != '') {
1406
+					return $error;
1407
+				}
1344 1408
 			}
1345 1409
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1346 1410
 				$error .= update_db::update_IVAO();
1347
-				if ($error != '') return $error;
1411
+				if ($error != '') {
1412
+					return $error;
1413
+				}
1348 1414
 			}
1349 1415
 		}
1350 1416
 
@@ -1607,41 +1673,65 @@  discard block
 block discarded – undo
1607 1673
 		if ($globalDBdriver == 'mysql') {
1608 1674
 			if (!$Connection->tableExists('tracker_output')) {
1609 1675
 				$error .= create_db::import_file('../db/tracker_output.sql');
1610
-				if ($error != '') return $error;
1676
+				if ($error != '') {
1677
+					return $error;
1678
+				}
1611 1679
 			}
1612 1680
 			if (!$Connection->tableExists('tracker_live')) {
1613 1681
 				$error .= create_db::import_file('../db/tracker_live.sql');
1614
-				if ($error != '') return $error;
1682
+				if ($error != '') {
1683
+					return $error;
1684
+				}
1615 1685
 			}
1616 1686
 			if (!$Connection->tableExists('marine_output')) {
1617 1687
 				$error .= create_db::import_file('../db/marine_output.sql');
1618
-				if ($error != '') return $error;
1688
+				if ($error != '') {
1689
+					return $error;
1690
+				}
1619 1691
 			}
1620 1692
 			if (!$Connection->tableExists('marine_live')) {
1621 1693
 				$error .= create_db::import_file('../db/marine_live.sql');
1622
-				if ($error != '') return $error;
1694
+				if ($error != '') {
1695
+					return $error;
1696
+				}
1623 1697
 			}
1624 1698
 			if (!$Connection->tableExists('marine_identity')) {
1625 1699
 				$error .= create_db::import_file('../db/marine_identity.sql');
1626
-				if ($error != '') return $error;
1700
+				if ($error != '') {
1701
+					return $error;
1702
+				}
1627 1703
 			}
1628 1704
 			if (!$Connection->tableExists('marine_mid')) {
1629 1705
 				$error .= create_db::import_file('../db/marine_mid.sql');
1630
-				if ($error != '') return $error;
1706
+				if ($error != '') {
1707
+					return $error;
1708
+				}
1631 1709
 			}
1632 1710
 		} else {
1633 1711
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1634
-			if ($error != '') return $error;
1712
+			if ($error != '') {
1713
+				return $error;
1714
+			}
1635 1715
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1636
-			if ($error != '') return $error;
1716
+			if ($error != '') {
1717
+				return $error;
1718
+			}
1637 1719
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1638
-			if ($error != '') return $error;
1720
+			if ($error != '') {
1721
+				return $error;
1722
+			}
1639 1723
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1640
-			if ($error != '') return $error;
1724
+			if ($error != '') {
1725
+				return $error;
1726
+			}
1641 1727
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1642
-			if ($error != '') return $error;
1728
+			if ($error != '') {
1729
+				return $error;
1730
+			}
1643 1731
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1644
-			if ($error != '') return $error;
1732
+			if ($error != '') {
1733
+				return $error;
1734
+			}
1645 1735
 		}
1646 1736
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1647 1737
 		try {
@@ -1660,39 +1750,61 @@  discard block
 block discarded – undo
1660 1750
 		if ($globalDBdriver == 'mysql') {
1661 1751
 			if (!$Connection->tableExists('marine_image')) {
1662 1752
 				$error .= create_db::import_file('../db/marine_image.sql');
1663
-				if ($error != '') return $error;
1753
+				if ($error != '') {
1754
+					return $error;
1755
+				}
1664 1756
 			}
1665 1757
 			if (!$Connection->tableExists('marine_archive')) {
1666 1758
 				$error .= create_db::import_file('../db/marine_archive.sql');
1667
-				if ($error != '') return $error;
1759
+				if ($error != '') {
1760
+					return $error;
1761
+				}
1668 1762
 			}
1669 1763
 			if (!$Connection->tableExists('marine_archive_output')) {
1670 1764
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1671
-				if ($error != '') return $error;
1765
+				if ($error != '') {
1766
+					return $error;
1767
+				}
1672 1768
 			}
1673 1769
 			if (!$Connection->tableExists('tracker_archive')) {
1674 1770
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1675
-				if ($error != '') return $error;
1771
+				if ($error != '') {
1772
+					return $error;
1773
+				}
1676 1774
 			}
1677 1775
 			if (!$Connection->tableExists('tracker_archive_output')) {
1678 1776
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1679
-				if ($error != '') return $error;
1777
+				if ($error != '') {
1778
+					return $error;
1779
+				}
1680 1780
 			}
1681 1781
 			if (!$Connection->tableExists('marine_archive_output')) {
1682 1782
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1683
-				if ($error != '') return $error;
1783
+				if ($error != '') {
1784
+					return $error;
1785
+				}
1684 1786
 			}
1685 1787
 		} else {
1686 1788
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1687
-			if ($error != '') return $error;
1789
+			if ($error != '') {
1790
+				return $error;
1791
+			}
1688 1792
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1689
-			if ($error != '') return $error;
1793
+			if ($error != '') {
1794
+				return $error;
1795
+			}
1690 1796
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1691
-			if ($error != '') return $error;
1797
+			if ($error != '') {
1798
+				return $error;
1799
+			}
1692 1800
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1693
-			if ($error != '') return $error;
1801
+			if ($error != '') {
1802
+				return $error;
1803
+			}
1694 1804
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1695
-			if ($error != '') return $error;
1805
+			if ($error != '') {
1806
+				return $error;
1807
+			}
1696 1808
 		}
1697 1809
 		if ($globalDBdriver == 'mysql') {
1698 1810
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2063,7 +2175,9 @@  discard block
 block discarded – undo
2063 2175
 		if ($globalDBdriver == 'mysql') {
2064 2176
 			if (!$Connection->tableExists('tracker_archive_output')) {
2065 2177
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2066
-				if ($error != '') return $error;
2178
+				if ($error != '') {
2179
+					return $error;
2180
+				}
2067 2181
 			}
2068 2182
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2069 2183
 		} else {
@@ -2091,14 +2205,22 @@  discard block
 block discarded – undo
2091 2205
 		$error = '';
2092 2206
 		if ($globalDBdriver == 'mysql') {
2093 2207
 			$error .= create_db::import_file('../db/airport.sql');
2094
-			if ($error != '') return $error;
2208
+			if ($error != '') {
2209
+				return $error;
2210
+			}
2095 2211
 			$error .= create_db::import_file('../db/airlines.sql');
2096
-			if ($error != '') return $error;
2212
+			if ($error != '') {
2213
+				return $error;
2214
+			}
2097 2215
 		} else {
2098 2216
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2099
-			if ($error != '') return $error;
2217
+			if ($error != '') {
2218
+				return $error;
2219
+			}
2100 2220
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2101
-			if ($error != '') return $error;
2221
+			if ($error != '') {
2222
+				return $error;
2223
+			}
2102 2224
 		}
2103 2225
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2104 2226
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2115,7 +2237,9 @@  discard block
 block discarded – undo
2115 2237
 				$error .= update_db::update_vatsim();
2116 2238
 			}
2117 2239
 		}
2118
-		if ($error != '') return $error;
2240
+		if ($error != '') {
2241
+			return $error;
2242
+		}
2119 2243
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2120 2244
 		try {
2121 2245
 			$sth = $Connection->db->prepare($query);
@@ -2133,10 +2257,14 @@  discard block
 block discarded – undo
2133 2257
 		if (!$Connection->tableExists('satellite')) {
2134 2258
 			if ($globalDBdriver == 'mysql') {
2135 2259
 				$error .= create_db::import_file('../db/satellite.sql');
2136
-				if ($error != '') return $error;
2260
+				if ($error != '') {
2261
+					return $error;
2262
+				}
2137 2263
 			} else {
2138 2264
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2139
-				if ($error != '') return $error;
2265
+				if ($error != '') {
2266
+					return $error;
2267
+				}
2140 2268
 			}
2141 2269
 		}
2142 2270
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2156,37 +2284,53 @@  discard block
 block discarded – undo
2156 2284
 		if (!$Connection->tableExists('stats_marine')) {
2157 2285
 			if ($globalDBdriver == 'mysql') {
2158 2286
 				$error .= create_db::import_file('../db/stats_marine.sql');
2159
-				if ($error != '') return $error;
2287
+				if ($error != '') {
2288
+					return $error;
2289
+				}
2160 2290
 			} else {
2161 2291
 				$error .= create_db::import_file('../db/pgsql/stats_marine.sql');
2162
-				if ($error != '') return $error;
2292
+				if ($error != '') {
2293
+					return $error;
2294
+				}
2163 2295
 			}
2164 2296
 		}
2165 2297
 		if (!$Connection->tableExists('stats_marine_country')) {
2166 2298
 			if ($globalDBdriver == 'mysql') {
2167 2299
 				$error .= create_db::import_file('../db/stats_marine_country.sql');
2168
-				if ($error != '') return $error;
2300
+				if ($error != '') {
2301
+					return $error;
2302
+				}
2169 2303
 			} else {
2170 2304
 				$error .= create_db::import_file('../db/pgsql/stats_marine_country.sql');
2171
-				if ($error != '') return $error;
2305
+				if ($error != '') {
2306
+					return $error;
2307
+				}
2172 2308
 			}
2173 2309
 		}
2174 2310
 		if (!$Connection->tableExists('stats_tracker')) {
2175 2311
 			if ($globalDBdriver == 'mysql') {
2176 2312
 				$error .= create_db::import_file('../db/stats_tracker.sql');
2177
-				if ($error != '') return $error;
2313
+				if ($error != '') {
2314
+					return $error;
2315
+				}
2178 2316
 			} else {
2179 2317
 				$error .= create_db::import_file('../db/pgsql/stats_tracker.sql');
2180
-				if ($error != '') return $error;
2318
+				if ($error != '') {
2319
+					return $error;
2320
+				}
2181 2321
 			}
2182 2322
 		}
2183 2323
 		if (!$Connection->tableExists('stats_tracker_country')) {
2184 2324
 			if ($globalDBdriver == 'mysql') {
2185 2325
 				$error .= create_db::import_file('../db/stats_tracker_country.sql');
2186
-				if ($error != '') return $error;
2326
+				if ($error != '') {
2327
+					return $error;
2328
+				}
2187 2329
 			} else {
2188 2330
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql');
2189
-				if ($error != '') return $error;
2331
+				if ($error != '') {
2332
+					return $error;
2333
+				}
2190 2334
 			}
2191 2335
 		}
2192 2336
 		$query = "UPDATE config SET value = '47' WHERE name = 'schema_version'";
@@ -2209,8 +2353,11 @@  discard block
 block discarded – undo
2209 2353
 			if ($Connection->tableExists('aircraft')) {
2210 2354
 				if (!$Connection->tableExists('config')) {
2211 2355
 					$version = '1';
2212
-					if ($update) return self::update_from_1();
2213
-					else return $version;
2356
+					if ($update) {
2357
+						return self::update_from_1();
2358
+					} else {
2359
+						return $version;
2360
+					}
2214 2361
 				} else {
2215 2362
 					$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2216 2363
 					try {
@@ -2223,191 +2370,333 @@  discard block
 block discarded – undo
2223 2370
 					if ($update) {
2224 2371
 						if ($result['value'] == '2') {
2225 2372
 							$error = self::update_from_2();
2226
-							if ($error != '') return $error;
2227
-							else return self::check_version(true);
2373
+							if ($error != '') {
2374
+								return $error;
2375
+							} else {
2376
+								return self::check_version(true);
2377
+							}
2228 2378
 						} elseif ($result['value'] == '3') {
2229 2379
 							$error = self::update_from_3();
2230
-							if ($error != '') return $error;
2231
-							else return self::check_version(true);
2380
+							if ($error != '') {
2381
+								return $error;
2382
+							} else {
2383
+								return self::check_version(true);
2384
+							}
2232 2385
 						} elseif ($result['value'] == '4') {
2233 2386
 							$error = self::update_from_4();
2234
-							if ($error != '') return $error;
2235
-							else return self::check_version(true);
2387
+							if ($error != '') {
2388
+								return $error;
2389
+							} else {
2390
+								return self::check_version(true);
2391
+							}
2236 2392
 						} elseif ($result['value'] == '5') {
2237 2393
 							$error = self::update_from_5();
2238
-							if ($error != '') return $error;
2239
-							else return self::check_version(true);
2394
+							if ($error != '') {
2395
+								return $error;
2396
+							} else {
2397
+								return self::check_version(true);
2398
+							}
2240 2399
 						} elseif ($result['value'] == '6') {
2241 2400
 							$error = self::update_from_6();
2242
-							if ($error != '') return $error;
2243
-							else return self::check_version(true);
2401
+							if ($error != '') {
2402
+								return $error;
2403
+							} else {
2404
+								return self::check_version(true);
2405
+							}
2244 2406
 						} elseif ($result['value'] == '7') {
2245 2407
 							$error = self::update_from_7();
2246
-							if ($error != '') return $error;
2247
-							else return self::check_version(true);
2408
+							if ($error != '') {
2409
+								return $error;
2410
+							} else {
2411
+								return self::check_version(true);
2412
+							}
2248 2413
 						} elseif ($result['value'] == '8') {
2249 2414
 							$error = self::update_from_8();
2250
-							if ($error != '') return $error;
2251
-							else return self::check_version(true);
2415
+							if ($error != '') {
2416
+								return $error;
2417
+							} else {
2418
+								return self::check_version(true);
2419
+							}
2252 2420
 						} elseif ($result['value'] == '9') {
2253 2421
 							$error = self::update_from_9();
2254
-							if ($error != '') return $error;
2255
-							else return self::check_version(true);
2422
+							if ($error != '') {
2423
+								return $error;
2424
+							} else {
2425
+								return self::check_version(true);
2426
+							}
2256 2427
 						} elseif ($result['value'] == '10') {
2257 2428
 							$error = self::update_from_10();
2258
-							if ($error != '') return $error;
2259
-							else return self::check_version(true);
2429
+							if ($error != '') {
2430
+								return $error;
2431
+							} else {
2432
+								return self::check_version(true);
2433
+							}
2260 2434
 						} elseif ($result['value'] == '11') {
2261 2435
 							$error = self::update_from_11();
2262
-							if ($error != '') return $error;
2263
-							else return self::check_version(true);
2436
+							if ($error != '') {
2437
+								return $error;
2438
+							} else {
2439
+								return self::check_version(true);
2440
+							}
2264 2441
 						} elseif ($result['value'] == '12') {
2265 2442
 							$error = self::update_from_12();
2266
-							if ($error != '') return $error;
2267
-							else return self::check_version(true);
2443
+							if ($error != '') {
2444
+								return $error;
2445
+							} else {
2446
+								return self::check_version(true);
2447
+							}
2268 2448
 						} elseif ($result['value'] == '13') {
2269 2449
 							$error = self::update_from_13();
2270
-							if ($error != '') return $error;
2271
-							else return self::check_version(true);
2450
+							if ($error != '') {
2451
+								return $error;
2452
+							} else {
2453
+								return self::check_version(true);
2454
+							}
2272 2455
 						} elseif ($result['value'] == '14') {
2273 2456
 							$error = self::update_from_14();
2274
-							if ($error != '') return $error;
2275
-							else return self::check_version(true);
2457
+							if ($error != '') {
2458
+								return $error;
2459
+							} else {
2460
+								return self::check_version(true);
2461
+							}
2276 2462
 						} elseif ($result['value'] == '15') {
2277 2463
 							$error = self::update_from_15();
2278
-							if ($error != '') return $error;
2279
-							else return self::check_version(true);
2464
+							if ($error != '') {
2465
+								return $error;
2466
+							} else {
2467
+								return self::check_version(true);
2468
+							}
2280 2469
 						} elseif ($result['value'] == '16') {
2281 2470
 							$error = self::update_from_16();
2282
-							if ($error != '') return $error;
2283
-							else return self::check_version(true);
2471
+							if ($error != '') {
2472
+								return $error;
2473
+							} else {
2474
+								return self::check_version(true);
2475
+							}
2284 2476
 						} elseif ($result['value'] == '17') {
2285 2477
 							$error = self::update_from_17();
2286
-							if ($error != '') return $error;
2287
-							else return self::check_version(true);
2478
+							if ($error != '') {
2479
+								return $error;
2480
+							} else {
2481
+								return self::check_version(true);
2482
+							}
2288 2483
 						} elseif ($result['value'] == '18') {
2289 2484
 							$error = self::update_from_18();
2290
-							if ($error != '') return $error;
2291
-							else return self::check_version(true);
2485
+							if ($error != '') {
2486
+								return $error;
2487
+							} else {
2488
+								return self::check_version(true);
2489
+							}
2292 2490
 						} elseif ($result['value'] == '19') {
2293 2491
 							$error = self::update_from_19();
2294
-							if ($error != '') return $error;
2295
-							else return self::check_version(true);
2492
+							if ($error != '') {
2493
+								return $error;
2494
+							} else {
2495
+								return self::check_version(true);
2496
+							}
2296 2497
 						} elseif ($result['value'] == '20') {
2297 2498
 							$error = self::update_from_20();
2298
-							if ($error != '') return $error;
2299
-							else return self::check_version(true);
2499
+							if ($error != '') {
2500
+								return $error;
2501
+							} else {
2502
+								return self::check_version(true);
2503
+							}
2300 2504
 						} elseif ($result['value'] == '21') {
2301 2505
 							$error = self::update_from_21();
2302
-							if ($error != '') return $error;
2303
-							else return self::check_version(true);
2506
+							if ($error != '') {
2507
+								return $error;
2508
+							} else {
2509
+								return self::check_version(true);
2510
+							}
2304 2511
 						} elseif ($result['value'] == '22') {
2305 2512
 							$error = self::update_from_22();
2306
-							if ($error != '') return $error;
2307
-							else return self::check_version(true);
2513
+							if ($error != '') {
2514
+								return $error;
2515
+							} else {
2516
+								return self::check_version(true);
2517
+							}
2308 2518
 						} elseif ($result['value'] == '23') {
2309 2519
 							$error = self::update_from_23();
2310
-							if ($error != '') return $error;
2311
-							else return self::check_version(true);
2520
+							if ($error != '') {
2521
+								return $error;
2522
+							} else {
2523
+								return self::check_version(true);
2524
+							}
2312 2525
 						} elseif ($result['value'] == '24') {
2313 2526
 							$error = self::update_from_24();
2314
-							if ($error != '') return $error;
2315
-							else return self::check_version(true);
2527
+							if ($error != '') {
2528
+								return $error;
2529
+							} else {
2530
+								return self::check_version(true);
2531
+							}
2316 2532
 						} elseif ($result['value'] == '25') {
2317 2533
 							$error = self::update_from_25();
2318
-							if ($error != '') return $error;
2319
-							else return self::check_version(true);
2534
+							if ($error != '') {
2535
+								return $error;
2536
+							} else {
2537
+								return self::check_version(true);
2538
+							}
2320 2539
 						} elseif ($result['value'] == '26') {
2321 2540
 							$error = self::update_from_26();
2322
-							if ($error != '') return $error;
2323
-							else return self::check_version(true);
2541
+							if ($error != '') {
2542
+								return $error;
2543
+							} else {
2544
+								return self::check_version(true);
2545
+							}
2324 2546
 						} elseif ($result['value'] == '27') {
2325 2547
 							$error = self::update_from_27();
2326
-							if ($error != '') return $error;
2327
-							else return self::check_version(true);
2548
+							if ($error != '') {
2549
+								return $error;
2550
+							} else {
2551
+								return self::check_version(true);
2552
+							}
2328 2553
 						} elseif ($result['value'] == '28') {
2329 2554
 							$error = self::update_from_28();
2330
-							if ($error != '') return $error;
2331
-							else return self::check_version(true);
2555
+							if ($error != '') {
2556
+								return $error;
2557
+							} else {
2558
+								return self::check_version(true);
2559
+							}
2332 2560
 						} elseif ($result['value'] == '29') {
2333 2561
 							$error = self::update_from_29();
2334
-							if ($error != '') return $error;
2335
-							else return self::check_version(true);
2562
+							if ($error != '') {
2563
+								return $error;
2564
+							} else {
2565
+								return self::check_version(true);
2566
+							}
2336 2567
 						} elseif ($result['value'] == '30') {
2337 2568
 							$error = self::update_from_30();
2338
-							if ($error != '') return $error;
2339
-							else return self::check_version(true);
2569
+							if ($error != '') {
2570
+								return $error;
2571
+							} else {
2572
+								return self::check_version(true);
2573
+							}
2340 2574
 						} elseif ($result['value'] == '31') {
2341 2575
 							$error = self::update_from_31();
2342
-							if ($error != '') return $error;
2343
-							else return self::check_version(true);
2576
+							if ($error != '') {
2577
+								return $error;
2578
+							} else {
2579
+								return self::check_version(true);
2580
+							}
2344 2581
 						} elseif ($result['value'] == '32') {
2345 2582
 							$error = self::update_from_32();
2346
-							if ($error != '') return $error;
2347
-							else return self::check_version(true);
2583
+							if ($error != '') {
2584
+								return $error;
2585
+							} else {
2586
+								return self::check_version(true);
2587
+							}
2348 2588
 						} elseif ($result['value'] == '33') {
2349 2589
 							$error = self::update_from_33();
2350
-							if ($error != '') return $error;
2351
-							else return self::check_version(true);
2590
+							if ($error != '') {
2591
+								return $error;
2592
+							} else {
2593
+								return self::check_version(true);
2594
+							}
2352 2595
 						} elseif ($result['value'] == '34') {
2353 2596
 							$error = self::update_from_34();
2354
-							if ($error != '') return $error;
2355
-							else return self::check_version(true);
2597
+							if ($error != '') {
2598
+								return $error;
2599
+							} else {
2600
+								return self::check_version(true);
2601
+							}
2356 2602
 						} elseif ($result['value'] == '35') {
2357 2603
 							$error = self::update_from_35();
2358
-							if ($error != '') return $error;
2359
-							else return self::check_version(true);
2604
+							if ($error != '') {
2605
+								return $error;
2606
+							} else {
2607
+								return self::check_version(true);
2608
+							}
2360 2609
 						} elseif ($result['value'] == '36') {
2361 2610
 							$error = self::update_from_36();
2362
-							if ($error != '') return $error;
2363
-							else return self::check_version(true);
2611
+							if ($error != '') {
2612
+								return $error;
2613
+							} else {
2614
+								return self::check_version(true);
2615
+							}
2364 2616
 						} elseif ($result['value'] == '37') {
2365 2617
 							$error = self::update_from_37();
2366
-							if ($error != '') return $error;
2367
-							else return self::check_version(true);
2618
+							if ($error != '') {
2619
+								return $error;
2620
+							} else {
2621
+								return self::check_version(true);
2622
+							}
2368 2623
 						} elseif ($result['value'] == '38') {
2369 2624
 							$error = self::update_from_38();
2370
-							if ($error != '') return $error;
2371
-							else return self::check_version(true);
2625
+							if ($error != '') {
2626
+								return $error;
2627
+							} else {
2628
+								return self::check_version(true);
2629
+							}
2372 2630
 						} elseif ($result['value'] == '39') {
2373 2631
 							$error = self::update_from_39();
2374
-							if ($error != '') return $error;
2375
-							else return self::check_version(true);
2632
+							if ($error != '') {
2633
+								return $error;
2634
+							} else {
2635
+								return self::check_version(true);
2636
+							}
2376 2637
 						} elseif ($result['value'] == '40') {
2377 2638
 							$error = self::update_from_40();
2378
-							if ($error != '') return $error;
2379
-							else return self::check_version(true);
2639
+							if ($error != '') {
2640
+								return $error;
2641
+							} else {
2642
+								return self::check_version(true);
2643
+							}
2380 2644
 						} elseif ($result['value'] == '41') {
2381 2645
 							$error = self::update_from_41();
2382
-							if ($error != '') return $error;
2383
-							else return self::check_version(true);
2646
+							if ($error != '') {
2647
+								return $error;
2648
+							} else {
2649
+								return self::check_version(true);
2650
+							}
2384 2651
 						} elseif ($result['value'] == '42') {
2385 2652
 							$error = self::update_from_42();
2386
-							if ($error != '') return $error;
2387
-							else return self::check_version(true);
2653
+							if ($error != '') {
2654
+								return $error;
2655
+							} else {
2656
+								return self::check_version(true);
2657
+							}
2388 2658
 						} elseif ($result['value'] == '43') {
2389 2659
 							$error = self::update_from_43();
2390
-							if ($error != '') return $error;
2391
-							else return self::check_version(true);
2660
+							if ($error != '') {
2661
+								return $error;
2662
+							} else {
2663
+								return self::check_version(true);
2664
+							}
2392 2665
 						} elseif ($result['value'] == '44') {
2393 2666
 							$error = self::update_from_44();
2394
-							if ($error != '') return $error;
2395
-							else return self::check_version(true);
2667
+							if ($error != '') {
2668
+								return $error;
2669
+							} else {
2670
+								return self::check_version(true);
2671
+							}
2396 2672
 						} elseif ($result['value'] == '45') {
2397 2673
 							$error = self::update_from_45();
2398
-							if ($error != '') return $error;
2399
-							else return self::check_version(true);
2674
+							if ($error != '') {
2675
+								return $error;
2676
+							} else {
2677
+								return self::check_version(true);
2678
+							}
2400 2679
 						} elseif ($result['value'] == '46') {
2401 2680
 							$error = self::update_from_46();
2402
-							if ($error != '') return $error;
2403
-							else return self::check_version(true);
2404
-						} else return '';
2681
+							if ($error != '') {
2682
+								return $error;
2683
+							} else {
2684
+								return self::check_version(true);
2685
+							}
2686
+						} else {
2687
+							return '';
2688
+						}
2405 2689
 					} else {
2406
-						if (isset($result['value']) && $result['value'] != '') return $result['value'];
2407
-						else return 0;
2690
+						if (isset($result['value']) && $result['value'] != '') {
2691
+							return $result['value'];
2692
+						} else {
2693
+							return 0;
2694
+						}
2408 2695
 					}
2409 2696
 				}
2410
-			} else return $version;
2697
+			} else {
2698
+				return $version;
2699
+			}
2411 2700
 		}
2412 2701
 	}
2413 2702
 }
Please login to merge, or discard this patch.
search.php 1 patch
Braces   +142 added lines, -39 removed lines patch added patch discarded remove patch
@@ -46,8 +46,10 @@  discard block
 block discarded – undo
46 46
 			$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
47 47
 			$sql_date = $end_date;
48 48
 		}
49
-	} else $sql_date = '';
50
-}
49
+	} else {
50
+		$sql_date = '';
51
+	}
52
+	}
51 53
 
52 54
 if (isset($_GET['highest_altitude'])) {
53 55
 	//for altitude manipulation
@@ -61,8 +63,12 @@  discard block
 block discarded – undo
61 63
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
62 64
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
63 65
 		$sql_altitude = $start_altitude;
64
-	} else $sql_altitude = '';
65
-} else $sql_altitude = '';
66
+	} else {
67
+		$sql_altitude = '';
68
+	}
69
+	} else {
70
+	$sql_altitude = '';
71
+}
66 72
 
67 73
 //calculuation for the pagination
68 74
 if(!isset($_GET['limit']))
@@ -80,7 +86,7 @@  discard block
 block discarded – undo
80 86
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
81 87
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
82 88
 	}
83
-}  else {
89
+} else {
84 90
 	$limit_explode = explode(",", $_GET['limit']);
85 91
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
86 92
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -138,10 +144,15 @@  discard block
 block discarded – undo
138 144
 	$dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT);
139 145
 	$number_results = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
140 146
 	if ($dist != '') {
141
-		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934;
142
-		elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852;
147
+		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') {
148
+			$dist = $dist*1.60934;
149
+		} elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') {
150
+			$dist = $dist*1.852;
151
+		}
152
+	}
153
+	if (!isset($sql_date)) {
154
+		$sql_date = '';
143 155
 	}
144
-	if (!isset($sql_date)) $sql_date = '';
145 156
 	if ($archive == 1) {
146 157
 		if ($type == 'aircraft') {
147 158
 			$SpotterArchive = new SpotterArchive();
@@ -219,7 +230,10 @@  discard block
 block discarded – undo
219 230
 		if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; }
220 231
 		if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; }
221 232
 		if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; }
222
-		if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; }
233
+		if (isset($_GET['highlights'])) {
234
+			if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> ';
235
+		}
236
+		}
223 237
 		if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; }
224 238
 		if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; }
225 239
 		if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; }
@@ -355,7 +369,10 @@  discard block
 block discarded – undo
355 369
 			<div class="form-group">
356 370
 				<label class="control-label col-sm-2"><?php echo _("Keywords"); ?></label>
357 371
 				<div class="col-sm-10">
358
-					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) print $q; ?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
372
+					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) {
373
+	print $q;
374
+}
375
+?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
359 376
 				</div>
360 377
 			</div>
361 378
 		</fieldset>
@@ -374,7 +391,10 @@  discard block
 block discarded – undo
374 391
 					    </select>
375 392
 					</div>
376 393
 				</div>
377
-				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script>
394
+				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) {
395
+	print $manufacturer;
396
+}
397
+?>')</script>
378 398
 				<div class="form-group">
379 399
 					<label class="control-label col-sm-2"><?php echo _("Type"); ?></label>
380 400
 						<div class="col-sm-10">
@@ -383,11 +403,17 @@  discard block
 block discarded – undo
383 403
 							</select>
384 404
 						</div>
385 405
 				</div>
386
-				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script>
406
+				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) {
407
+	print $aircraft_icao;
408
+}
409
+?>');</script>
387 410
 				<div class="form-group">
388 411
 					<label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> 
389 412
 					<div class="col-sm-10">
390
-						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) print $registration; ?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
413
+						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) {
414
+	print $registration;
415
+}
416
+?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
391 417
 					</div>
392 418
 				</div>
393 419
 <?php
@@ -396,22 +422,31 @@  discard block
 block discarded – undo
396 422
 				<div class="form-group">
397 423
 					<label class="control-label col-sm-2"><?php echo _("Pilot id"); ?></label> 
398 424
 					<div class="col-sm-10">
399
-						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) print $pilot_id; ?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
425
+						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) {
426
+	print $pilot_id;
427
+}
428
+?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
400 429
 					</div>
401 430
 				</div>
402 431
 				<div class="form-group">
403 432
 					<label class="control-label col-sm-2"><?php echo _("Pilot name"); ?></label> 
404 433
 					<div class="col-sm-10">
405
-						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) print $pilot_name; ?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
434
+						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) {
435
+	print $pilot_name;
436
+}
437
+?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
406 438
 					</div>
407 439
 				</div>
408 440
 <?php
409
-	}else {
441
+	} else {
410 442
 ?>
411 443
 				<div class="form-group">
412 444
 					<label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> 
413 445
 					<div class="col-sm-10">
414
-						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) print $owner; ?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
446
+						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) {
447
+	print $owner;
448
+}
449
+?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
415 450
 					</div>
416 451
 				</div>
417 452
 <?php
@@ -419,8 +454,14 @@  discard block
 block discarded – undo
419 454
 ?>
420 455
 				<div class="form-group">
421 456
 					<div class="col-sm-offset-2 col-sm-10">
422
-					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
423
-					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label>
457
+					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
458
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
459
+}
460
+} ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
461
+					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
462
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
463
+}
464
+} ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label>
424 465
 					</div>
425 466
 				</div>
426 467
 			</fieldset>
@@ -434,7 +475,10 @@  discard block
 block discarded – undo
434 475
 						</select>
435 476
 					</div>
436 477
 				</div>
437
-				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script>
478
+				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) {
479
+	print $airline;
480
+}
481
+?>');</script>
438 482
 				<div class="form-group">
439 483
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
440 484
 					<div class="col-sm-10">
@@ -443,19 +487,34 @@  discard block
 block discarded – undo
443 487
 						</select>
444 488
 					</div>
445 489
 				</div>
446
-				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script>
490
+				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) {
491
+	print $airline_country;
492
+}
493
+?>');</script>
447 494
 				<div class="form-group">
448 495
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
449 496
 					<div class="col-sm-10">
450
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
497
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
498
+	print $callsign;
499
+}
500
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
451 501
 					</div>
452 502
 				</div>
453 503
 				<div class="form-group">
454 504
 					<div class="col-sm-offset-2 col-sm-10">
455 505
 						<label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label>
456
-						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label>
457
-						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label>
458
-						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label>
506
+						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) {
507
+	if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"';
508
+}
509
+} ?>> <?php echo _("Only Passenger airlines"); ?></label>
510
+						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) {
511
+	if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"';
512
+}
513
+} ?>> <?php echo _("Only Cargo airlines"); ?></label>
514
+						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) {
515
+	if ( $_GET['airline_type'] == "military"){ print 'checked="checked"';
516
+}
517
+} ?>> <?php echo _("Only Military airlines"); ?></label>
459 518
 					</div>
460 519
 				</div>
461 520
 			</fieldset>
@@ -469,7 +528,10 @@  discard block
 block discarded – undo
469 528
 						</select>
470 529
 					</div>
471 530
 				</div>
472
-				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script>
531
+				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) {
532
+	print $airport_icao;
533
+}
534
+?>');</script>
473 535
 				<div class="form-group">
474 536
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
475 537
 					<div class="col-sm-10">
@@ -478,7 +540,10 @@  discard block
 block discarded – undo
478 540
 						</select>
479 541
 					</div>
480 542
 				</div>
481
-				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script>
543
+				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) {
544
+	print $airport_country;
545
+}
546
+?>');</script>
482 547
 			</fieldset>
483 548
 			<fieldset>
484 549
 				<legend><?php echo _("Route"); ?></legend>
@@ -490,7 +555,10 @@  discard block
 block discarded – undo
490 555
 						</select>
491 556
 					</div>
492 557
 				</div>
493
-				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script>
558
+				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) {
559
+	print $departure_airport_route;
560
+}
561
+?>');</script>
494 562
 				<div class="form-group">
495 563
 					<label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> 
496 564
 					<div class="col-sm-10">
@@ -499,7 +567,10 @@  discard block
 block discarded – undo
499 567
 						</select>
500 568
 					</div>
501 569
 				</div>
502
-				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script>
570
+				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) {
571
+	print $arrival_airport_route;
572
+}
573
+?>');</script>
503 574
 			</fieldset>
504 575
 			<fieldset>
505 576
 				<legend>Altitude</legend>
@@ -549,19 +620,33 @@  discard block
 block discarded – undo
549 620
 				<div class="form-group">
550 621
 					<label class="control-label col-sm-2"><?php echo _("Latitude"); ?></label>
551 622
 					<div class="col-sm-10">
552
-						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) print $origlat; ?>" />
623
+						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) {
624
+	print $origlat;
625
+}
626
+?>" />
553 627
 					</div>
554 628
 				</div>
555 629
 				<div class="form-group">
556 630
 					<label class="control-label col-sm-2"><?php echo _("Longitude"); ?></label>
557 631
 					<div class="col-sm-10">
558
-						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) print $origlon; ?>" />
632
+						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) {
633
+	print $origlon;
634
+}
635
+?>" />
559 636
 					</div>
560 637
 				</div>
561 638
 				<div class="form-group">
562
-					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) print $globalDistanceUnit; else print 'km'; print ')'; ?></label>
639
+					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) {
640
+	print $globalDistanceUnit;
641
+} else {
642
+	print 'km';
643
+}
644
+print ')'; ?></label>
563 645
 					<div class="col-sm-10">
564
-						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) print $distance; ?>" />
646
+						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) {
647
+	print $distance;
648
+}
649
+?>" />
565 650
 					</div>
566 651
 				</div>
567 652
 			</fieldset>
@@ -572,7 +657,10 @@  discard block
 block discarded – undo
572 657
 				<div class="form-group">
573 658
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
574 659
 					<div class="col-sm-10">
575
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
660
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
661
+	print $callsign;
662
+}
663
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
576 664
 					</div>
577 665
 				</div>
578 666
 			</fieldset>
@@ -583,7 +671,10 @@  discard block
 block discarded – undo
583 671
 				<div class="form-group">
584 672
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
585 673
 					<div class="col-sm-10">
586
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
674
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
675
+	print $callsign;
676
+}
677
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
587 678
 					</div>
588 679
 				</div>
589 680
 			</fieldset>
@@ -591,7 +682,10 @@  discard block
 block discarded – undo
591 682
 				<div class="form-group">
592 683
 					<label class="control-label col-sm-2"><?php echo _("MMSI"); ?></label> 
593 684
 					<div class="col-sm-10">
594
-						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) print $mmsi; ?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
685
+						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) {
686
+	print $mmsi;
687
+}
688
+?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
595 689
 					</div>
596 690
 				</div>
597 691
 			</fieldset>
@@ -599,7 +693,10 @@  discard block
 block discarded – undo
599 693
 				<div class="form-group">
600 694
 					<label class="control-label col-sm-2"><?php echo _("IMO"); ?></label> 
601 695
 					<div class="col-sm-10">
602
-						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) print $imo; ?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
696
+						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) {
697
+	print $imo;
698
+}
699
+?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
603 700
 					</div>
604 701
 				</div>
605 702
 			</fieldset>
@@ -612,7 +709,10 @@  discard block
 block discarded – undo
612 709
 					<label class="control-label col-sm-2"><?php echo _("Start Date"); ?></label>
613 710
 					<div class="col-sm-10">
614 711
 						<div class='input-group date' id='datetimepicker1'>
615
-							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') print $start_date; ?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
712
+							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') {
713
+	print $start_date;
714
+}
715
+?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
616 716
 							<span class="input-group-addon">
617 717
 								<span class="glyphicon glyphicon-calendar"></span>
618 718
 							</span>
@@ -623,7 +723,10 @@  discard block
 block discarded – undo
623 723
 					<label class="control-label col-sm-2"><?php echo _("End Date"); ?></label>
624 724
 					<div class="col-sm-10">
625 725
 						<div class='input-group date' id='datetimepicker2'>
626
-						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') print $end_date; ?>" placeholder="<?php echo _("End Date/Time"); ?>" />
726
+						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') {
727
+	print $end_date;
728
+}
729
+?>" placeholder="<?php echo _("End Date/Time"); ?>" />
627 730
 						<span class="input-group-addon">
628 731
 							<span class="glyphicon glyphicon-calendar"></span>
629 732
 						</span>
Please login to merge, or discard this patch.
statistics.php 1 patch
Braces   +169 added lines, -80 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@  discard block
 block discarded – undo
22 22
 	require_once('require/class.Spotter.php');
23 23
 }
24 24
 
25
-if (!isset($filter_name)) $filter_name = '';
25
+if (!isset($filter_name)) {
26
+	$filter_name = '';
27
+}
26 28
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 29
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
-}
30
+	if (isset($globalFilter['airline'])) {
31
+		$airline_icao = $globalFilter['airline'][0];
32
+	}
33
+	}
30 34
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 35
 	$Spotter = new Spotter();
32 36
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -73,7 +82,9 @@  discard block
 block discarded – undo
73 82
 if (isset($last_update[0]['value'])) {
74 83
 	date_default_timezone_set('UTC');
75 84
 	$lastupdate = strtotime($last_update[0]['value']);
76
-	if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
85
+	if (isset($globalTimezone) && $globalTimezone != '') {
86
+		date_default_timezone_set($globalTimezone);
87
+	}
77 88
 	print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
78 89
 }
79 90
 
@@ -158,8 +169,11 @@  discard block
 block discarded – undo
158 169
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
159 170
 		$aircraft_data = '';
160 171
 		foreach($aircraft_array as $aircraft_item) {
161
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
173
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
174
+			} else {
175
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
176
+			}
163 177
 		}
164 178
 		$aircraft_data = substr($aircraft_data, 0, -1);
165 179
 		print 'var series = ['.$aircraft_data.'];';
@@ -176,11 +190,17 @@  discard block
 block discarded – undo
176 190
 <?php
177 191
 	if ($year != '' && $month != '') {
178 192
 ?>
179
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
193
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
194
+	echo '/'.$airline_icao;
195
+}
196
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 197
 <?php
181 198
 	} else {
182 199
 ?>
183
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
200
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
201
+	echo '/'.$airline_icao;
202
+}
203
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
184 204
 <?php
185 205
 	}
186 206
 ?>
@@ -209,11 +229,15 @@  discard block
 block discarded – undo
209 229
 			print '</script>';
210 230
 			if ($year != '' && $month != '') {
211 231
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
232
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
233
+					echo '/'.$airline_icao;
234
+				}
213 235
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 236
 			} else {
215 237
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
216
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
238
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
239
+					echo '/'.$airline_icao;
240
+				}
217 241
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
218 242
 			}
219 243
 			print '</div>';
@@ -233,8 +257,9 @@  discard block
 block discarded – undo
233 257
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234 258
 <?php
235 259
 	$marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
236
-	if (count($marine_array) == 0) print _("No data available");
237
-	else {
260
+	if (count($marine_array) == 0) {
261
+		print _("No data available");
262
+	} else {
238 263
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
239 264
 		$marine_data = '';
240 265
 		foreach($marine_array as $marine_item) {
@@ -278,8 +303,9 @@  discard block
 block discarded – undo
278 303
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
279 304
 <?php
280 305
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
281
-	if (count($tracker_array) == 0) print _("No data available");
282
-	else {
306
+	if (count($tracker_array) == 0) {
307
+		print _("No data available");
308
+	} else {
283 309
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
284 310
 		$tracker_data = '';
285 311
 		foreach($tracker_array as $tracker_item) {
@@ -323,8 +349,9 @@  discard block
 block discarded – undo
323 349
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
324 350
 <?php
325 351
 		$owner_array = $Satellite->countAllOwners(true);
326
-		if (count($owner_array) == 0) print _("No data available");
327
-		else {
352
+		if (count($owner_array) == 0) {
353
+			print _("No data available");
354
+		} else {
328 355
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
329 356
 			$owner_data = '';
330 357
 			foreach($owner_array as $owner_item) {
@@ -343,7 +370,10 @@  discard block
 block discarded – undo
343 370
 ?>
344 371
                <!--
345 372
                 <div class="more">
346
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
373
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
374
+	echo '/'.$airline_icao;
375
+}
376
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
347 377
                 </div>
348 378
                 -->
349 379
             </div>
@@ -352,8 +382,9 @@  discard block
 block discarded – undo
352 382
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
353 383
 <?php
354 384
 		$countries_array = $Satellite->countAllCountriesOwners(true);
355
-		if (count($countries_array) == 0) print _("No data available");
356
-		else {
385
+		if (count($countries_array) == 0) {
386
+			print _("No data available");
387
+		} else {
357 388
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
358 389
 			$owner_data = '';
359 390
 			foreach($countries_array as $owner_item) {
@@ -372,7 +403,10 @@  discard block
 block discarded – undo
372 403
 ?>
373 404
 	    <!--
374 405
                 <div class="more">
375
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
406
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
407
+	echo '/'.$airline_icao;
408
+}
409
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
376 410
                 </div>
377 411
                 -->
378 412
             </div>
@@ -384,8 +418,9 @@  discard block
 block discarded – undo
384 418
                 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
385 419
 <?php
386 420
 		$launch_site_array = $Satellite->countAllLaunchSite(true);
387
-		if (count($launch_site_array) == 0) print _("No data available");
388
-		else {
421
+		if (count($launch_site_array) == 0) {
422
+			print _("No data available");
423
+		} else {
389 424
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
390 425
 			$launch_site_data = '';
391 426
 			foreach($launch_site_array as $launch_site_item) {
@@ -404,7 +439,10 @@  discard block
 block discarded – undo
404 439
 ?>
405 440
                <!--
406 441
                 <div class="more">
407
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
442
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
443
+	echo '/'.$airline_icao;
444
+}
445
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
408 446
                 </div>
409 447
                 -->
410 448
             </div>
@@ -427,8 +465,9 @@  discard block
 block discarded – undo
427 465
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
428 466
 <?php
429 467
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
430
-		if (count($pilot_array) == 0) print _("No data available");
431
-		else {
468
+		if (count($pilot_array) == 0) {
469
+			print _("No data available");
470
+		} else {
432 471
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
433 472
 			$pilot_data = '';
434 473
 			foreach($pilot_array as $pilot_item) {
@@ -446,7 +485,9 @@  discard block
 block discarded – undo
446 485
 		}
447 486
 		print '<div class="more">';
448 487
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
449
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
488
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
489
+			echo '/'.$airline_icao;
490
+		}
450 491
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
451 492
 		print '</div>';
452 493
 ?>
@@ -462,8 +503,9 @@  discard block
 block discarded – undo
462 503
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
463 504
 <?php
464 505
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
465
-		if (count($owner_array) == 0) print _("No data available");
466
-		else {
506
+		if (count($owner_array) == 0) {
507
+			print _("No data available");
508
+		} else {
467 509
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
468 510
 			$owner_data = '';
469 511
 			foreach($owner_array as $owner_item) {
@@ -481,7 +523,10 @@  discard block
 block discarded – undo
481 523
 		}
482 524
 ?>
483 525
                 <div class="more">
484
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
526
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
527
+	echo '/'.$airline_icao;
528
+}
529
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
485 530
                 </div>
486 531
             </div>
487 532
         
@@ -494,8 +539,9 @@  discard block
 block discarded – undo
494 539
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
495 540
 <?php
496 541
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
497
-		if (count($flightover_array) == 0) print _("No data available");
498
-		else {
542
+		if (count($flightover_array) == 0) {
543
+			print _("No data available");
544
+		} else {
499 545
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
500 546
 			print 'var series = [';
501 547
 			$flightover_data = '';
@@ -537,7 +583,10 @@  discard block
 block discarded – undo
537 583
 		}
538 584
 ?>
539 585
                 <div class="more">
540
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
586
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
587
+	echo '/'.$airline_icao;
588
+}
589
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
541 590
                 </div>
542 591
             </div>
543 592
 <?php
@@ -555,8 +604,9 @@  discard block
 block discarded – undo
555 604
 	<div class="col-md-6">
556 605
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
557 606
 <?php
558
-	if (count($flightover_array) == 0) print _("No data available");
559
-	else {
607
+	if (count($flightover_array) == 0) {
608
+		print _("No data available");
609
+	} else {
560 610
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
561 611
 		print 'var series = [';
562 612
 		$flightover_data = '';
@@ -612,8 +662,9 @@  discard block
 block discarded – undo
612 662
 	<div class="col-md-6">
613 663
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
614 664
 <?php
615
-	if (count($flightover_array) == 0) print _("No data available");
616
-	else {
665
+	if (count($flightover_array) == 0) {
666
+		print _("No data available");
667
+	} else {
617 668
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
618 669
 		print 'var series = [';
619 670
 		$flightover_data = '';
@@ -719,7 +770,9 @@  discard block
 block discarded – undo
719 770
 		});";
720 771
 		print '</script>';
721 772
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
722
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
773
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
774
+			echo '/'.$airline_icao;
775
+		}
723 776
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
724 777
 	}
725 778
 ?>
@@ -781,7 +834,9 @@  discard block
 block discarded – undo
781 834
 		});";
782 835
 		print '</script>';
783 836
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
784
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
837
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
838
+			echo '/'.$airline_icao;
839
+		}
785 840
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
786 841
 	}
787 842
 ?>
@@ -800,8 +855,9 @@  discard block
 block discarded – undo
800 855
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
801 856
 <?php
802 857
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
803
-		if (count($year_array) == 0) print _("No data available");
804
-		else {
858
+		if (count($year_array) == 0) {
859
+			print _("No data available");
860
+		} else {
805 861
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
806 862
 			$year_data = '';
807 863
 			$year_cnt = '';
@@ -820,7 +876,10 @@  discard block
 block discarded – undo
820 876
 		}
821 877
 ?>
822 878
                 <div class="more">
823
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
879
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
880
+	echo '/'.$airline_icao;
881
+}
882
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
824 883
                 </div>
825 884
             </div>
826 885
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -828,8 +887,9 @@  discard block
 block discarded – undo
828 887
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
829 888
 <?php
830 889
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
831
-		if (count($month_array) == 0) print _("No data available");
832
-		else {
890
+		if (count($month_array) == 0) {
891
+			print _("No data available");
892
+		} else {
833 893
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
834 894
 			$month_data = '';
835 895
 			$month_cnt = '';
@@ -848,7 +908,10 @@  discard block
 block discarded – undo
848 908
 		}
849 909
 ?>
850 910
                 <div class="more">
851
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
911
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
912
+	echo '/'.$airline_icao;
913
+}
914
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
852 915
                 </div>
853 916
             </div>
854 917
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -857,8 +920,9 @@  discard block
 block discarded – undo
857 920
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
858 921
 <?php
859 922
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
860
-		if (empty($date_array)) print _("No data available");
861
-		else {
923
+		if (empty($date_array)) {
924
+			print _("No data available");
925
+		} else {
862 926
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
863 927
 			$date_data = '';
864 928
 			$date_cnt = '';
@@ -877,7 +941,10 @@  discard block
 block discarded – undo
877 941
 		}
878 942
 ?>
879 943
                 <div class="more">
880
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
944
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
945
+	echo '/'.$airline_icao;
946
+}
947
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
881 948
                 </div>
882 949
             </div>
883 950
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -885,8 +952,9 @@  discard block
 block discarded – undo
885 952
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
886 953
 <?php
887 954
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
888
-		if (empty($hour_array)) print _("No data available");
889
-		else {
955
+		if (empty($hour_array)) {
956
+			print _("No data available");
957
+		} else {
890 958
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
891 959
 			$hour_data = '';
892 960
 			$hour_cnt = '';
@@ -905,7 +973,10 @@  discard block
 block discarded – undo
905 973
 		}
906 974
 ?>
907 975
                 <div class="more">
908
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
976
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
977
+	echo '/'.$airline_icao;
978
+}
979
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
909 980
                 </div>
910 981
             </div>
911 982
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -925,8 +996,9 @@  discard block
 block discarded – undo
925 996
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
926 997
 <?php
927 998
 		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
928
-		if (count($year_array) == 0) print _("No data available");
929
-		else {
999
+		if (count($year_array) == 0) {
1000
+			print _("No data available");
1001
+		} else {
930 1002
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
931 1003
 			$year_data = '';
932 1004
 			$year_cnt = '';
@@ -954,8 +1026,9 @@  discard block
 block discarded – undo
954 1026
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
955 1027
 <?php
956 1028
 		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
957
-		if (count($month_array) == 0) print _("No data available");
958
-		else {
1029
+		if (count($month_array) == 0) {
1030
+			print _("No data available");
1031
+		} else {
959 1032
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
960 1033
 			$month_data = '';
961 1034
 			$month_cnt = '';
@@ -983,8 +1056,9 @@  discard block
 block discarded – undo
983 1056
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
984 1057
 <?php
985 1058
 		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
986
-		if (empty($date_array)) print _("No data available");
987
-		else {
1059
+		if (empty($date_array)) {
1060
+			print _("No data available");
1061
+		} else {
988 1062
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
989 1063
 			$date_data = '';
990 1064
 			$date_cnt = '';
@@ -1011,8 +1085,9 @@  discard block
 block discarded – undo
1011 1085
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1012 1086
 <?php
1013 1087
 		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1014
-		if (empty($hour_array)) print _("No data available");
1015
-		else {
1088
+		if (empty($hour_array)) {
1089
+			print _("No data available");
1090
+		} else {
1016 1091
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1017 1092
 			$hour_data = '';
1018 1093
 			$hour_cnt = '';
@@ -1051,8 +1126,9 @@  discard block
 block discarded – undo
1051 1126
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1052 1127
 <?php
1053 1128
 		$year_array = $Tracker->countAllMonthsLastYear(true);
1054
-		if (count($year_array) == 0) print _("No data available");
1055
-		else {
1129
+		if (count($year_array) == 0) {
1130
+			print _("No data available");
1131
+		} else {
1056 1132
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1057 1133
 			$year_data = '';
1058 1134
 			$year_cnt = '';
@@ -1080,8 +1156,9 @@  discard block
 block discarded – undo
1080 1156
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1081 1157
 <?php
1082 1158
 		$month_array = $Tracker->countAllDatesLastMonth();
1083
-		if (count($month_array) == 0) print _("No data available");
1084
-		else {
1159
+		if (count($month_array) == 0) {
1160
+			print _("No data available");
1161
+		} else {
1085 1162
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1086 1163
 			$month_data = '';
1087 1164
 			$month_cnt = '';
@@ -1109,8 +1186,9 @@  discard block
 block discarded – undo
1109 1186
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1110 1187
 <?php
1111 1188
 		$date_array = $Tracker->countAllDatesLast7Days();
1112
-		if (empty($date_array)) print _("No data available");
1113
-		else {
1189
+		if (empty($date_array)) {
1190
+			print _("No data available");
1191
+		} else {
1114 1192
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1115 1193
 			$date_data = '';
1116 1194
 			$date_cnt = '';
@@ -1137,8 +1215,9 @@  discard block
 block discarded – undo
1137 1215
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1138 1216
 <?php
1139 1217
 		$hour_array = $Tracker->countAllHours('hour',true);
1140
-		if (empty($hour_array)) print _("No data available");
1141
-		else {
1218
+		if (empty($hour_array)) {
1219
+			print _("No data available");
1220
+		} else {
1142 1221
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1143 1222
 			$hour_data = '';
1144 1223
 			$hour_cnt = '';
@@ -1177,8 +1256,9 @@  discard block
 block discarded – undo
1177 1256
                 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1178 1257
 <?php
1179 1258
 		$year_array = $Satellite->countAllMonthsLastYear();
1180
-		if (count($year_array) == 0) print _("No data available");
1181
-		else {
1259
+		if (count($year_array) == 0) {
1260
+			print _("No data available");
1261
+		} else {
1182 1262
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1183 1263
 			$year_data = '';
1184 1264
 			$year_cnt = '';
@@ -1208,8 +1288,9 @@  discard block
 block discarded – undo
1208 1288
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1209 1289
 <?php
1210 1290
 		$year_array = $Satellite->countAllYears();
1211
-		if (count($year_array) == 0) print _("No data available");
1212
-		else {
1291
+		if (count($year_array) == 0) {
1292
+			print _("No data available");
1293
+		} else {
1213 1294
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1214 1295
 			$year_data = '';
1215 1296
 			$year_cnt = '';
@@ -1251,8 +1332,9 @@  discard block
 block discarded – undo
1251 1332
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1252 1333
 <?php
1253 1334
 		$year_array = $Stats->countFatalitiesByYear();
1254
-		if (count($year_array) == 0) print _("No data available");
1255
-		else {
1335
+		if (count($year_array) == 0) {
1336
+			print _("No data available");
1337
+		} else {
1256 1338
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1257 1339
 			$year_data = '';
1258 1340
 			$year_cnt = '';
@@ -1281,8 +1363,9 @@  discard block
 block discarded – undo
1281 1363
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1282 1364
 <?php
1283 1365
 		$year_array = $Stats->countFatalitiesLast12Months();
1284
-		if (count($year_array) == 0) print _("No data available");
1285
-		else {
1366
+		if (count($year_array) == 0) {
1367
+			print _("No data available");
1368
+		} else {
1286 1369
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1287 1370
 			$year_data = '';
1288 1371
 			$year_cnt = '';
@@ -1353,8 +1436,11 @@  discard block
 block discarded – undo
1353 1436
 					$distance = $distance;
1354 1437
 					$unit = 'km';
1355 1438
 				}
1356
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1357
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1439
+				if (!isset($polar_data)) {
1440
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1441
+				} else {
1442
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1443
+				}
1358 1444
 			}
1359 1445
 ?>
1360 1446
             <div class="col-md-6">
@@ -1418,9 +1504,12 @@  discard block
 block discarded – undo
1418 1504
 		foreach ($msg as $eachmsg) {
1419 1505
 			//$eachmsg = $msg[0];
1420 1506
 			$data = $eachmsg['source_data'];
1421
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1422
-			else $max = 500;
1423
-?>
1507
+			if ($data > 500) {
1508
+				$max = (round(($data+100)/100))*100;
1509
+			} else {
1510
+				$max = 500;
1511
+			}
1512
+			?>
1424 1513
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1425 1514
         	<script>
1426 1515
 		      var g = new JustGage({
Please login to merge, or discard this patch.