Completed
Push — master ( 4c247d...ce17c6 )
by Yannick
07:53
created
live-czml.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     $s3 = sin($bank/2);
44 44
     $c1c2 = $c1*$c2;
45 45
     $s1s2 = $s1*$s2;
46
-    $w =$c1c2*$c3 - $s1s2*$s3;
47
-    $x =$c1c2*$s3 + $s1s2*$c3;
48
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
49
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
50
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
46
+    $w = $c1c2*$c3 - $s1s2*$s3;
47
+    $x = $c1c2*$s3 + $s1s2*$c3;
48
+    $y = $s1*$c2*$c3 + $c1*$s2*$s3;
49
+    $z = $c1*$s2*$c3 - $s1*$c2*$s3;
50
+    return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w);
51 51
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
52 52
 
53 53
 }
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
 $min = false;
69 69
 $allhistory = false;
70 70
 $filter['source'] = array();
71
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
72
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
73
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
74
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
75
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
76
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
79
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
80
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
71
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
73
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
74
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
75
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
76
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
77
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
78
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
79
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
80
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
81 81
 /*
82 82
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
83 83
 	$min = true;
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 	$from_archive = true;
125 125
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
126 126
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
127
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
128
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
129
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
130
-	$begindate = date('Y-m-d H:i:s',$begindate);
131
-	$enddate = date('Y-m-d H:i:s',$enddate);
132
-	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter);
127
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
128
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
129
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
130
+	$begindate = date('Y-m-d H:i:s', $begindate);
131
+	$enddate = date('Y-m-d H:i:s', $enddate);
132
+	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter);
133 133
 } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) {
134 134
 	$from_archive = true;
135 135
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	$begindate = $_COOKIE['archive_begin'];
140 140
 	$enddate = $_COOKIE['archive_end'];
141 141
 
142
-	$archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT);
143
-	$begindate = date('Y-m-d H:i:s',$begindate);
144
-	$enddate = date('Y-m-d H:i:s',$enddate);
142
+	$archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT);
143
+	$begindate = date('Y-m-d H:i:s', $begindate);
144
+	$enddate = date('Y-m-d H:i:s', $enddate);
145 145
 //	echo 'Begin : '.$begindate.' - End : '.$enddate."\n";
146
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
146
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
147 147
 } elseif ($tracker) {
148 148
 	$spotter_array = $TrackerLive->getMinLastLiveTrackerData($filter);
149 149
 } elseif ($marine) {
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
 if (!empty($spotter_array)) {
156 156
 	if (isset($_GET['archive'])) {
157
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
157
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
158 158
 	} elseif ($tracker) {
159 159
 		$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
160 160
 	} elseif ($marine) {
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
 	if ($flightcnt == '') $flightcnt = 0;
166 166
 } else $flightcnt = 0;
167 167
 
168
-$sqltime = round(microtime(true)-$begintime,2);
168
+$sqltime = round(microtime(true) - $begintime, 2);
169 169
 $minitime = time();
170 170
 $maxitime = 0;
171 171
 
172 172
 
173 173
 $modelsdb = array();
174 174
 if (file_exists('models/modelsdb')) {
175
-	if (($handle = fopen('models/modelsdb','r')) !== FALSE) {
176
-		while (($row = fgetcsv($handle,1000)) !== FALSE) {
177
-			if (isset($row[1]) ){
175
+	if (($handle = fopen('models/modelsdb', 'r')) !== FALSE) {
176
+		while (($row = fgetcsv($handle, 1000)) !== FALSE) {
177
+			if (isset($row[1])) {
178 178
 				$model = $row[0];
179 179
 				$modelsdb[$model] = $row[1];
180 180
 			}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER","interval": "%minitime%/%maxitime%"}';
204 204
 } else {
205 205
 	if (isset($globalArchive) && $globalArchive === TRUE) {
206
-		$output .= ',"clock": {"currentTime" : "'.date("c",time()-$globalLiveInterval).'","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
206
+		$output .= ',"clock": {"currentTime" : "'.date("c", time() - $globalLiveInterval).'","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
207 207
 	} else {
208 208
 		$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
209 209
 	}
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 $output .= '},';
214 214
 if (!empty($spotter_array) && is_array($spotter_array))
215 215
 {
216
-	foreach($spotter_array as $spotter_item)
216
+	foreach ($spotter_array as $spotter_item)
217 217
 	{
218 218
 		$j++;
219 219
 		date_default_timezone_set('UTC');
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 			$output .= '"cartographicDegrees": [';
502 502
 			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
503 503
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
504
-			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
504
+			$output .= '"'.date("c", strtotime($spotter_item['date'])).'", ';
505 505
 			$output .= $spotter_item['longitude'].', ';
506 506
 			$output .= $spotter_item['latitude'];
507 507
 			$prevlong = $spotter_item['longitude'];
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
516 516
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
517 517
 		} else {
518
-			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
518
+			$output .= ',"'.date("c", strtotime($spotter_item['date'])).'", ';
519 519
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
520 520
 			if ($spotter_item['ground_speed'] == 0) {
521 521
 				$output .= $prevlong.', ';
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	$output  = substr($output, 0, -1);
548 548
 }
549 549
 $output .= ']';
550
-$output = str_replace('%minitime%',date("c",$minitime),$output);
551
-$output = str_replace('%maxitime%',date("c",$maxitime),$output);
550
+$output = str_replace('%minitime%', date("c", $minitime), $output);
551
+$output = str_replace('%maxitime%', date("c", $maxitime), $output);
552 552
 print $output;
553 553
 ?>
Please login to merge, or discard this patch.
require/class.SpotterLive.php 3 patches
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	/**
131
-	* Gets all the spotter information based on the latest data entry
132
-	*
133
-	* @return Array the spotter information
134
-	*
135
-	*/
131
+	 * Gets all the spotter information based on the latest data entry
132
+	 *
133
+	 * @return Array the spotter information
134
+	 *
135
+	 */
136 136
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
137 137
 	{
138 138
 		global $globalDBdriver, $globalLiveInterval;
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 
176 176
 	/**
177
-	* Gets Minimal Live Spotter data
178
-	*
179
-	* @return Array the spotter information
180
-	*
181
-	*/
177
+	 * Gets Minimal Live Spotter data
178
+	 *
179
+	 * @return Array the spotter information
180
+	 *
181
+	 */
182 182
 	public function getMinLiveSpotterData($filter = array())
183 183
 	{
184 184
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 	}
216 216
 
217 217
 	/**
218
-	* Gets Minimal Live Spotter data since xx seconds
219
-	*
220
-	* @return Array the spotter information
221
-	*
222
-	*/
218
+	 * Gets Minimal Live Spotter data since xx seconds
219
+	 *
220
+	 * @return Array the spotter information
221
+	 *
222
+	 */
223 223
 	public function getMinLastLiveSpotterData($filter = array())
224 224
 	{
225 225
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
239 239
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
240 240
 			}
241
-                } else {
241
+				} else {
242 242
 			if (isset($globalArchive) && $globalArchive === TRUE) {
243 243
 				$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, spotter_archive.date, spotter_archive.format_source 
244 244
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			}
251 251
 		}
