Completed
Push — master ( f4eedb...76be65 )
by Yannick
126:35 queued 101:17
created
require/class.SpotterLive.php 1 patch
Braces   +89 added lines, -30 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.');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection.');
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) {
@@ -119,8 +123,11 @@  discard block
 block discarded – undo
119 123
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
120 124
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
121 125
 		}
122
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
123
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
126
+		if ($filter_query_where == '' && $where) {
127
+			$filter_query_where = ' WHERE';
128
+		} elseif ($filter_query_where != '' && $and) {
129
+			$filter_query_where .= ' AND';
130
+		}
124 131
 		if ($filter_query_where != '') {
125 132
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
126 133
 		}
@@ -161,9 +168,13 @@  discard block
 block discarded – undo
161 168
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
162 169
 			}
163 170
 		}
164
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
171
+		if ($orderby_query == '') {
172
+			$orderby_query = ' ORDER BY date DESC';
173
+		}
165 174
 
166
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
175
+		if (!isset($globalLiveInterval)) {
176
+			$globalLiveInterval = '200';
177
+		}
167 178
 		if ($globalDBdriver == 'mysql') {
168 179
 			//$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";
169 180
 			$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;
@@ -186,7 +197,9 @@  discard block
 block discarded – undo
186 197
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
187 198
 		date_default_timezone_set('UTC');
188 199
 		$filter_query = $this->getFilter($filter,true,true);
189
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
200
+		if (!isset($globalLiveInterval)) {
201
+			$globalLiveInterval = '200';
202
+		}
190 203
 		if ($globalDBdriver == 'mysql') {
191 204
 			if (isset($globalArchive) && $globalArchive === TRUE) {
192 205
 				$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 
@@ -229,7 +242,9 @@  discard block
 block discarded – undo
229 242
 
230 243
 		$filter_query = $this->getFilter($filter,true,true);
231 244
 
232
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
245
+		if (!isset($globalLiveInterval)) {
246
+			$globalLiveInterval = '200';
247
+		}
233 248
 		if ($globalDBdriver == 'mysql') {
234 249
 			if (isset($globalArchive) && $globalArchive === TRUE) {
235 250
 				/*
@@ -297,7 +312,9 @@  discard block
 block discarded – undo
297 312
 		global $globalDBdriver, $globalLiveInterval;
298 313
 		$filter_query = $this->getFilter($filter,true,true);
299 314
 
300
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
315
+		if (!isset($globalLiveInterval)) {
316
+			$globalLiveInterval = '200';
317
+		}
301 318
 		if ($globalDBdriver == 'mysql') {
302 319
 			//$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;
303 320
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -327,7 +344,9 @@  discard block
 block discarded – undo
327 344
 	{
328 345
 		global $globalDBdriver, $globalLiveInterval;
329 346
 		$Spotter = new Spotter($this->db);
330
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
347
+		if (!isset($globalLiveInterval)) {
348
+			$globalLiveInterval = '200';
349
+		}
331 350
 		$filter_query = $this->getFilter($filter);
332 351
 
333 352
 		if (is_array($coord)) {
@@ -335,7 +354,9 @@  discard block
 block discarded – undo
335 354
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
336 355
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
337 356
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
338
-		} else return array();
357
+		} else {
358
+			return array();
359
+		}
339 360
 		if ($globalDBdriver == 'mysql') {
340 361
 			$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;
341 362
 		} else {
@@ -356,7 +377,9 @@  discard block
 block discarded – undo
356 377
 	{
357 378
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
358 379
 		$Spotter = new Spotter($this->db);
359
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
380
+		if (!isset($globalLiveInterval)) {
381
+			$globalLiveInterval = '200';
382
+		}
360 383
 		$filter_query = $this->getFilter($filter,true,true);
361 384
 
362 385
 		if (is_array($coord)) {
@@ -364,7 +387,9 @@  discard block
 block discarded – undo
364 387
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
365 388
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
366 389
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
367
-		} else return array();
390
+		} else {
391
+			return array();
392
+		}
368 393
 		if ($globalDBdriver == 'mysql') {
369 394
 			if (isset($globalArchive) && $globalArchive === TRUE) {
370 395
 				$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 
@@ -591,11 +616,15 @@  discard block
 block discarded – undo
591 616
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
592 617
 		if ($globalDBdriver == 'mysql') {
593 618
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
594
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
619
+			if ($liveinterval) {
620
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
621
+			}
595 622
 			$query .= ' ORDER BY date';
596 623
 		} else {
597 624
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
598
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
625
+			if ($liveinterval) {
626
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
627
+			}
599 628
 			$query .= ' ORDER BY date';
600 629
 		}
601 630
 
@@ -690,7 +719,9 @@  discard block
 block discarded – undo
690 719
 				$i++;
691 720
 				$j++;
692 721
 				if ($j == 30) {
693
-					if ($globalDebug) echo ".";
722
+					if ($globalDebug) {
723
+						echo ".";
724
+					}
694 725
 				    	try {
695 726
 						
696 727
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -997,7 +1028,9 @@  discard block
 block discarded – undo
997 1028
 			{
998 1029
 				return false;
999 1030
 			}
1000
-		} else return '';
1031
+		} else {
1032
+			return '';
1033
+		}
1001 1034
 
1002 1035
 		if ($longitude != '')
1003 1036
 		{
@@ -1005,7 +1038,9 @@  discard block
 block discarded – undo
1005 1038
 			{
1006 1039
 				return false;
1007 1040
 			}
1008
-		} else return '';
1041
+		} else {
1042
+			return '';
1043
+		}
1009 1044
 
1010 1045
 		if ($waypoints != '')
1011 1046
 		{
@@ -1021,14 +1056,18 @@  discard block
 block discarded – undo
1021 1056
 			{
1022 1057
 				return false;
1023 1058
 			}
1024
-		} else $altitude = 0;
1059
+		} else {
1060
+			$altitude = 0;
1061
+		}
1025 1062
 		if ($altitude_real != '')
1026 1063
 		{
1027 1064
 			if (!is_numeric($altitude_real))
1028 1065
 			{
1029 1066
 				return false;
1030 1067
 			}
1031
-		} else $altitude_real = 0;
1068
+		} else {
1069
+			$altitude_real = 0;
1070
+		}
1032 1071
 
1033 1072
 		if ($heading != '')
1034 1073
 		{
@@ -1036,7 +1075,9 @@  discard block
 block discarded – undo
1036 1075
 			{
1037 1076
 				return false;
1038 1077
 			}
1039
-		} else $heading = 0;
1078
+		} else {
1079
+			$heading = 0;
1080
+		}
1040 1081
 
1041 1082
 		if ($groundspeed != '')
1042 1083
 		{
@@ -1044,9 +1085,13 @@  discard block
 block discarded – undo
1044 1085
 			{
1045 1086
 				return false;
1046 1087
 			}
1047
-		} else $groundspeed = 0;
1088
+		} else {
1089
+			$groundspeed = 0;
1090
+		}
1048 1091
 		date_default_timezone_set('UTC');
1049
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1092
+		if ($date == '') {
1093
+			$date = date("Y-m-d H:i:s", time());
1094
+		}
1050 1095
 
1051 1096
         
1052 1097
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1091,14 +1136,24 @@  discard block
 block discarded – undo
1091 1136
 		$arrival_airport_country = '';
1092 1137
 		
1093 1138
             	
1094
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1095
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1096
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1097
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1139
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1140
+            		$squawk = NULL;
1141
+            	}
1142
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1143
+            		$verticalrate = NULL;
1144
+            	}
1145
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1146
+            		$groundspeed = 0;
1147
+            	}
1148
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1149
+            		$heading = 0;
1150
+            	}
1098 1151
 		
1099 1152
 		$query = '';
1100 1153
 		if ($globalArchive) {
1101
-			if ($globalDebug) echo '-- Delete previous data -- ';
1154
+			if ($globalDebug) {
1155
+				echo '-- Delete previous data -- ';
1156
+			}
1102 1157
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1103 1158
 		}
1104 1159
 
@@ -1115,10 +1170,14 @@  discard block
 block discarded – undo
1115 1170
 			return "error : ".$e->getMessage();
1116 1171
 		}
1117 1172
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1118
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1173
+		    if ($globalDebug) {
1174
+		    	echo '(Add to SBS archive : ';
1175
+		    }
1119 1176
 		    $SpotterArchive = new SpotterArchive($this->db);
1120 1177
 		    $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);
1121
-		    if ($globalDebug) echo $result.')';
1178
+		    if ($globalDebug) {
1179
+		    	echo $result.')';
1180
+		    }
1122 1181
 		} elseif ($globalDebug && $putinarchive !== true) {
1123 1182
 			echo '(Not adding to archive)';
1124 1183
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
require/class.Satellite.php 1 patch
Braces   +58 added lines, -21 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	public function __construct($dbc = null) {
13 13
 		$Connection = new Connection($dbc);
14 14
 		$this->db = $Connection->db();
15
-		if ($this->db === null) die('Error: No DB connection.');
15
+		if ($this->db === null) {
16
+			die('Error: No DB connection.');
17
+		}
16 18
 	}
17 19
 
18 20
 	public function get_tle($name) {
@@ -24,8 +26,11 @@  discard block
 block discarded – undo
24 26
 			echo $e->getMessage();
25 27
 		}
26 28
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
27
-		if (isset($result[0])) return $result[0];
28
-		else return array();
29
+		if (isset($result[0])) {
30
+			return $result[0];
31
+		} else {
32
+			return array();
33
+		}
29 34
 	}
30 35
 	public function get_tle_types() {
31 36
 		$query = 'SELECT DISTINCT tle_type FROM tle ORDER BY tle_type';
@@ -36,8 +41,11 @@  discard block
 block discarded – undo
36 41
 			echo $e->getMessage();
37 42
 		}
38 43
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
39
-		if (isset($result[0])) return $result;
40
-		else return array();
44
+		if (isset($result[0])) {
45
+			return $result;
46
+		} else {
47
+			return array();
48
+		}
41 49
 	}
42 50
 	public function get_tle_names() {
43 51
 		$query = 'SELECT DISTINCT tle_name, tle_type FROM tle';
@@ -48,8 +56,11 @@  discard block
 block discarded – undo
48 56
 			echo $e->getMessage();
49 57
 		}
50 58
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
51
-		if (isset($result[0])) return $result;
52
-		else return array();
59
+		if (isset($result[0])) {
60
+			return $result;
61
+		} else {
62
+			return array();
63
+		}
53 64
 	}
54 65
 	public function get_tle_names_type($type) {
55 66
 		$query = 'SELECT tle_name, tle_type FROM tle WHERE tle_type = :type ORDER BY tle_name';
@@ -60,8 +71,11 @@  discard block
 block discarded – undo
60 71
 			echo $e->getMessage();
61 72
 		}
62 73
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
63
-		if (isset($result[0])) return $result;
64
-		else return array();
74
+		if (isset($result[0])) {
75
+			return $result;
76
+		} else {
77
+			return array();
78
+		}
65 79
 	}
66 80
 	
67 81
 	public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) {
@@ -95,7 +109,9 @@  discard block
 block discarded – undo
95 109
 		$sat = new Predict_Sat($tle);
96 110
 		$predict = new Predict();
97 111
 		//if ($timestamp == '') $now = Predict_Time::get_current_daynum();
98
-		if ($timestamp_begin == '') $timestamp_begin = time();
112
+		if ($timestamp_begin == '') {
113
+			$timestamp_begin = time();
114
+		}
99 115
 		if ($timestamp_end == '') {
100 116
 			$now = Predict_Time::unix2daynum($timestamp_begin);
101 117
 			$predict->predict_calc($sat,$qth,$now);
@@ -120,8 +136,11 @@  discard block
 block discarded – undo
120 136
 			echo $e->getMessage();
121 137
 		}
122 138
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
123
-		if (isset($result[0])) return $result[0];
124
-		else return array();
139
+		if (isset($result[0])) {
140
+			return $result[0];
141
+		} else {
142
+			return array();
143
+		}
125 144
 	}
126 145
 
127 146
 	/**
@@ -139,7 +158,9 @@  discard block
 block discarded – undo
139 158
 		    FROM satellite".$filter_query." satellite.launch_site <> '' AND satellite.launch_site IS NOT NULL";
140 159
 		$query_values = array();
141 160
 		$query .= " GROUP BY satellite.launch_site ORDER BY launch_site_count DESC";
142
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
161
+		if ($limit) {
162
+			$query .= " LIMIT 10 OFFSET 0";
163
+		}
143 164
 		$sth = $this->db->prepare($query);
144 165
 		$sth->execute($query_values);
145 166
 		$launch_site_array = array();
@@ -168,7 +189,9 @@  discard block
 block discarded – undo
168 189
 		    FROM satellite".$filter_query." satellite.owner <> '' AND satellite.owner IS NOT NULL";
169 190
 		$query_values = array();
170 191
 		$query .= " GROUP BY satellite.owner ORDER BY owner_count DESC";
171
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
192
+		if ($limit) {
193
+			$query .= " LIMIT 10 OFFSET 0";
194
+		}
172 195
 		$sth = $this->db->prepare($query);
173 196
 		$sth->execute($query_values);
174 197
 		$owner_array = array();
@@ -197,7 +220,9 @@  discard block
 block discarded – undo
197 220
 		    FROM satellite".$filter_query." satellite.country_owner <> '' AND satellite.country_owner IS NOT NULL";
198 221
 		$query_values = array();
199 222
 		$query .= " GROUP BY satellite.country_owner ORDER BY country_count DESC";
200
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
223
+		if ($limit) {
224
+			$query .= " LIMIT 10 OFFSET 0";
225
+		}
201 226
 		$sth = $this->db->prepare($query);
202 227
 		$sth->execute($query_values);
203 228
 		$owner_array = array();
@@ -224,20 +249,26 @@  discard block
 block discarded – undo
224 249
 			date_default_timezone_set($globalTimezone);
225 250
 			$datetime = new DateTime();
226 251
 			$offset = $datetime->format('P');
227
-		} else $offset = '+00:00';
252
+		} else {
253
+			$offset = '+00:00';
254
+		}
228 255
 		//$filter_query = $this->getFilter($filters,true,true);
229 256
 		$filter_query = ' WHERE';
230 257
 		if ($globalDBdriver == 'mysql') {
231 258
 			$query  = "SELECT MONTH(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count
232 259
 				FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
233
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
260
+			if ($sincedate != '') {
261
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
262
+			}
234 263
 			$query .= " GROUP BY year_name, month_name
235 264
 				ORDER BY year_name, month_name ASC";
236 265
 			$query_data = array(':offset' => $offset);
237 266
 		} else {
238 267
 			$query  = "SELECT EXTRACT(MONTH FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS month_name, EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count
239 268
 				FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 YEARS'";
240
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
269
+			if ($sincedate != '') {
270
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
271
+			}
241 272
 			$query .= " GROUP BY year_name, month_name
242 273
 				ORDER BY year_name, month_name ASC";
243 274
 			$query_data = array(':offset' => $offset);
@@ -269,20 +300,26 @@  discard block
 block discarded – undo
269 300
 			date_default_timezone_set($globalTimezone);
270 301
 			$datetime = new DateTime();
271 302
 			$offset = $datetime->format('P');
272
-		} else $offset = '+00:00';
303
+		} else {
304
+			$offset = '+00:00';
305
+		}
273 306
 		//$filter_query = $this->getFilter($filters,true,true);
274 307
 		$filter_query = ' WHERE';
275 308
 		if ($globalDBdriver == 'mysql') {
276 309
 			$query  = "SELECT YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count
277 310
 				FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 YEAR)";
278
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
311
+			if ($sincedate != '') {
312
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
313
+			}
279 314
 			$query .= " GROUP BY year_name
280 315
 				ORDER BY year_name ASC";
281 316
 			$query_data = array(':offset' => $offset);
282 317
 		} else {
283 318
 			$query  = "SELECT EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count
284 319
 				FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '10 YEARS'";
285
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
320
+			if ($sincedate != '') {
321
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
322
+			}
286 323
 			$query .= " GROUP BY year_name
287 324
 				ORDER BY year_name ASC";
288 325
 			$query_data = array(':offset' => $offset);
Please login to merge, or discard this patch.
require/class.Accident.php 1 patch
Braces   +87 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 	public function __construct($dbc = null) {
11 11
 		$Connection = new Connection($dbc);
12 12
 		$this->db = $Connection->db();
13
-		if ($this->db === null) die('Error: No DB connection.');
13
+		if ($this->db === null) {
14
+			die('Error: No DB connection.');
15
+		}
14 16
 	}
15 17
 
16 18
 	public function get() {
@@ -111,8 +113,11 @@  discard block
 block discarded – undo
111 113
 				$data = array();
112 114
 				if ($row['registration'] != '') {
113 115
 					$image_array = $Image->getSpotterImage($row['registration']);
114
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
115
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
116
+					if (count($image_array) > 0) {
117
+						$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
118
+					} else {
119
+						$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
120
+					}
116 121
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
117 122
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
118 123
 					if (!empty($aircraft_info)) {
@@ -128,17 +133,30 @@  discard block
 block discarded – undo
128 133
 						$data['aircraft_base'] = $owner_data['base'];
129 134
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
130 135
 					}
131
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
132
-				if ($row['registration'] == '') $row['registration'] = 'NA';
133
-				if ($row['ident'] == '') $row['ident'] = 'NA';
136
+				} else {
137
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
138
+				}
139
+				if ($row['registration'] == '') {
140
+					$row['registration'] = 'NA';
141
+				}
142
+				if ($row['ident'] == '') {
143
+					$row['ident'] = 'NA';
144
+				}
134 145
 				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
135 146
 				if (isset($identicao[0])) {
136 147
 					if (substr($row['ident'],0,2) == 'AF') {
137
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
138
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
139
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
148
+						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
149
+							$icao = $row['ident'];
150
+						} else {
151
+							$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
152
+						}
153
+					} else {
154
+						$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
155
+					}
140 156
 					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
141
-				} else $icao = $row['ident'];
157
+				} else {
158
+					$icao = $row['ident'];
159
+				}
142 160
 				$icao = $Translation->checkTranslation($icao,false);
143 161
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
144 162
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -153,10 +171,14 @@  discard block
 block discarded – undo
153 171
 					//else echo 'No data...'."\n";
154 172
 				}
155 173
 				$data = array_merge($row,$data);
156
-				if ($data['ident'] == null) $data['ident'] = $icao;
174
+				if ($data['ident'] == null) {
175
+					$data['ident'] = $icao;
176
+				}
157 177
 				if ($data['title'] == null) {
158 178
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
159
-				} else $data['message'] = strtolower($data['title']);
179
+				} else {
180
+					$data['message'] = strtolower($data['title']);
181
+				}
160 182
 				$ids = $Spotter->getAllIDByRegistration($data['registration']);
161 183
 				$date = $data['date'];
162 184
 				if (isset($ids[$date])) {
@@ -175,8 +197,9 @@  discard block
 block discarded – undo
175 197
 		if (isset($result)) {
176 198
 			$result[0]['query_number_rows'] = $i;
177 199
 			return $result;
200
+		} else {
201
+			return array();
178 202
 		}
179
-		else return array();
180 203
 	}
181 204
 
182 205
 	/*
@@ -221,7 +244,9 @@  discard block
 block discarded – undo
221 244
 	*/
222 245
 	public function import($file) {
223 246
 		global $globalTransaction, $globalDebug;
224
-		if ($globalDebug) echo 'Import '.$file."\n";
247
+		if ($globalDebug) {
248
+			echo 'Import '.$file."\n";
249
+		}
225 250
 		$result = array();
226 251
 		if (file_exists($file)) {
227 252
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -232,8 +257,11 @@  discard block
 block discarded – undo
232 257
 				}
233 258
 				fclose($handle);
234 259
 			}
235
-			if (!empty($result)) $this->add($result,true);
236
-			elseif ($globalDebug) echo 'Nothing to import';
260
+			if (!empty($result)) {
261
+				$this->add($result,true);
262
+			} elseif ($globalDebug) {
263
+				echo 'Nothing to import';
264
+			}
237 265
 		}
238 266
 	}
239 267
 
@@ -269,14 +297,23 @@  discard block
 block discarded – undo
269 297
 					}
270 298
 				}
271 299
 				fclose($handle);
272
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
273
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
300
+			} elseif ($globalDebug) {
301
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
302
+			}
303
+		} elseif ($globalDebug) {
304
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
305
+		}
274 306
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
275
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
307
+		if (empty($result) && $globalDebug) {
308
+			echo 'Nothing to update';
309
+		}
276 310
 		foreach ($result as $file => $md5) {
277 311
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
278
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
279
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
312
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
313
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
314
+			} elseif ($globalDebug) {
315
+				echo 'Download '.$file.' failed';
316
+			}
280 317
 		}
