Completed
Push — master ( 4c6fa5...c1d943 )
by Yannick
07:26
created
require/class.Common.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 	* @param Array $headers header to submit with the form
14 14
 	* @return String the result
15 15
 	*/
16
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
16
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') {
17 17
 		$ch = curl_init();
18 18
 		curl_setopt($ch, CURLOPT_URL, $url);
19 19
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
20 20
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
21 21
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
22
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
22
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
23 23
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
24 24
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
25 25
 		if ($useragent == '') {
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 		}
30 30
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
31 31
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
32
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
32
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
33 33
 		if ($type == 'post') {
34 34
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
35 35
 			if (is_array($data)) {
36 36
 				curl_setopt($ch, CURLOPT_POST, count($data));
37 37
 				$data_string = '';
38
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
38
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
39 39
 				rtrim($data_string, '&');
40 40
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
41 41
 			} else {
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		}
48 48
 		if ($cookie != '') {
49 49
 			if (is_array($cookie)) {
50
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
50
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
51 51
 			} else {
52 52
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
53 53
 			}
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 		$result = curl_exec($ch);
59 59
 		$info = curl_getinfo($ch);
60 60
 		curl_close($ch);
61
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
61
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
62 62
 			echo "Cloudflare Detected\n";
63 63
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
64 64
 			$useragent = UAgent::random();
65 65
 			cloudflare::useUserAgent($useragent);
66 66
 			if ($clearanceCookie = cloudflare::bypass($url)) {
67
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
67
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
68 68
 			}
69 69
 		} else {
70 70
 		    return $result;
@@ -105,27 +105,27 @@  discard block
 block discarded – undo
105 105
 		if ($data == '') return array();
106 106
 		$html = str_get_html($data);
107 107
 		if ($html === false) return array();
108
-		$tabledata=array();
109
-		foreach($html->find('tr') as $element)
108
+		$tabledata = array();
109
+		foreach ($html->find('tr') as $element)
110 110
 		{
111 111
 			$td = array();
112
-			foreach( $element->find('th') as $row)
112
+			foreach ($element->find('th') as $row)
113 113
 			{
114 114
 				$td [] = trim($row->plaintext);
115 115
 			}
116
-			$td=array_filter($td);
116
+			$td = array_filter($td);
117 117
 			$tabledata[] = $td;
118 118
 
119 119
 			$td = array();
120 120
 			$tdi = array();
121
-			foreach( $element->find('td') as $row)
121
+			foreach ($element->find('td') as $row)
122 122
 			{
123 123
 				$td [] = trim($row->plaintext);
124 124
 				$tdi [] = trim($row->innertext);
125 125
 			}
126
-			$td=array_filter($td);
127
-			$tdi=array_filter($tdi);
128
-			$tabledata[]=array_merge($td,$tdi);
126
+			$td = array_filter($td);
127
+			$tdi = array_filter($tdi);
128
+			$tabledata[] = array_merge($td, $tdi);
129 129
 		}
130 130
 		$html->clear();
131 131
 		unset($html);
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	public function text2array($data) {
141 141
 		$html = str_get_html($data);
142 142
 		if ($html === false) return array();
143
-		$tabledata=array();
144
-		foreach($html->find('p') as $element)
143
+		$tabledata = array();
144
+		foreach ($html->find('p') as $element)
145 145
 		{
146 146
 			$tabledata [] = trim($element->plaintext);
147 147
 		}
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
 	*/
162 162
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
163 163
 		if ($lat == $latc && $lon == $lonc) return 0;
164
-		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
164
+		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515;
165 165
 		if ($unit == "km") {
166
-			return round($dist * 1.609344);
166
+			return round($dist*1.609344);
167 167
 		} elseif ($unit == "m") {
168
-			return round($dist * 1.609344 * 1000);
168
+			return round($dist*1.609344*1000);
169 169
 		} elseif ($unit == "mile" || $unit == "mi") {
170 170
 			return round($dist);
171 171
 		} elseif ($unit == "nm") {
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	* @param float $distance distance covered
182 182
 	* @return whether distance is realistic
183 183
 	*/
184
-	public function withinThreshold ($timeDifference, $distance) {
184
+	public function withinThreshold($timeDifference, $distance) {
185 185
 		$x = abs($timeDifference);
186 186
 		$d = abs($distance);
187 187
 		if ($x == 0 || $d == 0) return true;
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 		return ($array !== array_values($array));
198 198
 	}
199 199
 
200
-	public function isInteger($input){
200
+	public function isInteger($input) {
201 201
 	    return(ctype_digit(strval($input)));
202 202
 	}
203 203
 
204 204
 
205
-	public function convertDec($dms,$latlong) {
205
+	public function convertDec($dms, $latlong) {
206 206
 		if ($latlong == 'latitude') {
207 207
 			$deg = substr($dms, 0, 2);
208 208
 			$min = substr($dms, 2, 4);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			$deg = substr($dms, 0, 3);
211 211
 			$min = substr($dms, 3, 5);
212 212
 		}
213
-		return $deg+(($min*60)/3600);
213
+		return $deg + (($min*60)/3600);
214 214
 	}
215 215
 	
216 216
 	/**
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	public function xcopy($source, $dest)
223 223
 	{
224 224
 		$files = glob($source.'*.*');
225
-		foreach($files as $file){
226
-			$file_to_go = str_replace($source,$dest,$file);
225
+		foreach ($files as $file) {
226
+			$file_to_go = str_replace($source, $dest, $file);
227 227
 			copy($file, $file_to_go);
228 228
 		}
229 229
 		return true;
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 	* @param	String $url url to check
235 235
 	* @return	bool Return true on succes false on failure
236 236
 	*/
237
-	public function urlexist($url){
238
-		$headers=get_headers($url);
239
-		return stripos($headers[0],"200 OK")?true:false;
237
+	public function urlexist($url) {
238
+		$headers = get_headers($url);
239
+		return stripos($headers[0], "200 OK") ? true : false;
240 240
 	}
241 241
 	
242 242
 	/**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	public function hex2str($hex) {
248 248
 		$str = '';
249 249
 		$hexln = strlen($hex);
250
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
250
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
251 251
 		return $str;
252 252
 	}
253 253
 	
@@ -256,33 +256,33 @@  discard block
 block discarded – undo
256 256
 		//difference in longitudinal coordinates
257 257
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
258 258
 		//difference in the phi of latitudinal coordinates
259
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
259
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
260 260
 		//we need to recalculate $dLon if it is greater than pi
261
-		if(abs($dLon) > pi()) {
262
-			if($dLon > 0) {
263
-				$dLon = (2 * pi() - $dLon) * -1;
261
+		if (abs($dLon) > pi()) {
262
+			if ($dLon > 0) {
263
+				$dLon = (2*pi() - $dLon)*-1;
264 264
 			} else {
265
-				$dLon = 2 * pi() + $dLon;
265
+				$dLon = 2*pi() + $dLon;
266 266
 			}
267 267
 		}
268 268
 		//return the angle, normalized
269
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
269
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
270 270
 	}
271 271
 	
272
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) {
272
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) {
273 273
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
274
-		$a = -($lon2-$lon1);
274
+		$a = -($lon2 - $lon1);
275 275
 		$b = $lat2 - $lat1;
276
-		$c = -($a*$lat1+$b*$lon1);
277
-		$d = $a*$lat3+$b*$lon3+$c;
276
+		$c = -($a*$lat1 + $b*$lon1);
277
+		$d = $a*$lat3 + $b*$lon3 + $c;
278 278
 		if ($d > -$approx && $d < $approx) return true;
279 279
 		else return false;
280 280
 	}
281 281
 	
282 282
 	public function array_merge_noappend() {
283 283
 		$output = array();
284
-		foreach(func_get_args() as $array) {
285
-			foreach($array as $key => $value) {
284
+		foreach (func_get_args() as $array) {
285
+			foreach ($array as $key => $value) {
286 286
 				$output[$key] = isset($output[$key]) ?
287 287
 				array_merge($output[$key], $value) : $value;
288 288
 			}
@@ -346,34 +346,34 @@  discard block
 block discarded – undo
346 346
 		return $result;
347 347
 	}
348 348
 
349
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){
349
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) {
350 350
 		global $globalMapRefresh;
351 351
 		$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
352 352
 		$r = 6378;
353 353
 		$latitude = deg2rad($latitude);
354 354
 		$longitude = deg2rad($longitude);
355 355
 		$bearing = deg2rad($heading); 
356
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
357
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
358
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
356
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
357
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
358
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
359 359
 	}
360 360
 	
361
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
361
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
362 362
 		// distance in meter
363 363
 		$R = 6378.14;
364
-		$latitude1 = $latitude * (M_PI/180);
365
-		$longitude1 = $longitude * (M_PI/180);
366
-		$brng = $bearing * (M_PI/180);
364
+		$latitude1 = $latitude*(M_PI/180);
365
+		$longitude1 = $longitude*(M_PI/180);
366
+		$brng = $bearing*(M_PI/180);
367 367
 		$d = $distance;
368 368
 
369 369
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
370
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
370
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
371 371
 
372
-		$latitude2 = $latitude2 * (180/M_PI);
373
-		$longitude2 = $longitude2 * (180/M_PI);
372
+		$latitude2 = $latitude2*(180/M_PI);
373
+		$longitude2 = $longitude2*(180/M_PI);
374 374
 
375
-		$flat = round ($latitude2,6);
376
-		$flong = round ($longitude2,6);
375
+		$flat = round($latitude2, 6);
376
+		$flong = round($longitude2, 6);
377 377
 /*
378 378
 		$dx = $distance*cos($bearing);
379 379
 		$dy = $distance*sin($bearing);
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 		$flong = $longitude + $dlong;
383 383
 		$flat = $latitude + $dlat;
384 384
 */
385
-		return array('latitude' => $flat,'longitude' => $flong);
385
+		return array('latitude' => $flat, 'longitude' => $flong);
386 386
 	}
387 387
 
388 388
 	/**
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 	 * @param integer $level GZIP compression level (default: 9)
397 397
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
398 398
 	 */
399
-	public function gzCompressFile($source, $level = 9){ 
400
-		$dest = $source . '.gz'; 
401
-		$mode = 'wb' . $level; 
399
+	public function gzCompressFile($source, $level = 9) { 
400
+		$dest = $source.'.gz'; 
401
+		$mode = 'wb'.$level; 
402 402
 		$error = false; 
403 403
 		if ($fp_out = gzopen($dest, $mode)) { 
404
-			if ($fp_in = fopen($source,'rb')) { 
404
+			if ($fp_in = fopen($source, 'rb')) { 
405 405
 				while (!feof($fp_in)) 
406
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
406
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
407 407
 				fclose($fp_in); 
408 408
 			} else {
409 409
 				$error = true; 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	} 
420 420
 	
421 421
 	public function remove_accents($string) {
422
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
422
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
423 423
 		$chars = array(
424 424
 		    // Decompositions for Latin-1 Supplement
425 425
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
477 477
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
478 478
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
479
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
479
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
480 480
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
481 481
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
482 482
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -492,13 +492,13 @@  discard block
 block discarded – undo
492 492
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
493 493
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
494 494
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
495
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
496
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
497
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
498
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
499
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
500
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
501
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
495
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
496
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
497
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
498
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
499
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
500
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
501
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
502 502
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
503 503
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
504 504
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
32
+	    foreach ($sourcestat as $srcst) {
33 33
 	    	$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35 35
 		    $source = $srcst['source_name'];
36 36
 		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
37
+		    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
38 38
 	        }
39 39
 	    }
40 40
 	}
41 41
     }
42 42
 
43
-    public function get_Schedule($id,$ident) {
43
+    public function get_Schedule($id, $ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 		$schedule = $Schedule->fetchSchedule($operator);
66 66
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
67 67
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
68
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
68
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
69
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
70 70
 		    // Should also check if route schedule = route from DB
71 71
 		    if ($schedule['DepartureAirportIATA'] != '') {
72 72
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			    }
87 87
 			}
88 88
 		    }
89
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
89
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
90 90
 		}
91 91
 	    } else $scheduleexist = true;
92 92
 	} else $scheduleexist = true;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
        if ($scheduleexist) {
95 95
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
96 96
     		$sch = $Schedule->getSchedule($operator);
97
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
97
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
98 98
        }
99 99
 	$Spotter->db = null;
100 100
 	$Schedule->db = null;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
121 121
     		$Spotter = new Spotter($this->db);
122 122
         	$real_arrival = $this->arrival($key);
123
-        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
123
+        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
124 124
             }
125 125
 	}
126 126
     }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         $airport_time = '';
134 134
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
135 135
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
136
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
136
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
137 137
     	    if (isset($closestAirports[0])) {
138 138
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139 139
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         		    break;
149 149
         		}
150 150
         	    }
151
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
151
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
152 152
         		$airport_icao = $closestAirports[0]['icao'];
153 153
         		$airport_time = $this->all_flights[$key]['datetime'];
154 154
         	} else {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         } else {
162 162
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
163 163
         }
164
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
164
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
165 165
     }
166 166
 
167 167
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
173 173
 	foreach ($this->all_flights as $key => $flight) {
174 174
     	    if (isset($flight['lastupdate'])) {
175
-        	if ($flight['lastupdate'] < (time()-3000)) {
175
+        	if ($flight['lastupdate'] < (time() - 3000)) {
176 176
             	    if (isset($this->all_flights[$key]['id'])) {
177 177
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
178 178
 			/*
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             		$real_arrival = $this->arrival($key);
184 184
             		$Spotter = new Spotter($this->db);
185 185
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
186
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
186
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
187 187
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
188 188
 			}
189 189
 			// Put in archive
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	$send = false;
220 220
 	
221 221
 	// SBS format is CSV format
222
-	if(is_array($line) && isset($line['hex'])) {
222
+	if (is_array($line) && isset($line['hex'])) {
223 223
 	    //print_r($line);
224 224
   	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
225 225
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 		//print_r($this->all_flights);
254 254
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
255 255
 		    $this->all_flights[$id] = array('hex' => $hex);
256
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
256
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
257 257
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
258 258
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
259 259
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 			$Spotter = new Spotter($this->db);
264 264
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
265 265
 			$Spotter->db = null;
266
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
266
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
267 267
 
268 268
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
269 269
 			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
@@ -271,33 +271,33 @@  discard block
 block discarded – undo
271 271
 			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
272 272
 			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
273 273
 			}
274
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
274
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
275 275
 		    } else if (isset($line['aircraft_name'])) {
276 276
 			// Get aircraft ICAO from aircraft name
277 277
 			$Spotter = new Spotter($this->db);
278 278
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
279 279
 			$Spotter->db = null;
280
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
281
-			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
282
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
283
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
284
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
+			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
281
+			else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
282
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
283
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true));
284
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
285 285
 		    if (!isset($line['id'])) {
286 286
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
287 287
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
288 288
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
289
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
289
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
290 290
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
291
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
291
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
292 292
 
293 293
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
294 294
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
295 295
 		}
296 296
 		
297 297
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
298
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
298
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) {
299 299
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
300
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
300
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
301 301
 		    } else {
302 302
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
303 303
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -310,24 +310,24 @@  discard block
 block discarded – undo
310 310
 		    }
311 311
 		} else {
312 312
 			date_default_timezone_set('UTC');
313
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
313
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
314 314
 		}
315 315
 
316 316
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
317
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
317
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
318 318
 		}
319 319
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
320
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
321 321
 		}
322 322
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
323
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
323
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
324 324
 		}
325 325
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
326
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
326
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
327 327
 		}
328 328
  
329 329
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
330
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
330
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
331 331
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
332 332
 			$timeelapsed = microtime(true);
333 333
             		$Spotter = new Spotter($this->db);
@@ -337,10 +337,10 @@  discard block
 block discarded – undo
337 337
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
338 338
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
339 339
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
340
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
340
+            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
341 341
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
342 342
 			$Spotter->db = null;
343
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
343
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
344 344
 		    }
345 345
 
346 346
 /*
@@ -351,24 +351,24 @@  discard block
 block discarded – undo
351 351
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
352 352
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
353 353
   */
354
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
354
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
355 355
 
356 356
 		    //$putinarchive = true;
357 357
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
358
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
358
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
359 359
 		    }
360 360
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
361
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
361
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
362 362
 		    }
363 363
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
364
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
364
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
365 365
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
366 366
 				$timeelapsed = microtime(true);
367 367
 				$Spotter = new Spotter($this->db);
368 368
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
369 369
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
370
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
371
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
370
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
371
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
372 372
 
373 373
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
374 374
 			$timeelapsed = microtime(true);
@@ -381,34 +381,34 @@  discard block
 block discarded – undo
381 381
 				$Translation->db = null;
382 382
 			}
383 383
 			$Spotter->db = null;
384
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
384
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
385 385
 
386 386
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
387 387
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
388 388
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
389 389
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
390
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
390
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
391 391
 		    	    }
392 392
 			}
393 393
 			if (!isset($globalFork)) $globalFork = TRUE;
394 394
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
395
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
395
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
396 396
 			}