252 252
 
253
-    		try {
253
+			try {
254 254
 			$sth = $this->db->prepare($query);
255 255
 			$sth->execute();
256 256
 		} catch(PDOException $e) {
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 	}
263 263
 
264 264
 	/**
265
-	* Gets number of latest data entry
266
-	*
267
-	* @return String number of entry
268
-	*
269
-	*/
265
+	 * Gets number of latest data entry
266
+	 *
267
+	 * @return String number of entry
268
+	 *
269
+	 */
270 270
 	public function getLiveSpotterCount($filter = array())
271 271
 	{
272 272
 		global $globalDBdriver, $globalLiveInterval;
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
 	}
294 294
 
295 295
 	/**
296
-	* Gets all the spotter information based on the latest data entry and coord
297
-	*
298
-	* @return Array the spotter information
299
-	*
300
-	*/
296
+	 * Gets all the spotter information based on the latest data entry and coord
297
+	 *
298
+	 * @return Array the spotter information
299
+	 *
300
+	 */
301 301
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
302 302
 	{
303 303
 		global $globalDBdriver, $globalLiveInterval;
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
 	}
323 323
 
324 324
 	/**
325
-	* Gets all the spotter information based on the latest data entry and coord
326
-	*
327
-	* @return Array the spotter information
328
-	*
329
-	*/
325
+	 * Gets all the spotter information based on the latest data entry and coord
326
+	 *
327
+	 * @return Array the spotter information
328
+	 *
329
+	 */
330 330
 	public function getMinLiveSpotterDatabyCoord($coord, $filter = array())
331 331
 	{
332 332
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
 	}
392 392
 
393 393
 	/**
394
-	* Gets all the spotter information based on a user's latitude and longitude
395
-	*
396
-	* @return Array the spotter information
397
-	*
398
-	*/
394
+	 * Gets all the spotter information based on a user's latitude and longitude
395
+	 *
396
+	 * @return Array the spotter information
397
+	 *
398
+	 */
399 399
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
400 400
 	{
401 401
 		$Spotter = new Spotter($this->db);
@@ -405,145 +405,145 @@  discard block
 block discarded – undo
405 405
 				return false;
406 406
 			}
407 407
 		}
408
-        if ($lng != '')
409
-                {
410
-                        if (!is_numeric($lng))
411
-                        {
412
-                                return false;
413
-                        }
414
-                }
415
-
416
-                if ($radius != '')
417
-                {
418
-                        if (!is_numeric($radius))
419
-                        {
420
-                                return false;
421
-                        }
422
-                }
408
+		if ($lng != '')
409
+				{
410
+						if (!is_numeric($lng))
411
+						{
412
+								return false;
413
+						}
414
+				}
415
+
416
+				if ($radius != '')
417
+				{
418
+						if (!is_numeric($radius))
419
+						{
420
+								return false;
421
+						}
422
+				}
423 423
 		$additional_query = '';
424
-        if ($interval != '')
425
-                {
426
-                        if (!is_string($interval))
427
-                        {
428
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
429
-			        return false;
430
-                        } else {
431
-                if ($interval == '1m')
432
-                {
433
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
434
-                } else if ($interval == '15m'){
435
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
436
-                } 
437
-            }
438
-                } else {
439
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
440
-        }
441
-
442
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
424
+		if ($interval != '')
425
+				{
426
+						if (!is_string($interval))
427
+						{
428
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
429
+					return false;
430
+						} else {
431
+				if ($interval == '1m')
432
+				{
433
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
434
+				} else if ($interval == '15m'){
435
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
436
+				} 
437
+			}
438
+				} else {
439
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
440
+		}
441
+
442
+				$query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
443 443
                    WHERE spotter_live.latitude <> '' 
444 444
                                    AND spotter_live.longitude <> '' 
445 445
                    ".$additional_query."
446 446
                    HAVING distance < :radius  
447 447
                                    ORDER BY distance";
448 448
 
449
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
449
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
450 450
 
451
-                return $spotter_array;
452
-        }
451
+				return $spotter_array;
452
+		}
453 453
 
454 454
     
455
-        /**
456
-	* Gets all the spotter information based on a particular callsign
457
-	*
458
-	* @return Array the spotter information
459
-	*
460
-	*/
455
+		/**
456
+		 * Gets all the spotter information based on a particular callsign
457
+		 *
458
+		 * @return Array the spotter information
459
+		 *
460
+		 */
461 461
 	public function getLastLiveSpotterDataByIdent($ident)
462 462
 	{
463 463
 		$Spotter = new Spotter($this->db);
464 464
 		date_default_timezone_set('UTC');
465 465
 
466 466
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
467
-                $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
467
+				$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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
468 468
 
469 469
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
470 470
 
471 471
 		return $spotter_array;
472 472
 	}
473 473
 
474
-        /**
475
-	* Gets all the spotter information based on a particular callsign
476
-	*
477
-	* @return Array the spotter information
478
-	*
479
-	*/
474
+		/**
475
+		 * Gets all the spotter information based on a particular callsign
476
+		 *
477
+		 * @return Array the spotter information
478
+		 *
479
+		 */
480 480
 	public function getDateLiveSpotterDataByIdent($ident,$date)
481 481
 	{
482 482
 		$Spotter = new Spotter($this->db);
483 483
 		date_default_timezone_set('UTC');
484 484
 
485 485
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
486
-                $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
486
+				$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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
487 487
 
488
-                $date = date('c',$date);
488
+				$date = date('c',$date);
489 489
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
490 490
 
491 491
 		return $spotter_array;
492 492
 	}
493 493
 
494
-        /**
495
-	* Gets last spotter information based on a particular callsign
496
-	*
497
-	* @return Array the spotter information
498
-	*
499
-	*/
494
+		/**
495
+		 * Gets last spotter information based on a particular callsign
496
+		 *
497
+		 * @return Array the spotter information
498
+		 *
499
+		 */
500 500
 	public function getLastLiveSpotterDataById($id)