281 318
 	}
282 319
 
@@ -293,13 +330,17 @@  discard block
 block discarded – undo
293 330
 		$Image = new Image();
294 331
 		$Spotter = new Spotter();
295 332
 
296
-		if (empty($crash)) return false;
333
+		if (empty($crash)) {
334
+			return false;
335
+		}
297 336
 		if (!$new) {
298 337
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
299 338
 			$sthd = $Connection->db->prepare($query_delete);
300 339
 			$sthd->execute(array(':source' => $crash[0]['source']));
301 340
 		}
302
-		if ($globalTransaction) $Connection->db->beginTransaction();
341
+		if ($globalTransaction) {
342
+			$Connection->db->beginTransaction();
343
+		}
303 344
 		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
304 345
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
305 346
 		$sth_check = $Connection->db->prepare($query_check);
@@ -314,7 +355,9 @@  discard block
 block discarded – undo
314 355
 					return $value === "" ? NULL : $value;
315 356
 				}, $cr);
316 357
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
317
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
358
+					if (strpos($cr['registration'],'-') === FALSE) {
359
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
360
+					}
318 361
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
319 362
 					$sth_check->execute($query_check_values);
320 363
 					$result_check = $sth_check->fetch(PDO::FETCH_ASSOC);
@@ -323,13 +366,19 @@  discard block
 block discarded – undo
323 366
 						$sth->execute($query_values);
324 367
 						if ($cr['date'] > time()-(30*86400)) {
325 368
 							if (empty($Image->getSpotterImage($cr['registration']))) {
326
-								if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
369
+								if ($globalDebug) {
370
+									echo "\t".'Get image for '.$cr['registration'].'...';
371
+								}
327 372
 								$Image->addSpotterImage($cr['registration']);
328
-								if ($globalDebug) echo "\t".'Done'."\n";
373
+								if ($globalDebug) {
374
+									echo "\t".'Done'."\n";
375
+								}
329 376
 							}
330 377
 							// elseif ($globalDebug) echo 'Image already in DB'."\n";
331 378
 						}
332
-						if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
379
+						if ($cr['title'] == '') {
380
+							$cr['title'] = $cr['registration'].' '.$cr['type'];
381
+						}
333 382
 						$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
334 383
 					}
335 384
 				}
@@ -338,9 +387,13 @@  discard block
 block discarded – undo
338 387
 					$Connection->db->beginTransaction();
339 388
 				}
340 389
 			}
341
-			if ($globalTransaction) $Connection->db->commit();
390
+			if ($globalTransaction) {
391
+				$Connection->db->commit();
392
+			}
342 393
 		} catch(PDOException $e) {
343
-			if ($globalTransaction) $Connection->db->rollBack();
394
+			if ($globalTransaction) {
395
+				$Connection->db->rollBack();
396
+			}
344 397
 			echo $e->getMessage();
345 398
 		}
346 399
 		$sth_check->closeCursor();
@@ -379,8 +432,11 @@  discard block
 block discarded – undo
379 432
 			return "error : ".$e->getMessage();
380 433
 		}
381 434
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
382
-		if ($row['nb'] > 0) return false;
383
-		else return true;
435
+		if ($row['nb'] > 0) {
436
+			return false;
437
+		} else {
438
+			return true;
439
+		}
384 440
 	}
385 441
 
386 442
 	public static function insert_last_accidents_update() {
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 2 patches
Indentation   +651 added lines, -651 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 		if ($this->db === null) die('Error: No DB connection.');
10 10
 	}
11 11
 
12
-    /**
13
-    * Get SQL query part for filter used
14
-    * @param Array $filter the filter
15
-    * @return Array the SQL part
16
-    */
17
-    public function getFilter($filter = array(),$where = false,$and = false) {
12
+	/**
13
+	 * Get SQL query part for filter used
14
+	 * @param Array $filter the filter
15
+	 * @return Array the SQL part
16
+	 */
17
+	public function getFilter($filter = array(),$where = false,$and = false) {
18 18
 	global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 	$filters = array();
20 20
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
@@ -31,88 +31,88 @@  discard block
 block discarded – undo
31 31
 	$filter_query_join = '';
32 32
 	$filter_query_where = '';
33 33
 	foreach($filters as $flt) {
34
-	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
34
+		if (isset($flt['airlines']) && !empty($flt['airlines'])) {
35 35
 		if ($flt['airlines'][0] != '') {
36
-		    if (isset($flt['source'])) {
36
+			if (isset($flt['source'])) {
37 37
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
38
-		    } else {
38
+			} else {
39 39
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
40
-		    }
40
+			}
41
+		}
41 42
 		}
42
-	    }
43
-	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
43
+		if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
44 44
 		if (isset($flt['source'])) {
45
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
45
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
46 46
 		} else {
47
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
47
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
48 48
 		}
49
-	    }
50
-	    if (isset($flt['idents']) && !empty($flt['idents'])) {
49
+		}
50
+		if (isset($flt['idents']) && !empty($flt['idents'])) {
51 51
 		if (isset($flt['source'])) {
52
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
52
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
53 53
 		} else {
54
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
54
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
55
+		}
55 56
 		}
56
-	    }
57
-	    if (isset($flt['registrations']) && !empty($flt['registrations'])) {
57
+		if (isset($flt['registrations']) && !empty($flt['registrations'])) {
58 58
 		if (isset($flt['source'])) {
59
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
59
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
60 60
 		} else {
61
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
61
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
62
+		}
62 63
 		}
63
-	    }
64
-	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
64
+		if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
65 65
 		if (isset($flt['source'])) {
66
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
66
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
67
+		}
67 68
 		}