397 397
 		    }
398 398
 		}
399 399
 
400 400
 		if (isset($line['speed']) && $line['speed'] != '') {
401 401
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
402
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
403
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
402
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
403
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
404 404
 		    //$dataFound = true;
405 405
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
406
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
406
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
407 407
 		    if ($distance > 1000 && $distance < 10000) {
408 408
 		    // use datetime
409 409
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
410 410
 			$speed = $speed*3.6;
411
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
411
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
412 412
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
413 413
 		    }
414 414
 		}
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 
417 417
 
418 418
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
419
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
419
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
420 420
 	    	    else unset($timediff);
421
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
421
+	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) {
422 422
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
423
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
423
+			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
424 424
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
425 425
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
426 426
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -428,10 +428,10 @@  discard block
 block discarded – undo
428 428
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
429 429
 				$timeelapsed = microtime(true);
430 430
 				$Spotter = new Spotter($this->db);
431
-				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
431
+				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
432 432
 				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
433 433
 				$Spotter->db = null;
434
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
434
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
435 435
 				$this->tmd = 0;
436 436
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
437 437
 			    }
@@ -440,13 +440,13 @@  discard block
 block discarded – undo
440 440
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
441 441
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
442 442
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
443
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
443
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
444 444
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
445 445
 				    $dataFound = true;