501 501
 	{
502 502
 		$Spotter = new Spotter($this->db);
503 503
 		date_default_timezone_set('UTC');
504 504
 
505 505
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
506
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
506
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
507 507
 
508 508
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
509 509
 
510 510
 		return $spotter_array;
511 511
 	}
512 512
 
513
-        /**
514
-	* Gets last spotter information based on a particular callsign
515
-	*
516
-	* @return Array the spotter information
517
-	*
518
-	*/
513
+		/**
514
+		 * Gets last spotter information based on a particular callsign
515
+		 *
516
+		 * @return Array the spotter information
517
+		 *
518
+		 */
519 519
 	public function getDateLiveSpotterDataById($id,$date)
520 520
 	{
521 521
 		$Spotter = new Spotter($this->db);
522 522
 		date_default_timezone_set('UTC');
523 523
 
524 524
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
525
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
526
-                $date = date('c',$date);
525
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
526
+				$date = date('c',$date);
527 527
 		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
528 528
 
529 529
 		return $spotter_array;
530 530
 	}
531 531
 
532
-        /**
533
-	* Gets altitude information based on a particular callsign
534
-	*
535
-	* @return Array the spotter information
536
-	*
537
-	*/
532
+		/**
533
+		 * Gets altitude information based on a particular callsign
534
+		 *
535
+		 * @return Array the spotter information
536
+		 *
537
+		 */
538 538
 	public function getAltitudeLiveSpotterDataByIdent($ident)