68
-	    }
69 69
 	}
70 70
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
71
-	    if ($filter['airlines'][0] != '') {
71
+		if ($filter['airlines'][0] != '') {
72 72
 		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
73
-	    }
73
+		}
74 74
 	}
75 75
 	
76 76
 	if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
77
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
77
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
78 78
 	}
79 79
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
80
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
80
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
81 81
 	}
82 82
 	if (isset($filter['source']) && !empty($filter['source'])) {
83
-	    $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
83
+		$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
84 84
 	}
85 85
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
86
-	    $filter_query_where .= " AND ident = '".$filter['ident']."'";
86
+		$filter_query_where .= " AND ident = '".$filter['ident']."'";
87 87
 	}
88 88
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
89 89
 		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
90 90
 	}
91 91
 	if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
92
-	    $filter_query_date = '';
92
+		$filter_query_date = '';
93 93
 	    
94
-	    if (isset($filter['year']) && $filter['year'] != '') {
94
+		if (isset($filter['year']) && $filter['year'] != '') {
95 95
 		if ($globalDBdriver == 'mysql') {
96
-		    $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
96
+			$filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
97 97
 		} else {
98
-		    $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
98
+			$filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
99
+		}
99 100
 		}
100
-	    }
101
-	    if (isset($filter['month']) && $filter['month'] != '') {
101
+		if (isset($filter['month']) && $filter['month'] != '') {
102 102
 		if ($globalDBdriver == 'mysql') {
103
-		    $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
103
+			$filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
104 104
 		} else {
105
-		    $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
105
+			$filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
106 106
 		}
107
-	    }
108
-	    if (isset($filter['day']) && $filter['day'] != '') {
107
+		}
108
+		if (isset($filter['day']) && $filter['day'] != '') {
109 109
 		if ($globalDBdriver == 'mysql') {
110
-		    $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
110
+			$filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
111 111
 		} else {
112
-		    $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
112
+			$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
113
+		}
113 114
 		}
114
-	    }
115
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
115
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
116 116
 	}
117 117
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
118 118
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	}
122 122
 	$filter_query = $filter_query_join.$filter_query_where;
123 123
 	return $filter_query;
124
-    }
124
+	}
125 125
 
126 126
 	// Spotter_archive
127 127
 	public function 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 = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
@@ -153,44 +153,44 @@  discard block
 block discarded – undo
153 153
 	}
154 154
 
155 155
 
156
-        /**
157
-        * Gets all the spotter information based on a particular callsign
158
-        *
159
-        * @return Array the spotter information
160
-        *
161
-        */
162
-        public function getLastArchiveSpotterDataByIdent($ident)
163
-        {
156
+		/**
157
+		 * Gets all the spotter information based on a particular callsign
158
+		 *
159
+		 * @return Array the spotter information
160
+		 *
161
+		 */
162
+		public function getLastArchiveSpotterDataByIdent($ident)
163
+		{
164 164
 		$Spotter = new Spotter($this->db);
165
-                date_default_timezone_set('UTC');
165
+				date_default_timezone_set('UTC');
166 166
 
167
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
168
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
169
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
167
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
168
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
169
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
170 170
 
171
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
171
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
172 172
 
173
-                return $spotter_array;
174
-        }
173
+				return $spotter_array;
174
+		}
175 175
 
176 176
 
177
-        /**
178
-        * Gets last the spotter information based on a particular id
179
-        *
180
-        * @return Array the spotter information
181
-        *
182
-        */
183
-        public function getLastArchiveSpotterDataById($id)
184
-        {
185
-    		$Spotter = new Spotter($this->db);
186
-                date_default_timezone_set('UTC');
187
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
188
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
189
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
190
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
177
+		/**
178
+		 * Gets last the spotter information based on a particular id
179
+		 *
180
+		 * @return Array the spotter information
181
+		 *
182
+		 */
183
+		public function getLastArchiveSpotterDataById($id)
184
+		{
185
+			$Spotter = new Spotter($this->db);
186
+				date_default_timezone_set('UTC');
187
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
188
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
189
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
190
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
191 191
 
192 192
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
193
-                  /*
193
+				  /*
194 194
                 try {
195 195
                         $Connection = new Connection();
196 196
                         $sth = Connection->$db->prepare($query);
@@ -200,235 +200,235 @@  discard block
 block discarded – undo
200 200
                 }
201 201
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
202 202
                 */
203
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
204
-
205
-                return $spotter_array;
206
-        }
207
-
208
-        /**
209
-        * Gets all the spotter information based on a particular id
210
-        *
211
-        * @return Array the spotter information
212
-        *
213
-        */
214
-        public function getAllArchiveSpotterDataById($id)
203
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
204
+
205
+				return $spotter_array;
206
+		}
207
+
208
+		/**
209
+		 * Gets all the spotter information based on a particular id
210
+		 *
211
+		 * @return Array the spotter information
212
+		 *
213
+		 */
214
+		public function getAllArchiveSpotterDataById($id)
215 215
 	{
216
-                date_default_timezone_set('UTC');
217
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
218
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
216
+				date_default_timezone_set('UTC');
217
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
218
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
219 219
 
220 220
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
221 221
 
222
-                try {
223
-                        $sth = $this->db->prepare($query);
224
-                        $sth->execute(array(':id' => $id));
225
-                } catch(PDOException $e) {
226
-                        echo $e->getMessage();
227
-                        die;
228
-                }
229
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
230
-
231
-                return $spotter_array;
232
-        }
233
-
234
-        /**
235
-        * Gets coordinate & time spotter information based on a particular id
236
-        *
237
-        * @return Array the spotter information
238
-        *
239
-        */
240
-        public function getCoordArchiveSpotterDataById($id)
241
-        {
242
-                date_default_timezone_set('UTC');
243
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
244
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
222
+				try {
223
+						$sth = $this->db->prepare($query);
224
+						$sth->execute(array(':id' => $id));
225
+				} catch(PDOException $e) {
226
+						echo $e->getMessage();
227
+						die;
228
+				}
229
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
230
+
231
+				return $spotter_array;
232
+		}
233
+
234
+		/**
235
+		 * Gets coordinate & time spotter information based on a particular id
236
+		 *
237
+		 * @return Array the spotter information
238
+		 *
239
+		 */
240
+		public function getCoordArchiveSpotterDataById($id)
241
+		{
242
+				date_default_timezone_set('UTC');
243
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
244
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
245 245
 
246 246
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
247 247
 
248
-                try {
249
-                        $sth = $this->db->prepare($query);
250
-                        $sth->execute(array(':id' => $id));
251
-                } catch(PDOException $e) {
252
-                        echo $e->getMessage();
253
-                        die;
254
-                }
255
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
248
+				try {
249
+						$sth = $this->db->prepare($query);
250
+						$sth->execute(array(':id' => $id));
251
+				} catch(PDOException $e) {
252
+						echo $e->getMessage();
253
+						die;
254
+				}
255
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
256 256
 
257
-                return $spotter_array;
258
-        }
257
+				return $spotter_array;
258
+		}
259 259
 
260 260
 
261
-        /**
262
-        * Gets altitude information based on a particular callsign
263
-        *
264
-        * @return Array the spotter information
265
-        *
266
-        */
267
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
268
-        {
261
+		/**
262
+		 * Gets altitude information based on a particular callsign
263
+		 *
264
+		 * @return Array the spotter information
265
+		 *
266
+		 */
267
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
268
+		{
269 269
 
270
-                date_default_timezone_set('UTC');
270
+				date_default_timezone_set('UTC');
271 271
 
272
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
273
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
272
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
273
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
274 274
 
275
-                try {
276
-                        $sth = $this->db->prepare($query);
277
-                        $sth->execute(array(':ident' => $ident));
278
-                } catch(PDOException $e) {
279
-                        echo $e->getMessage();
280
-                        die;
281
-                }
282
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
275
+				try {
276
+						$sth = $this->db->prepare($query);
277
+						$sth->execute(array(':ident' => $ident));
278
+				} catch(PDOException $e) {
279
+						echo $e->getMessage();
280
+						die;
281
+				}
282
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
283 283
 
284
-                return $spotter_array;
285
-        }
284
+				return $spotter_array;
285
+		}
286 286
 
287
-        /**
288
-        * Gets altitude information based on a particular id
289
-        *
290
-        * @return Array the spotter information
291
-        *
292
-        */
293
-        public function getAltitudeArchiveSpotterDataById($id)
294
-        {
287
+		/**
288
+		 * Gets altitude information based on a particular id
289
+		 *
290
+		 * @return Array the spotter information
291
+		 *
292
+		 */
293
+		public function getAltitudeArchiveSpotterDataById($id)
294
+		{
295 295
 
296
-                date_default_timezone_set('UTC');
296
+				date_default_timezone_set('UTC');
297 297
 
298
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
299
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
298
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
299
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
300 300
 
301
-                try {
302
-                        $sth = $this->db->prepare($query);
303
-                        $sth->execute(array(':id' => $id));
304
-                } catch(PDOException $e) {
305
-                        echo $e->getMessage();
306
-                        die;
307
-                }
308
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
301
+				try {
302
+						$sth = $this->db->prepare($query);
303
+						$sth->execute(array(':id' => $id));
304
+				} catch(PDOException $e) {
305
+						echo $e->getMessage();
306
+						die;
307
+				}
308
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
309 309
 
310
-                return $spotter_array;
311
-        }
310
+				return $spotter_array;
311
+		}
312 312
 
313
-        /**
314
-        * Gets altitude & speed information based on a particular id
315
-        *
316
-        * @return Array the spotter information
317
-        *
318
-        */
319
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
320
-        {
313
+		/**
314
+		 * Gets altitude & speed information based on a particular id
315
+		 *
316
+		 * @return Array the spotter information
317
+		 *
318
+		 */
319
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
320
+		{
321 321
 
322
-                date_default_timezone_set('UTC');
322
+				date_default_timezone_set('UTC');
323 323
 
324
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
325
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
324
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
325
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
326 326
 
327
-                try {
328
-                        $sth = $this->db->prepare($query);
329
-                        $sth->execute(array(':id' => $id));
330
-                } catch(PDOException $e) {
331
-                        echo $e->getMessage();
332
-                        die;
333
-                }
334
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
327
+				try {
328
+						$sth = $this->db->prepare($query);
329
+						$sth->execute(array(':id' => $id));
330
+				} catch(PDOException $e) {
331
+						echo $e->getMessage();
332
+						die;
333
+				}
334
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
335 335
 
336
-                return $spotter_array;
337
-        }
336
+				return $spotter_array;
337
+		}
338 338
 
339 339
 
340
-        /**
341
-        * Gets altitude information based on a particular callsign
342
-        *
343
-        * @return Array the spotter information
344
-        *
345
-        */
346
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
347
-        {
340
+		/**
341
+		 * Gets altitude information based on a particular callsign
342
+		 *
343
+		 * @return Array the spotter information
344
+		 *
345
+		 */
346
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
347
+		{
348 348
 
349
-                date_default_timezone_set('UTC');
349
+				date_default_timezone_set('UTC');
350 350
 
351
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
352
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
351
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
352
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
353 353
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
354 354
 
355
-                try {
356
-                        $sth = $this->db->prepare($query);
357
-                        $sth->execute(array(':ident' => $ident));
358
-                } catch(PDOException $e) {
359
-                        echo $e->getMessage();
360
-                        die;
361
-                }
362
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
355
+				try {
356
+						$sth = $this->db->prepare($query);
357
+						$sth->execute(array(':ident' => $ident));
358
+				} catch(PDOException $e) {
359
+						echo $e->getMessage();
360
+						die;
361
+				}
362
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
363 363
 
364
-                return $spotter_array;
365
-        }
364
+				return $spotter_array;
365
+		}
366 366
 
367 367
 
368 368
 
369
-       /**
370
-        * Gets all the archive spotter information
371
-        *
372
-        * @return Array the spotter information
373
-        *
374
-        */
375
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
376
-        {
377
-    		$Spotter = new Spotter($this->db);
378
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
379
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
369
+	   /**
370
+	    * Gets all the archive spotter information
371
+	    *
372
+	    * @return Array the spotter information
373
+	    *
374
+	    */
375
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
376
+		{
377
+			$Spotter = new Spotter($this->db);
378
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
379
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
380 380
 
381
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
381
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
382 382
 
383
-                return $spotter_array;
384
-        }
383
+				return $spotter_array;
384
+		}
385 385
         