446 446
 				    $this->all_flights[$id]['time_last_coord'] = time();
447 447
 				}
448 448
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
449
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
449
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
450 450
 				/*
451 451
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
452 452
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -464,13 +464,13 @@  discard block
 block discarded – undo
464 464
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
465 465
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
466 466
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
467
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
467
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
468 468
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
469 469
 				    $dataFound = true;
470 470
 				    $this->all_flights[$id]['time_last_coord'] = time();
471 471
 				}
472 472
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
473
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
473
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
474 474
 				/*
475 475
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
476 476
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -488,46 +488,46 @@  discard block
 block discarded – undo
488 488
 		    } else if ($globalDebug && $timediff > 20) {
489 489
 			$this->tmd = $this->tmd + 1;
490 490
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
491
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
492
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
491
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
492
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
493 493
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
494 494
 		    }
495 495
 		}
496 496
 		if (isset($line['last_update']) && $line['last_update'] != '') {
497 497
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
498
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
498
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
499 499
 		}
500 500
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
501
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
501
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
502 502
 		    //$dataFound = true;
503 503
 		}
504 504
 		if (isset($line['format_source']) && $line['format_source'] != '') {
505
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
505
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
506 506
 		}
507 507
 		if (isset($line['source_name']) && $line['source_name'] != '') {
508
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
508
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
509 509
 		}
510 510
 		if (isset($line['emergency']) && $line['emergency'] != '') {
511
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
511
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
512 512
 		    //$dataFound = true;
513 513
 		}
514 514
 		if (isset($line['ground']) && $line['ground'] != '') {
515 515
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
516 516
 			// Here we force archive of flight because after ground it's a new one (or should be)
517
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
518
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
519
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
520
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
521
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
517
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
518
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
519
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
520
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
521
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
522 522
 		    }
523 523
 		    if ($line['ground'] != 1) $line['ground'] = 0;
524
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
524
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
525 525
 		    //$dataFound = true;
526 526
 		}
527 527
 		if (isset($line['squawk']) && $line['squawk'] != '') {
528 528
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
529 529
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
530
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
530
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
531 531
 			    $highlight = '';
532 532
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
533 533
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -535,47 +535,47 @@  discard block
 block discarded – undo
535 535
 			    if ($highlight != '') {
536 536
 				$timeelapsed = microtime(true);
537 537
 				$Spotter = new Spotter($this->db);
538
-				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
538
+				$Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
539 539
 				$Spotter->db = null;
540
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
540
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
541 541
 
542 542
 				//$putinarchive = true;
543 543
 				//$highlight = '';
544 544
 			    }
545 545
 			    
546
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
546
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
547 547
 		    //$dataFound = true;
548 548
 		}
549 549
 
550 550
 		if (isset($line['altitude']) && $line['altitude'] != '') {
551 551
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
552
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
553
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
554
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
552
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
553
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
554
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
555 555
 			//$dataFound = true;
556 556
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
557 557
   		}
558 558
 
559 559
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
560
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
560
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
561 561
 		}
562 562
 		
563 563
 		if (isset($line['heading']) && $line['heading'] != '') {
564
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
565
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
566
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
564
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
565
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
566
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
567 567
 		    //$dataFound = true;
568 568
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
569
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
570
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
571
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
569
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
570
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
571
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
572 572
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
573 573
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
574 574
   		    // If not enough messages and ACARS set heading to 0
575
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
575
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
576 576
   		}
577
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
578
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
577
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
578
+		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
579 579
 
580 580
 //		print_r($this->all_flights[$id]);
581 581
 		//gets the callsign from the last hour
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
586 586
 		    $this->all_flights[$id]['lastupdate'] = time();
587 587
 		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
588
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
588
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
589 589
 			    //print_r($this->all_flights);
590 590
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
591 591
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -595,61 +595,61 @@  discard block
 block discarded – undo
595 595
 				$SpotterLive = new SpotterLive($this->db);
596 596
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
597 597
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
598
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
598
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
599 599
 				} elseif (isset($line['id'])) {
600 600
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
601
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
601
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
602 602
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
603 603
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
604
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
604
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
605 605
 				} else $recent_ident = '';
606
-				$SpotterLive->db=null;
606
+				$SpotterLive->db = null;
607 607
 
608 608
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
609 609
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
610 610
 			    } else {
611 611
 				$recent_ident = '';
612
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
612
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
613 613
 			    }
614 614
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
615
-			    if($recent_ident == "")
615
+			    if ($recent_ident == "")
616 616
 			    {
617 617
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
618 618
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
619 619
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
620 620
 				//adds the spotter data for the archive
621 621
 				$ignoreImport = false;
622
-				foreach($globalAirportIgnore as $airportIgnore) {
622
+				foreach ($globalAirportIgnore as $airportIgnore) {
623 623
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
624 624
 					$ignoreImport = true;
625 625
 				    }
626 626
 				}
627 627
 				if (count($globalAirportAccept) > 0) {
628 628
 				    $ignoreImport = true;
629
-				    foreach($globalAirportIgnore as $airportIgnore) {
629
+				    foreach ($globalAirportIgnore as $airportIgnore) {
630 630
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
631 631
 					    $ignoreImport = false;
632 632
 					}
633 633
 				    }
634 634
 				}
635 635
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
636
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
637
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
636
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
637
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
638 638
 					    $ignoreImport = true;
639 639
 					}
640 640
 				    }
641 641
 				}
642 642
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
643 643
 				    $ignoreImport = true;
644
-				    foreach($globalAirlineAccept as $airlineAccept) {
645
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
644
+				    foreach ($globalAirlineAccept as $airlineAccept) {
645
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
646 646
 					    $ignoreImport = false;
647 647
 					}
648 648
 				    }
649 649
 				}
650 650
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
651 651
 				    $ignoreImport = true;
652
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
652
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
653 653
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
654 654
 					    $ignoreImport = false;
655 655
 					}
@@ -661,27 +661,27 @@  discard block
 block discarded – undo
661 661
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
662 662
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
663 663
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
664
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
664
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
665 665
 				    $timeelapsed = microtime(true);
666 666
 				    $Spotter = new Spotter($this->db);
667
-				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
667
+				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name']);
668 668
 				    $Spotter->db = null;
669 669
 				    if ($globalDebug && isset($result)) echo $result."\n";
670
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
670
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
671 671
 				    
672 672
 				    // Add source stat in DB
673 673
 				    $Stats = new Stats($this->db);
674 674
 				    if (!empty($this->stats)) {
675 675
 					if ($globalDebug) echo 'Add source stats : ';
676
-				        foreach($this->stats as $date => $data) {
677
-					    foreach($data as $source => $sourced) {
676
+				        foreach ($this->stats as $date => $data) {
677
+					    foreach ($data as $source => $sourced) {
678 678
 					        //print_r($sourced);
679
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
680
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
679
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
680
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
681 681
 				    		if (isset($sourced['msg'])) {
682 682
 				    		    if (time() - $sourced['msg']['date'] > 10) {
683 683
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
684
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
684
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
685 685
 			    			        unset($this->stats[$date][$source]['msg']);
686 686
 			    			    }
687 687
 			    			}
@@ -717,18 +717,18 @@  discard block
 block discarded – undo
717 717
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
718 718
 				    $SpotterLive = new SpotterLive($this->db);
719 719
 				    $SpotterLive->deleteLiveSpotterData();
720
-				    $SpotterLive->db=null;
720
+				    $SpotterLive->db = null;
721 721
 				    if ($globalDebug) echo " Done\n";
722 722
 				    $this->last_delete = time();
723 723
 				}
724 724
 			    } else {
725
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
725
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
726 726
 				    $this->all_flights[$id]['id'] = $recent_ident;
727 727
 				    $this->all_flights[$id]['addedSpotter'] = 1;
728 728
 				}
729 729
 				if (isset($globalDaemon) && !$globalDaemon) {
730 730
 					$Spotter = new Spotter($this->db);
731
-					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
731
+					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
732 732
 					$Spotter->db = null;
733 733
 				}
734 734
 				
@@ -752,37 +752,37 @@  discard block
 block discarded – undo
752 752
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
753 753
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
754 754
 
755
-		    foreach($globalAirportIgnore as $airportIgnore) {
755
+		    foreach ($globalAirportIgnore as $airportIgnore) {
756 756
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
757 757
 			    $ignoreImport = true;
758 758
 			}
759 759
 		    }
760 760
 		    if (count($globalAirportAccept) > 0) {
761 761
 		        $ignoreImport = true;
762
-		        foreach($globalAirportIgnore as $airportIgnore) {
762
+		        foreach ($globalAirportIgnore as $airportIgnore) {
763 763
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
764 764
 				$ignoreImport = false;
765 765
 			    }
766 766
 			}
767 767
 		    }
768 768
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
769
-			foreach($globalAirlineIgnore as $airlineIgnore) {
770
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
769
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
770
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
771 771
 				$ignoreImport = true;
772 772
 			    }
773 773
 			}
774 774
 		    }
775 775
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
776 776
 			$ignoreImport = true;
777
-			foreach($globalAirlineAccept as $airlineAccept) {
778
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
777
+			foreach ($globalAirlineAccept as $airlineAccept) {
778
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
779 779
 				$ignoreImport = false;
780 780
 			    }
781 781
 			}
782 782
 		    }
783 783
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
784 784
 			$ignoreImport = true;
785
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
785
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
786 786
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
787 787
 			        $ignoreImport = false;
788 788
 			    }
@@ -790,14 +790,14 @@  discard block
 block discarded – undo
790 790
 		    }
791 791
 
792 792
 		    if (!$ignoreImport) {
793
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
793
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
794 794
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
795 795
 				$timeelapsed = microtime(true);
796 796
 				$SpotterLive = new SpotterLive($this->db);
797
-				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
797
+				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
798 798
 				$SpotterLive->db = null;
799 799
 				$this->all_flights[$id]['putinarchive'] = false;
800
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
800
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
801 801
 
802 802
 				// Put statistics in $this->stats variable
803 803
 				//if ($line['format_source'] != 'aprs') {
@@ -815,19 +815,19 @@  discard block
 block discarded – undo
815 815
 							$latitude = $globalCenterLatitude;
816 816
 							$longitude = $globalCenterLongitude;
817 817
 						}
818
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
818
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
819 819
 					} else {
820 820
 						$latitude = $this->source_location[$source]['latitude'];
821 821
 						$longitude = $this->source_location[$source]['longitude'];
822 822
 					}
823
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
823
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
824 824
 					//$stats_heading = $stats_heading%22.5;
825 825
 					$stats_heading = round($stats_heading/22.5);
826
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
826
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
827 827
 					$current_date = date('Y-m-d');
828 828
 					if ($stats_heading == 16) $stats_heading = 0;
829 829
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
830
-						for ($i=0;$i<=15;$i++) {
830
+						for ($i = 0; $i <= 15; $i++) {
831 831
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
832 832
 						}
833 833
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -842,9 +842,9 @@  discard block
 block discarded – undo
842 842
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
843 843
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
844 844
 						    end($this->stats[$current_date][$source]['hist']);
845
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
845
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
846 846
 						} else $mini = 0;
847
-						for ($i=$mini;$i<=$distance;$i+=10) {
847
+						for ($i = $mini; $i <= $distance; $i += 10) {
848 848
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
849 849
 						}
850 850
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
858 858
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
859 859
 				if ($globalDebug) echo $result."\n";
860
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
860
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
861 861
 			//$this->del();
862 862
 			
863 863
 			
Please login to merge, or discard this patch.