539 539
 	{
540 540
 
541 541
 		date_default_timezone_set('UTC');
542 542
 
543 543
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
544
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
544
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
545 545
 
546
-    		try {
546
+			try {
547 547
 			
548 548
 			$sth = $this->db->prepare($query);
549 549
 			$sth->execute(array(':ident' => $ident));
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
 		return $spotter_array;
557 557
 	}
558 558
 
559
-        /**
560
-	* Gets all the spotter information based on a particular id
561
-	*
562
-	* @return Array the spotter information
563
-	*
564
-	*/
559
+		/**
560
+		 * Gets all the spotter information based on a particular id
561
+		 *
562
+		 * @return Array the spotter information
563
+		 *
564
+		 */
565 565
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
566 566
 	{
567 567
 		global $globalDBdriver, $globalLiveInterval;
@@ -589,18 +589,18 @@  discard block
 block discarded – undo
589 589
 		return $spotter_array;
590 590
 	}
591 591
 
592
-        /**
593
-	* Gets all the spotter information based on a particular ident
594
-	*
595
-	* @return Array the spotter information
596
-	*
597
-	*/
592
+		/**
593
+		 * Gets all the spotter information based on a particular ident
594
+		 *
595
+		 * @return Array the spotter information
596
+		 *
597
+		 */
598 598
 	public function getAllLiveSpotterDataByIdent($ident)
599 599
 	{
600 600
 		date_default_timezone_set('UTC');
601 601
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
602 602
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
603
-    		try {
603
+			try {
604 604
 			
605 605
 			$sth = $this->db->prepare($query);
606 606
 			$sth->execute(array(':ident' => $ident));
@@ -614,23 +614,23 @@  discard block
 block discarded – undo
614 614
 
615 615
 
616 616
 	/**
617
-	* Deletes all info in the table
618
-	*
619
-	* @return String success or false
620
-	*
621
-	*/
617
+	 * Deletes all info in the table
618
+	 *
619
+	 * @return String success or false
620
+	 *
621
+	 */
622 622
 	public function deleteLiveSpotterData()
623 623
 	{
624 624
 		global $globalDBdriver;
625 625
 		if ($globalDBdriver == 'mysql') {
626 626
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
627 627
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
628
-            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
628
+					//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
629 629
 		} else {
630 630
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
631 631
 		}
632 632
         
633
-    		try {
633
+			try {
634 634
 			
635 635
 			$sth = $this->db->prepare($query);
636 636
 			$sth->execute();
@@ -642,18 +642,18 @@  discard block
 block discarded – undo
642 642
 	}
643 643
 
644 644
 	/**
645
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
646
-	*
647
-	* @return String success or false
648
-	*
649
-	*/
645
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
646
+	 *
647
+	 * @return String success or false
648
+	 *
649
+	 */
650 650
 	public function deleteLiveSpotterDataNotUpdated()
651 651
 	{
652 652
 		global $globalDBdriver, $globalDebug;
653 653
 		if ($globalDBdriver == 'mysql') {
654 654
 			//$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0';
655
-    			$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
656
-    			try {
655
+				$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
656
+				try {
657 657
 				
658 658
 				$sth = $this->db->prepare($query);
659 659
 				$sth->execute();
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
 				return "error";
662 662
 			}
663 663
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
664
-                        $i = 0;
665
-                        $j =0;
664
+						$i = 0;
665
+						$j =0;
666 666
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
667 667
 			foreach($all as $row)
668 668
 			{
@@ -670,20 +670,20 @@  discard block
 block discarded – undo
670 670
 				$j++;
671 671
 				if ($j == 30) {
672 672
 					if ($globalDebug) echo ".";
673
-				    	try {
673
+						try {
674 674
 						
675 675
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
676 676
 						$sth->execute();
677 677
 					} catch(PDOException $e) {
678 678
 						return "error";
679 679
 					}
680
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
681
-                                	$j = 0;
680
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
681
+									$j = 0;
682 682
 				}
683 683
 				$query_delete .= "'".$row['flightaware_id']."',";
684 684
 			}
685 685
 			if ($i > 0) {
686
-    				try {
686
+					try {
687 687
 					
688 688
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
689 689
 					$sth->execute();
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
 			return "success";
695 695
 		} elseif ($globalDBdriver == 'pgsql') {
696 696
 			//$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0";
697
-    			//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
698
-    			$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
699
-    			try {
697
+				//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
698
+				$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
699
+				try {
700 700
 				
701 701
 				$sth = $this->db->prepare($query);
702 702
 				$sth->execute();
@@ -740,17 +740,17 @@  discard block
 block discarded – undo
740 740
 	}
741 741
 
742 742
 	/**
743
-	* Deletes all info in the table for an ident
744
-	*
745
-	* @return String success or false
746
-	*
747
-	*/
743
+	 * Deletes all info in the table for an ident
744
+	 *
745
+	 * @return String success or false
746
+	 *
747
+	 */
748 748
 	public function deleteLiveSpotterDataByIdent($ident)
749 749
 	{
750 750
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
751 751
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
752 752
         
753
-    		try {
753
+			try {
754 754
 			
755 755
 			$sth = $this->db->prepare($query);
756 756
 			$sth->execute(array(':ident' => $ident));
@@ -762,17 +762,17 @@  discard block
 block discarded – undo
762 762
 	}
763 763
 
764 764
 	/**
765
-	* Deletes all info in the table for an id
766
-	*
767
-	* @return String success or false
768
-	*
769
-	*/
765
+	 * Deletes all info in the table for an id
766
+	 *
767
+	 * @return String success or false
768
+	 *
769
+	 */
770 770
 	public function deleteLiveSpotterDataById($id)
771 771
 	{
772 772
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
773 773
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
774 774
         
775
-    		try {
775
+			try {
776 776
 			
777 777
 			$sth = $this->db->prepare($query);
778 778
 			$sth->execute(array(':id' => $id));
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
 
786 786
 
787 787
 	/**
788
-	* Gets the aircraft ident within the last hour
789
-	*
790
-	* @return String the ident
791
-	*
792
-	*/
788
+	 * Gets the aircraft ident within the last hour
789
+	 *
790
+	 * @return String the ident
791
+	 *
792
+	 */
793 793
 	public function getIdentFromLastHour($ident)
794 794
 	{
795 795
 		global $globalDBdriver, $globalTimezone;
@@ -815,14 +815,14 @@  discard block
 block discarded – undo
815 815
 			$ident_result = $row['ident'];
816 816
 		}
817 817
 		return $ident_result;
818
-        }
818
+		}
819 819
 
820 820
 	/**
821
-	* Check recent aircraft
822
-	*
823
-	* @return String the ident
824
-	*
825
-	*/
821
+	 * Check recent aircraft
822
+	 *
823
+	 * @return String the ident
824
+	 *
825
+	 */
826 826
 	public function checkIdentRecent($ident)
827 827
 	{
828 828
 		global $globalDBdriver, $globalTimezone;
@@ -848,14 +848,14 @@  discard block
 block discarded – undo
848 848
 			$ident_result = $row['flightaware_id'];
849 849
 		}
850 850
 		return $ident_result;
851
-        }
851
+		}
852 852
 
853 853
 	/**
854
-	* Check recent aircraft by id
855
-	*
856
-	* @return String the ident
857
-	*
858
-	*/
854
+	 * Check recent aircraft by id
855
+	 *
856
+	 * @return String the ident
857
+	 *
858
+	 */
859 859
 	public function checkIdRecent($id)
860 860
 	{
861 861
 		global $globalDBdriver, $globalTimezone;
@@ -881,14 +881,14 @@  discard block
 block discarded – undo
881 881
 			$ident_result = $row['flightaware_id'];
882 882
 		}
883 883
 		return $ident_result;
884
-        }
884
+		}
885 885
 
886 886
 	/**
887
-	* Check recent aircraft by ModeS
888
-	*
889
-	* @return String the ModeS
890
-	*
891
-	*/
887
+	 * Check recent aircraft by ModeS
888
+	 *
889
+	 * @return String the ModeS
890
+	 *
891
+	 */
892 892
 	public function checkModeSRecent($modes)
893 893
 	{
894 894
 		global $globalDBdriver, $globalTimezone;
@@ -915,19 +915,19 @@  discard block
 block discarded – undo
915 915
 			$ident_result = $row['flightaware_id'];
916 916
 		}
917 917
 		return $ident_result;
918
-        }
918
+		}
919 919
 
920 920
 	/**
921
-	* Adds a new spotter data
922
-	*
923
-	* @param String $flightaware_id the ID from flightaware
924
-	* @param String $ident the flight ident
925
-	* @param String $aircraft_icao the aircraft type
926
-	* @param String $departure_airport_icao the departure airport
927
-	* @param String $arrival_airport_icao the arrival airport
928
-	* @return String success or false
929
-	*
930
-	*/
921
+	 * Adds a new spotter data
922
+	 *
923
+	 * @param String $flightaware_id the ID from flightaware
924
+	 * @param String $ident the flight ident
925
+	 * @param String $aircraft_icao the aircraft type
926
+	 * @param String $departure_airport_icao the departure airport
927
+	 * @param String $arrival_airport_icao the arrival airport
928
+	 * @return String success or false
929
+	 *
930
+	 */
931 931
 	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
932 932
 	{
933 933
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1062,10 +1062,10 @@  discard block
 block discarded – undo
1062 1062
 		$arrival_airport_country = '';
1063 1063
 		
1064 1064
             	
1065
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1066
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1067
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1068
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1065
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1066
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1067
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1068
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1069 1069
 		
1070 1070
 		$query = '';
1071 1071
 		if ($globalArchive) {
@@ -1086,10 +1086,10 @@  discard block
 block discarded – undo
1086 1086
 			return "error : ".$e->getMessage();
1087 1087
 		}
1088 1088
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1089
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1090
-		    $SpotterArchive = new SpotterArchive($this->db);
1091
-		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1092
-		    if ($globalDebug) echo $result.')';
1089
+			if ($globalDebug) echo '(Add to SBS archive : ';
1090
+			$SpotterArchive = new SpotterArchive($this->db);
1091
+			$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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1092
+			if ($globalDebug) echo $result.')';
1093 1093
 		}
1094 1094
 		return "success";
1095 1095
 
Please login to merge, or discard this patch.
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -16,62 +16,62 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
37 37
 				if ($flt['airlines'][0] != '') {
38 38
 					if (isset($flt['source'])) {
39
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
39
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
40 40
 					} else {
41
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
41
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
42 42
 					}
43 43
 				}
44 44
 			}
45 45
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
46 46
 				if (isset($flt['source'])) {
47
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
47
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
48 48
 				} else {
49
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
49
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
50 50
 				}
51 51
 			}
52 52
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
53 53
 				if (isset($flt['source'])) {
54
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
54
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
55 55
 				} else {
56
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
56
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
57 57
 				}
58 58
 			}
59 59
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
60 60
 				if (isset($flt['source'])) {
61
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
61
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
62 62
 				} else {
63
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
63
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
64 64
 				}
65 65
 			}
66 66
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
67 67
 				if (isset($flt['source'])) {
68
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
68
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
69 69
 				}
70 70
 			}
71 71
 		}
72 72
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
73 73
 			if ($filter['airlines'][0] != '') {
74
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
74
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
75 75
 			}
76 76
 		}
77 77
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
82 82
 		}
83 83
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
84
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
84
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
85 85
 		}
86 86
 		if (isset($filter['source']) && !empty($filter['source'])) {
87
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
87
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
88 88
 		}
89 89
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
90 90
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
114 114
 				}
115 115
 			}
116
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
116
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
117 117
 		}