386
-        public function deleteSpotterArchiveTrackData()
387
-        {
386
+		public function deleteSpotterArchiveTrackData()
387
+		{
388 388
 		global $globalArchiveKeepTrackMonths, $globalDBdriver;
389 389
 		if ($globalDBdriver == 'mysql') {
390 390
 			$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
391 391
 		} else {
392 392
 			$query = "DELETE FROM spotter_archive WHERE spotter_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH'";
393 393
 		}
394
-                try {
395
-                        $sth = $this->db->prepare($query);
396
-                        $sth->execute();
397
-                } catch(PDOException $e) {
398
-                        echo $e->getMessage();
399
-                        die;
400
-                }
394
+				try {
395
+						$sth = $this->db->prepare($query);
396
+						$sth->execute();
397
+				} catch(PDOException $e) {
398
+						echo $e->getMessage();
399
+						die;
400
+				}
401 401
 	}
402 402
 
403 403
 	/**
404
-        * Gets Minimal Live Spotter data
405
-        *
406
-        * @return Array the spotter information
407
-        *
408
-        */
409
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
410
-        {
411
-                global $globalDBdriver, $globalLiveInterval;
412
-                date_default_timezone_set('UTC');
413
-
414
-                $filter_query = '';
415
-                if (isset($filter['source']) && !empty($filter['source'])) {
416
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
417
-                }
418
-                // Use spotter_output also ?
419
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
420
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
421
-                }
422
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
423
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
424
-                }
425
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
426
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
427
-                }
428
-
429
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
430
-                if ($globalDBdriver == 'mysql') {
431
-                        /*
404
+	 * Gets Minimal Live Spotter data
405
+	 *
406
+	 * @return Array the spotter information
407
+	 *
408
+	 */
409
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
410
+		{
411
+				global $globalDBdriver, $globalLiveInterval;
412
+				date_default_timezone_set('UTC');
413
+
414
+				$filter_query = '';
415
+				if (isset($filter['source']) && !empty($filter['source'])) {
416
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
417
+				}
418
+				// Use spotter_output also ?
419
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
420
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
421
+				}
422
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
423
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
424
+				}
425
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
426
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
427
+				}
428
+
429
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
430
+				if ($globalDBdriver == 'mysql') {
431
+						/*
432 432
                         $query  = 'SELECT a.aircraft_shadow, 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 
433 433
                     		    FROM spotter_archive 
434 434
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -447,56 +447,56 @@  discard block
 block discarded – undo
447 447
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
448 448
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
449 449
                         	    '.$filter_query.' ORDER BY flightaware_id';
450
-                } else {
451
-                        //$query  = '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, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
452
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
450
+				} else {
451
+						//$query  = '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, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
452
+						$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
453 453
                         	    FROM spotter_archive 
454 454
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
455 455
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
456 456
                         	    '.$filter_query.' ORDER BY flightaware_id';
457
-                }
458
-                //echo $query;
459
-                try {
460
-                        $sth = $this->db->prepare($query);
461
-                        $sth->execute();
462
-                } catch(PDOException $e) {
463
-                        echo $e->getMessage();
464
-                        die;
465
-                }
466
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
467
-
468
-                return $spotter_array;
469
-        }
457
+				}
458
+				//echo $query;
459
+				try {
460
+						$sth = $this->db->prepare($query);
461
+						$sth->execute();
462
+				} catch(PDOException $e) {
463
+						echo $e->getMessage();
464
+						die;
465
+				}
466
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
467
+
468
+				return $spotter_array;
469
+		}
470 470
 
471 471
 	/**
472
-        * Gets Minimal Live Spotter data
473
-        *
474
-        * @return Array the spotter information
475
-        *
476
-        */
477
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
478
-        {
479
-                global $globalDBdriver, $globalLiveInterval;
480
-                date_default_timezone_set('UTC');
481
-
482
-                $filter_query = '';
483
-                if (isset($filter['source']) && !empty($filter['source'])) {
484
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
485
-                }
486
-                // Should use spotter_output also ?
487
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
488
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
489
-                }
490
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
491
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
492
-                }
493
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
494
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
495
-                }
496
-
497
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
498
-                if ($globalDBdriver == 'mysql') {
499
-                        /*
472
+	 * Gets Minimal Live Spotter data
473
+	 *
474
+	 * @return Array the spotter information
475
+	 *
476
+	 */
477
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
478
+		{
479
+				global $globalDBdriver, $globalLiveInterval;
480
+				date_default_timezone_set('UTC');
481
+
482
+				$filter_query = '';
483
+				if (isset($filter['source']) && !empty($filter['source'])) {
484
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
485
+				}
486
+				// Should use spotter_output also ?
487
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
488
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
489
+				}
490
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
491
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
492
+				}
493
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
494
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
495
+				}
496
+
497
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
498
+				if ($globalDBdriver == 'mysql') {
499
+						/*
500 500
                         $query  = 'SELECT a.aircraft_shadow, 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 
501 501
                     		    FROM spotter_archive 
502 502
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -507,95 +507,95 @@  discard block
 block discarded – undo
507 507
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
508 508
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
509 509
 
510
-                } else {
511
-                        //$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
512
-                       /*
510
+				} else {
511
+						//$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
512
+					   /*
513 513
                         $query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
514 514
                         	    FROM spotter_archive_output 
515 515
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
516 516
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
517 517
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
518 518
                         */
519
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
519
+						$query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
520 520
                         	    FROM spotter_archive_output 
521 521
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
522 522
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
523 523
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
524 524
 //                        	    .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
525 525
                         	    
526
-                }
527
-                //echo $query;
528
-                try {
529
-                        $sth = $this->db->prepare($query);
530
-                        $sth->execute();
531
-                } catch(PDOException $e) {
532
-                        echo $e->getMessage();
533
-                        die;
534
-                }
535
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
536
-
537
-                return $spotter_array;
538
-        }
526
+				}
527
+				//echo $query;
528
+				try {
529
+						$sth = $this->db->prepare($query);
530
+						$sth->execute();
531
+				} catch(PDOException $e) {
532
+						echo $e->getMessage();
533
+						die;
534
+				}
535
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
536
+
537
+				return $spotter_array;
538
+		}
539 539
 
540 540
 	 /**
541
-        * Gets count Live Spotter data
542
-        *
543
-        * @return Array the spotter information
544
-        *
545
-        */
546
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
547
-        {
548
-                global $globalDBdriver, $globalLiveInterval;
549
-                date_default_timezone_set('UTC');
550
-
551
-                $filter_query = '';
552
-                if (isset($filter['source']) && !empty($filter['source'])) {
553
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
554
-                }
555
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
556
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
557
-                }
558
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
559
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
560
-                }
561
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
562
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
563
-                }
564
-
565
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
566
-                if ($globalDBdriver == 'mysql') {
541
+	  * Gets count Live Spotter data
542
+	  *
543
+	  * @return Array the spotter information
544
+	  *
545
+	  */
546
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
547
+		{
548
+				global $globalDBdriver, $globalLiveInterval;
549
+				date_default_timezone_set('UTC');
550
+
551
+				$filter_query = '';
552
+				if (isset($filter['source']) && !empty($filter['source'])) {
553
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
554
+				}
555
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
556
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
557
+				}
558
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
559
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
560
+				}
561
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
562
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
563
+				}
564
+
565
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
566
+				if ($globalDBdriver == 'mysql') {
567 567
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
568 568
 			FROM spotter_archive l 
569 569
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
570
-                } else {
570
+				} else {
571 571
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
572
-                }
573
-                //echo $query;
574
-                try {
575
-                        $sth = $this->db->prepare($query);
576
-                        $sth->execute();
577
-                } catch(PDOException $e) {
578
-                        echo $e->getMessage();
579
-                        die;
580
-                }
572
+				}
573
+				//echo $query;
574
+				try {
575
+						$sth = $this->db->prepare($query);
576
+						$sth->execute();
577
+				} catch(PDOException $e) {
578
+						echo $e->getMessage();
579
+						die;
580
+				}
581 581
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
582 582
 		$sth->closeCursor();
583
-                return $result['nb'];
583
+				return $result['nb'];
584 584
 
585
-        }
585
+		}
586 586
 
587 587
 
588 588
 
589 589
 	// Spotter_Archive_output
590 590
 	
591
-    /**
592
-    * Gets all the spotter information
593
-    *
594
-    * @return Array the spotter information
595
-    *
596
-    */
597
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
598
-    {
591
+	/**
592
+	 * Gets all the spotter information
593
+	 *
594
+	 * @return Array the spotter information
595
+	 *
596
+	 */
597
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
598
+	{
599 599
 	global $globalTimezone, $globalDBdriver;
600 600
 	require_once(dirname(__FILE__).'/class.Translation.php');
601 601
 	$Translation = new Translation();
@@ -609,159 +609,159 @@  discard block
 block discarded – undo
609 609
 	$filter_query = $this->getFilter($filters);
610 610
 	if ($q != "")
611 611
 	{
612
-	    if (!is_string($q))
613
-	    {
612
+		if (!is_string($q))
613
+		{
614 614
 		return false;
615
-	    } else {
615
+		} else {
616 616
 	        
617 617
 		$q_array = explode(" ", $q);
618 618
 		
619 619
 		foreach ($q_array as $q_item){
620
-		    $additional_query .= " AND (";
621
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
622
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
623
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
624
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
625
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
626
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
627
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
628
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
629
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
630
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
631
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
632
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
633
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
634
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
635
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
636
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
637
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
638
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
639
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
640
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
641
-		    $translate = $Translation->ident2icao($q_item);
642
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
643
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
644
-		    $additional_query .= ")";
645
-		}
646
-	    }
620
+			$additional_query .= " AND (";
621
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
622
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
623
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
624
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
625
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
626
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
627
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
628
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
629
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
630
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
631
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
632
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
633
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
634
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
635
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
636
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
637
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
638
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
639
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
640
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
641
+			$translate = $Translation->ident2icao($q_item);
642
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
643
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
644
+			$additional_query .= ")";
645
+		}
646
+		}
647 647
 	}
648 648
 	
649 649
 	if ($registration != "")
650 650
 	{
651
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
652
-	    if (!is_string($registration))
653
-	    {
651
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
652
+		if (!is_string($registration))
653
+		{
654 654
 		return false;
655
-	    } else {
655
+		} else {
656 656
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
657
-	    }
657
+		}
658 658
 	}
659 659
 	
660 660
 	if ($aircraft_icao != "")
661 661
 	{
662
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
663
-	    if (!is_string($aircraft_icao))
664
-	    {
662
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
663
+		if (!is_string($aircraft_icao))
664
+		{
665 665
 		return false;
666
-	    } else {
666
+		} else {
667 667
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
668
-	    }
668
+		}
669 669
 	}
670 670
 	
671 671
 	if ($aircraft_manufacturer != "")
672 672
 	{
673
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
674
-	    if (!is_string($aircraft_manufacturer))
675
-	    {
673
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
674
+		if (!is_string($aircraft_manufacturer))
675
+		{
676 676
 		return false;
677
-	    } else {
677
+		} else {
678 678
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
679
-	    }
679
+		}
680 680
 	}
681 681
 	
682 682
 	if ($highlights == "true")
683 683
 	{
684
-	    if (!is_string($highlights))
685
-	    {
684
+		if (!is_string($highlights))
685
+		{
686 686
 		return false;
687
-	    } else {
687
+		} else {
688 688
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
689
-	    }
689
+		}
690 690
 	}
691 691
 	
692 692
 	if ($airline_icao != "")
693 693
 	{
694
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
695
-	    if (!is_string($airline_icao))
696
-	    {
694
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
695
+		if (!is_string($airline_icao))
696
+		{
697 697
 		return false;
698
-	    } else {
698
+		} else {
699 699
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
700
-	    }
700
+		}
701 701
 	}
702 702
 	
703 703
 	if ($airline_country != "")
704 704
 	{
705
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
706
-	    if (!is_string($airline_country))
707
-	    {
705
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
706
+		if (!is_string($airline_country))
707
+		{
708 708
 		return false;
709
-	    } else {
709
+		} else {
710 710
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
711
-	    }
711
+		}
712 712
 	}
713 713
 	
714 714
 	if ($airline_type != "")
715 715
 	{
716
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
717
-	    if (!is_string($airline_type))
718
-	    {
716
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
717
+		if (!is_string($airline_type))
718
+		{
719 719
 		return false;
720
-	    } else {
720
+		} else {
721 721
 		if ($airline_type == "passenger")
722 722
 		{
723
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
723
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
724 724
 		}
725 725
 		if ($airline_type == "cargo")
726 726
 		{
727
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
727
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
728 728
 		}
729 729
 		if ($airline_type == "military")
730 730
 		{
731
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
731
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
732
+		}
732 733
 		}
733
-	    }
734 734
 	}
735 735
 	
736 736
 	if ($airport != "")
737 737
 	{
738
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
739
-	    if (!is_string($airport))
740
-	    {
738
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
739
+		if (!is_string($airport))
740
+		{
741 741
 		return false;
742
-	    } else {
742
+		} else {
743 743
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
744
-	    }
744
+		}
745 745
 	}
746 746
 	
747 747
 	if ($airport_country != "")
748 748
 	{
749
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
750
-	    if (!is_string($airport_country))
751
-	    {
749
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
750
+		if (!is_string($airport_country))
751
+		{
752 752
 		return false;
753
-	    } else {
753
+		} else {
754 754
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
755
-	    }
755
+		}
756 756
 	}
757 757
     
758 758
 	if ($callsign != "")
759 759
 	{
760
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
761
-	    if (!is_string($callsign))
762
-	    {
760
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
761
+		if (!is_string($callsign))
762
+		{
763 763
 		return false;
764
-	    } else {
764
+		} else {
765 765
 		$translate = $Translation->ident2icao($callsign);
766 766
 		if ($translate != $callsign) {
767 767
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -769,99 +769,99 @@  discard block
 block discarded – undo
769 769
 		} else {
770 770
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
771 771
 		}
772
-	    }
772
+		}
773 773
 	}
774 774
 
775 775
 	if ($owner != "")
776 776
 	{
777
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
778
-	    if (!is_string($owner))
779
-	    {
777
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
778
+		if (!is_string($owner))
779
+		{
780 780
 		return false;
781
-	    } else {
781
+		} else {
782 782
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
783
-	    }
783
+		}
784 784
 	}
785 785
 
786 786
 	if ($pilot_name != "")
787 787
 	{
788
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
789
-	    if (!is_string($pilot_name))
790
-	    {
788
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
789
+		if (!is_string($pilot_name))
790
+		{
791 791
 		return false;
792
-	    } else {
792
+		} else {
793 793
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
794
-	    }
794
+		}
795 795
 	}
796 796
 	
797 797
 	if ($pilot_id != "")
798 798
 	{
799
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
800
-	    if (!is_string($pilot_id))
801
-	    {
799
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
800
+		if (!is_string($pilot_id))
801
+		{
802 802
 		return false;
803
-	    } else {
803
+		} else {
804 804
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
805
-	    }
805
+		}
806 806
 	}
807 807
 	
808 808
 	if ($departure_airport_route != "")
809 809
 	{
810
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
811
-	    if (!is_string($departure_airport_route))
812
-	    {
810
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
811
+		if (!is_string($departure_airport_route))
812
+		{
813 813
 		return false;
814
-	    } else {
814
+		} else {
815 815
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
816
-	    }
816
+		}
817 817
 	}
818 818
 	
819 819
 	if ($arrival_airport_route != "")
820 820
 	{
821
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
822
-	    if (!is_string($arrival_airport_route))
823
-	    {
821
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
822
+		if (!is_string($arrival_airport_route))
823
+		{
824 824
 		return false;
825
-	    } else {
825
+		} else {
826 826
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
827
-	    }
827
+		}
828 828
 	}
829 829
 	
830 830
 	if ($altitude != "")
831 831
 	{
832
-	    $altitude_array = explode(",", $altitude);
832
+		$altitude_array = explode(",", $altitude);
833 833
 	    
834
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
835
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
834
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
835
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
836 836
 	    
837 837
 
838
-	    if ($altitude_array[1] != "")
839
-	    {                
838
+		if ($altitude_array[1] != "")
839
+		{                
840 840
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
841 841
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
842 842
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
843
-	    } else {
843
+		} else {
844 844
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
845 845
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
846
-	    }
846
+		}
847 847
 	}
848 848
 	
849 849
 	if ($date_posted != "")
850 850
 	{
851
-	    $date_array = explode(",", $date_posted);
851
+		$date_array = explode(",", $date_posted);
852 852
 	    
853
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
854
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
853
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
854
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
855 855
 	    
856
-	    if ($globalTimezone != '') {
856
+		if ($globalTimezone != '') {
857 857
 		date_default_timezone_set($globalTimezone);
858 858
 		$datetime = new DateTime();
859 859
 		$offset = $datetime->format('P');
860
-	    } else $offset = '+00:00';
860
+		} else $offset = '+00:00';
861 861
 
862 862
 
863
-	    if ($date_array[1] != "")
864
-	    {                
863
+		if ($date_array[1] != "")
864
+		{                
865 865
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
866 866
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
867 867
 		if ($globalDBdriver == 'mysql') {
@@ -869,28 +869,28 @@  discard block
 block discarded – undo
869 869
 		} else {
870 870
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
871 871
 		}
872
-	    } else {
872
+		} else {
873 873
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
874
-                if ($globalDBdriver == 'mysql') {
874
+				if ($globalDBdriver == 'mysql') {
875 875
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
876 876
 		} else {
877 877
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
878 878
 		}
879
-	    }
879
+		}
880 880
 	}
881 881
 	
882 882
 	if ($limit != "")
883 883
 	{
884
-	    $limit_array = explode(",", $limit);
884
+		$limit_array = explode(",", $limit);
885 885
 	    
886
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
887
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
886
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
887
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
888 888
 	    
889
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
890
-	    {
889
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
890
+		{
891 891
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
892 892
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
893
-	    }
893
+		}
894 894
 	}
895 895
 	
896 896
 
@@ -921,33 +921,33 @@  discard block
 block discarded – undo
921 921
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
922 922
 
923 923
 	return $spotter_array;
924
-    }
924
+	}
925 925
 
926
-    public function deleteSpotterArchiveData()
927
-    {
926
+	public function deleteSpotterArchiveData()
927
+	{
928 928
 		global $globalArchiveKeepMonths, $globalDBdriver;
929
-                date_default_timezone_set('UTC');
930
-                if ($globalDBdriver == 'mysql') {
929
+				date_default_timezone_set('UTC');
930
+				if ($globalDBdriver == 'mysql') {
931 931
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
932 932
 		} else {
933 933
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
934 934
 		}
935
-                try {
936
-                        $sth = $this->db->prepare($query);
937
-                        $sth->execute();
938
-                } catch(PDOException $e) {
939
-                        return "error";
940
-                }
935
+				try {
936
+						$sth = $this->db->prepare($query);
937
+						$sth->execute();
938
+				} catch(PDOException $e) {
939
+						return "error";
940
+				}
941 941
 	}
942 942
 
943
-    /**
944
-    * Gets all the spotter information based on the callsign
945
-    *
946
-    * @return Array the spotter information
947
-    *
948
-    */
949
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
950
-    {
943
+	/**
944
+	 * Gets all the spotter information based on the callsign
945
+	 *
946
+	 * @return Array the spotter information
947
+	 *
948
+	 */
949
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
950
+	{
951 951
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
952 952
 	
953 953
 	date_default_timezone_set('UTC');
@@ -959,35 +959,35 @@  discard block
 block discarded – undo
959 959
 	
960 960
 	if ($ident != "")
961 961
 	{
962
-	    if (!is_string($ident))
963
-	    {
962
+		if (!is_string($ident))
963
+		{
964 964
 		return false;
965
-	    } else {
965
+		} else {
966 966
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
967 967
 		$query_values = array(':ident' => $ident);
968
-	    }
968
+		}
969 969
 	}
970 970
 	
971 971
 	if ($limit != "")
972 972
 	{
973
-	    $limit_array = explode(",", $limit);
973
+		$limit_array = explode(",", $limit);
974 974
 	    
975
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
976
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
975
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
976
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
977 977
 	    
978
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
979
-	    {
978
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
979
+		{
980 980
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
981 981
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
982
-	    }
982
+		}
983 983
 	}
984 984
 
985 985
 	if ($sort != "")
986 986
 	{
987
-	    $search_orderby_array = $Spotter->getOrderBy();
988
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
987
+		$search_orderby_array = $Spotter->getOrderBy();
988
+		$orderby_query = $search_orderby_array[$sort]['sql'];
989 989
 	} else {
990
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
990
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
991 991
 	}
992 992
 
993 993
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -995,17 +995,17 @@  discard block
 block discarded – undo
995 995
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
996 996
 
997 997
 	return $spotter_array;
998
-    }
998
+	}
999 999
 
1000 1000
 
1001
-    /**
1002
-    * Gets all the spotter information based on the owner
1003
-    *
1004
-    * @return Array the spotter information
1005
-    *
1006
-    */
1007
-    public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1008
-    {
1001
+	/**
1002
+	 * Gets all the spotter information based on the owner
1003
+	 *
1004
+	 * @return Array the spotter information
1005
+	 *
1006
+	 */
1007
+	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1008
+	{
1009 1009
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1010 1010
 	
1011 1011
 	date_default_timezone_set('UTC');
@@ -1018,35 +1018,35 @@  discard block
 block discarded – undo
1018 1018
 	
1019 1019
 	if ($owner != "")
1020 1020
 	{
1021
-	    if (!is_string($owner))
1022
-	    {
1021
+		if (!is_string($owner))
1022
+		{
1023 1023
 		return false;
1024
-	    } else {
1024
+		} else {
1025 1025
 		$additional_query = " AND (spotter_archive_output.owner_name = :owner)";
1026 1026
 		$query_values = array(':owner' => $owner);
1027
-	    }
1027
+		}
1028 1028
 	}
1029 1029
 	
1030 1030
 	if ($limit != "")
1031 1031
 	{
1032
-	    $limit_array = explode(",", $limit);
1032
+		$limit_array = explode(",", $limit);
1033 1033
 	    
1034
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1035
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1034
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1035
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1036 1036
 	    
1037
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1038
-	    {
1037
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1038
+		{
1039 1039
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1040 1040
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1041
-	    }
1041
+		}
1042 1042
 	}
1043 1043
 
1044 1044
 	if ($sort != "")
1045 1045
 	{
1046
-	    $search_orderby_array = $Spotter->getOrderBy();
1047
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1046
+		$search_orderby_array = $Spotter->getOrderBy();
1047
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1048 1048
 	} else {
1049
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1049
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1050 1050
 	}
1051 1051
 
1052 1052
 	$query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1054,16 +1054,16 @@  discard block
 block discarded – undo
1054 1054
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1055 1055
 
1056 1056
 	return $spotter_array;
1057
-    }
1058
-
1059
-    /**
1060
-    * Gets all the spotter information based on the pilot
1061
-    *
1062
-    * @return Array the spotter information
1063
-    *
1064
-    */
1065
-    public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1066
-    {
1057
+	}
1058
+
1059
+	/**
1060
+	 * Gets all the spotter information based on the pilot
1061
+	 *
1062
+	 * @return Array the spotter information
1063
+	 *
1064
+	 */
1065
+	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1066
+	{
1067 1067
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1068 1068
 	
1069 1069
 	date_default_timezone_set('UTC');
@@ -1082,24 +1082,24 @@  discard block
 block discarded – undo
1082 1082
 	
1083 1083
 	if ($limit != "")
1084 1084
 	{
1085
-	    $limit_array = explode(",", $limit);
1085
+		$limit_array = explode(",", $limit);
1086 1086
 	    
1087
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1088
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1087
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1088
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1089 1089
 	    
1090
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1091
-	    {
1090
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1091
+		{
1092 1092
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1093 1093
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1094
-	    }
1094
+		}
1095 1095
 	}
1096 1096
 
1097 1097
 	if ($sort != "")
1098 1098
 	{
1099
-	    $search_orderby_array = $Spotter->getOrderBy();
1100
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1099
+		$search_orderby_array = $Spotter->getOrderBy();
1100
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1101 1101
 	} else {
1102
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1102
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1103 1103
 	}
1104 1104
 
1105 1105
 	$query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1107,16 +1107,16 @@  discard block
 block discarded – undo
1107 1107
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1108 1108
 
1109 1109
 	return $spotter_array;
1110
-    }
1111
-
1112
-    /**
1113
-    * Gets all number of flight over countries
1114
-    *
1115
-    * @return Array the airline country list
1116
-    *
1117
-    */
1118
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
-    {
1110
+	}
1111
+
1112
+	/**
1113
+	 * Gets all number of flight over countries
1114
+	 *
1115
+	 * @return Array the airline country list
1116
+	 *
1117
+	 */
1118
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
+	{
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
1122 1122
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1126,14 +1126,14 @@  discard block
 block discarded – undo
1126 1126
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1127 1127
 		    FROM countries c, spotter_archive s
1128 1128
 		    WHERE c.iso2 = s.over_country ";
1129
-                if ($olderthanmonths > 0) {
1130
-            		if ($globalDBdriver == 'mysql') {
1129
+				if ($olderthanmonths > 0) {
1130
+					if ($globalDBdriver == 'mysql') {
1131 1131
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1132 1132
 			} else {
1133 1133
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1134
 			}
1135 1135
 		}
1136
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1136
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1137 1137
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138 1138
 	if ($limit) $query .= " LIMIT 0,10";
1139 1139
       
@@ -1146,23 +1146,23 @@  discard block
 block discarded – undo
1146 1146
         
1147 1147
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149
-	    $temp_array['flight_count'] = $row['nb'];
1150
-	    $temp_array['flight_country'] = $row['name'];
1151
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1152
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1153
-	    $flight_array[] = $temp_array;
1149
+		$temp_array['flight_count'] = $row['nb'];
1150
+		$temp_array['flight_country'] = $row['name'];
1151
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1152
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1153
+		$flight_array[] = $temp_array;
1154 1154
 	}
1155 1155
 	return $flight_array;
1156
-    }
1157
-
1158
-    /**
1159
-    * Gets all number of flight over countries
1160
-    *
1161
-    * @return Array the airline country list
1162
-    *
1163
-    */
1164
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1165
-    {
1156
+	}
1157
+
1158
+	/**
1159
+	 * Gets all number of flight over countries
1160
+	 *
1161
+	 * @return Array the airline country list
1162
+	 *
1163
+	 */
1164
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1165
+	{
1166 1166
 	global $globalDBdriver;
1167 1167
 	/*
1168 1168
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1172,14 +1172,14 @@  discard block
 block discarded – undo
1172 1172
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1173 1173
 		    FROM countries c, spotter_archive s, spotter_output o
1174 1174
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id ";
1175
-                if ($olderthanmonths > 0) {
1176
-            		if ($globalDBdriver == 'mysql') {
1175
+				if ($olderthanmonths > 0) {
1176
+					if ($globalDBdriver == 'mysql') {
1177 1177
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1178 1178
 			} else {
1179 1179
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1180 1180
 			}
1181 1181
 		}
1182
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1182
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1183 1183
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1184 1184
 	if ($limit) $query .= " LIMIT 0,10";
1185 1185
       
@@ -1192,24 +1192,24 @@  discard block
 block discarded – undo
1192 1192
         
1193 1193
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1194 1194
 	{
1195
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1196
-	    $temp_array['flight_count'] = $row['nb'];
1197
-	    $temp_array['flight_country'] = $row['name'];
1198
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1199
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1200
-	    $flight_array[] = $temp_array;
1195
+		$temp_array['airline_icao'] = $row['airline_icao'];
1196
+		$temp_array['flight_count'] = $row['nb'];
1197
+		$temp_array['flight_country'] = $row['name'];
1198
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1199
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1200
+		$flight_array[] = $temp_array;
1201 1201
 	}
1202 1202
 	return $flight_array;
1203
-    }
1204
-
1205
-    /**
1206
-    * Gets last spotter information based on a particular callsign
1207
-    *
1208
-    * @return Array the spotter information
1209
-    *
1210
-    */
1211
-    public function getDateArchiveSpotterDataById($id,$date)
1212
-    {
1203
+	}
1204
+
1205
+	/**
1206
+	 * Gets last spotter information based on a particular callsign
1207
+	 *
1208
+	 * @return Array the spotter information
1209
+	 *
1210
+	 */
1211
+	public function getDateArchiveSpotterDataById($id,$date)
1212
+	{
1213 1213
 	$Spotter = new Spotter($this->db);
1214 1214
 	date_default_timezone_set('UTC');
1215 1215
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1217,16 +1217,16 @@  discard block
 block discarded – undo
1217 1217
 	$date = date('c',$date);
1218 1218
 	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1219 1219
 	return $spotter_array;
1220
-    }
1221
-
1222
-    /**
1223
-    * Gets all the spotter information based on a particular callsign
1224
-    *
1225
-    * @return Array the spotter information
1226
-    *
1227
-    */
1228
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1229
-    {
1220
+	}
1221
+
1222
+	/**
1223
+	 * Gets all the spotter information based on a particular callsign
1224
+	 *
1225
+	 * @return Array the spotter information
1226
+	 *
1227
+	 */
1228
+	public function getDateArchiveSpotterDataByIdent($ident,$date)
1229
+	{
1230 1230
 	$Spotter = new Spotter($this->db);
1231 1231
 	date_default_timezone_set('UTC');
1232 1232
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1234,16 +1234,16 @@  discard block
 block discarded – undo
1234 1234
 	$date = date('c',$date);
1235 1235
 	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1236 1236
 	return $spotter_array;
1237
-    }
1238
-
1239
-    /**
1240
-    * Gets all the spotter information based on the airport
1241
-    *
1242
-    * @return Array the spotter information
1243
-    *
1244
-    */
1245
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1246
-    {
1237
+	}
1238
+
1239
+	/**
1240
+	 * Gets all the spotter information based on the airport
1241
+	 *
1242
+	 * @return Array the spotter information
1243
+	 *
1244
+	 */
1245
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1246
+	{
1247 1247
 	global $global_query;
1248 1248
 	$Spotter = new Spotter();
1249 1249
 	date_default_timezone_set('UTC');
@@ -1254,35 +1254,35 @@  discard block
 block discarded – undo
1254 1254
 	
1255 1255
 	if ($airport != "")
1256 1256
 	{
1257
-	    if (!is_string($airport))
1258
-	    {
1257
+		if (!is_string($airport))
1258
+		{
1259 1259
 		return false;
1260
-	    } else {
1260
+		} else {
1261 1261
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))";
1262 1262
 		$query_values = array(':airport' => $airport);
1263
-	    }
1263
+		}
1264 1264
 	}
1265 1265
 	
1266 1266
 	if ($limit != "")
1267 1267
 	{
1268
-	    $limit_array = explode(",", $limit);
1268
+		$limit_array = explode(",", $limit);
1269 1269
 	    
1270
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1271
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1270
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1271
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1272 1272
 	    
1273
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1274
-	    {
1273
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1274
+		{
1275 1275
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1276 1276
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1277
-	    }
1277
+		}
1278 1278
 	}
1279 1279
 	
1280 1280
 	if ($sort != "")
1281 1281
 	{
1282
-	    $search_orderby_array = $Spotter->getOrderBy();
1283
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1282
+		$search_orderby_array = $Spotter->getOrderBy();
1283
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1284 1284
 	} else {
1285
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1285
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1286 1286
 	}
1287 1287
 
1288 1288
 	$query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1290,6 +1290,6 @@  discard block
 block discarded – undo
1290 1290
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1291 1291
 
1292 1292
 	return $spotter_array;
1293
-    }
1293
+	}
1294 1294
 }
1295 1295
 ?>
1296 1296
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +40 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection.');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection.');
11
+		}
10 12
 	}