118 118
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
119
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
120 120
 		}
121 121
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122 122
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123 123
 		if ($filter_query_where != '') {
124
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
124
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
125 125
 		}
126 126
 		$filter_query = $filter_query_join.$filter_query_where;
127 127
 		return $filter_query;
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 		if ($limit != '')
145 145
 		{
146 146
 			$limit_array = explode(',', $limit);
147
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
148
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
147
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
148
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
149 149
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
150 150
 			{
151 151
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		} else {
169 169
 			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= 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;
170 170
 		}
171
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
171
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
172 172
 
173 173
 		return $spotter_array;
174 174
 	}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	{
184 184
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
185 185
 		date_default_timezone_set('UTC');
186
-		$filter_query = $this->getFilter($filter,true,true);
186
+		$filter_query = $this->getFilter($filter, true, true);
187 187
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
188 188
 		if ($globalDBdriver == 'mysql') {
189 189
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		try {
207 207
 			$sth = $this->db->prepare($query);
208 208
 			$sth->execute();
209
-		} catch(PDOException $e) {
209
+		} catch (PDOException $e) {
210 210
 			echo $e->getMessage();
211 211
 			die;
212 212
 		}
@@ -225,26 +225,26 @@  discard block
 block discarded – undo
225 225
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
226 226
 		date_default_timezone_set('UTC');
227 227
 
228
-		$filter_query = $this->getFilter($filter,true,true);
228
+		$filter_query = $this->getFilter($filter, true, true);
229 229
 
230 230
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
231 231
 		if ($globalDBdriver == 'mysql') {
232 232
 			if (isset($globalArchive) && $globalArchive === TRUE) {
233
-				$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, spotter_archive.date, spotter_archive.format_source 
233
+				$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, spotter_archive.date, spotter_archive.format_source 
234 234
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id AND spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
235 235
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
236 236
 			} else {
237
-				$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 
237
+				$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 
238 238
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
239 239
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
240 240
 			}
241 241
                 } else {
242 242
 			if (isset($globalArchive) && $globalArchive === TRUE) {
243
-				$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, spotter_archive.date, spotter_archive.format_source 
243
+				$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, spotter_archive.date, spotter_archive.format_source 
244 244
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
245 245
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
246 246
 			} else {
247
-				$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 
247
+				$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 
248 248
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
249 249
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
250 250
 			}
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     		try {
254 254
 			$sth = $this->db->prepare($query);
255 255
 			$sth->execute();
256
-		} catch(PDOException $e) {
256
+		} catch (PDOException $e) {
257 257
 			echo $e->getMessage();
258 258
 			die;
259 259
 		}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	public function getLiveSpotterCount($filter = array())
271 271
 	{
272 272
 		global $globalDBdriver, $globalLiveInterval;
273
-		$filter_query = $this->getFilter($filter,true,true);
273
+		$filter_query = $this->getFilter($filter, true, true);
274 274
 
275 275
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
276 276
 		if ($globalDBdriver == 'mysql') {
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 		try {
284 284
 			$sth = $this->db->prepare($query);
285 285
 			$sth->execute();
286
-		} catch(PDOException $e) {
286
+		} catch (PDOException $e) {
287 287
 			echo $e->getMessage();
288 288
 			die;
289 289
 		}
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
 		$filter_query = $this->getFilter($filter);
307 307
 
308 308
 		if (is_array($coord)) {
309
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
310
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
311
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
312
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
309
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
310
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
311
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
312
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
313 313
 		} else return array();
314 314
 		if ($globalDBdriver == 'mysql') {
315 315
 			$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;
@@ -332,23 +332,23 @@  discard block
 block discarded – undo
332 332
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
333 333
 		$Spotter = new Spotter($this->db);
334 334
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
335
-		$filter_query = $this->getFilter($filter,true,true);
335
+		$filter_query = $this->getFilter($filter, true, true);
336 336
 
337 337
 		if (is_array($coord)) {
338
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
339
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
340
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
341
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
338
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
339
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
340
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
341
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
342 342
 		} else return array();
343 343
 		if ($globalDBdriver == 'mysql') {
344 344
 			if (isset($globalArchive) && $globalArchive === TRUE) {
345
-				$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 
345
+				$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 
346 346
 				FROM spotter_live 
347 347
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
348 348
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
349 349
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0';
350 350
 			} else {
351
-				$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 
351
+				$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 
352 352
 				FROM spotter_live 
353 353
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
354 354
 				    FROM spotter_live l 
@@ -360,14 +360,14 @@  discard block
 block discarded – undo
360 360
 			}
361 361
 		} else {
362 362
 			if (isset($globalArchive) && $globalArchive === TRUE) {
363
-				$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 
363
+				$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 
364 364
 				FROM spotter_live 
365 365
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
366 366
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
367 367
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
368 368
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
369 369
 			} else {
370
-				$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 
370
+				$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 
371 371
 				FROM spotter_live 
372 372
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
373 373
 				    FROM spotter_live l 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 		try {
383 383
 			$sth = $this->db->prepare($query);
384 384
 			$sth->execute();
385
-		} catch(PDOException $e) {
385
+		} catch (PDOException $e) {
386 386
 			echo $e->getMessage();
387 387
 			die;
388 388
 		}
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
                 if ($interval == '1m')
432 432
                 {
433 433
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
434
-                } else if ($interval == '15m'){
434
+                } else if ($interval == '15m') {
435 435
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
436 436
                 } 
437 437
             }
@@ -439,14 +439,14 @@  discard block
 block discarded – undo
439 439
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
440 440
         }
441 441
 
442
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
442
+                $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
443 443
                    WHERE spotter_live.latitude <> '' 
444 444
                                    AND spotter_live.longitude <> '' 
445 445
                    ".$additional_query."
446 446
                    HAVING distance < :radius  
447 447
                                    ORDER BY distance";
448 448
 
449
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
449
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
450 450
 
451 451
                 return $spotter_array;
452 452
         }
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 		date_default_timezone_set('UTC');
465 465
 
466 466
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
467
-                $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
467
+                $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 GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
468 468
 
469
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
469
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
470 470
 
471 471
 		return $spotter_array;
472 472
 	}
@@ -477,16 +477,16 @@  discard block
 block discarded – undo
477 477
 	* @return Array the spotter information
478 478
 	*
479 479
 	*/
480
-	public function getDateLiveSpotterDataByIdent($ident,$date)
480
+	public function getDateLiveSpotterDataByIdent($ident, $date)
481 481
 	{
482 482
 		$Spotter = new Spotter($this->db);
483 483
 		date_default_timezone_set('UTC');
484 484
 
485 485
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
486
-                $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
486
+                $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.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
487 487
 
488
-                $date = date('c',$date);
489
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
488
+                $date = date('c', $date);
489
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
490 490
 
491 491
 		return $spotter_array;
492 492
 	}
@@ -503,9 +503,9 @@  discard block
 block discarded – undo
503 503
 		date_default_timezone_set('UTC');
504 504
 
505 505
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
506
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
506
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
507 507
 
508
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
508
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
509 509
 
510 510
 		return $spotter_array;
511 511
 	}
@@ -516,15 +516,15 @@  discard block
 block discarded – undo
516 516
 	* @return Array the spotter information
517 517
 	*
518 518
 	*/
519
-	public function getDateLiveSpotterDataById($id,$date)
519
+	public function getDateLiveSpotterDataById($id, $date)
520 520
 	{
521 521
 		$Spotter = new Spotter($this->db);
522 522
 		date_default_timezone_set('UTC');
523 523
 
524 524
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
525
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
526
-                $date = date('c',$date);
527
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
525
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
526
+                $date = date('c', $date);
527
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
528 528
 
529 529
 		return $spotter_array;
530 530
 	}
@@ -541,13 +541,13 @@  discard block
 block discarded – undo
541 541
 		date_default_timezone_set('UTC');
542 542
 
543 543
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
544
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
544
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
545 545
 
546 546
     		try {
547 547
 			
548 548
 			$sth = $this->db->prepare($query);
549 549
 			$sth->execute(array(':ident' => $ident));
550
-		} catch(PDOException $e) {
550
+		} catch (PDOException $e) {
551 551
 			echo $e->getMessage();
552 552
 			die;
553 553
 		}
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	* @return Array the spotter information
563 563
 	*
564 564
 	*/
565
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
565
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
566 566
 	{
567 567
 		global $globalDBdriver, $globalLiveInterval;
568 568
 		date_default_timezone_set('UTC');
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 		try {
582 582
 			$sth = $this->db->prepare($query);
583 583
 			$sth->execute(array(':id' => $id));
584
-		} catch(PDOException $e) {
584
+		} catch (PDOException $e) {
585 585
 			echo $e->getMessage();
586 586
 			die;
587 587
 		}
@@ -599,12 +599,12 @@  discard block
 block discarded – undo
599 599
 	{
600 600
 		date_default_timezone_set('UTC');
601 601
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
602
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
602
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
603 603
     		try {
604 604
 			
605 605
 			$sth = $this->db->prepare($query);
606 606
 			$sth->execute(array(':ident' => $ident));
607
-		} catch(PDOException $e) {
607
+		} catch (PDOException $e) {
608 608
 			echo $e->getMessage();
609 609
 			die;
610 610
 		}
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 			
635 635
 			$sth = $this->db->prepare($query);
636 636
 			$sth->execute();
637
-		} catch(PDOException $e) {
637
+		} catch (PDOException $e) {
638 638
 			return "error";
639 639
 		}
640 640
 
@@ -657,14 +657,14 @@  discard block
 block discarded – undo
657 657
 				
658 658
 				$sth = $this->db->prepare($query);
659 659
 				$sth->execute();
660
-			} catch(PDOException $e) {
660
+			} catch (PDOException $e) {
661 661
 				return "error";
662 662
 			}
663 663
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
664 664
                         $i = 0;
665
-                        $j =0;
665
+                        $j = 0;
666 666
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
667
-			foreach($all as $row)
667
+			foreach ($all as $row)
668 668
 			{
669 669
 				$i++;
670 670
 				$j++;
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
 					if ($globalDebug) echo ".";
673 673
 				    	try {
674 674
 						
675
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
675
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
676 676
 						$sth->execute();
677
-					} catch(PDOException $e) {
677
+					} catch (PDOException $e) {
678 678
 						return "error";
679 679
 					}
680 680
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -685,9 +685,9 @@  discard block
 block discarded – undo
685 685
 			if ($i > 0) {
686 686
     				try {
687 687
 					
688
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
688
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
689 689
 					$sth->execute();
690
-				} catch(PDOException $e) {
690
+				} catch (PDOException $e) {
691 691
 					return "error";
692 692
 				}
693 693
 			}
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 				
701 701
 				$sth = $this->db->prepare($query);
702 702
 				$sth->execute();
703
-			} catch(PDOException $e) {
703
+			} catch (PDOException $e) {
704 704
 				return "error";
705 705
 			}
706 706
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -748,13 +748,13 @@  discard block
 block discarded – undo
748 748
 	public function deleteLiveSpotterDataByIdent($ident)
749 749
 	{
750 750
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
751
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
751
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
752 752
         
753 753
     		try {
754 754
 			
755 755
 			$sth = $this->db->prepare($query);
756 756
 			$sth->execute(array(':ident' => $ident));
757
-		} catch(PDOException $e) {
757
+		} catch (PDOException $e) {
758 758
 			return "error";
759 759
 		}
760 760
 
@@ -770,13 +770,13 @@  discard block
 block discarded – undo
770 770
 	public function deleteLiveSpotterDataById($id)
771 771
 	{
772 772
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
773
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
773
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
774 774
         
775 775
     		try {
776 776
 			
777 777
 			$sth = $this->db->prepare($query);
778 778
 			$sth->execute(array(':id' => $id));
779
-		} catch(PDOException $e) {
779
+		} catch (PDOException $e) {
780 780
 			return "error";
781 781
 		}
782 782
 
@@ -794,13 +794,13 @@  discard block
 block discarded – undo
794 794
 	{
795 795
 		global $globalDBdriver, $globalTimezone;
796 796
 		if ($globalDBdriver == 'mysql') {
797
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
797
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
798 798
 				WHERE spotter_live.ident = :ident 
799 799
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
800 800
 				AND spotter_live.date < UTC_TIMESTAMP()';
801 801
 			$query_data = array(':ident' => $ident);
802 802
 		} else {
803
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
803
+			$query = "SELECT spotter_live.ident FROM spotter_live 
804 804
 				WHERE spotter_live.ident = :ident 
805 805
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
806 806
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 		
810 810
 		$sth = $this->db->prepare($query);
811 811
 		$sth->execute($query_data);
812
-		$ident_result='';
813
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
812
+		$ident_result = '';
813
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
814 814
 		{
815 815
 			$ident_result = $row['ident'];
816 816
 		}
@@ -827,13 +827,13 @@  discard block
 block discarded – undo
827 827
 	{
828 828
 		global $globalDBdriver, $globalTimezone;
829 829
 		if ($globalDBdriver == 'mysql') {
830
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
830
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
831 831
 				WHERE spotter_live.ident = :ident 
832 832
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
833 833
 //				AND spotter_live.date < UTC_TIMESTAMP()";
834 834
 			$query_data = array(':ident' => $ident);
835 835
 		} else {
836
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
836
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
837 837
 				WHERE spotter_live.ident = :ident 
838 838
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
839 839
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -842,8 +842,8 @@  discard block
 block discarded – undo
842 842
 		
843 843
 		$sth = $this->db->prepare($query);
844 844
 		$sth->execute($query_data);
845
-		$ident_result='';
846
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
845
+		$ident_result = '';
846
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
847 847
 		{
848 848
 			$ident_result = $row['flightaware_id'];
849 849
 		}
@@ -860,13 +860,13 @@  discard block
 block discarded – undo
860 860
 	{
861 861
 		global $globalDBdriver, $globalTimezone;
862 862
 		if ($globalDBdriver == 'mysql') {
863
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
863
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
864 864
 				WHERE spotter_live.flightaware_id = :id 
865 865
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
866 866
 //				AND spotter_live.date < UTC_TIMESTAMP()";
867 867
 			$query_data = array(':id' => $id);
868 868
 		} else {
869
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
869
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
870 870
 				WHERE spotter_live.flightaware_id = :id 
871 871
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
872 872
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -875,8 +875,8 @@  discard block
 block discarded – undo
875 875
 		
876 876
 		$sth = $this->db->prepare($query);
877 877
 		$sth->execute($query_data);
878
-		$ident_result='';
879
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
878
+		$ident_result = '';
879
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
880 880
 		{
881 881
 			$ident_result = $row['flightaware_id'];
882 882
 		}
@@ -893,13 +893,13 @@  discard block
 block discarded – undo
893 893
 	{
894 894
 		global $globalDBdriver, $globalTimezone;
895 895
 		if ($globalDBdriver == 'mysql') {
896
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
896
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
897 897
 				WHERE spotter_live.ModeS = :modes 
898 898
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
899 899
 //				AND spotter_live.date < UTC_TIMESTAMP()";
900 900
 			$query_data = array(':modes' => $modes);
901 901
 		} else {
902
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
902
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
903 903
 				WHERE spotter_live.ModeS = :modes 
904 904
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
905 905
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -908,8 +908,8 @@  discard block
 block discarded – undo
908 908
 		
909 909
 		$sth = $this->db->prepare($query);
910 910
 		$sth->execute($query_data);
911
-		$ident_result='';
912
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
911
+		$ident_result = '';
912
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
913 913
 		{
914 914
 			//$ident_result = $row['spotter_live_id'];
915 915
 			$ident_result = $row['flightaware_id'];
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	* @return String success or false
929 929
 	*
930 930
 	*/
931
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
931
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
932 932
 	{
933 933
 		global $globalURL, $globalArchive, $globalDebug;
934 934
 		$Common = new Common();
@@ -1021,26 +1021,26 @@  discard block
 block discarded – undo
1021 1021
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1022 1022
 
1023 1023
         
1024
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1025
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1026
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1027
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1028
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1029
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1030
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1031
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1032
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1033
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1034
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1035
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1036
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1037
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1038
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1039
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1040
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1041
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1042
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1043
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1024
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1025
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1026
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1027
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1028
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1029
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1030
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1031
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1032
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1033
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1034
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1035
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1036
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1037
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1038
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1039
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1040
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1041
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1042
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1043
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1044 1044
 
1045 1045
 		$airline_name = '';
1046 1046
 		$airline_icao = '';
@@ -1062,10 +1062,10 @@  discard block
 block discarded – undo
1062 1062
 		$arrival_airport_country = '';
1063 1063
 		
1064 1064
             	
1065
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1066
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1067
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1068
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1065
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1066
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1067
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1068
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1069 1069
 		
1070 1070
 		$query = '';
1071 1071
 		if ($globalArchive) {
@@ -1076,19 +1076,19 @@  discard block
 block discarded – undo
1076 1076
 		$query  .= 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
1077 1077
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)';
1078 1078
 
1079
-		$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country);
1079
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country);
1080 1080
 		try {
1081 1081
 			
1082 1082
 			$sth = $this->db->prepare($query);
1083 1083
 			$sth->execute($query_values);
1084 1084
 			$sth->closeCursor();
1085
-		} catch(PDOException $e) {
1085
+		} catch (PDOException $e) {
1086 1086
 			return "error : ".$e->getMessage();
1087 1087
 		}
1088 1088
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1089 1089
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1090 1090
 		    $SpotterArchive = new SpotterArchive($this->db);
1091
-		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1091
+		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1092 1092
 		    if ($globalDebug) echo $result.')';
1093 1093
 		}
1094 1094
 		return "success";
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 
1098 1098
 	public function getOrderBy()
1099 1099
 	{
1100
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1100
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1101 1101
 		return $orderby;
1102 1102
 	}
1103 1103
 
Please login to merge, or discard this patch.
Braces   +80 added lines, -27 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -118,8 +120,11 @@  discard block
 block discarded – undo
118 120
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119 121
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
120 122
 		}
121
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123
+		if ($filter_query_where == '' && $where) {
124
+			$filter_query_where = ' WHERE';
125
+		} elseif ($filter_query_where != '' && $and) {
126
+			$filter_query_where .= ' AND';
127
+		}
123 128
 		if ($filter_query_where != '') {
124 129
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
125 130
 		}
@@ -161,7 +166,9 @@  discard block
 block discarded – undo
161 166
 			}
162 167
 		}
163 168
 
164
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
169
+		if (!isset($globalLiveInterval)) {
170
+			$globalLiveInterval = '200';
171
+		}
165 172
 		if ($globalDBdriver == 'mysql') {
166 173
 			//$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";
167 174
 			$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;
@@ -184,7 +191,9 @@  discard block
 block discarded – undo
184 191
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
185 192
 		date_default_timezone_set('UTC');
186 193
 		$filter_query = $this->getFilter($filter,true,true);
187
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
+		if (!isset($globalLiveInterval)) {
195
+			$globalLiveInterval = '200';
196
+		}
188 197
 		if ($globalDBdriver == 'mysql') {
189 198
 			if (isset($globalArchive) && $globalArchive === TRUE) {
190 199
 				$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 
@@ -227,7 +236,9 @@  discard block
 block discarded – undo
227 236
 
228 237
 		$filter_query = $this->getFilter($filter,true,true);
229 238
 
230
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
239
+		if (!isset($globalLiveInterval)) {
240
+			$globalLiveInterval = '200';
241
+		}
231 242
 		if ($globalDBdriver == 'mysql') {
232 243
 			if (isset($globalArchive) && $globalArchive === TRUE) {
233 244
 				$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, spotter_archive.date, spotter_archive.format_source 
@@ -272,7 +283,9 @@  discard block
 block discarded – undo
272 283
 		global $globalDBdriver, $globalLiveInterval;
273 284
 		$filter_query = $this->getFilter($filter,true,true);
274 285
 
275
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
286
+		if (!isset($globalLiveInterval)) {
287
+			$globalLiveInterval = '200';
288
+		}
276 289
 		if ($globalDBdriver == 'mysql') {
277 290
 			//$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;
278 291
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -302,7 +315,9 @@  discard block
 block discarded – undo
302 315
 	{
303 316
 		global $globalDBdriver, $globalLiveInterval;
304 317
 		$Spotter = new Spotter($this->db);
305
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
318
+		if (!isset($globalLiveInterval)) {
319
+			$globalLiveInterval = '200';
320
+		}
306 321
 		$filter_query = $this->getFilter($filter);
307 322
 
308 323
 		if (is_array($coord)) {
@@ -310,7 +325,9 @@  discard block
 block discarded – undo
310 325
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
311 326
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
312 327
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
313
-		} else return array();
328
+		} else {
329
+			return array();
330
+		}
314 331
 		if ($globalDBdriver == 'mysql') {
315 332
 			$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;
316 333
 		} else {
@@ -331,7 +348,9 @@  discard block
 block discarded – undo
331 348
 	{
332 349
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
333 350
 		$Spotter = new Spotter($this->db);
334
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
351
+		if (!isset($globalLiveInterval)) {
352
+			$globalLiveInterval = '200';
353
+		}
335 354
 		$filter_query = $this->getFilter($filter,true,true);
336 355
 
337 356
 		if (is_array($coord)) {
@@ -339,7 +358,9 @@  discard block
 block discarded – undo
339 358
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
340 359
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
341 360
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
342
-		} else return array();
361
+		} else {
362
+			return array();
363
+		}
343 364
 		if ($globalDBdriver == 'mysql') {
344 365
 			if (isset($globalArchive) && $globalArchive === TRUE) {
345 366
 				$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 
@@ -570,11 +591,15 @@  discard block
 block discarded – undo
570 591
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
571 592
 		if ($globalDBdriver == 'mysql') {
572 593
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
573
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
594
+			if ($liveinterval) {
595
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
596
+			}
574 597
 			$query .= ' ORDER BY date';
575 598
 		} else {
576 599
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
577
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
600
+			if ($liveinterval) {
601
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
602
+			}
578 603
 			$query .= ' ORDER BY date';
579 604
 		}
580 605
 
@@ -669,7 +694,9 @@  discard block
 block discarded – undo
669 694
 				$i++;
670 695
 				$j++;
671 696
 				if ($j == 30) {
672
-					if ($globalDebug) echo ".";
697
+					if ($globalDebug) {
698
+						echo ".";
699
+					}
673 700
 				    	try {
674 701
 						
675 702
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -976,7 +1003,9 @@  discard block
 block discarded – undo
976 1003
 			{
977 1004
 				return false;
978 1005
 			}
979
-		} else return '';
1006
+		} else {
1007
+			return '';
1008
+		}
980 1009
 
981 1010
 		if ($longitude != '')
982 1011
 		{
@@ -984,7 +1013,9 @@  discard block
 block discarded – undo
984 1013
 			{
985 1014
 				return false;
986 1015
 			}
987
-		} else return '';
1016
+		} else {
1017
+			return '';
1018
+		}
988 1019
 
989 1020
 		if ($waypoints != '')
990 1021
 		{
@@ -1000,7 +1031,9 @@  discard block
 block discarded – undo
1000 1031
 			{
1001 1032
 				return false;
1002 1033
 			}
1003
-		} else $altitude = 0;
1034
+		} else {
1035
+			$altitude = 0;
1036
+		}
1004 1037
 
1005 1038
 		if ($heading != '')
1006 1039
 		{
@@ -1008,7 +1041,9 @@  discard block
 block discarded – undo
1008 1041
 			{
1009 1042
 				return false;
1010 1043
 			}
1011
-		} else $heading = 0;
1044
+		} else {
1045
+			$heading = 0;
1046
+		}
1012 1047
 
1013 1048
 		if ($groundspeed != '')
1014 1049
 		{
@@ -1016,9 +1051,13 @@  discard block
 block discarded – undo
1016 1051
 			{
1017 1052
 				return false;
1018 1053
 			}
1019
-		} else $groundspeed = 0;
1054
+		} else {
1055
+			$groundspeed = 0;
1056
+		}
1020 1057
 		date_default_timezone_set('UTC');
1021
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1058
+		if ($date == '') {
1059
+			$date = date("Y-m-d H:i:s", time());
1060
+		}
1022 1061
 
1023 1062
         
1024 1063
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1062,14 +1101,24 @@  discard block
 block discarded – undo
1062 1101
 		$arrival_airport_country = '';
1063 1102
 		
1064 1103
             	
1065
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1066
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1067
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1068
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1104
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1105
+            		$squawk = NULL;
1106
+            	}
1107
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1108
+            		$verticalrate = NULL;
1109
+            	}
1110
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1111
+            		$groundspeed = 0;
1112
+            	}
1113
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1114
+            		$heading = 0;
1115
+            	}
1069 1116
 		
1070 1117
 		$query = '';
1071 1118
 		if ($globalArchive) {
1072
-			if ($globalDebug) echo '-- Delete previous data -- ';
1119
+			if ($globalDebug) {
1120
+				echo '-- Delete previous data -- ';
1121
+			}
1073 1122
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1074 1123
 		}
1075 1124
 
@@ -1086,10 +1135,14 @@  discard block
 block discarded – undo
1086 1135
 			return "error : ".$e->getMessage();
1087 1136
 		}
1088 1137
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1089
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1138
+		    if ($globalDebug) {
1139
+		    	echo '(Add to SBS archive : ';
1140
+		    }
1090 1141
 		    $SpotterArchive = new SpotterArchive($this->db);
1091 1142
 		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1092
-		    if ($globalDebug) echo $result.')';
1143
+		    if ($globalDebug) {
1144
+		    	echo $result.')';
1145
+		    }
1093 1146
 		}
1094 1147
 		return "success";
1095 1148
 
Please login to merge, or discard this patch.