11 13
 
12 14
     /**
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 	if (isset($filter[0]['source'])) {
28 30
 		$filters = array_merge($filters,$filter);
29 31
 	}
30
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+	if (is_array($globalFilter)) {
33
+		$filter = array_merge($filter,$globalFilter);
34
+	}
31 35
 	$filter_query_join = '';
32 36
 	$filter_query_where = '';
33 37
 	foreach($filters as $flt) {
@@ -114,8 +118,11 @@  discard block
 block discarded – undo
114 118
 	    }
115 119
 	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
116 120
 	}
117
-	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
118
-	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
121
+	if ($filter_query_where == '' && $where) {
122
+		$filter_query_where = ' WHERE';
123
+	} elseif ($filter_query_where != '' && $and) {
124
+		$filter_query_where .= ' AND';
125
+	}
119 126
 	if ($filter_query_where != '') {
120 127
 		$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
121 128
 	}
@@ -129,10 +136,17 @@  discard block
 block discarded – undo
129 136
 		if ($over_country == '') {
130 137
 			$Spotter = new Spotter($this->db);
131 138
 			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
132
-			if (!empty($data_country)) $country = $data_country['iso2'];
133
-			else $country = '';
134
-		} else $country = $over_country;
135
-		if ($airline_type === NULL) $airline_type ='';
139
+			if (!empty($data_country)) {
140
+				$country = $data_country['iso2'];
141
+			} else {
142
+				$country = '';
143
+			}
144
+		} else {
145
+			$country = $over_country;
146
+		}
147
+		if ($airline_type === NULL) {
148
+			$airline_type ='';
149
+		}
136 150
 	
137 151
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
138 152
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
@@ -639,7 +653,9 @@  discard block
 block discarded – undo
639 653
 		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
640 654
 		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
641 655
 		    $translate = $Translation->ident2icao($q_item);
642
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
656
+		    if ($translate != $q_item) {
657
+		    	$additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
658
+		    }
643 659
 		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
644 660
 		    $additional_query .= ")";
645 661
 		}
@@ -857,7 +873,9 @@  discard block
 block discarded – undo
857 873
 		date_default_timezone_set($globalTimezone);
858 874
 		$datetime = new DateTime();
859 875
 		$offset = $datetime->format('P');
860
-	    } else $offset = '+00:00';
876
+	    } else {
877
+	    	$offset = '+00:00';
878
+	    }
861 879
 
862 880
 
863 881
 	    if ($date_array[1] != "")
@@ -1133,9 +1151,13 @@  discard block
 block discarded – undo
1133 1151
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1152
 			}
1135 1153
 		}
1136
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1154
+                if ($sincedate != '') {
1155
+                	$query .= "AND date > '".$sincedate."' ";
1156
+                }
1137 1157
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138
-	if ($limit) $query .= " LIMIT 0,10";
1158
+	if ($limit) {
1159
+		$query .= " LIMIT 0,10";
1160
+	}
1139 1161
       
1140 1162
 	
1141 1163
 	$sth = $this->db->prepare($query);
@@ -1179,9 +1201,13 @@  discard block
 block discarded – undo
1179 1201
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1180 1202
 			}
1181 1203
 		}
1182
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1204
+                if ($sincedate != '') {
1205
+                	$query .= "AND s.date > '".$sincedate."' ";
1206
+                }
1183 1207
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1184
-	if ($limit) $query .= " LIMIT 0,10";
1208
+	if ($limit) {
1209
+		$query .= " LIMIT 0,10";
1210
+	}
1185 1211
       
1186 1212
 	
1187 1213
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
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.');
10
+		if ($this->db === null) {
11
+			die('Error: No DB connection.');
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.MarineArchive.php 1 patch
Braces   +37 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection.');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection.');
11
+		}
10 12
 	}
11 13
 
12 14
 	/**
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 		if (isset($filter[0]['source'])) {
28 30
 			$filters = array_merge($filters,$filter);
29 31
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
31 35
 		$filter_query_join = '';
32 36
 		$filter_query_where = '';
33 37
 		foreach($filters as $flt) {
@@ -73,8 +77,11 @@  discard block
 block discarded – undo
73 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74 78
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
75 79
 		}
76
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
80
+		if ($filter_query_where == '' && $where) {
81
+			$filter_query_where = ' WHERE';
82
+		} elseif ($filter_query_where != '' && $and) {
83
+			$filter_query_where .= ' AND';
84
+		}
78 85
 		if ($filter_query_where != '') {
79 86
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
80 87
 		}
@@ -88,9 +95,14 @@  discard block
 block discarded – undo
88 95
 		if ($over_country == '') {
89 96
 			$Marine = new Marine($this->db);
90 97
 			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude);
91
-			if (!empty($data_country)) $country = $data_country['iso2'];
92
-			else $country = '';
93
-		} else $country = $over_country;
98
+			if (!empty($data_country)) {
99
+				$country = $data_country['iso2'];
100
+			} else {
101
+				$country = '';
102
+			}
103
+		} else {
104
+			$country = $over_country;
105
+		}
94 106
 		
95 107
 		//$country = $over_country;
96 108
 		// Route is not added in marine_archive
@@ -593,7 +605,9 @@  discard block
 block discarded – undo
593 605
 		    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
594 606
 		    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
595 607
 		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
608
+		    if ($translate != $q_item) {
609
+		    	$additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
610
+		    }
597 611
 		    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
598 612
 		    $additional_query .= ")";
599 613
 		}
@@ -811,7 +825,9 @@  discard block
 block discarded – undo
811 825
 		date_default_timezone_set($globalTimezone);
812 826
 		$datetime = new DateTime();
813 827
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
828
+	    } else {
829
+	    	$offset = '+00:00';
830
+	    }
815 831
 
816 832
 
817 833
 	    if ($date_array[1] != "")
@@ -1087,9 +1103,13 @@  discard block
 block discarded – undo
1087 1103
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1104
 			}
1089 1105
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1106
+                if ($sincedate != '') {
1107
+                	$query .= "AND date > '".$sincedate."' ";
1108
+                }
1091 1109
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092
-	if ($limit) $query .= " LIMIT 0,10";
1110
+	if ($limit) {
1111
+		$query .= " LIMIT 0,10";
1112
+	}
1093 1113
       
1094 1114
 	
1095 1115
 	$sth = $this->db->prepare($query);
@@ -1133,9 +1153,13 @@  discard block
 block discarded – undo
1133 1153
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1154
 			}
1135 1155
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1156
+                if ($sincedate != '') {
1157
+                	$query .= "AND s.date > '".$sincedate."' ";
1158
+                }
1137 1159
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138
-	if ($limit) $query .= " LIMIT 0,10";
1160
+	if ($limit) {
1161
+		$query .= " LIMIT 0,10";
1162
+	}
1139 1163
       
1140 1164
 	
1141 1165
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Braces   +77 added lines, -26 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.');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection.');
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";
@@ -183,7 +194,9 @@  discard block
 block discarded – undo
183 194
 
184 195
 		$filter_query = $this->getFilter($filter,true,true);
185 196
 
186
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
197
+		if (!isset($globalLiveInterval)) {
198
+			$globalLiveInterval = '200';
199
+		}
187 200
 		if ($globalDBdriver == 'mysql') {
188 201
 			if (isset($globalArchive) && $globalArchive) {
189 202
 				$query  = "SELECT * FROM (
@@ -241,7 +254,9 @@  discard block
 block discarded – undo
241 254
 		global $globalDBdriver, $globalLiveInterval;
242 255
 		$filter_query = $this->getFilter($filter,true,true);
243 256
 
244
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
257
+		if (!isset($globalLiveInterval)) {
258
+			$globalLiveInterval = '200';
259
+		}
245 260
 		if ($globalDBdriver == 'mysql') {
246 261
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
247 262
 		} else {
@@ -269,7 +284,9 @@  discard block
 block discarded – undo
269 284
 	{
270 285
 		global $globalDBdriver, $globalLiveInterval;
271 286
 		$Spotter = new Spotter($this->db);
272
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
287
+		if (!isset($globalLiveInterval)) {
288
+			$globalLiveInterval = '200';
289
+		}
273 290
 		$filter_query = $this->getFilter($filter);
274 291
 
275 292
 		if (is_array($coord)) {
@@ -277,7 +294,9 @@  discard block
 block discarded – undo
277 294
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278 295
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
279 296
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
280
-		} else return array();
297
+		} else {
298
+			return array();
299
+		}
281 300
 		if ($globalDBdriver == 'mysql') {
282 301
 			$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;
283 302
 		} else {
@@ -297,7 +316,9 @@  discard block
 block discarded – undo
297 316
 	{
298 317
 		global $globalDBdriver, $globalLiveInterval;
299 318
 		$Spotter = new Spotter($this->db);
300
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
319
+		if (!isset($globalLiveInterval)) {
320
+			$globalLiveInterval = '200';
321
+		}
301 322
 		$filter_query = $this->getFilter($filter);
302 323
 
303 324
 		if (is_array($coord)) {
@@ -305,7 +326,9 @@  discard block
 block discarded – undo
305 326
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
306 327
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
307 328
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
308
-		} else return array();
329
+		} else {
330
+			return array();
331
+		}
309 332
 		if ($globalDBdriver == 'mysql') {
310 333
 			$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 
311 334
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
@@ -498,11 +521,15 @@  discard block
 block discarded – undo
498 521
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
499 522
 		if ($globalDBdriver == 'mysql') {
500 523
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
501
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
524
+			if ($liveinterval) {
525
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
526
+			}
502 527
 			$query .= ' ORDER BY date';
503 528
 		} else {
504 529
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
505
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
530
+			if ($liveinterval) {
531
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
532
+			}
506 533
 			$query .= ' ORDER BY date';
507 534
 		}
508 535
 
@@ -597,7 +624,9 @@  discard block
 block discarded – undo
597 624
 				$i++;
598 625
 				$j++;
599 626
 				if ($j == 30) {
600
-					if ($globalDebug) echo ".";
627
+					if ($globalDebug) {
628
+						echo ".";
629
+					}
601 630
 				    	try {
602 631
 						
603 632
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -844,7 +873,9 @@  discard block
 block discarded – undo
844 873
 			{
845 874
 				return false;
846 875
 			}
847
-		} else return '';
876
+		} else {
877
+			return '';
878
+		}
848 879
 
849 880
 		if ($longitude != '')
850 881
 		{
@@ -852,7 +883,9 @@  discard block
 block discarded – undo
852 883
 			{
853 884
 				return false;
854 885
 			}
855
-		} else return '';
886
+		} else {
887
+			return '';
888
+		}
856 889
 
857 890
 		if ($altitude != '')
858 891
 		{
@@ -860,7 +893,9 @@  discard block
 block discarded – undo
860 893
 			{
861 894
 				return false;
862 895
 			}
863
-		} else $altitude = 0;
896
+		} else {
897
+			$altitude = 0;
898
+		}
864 899
 
865 900
 		if ($heading != '')
866 901
 		{
@@ -868,7 +903,9 @@  discard block
 block discarded – undo
868 903
 			{
869 904
 				return false;
870 905
 			}
871
-		} else $heading = 0;
906
+		} else {
907
+			$heading = 0;
908
+		}
872 909
 
873 910
 		if ($groundspeed != '')
874 911
 		{
@@ -876,9 +913,13 @@  discard block
 block discarded – undo
876 913
 			{
877 914
 				return false;
878 915
 			}
879
-		} else $groundspeed = 0;
916
+		} else {
917
+			$groundspeed = 0;
918
+		}
880 919
 		date_default_timezone_set('UTC');
881
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
920
+		if ($date == '') {
921
+			$date = date("Y-m-d H:i:s", time());
922
+		}
882 923
 
883 924
         
884 925
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -894,12 +935,18 @@  discard block
 block discarded – undo
894 935
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
895 936
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
896 937
 
897
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
898
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
938
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
939
+            		$groundspeed = 0;
940
+            	}
941
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
942
+            		$heading = 0;
943
+            	}
899 944
             	
900 945
 		$query = '';
901 946
 		if ($globalArchive) {
902
-			if ($globalDebug) echo '-- Delete previous data -- ';
947
+			if ($globalDebug) {
948
+				echo '-- Delete previous data -- ';
949
+			}
903 950
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
904 951
 		}
905 952
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -918,10 +965,14 @@  discard block
 block discarded – undo
918 965
                 echo 'noarchive : '.$noarchive."\n";
919 966
                 */
920 967
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
921
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
968
+		    if ($globalDebug) {
969
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
970
+		    }
922 971
 		    $TrackerArchive = new TrackerArchive($this->db);
923 972
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
924
-		    if ($globalDebug) echo $result.')';
973
+		    if ($globalDebug) {
974
+		    	echo $result.')';
975
+		    }
925 976
 		}
926 977
 
927 978
 		return "success";
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +173 added lines, -62 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.');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection.');
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) {
@@ -69,8 +73,11 @@  discard block
 block discarded – undo
69 73
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
70 74
 			}
71 75
 		}
72
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
73
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
76
+		if ($filter_query_where == '' && $where) {
77
+			$filter_query_where = ' WHERE';
78
+		} elseif ($filter_query_where != '' && $and) {
79
+			$filter_query_where .= ' AND';
80
+		}
74 81
 		if ($filter_query_where != '') {
75 82
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
76 83
 		}
@@ -124,32 +131,54 @@  discard block
 block discarded – undo
124 131
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
125 132
 			} elseif (isset($row['spotter_archive_output_id'])) {
126 133
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
127
-			*/} 
128
-			elseif (isset($row['marineid'])) {
134
+			*/} elseif (isset($row['marineid'])) {
129 135
 				$temp_array['marine_id'] = $row['marineid'];
130 136
 			} else {
131 137
 				$temp_array['marine_id'] = '';
132 138
 			}
133
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
134
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
135
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
136
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
137
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
138
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
139
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
140
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
139
+			if (isset($row['fammarine_id'])) {
140
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
141
+			}
142
+			if (isset($row['mmsi'])) {
143
+				$temp_array['mmsi'] = $row['mmsi'];
144
+			}
145
+			if (isset($row['type'])) {
146
+				$temp_array['type'] = $row['type'];
147
+			}
148
+			if (isset($row['type_id'])) {
149
+				$temp_array['type_id'] = $row['type_id'];
150
+			}
151
+			if (isset($row['ident'])) {
152
+				$temp_array['ident'] = $row['ident'];
153
+			}
154
+			if (isset($row['latitude'])) {
155
+				$temp_array['latitude'] = $row['latitude'];
156
+			}
157
+			if (isset($row['longitude'])) {
158
+				$temp_array['longitude'] = $row['longitude'];
159
+			}
160
+			if (isset($row['format_source'])) {
161
+				$temp_array['format_source'] = $row['format_source'];
162
+			}
141 163
 			if (isset($row['heading'])) {
142 164
 				$temp_array['heading'] = $row['heading'];
143 165
 				$heading_direction = $this->parseDirection($row['heading']);
144
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
166
+				if (isset($heading_direction[0]['direction_fullname'])) {
167
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
168
+				}
169
+			}
170
+			if (isset($row['ground_speed'])) {
171
+				$temp_array['ground_speed'] = $row['ground_speed'];
145 172
 			}
146
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
147 173
 
148 174
 			if($temp_array['mmsi'] != "")
149 175
 			{
150 176
 				$Image = new Image($this->db);
151
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
152
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
177
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
178
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
179
+				} else {
180
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
181
+				}
153 182
 				unset($Image);
154 183
 				if (count($image_array) > 0) {
155 184
 					$temp_array['image'] = $image_array[0]['image'];
@@ -201,13 +230,21 @@  discard block
 block discarded – undo
201 230
 			}
202 231
 			
203 232
 			$fromsource = NULL;
204
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
205
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
206
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
233
+			if (isset($row['source_name']) && $row['source_name'] != '') {
234
+				$temp_array['source_name'] = $row['source_name'];
235
+			}
236
+			if (isset($row['over_country']) && $row['over_country'] != '') {
237
+				$temp_array['over_country'] = $row['over_country'];
238
+			}
239
+			if (isset($row['distance']) && $row['distance'] != '') {
240
+				$temp_array['distance'] = $row['distance'];
241
+			}
207 242
 			$temp_array['query_number_rows'] = $num_rows;
208 243
 			$spotter_array[] = $temp_array;
209 244
 		}
210
-		if ($num_rows == 0) return array();
245
+		if ($num_rows == 0) {
246
+			return array();
247
+		}
211 248
 		$spotter_array[0]['query_number_rows'] = $num_rows;
212 249
 		return $spotter_array;
213 250
 	}	
@@ -233,8 +270,12 @@  discard block
 block discarded – undo
233 270
 			{
234 271
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
235 272
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
236
-			} else $limit_query = "";
237
-		} else $limit_query = "";
273
+			} else {
274
+				$limit_query = "";
275
+			}
276
+		} else {
277
+			$limit_query = "";
278
+		}
238 279
 		if ($sort != "")
239 280
 		{
240 281
 			$search_orderby_array = $this->getOrderBy();
@@ -258,7 +299,9 @@  discard block
 block discarded – undo
258 299
 		global $global_query;
259 300
 		
260 301
 		date_default_timezone_set('UTC');
261
-		if ($id == '') return array();
302
+		if ($id == '') {
303
+			return array();
304
+		}
262 305
 		$additional_query = "marine_output.fammarine_id = :id";
263 306
 		$query_values = array(':id' => $id);
264 307
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -401,8 +444,11 @@  discard block
 block discarded – undo
401 444
 		$query .= " ORDER BY marine_output.source_name ASC";
402 445
 
403 446
 		$sth = $this->db->prepare($query);
404
-		if (!empty($query_values)) $sth->execute($query_values);
405
-		else $sth->execute();
447
+		if (!empty($query_values)) {
448
+			$sth->execute($query_values);
449
+		} else {
450
+			$sth->execute();
451
+		}
406 452
 
407 453
 		$source_array = array();
408 454
 		$temp_array = array();
@@ -457,8 +503,11 @@  discard block
 block discarded – undo
457 503
 		$sth = $this->db->prepare($query);
458 504
 		$sth->execute(array(':mmsi' => $mmsi));
459 505
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
460
-		if (isset($result[0])) return $result[0];
461
-		else return array();
506
+		if (isset($result[0])) {
507
+			return $result[0];
508
+		} else {
509
+			return array();
510
+		}
462 511
 	}
463 512
 
464 513
 	/*
@@ -474,7 +523,9 @@  discard block
 block discarded – undo
474 523
 			date_default_timezone_set($globalTimezone);
475 524
 			$datetime = new DateTime();
476 525
 			$offset = $datetime->format('P');
477
-		} else $offset = '+00:00';
526
+		} else {
527
+			$offset = '+00:00';
528
+		}
478 529
 
479 530
 		if ($globalDBdriver == 'mysql') {
480 531
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -704,9 +755,15 @@  discard block
 block discarded – undo
704 755
             		$latitude = 0;
705 756
             		$longitude = 0;
706 757
             	}
707
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
708
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
709
-                if ($arrival_date == '') $arrival_date = NULL;
758
+                if ($heading == '' || $Common->isInteger($heading) === false) {
759
+                	$heading = 0;
760
+                }
761
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
762
+                	$groundspeed = 0;
763
+                }
764
+                if ($arrival_date == '') {
765
+                	$arrival_date = NULL;
766
+                }
710 767
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
711 768
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
712 769
 
@@ -814,7 +871,9 @@  discard block
 block discarded – undo
814 871
 		global $globalDBdriver, $globalArchive;
815 872
 		//$filter_query = $this->getFilter($filters,true,true);
816 873
 		$Connection= new Connection($this->db);
817
-		if (!$Connection->tableExists('countries')) return array();
874
+		if (!$Connection->tableExists('countries')) {
875
+			return array();
876
+		}
818 877
 		require_once('class.SpotterLive.php');
819 878
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
820 879
 			$MarineLive = new MarineLive();
@@ -858,7 +917,9 @@  discard block
 block discarded – undo
858 917
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
859 918
 		}
860 919
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
861
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
920
+		if ($limit) {
921
+			$query .= " LIMIT 10 OFFSET 0";
922
+		}
862 923
 
863 924
 		$sth = $this->db->prepare($query);
864 925
 		$sth->execute();
@@ -892,12 +953,18 @@  discard block
 block discarded – undo
892 953
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
893 954
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
894 955
 		 if ($olderthanmonths > 0) {
895
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
896
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
956
+			if ($globalDBdriver == 'mysql') {
957
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
958
+			} else {
959
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
960
+			}
897 961
 		}
898 962
 		if ($sincedate != '') {
899
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
900
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
963
+			if ($globalDBdriver == 'mysql') {
964
+				$query .= " AND marine_output.date > '".$sincedate."'";
965
+			} else {
966
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
967
+			}
901 968
 		}
902 969
 		$query_values = array();
903 970
 		if ($year != '') {
@@ -928,7 +995,9 @@  discard block
 block discarded – undo
928 995
 			}
929 996
 		}
930 997
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
931
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
998
+		if ($limit) {
999
+			$query .= " LIMIT 10 OFFSET 0";
1000
+		}
932 1001
       		
933 1002
 		$sth = $this->db->prepare($query);
934 1003
 		$sth->execute($query_values);
@@ -963,7 +1032,9 @@  discard block
 block discarded – undo
963 1032
 			date_default_timezone_set($globalTimezone);
964 1033
 			$datetime = new DateTime();
965 1034
 			$offset = $datetime->format('P');
966
-		} else $offset = '+00:00';
1035
+		} else {
1036
+			$offset = '+00:00';
1037
+		}
967 1038
 
968 1039
 		if ($globalDBdriver == 'mysql') {
969 1040
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1013,7 +1084,9 @@  discard block
 block discarded – undo
1013 1084
 			date_default_timezone_set($globalTimezone);
1014 1085
 			$datetime = new DateTime();
1015 1086
 			$offset = $datetime->format('P');
1016
-		} else $offset = '+00:00';
1087
+		} else {
1088
+			$offset = '+00:00';
1089
+		}
1017 1090
 		$filter_query = $this->getFilter($filters,true,true);
1018 1091
 		if ($globalDBdriver == 'mysql') {
1019 1092
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1059,7 +1132,9 @@  discard block
 block discarded – undo
1059 1132
 			date_default_timezone_set($globalTimezone);
1060 1133
 			$datetime = new DateTime();
1061 1134
 			$offset = $datetime->format('P');
1062
-		} else $offset = '+00:00';
1135
+		} else {
1136
+			$offset = '+00:00';
1137
+		}
1063 1138
 		$filter_query = $this->getFilter($filters,true,true);
1064 1139
 		if ($globalDBdriver == 'mysql') {
1065 1140
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1107,7 +1182,9 @@  discard block
 block discarded – undo
1107 1182
 			date_default_timezone_set($globalTimezone);
1108 1183
 			$datetime = new DateTime();
1109 1184
 			$offset = $datetime->format('P');
1110
-		} else $offset = '+00:00';
1185
+		} else {
1186
+			$offset = '+00:00';
1187
+		}
1111 1188
 
1112 1189
 		if ($globalDBdriver == 'mysql') {
1113 1190
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1156,7 +1233,9 @@  discard block
 block discarded – undo
1156 1233
 			date_default_timezone_set($globalTimezone);
1157 1234
 			$datetime = new DateTime();
1158 1235
 			$offset = $datetime->format('P');
1159
-		} else $offset = '+00:00';
1236
+		} else {
1237
+			$offset = '+00:00';
1238
+		}
1160 1239
 		$filter_query = $this->getFilter($filters,true,true);
1161 1240
 		if ($globalDBdriver == 'mysql') {
1162 1241
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1205,7 +1284,9 @@  discard block
 block discarded – undo
1205 1284
 			date_default_timezone_set($globalTimezone);
1206 1285
 			$datetime = new DateTime();
1207 1286
 			$offset = $datetime->format('P');
1208
-		} else $offset = '+00:00';
1287
+		} else {
1288
+			$offset = '+00:00';
1289
+		}
1209 1290
 
1210 1291
 		$orderby_sql = '';
1211 1292
 		if ($orderby == "hour")
@@ -1274,7 +1355,9 @@  discard block
 block discarded – undo
1274 1355
 			date_default_timezone_set($globalTimezone);
1275 1356
 			$datetime = new DateTime($date);
1276 1357
 			$offset = $datetime->format('P');
1277
-		} else $offset = '+00:00';
1358
+		} else {
1359
+			$offset = '+00:00';
1360
+		}
1278 1361
 
1279 1362
 		if ($globalDBdriver == 'mysql') {
1280 1363
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1322,7 +1405,9 @@  discard block
 block discarded – undo
1322 1405
 			date_default_timezone_set($globalTimezone);
1323 1406
 			$datetime = new DateTime();
1324 1407
 			$offset = $datetime->format('P');
1325
-		} else $offset = '+00:00';
1408
+		} else {
1409
+			$offset = '+00:00';
1410
+		}
1326 1411
 
1327 1412
 		if ($globalDBdriver == 'mysql') {
1328 1413
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1387,8 +1472,11 @@  discard block
 block discarded – undo
1387 1472
 				$query_values = array_merge($query_values,array(':month' => $month));
1388 1473
 			}
1389 1474
 		}
1390
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1391
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1475
+		if (empty($query_values)) {
1476
+			$queryi .= $this->getFilter($filters);
1477
+		} else {
1478
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1479
+		}
1392 1480
 		
1393 1481
 		$sth = $this->db->prepare($queryi);
1394 1482
 		$sth->execute($query_values);
@@ -1425,8 +1513,11 @@  discard block
 block discarded – undo
1425 1513
 				$query_values = array_merge($query_values,array(':month' => $month));
1426 1514
 			}
1427 1515
 		}
1428
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1429
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1516
+		if (empty($query_values)) {
1517
+			$queryi .= $this->getFilter($filters);
1518
+		} else {
1519
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1520
+		}
1430 1521
 		
1431 1522
 		$sth = $this->db->prepare($queryi);
1432 1523
 		$sth->execute($query_values);
@@ -1448,7 +1539,9 @@  discard block
 block discarded – undo
1448 1539
 			date_default_timezone_set($globalTimezone);
1449 1540
 			$datetime = new DateTime();
1450 1541
 			$offset = $datetime->format('P');
1451
-		} else $offset = '+00:00';
1542
+		} else {
1543
+			$offset = '+00:00';
1544
+		}
1452 1545
 
1453 1546
 		if ($globalDBdriver == 'mysql') {
1454 1547
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1552,7 +1645,9 @@  discard block
 block discarded – undo
1552 1645
 	*/
1553 1646
 	public function parseDirection($direction = 0)
1554 1647
 	{
1555
-		if ($direction == '') $direction = 0;
1648
+		if ($direction == '') {
1649
+			$direction = 0;
1650
+		}
1556 1651
 		$direction_array = array();
1557 1652
 		$temp_array = array();
1558 1653
 
@@ -1641,7 +1736,9 @@  discard block
 block discarded – undo
1641 1736
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1642 1737
 	
1643 1738
 		$Connection = new Connection($this->db);
1644
-		if (!$Connection->tableExists('countries')) return '';
1739
+		if (!$Connection->tableExists('countries')) {
1740
+			return '';
1741
+		}
1645 1742
 	
1646 1743
 		try {
1647 1744
 			/*
@@ -1661,9 +1758,13 @@  discard block
 block discarded – undo
1661 1758
 			$sth->closeCursor();
1662 1759
 			if (count($row) > 0) {
1663 1760
 				return $row;
1664
-			} else return '';
1761
+			} else {
1762
+				return '';
1763
+			}
1665 1764
 		} catch (PDOException $e) {
1666
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1765
+			if (isset($globalDebug) && $globalDebug) {
1766
+				echo 'Error : '.$e->getMessage()."\n";
1767
+			}
1667 1768
 			return '';
1668 1769
 		}
1669 1770
 	
@@ -1681,7 +1782,9 @@  discard block
 block discarded – undo
1681 1782
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1682 1783
 	
1683 1784
 		$Connection = new Connection($this->db);
1684
-		if (!$Connection->tableExists('countries')) return '';
1785
+		if (!$Connection->tableExists('countries')) {
1786
+			return '';
1787
+		}
1685 1788
 	
1686 1789
 		try {
1687 1790
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1693,9 +1796,13 @@  discard block
 block discarded – undo
1693 1796
 			$sth->closeCursor();
1694 1797
 			if (count($row) > 0) {
1695 1798
 				return $row;
1696
-			} else return '';
1799
+			} else {
1800
+				return '';
1801
+			}
1697 1802
 		} catch (PDOException $e) {
1698
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1803
+			if (isset($globalDebug) && $globalDebug) {
1804
+				echo 'Error : '.$e->getMessage()."\n";
1805
+			}
1699 1806
 			return '';
1700 1807
 		}
1701 1808
 	
@@ -1713,7 +1820,9 @@  discard block
 block discarded – undo
1713 1820
 	{
1714 1821
 		global $globalBitlyAccessToken;
1715 1822
 		
1716
-		if ($globalBitlyAccessToken == '') return $url;
1823
+		if ($globalBitlyAccessToken == '') {
1824
+			return $url;
1825
+		}
1717 1826
         
1718 1827
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1719 1828
 		
@@ -1789,7 +1898,9 @@  discard block
 block discarded – undo
1789 1898
 			}
1790 1899
 		}
1791 1900
 		$query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC";
1792
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1901
+		if ($limit) {
1902
+			$query .= " LIMIT 10 OFFSET 0";
1903
+		}
1793 1904
 		$sth = $this->db->prepare($query);
1794 1905
 		$sth->execute($query_values);
1795 1906
 		$marine_array = array();
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 1 patch
Braces   +37 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection.');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection.');
11
+		}
10 12
 	}
11 13
 
12 14
 	/**
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 		if (isset($filter[0]['source'])) {
28 30
 			$filters = array_merge($filters,$filter);
29 31
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
31 35
 		$filter_query_join = '';
32 36
 		$filter_query_where = '';
33 37
 		foreach($filters as $flt) {
@@ -73,8 +77,11 @@  discard block
 block discarded – undo
73 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74 78
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
75 79
 		}
76
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
80
+		if ($filter_query_where == '' && $where) {
81
+			$filter_query_where = ' WHERE';
82
+		} elseif ($filter_query_where != '' && $and) {
83
+			$filter_query_where .= ' AND';
84
+		}
78 85
 		if ($filter_query_where != '') {
79 86
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
80 87
 		}
@@ -88,9 +95,14 @@  discard block
 block discarded – undo
88 95
 		if ($over_country == '') {
89 96
 			$Tracker = new Tracker($this->db);
90 97
 			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
91
-			if (!empty($data_country)) $country = $data_country['iso2'];
92
-			else $country = '';
93
-		} else $country = $over_country;
98
+			if (!empty($data_country)) {
99
+				$country = $data_country['iso2'];
100
+			} else {
101
+				$country = '';
102
+			}
103
+		} else {
104
+			$country = $over_country;
105
+		}
94 106
 		// Route is not added in tracker_archive
95 107
 		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
96 108
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
@@ -589,7 +601,9 @@  discard block
 block discarded – undo
589 601
 		    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
590 602
 		    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
591 603
 		    $translate = $Translation->ident2icao($q_item);
592
-		    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
604
+		    if ($translate != $q_item) {
605
+		    	$additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
606
+		    }
593 607
 		    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
594 608
 		    $additional_query .= ")";
595 609
 		}
@@ -807,7 +821,9 @@  discard block
 block discarded – undo
807 821
 		date_default_timezone_set($globalTimezone);
808 822
 		$datetime = new DateTime();
809 823
 		$offset = $datetime->format('P');
810
-	    } else $offset = '+00:00';
824
+	    } else {
825
+	    	$offset = '+00:00';
826
+	    }
811 827
 
812 828
 
813 829
 	    if ($date_array[1] != "")
@@ -1083,9 +1099,13 @@  discard block
 block discarded – undo
1083 1099
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1084 1100
 			}
1085 1101
 		}
1086
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1102
+                if ($sincedate != '') {
1103
+                	$query .= "AND date > '".$sincedate."' ";
1104
+                }
1087 1105
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1088
-	if ($limit) $query .= " LIMIT 0,10";
1106
+	if ($limit) {
1107
+		$query .= " LIMIT 0,10";
1108
+	}
1089 1109
       
1090 1110
 	
1091 1111
 	$sth = $this->db->prepare($query);
@@ -1129,9 +1149,13 @@  discard block
 block discarded – undo
1129 1149
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1130 1150
 			}
1131 1151
 		}
1132
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1152
+                if ($sincedate != '') {
1153
+                	$query .= "AND s.date > '".$sincedate."' ";
1154
+                }
1133 1155
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1134
-	if ($limit) $query .= " LIMIT 0,10";
1156
+	if ($limit) {
1157
+		$query .= " LIMIT 0,10";
1158
+	}
1135 1159
       
1136 1160
 	
1137 1161
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.