Completed
Push — master ( 5ac10e...30ddc4 )
by Yannick
07:31
created
live-czml.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
     $s3 = sin($bank/2);
23 23
     $c1c2 = $c1*$c2;
24 24
     $s1s2 = $s1*$s2;
25
-    $w =$c1c2*$c3 - $s1s2*$s3;
26
-    $x =$c1c2*$s3 + $s1s2*$c3;
27
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
28
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
29
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
25
+    $w = $c1c2*$c3 - $s1s2*$s3;
26
+    $x = $c1c2*$s3 + $s1s2*$c3;
27
+    $y = $s1*$c2*$c3 + $c1*$s2*$s3;
28
+    $z = $c1*$s2*$c3 - $s1*$c2*$s3;
29
+    return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w);
30 30
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
31 31
 
32 32
 }
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 $min = false;
48 48
 $allhistory = false;
49 49
 $filter['source'] = array();
50
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
51
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
52
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
53
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
54
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
55
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
56
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
57
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
58
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
50
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
51
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
52
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
53
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs'));
54
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
55
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
56
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
57
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
58
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
59 59
 /*
60 60
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
61 61
 	$min = true;
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 	$from_archive = true;
103 103
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
104 104
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
105
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
106
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
107
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
108
-	$begindate = date('Y-m-d H:i:s',$begindate);
109
-	$enddate = date('Y-m-d H:i:s',$enddate);
110
-	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter);
105
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
106
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
107
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
108
+	$begindate = date('Y-m-d H:i:s', $begindate);
109
+	$enddate = date('Y-m-d H:i:s', $enddate);
110
+	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter);
111 111
 } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) {
112 112
 	$from_archive = true;
113 113
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
@@ -117,34 +117,34 @@  discard block
 block discarded – undo
117 117
 	$begindate = $_COOKIE['archive_begin'];
118 118
 	$enddate = $_COOKIE['archive_end'];
119 119
 
120
-	$archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT);
121
-	$begindate = date('Y-m-d H:i:s',$begindate);
122
-	$enddate = date('Y-m-d H:i:s',$enddate);
120
+	$archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT);
121
+	$begindate = date('Y-m-d H:i:s', $begindate);
122
+	$enddate = date('Y-m-d H:i:s', $enddate);
123 123
 //	echo 'Begin : '.$begindate.' - End : '.$enddate."\n";
124
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
124
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
125 125
 } else {
126 126
 	$spotter_array = $SpotterLive->getMinLastLiveSpotterData($filter);
127 127
 }
128 128
 
129 129
 if (!empty($spotter_array)) {
130 130
 	if (isset($_GET['archive'])) {
131
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
131
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
132 132
 	} else {
133 133
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
134 134
 	}
135 135
 	if ($flightcnt == '') $flightcnt = 0;
136 136
 } else $flightcnt = 0;
137 137
 
138
-$sqltime = round(microtime(true)-$begintime,2);
138
+$sqltime = round(microtime(true) - $begintime, 2);
139 139
 $minitime = time();
140 140
 $maxitime = 0;
141 141
 
142 142
 
143 143
 $modelsdb = array();
144 144
 if (file_exists('models/modelsdb')) {
145
-	if (($handle = fopen('models/modelsdb','r')) !== FALSE) {
146
-		while (($row = fgetcsv($handle,1000)) !== FALSE) {
147
-			if (isset($row[1]) ){
145
+	if (($handle = fopen('models/modelsdb', 'r')) !== FALSE) {
146
+		while (($row = fgetcsv($handle, 1000)) !== FALSE) {
147
+			if (isset($row[1])) {
148 148
 				$model = $row[0];
149 149
 				$modelsdb[$model] = $row[1];
150 150
 			}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 $output .= '},';
173 173
 if (!empty($spotter_array) && is_array($spotter_array))
174 174
 {
175
-	foreach($spotter_array as $spotter_item)
175
+	foreach ($spotter_array as $spotter_item)
176 176
 	{
177 177
 		$j++;
178 178
 		date_default_timezone_set('UTC');
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			$output .= '"cartographicDegrees": [';
311 311
 			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
312 312
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
313
-			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
313
+			$output .= '"'.date("c", strtotime($spotter_item['date'])).'", ';
314 314
 			$output .= $spotter_item['longitude'].', ';
315 315
 			$output .= $spotter_item['latitude'].', ';
316 316
 			$prevlong = $spotter_item['longitude'];
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
323 323
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
324 324
 		} else {
325
-			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
325
+			$output .= ',"'.date("c", strtotime($spotter_item['date'])).'", ';
326 326
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
327 327
 			if ($spotter_item['ground_speed'] == 0) {
328 328
 				$output .= $prevlong.', ';
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	$output  = substr($output, 0, -1);
352 352
 }
353 353
 $output .= ']';
354
-$output = str_replace('%minitime%',date("c",$minitime),$output);
355
-$output = str_replace('%maxitime%',date("c",$maxitime),$output);
354
+$output = str_replace('%minitime%', date("c", $minitime), $output);
355
+$output = str_replace('%maxitime%', date("c", $maxitime), $output);
356 356
 print $output;
357 357
 ?>
Please login to merge, or discard this patch.
Braces   +56 added lines, -19 removed lines patch added patch discarded remove patch
@@ -40,22 +40,43 @@  discard block
 block discarded – undo
40 40
 }
41 41
 header('Content-Type: text/javascript');
42 42
 
43
-if (!isset($globalJsonCompress)) $compress = true;
44
-else $compress = $globalJsonCompress;
43
+if (!isset($globalJsonCompress)) {
44
+	$compress = true;
45
+} else {
46
+	$compress = $globalJsonCompress;
47
+}
45 48
 
46 49
 $from_archive = false;
47 50
 $min = false;
48 51
 $allhistory = false;
49 52
 $filter['source'] = array();
50
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
51
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
52
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
53
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
54
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
55
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
56
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
57
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
58
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
53
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
54
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
55
+}
56
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
57
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
58
+}
59
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
60
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
+}
62
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
63
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
64
+}
65
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
66
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
67
+}
68
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
69
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
70
+}
71
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
72
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
73
+}
74
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
75
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
+}
77
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
78
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
79
+}
59 80
 /*
60 81
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
61 82
 	$min = true;
@@ -132,8 +153,12 @@  discard block
 block discarded – undo
132 153
 	} else {
133 154
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
134 155
 	}
135
-	if ($flightcnt == '') $flightcnt = 0;
136
-} else $flightcnt = 0;
156
+	if ($flightcnt == '') {
157
+		$flightcnt = 0;
158
+	}
159
+	} else {
160
+	$flightcnt = 0;
161
+}
137 162
 
138 163
 $sqltime = round(microtime(true)-$begintime,2);
139 164
 $minitime = time();
@@ -155,7 +180,9 @@  discard block
 block discarded – undo
155 180
 $j = 0;
156 181
 $prev_flightaware_id = '';
157 182
 $speed = 1;
158
-if (isset($archivespeed)) $speed = $archivespeed;
183
+if (isset($archivespeed)) {
184
+	$speed = $archivespeed;
185
+}
159 186
 $output = '[';
160 187
 $output .= '{"id" : "document", "name" : "fam","version" : "1.0"';
161 188
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "LOOP_STOP","step": "SYSTEM_CLOCK_MULTIPLIER"}';
@@ -296,8 +323,12 @@  discard block
 block discarded – undo
296 323
 				}
297 324
 			} else {
298 325
 				$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
299
-				if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
300
-				if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
326
+				if ($spotter_item['aircraft_shadow'] != '') {
327
+					$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
328
+				}
329
+				if ($spotter_item['aircraft_icao'] != '') {
330
+					$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
331
+				}
301 332
 			}
302 333
 	//		$output .= '"heightReference": "CLAMP_TO_GROUND",';
303 334
 			$output .= '"heightReference": "RELATIVE_TO_GROUND",';
@@ -308,8 +339,12 @@  discard block
 block discarded – undo
308 339
 	//		$output .= '"interpolationDegree" : 5,';
309 340
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
310 341
 			$output .= '"cartographicDegrees": [';
311
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
312
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
342
+			if ($minitime > strtotime($spotter_item['date'])) {
343
+				$minitime = strtotime($spotter_item['date']);
344
+			}
345
+			if ($maxitime < strtotime($spotter_item['date'])) {
346
+				$maxitime = strtotime($spotter_item['date']);
347
+			}
313 348
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
314 349
 			$output .= $spotter_item['longitude'].', ';
315 350
 			$output .= $spotter_item['latitude'].', ';
@@ -323,7 +358,9 @@  discard block
 block discarded – undo
323 358
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
324 359
 		} else {
325 360
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
326
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
361
+			if ($maxitime < strtotime($spotter_item['date'])) {
362
+				$maxitime = strtotime($spotter_item['date']);
363
+			}
327 364
 			if ($spotter_item['ground_speed'] == 0) {
328 365
 				$output .= $prevlong.', ';
329 366
 				$output .= $prevlat.', ';
Please login to merge, or discard this patch.
js/map.js.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once('../require/settings.php');
3 3
 require_once('../require/class.Language.php'); 
4 4
 
5
-setcookie("MapFormat",'2d');
5
+setcookie("MapFormat", '2d');
6 6
 //$_COOKIE['MapFormat'] = '2d';
7 7
 
8 8
 // Compressed GeoJson is used if true
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 		$lastupd = $_GET['archivespeed']*$archiveupdatetime;
22 22
 		if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
23 23
 		else $enddate = time();
24
-		setcookie("archive_begin",$begindate);
25
-		setcookie("archive_end",$enddate);
26
-		setcookie("archive_update",$lastupd);
27
-		setcookie("archive_speed",$archivespeed);
24
+		setcookie("archive_begin", $begindate);
25
+		setcookie("archive_end", $enddate);
26
+		setcookie("archive_update", $lastupd);
27
+		setcookie("archive_speed", $archivespeed);
28 28
 ?>
29 29
 
30 30
 document.cookie =  'archive_begin=<?php print $begindate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
@@ -95,16 +95,16 @@  discard block
 block discarded – undo
95 95
 <?php
96 96
 	}
97 97
 	if (isset($_GET['ident'])) {
98
-		$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
98
+		$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
99 99
 	}
100 100
 	if (isset($_GET['flightaware_id'])) {
101
-		$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
101
+		$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
102 102
 	}
103 103
 	if (isset($_GET['latitude'])) {
104
-		$latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_STRING);
104
+		$latitude = filter_input(INPUT_GET, 'latitude', FILTER_SANITIZE_STRING);
105 105
 	}
106 106
 	if (isset($_GET['longitude'])) {
107
-		$longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_STRING);
107
+		$longitude = filter_input(INPUT_GET, 'longitude', FILTER_SANITIZE_STRING);
108 108
 	}
109 109
 ?>
110 110
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	     || navigator.userAgent.match(/BlackBerry/i)
140 140
 	     || navigator.userAgent.match(/Windows Phone/i))
141 141
 	{
142
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
142
+		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom - 1; else print '8'; ?>;
143 143
 	} else {
144 144
 		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
145 145
 	}
@@ -233,19 +233,19 @@  discard block
 block discarded – undo
233 233
 	map.addLayer(yandexLayer);
234 234
 <?php
235 235
 	} elseif ($MapType == 'Bing-Aerial') {
236
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
236
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
237 237
 ?>
238 238
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
239 239
 	map.addLayer(bingLayer);
240 240
 <?php
241 241
 	} elseif ($MapType == 'Bing-Hybrid') {
242
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
242
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
243 243
 ?>
244 244
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
245 245
 	map.addLayer(bingLayer);
246 246
 <?php
247 247
 	} elseif ($MapType == 'Bing-Road') {
248
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
248
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
249 249
 ?>
250 250
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
251 251
 	map.addLayer(bingLayer);
@@ -535,10 +535,10 @@  discard block
 block discarded – undo
535 535
 	};
536 536
 	archive.update = function (props) {
537 537
 		if (typeof props != 'undefined') {
538
-			//this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
539
-			this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>';
538
+			//this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
539
+			this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>';
540 540
 		} else {
541
-			this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
541
+			this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
542 542
 		}
543 543
 
544 544
 	};
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 <?php
739 739
 		} else {
740 740
 ?>
741
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
741
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
742 742
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
743 743
 <?php
744 744
 		}
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 			    iconAnchor: [<?php print $globalAircraftSize/2; ?>, <?php print $globalAircraftSize; ?>],
754 754
 			    shadowUrl: iconURLShadowpath,
755 755
 			    shadowSize: [<?php print $globalAircraftSize; ?>, <?php print $globalAircraftSize; ?>],
756
-			    shadowAnchor: [<?php print ($globalAircraftSize/2)+1; ?>, <?php print $globalAircraftSize; ?>]
756
+			    shadowAnchor: [<?php print ($globalAircraftSize/2) + 1; ?>, <?php print $globalAircraftSize; ?>]
757 757
 			})
758 758
 		    })
759 759
 <?php
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 <?php
786 786
 		} else {
787 787
 ?>
788
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
788
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
789 789
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
790 790
 <?php
791 791
 		}
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 <?php
832 832
 		} else {
833 833
 ?>
834
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
834
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
835 835
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
836 836
 <?php
837 837
 		}
@@ -1420,18 +1420,18 @@  discard block
 block discarded – undo
1420 1420
 	    airs.push(air.value);
1421 1421
 	}
1422 1422
     }
1423
-    document.cookie =  'filter_Airlines='+airs.join()+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"))); ?>; path=/'
1423
+    document.cookie =  'filter_Airlines='+airs.join()+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"))); ?>; path=/'
1424 1424
 }
1425 1425
 function airlinestype(selectObj) {
1426 1426
     var idx = selectObj.selectedIndex;
1427 1427
     var airtype = selectObj.options[idx].value;
1428
-    document.cookie =  'filter_airlinestype='+airtype+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"))); ?>; path=/'
1428
+    document.cookie =  'filter_airlinestype='+airtype+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"))); ?>; path=/'
1429 1429
 }
1430 1430
 
1431 1431
 function identfilter() {
1432 1432
     var ident = $('#identfilter').val();
1433 1433
     console.log('Filter with '+ident);
1434
-    document.cookie =  'filter_ident='+ident+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1434
+    document.cookie =  'filter_ident='+ident+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1435 1435
 }
1436 1436
 function removefilters() {
1437 1437
     // Get an array of all cookie names (the regex matches what we don't want)
@@ -1453,7 +1453,7 @@  discard block
 block discarded – undo
1453 1453
 	}
1454 1454
     }
1455 1455
     //document.cookie =  'Sources='+sources.join()+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1456
-    document.cookie =  'filter_Sources='+sources.join()+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"))); ?>; path=/'
1456
+    document.cookie =  'filter_Sources='+sources.join()+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"))); ?>; path=/'
1457 1457
 }
1458 1458
 
1459 1459
 function show3D() {
@@ -1476,23 +1476,23 @@  discard block
 block discarded – undo
1476 1476
 
1477 1477
 function clickVATSIM(cb) {
1478 1478
     //document.cookie =  'ShowVATSIM='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1479
-    document.cookie =  'filter_ShowVATSIM='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1479
+    document.cookie =  'filter_ShowVATSIM='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1480 1480
 }
1481 1481
 function clickIVAO(cb) {
1482 1482
     //document.cookie =  'ShowIVAO='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1483
-    document.cookie =  'filter_ShowIVAO='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1483
+    document.cookie =  'filter_ShowIVAO='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1484 1484
 }
1485 1485
 function clickphpVMS(cb) {
1486 1486
     //document.cookie =  'ShowVMS='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1487
-    document.cookie =  'filter_ShowVMS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1487
+    document.cookie =  'filter_ShowVMS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1488 1488
 }
1489 1489
 function clickSBS1(cb) {
1490 1490
     //document.cookie =  'ShowSBS1='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1491
-    document.cookie =  'filter_ShowSBS1='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1491
+    document.cookie =  'filter_ShowSBS1='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1492 1492
 }
1493 1493
 function clickAPRS(cb) {
1494 1494
     //document.cookie =  'ShowAPRS='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1495
-    document.cookie =  'filter_ShowAPRS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1495
+    document.cookie =  'filter_ShowAPRS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1496 1496
 }
1497 1497
 function clickFlightPopup(cb) {
1498 1498
     document.cookie =  'flightpopup='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
Please login to merge, or discard this patch.
aircraft-data.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@  discard block
 block discarded – undo
9 9
 
10 10
 $from_archive = false;
11 11
 if (isset($_GET['ident'])) {
12
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
13 13
 	if (isset($_GET['currenttime'])) {
14
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
14
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
15 15
 		$currenttime = round($currenttime/1000);
16
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime);
16
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime);
17 17
 		if (empty($spotter_array)) {
18 18
 			$from_archive = true;
19
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime);
19
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime);
20 20
 		}
21 21
 	} else {
22 22
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 	}
28 28
 }
29 29
 if (isset($_GET['flightaware_id'])) {
30
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
30
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
31 31
 	if (isset($_GET['currenttime'])) {
32
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
32
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
33 33
 		$currenttime = round($currenttime/1000);
34
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime);
34
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime);
35 35
 		if (empty($spotter_array)) {
36 36
 			$from_archive = true;
37 37
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
38
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime);
38
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime);
39 39
 		}
40 40
 	} else {
41 41
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
55 55
 {
56 56
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
57
-		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
57
+		$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
58 58
 	} else $image = $spotter_item['image_thumbnail'];
59 59
 
60 60
 }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
73 73
 if (isset($spotter_item['departure_airport_time'])) {
74 74
 	if ($spotter_item['departure_airport_time'] > 2460) {
75
-		print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>';
75
+		print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>';
76 76
 	} else {
77 77
 		print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>';
78 78
 	}
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
82 82
 if (isset($spotter_item['arrival_airport_time'])) {
83 83
 	if ($spotter_item['arrival_airport_time'] > 2460) {
84
-		print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>';
84
+		print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>';
85 85
 	} else {
86 86
 		print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>';
87 87
 	}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
 if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
151 151
 if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
152
-if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
152
+if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br/>', $spotter_item['acars']['message'])).'</div>';
153 153
 if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
154 154
 print '</div>';
155 155
 ?>
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 <div id="showdetails" class="showdetails"></div>
37 37
 <div id="infobox" class="infobox"><h4><?php echo _("Aircrafts detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div>
38 38
 <?php
39
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
39
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
40 40
 
41 41
 ?>
42 42
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script>
43 43
 <?php
44
-    }
44
+	}
45 45
 ?>
46 46
 <div id="dialog" title="<?php echo _("Session has timed-out"); ?>">
47 47
   <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p>
@@ -55,34 +55,34 @@  discard block
 block discarded – undo
55 55
 	<li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
56 56
 	<li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
57 57
 <?php
58
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
58
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
59 59
 	if (isset($globalArchive) && $globalArchive == TRUE) {
60 60
 ?>
61 61
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
62 62
 <?php
63 63
 	}
64
-    }
64
+	}
65 65
 ?>
66 66
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
67 67
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
68 68
 	<li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li>
69 69
 <?php
70
-    if (isset($globalMap3D) && $globalMap3D) {
70
+	if (isset($globalMap3D) && $globalMap3D) {
71 71
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
72 72
 ?>
73 73
 	<li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
74 74
 <?php
75
-        } else {
76
-    	    if (isset($globalMapSatellites) && $globalMapSatellites) {
75
+		} else {
76
+			if (isset($globalMapSatellites) && $globalMapSatellites) {
77 77
 ?>
78 78
 	<li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li>
79 79
 <?php
80
-	    }
80
+		}
81 81
 ?>
82 82
 	<li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
83 83
 <?php
84 84
 	}
85
-    }
85
+	}
86 86
 ?>
87 87
     </ul>
88 88
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 ?>
157 157
         </div>
158 158
 <?php
159
-    if (isset($globalArchive) && $globalArchive == TRUE) {
159
+	if (isset($globalArchive) && $globalArchive == TRUE) {
160 160
 ?>
161 161
         <div class="sidebar-pane" id="archive">
162 162
 	    <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	    </form>
217 217
 	</div>
218 218
 <?php
219
-    }
219
+	}
220 220
 ?>
221 221
         <div class="sidebar-pane" id="settings">
222 222
 	    <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -227,56 +227,56 @@  discard block
 block discarded – undo
227 227
 			    <?php
228 228
 				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
229 229
 				else $MapType = $_COOKIE['MapType'];
230
-			    ?>
230
+				?>
231 231
 			    <?php
232 232
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
233
-			    ?>
233
+				?>
234 234
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
235 235
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
236 236
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
237 237
 			    <?php
238 238
 				}
239
-			    ?>
239
+				?>
240 240
 			    <?php
241
-			        if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
242
-			    ?>
241
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
242
+				?>
243 243
 			    <?php
244
-				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
245
-			    ?>
244
+					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
245
+				?>
246 246
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
247 247
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
248 248
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
249 249
 			    <?php
250
-				    }
251
-			    ?>
250
+					}
251
+				?>
252 252
 			    <?php
253
-				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
254
-			    ?>
253
+					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
254
+				?>
255 255
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
256 256
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
257 257
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
258 258
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
259 259
 			    <?php
260
-				    }
261
-			    ?>
260
+					}
261
+				?>
262 262
 			    <?php
263
-				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
264
-			    ?>
263
+					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
264
+				?>
265 265
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
266 266
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
267 267
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
268 268
 			    <?php
269
-				    }
270
-			    ?>
269
+					}
270
+				?>
271 271
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
272 272
 			    <?php
273 273
 				}
274
-			    ?>
274
+				?>
275 275
 			    <?php
276
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
276
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
277 277
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
278 278
 					else $MapBoxId = $_COOKIE['MapTypeId'];
279
-			    ?>
279
+				?>
280 280
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
281 281
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
282 282
 			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
291 291
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
292 292
 			    <?php
293
-				    }
294
-			    ?>
293
+					}
294
+				?>
295 295
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
296 296
 			</select>
297 297
 		    </li>
298 298
 <?php
299
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
299
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
300 300
 ?>
301 301
 		    <li><?php echo _("Type of Terrain:"); ?>
302 302
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
 			</select>
307 307
 		    </li>
308 308
 <?php
309
-    }
309
+	}
310 310
 ?>
311 311
 <?php
312
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
312
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
313 313
 ?>
314 314
 		    
315 315
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
@@ -317,54 +317,54 @@  discard block
 block discarded – undo
317 317
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
318 318
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
319 319
 <?php
320
-    }
320
+	}
321 321
 ?>
322 322
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
323 323
 <?php
324
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
324
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
325 325
 ?>
326 326
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
327 327
 <?php
328
-    }
328
+	}
329 329
 ?>
330 330
 
331 331
 		    <?php
332 332
 			if (function_exists('array_column')) {
333
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
334
-		    ?>
333
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
334
+			?>
335 335
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
336 336
 		    <?php
337
-			    }
337
+				}
338 338
 			} elseif (isset($globalSources)) {
339
-			    $dispolar = false;
340
-			    foreach ($globalSources as $testsource) {
341
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
342
-			    }
343
-			    if ($dispolar) {
344
-		    ?>
339
+				$dispolar = false;
340
+				foreach ($globalSources as $testsource) {
341
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
342
+				}
343
+				if ($dispolar) {
344
+			?>
345 345
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
346 346
 		    <?php
347
-			    }
348
-		        }
349
-		    ?>
347
+				}
348
+				}
349
+			?>
350 350
 <?php
351
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
351
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
352 352
 ?>
353 353
 
354 354
 		    <?php
355
-		        if (extension_loaded('gd') && function_exists('gd_info')) {
356
-		    ?>
355
+				if (extension_loaded('gd') && function_exists('gd_info')) {
356
+			?>
357 357
 		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
358 358
 		    <?php 
359 359
 			if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
360
-		    ?>
360
+			?>
361 361
 		    <li><?php echo _("Aircraft icon color:"); ?>
362 362
 			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
363 363
 		    </li>
364 364
 		    <?php
365
-			    }
366
-		        }
367
-		    ?>
365
+				}
366
+				}
367
+			?>
368 368
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
369 369
 			<div class="range">
370 370
 			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 			</div>
373 373
 		    </li>
374 374
 <?php
375
-    }
375
+	}
376 376
 ?>
377 377
 		    <li><?php echo _("Distance unit:"); ?>
378 378
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -405,16 +405,16 @@  discard block
 block discarded – undo
405 405
 		    <ul>
406 406
 		    <?php
407 407
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
408
-		    ?>
408
+			?>
409 409
 			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
410 410
 			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
411 411
 			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
412 412
 		    <?php
413 413
 			}
414
-		    ?>
414
+			?>
415 415
 		    <?php
416 416
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
417
-		    ?>
417
+			?>
418 418
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
419 419
 			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
420 420
 			<?php } ?>
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 			<?php } ?>
424 424
 		    <?php
425 425
 			}
426
-		    ?>
426
+			?>
427 427
 		    <li><?php echo _("Display airlines:"); ?>
428 428
 		    <br/>
429 429
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -438,12 +438,12 @@  discard block
 block discarded – undo
438 438
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
439 439
 					}
440 440
 				}
441
-			    ?>
441
+				?>
442 442
 			</select>
443 443
 		    </li>
444 444
 		    <?php
445 445
 			if (isset($globalAPRS) && $globalAPRS) {
446
-		    ?>
446
+			?>
447 447
 		    <li><?php echo _("Display APRS sources name:"); ?>
448 448
 			<select class="selectpicker" multiple onchange="sources(this);">
449 449
 			    <?php
@@ -455,15 +455,15 @@  discard block
 block discarded – undo
455 455
 						echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>';
456 456
 					}
457 457
 				}
458
-			    ?>
458
+				?>
459 459
 			</select>
460 460
 		    </li>
461 461
 		    <?php
462 462
 			}
463
-		    ?>
463
+			?>
464 464
 		    <?php
465 465
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
466
-		    ?>
466
+			?>
467 467
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
468 468
 			<select class="selectpicker" onchange="airlinestype(this);">
469 469
 			    <option value="all"<?php if (!isset($_COOKIE['airlinestype']) || $_COOKIE['airlinestype'] == 'all' || $_COOKIE['airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 		    </li>
475 475
 		    <?php
476 476
 			}
477
-		    ?>
477
+			?>
478 478
 		    <li>
479 479
 			<?php echo _("Display flight with ident:"); ?>
480 480
 			<input type="text" name="identfilter" id="identfilter" value="<?php if (isset($_COOKIE['identfilter'])) print $_COOKIE['identfilter']; ?>" />
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 	    </form>
488 488
     	</div>
489 489
 <?php
490
-    if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
490
+	if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
491 491
 ?>
492 492
         <div class="sidebar-pane" id="satellites">
493 493
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -527,14 +527,14 @@  discard block
 block discarded – undo
527 527
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
528 528
 					}
529 529
 				}
530
-			    ?>
530
+				?>
531 531
 			</select>
532 532
 		    </li>
533 533
 		</ul>
534 534
 	    </form>
535 535
 	</div>
536 536
 <?php
537
-    }
537
+	}
538 538
 ?>
539 539
     </div>
540 540
 </div>
Please login to merge, or discard this patch.
Braces   +351 added lines, -95 removed lines patch added patch discarded remove patch
@@ -135,11 +135,26 @@  discard block
 block discarded – undo
135 135
 				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li>
136 136
 				<li><?php echo _("NOTAM scope:"); ?>
137 137
 					<select class="selectpicker" onchange="notamscope(this);">
138
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
139
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
140
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
141
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
142
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
138
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
139
+	print ' selected';
140
+}
141
+?>>All</option>
142
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
143
+	print ' selected';
144
+}
145
+?>>Airport/Enroute warning</option>
146
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
147
+	print ' selected';
148
+}
149
+?>>Airport warning</option>
150
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
151
+	print ' selected';
152
+}
153
+?>>Navigation warning</option>
154
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
155
+	print ' selected';
156
+}
157
+?>>Enroute warning</option>
143 158
 					</select
144 159
 				</li>
145 160
 			</ul>
@@ -167,7 +182,10 @@  discard block
 block discarded – undo
167 182
 		        <div class="form-group">
168 183
 			    <label>From (UTC):</label>
169 184
 		            <div class='input-group date' id='datetimepicker1'>
170
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_COOKIE['archive_begin'])) print date("d/m/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
185
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_COOKIE['archive_begin'])) {
186
+	print date("d/m/Y h:i a",$_COOKIE['archive_begin']);
187
+}
188
+?>" required />
171 189
 		                <span class="input-group-addon">
172 190
             			    <span class="glyphicon glyphicon-calendar"></span>
173 191
 		                </span>
@@ -176,7 +194,10 @@  discard block
 block discarded – undo
176 194
 		        <div class="form-group">
177 195
 			    <label>To (UTC):</label>
178 196
 		            <div class='input-group date' id='datetimepicker2'>
179
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_COOKIE['archive_end'])) print date("d/m/Y h:i a",$_COOKIE['archive_end']); ?>" />
197
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_COOKIE['archive_end'])) {
198
+	print date("d/m/Y h:i a",$_COOKIE['archive_end']);
199
+}
200
+?>" />
180 201
             			<span class="input-group-addon">
181 202
 		                    <span class="glyphicon glyphicon-calendar"></span>
182 203
             			</span>
@@ -202,8 +223,18 @@  discard block
 block discarded – undo
202 223
 
203 224
 		    <li><?php echo _("Playback speed:"); ?>
204 225
 			<div class="range">
205
-			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
206
-			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
226
+			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_COOKIE['archive_speed'])) {
227
+	print $_COOKIE['archive_speed'];
228
+} else {
229
+	print '1';
230
+}
231
+?>">
232
+			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
233
+	print $_COOKIE['archive_speed'];
234
+} else {
235
+	print '1';
236
+}
237
+?></output>
207 238
 			</div>
208 239
 		    </li>
209 240
 		    <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li>
@@ -225,15 +256,27 @@  discard block
 block discarded – undo
225 256
 		    <li><?php echo _("Type of Map:"); ?>
226 257
 			<select  class="selectpicker" onchange="mapType(this);">
227 258
 			    <?php
228
-				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
229
-				else $MapType = $_COOKIE['MapType'];
259
+				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
260
+					$MapType = $globalMapProvider;
261
+				} else {
262
+					$MapType = $_COOKIE['MapType'];
263
+				}
230 264
 			    ?>
231 265
 			    <?php
232 266
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
233 267
 			    ?>
234
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
235
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
236
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
268
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
269
+	print ' selected';
270
+}
271
+?>>Bing-Aerial</option>
272
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
273
+	print ' selected';
274
+}
275
+?>>Bing-Hybrid</option>
276
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
277
+	print ' selected';
278
+}
279
+?>>Bing-Road</option>
237 280
 			    <?php
238 281
 				}
239 282
 			    ?>
@@ -243,56 +286,131 @@  discard block
 block discarded – undo
243 286
 			    <?php
244 287
 				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
245 288
 			    ?>
246
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
247
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
248
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
289
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
290
+	print ' selected';
291
+}
292
+?>>Here-Aerial</option>
293
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
294
+	print ' selected';
295
+}
296
+?>>Here-Hybrid</option>
297
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
298
+	print ' selected';
299
+}
300
+?>>Here-Road</option>
249 301
 			    <?php
250 302
 				    }
251 303
 			    ?>
252 304
 			    <?php
253 305
 				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
254 306
 			    ?>
255
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
256
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
257
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
258
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
307
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
308
+	print ' selected';
309
+}
310
+?>>Google Roadmap</option>
311
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
312
+	print ' selected';
313
+}
314
+?>>Google Satellite</option>
315
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
316
+	print ' selected';
317
+}
318
+?>>Google Hybrid</option>
319
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
320
+	print ' selected';
321
+}
322
+?>>Google Terrain</option>
259 323
 			    <?php
260 324
 				    }
261 325
 			    ?>
262 326
 			    <?php
263 327
 				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
264 328
 			    ?>
265
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
266
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
267
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
329
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
330
+	print ' selected';
331
+}
332
+?>>MapQuest-OSM</option>
333
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
334
+	print ' selected';
335
+}
336
+?>>MapQuest-Aerial</option>
337
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
338
+	print ' selected';
339
+}
340
+?>>MapQuest-Hybrid</option>
268 341
 			    <?php
269 342
 				    }
270 343
 			    ?>
271
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
344
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
345
+	print ' selected';
346
+}
347
+?>>Yandex</option>
272 348
 			    <?php
273 349
 				}
274 350
 			    ?>
275 351
 			    <?php
276 352
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
277
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
278
-					else $MapBoxId = $_COOKIE['MapTypeId'];
353
+					if (!isset($_COOKIE['MapTypeId'])) {
354
+						$MapBoxId = 'default';
355
+					} else {
356
+						$MapBoxId = $_COOKIE['MapTypeId'];
357
+					}
279 358
 			    ?>
280
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
281
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
282
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
283
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
284
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
285
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
286
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
287
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
288
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
289
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
290
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
291
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
359
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
360
+	print ' selected';
361
+}
362
+?>>Mapbox default</option>
363
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
364
+	print ' selected';
365
+}
366
+?>>Mapbox streets</option>
367
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
368
+	print ' selected';
369
+}
370
+?>>Mapbox light</option>
371
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
372
+	print ' selected';
373
+}
374
+?>>Mapbox dark</option>
375
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
376
+	print ' selected';
377
+}
378
+?>>Mapbox satellite</option>
379
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
380
+	print ' selected';
381
+}
382
+?>>Mapbox streets-satellite</option>
383
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
384
+	print ' selected';
385
+}
386
+?>>Mapbox streets-basic</option>
387
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
388
+	print ' selected';
389
+}
390
+?>>Mapbox comic</option>
391
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
392
+	print ' selected';
393
+}
394
+?>>Mapbox outdoors</option>
395
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
396
+	print ' selected';
397
+}
398
+?>>Mapbox pencil</option>
399
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
400
+	print ' selected';
401
+}
402
+?>>Mapbox pirates</option>
403
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
404
+	print ' selected';
405
+}
406
+?>>Mapbox emerald</option>
292 407
 			    <?php
293 408
 				    }
294 409
 			    ?>
295
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
410
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
411
+	print ' selected';
412
+}
413
+?>>OpenStreetMap</option>
296 414
 			</select>
297 415
 		    </li>
298 416
 <?php
@@ -300,9 +418,18 @@  discard block
 block discarded – undo
300 418
 ?>
301 419
 		    <li><?php echo _("Type of Terrain:"); ?>
302 420
 			<select  class="selectpicker" onchange="terrainType(this);">
303
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
304
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
305
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
421
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
422
+	print ' selected';
423
+}
424
+?>>stk terrain</option>
425
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
426
+	print ' selected';
427
+}
428
+?>>ellipsoid</option>
429
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
430
+	print ' selected';
431
+}
432
+?>>vr terrain</option>
306 433
 			</select>
307 434
 		    </li>
308 435
 <?php
@@ -312,18 +439,36 @@  discard block
 block discarded – undo
312 439
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
313 440
 ?>
314 441
 		    
315
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
316
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || !isset($_COOKIE['flightpath'])) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li>
317
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
318
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
442
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
443
+	print 'checked';
444
+}
445
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
446
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || !isset($_COOKIE['flightpath'])) {
447
+	print 'checked';
448
+}
449
+?> ><?php echo _("Display flight path"); ?></label></div></li>
450
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) {
451
+	print 'checked';
452
+}
453
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
454
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
455
+	print 'checked';
456
+}
457
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
319 458
 <?php
320 459
     }
321 460
 ?>
322
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
461
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') {
462
+	print 'checked';
463
+}
464
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
323 465
 <?php
324 466
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
325 467
 ?>
326
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
468
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) {
469
+	print 'checked';
470
+}
471
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
327 472
 <?php
328 473
     }
329 474
 ?>
@@ -332,17 +477,25 @@  discard block
 block discarded – undo
332 477
 			if (function_exists('array_column')) {
333 478
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
334 479
 		    ?>
335
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
480
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
481
+	print 'checked';
482
+}
483
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
336 484
 		    <?php
337 485
 			    }
338 486
 			} elseif (isset($globalSources)) {
339 487
 			    $dispolar = false;
340 488
 			    foreach ($globalSources as $testsource) {
341
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
489
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
490
+			        	$dispolar = true;
491
+			        }
342 492
 			    }
343 493
 			    if ($dispolar) {
344 494
 		    ?>
345
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
495
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
496
+	print 'checked';
497
+}
498
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
346 499
 		    <?php
347 500
 			    }
348 501
 		        }
@@ -354,12 +507,22 @@  discard block
 block discarded – undo
354 507
 		    <?php
355 508
 		        if (extension_loaded('gd') && function_exists('gd_info')) {
356 509
 		    ?>
357
-		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
510
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
511
+	print 'checked';
512
+}
513
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
358 514
 		    <?php 
359 515
 			if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
360 516
 		    ?>
361 517
 		    <li><?php echo _("Aircraft icon color:"); ?>
362
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
518
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
519
+	print $_COOKIE['IconColor'];
520
+} elseif (isset($globalAircraftIconColor)) {
521
+	print $globalAircraftIconColor;
522
+} else {
523
+	print '1a3151';
524
+}
525
+?>">
363 526
 		    </li>
364 527
 		    <?php
365 528
 			    }
@@ -367,8 +530,22 @@  discard block
 block discarded – undo
367 530
 		    ?>
368 531
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
369 532
 			<div class="range">
370
-			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
371
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
533
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
534
+	print $_COOKIE['AirportZoom'];
535
+} elseif (isset($globalAirportZoom)) {
536
+	print $globalAirportZoom;
537
+} else {
538
+	print '7';
539
+}
540
+?>">
541
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
542
+	print $_COOKIE['AirportZoom'];
543
+} elseif (isset($globalAirportZoom)) {
544
+	print $globalAirportZoom;
545
+} else {
546
+	print '7';
547
+}
548
+?></output>
372 549
 			</div>
373 550
 		    </li>
374 551
 <?php
@@ -376,22 +553,46 @@  discard block
 block discarded – undo
376 553
 ?>
377 554
 		    <li><?php echo _("Distance unit:"); ?>
378 555
 			<select class="selectpicker" onchange="unitdistance(this);">
379
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
380
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
381
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
556
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
557
+	echo ' selected';
558
+}
559
+?>>km</option>
560
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
561
+	echo ' selected';
562
+}
563
+?>>nm</option>
564
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
565
+	echo ' selected';
566
+}
567
+?>>mi</option>
382 568
 		        </select>
383 569
 		    </li>
384 570
 		    <li><?php echo _("Altitude unit:"); ?>
385 571
 			<select class="selectpicker" onchange="unitaltitude(this);">
386
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
387
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
572
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
573
+	echo ' selected';
574
+}
575
+?>>m</option>
576
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
577
+	echo ' selected';
578
+}
579
+?>>feet</option>
388 580
 		        </select>
389 581
 		    </li>
390 582
 		    <li><?php echo _("Speed unit:"); ?>
391 583
 			<select class="selectpicker" onchange="unitspeed(this);">
392
-			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option>
393
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
394
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
584
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
585
+	echo ' selected';
586
+}
587
+?>>km/h</option>
588
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
589
+	echo ' selected';
590
+}
591
+?>>mph</option>
592
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
593
+	echo ' selected';
594
+}
595
+?>>knots</option>
395 596
 		        </select>
396 597
 		    </li>
397 598
 
@@ -406,9 +607,18 @@  discard block
 block discarded – undo
406 607
 		    <?php
407 608
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
408 609
 		    ?>
409
-			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
410
-			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
411
-			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
610
+			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) {
611
+	print 'checked';
612
+}
613
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
614
+			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) {
615
+	print 'checked';
616
+}
617
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
618
+			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) {
619
+	print 'checked';
620
+}
621
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
412 622
 		    <?php
413 623
 			}
414 624
 		    ?>
@@ -416,10 +626,16 @@  discard block
 block discarded – undo
416 626
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
417 627
 		    ?>
418 628
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
419
-			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
629
+			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) {
630
+	print 'checked';
631
+}
632
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
420 633
 			<?php } ?>
421 634
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
422
-			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li>
635
+			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) {
636
+	print 'checked';
637
+}
638
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
423 639
 			<?php } ?>
424 640
 		    <?php
425 641
 			}
@@ -431,7 +647,9 @@  discard block
 block discarded – undo
431 647
 				$Spotter = new Spotter();
432 648
 				foreach($Spotter->getAllAirlineNames() as $airline) {
433 649
 					$airline_name = $airline['airline_name'];
434
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
650
+					if (strlen($airline_name) > 30) {
651
+						$airline_name = substr($airline_name,0,30).'...';
652
+					}
435 653
 					if (isset($_COOKIE['Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['Airlines']))) {
436 654
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
437 655
 					} else {
@@ -466,10 +684,22 @@  discard block
 block discarded – undo
466 684
 		    ?>
467 685
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
468 686
 			<select class="selectpicker" onchange="airlinestype(this);">
469
-			    <option value="all"<?php if (!isset($_COOKIE['airlinestype']) || $_COOKIE['airlinestype'] == 'all' || $_COOKIE['airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
470
-			    <option value="passenger"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
471
-			    <option value="cargo"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
472
-			    <option value="military"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
687
+			    <option value="all"<?php if (!isset($_COOKIE['airlinestype']) || $_COOKIE['airlinestype'] == 'all' || $_COOKIE['airlinestype'] == '') {
688
+	echo ' selected';
689
+}
690
+?>><?php echo _("All"); ?></option>
691
+			    <option value="passenger"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'passenger') {
692
+	echo ' selected';
693
+}
694
+?>><?php echo _("Passenger"); ?></option>
695
+			    <option value="cargo"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'cargo') {
696
+	echo ' selected';
697
+}
698
+?>><?php echo _("Cargo"); ?></option>
699
+			    <option value="military"<?php if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] == 'military') {
700
+	echo ' selected';
701
+}
702
+?>><?php echo _("Military"); ?></option>
473 703
 			</select>
474 704
 		    </li>
475 705
 		    <?php
@@ -477,7 +707,10 @@  discard block
 block discarded – undo
477 707
 		    ?>
478 708
 		    <li>
479 709
 			<?php echo _("Display flight with ident:"); ?>
480
-			<input type="text" name="identfilter" id="identfilter" value="<?php if (isset($_COOKIE['identfilter'])) print $_COOKIE['identfilter']; ?>" />
710
+			<input type="text" name="identfilter" id="identfilter" value="<?php if (isset($_COOKIE['identfilter'])) {
711
+	print $_COOKIE['identfilter'];
712
+}
713
+?>" />
481 714
 		    </li>
482 715
 		</ul>
483 716
 	    </form>
@@ -493,7 +726,10 @@  discard block
 block discarded – undo
493 726
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
494 727
 	    <form>
495 728
 		<ul>
496
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
729
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') {
730
+	print 'checked';
731
+}
732
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
497 733
 		    <li><?php echo _("Type:"); ?>
498 734
 			<select class="selectpicker" multiple onchange="sattypes(this);">
499 735
 			    <?php
@@ -501,25 +737,45 @@  discard block
 block discarded – undo
501 737
 				$types = $Satellite->get_tle_types();
502 738
 				foreach ($types as $type) {
503 739
 					$type_name = $type['tle_type'];
504
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
505
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
506
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
507
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
508
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
509
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
510
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
511
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
512
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
513
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
514
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
515
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
516
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
517
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
518
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
519
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
520
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
521
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
522
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
740
+					if ($type_name == 'musson') {
741
+						$type_name = 'Russian LEO Navigation';
742
+					} else if ($type_name == 'nnss') {
743
+						$type_name = 'Navi Navigation Satellite System';
744
+					} else if ($type_name == 'sbas') {
745
+						$type_name = 'Satellite-Based Augmentation System';
746
+					} else if ($type_name == 'glo-ops') {
747
+						$type_name = 'Glonass Operational';
748
+					} else if ($type_name == 'gps-ops') {
749
+						$type_name = 'GPS Operational';
750
+					} else if ($type_name == 'argos') {
751
+						$type_name = 'ARGOS Data Collection System';
752
+					} else if ($type_name == 'tdrss') {
753
+						$type_name = 'Tracking and Data Relay Satellite System';
754
+					} else if ($type_name == 'sarsat') {
755
+						$type_name = 'Search & Rescue';
756
+					} else if ($type_name == 'dmc') {
757
+						$type_name = 'Disaster Monitoring';
758
+					} else if ($type_name == 'resource') {
759
+						$type_name = 'Earth Resources';
760
+					} else if ($type_name == 'stations') {
761
+						$type_name = 'Space Stations';
762
+					} else if ($type_name == 'geo') {
763
+						$type_name = 'Geostationary';
764
+					} else if ($type_name == 'amateur') {
765
+						$type_name = 'Amateur Radio';
766
+					} else if ($type_name == 'x-comm') {
767
+						$type_name = 'Experimental';
768
+					} else if ($type_name == 'other-comm') {
769
+						$type_name = 'Other Comm';
770
+					} else if ($type_name == 'science') {
771
+						$type_name = 'Space & Earth Science';
772
+					} else if ($type_name == 'military') {
773
+						$type_name = 'Miscellaneous Military';
774
+					} else if ($type_name == 'radar') {
775
+						$type_name = 'Radar Calibration';
776
+					} else if ($type_name == 'tle-new') {
777
+						$type_name = 'Last 30 days launches';
778
+					}
523 779
 					
524 780
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
525 781
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 2 patches
Indentation   +523 added lines, -523 removed lines patch added patch discarded remove patch
@@ -60,44 +60,44 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 
63
-        /**
64
-        * Gets all the spotter information based on a particular callsign
65
-        *
66
-        * @return Array the spotter information
67
-        *
68
-        */
69
-        public function getLastArchiveSpotterDataByIdent($ident)
70
-        {
63
+		/**
64
+		 * Gets all the spotter information based on a particular callsign
65
+		 *
66
+		 * @return Array the spotter information
67
+		 *
68
+		 */
69
+		public function getLastArchiveSpotterDataByIdent($ident)
70
+		{
71 71
 		$Spotter = new Spotter($this->db);
72
-                date_default_timezone_set('UTC');
72
+				date_default_timezone_set('UTC');
73 73
 
74
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
75
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
76
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
74
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
75
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
76
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
77 77
 
78
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
78
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
79 79
 
80
-                return $spotter_array;
81
-        }
80
+				return $spotter_array;
81
+		}
82 82
 
83 83
 
84
-        /**
85
-        * Gets last the spotter information based on a particular id
86
-        *
87
-        * @return Array the spotter information
88
-        *
89
-        */
90
-        public function getLastArchiveSpotterDataById($id)
91
-        {
92
-    		$Spotter = new Spotter($this->db);
93
-                date_default_timezone_set('UTC');
94
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
95
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
96
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
97
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
84
+		/**
85
+		 * Gets last the spotter information based on a particular id
86
+		 *
87
+		 * @return Array the spotter information
88
+		 *
89
+		 */
90
+		public function getLastArchiveSpotterDataById($id)
91
+		{
92
+			$Spotter = new Spotter($this->db);
93
+				date_default_timezone_set('UTC');
94
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
95
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
96
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
97
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
98 98
 
99 99
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
100
-                  /*
100
+				  /*
101 101
                 try {
102 102
                         $Connection = new Connection();
103 103
                         $sth = Connection->$db->prepare($query);
@@ -107,232 +107,232 @@  discard block
 block discarded – undo
107 107
                 }
108 108
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
109 109
                 */
110
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
111
-
112
-                return $spotter_array;
113
-        }
114
-
115
-        /**
116
-        * Gets all the spotter information based on a particular id
117
-        *
118
-        * @return Array the spotter information
119
-        *
120
-        */
121
-        public function getAllArchiveSpotterDataById($id)
122
-        {
123
-                date_default_timezone_set('UTC');
124
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
125
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
110
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
111
+
112
+				return $spotter_array;
113
+		}
114
+
115
+		/**
116
+		 * Gets all the spotter information based on a particular id
117
+		 *
118
+		 * @return Array the spotter information
119
+		 *
120
+		 */
121
+		public function getAllArchiveSpotterDataById($id)
122
+		{
123
+				date_default_timezone_set('UTC');
124
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
125
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
126 126
 
127 127
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
128 128
 
129
-                try {
130
-                        $sth = $this->db->prepare($query);
131
-                        $sth->execute(array(':id' => $id));
132
-                } catch(PDOException $e) {
133
-                        echo $e->getMessage();
134
-                        die;
135
-                }
136
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
137
-
138
-                return $spotter_array;
139
-        }
140
-
141
-        /**
142
-        * Gets coordinate & time spotter information based on a particular id
143
-        *
144
-        * @return Array the spotter information
145
-        *
146
-        */
147
-        public function getCoordArchiveSpotterDataById($id)
148
-        {
149
-                date_default_timezone_set('UTC');
150
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
151
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
129
+				try {
130
+						$sth = $this->db->prepare($query);
131
+						$sth->execute(array(':id' => $id));
132
+				} catch(PDOException $e) {
133
+						echo $e->getMessage();
134
+						die;
135
+				}
136
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
137
+
138
+				return $spotter_array;
139
+		}
140
+
141
+		/**
142
+		 * Gets coordinate & time spotter information based on a particular id
143
+		 *
144
+		 * @return Array the spotter information
145
+		 *
146
+		 */
147
+		public function getCoordArchiveSpotterDataById($id)
148
+		{
149
+				date_default_timezone_set('UTC');
150
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
151
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
152 152
 
153 153
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
154 154
 
155
-                try {
156
-                        $sth = $this->db->prepare($query);
157
-                        $sth->execute(array(':id' => $id));
158
-                } catch(PDOException $e) {
159
-                        echo $e->getMessage();
160
-                        die;
161
-                }
162
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
155
+				try {
156
+						$sth = $this->db->prepare($query);
157
+						$sth->execute(array(':id' => $id));
158
+				} catch(PDOException $e) {
159
+						echo $e->getMessage();
160
+						die;
161
+				}
162
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
163 163
 
164
-                return $spotter_array;
165
-        }
164
+				return $spotter_array;
165
+		}
166 166
 
167 167
 
168
-        /**
169
-        * Gets altitude information based on a particular callsign
170
-        *
171
-        * @return Array the spotter information
172
-        *
173
-        */
174
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
175
-        {
168
+		/**
169
+		 * Gets altitude information based on a particular callsign
170
+		 *
171
+		 * @return Array the spotter information
172
+		 *
173
+		 */
174
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
175
+		{
176 176
 
177
-                date_default_timezone_set('UTC');
177
+				date_default_timezone_set('UTC');
178 178
 
179
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
180
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
179
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
180
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
181 181
 
182
-                try {
183
-                        $sth = $this->db->prepare($query);
184
-                        $sth->execute(array(':ident' => $ident));
185
-                } catch(PDOException $e) {
186
-                        echo $e->getMessage();
187
-                        die;
188
-                }
189
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
182
+				try {
183
+						$sth = $this->db->prepare($query);
184
+						$sth->execute(array(':ident' => $ident));
185
+				} catch(PDOException $e) {
186
+						echo $e->getMessage();
187
+						die;
188
+				}
189
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
190 190
 
191
-                return $spotter_array;
192
-        }
191
+				return $spotter_array;
192
+		}
193 193
 
194
-        /**
195
-        * Gets altitude information based on a particular id
196
-        *
197
-        * @return Array the spotter information
198
-        *
199
-        */
200
-        public function getAltitudeArchiveSpotterDataById($id)
201
-        {
194
+		/**
195
+		 * Gets altitude information based on a particular id
196
+		 *
197
+		 * @return Array the spotter information
198
+		 *
199
+		 */
200
+		public function getAltitudeArchiveSpotterDataById($id)
201
+		{
202 202
 
203
-                date_default_timezone_set('UTC');
203
+				date_default_timezone_set('UTC');
204 204
 
205
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
206
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
205
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
206
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
207 207
 
208
-                try {
209
-                        $sth = $this->db->prepare($query);
210
-                        $sth->execute(array(':id' => $id));
211
-                } catch(PDOException $e) {
212
-                        echo $e->getMessage();
213
-                        die;
214
-                }
215
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
208
+				try {
209
+						$sth = $this->db->prepare($query);
210
+						$sth->execute(array(':id' => $id));
211
+				} catch(PDOException $e) {
212
+						echo $e->getMessage();
213
+						die;
214
+				}
215
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
216 216
 
217
-                return $spotter_array;
218
-        }
217
+				return $spotter_array;
218
+		}
219 219
 
220
-        /**
221
-        * Gets altitude & speed information based on a particular id
222
-        *
223
-        * @return Array the spotter information
224
-        *
225
-        */
226
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
227
-        {
220
+		/**
221
+		 * Gets altitude & speed information based on a particular id
222
+		 *
223
+		 * @return Array the spotter information
224
+		 *
225
+		 */
226
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
227
+		{
228 228
 
229
-                date_default_timezone_set('UTC');
229
+				date_default_timezone_set('UTC');
230 230
 
231
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
232
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
231
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
232
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
233 233
 
234
-                try {
235
-                        $sth = $this->db->prepare($query);
236
-                        $sth->execute(array(':id' => $id));
237
-                } catch(PDOException $e) {
238
-                        echo $e->getMessage();
239
-                        die;
240
-                }
241
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
234
+				try {
235
+						$sth = $this->db->prepare($query);
236
+						$sth->execute(array(':id' => $id));
237
+				} catch(PDOException $e) {
238
+						echo $e->getMessage();
239
+						die;
240
+				}
241
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
242 242
 
243
-                return $spotter_array;
244
-        }
243
+				return $spotter_array;
244
+		}
245 245
 
246 246
 
247
-        /**
248
-        * Gets altitude information based on a particular callsign
249
-        *
250
-        * @return Array the spotter information
251
-        *
252
-        */
253
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
254
-        {
247
+		/**
248
+		 * Gets altitude information based on a particular callsign
249
+		 *
250
+		 * @return Array the spotter information
251
+		 *
252
+		 */
253
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
254
+		{
255 255
 
256
-                date_default_timezone_set('UTC');
256
+				date_default_timezone_set('UTC');
257 257
 
258
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
259
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
258
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
259
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
260 260
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
261 261
 
262
-                try {
263
-                        $sth = $this->db->prepare($query);
264
-                        $sth->execute(array(':ident' => $ident));
265
-                } catch(PDOException $e) {
266
-                        echo $e->getMessage();
267
-                        die;
268
-                }
269
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
262
+				try {
263
+						$sth = $this->db->prepare($query);
264
+						$sth->execute(array(':ident' => $ident));
265
+				} catch(PDOException $e) {
266
+						echo $e->getMessage();
267
+						die;
268
+				}
269
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
270 270
 
271
-                return $spotter_array;
272
-        }
271
+				return $spotter_array;
272
+		}
273 273
 
274 274
 
275 275
 
276
-       /**
277
-        * Gets all the archive spotter information
278
-        *
279
-        * @return Array the spotter information
280
-        *
281
-        */
282
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
283
-        {
284
-    		$Spotter = new Spotter($this->db);
285
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
286
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
276
+	   /**
277
+	    * Gets all the archive spotter information
278
+	    *
279
+	    * @return Array the spotter information
280
+	    *
281
+	    */
282
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
283
+		{
284
+			$Spotter = new Spotter($this->db);
285
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
286
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
287 287
 
288
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
288
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
289 289
 
290
-                return $spotter_array;
291
-        }
290
+				return $spotter_array;
291
+		}
292 292
         
293
-        public function deleteSpotterArchiveTrackData()
294
-        {
293
+		public function deleteSpotterArchiveTrackData()
294
+		{
295 295
 		global $globalArchiveKeepTrackMonths;
296
-                date_default_timezone_set('UTC');
296
+				date_default_timezone_set('UTC');
297 297
 		$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
298
-                try {
299
-                        $sth = $this->db->prepare($query);
300
-                        $sth->execute();
301
-                } catch(PDOException $e) {
302
-                        echo $e->getMessage();
303
-                        die;
304
-                }
298
+				try {
299
+						$sth = $this->db->prepare($query);
300
+						$sth->execute();
301
+				} catch(PDOException $e) {
302
+						echo $e->getMessage();
303
+						die;
304
+				}
305 305
 	}
306 306
 
307 307
 	/**
308
-        * Gets Minimal Live Spotter data
309
-        *
310
-        * @return Array the spotter information
311
-        *
312
-        */
313
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
314
-        {
315
-                global $globalDBdriver, $globalLiveInterval;
316
-                date_default_timezone_set('UTC');
317
-
318
-                $filter_query = '';
319
-                if (isset($filter['source']) && !empty($filter['source'])) {
320
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
321
-                }
322
-                // Use spotter_output also ?
323
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
324
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
325
-                }
326
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
327
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
328
-                }
329
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
330
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
331
-                }
332
-
333
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
334
-                if ($globalDBdriver == 'mysql') {
335
-                        /*
308
+	 * Gets Minimal Live Spotter data
309
+	 *
310
+	 * @return Array the spotter information
311
+	 *
312
+	 */
313
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
314
+		{
315
+				global $globalDBdriver, $globalLiveInterval;
316
+				date_default_timezone_set('UTC');
317
+
318
+				$filter_query = '';
319
+				if (isset($filter['source']) && !empty($filter['source'])) {
320
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
321
+				}
322
+				// Use spotter_output also ?
323
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
324
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
325
+				}
326
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
327
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
328
+				}
329
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
330
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
331
+				}
332
+
333
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
334
+				if ($globalDBdriver == 'mysql') {
335
+						/*
336 336
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
337 337
                     		    FROM spotter_archive 
338 338
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -353,56 +353,56 @@  discard block
 block discarded – undo
353 353
 						WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".') 
354 354
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
355 355
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
356
-                } else {
357
-                        //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
358
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
356
+				} else {
357
+						//$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
358
+						$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
359 359
                         	    FROM spotter_archive 
360 360
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
361 361
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
362 362
                         	    '.$filter_query.' ORDER BY flightaware_id LIMIT 3500 OFFSET 0';
363
-                }
364
-                //echo $query;
365
-                try {
366
-                        $sth = $this->db->prepare($query);
367
-                        $sth->execute();
368
-                } catch(PDOException $e) {
369
-                        echo $e->getMessage();
370
-                        die;
371
-                }
372
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
373
-
374
-                return $spotter_array;
375
-        }
363
+				}
364
+				//echo $query;
365
+				try {
366
+						$sth = $this->db->prepare($query);
367
+						$sth->execute();
368
+				} catch(PDOException $e) {
369
+						echo $e->getMessage();
370
+						die;
371
+				}
372
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
373
+
374
+				return $spotter_array;
375
+		}
376 376
 
377 377
 	/**
378
-        * Gets Minimal Live Spotter data
379
-        *
380
-        * @return Array the spotter information
381
-        *
382
-        */
383
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
384
-        {
385
-                global $globalDBdriver, $globalLiveInterval;
386
-                date_default_timezone_set('UTC');
387
-
388
-                $filter_query = '';
389
-                if (isset($filter['source']) && !empty($filter['source'])) {
390
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
391
-                }
392
-                // Should use spotter_output also ?
393
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
394
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
395
-                }
396
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
397
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
398
-                }
399
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
400
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
401
-                }
402
-
403
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
404
-                if ($globalDBdriver == 'mysql') {
405
-                        /*
378
+	 * Gets Minimal Live Spotter data
379
+	 *
380
+	 * @return Array the spotter information
381
+	 *
382
+	 */
383
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
384
+		{
385
+				global $globalDBdriver, $globalLiveInterval;
386
+				date_default_timezone_set('UTC');
387
+
388
+				$filter_query = '';
389
+				if (isset($filter['source']) && !empty($filter['source'])) {
390
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
391
+				}
392
+				// Should use spotter_output also ?
393
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
394
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
395
+				}
396
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
397
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
398
+				}
399
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
400
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
401
+				}
402
+
403
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
404
+				if ($globalDBdriver == 'mysql') {
405
+						/*
406 406
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
407 407
                     		    FROM spotter_archive 
408 408
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -413,95 +413,95 @@  discard block
 block discarded – undo
413 413
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
414 414
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
415 415
 
416
-                } else {
417
-                        //$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
418
-                       /*
416
+				} else {
417
+						//$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
418
+					   /*
419 419
                         $query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
420 420
                         	    FROM spotter_archive_output 
421 421
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
422 422
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
423 423
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
424 424
                         */
425
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
425
+						$query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
426 426
                         	    FROM spotter_archive_output 
427 427
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
428 428
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
429 429
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
430 430
 //                        	    .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
431 431
                         	    
432
-                }
433
-                //echo $query;
434
-                try {
435
-                        $sth = $this->db->prepare($query);
436
-                        $sth->execute();
437
-                } catch(PDOException $e) {
438
-                        echo $e->getMessage();
439
-                        die;
440
-                }
441
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
442
-
443
-                return $spotter_array;
444
-        }
432
+				}
433
+				//echo $query;
434
+				try {
435
+						$sth = $this->db->prepare($query);
436
+						$sth->execute();
437
+				} catch(PDOException $e) {
438
+						echo $e->getMessage();
439
+						die;
440
+				}
441
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
442
+
443
+				return $spotter_array;
444
+		}
445 445
 
446 446
 	 /**
447
-        * Gets count Live Spotter data
448
-        *
449
-        * @return Array the spotter information
450
-        *
451
-        */
452
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
453
-        {
454
-                global $globalDBdriver, $globalLiveInterval;
455
-                date_default_timezone_set('UTC');
456
-
457
-                $filter_query = '';
458
-                if (isset($filter['source']) && !empty($filter['source'])) {
459
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
460
-                }
461
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
462
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
463
-                }
464
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
465
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
466
-                }
467
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
468
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
469
-                }
470
-
471
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
472
-                if ($globalDBdriver == 'mysql') {
447
+	  * Gets count Live Spotter data
448
+	  *
449
+	  * @return Array the spotter information
450
+	  *
451
+	  */
452
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
453
+		{
454
+				global $globalDBdriver, $globalLiveInterval;
455
+				date_default_timezone_set('UTC');
456
+
457
+				$filter_query = '';
458
+				if (isset($filter['source']) && !empty($filter['source'])) {
459
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
460
+				}
461
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
462
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
463
+				}
464
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
465
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
466
+				}
467
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
468
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
469
+				}
470
+
471
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
472
+				if ($globalDBdriver == 'mysql') {
473 473
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
474 474
 			FROM spotter_archive l 
475 475
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
476
-                } else {
476
+				} else {
477 477
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
478
-                }
479
-                //echo $query;
480
-                try {
481
-                        $sth = $this->db->prepare($query);
482
-                        $sth->execute();
483
-                } catch(PDOException $e) {
484
-                        echo $e->getMessage();
485
-                        die;
486
-                }
478
+				}
479
+				//echo $query;
480
+				try {
481
+						$sth = $this->db->prepare($query);
482
+						$sth->execute();
483
+				} catch(PDOException $e) {
484
+						echo $e->getMessage();
485
+						die;
486
+				}
487 487
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
488 488
 		$sth->closeCursor();
489
-                return $result['nb'];
489
+				return $result['nb'];
490 490
 
491
-        }
491
+		}
492 492
 
493 493
 
494 494
 
495 495
 	// Spotter_Archive_output
496 496
 	
497
-    /**
498
-    * Gets all the spotter information
499
-    *
500
-    * @return Array the spotter information
501
-    *
502
-    */
503
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filter=array())
504
-    {
497
+	/**
498
+	 * Gets all the spotter information
499
+	 *
500
+	 * @return Array the spotter information
501
+	 *
502
+	 */
503
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filter=array())
504
+	{
505 505
 	global $globalTimezone, $globalDBdriver;
506 506
 	require_once(dirname(__FILE__).'/class.Translation.php');
507 507
 	$Translation = new Translation();
@@ -515,159 +515,159 @@  discard block
 block discarded – undo
515 515
 	$filter_query = $this->getFilter($filter);
516 516
 	if ($q != "")
517 517
 	{
518
-	    if (!is_string($q))
519
-	    {
518
+		if (!is_string($q))
519
+		{
520 520
 		return false;
521
-	    } else {
521
+		} else {
522 522
 	        
523 523
 		$q_array = explode(" ", $q);
524 524
 		
525 525
 		foreach ($q_array as $q_item){
526
-		    $additional_query .= " AND (";
527
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
528
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
529
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
530
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
531
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
532
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
533
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
534
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
535
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
536
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
537
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
538
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
539
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
540
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
541
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
542
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
543
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
544
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
545
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
546
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
547
-		    $translate = $Translation->ident2icao($q_item);
548
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
549
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
550
-		    $additional_query .= ")";
551
-		}
552
-	    }
526
+			$additional_query .= " AND (";
527
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
528
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
529
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
530
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
531
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
532
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
533
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
534
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
535
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
536
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
537
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
538
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
539
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
540
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
541
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
542
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
543
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
544
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
545
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
546
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
547
+			$translate = $Translation->ident2icao($q_item);
548
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
549
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
550
+			$additional_query .= ")";
551
+		}
552
+		}
553 553
 	}
554 554
 	
555 555
 	if ($registration != "")
556 556
 	{
557
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
558
-	    if (!is_string($registration))
559
-	    {
557
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
558
+		if (!is_string($registration))
559
+		{
560 560
 		return false;
561
-	    } else {
561
+		} else {
562 562
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
563
-	    }
563
+		}
564 564
 	}
565 565
 	
566 566
 	if ($aircraft_icao != "")
567 567
 	{
568
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
569
-	    if (!is_string($aircraft_icao))
570
-	    {
568
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
569
+		if (!is_string($aircraft_icao))
570
+		{
571 571
 		return false;
572
-	    } else {
572
+		} else {
573 573
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
574
-	    }
574
+		}
575 575
 	}
576 576
 	
577 577
 	if ($aircraft_manufacturer != "")
578 578
 	{
579
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
580
-	    if (!is_string($aircraft_manufacturer))
581
-	    {
579
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
580
+		if (!is_string($aircraft_manufacturer))
581
+		{
582 582
 		return false;
583
-	    } else {
583
+		} else {
584 584
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
585
-	    }
585
+		}
586 586
 	}
587 587
 	
588 588
 	if ($highlights == "true")
589 589
 	{
590
-	    if (!is_string($highlights))
591
-	    {
590
+		if (!is_string($highlights))
591
+		{
592 592
 		return false;
593
-	    } else {
593
+		} else {
594 594
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
595
-	    }
595
+		}
596 596
 	}
597 597
 	
598 598
 	if ($airline_icao != "")
599 599
 	{
600
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
601
-	    if (!is_string($airline_icao))
602
-	    {
600
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
601
+		if (!is_string($airline_icao))
602
+		{
603 603
 		return false;
604
-	    } else {
604
+		} else {
605 605
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
606
-	    }
606
+		}
607 607
 	}
608 608
 	
609 609
 	if ($airline_country != "")
610 610
 	{
611
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
612
-	    if (!is_string($airline_country))
613
-	    {
611
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
612
+		if (!is_string($airline_country))
613
+		{
614 614
 		return false;
615
-	    } else {
615
+		} else {
616 616
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
617
-	    }
617
+		}
618 618
 	}
619 619
 	
620 620
 	if ($airline_type != "")
621 621
 	{
622
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
623
-	    if (!is_string($airline_type))
624
-	    {
622
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
623
+		if (!is_string($airline_type))
624
+		{
625 625
 		return false;
626
-	    } else {
626
+		} else {
627 627
 		if ($airline_type == "passenger")
628 628
 		{
629
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
629
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
630 630
 		}
631 631
 		if ($airline_type == "cargo")
632 632
 		{
633
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
633
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
634 634
 		}
635 635
 		if ($airline_type == "military")
636 636
 		{
637
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
637
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
638
+		}
638 639
 		}
639
-	    }
640 640
 	}
641 641
 	
642 642
 	if ($airport != "")
643 643
 	{
644
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
645
-	    if (!is_string($airport))
646
-	    {
644
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
645
+		if (!is_string($airport))
646
+		{
647 647
 		return false;
648
-	    } else {
648
+		} else {
649 649
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
650
-	    }
650
+		}
651 651
 	}
652 652
 	
653 653
 	if ($airport_country != "")
654 654
 	{
655
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
656
-	    if (!is_string($airport_country))
657
-	    {
655
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
656
+		if (!is_string($airport_country))
657
+		{
658 658
 		return false;
659
-	    } else {
659
+		} else {
660 660
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
661
-	    }
661
+		}
662 662
 	}
663 663
     
664 664
 	if ($callsign != "")
665 665
 	{
666
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
667
-	    if (!is_string($callsign))
668
-	    {
666
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
667
+		if (!is_string($callsign))
668
+		{
669 669
 		return false;
670
-	    } else {
670
+		} else {
671 671
 		$translate = $Translation->ident2icao($callsign);
672 672
 		if ($translate != $callsign) {
673 673
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -675,99 +675,99 @@  discard block
 block discarded – undo
675 675
 		} else {
676 676
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
677 677
 		}
678
-	    }
678
+		}
679 679
 	}
680 680
 
681 681
 	if ($owner != "")
682 682
 	{
683
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
684
-	    if (!is_string($owner))
685
-	    {
683
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
684
+		if (!is_string($owner))
685
+		{
686 686
 		return false;
687
-	    } else {
687
+		} else {
688 688
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
689
-	    }
689
+		}
690 690
 	}
691 691
 
692 692
 	if ($pilot_name != "")
693 693
 	{
694
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
695
-	    if (!is_string($pilot_name))
696
-	    {
694
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
695
+		if (!is_string($pilot_name))
696
+		{
697 697
 		return false;
698
-	    } else {
698
+		} else {
699 699
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
700
-	    }
700
+		}
701 701
 	}
702 702
 	
703 703
 	if ($pilot_id != "")
704 704
 	{
705
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
706
-	    if (!is_string($pilot_id))
707
-	    {
705
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
706
+		if (!is_string($pilot_id))
707
+		{
708 708
 		return false;
709
-	    } else {
709
+		} else {
710 710
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
711
-	    }
711
+		}
712 712
 	}
713 713
 	
714 714
 	if ($departure_airport_route != "")
715 715
 	{
716
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
717
-	    if (!is_string($departure_airport_route))
718
-	    {
716
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
717
+		if (!is_string($departure_airport_route))
718
+		{
719 719
 		return false;
720
-	    } else {
720
+		} else {
721 721
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
722
-	    }
722
+		}
723 723
 	}
724 724
 	
725 725
 	if ($arrival_airport_route != "")
726 726
 	{
727
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
728
-	    if (!is_string($arrival_airport_route))
729
-	    {
727
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
728
+		if (!is_string($arrival_airport_route))
729
+		{
730 730
 		return false;
731
-	    } else {
731
+		} else {
732 732
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
733
-	    }
733
+		}
734 734
 	}
735 735
 	
736 736
 	if ($altitude != "")
737 737
 	{
738
-	    $altitude_array = explode(",", $altitude);
738
+		$altitude_array = explode(",", $altitude);
739 739
 	    
740
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
741
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
740
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
741
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
742 742
 	    
743 743
 
744
-	    if ($altitude_array[1] != "")
745
-	    {                
744
+		if ($altitude_array[1] != "")
745
+		{                
746 746
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
747 747
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
748 748
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
749
-	    } else {
749
+		} else {
750 750
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
751 751
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
752
-	    }
752
+		}
753 753
 	}
754 754
 	
755 755
 	if ($date_posted != "")
756 756
 	{
757
-	    $date_array = explode(",", $date_posted);
757
+		$date_array = explode(",", $date_posted);
758 758
 	    
759
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
760
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
759
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
760
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
761 761
 	    
762
-	    if ($globalTimezone != '') {
762
+		if ($globalTimezone != '') {
763 763
 		date_default_timezone_set($globalTimezone);
764 764
 		$datetime = new DateTime();
765 765
 		$offset = $datetime->format('P');
766
-	    } else $offset = '+00:00';
766
+		} else $offset = '+00:00';
767 767
 
768 768
 
769
-	    if ($date_array[1] != "")
770
-	    {                
769
+		if ($date_array[1] != "")
770
+		{                
771 771
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
772 772
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
773 773
 		if ($globalDBdriver == 'mysql') {
@@ -775,28 +775,28 @@  discard block
 block discarded – undo
775 775
 		} else {
776 776
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
777 777
 		}
778
-	    } else {
778
+		} else {
779 779
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
780
-                if ($globalDBdriver == 'mysql') {
780
+				if ($globalDBdriver == 'mysql') {
781 781
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
782 782
 		} else {
783 783
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
784 784
 		}
785
-	    }
785
+		}
786 786
 	}
787 787
 	
788 788
 	if ($limit != "")
789 789
 	{
790
-	    $limit_array = explode(",", $limit);
790
+		$limit_array = explode(",", $limit);
791 791
 	    
792
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
793
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
792
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
793
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
794 794
 	    
795
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
796
-	    {
795
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
796
+		{
797 797
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
798 798
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
799
-	    }
799
+		}
800 800
 	}
801 801
 	
802 802
 
@@ -827,33 +827,33 @@  discard block
 block discarded – undo
827 827
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
828 828
 
829 829
 	return $spotter_array;
830
-    }
830
+	}
831 831
 
832
-    public function deleteSpotterArchiveData()
833
-    {
832
+	public function deleteSpotterArchiveData()
833
+	{
834 834
 		global $globalArchiveKeepMonths, $globalDBdriver;
835
-                date_default_timezone_set('UTC');
836
-                if ($globalDBdriver == 'mysql') {
835
+				date_default_timezone_set('UTC');
836
+				if ($globalDBdriver == 'mysql') {
837 837
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
838 838
 		} else {
839 839
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
840 840
 		}
841
-                try {
842
-                        $sth = $this->db->prepare($query);
843
-                        $sth->execute();
844
-                } catch(PDOException $e) {
845
-                        return "error";
846
-                }
841
+				try {
842
+						$sth = $this->db->prepare($query);
843
+						$sth->execute();
844
+				} catch(PDOException $e) {
845
+						return "error";
846
+				}
847 847
 	}
848 848
 
849
-    /**
850
-    * Gets all the spotter information based on the callsign
851
-    *
852
-    * @return Array the spotter information
853
-    *
854
-    */
855
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
856
-    {
849
+	/**
850
+	 * Gets all the spotter information based on the callsign
851
+	 *
852
+	 * @return Array the spotter information
853
+	 *
854
+	 */
855
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
856
+	{
857 857
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
858 858
 	
859 859
 	date_default_timezone_set('UTC');
@@ -865,35 +865,35 @@  discard block
 block discarded – undo
865 865
 	
866 866
 	if ($ident != "")
867 867
 	{
868
-	    if (!is_string($ident))
869
-	    {
868
+		if (!is_string($ident))
869
+		{
870 870
 		return false;
871
-	    } else {
871
+		} else {
872 872
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
873 873
 		$query_values = array(':ident' => $ident);
874
-	    }
874
+		}
875 875
 	}
876 876
 	
877 877
 	if ($limit != "")
878 878
 	{
879
-	    $limit_array = explode(",", $limit);
879
+		$limit_array = explode(",", $limit);
880 880
 	    
881
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
882
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
881
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
882
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
883 883
 	    
884
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
885
-	    {
884
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
885
+		{
886 886
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
887 887
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
888
-	    }
888
+		}
889 889
 	}
890 890
 
891 891
 	if ($sort != "")
892 892
 	{
893
-	    $search_orderby_array = $Spotter->getOrderBy();
894
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
893
+		$search_orderby_array = $Spotter->getOrderBy();
894
+		$orderby_query = $search_orderby_array[$sort]['sql'];
895 895
 	} else {
896
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
896
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
897 897
 	}
898 898
 
899 899
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -901,16 +901,16 @@  discard block
 block discarded – undo
901 901
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
902 902
 
903 903
 	return $spotter_array;
904
-    }
905
-
906
-    /**
907
-    * Gets all number of flight over countries
908
-    *
909
-    * @return Array the airline country list
910
-    *
911
-    */
912
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
913
-    {
904
+	}
905
+
906
+	/**
907
+	 * Gets all number of flight over countries
908
+	 *
909
+	 * @return Array the airline country list
910
+	 *
911
+	 */
912
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
913
+	{
914 914
 	global $globalDBdriver;
915 915
 	/*
916 916
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -920,14 +920,14 @@  discard block
 block discarded – undo
920 920
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
921 921
 		    FROM countries c, spotter_archive s
922 922
 		    WHERE c.iso2 = s.over_country ";
923
-                if ($olderthanmonths > 0) {
924
-            		if ($globalDBdriver == 'mysql') {
923
+				if ($olderthanmonths > 0) {
924
+					if ($globalDBdriver == 'mysql') {
925 925
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
926 926
 			} else {
927 927
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
928 928
 			}
929 929
 		}
930
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
930
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
931 931
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
932 932
 	if ($limit) $query .= " LIMIT 0,10";
933 933
       
@@ -940,23 +940,23 @@  discard block
 block discarded – undo
940 940
         
941 941
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
942 942
 	{
943
-	    $temp_array['flight_count'] = $row['nb'];
944
-	    $temp_array['flight_country'] = $row['name'];
945
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
946
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
947
-	    $flight_array[] = $temp_array;
943
+		$temp_array['flight_count'] = $row['nb'];
944
+		$temp_array['flight_country'] = $row['name'];
945
+		$temp_array['flight_country_iso3'] = $row['iso3'];
946
+		$temp_array['flight_country_iso2'] = $row['iso2'];
947
+		$flight_array[] = $temp_array;
948 948
 	}
949 949
 	return $flight_array;
950
-    }
951
-
952
-    /**
953
-    * Gets last spotter information based on a particular callsign
954
-    *
955
-    * @return Array the spotter information
956
-    *
957
-    */
958
-    public function getDateArchiveSpotterDataById($id,$date)
959
-    {
950
+	}
951
+
952
+	/**
953
+	 * Gets last spotter information based on a particular callsign
954
+	 *
955
+	 * @return Array the spotter information
956
+	 *
957
+	 */
958
+	public function getDateArchiveSpotterDataById($id,$date)
959
+	{
960 960
 	$Spotter = new Spotter($this->db);
961 961
 	date_default_timezone_set('UTC');
962 962
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -964,16 +964,16 @@  discard block
 block discarded – undo
964 964
 	$date = date('c',$date);
965 965
 	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
966 966
 	return $spotter_array;
967
-    }
968
-
969
-    /**
970
-    * Gets all the spotter information based on a particular callsign
971
-    *
972
-    * @return Array the spotter information
973
-    *
974
-    */
975
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
976
-    {
967
+	}
968
+
969
+	/**
970
+	 * Gets all the spotter information based on a particular callsign
971
+	 *
972
+	 * @return Array the spotter information
973
+	 *
974
+	 */
975
+	public function getDateArchiveSpotterDataByIdent($ident,$date)
976
+	{
977 977
 	$Spotter = new Spotter($this->db);
978 978
 	date_default_timezone_set('UTC');
979 979
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 	$date = date('c',$date);
982 982
 	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
983 983
 	return $spotter_array;
984
-    }
984
+	}
985 985
 
986 986
 
987 987
 }
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 	public function getFilter($filter) {
12 12
 		$filter_query = '';
13 13
 		if (isset($filter['source']) && !empty($filter['source'])) {
14
-			$filter_query = " AND format_source IN ('".implode("','",$filter['source'])."')";
14
+			$filter_query = " AND format_source IN ('".implode("','", $filter['source'])."')";
15 15
 		}
16 16
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
17
-			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
17
+			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
18 18
 		}
19 19
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
20 20
 			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
@@ -23,37 +23,37 @@  discard block
 block discarded – undo
23 23
 			$filter_query_where = " WHERE ident =  '".$filter['ident']."'";
24 24
 		}
25 25
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
26
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
26
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
27 27
 		}
28 28
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
29
-			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
29
+			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
30 30
 		}
31 31
 		return $filter_query;
32 32
 	}
33 33
 
34 34
 	// Spotter_archive
35
-	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
35
+	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
36 36
 		require_once(dirname(__FILE__).'/class.Spotter.php');
37 37
 		if ($over_country == '') {
38 38
 			$Spotter = new Spotter($this->db);
39
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
39
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
40 40
 			if (!empty($data_country)) $country = $data_country['iso2'];
41 41
 			else $country = '';
42 42
 		} else $country = $over_country;
43
-		if ($airline_type === NULL) $airline_type ='';
43
+		if ($airline_type === NULL) $airline_type = '';
44 44
 	
45 45
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
46 46
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
47 47
 
48 48
 		// Route is not added in spotter_archive
49
-		$query  = "INSERT INTO spotter_archive (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, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
49
+		$query = "INSERT INTO spotter_archive (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, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
50 50
 		        VALUES (: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, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)";
51 51
 
52
-		$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_name' => $aircraft_name, ':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, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
52
+		$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_name' => $aircraft_name, ':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, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
53 53
 		try {
54 54
 			$sth = $this->db->prepare($query);
55 55
 			$sth->execute($query_values);
56
-		} catch(PDOException $e) {
56
+		} catch (PDOException $e) {
57 57
 			return "error : ".$e->getMessage();
58 58
 		}
59 59
 		return "success";
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 
74 74
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
75 75
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
76
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
76
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
77 77
 
78
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
78
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
79 79
 
80 80
                 return $spotter_array;
81 81
         }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
95 95
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
96 96
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
97
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
97
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
98 98
 
99 99
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
100 100
                   /*
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                 }
108 108
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
109 109
                 */
110
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
110
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
111 111
 
112 112
                 return $spotter_array;
113 113
         }
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
         {
123 123
                 date_default_timezone_set('UTC');
124 124
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
125
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
125
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
126 126
 
127 127
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
128 128
 
129 129
                 try {
130 130
                         $sth = $this->db->prepare($query);
131 131
                         $sth->execute(array(':id' => $id));
132
-                } catch(PDOException $e) {
132
+                } catch (PDOException $e) {
133 133
                         echo $e->getMessage();
134 134
                         die;
135 135
                 }
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
         {
149 149
                 date_default_timezone_set('UTC');
150 150
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
151
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
151
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
152 152
 
153 153
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
154 154
 
155 155
                 try {
156 156
                         $sth = $this->db->prepare($query);
157 157
                         $sth->execute(array(':id' => $id));
158
-                } catch(PDOException $e) {
158
+                } catch (PDOException $e) {
159 159
                         echo $e->getMessage();
160 160
                         die;
161 161
                 }
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
                 date_default_timezone_set('UTC');
178 178
 
179 179
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
180
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
180
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
181 181
 
182 182
                 try {
183 183
                         $sth = $this->db->prepare($query);
184 184
                         $sth->execute(array(':ident' => $ident));
185
-                } catch(PDOException $e) {
185
+                } catch (PDOException $e) {
186 186
                         echo $e->getMessage();
187 187
                         die;
188 188
                 }
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
                 date_default_timezone_set('UTC');
204 204
 
205 205
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
206
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
206
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
207 207
 
208 208
                 try {
209 209
                         $sth = $this->db->prepare($query);
210 210
                         $sth->execute(array(':id' => $id));
211
-                } catch(PDOException $e) {
211
+                } catch (PDOException $e) {
212 212
                         echo $e->getMessage();
213 213
                         die;
214 214
                 }
@@ -229,12 +229,12 @@  discard block
 block discarded – undo
229 229
                 date_default_timezone_set('UTC');
230 230
 
231 231
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
232
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
232
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
233 233
 
234 234
                 try {
235 235
                         $sth = $this->db->prepare($query);
236 236
                         $sth->execute(array(':id' => $id));
237
-                } catch(PDOException $e) {
237
+                } catch (PDOException $e) {
238 238
                         echo $e->getMessage();
239 239
                         die;
240 240
                 }
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
                 date_default_timezone_set('UTC');
257 257
 
258 258
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
259
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
259
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
260 260
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
261 261
 
262 262
                 try {
263 263
                         $sth = $this->db->prepare($query);
264 264
                         $sth->execute(array(':ident' => $ident));
265
-                } catch(PDOException $e) {
265
+                } catch (PDOException $e) {
266 266
                         echo $e->getMessage();
267 267
                         die;
268 268
                 }
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
         * @return Array the spotter information
280 280
         *
281 281
         */
282
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
282
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
283 283
         {
284 284
     		$Spotter = new Spotter($this->db);
285 285
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
286
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
286
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
287 287
 
288
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
288
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
289 289
 
290 290
                 return $spotter_array;
291 291
         }
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
                 try {
299 299
                         $sth = $this->db->prepare($query);
300 300
                         $sth->execute();
301
-                } catch(PDOException $e) {
301
+                } catch (PDOException $e) {
302 302
                         echo $e->getMessage();
303 303
                         die;
304 304
                 }
@@ -310,24 +310,24 @@  discard block
 block discarded – undo
310 310
         * @return Array the spotter information
311 311
         *
312 312
         */
313
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
313
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
314 314
         {
315 315
                 global $globalDBdriver, $globalLiveInterval;
316 316
                 date_default_timezone_set('UTC');
317 317
 
318 318
                 $filter_query = '';
319 319
                 if (isset($filter['source']) && !empty($filter['source'])) {
320
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
320
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
321 321
                 }
322 322
                 // Use spotter_output also ?
323 323
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
324
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
324
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
325 325
                 }
326 326
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
327 327
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
328 328
                 }
329 329
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
330
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
330
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
331 331
                 }
332 332
 
333 333
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
347 347
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
348 348
 */
349
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
349
+			$query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
350 350
 				    FROM spotter_archive 
351 351
 				    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
352 352
 						FROM spotter_archive l 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
356 356
                 } else {
357 357
                         //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
358
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
358
+                        $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
359 359
                         	    FROM spotter_archive 
360 360
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
361 361
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                 try {
366 366
                         $sth = $this->db->prepare($query);
367 367
                         $sth->execute();
368
-                } catch(PDOException $e) {
368
+                } catch (PDOException $e) {
369 369
                         echo $e->getMessage();
370 370
                         die;
371 371
                 }
@@ -380,24 +380,24 @@  discard block
 block discarded – undo
380 380
         * @return Array the spotter information
381 381
         *
382 382
         */
383
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
383
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
384 384
         {
385 385
                 global $globalDBdriver, $globalLiveInterval;
386 386
                 date_default_timezone_set('UTC');
387 387
 
388 388
                 $filter_query = '';
389 389
                 if (isset($filter['source']) && !empty($filter['source'])) {
390
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
390
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
391 391
                 }
392 392
                 // Should use spotter_output also ?
393 393
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
394
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
394
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
395 395
                 }
396 396
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
397 397
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
398 398
                 }
399 399
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
400
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
400
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
401 401
                 }
402 402
 
403 403
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
                     		    FROM spotter_archive 
408 408
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
409 409
 			*/
410
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
410
+			$query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
411 411
 				    FROM spotter_archive_output 
412 412
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
413 413
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
423 423
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
424 424
                         */
425
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
425
+                        $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
426 426
                         	    FROM spotter_archive_output 
427 427
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
428 428
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
                 try {
435 435
                         $sth = $this->db->prepare($query);
436 436
                         $sth->execute();
437
-                } catch(PDOException $e) {
437
+                } catch (PDOException $e) {
438 438
                         echo $e->getMessage();
439 439
                         die;
440 440
                 }
@@ -449,23 +449,23 @@  discard block
 block discarded – undo
449 449
         * @return Array the spotter information
450 450
         *
451 451
         */
452
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
452
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
453 453
         {
454 454
                 global $globalDBdriver, $globalLiveInterval;
455 455
                 date_default_timezone_set('UTC');
456 456
 
457 457
                 $filter_query = '';
458 458
                 if (isset($filter['source']) && !empty($filter['source'])) {
459
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
459
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
460 460
                 }
461 461
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
462
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
462
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
463 463
                 }
464 464
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
465 465
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
466 466
                 }
467 467
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
468
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
468
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
469 469
                 }
470 470
 
471 471
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
                 try {
481 481
                         $sth = $this->db->prepare($query);
482 482
                         $sth->execute();
483
-                } catch(PDOException $e) {
483
+                } catch (PDOException $e) {
484 484
                         echo $e->getMessage();
485 485
                         die;
486 486
                 }
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
     * @return Array the spotter information
501 501
     *
502 502
     */
503
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filter=array())
503
+    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filter = array())
504 504
     {
505 505
 	global $globalTimezone, $globalDBdriver;
506 506
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 	        
523 523
 		$q_array = explode(" ", $q);
524 524
 		
525
-		foreach ($q_array as $q_item){
525
+		foreach ($q_array as $q_item) {
526 526
 		    $additional_query .= " AND (";
527 527
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
528 528
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 	
555 555
 	if ($registration != "")
556 556
 	{
557
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
557
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
558 558
 	    if (!is_string($registration))
559 559
 	    {
560 560
 		return false;
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 	
566 566
 	if ($aircraft_icao != "")
567 567
 	{
568
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
568
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
569 569
 	    if (!is_string($aircraft_icao))
570 570
 	    {
571 571
 		return false;
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	
577 577
 	if ($aircraft_manufacturer != "")
578 578
 	{
579
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
579
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
580 580
 	    if (!is_string($aircraft_manufacturer))
581 581
 	    {
582 582
 		return false;
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	
598 598
 	if ($airline_icao != "")
599 599
 	{
600
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
600
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
601 601
 	    if (!is_string($airline_icao))
602 602
 	    {
603 603
 		return false;
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	
609 609
 	if ($airline_country != "")
610 610
 	{
611
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
611
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
612 612
 	    if (!is_string($airline_country))
613 613
 	    {
614 614
 		return false;
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	
620 620
 	if ($airline_type != "")
621 621
 	{
622
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
622
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
623 623
 	    if (!is_string($airline_type))
624 624
 	    {
625 625
 		return false;
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 	
642 642
 	if ($airport != "")
643 643
 	{
644
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
644
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
645 645
 	    if (!is_string($airport))
646 646
 	    {
647 647
 		return false;
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 	
653 653
 	if ($airport_country != "")
654 654
 	{
655
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
655
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
656 656
 	    if (!is_string($airport_country))
657 657
 	    {
658 658
 		return false;
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
     
664 664
 	if ($callsign != "")
665 665
 	{
666
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
666
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
667 667
 	    if (!is_string($callsign))
668 668
 	    {
669 669
 		return false;
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 		$translate = $Translation->ident2icao($callsign);
672 672
 		if ($translate != $callsign) {
673 673
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
674
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
674
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
675 675
 		} else {
676 676
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
677 677
 		}
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 
681 681
 	if ($owner != "")
682 682
 	{
683
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
683
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
684 684
 	    if (!is_string($owner))
685 685
 	    {
686 686
 		return false;
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 
692 692
 	if ($pilot_name != "")
693 693
 	{
694
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
694
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
695 695
 	    if (!is_string($pilot_name))
696 696
 	    {
697 697
 		return false;
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	
703 703
 	if ($pilot_id != "")
704 704
 	{
705
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
705
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
706 706
 	    if (!is_string($pilot_id))
707 707
 	    {
708 708
 		return false;
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 	
714 714
 	if ($departure_airport_route != "")
715 715
 	{
716
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
716
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
717 717
 	    if (!is_string($departure_airport_route))
718 718
 	    {
719 719
 		return false;
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	
725 725
 	if ($arrival_airport_route != "")
726 726
 	{
727
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
727
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
728 728
 	    if (!is_string($arrival_airport_route))
729 729
 	    {
730 730
 		return false;
@@ -737,8 +737,8 @@  discard block
 block discarded – undo
737 737
 	{
738 738
 	    $altitude_array = explode(",", $altitude);
739 739
 	    
740
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
741
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
740
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
741
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
742 742
 	    
743 743
 
744 744
 	    if ($altitude_array[1] != "")
@@ -756,8 +756,8 @@  discard block
 block discarded – undo
756 756
 	{
757 757
 	    $date_array = explode(",", $date_posted);
758 758
 	    
759
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
760
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
759
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
760
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
761 761
 	    
762 762
 	    if ($globalTimezone != '') {
763 763
 		date_default_timezone_set($globalTimezone);
@@ -789,8 +789,8 @@  discard block
 block discarded – undo
789 789
 	{
790 790
 	    $limit_array = explode(",", $limit);
791 791
 	    
792
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
793
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
792
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
793
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
794 794
 	    
795 795
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
796 796
 	    {
@@ -801,8 +801,8 @@  discard block
 block discarded – undo
801 801
 	
802 802
 
803 803
 	if ($origLat != "" && $origLon != "" && $dist != "") {
804
-		$dist = number_format($dist*0.621371,2,'.','');
805
-		$query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
804
+		$dist = number_format($dist*0.621371, 2, '.', '');
805
+		$query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
806 806
                           FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
807 807
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
808 808
 	} else {
@@ -819,12 +819,12 @@  discard block
 block discarded – undo
819 819
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
820 820
 		}
821 821
 
822
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
822
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
823 823
 		    WHERE spotter_archive_output.ident <> '' 
824 824
 		    ".$additional_query."
825 825
 		    ".$filter_query.$orderby_query;
826 826
 	}
827
-	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
827
+	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
828 828
 
829 829
 	return $spotter_array;
830 830
     }
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
                 try {
842 842
                         $sth = $this->db->prepare($query);
843 843
                         $sth->execute();
844
-                } catch(PDOException $e) {
844
+                } catch (PDOException $e) {
845 845
                         return "error";
846 846
                 }
847 847
 	}
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	{
879 879
 	    $limit_array = explode(",", $limit);
880 880
 	    
881
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
882
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
881
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
882
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
883 883
 	    
884 884
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
885 885
 	    {
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
     * @return Array the airline country list
910 910
     *
911 911
     */
912
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
912
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
913 913
     {
914 914
 	global $globalDBdriver;
915 915
 	/*
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 	$flight_array = array();
939 939
 	$temp_array = array();
940 940
         
941
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
941
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
942 942
 	{
943 943
 	    $temp_array['flight_count'] = $row['nb'];
944 944
 	    $temp_array['flight_country'] = $row['name'];
@@ -955,14 +955,14 @@  discard block
 block discarded – undo
955 955
     * @return Array the spotter information
956 956
     *
957 957
     */
958
-    public function getDateArchiveSpotterDataById($id,$date)
958
+    public function getDateArchiveSpotterDataById($id, $date)
959 959
     {
960 960
 	$Spotter = new Spotter($this->db);
961 961
 	date_default_timezone_set('UTC');
962 962
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
963
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
964
-	$date = date('c',$date);
965
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
963
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
964
+	$date = date('c', $date);
965
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
966 966
 	return $spotter_array;
967 967
     }
968 968
 
@@ -972,14 +972,14 @@  discard block
 block discarded – undo
972 972
     * @return Array the spotter information
973 973
     *
974 974
     */
975
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
975
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
976 976
     {
977 977
 	$Spotter = new Spotter($this->db);
978 978
 	date_default_timezone_set('UTC');
979 979
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
980
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
981
-	$date = date('c',$date);
982
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
980
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
981
+	$date = date('c', $date);
982
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
983 983
 	return $spotter_array;
984 984
     }
985 985
 
Please login to merge, or discard this patch.
require/class.SpotterImport.php 3 patches
Indentation   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 
11 11
 class SpotterImport {
12
-    private $all_flights = array();
13
-    private $last_delete_hourly = 0;
14
-    private $last_delete = 0;
15
-    private $stats = array();
16
-    private $tmd = 0;
17
-    private $source_location = array();
18
-    public $db = null;
19
-    public $nb = 0;
20
-
21
-    public function __construct($dbc = null) {
12
+	private $all_flights = array();
13
+	private $last_delete_hourly = 0;
14
+	private $last_delete = 0;
15
+	private $stats = array();
16
+	private $tmd = 0;
17
+	private $source_location = array();
18
+	public $db = null;
19
+	public $nb = 0;
20
+
21
+	public function __construct($dbc = null) {
22 22
 	global $globalBeta;
23 23
 	$Connection = new Connection($dbc);
24 24
 	$this->db = $Connection->db();
@@ -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) {
33
-	    	$type = $srcst['stats_type'];
32
+		foreach($sourcestat as $srcst) {
33
+			$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35
-		    $source = $srcst['source_name'];
36
-		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
-	        }
39
-	    }
35
+			$source = $srcst['source_name'];
36
+			$data = $srcst['source_data'];
37
+			$this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
+			}
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
 	
@@ -59,35 +59,35 @@  discard block
 block discarded – undo
59 59
 	$Translation = new Translation($dbc);
60 60
 	$operator = $Spotter->getOperator($ident);
61 61
 	if ($Schedule->checkSchedule($operator) == 0) {
62
-	    $operator = $Translation->checkTranslation($ident);
63
-	    if ($Schedule->checkSchedule($operator) == 0) {
62
+		$operator = $Translation->checkTranslation($ident);
63
+		if ($Schedule->checkSchedule($operator) == 0) {
64 64
 		$schedule = $Schedule->fetchSchedule($operator);
65 65
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
66
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
67
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
68
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
69
-		    // Should also check if route schedule = route from DB
70
-		    if ($schedule['DepartureAirportIATA'] != '') {
66
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
67
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
68
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
69
+			// Should also check if route schedule = route from DB
70
+			if ($schedule['DepartureAirportIATA'] != '') {
71 71
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
72
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
73
-			    if ($airport_icao != '') {
72
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
73
+				if ($airport_icao != '') {
74 74
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
75 75
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
76
-			    }
76
+				}
77
+			}
77 78
 			}
78
-		    }
79
-		    if ($schedule['ArrivalAirportIATA'] != '') {
79
+			if ($schedule['ArrivalAirportIATA'] != '') {
80 80
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
81
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
82
-			    if ($airport_icao != '') {
81
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
82
+				if ($airport_icao != '') {
83 83
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
84 84
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
85
-			    }
85
+				}
86
+			}
86 87
 			}
87
-		    }
88
-		    $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']);
88
+			$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
+		}
89 90
 		}
90
-	    }
91 91
 	}
92 92
 	// close connection, at least one way will work ?
93 93
        
@@ -105,92 +105,92 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 	  */
107 107
 	}
108
-    }
108
+	}
109 109
 
110
-    public function checkAll() {
110
+	public function checkAll() {
111 111
 	global $globalDebug;
112 112
 	if ($globalDebug) echo "Update last seen flights data...\n";
113 113
 	foreach ($this->all_flights as $key => $flight) {
114
-	    if (isset($this->all_flights[$key]['id'])) {
114
+		if (isset($this->all_flights[$key]['id'])) {
115 115
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
116
-    		$Spotter = new Spotter($this->db);
117
-        	$real_arrival = $this->arrival($key);
118
-        	$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']);
119
-            }
116
+			$Spotter = new Spotter($this->db);
117
+			$real_arrival = $this->arrival($key);
118
+			$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']);
119
+			}
120
+	}
120 121
 	}
121
-    }
122 122
 
123
-    public function arrival($key) {
123
+	public function arrival($key) {
124 124
 	global $globalClosestMinDist, $globalDebug;
125 125
 	if ($globalDebug) echo 'Update arrival...'."\n";
126 126
 	$Spotter = new Spotter($this->db);
127
-        $airport_icao = '';
128
-        $airport_time = '';
129
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
127
+		$airport_icao = '';
128
+		$airport_time = '';
129
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
130 130
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
131
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
132
-    	    if (isset($closestAirports[0])) {
133
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
134
-        	    $airport_icao = $closestAirports[0]['icao'];
135
-        	    $airport_time = $this->all_flights[$key]['datetime'];
136
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
137
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
138
-        	    foreach ($closestAirports as $airport) {
139
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
140
-        		    $airport_icao = $airport['icao'];
141
-        		    $airport_time = $this->all_flights[$key]['datetime'];
142
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
143
-        		    break;
144
-        		}
145
-        	    }
146
-        	} 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))) {
147
-        		$airport_icao = $closestAirports[0]['icao'];
148
-        		$airport_time = $this->all_flights[$key]['datetime'];
149
-        	} else {
150
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
151
-        	}
152
-    	    } else {
153
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
154
-    	    }
155
-
156
-        } else {
157
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
158
-        }
159
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
160
-    }
161
-
162
-
163
-
164
-    public function del() {
131
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
132
+			if (isset($closestAirports[0])) {
133
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
134
+				$airport_icao = $closestAirports[0]['icao'];
135
+				$airport_time = $this->all_flights[$key]['datetime'];
136
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
137
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
138
+				foreach ($closestAirports as $airport) {
139
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
140
+					$airport_icao = $airport['icao'];
141
+					$airport_time = $this->all_flights[$key]['datetime'];
142
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
143
+					break;
144
+				}
145
+				}
146
+			} 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))) {
147
+				$airport_icao = $closestAirports[0]['icao'];
148
+				$airport_time = $this->all_flights[$key]['datetime'];
149
+			} else {
150
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
151
+			}
152
+			} else {
153
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
154
+			}
155
+
156
+		} else {
157
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
158
+		}
159
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
160
+	}
161
+
162
+
163
+
164
+	public function del() {
165 165
 	global $globalDebug;
166 166
 	// Delete old infos
167 167
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
168 168
 	foreach ($this->all_flights as $key => $flight) {
169
-    	    if (isset($flight['lastupdate'])) {
170
-        	if ($flight['lastupdate'] < (time()-3000)) {
171
-            	    if (isset($this->all_flights[$key]['id'])) {
172
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
169
+			if (isset($flight['lastupdate'])) {
170
+			if ($flight['lastupdate'] < (time()-3000)) {
171
+					if (isset($this->all_flights[$key]['id'])) {
172
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
173 173
 			/*
174 174
 			$SpotterLive = new SpotterLive();
175 175
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
176 176
 			$SpotterLive->db = null;
177 177
 			*/
178
-            		$real_arrival = $this->arrival($key);
179
-            		$Spotter = new Spotter($this->db);
180
-            		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
178
+					$real_arrival = $this->arrival($key);
179
+					$Spotter = new Spotter($this->db);
180
+					if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
181 181
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
182 182
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
183 183
 			}
184 184
 			// Put in archive
185 185
 //			$Spotter->db = null;
186
-            	    }
187
-            	    unset($this->all_flights[$key]);
188
-    	        }
189
-	    }
190
-        }
191
-    }
192
-
193
-    public function add($line) {
186
+					}
187
+					unset($this->all_flights[$key]);
188
+				}
189
+		}
190
+		}
191
+	}
192
+
193
+	public function add($line) {
194 194
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM;
195 195
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
196 196
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -215,18 +215,18 @@  discard block
 block discarded – undo
215 215
 	
216 216
 	// SBS format is CSV format
217 217
 	if(is_array($line) && isset($line['hex'])) {
218
-	    //print_r($line);
219
-  	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
218
+		//print_r($line);
219
+  		if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
220 220
 
221 221
 		// Increment message number
222 222
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
223
-		    $current_date = date('Y-m-d');
224
-		    $source = $line['source_name'];
225
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
226
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
227
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
228
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
229
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
223
+			$current_date = date('Y-m-d');
224
+			$source = $line['source_name'];
225
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
226
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
227
+				$this->stats[$current_date][$source]['msg']['date'] = time();
228
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
229
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
230 230
 		}
231 231
 		
232 232
 		/*
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
 		//$this->db = $dbc;
243 243
 
244 244
 		$hex = trim($line['hex']);
245
-	        if (!isset($line['id'])) $id = trim($line['hex']);
246
-	        else $id = trim($line['id']);
245
+			if (!isset($line['id'])) $id = trim($line['hex']);
246
+			else $id = trim($line['id']);
247 247
 		
248 248
 		//print_r($this->all_flights);
249 249
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
250
-		    $this->all_flights[$id] = array('hex' => $hex);
251
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
252
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
250
+			$this->all_flights[$id] = array('hex' => $hex);
251
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
252
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
253 253
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
254
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
255
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) {
254
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
255
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) {
256 256
 
257 257
 			$timeelapsed = microtime(true);
258 258
 			$Spotter = new Spotter($this->db);
@@ -261,37 +261,37 @@  discard block
 block discarded – undo
261 261
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
262 262
 
263 263
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
264
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
265
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
266
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
267
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
264
+				if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
265
+				elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
266
+				elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
267
+				elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
268 268
 			}
269 269
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
270
-		    } else if (isset($line['aircraft_name'])) {
270
+			} else if (isset($line['aircraft_name'])) {
271 271
 			// Get aircraft ICAO from aircraft name
272 272
 			$Spotter = new Spotter($this->db);
273 273
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
274 274
 			$Spotter->db = null;
275 275
 			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
276 276
 			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
277
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
278
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
279
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
-		    if (!isset($line['id'])) {
277
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
278
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
279
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
+			if (!isset($line['id'])) {
281 281
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
282 282
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
283 283
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
284 284
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
285
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
286
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
285
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
286
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
287 287
 
288
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
288
+			if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
289 289
 		}
290 290
 		
291 291
 		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
292
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
292
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
293 293
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
294
-		    } else {
294
+			} else {
295 295
 				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";
296 296
 				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";
297 297
 				/*
@@ -300,38 +300,38 @@  discard block
 block discarded – undo
300 300
 				print_r($line);
301 301
 				*/
302 302
 				return '';
303
-		    }
303
+			}
304 304
 		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
305 305
 
306 306
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
307
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
307
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
308 308
 		}
309 309
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
310
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
310
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
311 311
 		}
312 312
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
313
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
313
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
314 314
 		}
315 315
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
316
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
316
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
317 317
 		}
318 318
  
319 319
 		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'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
321
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
320
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
321
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
322 322
 			$timeelapsed = microtime(true);
323
-            		$Spotter = new Spotter($this->db);
324
-            		$fromsource = NULL;
325
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
326
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
323
+					$Spotter = new Spotter($this->db);
324
+					$fromsource = NULL;
325
+					if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
326
+					elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
327 327
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
328 328
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
329 329
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
330
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
330
+					$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
331 331
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
332 332
 			$Spotter->db = null;
333 333
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
334
-		    }
334
+			}
335 335
 
336 336
 /*
337 337
 		    if (!isset($line['id'])) {
@@ -341,26 +341,26 @@  discard block
 block discarded – undo
341 341
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
342 342
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
343 343
   */
344
-		    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']));
344
+			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']));
345 345
 
346
-		    //$putinarchive = true;
347
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
346
+			//$putinarchive = true;
347
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
348 348
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
349
-		    }
350
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
349
+			}
350
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
351 351
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
352
-		    }
353
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
354
-		    		$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' => ''));
355
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
352
+			}
353
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
354
+					$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' => ''));
355
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
356 356
 				$timeelapsed = microtime(true);
357 357
 				$Spotter = new Spotter($this->db);
358 358
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
359 359
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
360
-		    		$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' => ''));
360
+					$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' => ''));
361 361
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
362 362
 
363
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
363
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
364 364
 			$timeelapsed = microtime(true);
365 365
 			$Spotter = new Spotter($this->db);
366 366
 			$route = $Spotter->getRouteInfo(trim($line['ident']));
@@ -374,43 +374,43 @@  discard block
 block discarded – undo
374 374
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
375 375
 
376 376
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
377
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
378
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
377
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
378
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
379 379
 				//    $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']));
380
-		    		$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']));
381
-		    	    }
380
+					$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']));
381
+					}
382 382
 			}
383 383
 			if (!isset($globalFork)) $globalFork = TRUE;
384 384
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
385 385
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
386 386
 			}
387
-		    }
387
+			}
388 388
 		}
389 389
 
390 390
 		if (isset($line['speed']) && $line['speed'] != '') {
391 391
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
392
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
393
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
394
-		    //$dataFound = true;
392
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
393
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
394
+			//$dataFound = true;
395 395
 		} 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'])) {
396
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
397
-		    if ($distance > 1000 && $distance < 10000) {
398
-		    // use datetime
396
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
397
+			if ($distance > 1000 && $distance < 10000) {
398
+			// use datetime
399 399
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
400 400
 			$speed = $speed*3.6;
401 401
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
402 402
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
403
-		    }
403
+			}
404 404
 		}
405 405
 
406 406
 
407 407
 
408
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
409
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
410
-	    	    else unset($timediff);
411
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
408
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
409
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
410
+				else unset($timediff);
411
+				if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
412 412
 			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'])) {
413
-			    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'])) {
413
+				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'])) {
414 414
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
415 415
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
416 416
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -425,16 +425,16 @@  discard block
 block discarded – undo
425 425
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
426 426
 				$this->tmd = 0;
427 427
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
428
-			    }
428
+				}
429 429
 			}
430 430
 
431 431
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
432
-			    //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) {
432
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
433 433
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
434 434
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
435
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
436
-				    $dataFound = true;
437
-				    $this->all_flights[$id]['time_last_coord'] = time();
435
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
436
+					$dataFound = true;
437
+					$this->all_flights[$id]['time_last_coord'] = time();
438 438
 				}
439 439
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
440 440
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -445,20 +445,20 @@  discard block
 block discarded – undo
445 445
 				    //$putinarchive = true;
446 446
 				}
447 447
 				*/
448
-			    /*
448
+				/*
449 449
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
450 450
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
451 451
 			    }
452 452
 			    */
453 453
 			}
454 454
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
455
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
456
-			    //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) {
455
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
456
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
457 457
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
458 458
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
459
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
460
-				    $dataFound = true;
461
-				    $this->all_flights[$id]['time_last_coord'] = time();
459
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
460
+					$dataFound = true;
461
+					$this->all_flights[$id]['time_last_coord'] = time();
462 462
 				}
463 463
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
464 464
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -476,53 +476,53 @@  discard block
 block discarded – undo
476 476
 			    */
477 477
 			}
478 478
 
479
-		    } else if ($globalDebug && $timediff > 20) {
479
+			} else if ($globalDebug && $timediff > 20) {
480 480
 			$this->tmd = $this->tmd + 1;
481 481
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
482 482
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
483 483
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
484 484
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
485
-		    }
485
+			}
486 486
 		}
487 487
 		if (isset($line['last_update']) && $line['last_update'] != '') {
488
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
489
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
488
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
489
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
490 490
 		}
491 491
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
492
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
493
-		    //$dataFound = true;
492
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
493
+			//$dataFound = true;
494 494
 		}
495 495
 		if (isset($line['format_source']) && $line['format_source'] != '') {
496
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
496
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
497 497
 		}
498 498
 		if (isset($line['source_name']) && $line['source_name'] != '') {
499
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
499
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
500 500
 		}
501 501
 		if (isset($line['emergency']) && $line['emergency'] != '') {
502
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
503
-		    //$dataFound = true;
502
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
503
+			//$dataFound = true;
504 504
 		}
505 505
 		if (isset($line['ground']) && $line['ground'] != '') {
506
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
506
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
507 507
 			// Here we force archive of flight because after ground it's a new one (or should be)
508 508
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
509 509
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
510 510
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
511
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
511
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
512 512
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
513
-		    }
514
-		    if ($line['ground'] != 1) $line['ground'] = 0;
515
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
516
-		    //$dataFound = true;
513
+			}
514
+			if ($line['ground'] != 1) $line['ground'] = 0;
515
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
516
+			//$dataFound = true;
517 517
 		}
518 518
 		if (isset($line['squawk']) && $line['squawk'] != '') {
519
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
520
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
521
-			    $highlight = '';
522
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
523
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
524
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
525
-			    if ($highlight != '') {
519
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
520
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
521
+				$highlight = '';
522
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
523
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
524
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
525
+				if ($highlight != '') {
526 526
 				$timeelapsed = microtime(true);
527 527
 				$Spotter = new Spotter($this->db);
528 528
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
@@ -532,38 +532,38 @@  discard block
 block discarded – undo
532 532
 				$this->all_flights[$id]['putinarchive'] = true;
533 533
 				//$putinarchive = true;
534 534
 				//$highlight = '';
535
-			    }
535
+				}
536 536
 			    
537
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
538
-		    //$dataFound = true;
537
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
538
+			//$dataFound = true;
539 539
 		}
540 540
 
541 541
 		if (isset($line['altitude']) && $line['altitude'] != '') {
542
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
542
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
543 543
 			if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
544 544
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
545 545
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
546 546
 			//$dataFound = true;
547
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
547
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
548 548
   		}
549 549
 
550 550
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
551
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
551
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
552 552
 		}
553 553
 		
554 554
 		if (isset($line['heading']) && $line['heading'] != '') {
555
-		    if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
556
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
557
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
558
-		    //$dataFound = true;
555
+			if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
556
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
557
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
558
+			//$dataFound = true;
559 559
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
560
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
561
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
562
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
563
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
560
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
561
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
562
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
563
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
564 564
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
565
-  		    // If not enough messages and ACARS set heading to 0
566
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
565
+  			// If not enough messages and ACARS set heading to 0
566
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
567 567
   		}
568 568
 		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
569 569
 		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -573,119 +573,119 @@  discard block
 block discarded – undo
573 573
 		//if (time()-$this->all_flights[$id]['lastupdate'] > 30 && $dataFound == true && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
574 574
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
575 575
 		if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
576
-		    $this->all_flights[$id]['lastupdate'] = time();
577
-		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
578
-		        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'])) {
579
-			    //print_r($this->all_flights);
580
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
581
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
582
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
576
+			$this->all_flights[$id]['lastupdate'] = time();
577
+			if ($this->all_flights[$id]['addedSpotter'] == 0) {
578
+				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'])) {
579
+				//print_r($this->all_flights);
580
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
581
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
582
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
583 583
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
584 584
 				$timeelapsed = microtime(true);
585 585
 				$SpotterLive = new SpotterLive($this->db);
586 586
 				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')) {
587
-				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
588
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
587
+					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
588
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
589 589
 				} elseif (isset($line['id'])) {
590
-				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
591
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
590
+					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
591
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
592 592
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
593
-				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
594
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
593
+					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
594
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
595 595
 				} else $recent_ident = '';
596 596
 				$SpotterLive->db=null;
597 597
 
598 598
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
599 599
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
600
-			    } else {
600
+				} else {
601 601
 				$recent_ident = '';
602 602
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
603
-			    }
604
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
605
-			    if($recent_ident == "")
606
-			    {
603
+				}
604
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
605
+				if($recent_ident == "")
606
+				{
607 607
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
608 608
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
609 609
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
610 610
 				//adds the spotter data for the archive
611 611
 				$ignoreImport = false;
612 612
 				foreach($globalAirportIgnore as $airportIgnore) {
613
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
613
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
614 614
 					$ignoreImport = true;
615
-				    }
615
+					}
616 616
 				}
617 617
 				if (count($globalAirportAccept) > 0) {
618
-				    $ignoreImport = true;
619
-				    foreach($globalAirportIgnore as $airportIgnore) {
618
+					$ignoreImport = true;
619
+					foreach($globalAirportIgnore as $airportIgnore) {
620 620
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
621
-					    $ignoreImport = false;
621
+						$ignoreImport = false;
622
+					}
622 623
 					}
623
-				    }
624 624
 				}
625 625
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
626
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
626
+					foreach($globalAirlineIgnore as $airlineIgnore) {
627 627
 					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)) {
628
-					    $ignoreImport = true;
628
+						$ignoreImport = true;
629
+					}
629 630
 					}
630
-				    }
631 631
 				}
632 632
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
633
-				    $ignoreImport = true;
634
-				    foreach($globalAirlineAccept as $airlineAccept) {
633
+					$ignoreImport = true;
634
+					foreach($globalAirlineAccept as $airlineAccept) {
635 635
 					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)) {
636
-					    $ignoreImport = false;
636
+						$ignoreImport = false;
637
+					}
637 638
 					}
638
-				    }
639 639
 				}
640 640
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
641
-				    $ignoreImport = true;
642
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
641
+					$ignoreImport = true;
642
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
643 643
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
644
-					    $ignoreImport = false;
644
+						$ignoreImport = false;
645
+					}
645 646
 					}
646
-				    }
647 647
 				}
648 648
 				
649 649
 				if (!$ignoreImport) {
650
-				    $highlight = '';
651
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
652
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
653
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
654
-				    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')));
655
-				    $timeelapsed = microtime(true);
656
-				    $Spotter = new Spotter($this->db);
657
-				    $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']);
658
-				    $Spotter->db = null;
659
-				    if ($globalDebug && isset($result)) echo $result."\n";
660
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
650
+					$highlight = '';
651
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
652
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
653
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
654
+					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')));
655
+					$timeelapsed = microtime(true);
656
+					$Spotter = new Spotter($this->db);
657
+					$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']);
658
+					$Spotter->db = null;
659
+					if ($globalDebug && isset($result)) echo $result."\n";
660
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
661 661
 				    
662
-				    // Add source stat in DB
663
-				    $Stats = new Stats($this->db);
664
-				    if (!empty($this->stats)) {
662
+					// Add source stat in DB
663
+					$Stats = new Stats($this->db);
664
+					if (!empty($this->stats)) {
665 665
 					if ($globalDebug) echo 'Add source stats : ';
666
-				        foreach($this->stats as $date => $data) {
667
-					    foreach($data as $source => $sourced) {
668
-					        //print_r($sourced);
669
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
670
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
671
-				    		if (isset($sourced['msg'])) {
672
-				    		    if (time() - $sourced['msg']['date'] > 10) {
673
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
674
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
675
-			    			        unset($this->stats[$date][$source]['msg']);
676
-			    			    }
677
-			    			}
678
-			    		    }
679
-			    		    if ($date != date('Y-m-d')) {
680
-			    			unset($this->stats[$date]);
681
-			    		    }
682
-				    	}
683
-				    	if ($globalDebug) echo 'Done'."\n";
684
-
685
-				    }
686
-				    $Stats->db = null;
666
+						foreach($this->stats as $date => $data) {
667
+						foreach($data as $source => $sourced) {
668
+							//print_r($sourced);
669
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
670
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
671
+							if (isset($sourced['msg'])) {
672
+								if (time() - $sourced['msg']['date'] > 10) {
673
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
674
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
675
+									unset($this->stats[$date][$source]['msg']);
676
+								}
677
+							}
678
+							}
679
+							if ($date != date('Y-m-d')) {
680
+							unset($this->stats[$date]);
681
+							}
682
+						}
683
+						if ($globalDebug) echo 'Done'."\n";
684
+
685
+					}
686
+					$Stats->db = null;
687 687
 				    
688
-				    $this->del();
688
+					$this->del();
689 689
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
690 690
 				//$ignoreImport = false;
691 691
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -703,18 +703,18 @@  discard block
 block discarded – undo
703 703
 			*/
704 704
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
705 705
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
706
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
707
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
708
-				    $SpotterLive = new SpotterLive($this->db);
709
-				    $SpotterLive->deleteLiveSpotterData();
710
-				    $SpotterLive->db=null;
711
-				    if ($globalDebug) echo " Done\n";
712
-				    $this->last_delete = time();
706
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
707
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
708
+					$SpotterLive = new SpotterLive($this->db);
709
+					$SpotterLive->deleteLiveSpotterData();
710
+					$SpotterLive->db=null;
711
+					if ($globalDebug) echo " Done\n";
712
+					$this->last_delete = time();
713 713
 				}
714
-			    } else {
714
+				} else {
715 715
 				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')) {
716
-				    $this->all_flights[$id]['id'] = $recent_ident;
717
-				    $this->all_flights[$id]['addedSpotter'] = 1;
716
+					$this->all_flights[$id]['id'] = $recent_ident;
717
+					$this->all_flights[$id]['addedSpotter'] = 1;
718 718
 				}
719 719
 				if (isset($globalDaemon) && !$globalDaemon) {
720 720
 					$Spotter = new Spotter($this->db);
@@ -722,14 +722,14 @@  discard block
 block discarded – undo
722 722
 					$Spotter->db = null;
723 723
 				}
724 724
 				
725
-			    }
725
+				}
726
+			}
726 727
 			}
727
-		    }
728
-		    //adds the spotter LIVE data
729
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
730
-		    //echo "\nAdd in Live !! \n";
731
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
732
-		    if ($globalDebug) {
728
+			//adds the spotter LIVE data
729
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
730
+			//echo "\nAdd in Live !! \n";
731
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
732
+			if ($globalDebug) {
733 733
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
734 734
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
735 735
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -737,49 +737,49 @@  discard block
 block discarded – undo
737 737
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
738 738
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
739 739
 			}
740
-		    }
741
-		    $ignoreImport = false;
742
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
743
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
740
+			}
741
+			$ignoreImport = false;
742
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
743
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
744 744
 
745
-		    foreach($globalAirportIgnore as $airportIgnore) {
746
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
747
-			    $ignoreImport = true;
745
+			foreach($globalAirportIgnore as $airportIgnore) {
746
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
747
+				$ignoreImport = true;
748
+			}
748 749
 			}
749
-		    }
750
-		    if (count($globalAirportAccept) > 0) {
751
-		        $ignoreImport = true;
752
-		        foreach($globalAirportIgnore as $airportIgnore) {
753
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
750
+			if (count($globalAirportAccept) > 0) {
751
+				$ignoreImport = true;
752
+				foreach($globalAirportIgnore as $airportIgnore) {
753
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
754 754
 				$ignoreImport = false;
755
-			    }
755
+				}
756 756
 			}
757
-		    }
758
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
757
+			}
758
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
759 759
 			foreach($globalAirlineIgnore as $airlineIgnore) {
760
-			    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)) {
760
+				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)) {
761 761
 				$ignoreImport = true;
762
-			    }
762
+				}
763 763
 			}
764
-		    }
765
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
764
+			}
765
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
766 766
 			$ignoreImport = true;
767 767
 			foreach($globalAirlineAccept as $airlineAccept) {
768
-			    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)) {
768
+				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)) {
769 769
 				$ignoreImport = false;
770
-			    }
770
+				}
771 771
 			}
772
-		    }
773
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
772
+			}
773
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
774 774
 			$ignoreImport = true;
775 775
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
776
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
777
-			        $ignoreImport = false;
778
-			    }
776
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
777
+					$ignoreImport = false;
778
+				}
779
+			}
779 780
 			}
780
-		    }
781 781
 
782
-		    if (!$ignoreImport) {
782
+			if (!$ignoreImport) {
783 783
 			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'])) {
784 784
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
785 785
 				$timeelapsed = microtime(true);
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 					if ($stats_heading == 16) $stats_heading = 0;
818 818
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
819 819
 						for ($i=0;$i<=15;$i++) {
820
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
820
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
821 821
 						}
822 822
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
823 823
 					} else {
@@ -830,11 +830,11 @@  discard block
 block discarded – undo
830 830
 					//var_dump($this->stats);
831 831
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
832 832
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
833
-						    end($this->stats[$current_date][$source]['hist']);
834
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
833
+							end($this->stats[$current_date][$source]['hist']);
834
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
835 835
 						} else $mini = 0;
836 836
 						for ($i=$mini;$i<=$distance;$i+=10) {
837
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
837
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
838 838
 						}
839 839
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
840 840
 					} else {
@@ -851,22 +851,22 @@  discard block
 block discarded – undo
851 851
 			
852 852
 			
853 853
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
854
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
855
-			    $SpotterLive = new SpotterLive($this->db);
856
-			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
857
-			    $SpotterLive->db = null;
858
-			    //SpotterLive->deleteLiveSpotterData();
859
-			    if ($globalDebug) echo " Done\n";
860
-			    $this->last_delete_hourly = time();
854
+				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
855
+				$SpotterLive = new SpotterLive($this->db);
856
+				$SpotterLive->deleteLiveSpotterDataNotUpdated();
857
+				$SpotterLive->db = null;
858
+				//SpotterLive->deleteLiveSpotterData();
859
+				if ($globalDebug) echo " Done\n";
860
+				$this->last_delete_hourly = time();
861 861
 			}
862 862
 			
863
-		    }
864
-		    //$ignoreImport = false;
863
+			}
864
+			//$ignoreImport = false;
865 865
 		}
866 866
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
867 867
 		if ($send) return $this->all_flights[$id];
868
-	    }
868
+		}
869
+	}
869 870
 	}
870
-    }
871 871
 }
872 872
 ?>
Please login to merge, or discard this patch.
Spacing   +127 added lines, -127 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
 	
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 		$schedule = $Schedule->fetchSchedule($operator);
65 65
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
66 66
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
67
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
68
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
67
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
68
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
69 69
 		    // Should also check if route schedule = route from DB
70 70
 		    if ($schedule['DepartureAirportIATA'] != '') {
71 71
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 			    }
86 86
 			}
87 87
 		    }
88
-		    $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']);
88
+		    $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 89
 		}
90 90
 	    }
91 91
 	}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
116 116
     		$Spotter = new Spotter($this->db);
117 117
         	$real_arrival = $this->arrival($key);
118
-        	$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']);
118
+        	$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']);
119 119
             }
120 120
 	}
121 121
     }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         $airport_time = '';
129 129
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
130 130
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
131
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
131
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
132 132
     	    if (isset($closestAirports[0])) {
133 133
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
134 134
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         		    break;
144 144
         		}
145 145
         	    }
146
-        	} 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))) {
146
+        	} 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))) {
147 147
         		$airport_icao = $closestAirports[0]['icao'];
148 148
         		$airport_time = $this->all_flights[$key]['datetime'];
149 149
         	} else {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         } else {
157 157
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
158 158
         }
159
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
159
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
160 160
     }
161 161
 
162 162
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
168 168
 	foreach ($this->all_flights as $key => $flight) {
169 169
     	    if (isset($flight['lastupdate'])) {
170
-        	if ($flight['lastupdate'] < (time()-3000)) {
170
+        	if ($flight['lastupdate'] < (time() - 3000)) {
171 171
             	    if (isset($this->all_flights[$key]['id'])) {
172 172
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
173 173
 			/*
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             		$real_arrival = $this->arrival($key);
179 179
             		$Spotter = new Spotter($this->db);
180 180
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
181
-				$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']);
181
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
182 182
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
183 183
 			}
184 184
 			// Put in archive
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	$send = false;
215 215
 	
216 216
 	// SBS format is CSV format
217
-	if(is_array($line) && isset($line['hex'])) {
217
+	if (is_array($line) && isset($line['hex'])) {
218 218
 	    //print_r($line);
219 219
   	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
220 220
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 		//print_r($this->all_flights);
249 249
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
250 250
 		    $this->all_flights[$id] = array('hex' => $hex);
251
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
251
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
252 252
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
253 253
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
254 254
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			$Spotter = new Spotter($this->db);
259 259
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
260 260
 			$Spotter->db = null;
261
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
261
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
262 262
 
263 263
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
264 264
 			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
@@ -266,31 +266,31 @@  discard block
 block discarded – undo
266 266
 			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
267 267
 			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
268 268
 			}
269
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
269
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
270 270
 		    } else if (isset($line['aircraft_name'])) {
271 271
 			// Get aircraft ICAO from aircraft name
272 272
 			$Spotter = new Spotter($this->db);
273 273
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
274 274
 			$Spotter->db = null;
275
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
276
-			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
277
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
278
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
279
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
275
+			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
276
+			else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
277
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
278
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true));
279
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
280 280
 		    if (!isset($line['id'])) {
281 281
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
282 282
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
283 283
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
284
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
284
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
285 285
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
286
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
286
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
287 287
 
288 288
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
289 289
 		}
290 290
 		
291
-		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
291
+		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/', $line['datetime'])) {
292 292
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
293
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
293
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
294 294
 		    } else {
295 295
 				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";
296 296
 				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";
@@ -301,23 +301,23 @@  discard block
 block discarded – undo
301 301
 				*/
302 302
 				return '';
303 303
 		    }
304
-		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
304
+		} else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
305 305
 
306 306
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
307
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
307
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
308 308
 		}
309 309
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
310
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
310
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
311 311
 		}
312 312
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
313
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
313
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
314 314
 		}
315 315
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
316
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
316
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
317 317
 		}
318 318
  
319 319
 		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'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
320
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
321 321
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
322 322
 			$timeelapsed = microtime(true);
323 323
             		$Spotter = new Spotter($this->db);
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
328 328
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
329 329
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
330
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
330
+            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
331 331
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
332 332
 			$Spotter->db = null;
333
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
333
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
334 334
 		    }
335 335
 
336 336
 /*
@@ -341,24 +341,24 @@  discard block
 block discarded – undo
341 341
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
342 342
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
343 343
   */
344
-		    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']));
344
+		    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']));
345 345
 
346 346
 		    //$putinarchive = true;
347 347
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
348
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
348
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
349 349
 		    }
350 350
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
351
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
351
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
352 352
 		    }
353 353
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
354
-		    		$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' => ''));
354
+		    		$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' => ''));
355 355
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
356 356
 				$timeelapsed = microtime(true);
357 357
 				$Spotter = new Spotter($this->db);
358 358
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
359 359
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
360
-		    		$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' => ''));
361
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+		    		$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' => ''));
361
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
362 362
 
363 363
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
364 364
 			$timeelapsed = microtime(true);
@@ -371,34 +371,34 @@  discard block
 block discarded – undo
371 371
 				$Translation->db = null;
372 372
 			}
373 373
 			$Spotter->db = null;
374
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
374
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
375 375
 
376 376
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
377 377
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
378 378
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
379 379
 				//    $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']));
380
-		    		$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']));
380
+		    		$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']));
381 381
 		    	    }
382 382
 			}
383 383
 			if (!isset($globalFork)) $globalFork = TRUE;
384 384
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
385
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
385
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
386 386
 			}
387 387
 		    }
388 388
 		}
389 389
 
390 390
 		if (isset($line['speed']) && $line['speed'] != '') {
391 391
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
392
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
393
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
392
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
393
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
394 394
 		    //$dataFound = true;
395 395
 		} 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'])) {
396
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
396
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
397 397
 		    if ($distance > 1000 && $distance < 10000) {
398 398
 		    // use datetime
399 399
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
400 400
 			$speed = $speed*3.6;
401
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
401
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
402 402
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
403 403
 		    }
404 404
 		}
@@ -406,11 +406,11 @@  discard block
 block discarded – undo
406 406
 
407 407
 
408 408
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
409
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
409
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
410 410
 	    	    else unset($timediff);
411
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
411
+	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) {
412 412
 			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'])) {
413
-			    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'])) {
413
+			    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'])) {
414 414
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
415 415
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
416 416
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -419,10 +419,10 @@  discard block
 block discarded – undo
419 419
 				if ($globalDebug) echo "\n".' ------- Check Country.... ';
420 420
 				$timeelapsed = microtime(true);
421 421
 				$Spotter = new Spotter($this->db);
422
-				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
422
+				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
423 423
 				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
424 424
 				$Spotter->db = null;
425
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
425
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
426 426
 				$this->tmd = 0;
427 427
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
428 428
 			    }
@@ -431,13 +431,13 @@  discard block
 block discarded – undo
431 431
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
432 432
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
433 433
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
434
-				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') {
434
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
435 435
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
436 436
 				    $dataFound = true;
437 437
 				    $this->all_flights[$id]['time_last_coord'] = time();
438 438
 				}
439 439
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
440
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
440
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
441 441
 				/*
442 442
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
443 443
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -455,13 +455,13 @@  discard block
 block discarded – undo
455 455
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
456 456
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
457 457
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
458
-				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') {
458
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
459 459
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
460 460
 				    $dataFound = true;
461 461
 				    $this->all_flights[$id]['time_last_coord'] = time();
462 462
 				}
463 463
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
464
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
464
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
465 465
 				/*
466 466
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
467 467
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -479,45 +479,45 @@  discard block
 block discarded – undo
479 479
 		    } else if ($globalDebug && $timediff > 20) {
480 480
 			$this->tmd = $this->tmd + 1;
481 481
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
482
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
483
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
482
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
483
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
484 484
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
485 485
 		    }
486 486
 		}
487 487
 		if (isset($line['last_update']) && $line['last_update'] != '') {
488 488
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
489
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
489
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
490 490
 		}
491 491
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
492
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
492
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
493 493
 		    //$dataFound = true;
494 494
 		}
495 495
 		if (isset($line['format_source']) && $line['format_source'] != '') {
496
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
496
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
497 497
 		}
498 498
 		if (isset($line['source_name']) && $line['source_name'] != '') {
499
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
499
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
500 500
 		}
501 501
 		if (isset($line['emergency']) && $line['emergency'] != '') {
502
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
502
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
503 503
 		    //$dataFound = true;
504 504
 		}
505 505
 		if (isset($line['ground']) && $line['ground'] != '') {
506 506
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
507 507
 			// Here we force archive of flight because after ground it's a new one (or should be)
508
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
509
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
510
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
511
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
512
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
508
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
509
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
510
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
511
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
512
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
513 513
 		    }
514 514
 		    if ($line['ground'] != 1) $line['ground'] = 0;
515
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
515
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
516 516
 		    //$dataFound = true;
517 517
 		}
518 518
 		if (isset($line['squawk']) && $line['squawk'] != '') {
519 519
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
520
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
520
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
521 521
 			    $highlight = '';
522 522
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
523 523
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -525,48 +525,48 @@  discard block
 block discarded – undo
525 525
 			    if ($highlight != '') {
526 526
 				$timeelapsed = microtime(true);
527 527
 				$Spotter = new Spotter($this->db);
528
-				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
528
+				$Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
529 529
 				$Spotter->db = null;
530
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
530
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
531 531
 
532 532
 				$this->all_flights[$id]['putinarchive'] = true;
533 533
 				//$putinarchive = true;
534 534
 				//$highlight = '';
535 535
 			    }
536 536
 			    
537
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
537
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
538 538
 		    //$dataFound = true;
539 539
 		}
540 540
 
541 541
 		if (isset($line['altitude']) && $line['altitude'] != '') {
542 542
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
543
-			if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
544
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
545
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
543
+			if (abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
544
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
545
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
546 546
 			//$dataFound = true;
547 547
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
548 548
   		}
549 549
 
550 550
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
551
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
551
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
552 552
 		}
553 553
 		
554 554
 		if (isset($line['heading']) && $line['heading'] != '') {
555
-		    if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
556
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
557
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
555
+		    if (abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
556
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
557
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
558 558
 		    //$dataFound = true;
559 559
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
560
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
561
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
562
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
560
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
561
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
562
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
563 563
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
564 564
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
565 565
   		    // If not enough messages and ACARS set heading to 0
566
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
566
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
567 567
   		}
568
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
569
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
568
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
569
+		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
570 570
 
571 571
 //		print_r($this->all_flights[$id]);
572 572
 		//gets the callsign from the last hour
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 		if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
576 576
 		    $this->all_flights[$id]['lastupdate'] = time();
577 577
 		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
578
-		        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'])) {
578
+		        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'])) {
579 579
 			    //print_r($this->all_flights);
580 580
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
581 581
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -585,61 +585,61 @@  discard block
 block discarded – undo
585 585
 				$SpotterLive = new SpotterLive($this->db);
586 586
 				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')) {
587 587
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
588
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
588
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
589 589
 				} elseif (isset($line['id'])) {
590 590
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
591
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
591
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
592 592
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
593 593
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
594
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
594
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
595 595
 				} else $recent_ident = '';
596
-				$SpotterLive->db=null;
596
+				$SpotterLive->db = null;
597 597
 
598 598
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
599 599
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
600 600
 			    } else {
601 601
 				$recent_ident = '';
602
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
602
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
603 603
 			    }
604 604
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
605
-			    if($recent_ident == "")
605
+			    if ($recent_ident == "")
606 606
 			    {
607 607
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
608 608
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
609 609
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
610 610
 				//adds the spotter data for the archive
611 611
 				$ignoreImport = false;
612
-				foreach($globalAirportIgnore as $airportIgnore) {
612
+				foreach ($globalAirportIgnore as $airportIgnore) {
613 613
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
614 614
 					$ignoreImport = true;
615 615
 				    }
616 616
 				}
617 617
 				if (count($globalAirportAccept) > 0) {
618 618
 				    $ignoreImport = true;
619
-				    foreach($globalAirportIgnore as $airportIgnore) {
619
+				    foreach ($globalAirportIgnore as $airportIgnore) {
620 620
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
621 621
 					    $ignoreImport = false;
622 622
 					}
623 623
 				    }
624 624
 				}
625 625
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
626
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
627
-					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)) {
626
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
627
+					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)) {
628 628
 					    $ignoreImport = true;
629 629
 					}
630 630
 				    }
631 631
 				}
632 632
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
633 633
 				    $ignoreImport = true;
634
-				    foreach($globalAirlineAccept as $airlineAccept) {
635
-					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)) {
634
+				    foreach ($globalAirlineAccept as $airlineAccept) {
635
+					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)) {
636 636
 					    $ignoreImport = false;
637 637
 					}
638 638
 				    }
639 639
 				}
640 640
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
641 641
 				    $ignoreImport = true;
642
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
642
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
643 643
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
644 644
 					    $ignoreImport = false;
645 645
 					}
@@ -651,27 +651,27 @@  discard block
 block discarded – undo
651 651
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
652 652
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
653 653
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
654
-				    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')));
654
+				    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')));
655 655
 				    $timeelapsed = microtime(true);
656 656
 				    $Spotter = new Spotter($this->db);
657
-				    $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']);
657
+				    $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']);
658 658
 				    $Spotter->db = null;
659 659
 				    if ($globalDebug && isset($result)) echo $result."\n";
660
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
660
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
661 661
 				    
662 662
 				    // Add source stat in DB
663 663
 				    $Stats = new Stats($this->db);
664 664
 				    if (!empty($this->stats)) {
665 665
 					if ($globalDebug) echo 'Add source stats : ';
666
-				        foreach($this->stats as $date => $data) {
667
-					    foreach($data as $source => $sourced) {
666
+				        foreach ($this->stats as $date => $data) {
667
+					    foreach ($data as $source => $sourced) {
668 668
 					        //print_r($sourced);
669
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
670
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
669
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
670
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
671 671
 				    		if (isset($sourced['msg'])) {
672 672
 				    		    if (time() - $sourced['msg']['date'] > 10) {
673 673
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
674
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
674
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
675 675
 			    			        unset($this->stats[$date][$source]['msg']);
676 676
 			    			    }
677 677
 			    			}
@@ -707,18 +707,18 @@  discard block
 block discarded – undo
707 707
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
708 708
 				    $SpotterLive = new SpotterLive($this->db);
709 709
 				    $SpotterLive->deleteLiveSpotterData();
710
-				    $SpotterLive->db=null;
710
+				    $SpotterLive->db = null;
711 711
 				    if ($globalDebug) echo " Done\n";
712 712
 				    $this->last_delete = time();
713 713
 				}
714 714
 			    } else {
715
-				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')) {
715
+				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')) {
716 716
 				    $this->all_flights[$id]['id'] = $recent_ident;
717 717
 				    $this->all_flights[$id]['addedSpotter'] = 1;
718 718
 				}
719 719
 				if (isset($globalDaemon) && !$globalDaemon) {
720 720
 					$Spotter = new Spotter($this->db);
721
-					$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']);
721
+					$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']);
722 722
 					$Spotter->db = null;
723 723
 				}
724 724
 				
@@ -742,37 +742,37 @@  discard block
 block discarded – undo
742 742
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
743 743
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
744 744
 
745
-		    foreach($globalAirportIgnore as $airportIgnore) {
745
+		    foreach ($globalAirportIgnore as $airportIgnore) {
746 746
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
747 747
 			    $ignoreImport = true;
748 748
 			}
749 749
 		    }
750 750
 		    if (count($globalAirportAccept) > 0) {
751 751
 		        $ignoreImport = true;
752
-		        foreach($globalAirportIgnore as $airportIgnore) {
752
+		        foreach ($globalAirportIgnore as $airportIgnore) {
753 753
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
754 754
 				$ignoreImport = false;
755 755
 			    }
756 756
 			}
757 757
 		    }
758 758
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
759
-			foreach($globalAirlineIgnore as $airlineIgnore) {
760
-			    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)) {
759
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
760
+			    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)) {
761 761
 				$ignoreImport = true;
762 762
 			    }
763 763
 			}
764 764
 		    }
765 765
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
766 766
 			$ignoreImport = true;
767
-			foreach($globalAirlineAccept as $airlineAccept) {
768
-			    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)) {
767
+			foreach ($globalAirlineAccept as $airlineAccept) {
768
+			    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)) {
769 769
 				$ignoreImport = false;
770 770
 			    }
771 771
 			}
772 772
 		    }
773 773
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
774 774
 			$ignoreImport = true;
775
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
775
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
776 776
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
777 777
 			        $ignoreImport = false;
778 778
 			    }
@@ -780,13 +780,13 @@  discard block
 block discarded – undo
780 780
 		    }
781 781
 
782 782
 		    if (!$ignoreImport) {
783
-			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'])) {
783
+			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'])) {
784 784
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
785 785
 				$timeelapsed = microtime(true);
786 786
 				$SpotterLive = new SpotterLive($this->db);
787
-				$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']);
787
+				$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']);
788 788
 				$SpotterLive->db = null;
789
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
789
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
790 790
 
791 791
 				// Put statistics in $this->stats variable
792 792
 				//if ($line['format_source'] != 'aprs') {
@@ -804,19 +804,19 @@  discard block
 block discarded – undo
804 804
 							$latitude = $globalCenterLatitude;
805 805
 							$longitude = $globalCenterLongitude;
806 806
 						}
807
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
807
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
808 808
 					} else {
809 809
 						$latitude = $this->source_location[$source]['latitude'];
810 810
 						$longitude = $this->source_location[$source]['longitude'];
811 811
 					}
812
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
812
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
813 813
 					//$stats_heading = $stats_heading%22.5;
814 814
 					$stats_heading = round($stats_heading/22.5);
815
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
815
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
816 816
 					$current_date = date('Y-m-d');
817 817
 					if ($stats_heading == 16) $stats_heading = 0;
818 818
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
819
-						for ($i=0;$i<=15;$i++) {
819
+						for ($i = 0; $i <= 15; $i++) {
820 820
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
821 821
 						}
822 822
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -831,9 +831,9 @@  discard block
 block discarded – undo
831 831
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
832 832
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
833 833
 						    end($this->stats[$current_date][$source]['hist']);
834
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
834
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
835 835
 						} else $mini = 0;
836
-						for ($i=$mini;$i<=$distance;$i+=10) {
836
+						for ($i = $mini; $i <= $distance; $i += 10) {
837 837
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
838 838
 						}
839 839
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
847 847
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
848 848
 				if ($globalDebug) echo $result."\n";
849
-			} 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";
849
+			} 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";
850 850
 			//$this->del();
851 851
 			
852 852
 			
Please login to merge, or discard this patch.
Braces   +315 added lines, -112 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 	$dbc = $this->db;
54 54
 	$this->all_flights[$id]['schedule_check'] = true;
55 55
 	if ($globalSchedulesFetch) {
56
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
56
+	if ($globalDebug) {
57
+		echo 'Getting schedule info...'."\n";
58
+	}
57 59
 	$Spotter = new Spotter($dbc);
58 60
 	$Schedule = new Schedule($dbc);
59 61
 	$Translation = new Translation($dbc);
@@ -63,7 +65,9 @@  discard block
 block discarded – undo
63 65
 	    if ($Schedule->checkSchedule($operator) == 0) {
64 66
 		$schedule = $Schedule->fetchSchedule($operator);
65 67
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
66
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
68
+		    if ($globalDebug) {
69
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
70
+		    }
67 71
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
68 72
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
69 73
 		    // Should also check if route schedule = route from DB
@@ -72,7 +76,9 @@  discard block
 block discarded – undo
72 76
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
73 77
 			    if ($airport_icao != '') {
74 78
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
75
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
79
+				if ($globalDebug) {
80
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
81
+				}
76 82
 			    }
77 83
 			}
78 84
 		    }
@@ -81,7 +87,9 @@  discard block
 block discarded – undo
81 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
82 88
 			    if ($airport_icao != '') {
83 89
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
84
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
92
+				}
85 93
 			    }
86 94
 			}
87 95
 		    }
@@ -109,7 +117,9 @@  discard block
 block discarded – undo
109 117
 
110 118
     public function checkAll() {
111 119
 	global $globalDebug;
112
-	if ($globalDebug) echo "Update last seen flights data...\n";
120
+	if ($globalDebug) {
121
+		echo "Update last seen flights data...\n";
122
+	}
113 123
 	foreach ($this->all_flights as $key => $flight) {
114 124
 	    if (isset($this->all_flights[$key]['id'])) {
115 125
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
@@ -122,24 +132,32 @@  discard block
 block discarded – undo
122 132
 
123 133
     public function arrival($key) {
124 134
 	global $globalClosestMinDist, $globalDebug;
125
-	if ($globalDebug) echo 'Update arrival...'."\n";
135
+	if ($globalDebug) {
136
+		echo 'Update arrival...'."\n";
137
+	}
126 138
 	$Spotter = new Spotter($this->db);
127 139
         $airport_icao = '';
128 140
         $airport_time = '';
129
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
141
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
142
+        	$globalClosestMinDist = 50;
143
+        }
130 144
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
131 145
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
132 146
     	    if (isset($closestAirports[0])) {
133 147
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
134 148
         	    $airport_icao = $closestAirports[0]['icao'];
135 149
         	    $airport_time = $this->all_flights[$key]['datetime'];
136
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
150
+        	    if ($globalDebug) {
151
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
152
+        	    }
137 153
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
138 154
         	    foreach ($closestAirports as $airport) {
139 155
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
140 156
         		    $airport_icao = $airport['icao'];
141 157
         		    $airport_time = $this->all_flights[$key]['datetime'];
142
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
158
+        		    if ($globalDebug) {
159
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
160
+        		    }
143 161
         		    break;
144 162
         		}
145 163
         	    }
@@ -147,14 +165,20 @@  discard block
 block discarded – undo
147 165
         		$airport_icao = $closestAirports[0]['icao'];
148 166
         		$airport_time = $this->all_flights[$key]['datetime'];
149 167
         	} else {
150
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
168
+        		if ($globalDebug) {
169
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
170
+        		}
151 171
         	}
152 172
     	    } else {
153
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
173
+    		    if ($globalDebug) {
174
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
175
+    		    }
154 176
     	    }
155 177
 
156 178
         } else {
157
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
179
+        	if ($globalDebug) {
180
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
181
+        	}
158 182
         }
159 183
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
160 184
     }
@@ -164,12 +188,16 @@  discard block
 block discarded – undo
164 188
     public function del() {
165 189
 	global $globalDebug;
166 190
 	// Delete old infos
167
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
191
+	if ($globalDebug) {
192
+		echo 'Delete old values and update latest data...'."\n";
193
+	}
168 194
 	foreach ($this->all_flights as $key => $flight) {
169 195
     	    if (isset($flight['lastupdate'])) {
170 196
         	if ($flight['lastupdate'] < (time()-3000)) {
171 197
             	    if (isset($this->all_flights[$key]['id'])) {
172
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
198
+            		if ($globalDebug) {
199
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
200
+            		}
173 201
 			/*
174 202
 			$SpotterLive = new SpotterLive();
175 203
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -179,7 +207,9 @@  discard block
 block discarded – undo
179 207
             		$Spotter = new Spotter($this->db);
180 208
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
181 209
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
182
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
210
+				if ($globalDebug && $result != 'success') {
211
+					echo '!!! ERROR : '.$result."\n";
212
+				}
183 213
 			}
184 214
 			// Put in archive
185 215
 //			$Spotter->db = null;
@@ -193,8 +223,10 @@  discard block
 block discarded – undo
193 223
     public function add($line) {
194 224
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM;
195 225
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
196
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
197
-/*
226
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
227
+		$globalCoordMinChange = '0.02';
228
+	}
229
+	/*
198 230
 	$Spotter = new Spotter();
199 231
 	$dbc = $Spotter->db;
200 232
 	$SpotterLive = new SpotterLive($dbc);
@@ -222,11 +254,15 @@  discard block
 block discarded – undo
222 254
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
223 255
 		    $current_date = date('Y-m-d');
224 256
 		    $source = $line['source_name'];
225
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
257
+		    if ($source == '' || $line['format_source'] == 'aprs') {
258
+		    	$source = $line['format_source'];
259
+		    }
226 260
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
227 261
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
228 262
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
229
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
263
+		    } else {
264
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
265
+		    }
230 266
 		}
231 267
 		
232 268
 		/*
@@ -242,8 +278,11 @@  discard block
 block discarded – undo
242 278
 		//$this->db = $dbc;
243 279
 
244 280
 		$hex = trim($line['hex']);
245
-	        if (!isset($line['id'])) $id = trim($line['hex']);
246
-	        else $id = trim($line['id']);
281
+	        if (!isset($line['id'])) {
282
+	        	$id = trim($line['hex']);
283
+	        } else {
284
+	        	$id = trim($line['id']);
285
+	        }
247 286
 		
248 287
 		//print_r($this->all_flights);
249 288
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
@@ -258,13 +297,20 @@  discard block
 block discarded – undo
258 297
 			$Spotter = new Spotter($this->db);
259 298
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
260 299
 			$Spotter->db = null;
261
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
300
+			if ($globalDebugTimeElapsed) {
301
+				echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
+			}
262 303
 
263 304
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
264
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
265
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
266
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
267
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
305
+			    if ($line['aircraft_type'] == 'PARA_GLIDER') {
306
+			    	$aircraft_icao = 'GLID';
307
+			    } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
308
+			    	$aircraft_icao = 'UHEL';
309
+			    } elseif ($line['aircraft_type'] == 'TOW_PLANE') {
310
+			    	$aircraft_icao = 'TOWPLANE';
311
+			    } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
312
+			    	$aircraft_icao = 'POWAIRC';
313
+			    }
268 314
 			}
269 315
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
270 316
 		    } else if (isset($line['aircraft_name'])) {
@@ -272,28 +318,44 @@  discard block
 block discarded – undo
272 318
 			$Spotter = new Spotter($this->db);
273 319
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
274 320
 			$Spotter->db = null;
275
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
276
-			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
277
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
321
+			if ($aircraft_icao != '') {
322
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
323
+			} else {
324
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
325
+			}
326
+		    } else {
327
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
328
+		    }
278 329
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
279 330
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280 331
 		    if (!isset($line['id'])) {
281
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
282
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
332
+			if (!isset($globalDaemon)) {
333
+				$globalDaemon = TRUE;
334
+			}
335
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
283 336
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
284
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
337
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
338
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
339
+			}
285 340
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
286
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
341
+		     } else {
342
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
343
+		     }
287 344
 
288
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
345
+		    if ($globalDebug) {
346
+		    	echo "*********** New aircraft hex : ".$hex." ***********\n";
347
+		    }
289 348
 		}
290 349
 		
291 350
 		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
292 351
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
293 352
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
294 353
 		    } else {
295
-				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";
296
-				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";
354
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
355
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
356
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
357
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
358
+				}
297 359
 				/*
298 360
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
299 361
 				print_r($this->all_flights[$id]);
@@ -301,7 +363,9 @@  discard block
 block discarded – undo
301 363
 				*/
302 364
 				return '';
303 365
 		    }
304
-		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
366
+		} else {
367
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
368
+		}
305 369
 
306 370
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
307 371
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
@@ -322,15 +386,25 @@  discard block
 block discarded – undo
322 386
 			$timeelapsed = microtime(true);
323 387
             		$Spotter = new Spotter($this->db);
324 388
             		$fromsource = NULL;
325
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
326
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
327
-			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
328
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
329
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
389
+            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
390
+            			$fromsource = $globalAirlinesSource;
391
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
392
+            			$fromsource = 'vatsim';
393
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
394
+				$fromsource = 'ivao';
395
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
396
+				$fromsource = 'vatsim';
397
+			} elseif (isset($globalIVAO) && $globalIVAO) {
398
+				$fromsource = 'ivao';
399
+			}
330 400
             		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
331
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
401
+			if ($globalDebug && $result != 'success') {
402
+				echo '!!! ERROR : '.$result."\n";
403
+			}
332 404
 			$Spotter->db = null;
333
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
405
+			if ($globalDebugTimeElapsed) {
406
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
407
+			}
334 408
 		    }
335 409
 
336 410
 /*
@@ -341,7 +415,9 @@  discard block
 block discarded – undo
341 415
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
342 416
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
343 417
   */
344
-		    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']));
418
+		    if (!isset($this->all_flights[$id]['id'])) {
419
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
420
+		    }
345 421
 
346 422
 		    //$putinarchive = true;
347 423
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -358,7 +434,9 @@  discard block
 block discarded – undo
358 434
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
359 435
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
360 436
 		    		$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' => ''));
361
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
437
+				if ($globalDebugTimeElapsed) {
438
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
439
+				}
362 440
 
363 441
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
364 442
 			$timeelapsed = microtime(true);
@@ -371,7 +449,9 @@  discard block
 block discarded – undo
371 449
 				$Translation->db = null;
372 450
 			}
373 451
 			$Spotter->db = null;
374
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
452
+			if ($globalDebugTimeElapsed) {
453
+				echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
454
+			}
375 455
 
376 456
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
377 457
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -380,9 +460,13 @@  discard block
 block discarded – undo
380 460
 		    		$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']));
381 461
 		    	    }
382 462
 			}
383
-			if (!isset($globalFork)) $globalFork = TRUE;
463
+			if (!isset($globalFork)) {
464
+				$globalFork = TRUE;
465
+			}
384 466
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
385
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
467
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
468
+					$this->get_Schedule($id,trim($line['ident']));
469
+				}
386 470
 			}
387 471
 		    }
388 472
 		}
@@ -398,16 +482,23 @@  discard block
 block discarded – undo
398 482
 		    // use datetime
399 483
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
400 484
 			$speed = $speed*3.6;
401
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
402
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
485
+			if ($speed < 1000) {
486
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
487
+			}
488
+  			if ($globalDebug) {
489
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
490
+  			}
403 491
 		    }
404 492
 		}
405 493
 
406 494
 
407 495
 
408 496
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
409
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
410
-	    	    else unset($timediff);
497
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
498
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
499
+	    	    } else {
500
+	    	    	unset($timediff);
501
+	    	    }
411 502
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
412 503
 			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'])) {
413 504
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -416,21 +507,31 @@  discard block
 block discarded – undo
416 507
 				$this->all_flights[$id]['putinarchive'] = true;
417 508
 			    
418 509
 				
419
-				if ($globalDebug) echo "\n".' ------- Check Country.... ';
510
+				if ($globalDebug) {
511
+					echo "\n".' ------- Check Country.... ';
512
+				}
420 513
 				$timeelapsed = microtime(true);
421 514
 				$Spotter = new Spotter($this->db);
422 515
 				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
423
-				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
516
+				if (!empty($all_country)) {
517
+					$this->all_flights[$id]['over_country'] = $all_country['iso2'];
518
+				}
424 519
 				$Spotter->db = null;
425
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
520
+				if ($globalDebugTimeElapsed) {
521
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
522
+				}
426 523
 				$this->tmd = 0;
427
-				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
524
+				if ($globalDebug) {
525
+					echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
526
+				}
428 527
 			    }
429 528
 			}
430 529
 
431 530
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
432 531
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
433
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
532
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
533
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
534
+				}
434 535
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
435 536
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
436 537
 				    $dataFound = true;
@@ -452,9 +553,13 @@  discard block
 block discarded – undo
452 553
 			    */
453 554
 			}
454 555
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
455
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
556
+			    if ($line['longitude'] > 180) {
557
+			    	$line['longitude'] = $line['longitude'] - 360;
558
+			    }
456 559
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
457
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
560
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
561
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
562
+				}
458 563
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
459 564
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
460 565
 				    $dataFound = true;
@@ -485,7 +590,9 @@  discard block
 block discarded – undo
485 590
 		    }
486 591
 		}
487 592
 		if (isset($line['last_update']) && $line['last_update'] != '') {
488
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
593
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
594
+		    	$dataFound = true;
595
+		    }
489 596
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
490 597
 		}
491 598
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -507,11 +614,17 @@  discard block
 block discarded – undo
507 614
 			// Here we force archive of flight because after ground it's a new one (or should be)
508 615
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
509 616
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
510
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
511
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
512
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
617
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
618
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
619
+			} elseif (isset($line['id'])) {
620
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
621
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
622
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
623
+			}
624
+		    }
625
+		    if ($line['ground'] != 1) {
626
+		    	$line['ground'] = 0;
513 627
 		    }
514
-		    if ($line['ground'] != 1) $line['ground'] = 0;
515 628
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
516 629
 		    //$dataFound = true;
517 630
 		}
@@ -519,28 +632,40 @@  discard block
 block discarded – undo
519 632
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
520 633
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
521 634
 			    $highlight = '';
522
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
523
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
524
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
635
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
636
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
637
+			    }
638
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
639
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
640
+			    }
641
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
642
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
643
+			    }
525 644
 			    if ($highlight != '') {
526 645
 				$timeelapsed = microtime(true);
527 646
 				$Spotter = new Spotter($this->db);
528 647
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
529 648
 				$Spotter->db = null;
530
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
649
+				if ($globalDebugTimeElapsed) {
650
+					echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
651
+				}
531 652
 
532 653
 				$this->all_flights[$id]['putinarchive'] = true;
533 654
 				//$putinarchive = true;
534 655
 				//$highlight = '';
535 656
 			    }
536 657
 			    
537
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
658
+		    } else {
659
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
660
+		    }
538 661
 		    //$dataFound = true;
539 662
 		}
540 663
 
541 664
 		if (isset($line['altitude']) && $line['altitude'] != '') {
542 665
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
543
-			if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
666
+			if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) {
667
+				$this->all_flights[$id]['putinarchive'] = true;
668
+			}
544 669
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
545 670
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
546 671
 			//$dataFound = true;
@@ -552,21 +677,30 @@  discard block
 block discarded – undo
552 677
 		}
553 678
 		
554 679
 		if (isset($line['heading']) && $line['heading'] != '') {
555
-		    if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
680
+		    if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) {
681
+		    	$this->all_flights[$id]['putinarchive'] = true;
682
+		    }
556 683
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
557 684
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
558 685
 		    //$dataFound = true;
559 686
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
560 687
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
561 688
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
562
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
563
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
689
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) {
690
+		    	$this->all_flights[$id]['putinarchive'] = true;
691
+		    }
692
+  		    if ($globalDebug) {
693
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
694
+  		    }
564 695
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
565 696
   		    // If not enough messages and ACARS set heading to 0
566 697
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
567 698
   		}
568
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
569
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
699
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
700
+			$dataFound = false;
701
+		} elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
702
+			$dataFound = false;
703
+		}
570 704
 
571 705
 //		print_r($this->all_flights[$id]);
572 706
 		//gets the callsign from the last hour
@@ -580,23 +714,36 @@  discard block
 block discarded – undo
580 714
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
581 715
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
582 716
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
583
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
717
+				if ($globalDebug) {
718
+					echo "Check if aircraft is already in DB...";
719
+				}
584 720
 				$timeelapsed = microtime(true);
585 721
 				$SpotterLive = new SpotterLive($this->db);
586 722
 				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')) {
587 723
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
588
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
724
+				    if ($globalDebugTimeElapsed) {
725
+				    	echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
726
+				    }
589 727
 				} elseif (isset($line['id'])) {
590 728
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
591
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
729
+				    if ($globalDebugTimeElapsed) {
730
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
731
+				    }
592 732
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
593 733
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
594
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
595
-				} else $recent_ident = '';
734
+				    if ($globalDebugTimeElapsed) {
735
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
736
+				    }
737
+				} else {
738
+					$recent_ident = '';
739
+				}
596 740
 				$SpotterLive->db=null;
597 741
 
598
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
599
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
742
+				if ($globalDebug && $recent_ident == '') {
743
+					echo " Not in DB.\n";
744
+				} elseif ($globalDebug && $recent_ident != '') {
745
+					echo " Already in DB.\n";
746
+				}
600 747
 			    } else {
601 748
 				$recent_ident = '';
602 749
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -604,7 +751,9 @@  discard block
 block discarded – undo
604 751
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
605 752
 			    if($recent_ident == "")
606 753
 			    {
607
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
754
+				if ($globalDebug) {
755
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
756
+				}
608 757
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
609 758
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
610 759
 				//adds the spotter data for the archive
@@ -648,26 +797,44 @@  discard block
 block discarded – undo
648 797
 				
649 798
 				if (!$ignoreImport) {
650 799
 				    $highlight = '';
651
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
652
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
653
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
654
-				    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')));
800
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
801
+				    	$highlight = 'Squawk 7500 : Hijack';
802
+				    }
803
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
804
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
805
+				    }
806
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
807
+				    	$highlight = 'Squawk 7700 : Emergency';
808
+				    }
809
+				    if (!isset($this->all_flights[$id]['id'])) {
810
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
811
+				    }
655 812
 				    $timeelapsed = microtime(true);
656 813
 				    $Spotter = new Spotter($this->db);
657 814
 				    $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']);
658 815
 				    $Spotter->db = null;
659
-				    if ($globalDebug && isset($result)) echo $result."\n";
660
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
816
+				    if ($globalDebug && isset($result)) {
817
+				    	echo $result."\n";
818
+				    }
819
+				    if ($globalDebugTimeElapsed) {
820
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
821
+				    }
661 822
 				    
662 823
 				    // Add source stat in DB
663 824
 				    $Stats = new Stats($this->db);
664 825
 				    if (!empty($this->stats)) {
665
-					if ($globalDebug) echo 'Add source stats : ';
826
+					if ($globalDebug) {
827
+						echo 'Add source stats : ';
828
+					}
666 829
 				        foreach($this->stats as $date => $data) {
667 830
 					    foreach($data as $source => $sourced) {
668 831
 					        //print_r($sourced);
669
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
670
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
832
+				    	        if (isset($sourced['polar'])) {
833
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
834
+				    	        }
835
+				    	        if (isset($sourced['hist'])) {
836
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
837
+				    	        }
671 838
 				    		if (isset($sourced['msg'])) {
672 839
 				    		    if (time() - $sourced['msg']['date'] > 10) {
673 840
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -680,13 +847,17 @@  discard block
 block discarded – undo
680 847
 			    			unset($this->stats[$date]);
681 848
 			    		    }
682 849
 				    	}
683
-				    	if ($globalDebug) echo 'Done'."\n";
850
+				    	if ($globalDebug) {
851
+				    		echo 'Done'."\n";
852
+				    	}
684 853
 
685 854
 				    }
686 855
 				    $Stats->db = null;
687 856
 				    
688 857
 				    $this->del();
689
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
858
+				} elseif ($globalDebug) {
859
+					echo 'Ignore data'."\n";
860
+				}
690 861
 				//$ignoreImport = false;
691 862
 				$this->all_flights[$id]['addedSpotter'] = 1;
692 863
 				//print_r($this->all_flights[$id]);
@@ -703,12 +874,16 @@  discard block
 block discarded – undo
703 874
 			*/
704 875
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
705 876
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
706
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
877
+				    if ($globalDebug) {
878
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
879
+				    }
707 880
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
708 881
 				    $SpotterLive = new SpotterLive($this->db);
709 882
 				    $SpotterLive->deleteLiveSpotterData();
710 883
 				    $SpotterLive->db=null;
711
-				    if ($globalDebug) echo " Done\n";
884
+				    if ($globalDebug) {
885
+				    	echo " Done\n";
886
+				    }
712 887
 				    $this->last_delete = time();
713 888
 				}
714 889
 			    } else {
@@ -731,11 +906,17 @@  discard block
 block discarded – undo
731 906
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
732 907
 		    if ($globalDebug) {
733 908
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
734
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
735
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
909
+				if (isset($this->all_flights[$id]['source_name'])) {
910
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
911
+				} else {
912
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
913
+				}
736 914
 			} else {
737
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
738
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
915
+				if (isset($this->all_flights[$id]['source_name'])) {
916
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
917
+				} else {
918
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
919
+				}
739 920
 			}
740 921
 		    }
741 922
 		    $ignoreImport = false;
@@ -781,19 +962,25 @@  discard block
 block discarded – undo
781 962
 
782 963
 		    if (!$ignoreImport) {
783 964
 			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'])) {
784
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
965
+				if ($globalDebug) {
966
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
967
+				}
785 968
 				$timeelapsed = microtime(true);
786 969
 				$SpotterLive = new SpotterLive($this->db);
787 970
 				$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']);
788 971
 				$SpotterLive->db = null;
789
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
972
+				if ($globalDebugTimeElapsed) {
973
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
974
+				}
790 975
 
791 976
 				// Put statistics in $this->stats variable
792 977
 				//if ($line['format_source'] != 'aprs') {
793 978
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
794 979
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs') {
795 980
 					$source = $this->all_flights[$id]['source_name'];
796
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
981
+					if ($source == '') {
982
+						$source = $this->all_flights[$id]['format_source'];
983
+					}
797 984
 					if (!isset($this->source_location[$source])) {
798 985
 						$Location = new Source();
799 986
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -814,7 +1001,9 @@  discard block
 block discarded – undo
814 1001
 					$stats_heading = round($stats_heading/22.5);
815 1002
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
816 1003
 					$current_date = date('Y-m-d');
817
-					if ($stats_heading == 16) $stats_heading = 0;
1004
+					if ($stats_heading == 16) {
1005
+						$stats_heading = 0;
1006
+					}
818 1007
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
819 1008
 						for ($i=0;$i<=15;$i++) {
820 1009
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -832,7 +1021,9 @@  discard block
 block discarded – undo
832 1021
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
833 1022
 						    end($this->stats[$current_date][$source]['hist']);
834 1023
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
835
-						} else $mini = 0;
1024
+						} else {
1025
+							$mini = 0;
1026
+						}
836 1027
 						for ($i=$mini;$i<=$distance;$i+=10) {
837 1028
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
838 1029
 						}
@@ -843,20 +1034,30 @@  discard block
 block discarded – undo
843 1034
 				}
844 1035
 
845 1036
 				$this->all_flights[$id]['lastupdate'] = time();
846
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1037
+				if ($this->all_flights[$id]['putinarchive']) {
1038
+					$send = true;
1039
+				}
847 1040
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
848
-				if ($globalDebug) echo $result."\n";
849
-			} 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";
1041
+				if ($globalDebug) {
1042
+					echo $result."\n";
1043
+				}
1044
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1045
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1046
+			}
850 1047
 			//$this->del();
851 1048
 			
852 1049
 			
853 1050
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
854
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1051
+			    if ($globalDebug) {
1052
+			    	echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1053
+			    }
855 1054
 			    $SpotterLive = new SpotterLive($this->db);
856 1055
 			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
857 1056
 			    $SpotterLive->db = null;
858 1057
 			    //SpotterLive->deleteLiveSpotterData();
859
-			    if ($globalDebug) echo " Done\n";
1058
+			    if ($globalDebug) {
1059
+			    	echo " Done\n";
1060
+			    }
860 1061
 			    $this->last_delete_hourly = time();
861 1062
 			}
862 1063
 			
@@ -864,7 +1065,9 @@  discard block
 block discarded – undo
864 1065
 		    //$ignoreImport = false;
865 1066
 		}
866 1067
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
867
-		if ($send) return $this->all_flights[$id];
1068
+		if ($send) {
1069
+			return $this->all_flights[$id];
1070
+		}
868 1071
 	    }
869 1072
 	}
870 1073
     }
Please login to merge, or discard this patch.
live-geojson.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -25,22 +25,22 @@  discard block
 block discarded – undo
25 25
 $min = false;
26 26
 $allhistory = false;
27 27
 $filter['source'] = array();
28
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
29
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
30
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
31
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
32
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
33
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
34
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
35
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
36
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
28
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
29
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
30
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
31
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs'));
32
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
33
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
34
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
35
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
36
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
37 37
 
38 38
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
39 39
 	$min = true;
40 40
 }
41 41
 
42 42
 if (isset($_GET['ident'])) {
43
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
43
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
44 44
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
45 45
 	if (empty($spotter_array)) {
46 46
 		$from_archive = true;
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	}
49 49
 	$allhistory = true;
50 50
 } elseif (isset($_GET['flightaware_id'])) {
51
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
51
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
52 52
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
53 53
 	if (empty($spotter_array)) {
54 54
 		$from_archive = true;
@@ -57,37 +57,37 @@  discard block
 block discarded – undo
57 57
 	$allhistory = true;
58 58
 } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) {
59 59
 //if (isset($_GET['coord'])) {
60
-	$coord = explode(',',$_GET['coord']);
61
-	$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter);
60
+	$coord = explode(',', $_GET['coord']);
61
+	$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter);
62 62
 
63 63
 #} elseif (isset($globalMapPopup) && !$globalMapPopup) {
64 64
 } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed'])) {
65 65
 	$from_archive = true;
66 66
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
67 67
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
68
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
69
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
70
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
71
-	$begindate = date('Y-m-d H:i:s',$begindate);
72
-	$enddate = date('Y-m-d H:i:s',$enddate);
73
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
68
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
69
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
70
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
71
+	$begindate = date('Y-m-d H:i:s', $begindate);
72
+	$enddate = date('Y-m-d H:i:s', $enddate);
73
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
74 74
 } elseif ($min) {
75 75
 	$spotter_array = $SpotterLive->getMinLiveSpotterData($filter);
76 76
 #	$min = true;
77 77
 } else {
78
-	$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
78
+	$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
79 79
 }
80 80
 
81 81
 if (!empty($spotter_array)) {
82 82
 	if (isset($_GET['archive'])) {
83
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
83
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
84 84
 	} else {
85 85
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
86 86
 	}
87 87
 	if ($flightcnt == '') $flightcnt = 0;
88 88
 } else $flightcnt = 0;
89 89
 
90
-$sqltime = round(microtime(true)-$begintime,2);
90
+$sqltime = round(microtime(true) - $begintime, 2);
91 91
 
92 92
 $j = 0;
93 93
 $prev_flightaware_id = '';
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		if (!empty($spotter_array) && is_array($spotter_array))
103 103
 		{
104 104
 			$output .= '"features": [';
105
-			foreach($spotter_array as $spotter_item)
105
+			foreach ($spotter_array as $spotter_item)
106 106
 			{
107 107
 				$j++;
108 108
 				date_default_timezone_set('UTC');
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
154 154
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
155 155
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
156
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
156
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
157 157
 						} elseif (isset($spotter_item['aircraft_type'])) {
158 158
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
159 159
 						} elseif (!$min) {
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
222 222
 						else $output .= '"heading": "'.$spotter_item['heading'].'",';
223 223
 						
224
-						if (isset($archivespeed)) $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
225
-						else $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
224
+						if (isset($archivespeed)) $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed);
225
+						else $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']);
226 226
 						//$output .= '"nextlatitude": "'.$nextcoord['latitude'].'",';
227 227
 						//$output .= '"nextlongitude": "'.$nextcoord['longitude'].'",';
228 228
 						$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
 						if (!$min) $output .= '"image": "'.$image.'",';
232 232
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
233
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
233
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
234 234
 						}
235 235
 						if (isset($spotter_item['image_source_website'])) {
236 236
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
253 253
 						}
254 254
 						if (isset($spotter_item['acars'])) {
255
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
255
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
256 256
 						}
257 257
 						// type when not aircraft ?
258 258
 						if ($compress) $output .= '"t": "aircraft"';
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 */
325 325
 				//if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) || (isset($_GET['history']) && $_GET['history'] != '' && $_GET['history'] != 'NA' && ($_GET['history'] == $spotter_item['ident'] || $_GET['history'] == $spotter_item['flightaware_id'])))) {
326 326
 				//if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) || (isset($_GET['history']) && $_GET['history'] != '' && $_GET['history'] != 'NA' && ($_GET['history'] == $spotter_item['ident'] || $_GET['history'] == $spotter_item['flightaware_id']))) || (isset($_GET['history']) && $_GET['history'] == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) {
327
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
327
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
328 328
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
329 329
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) 
330 330
 				|| (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) 
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
 					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
355 355
 					}
356 356
 					$output_history .= '[';
357
-					$output_history .=  $spotter_history['longitude'].', ';
358
-					$output_history .=  $spotter_history['latitude'].', ';
359
-					$output_history .=  $spotter_history['altitude']*30.48;
357
+					$output_history .= $spotter_history['longitude'].', ';
358
+					$output_history .= $spotter_history['latitude'].', ';
359
+					$output_history .= $spotter_history['altitude']*30.48;
360 360
 					$output_history .= '],';
361 361
 					$prev_alt = $alt;
362 362
 				    //}
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 			//$output .= ']}}';
401 401
 			$output .= ']';
402 402
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
403
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
403
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
404 404
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
405 405
 			$output .= '"fc": "'.$j.'"';
406 406
 		} else {
Please login to merge, or discard this patch.
Braces   +133 added lines, -51 removed lines patch added patch discarded remove patch
@@ -18,22 +18,43 @@  discard block
 block discarded – undo
18 18
 }
19 19
 header('Content-Type: text/javascript');
20 20
 
21
-if (!isset($globalJsonCompress)) $compress = true;
22
-else $compress = $globalJsonCompress;
21
+if (!isset($globalJsonCompress)) {
22
+	$compress = true;
23
+} else {
24
+	$compress = $globalJsonCompress;
25
+}
23 26
 
24 27
 $from_archive = false;
25 28
 $min = false;
26 29
 $allhistory = false;
27 30
 $filter['source'] = array();
28
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
29
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
30
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
31
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
32
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
33
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
34
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
35
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
36
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
31
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
32
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
33
+}
34
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
35
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
36
+}
37
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
38
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
39
+}
40
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
41
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
42
+}
43
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
44
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
45
+}
46
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
47
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
48
+}
49
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
50
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
51
+}
52
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
53
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
54
+}
55
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
56
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
57
+}
37 58
 
38 59
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
39 60
 	$min = true;
@@ -84,8 +105,12 @@  discard block
 block discarded – undo
84 105
 	} else {
85 106
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
86 107
 	}
87
-	if ($flightcnt == '') $flightcnt = 0;
88
-} else $flightcnt = 0;
108
+	if ($flightcnt == '') {
109
+		$flightcnt = 0;
110
+	}
111
+	} else {
112
+	$flightcnt = 0;
113
+}
89 114
 
90 115
 $sqltime = round(microtime(true)-$begintime,2);
91 116
 
@@ -94,8 +119,11 @@  discard block
 block discarded – undo
94 119
 
95 120
 $output = '{';
96 121
 	$output .= '"type": "FeatureCollection",';
97
-		if ($min) $output .= '"minimal": "true",';
98
-		else $output .= '"minimal": "false",';
122
+		if ($min) {
123
+			$output .= '"minimal": "true",';
124
+		} else {
125
+			$output .= '"minimal": "false",';
126
+		}
99 127
 		$output .= '"fc": "'.$flightcnt.'",';
100 128
 		$output .= '"sqt": "'.$sqltime.'",';
101 129
 
@@ -132,11 +160,16 @@  discard block
 block discarded – undo
132 160
 						//$output .= '"sqt": "'.$sqltime.'",';
133 161
 						$output .= '"id": "'.$spotter_item['flightaware_id'].'",';
134 162
 						$output .= '"properties": {';
135
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
136
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
163
+							if ($compress) {
164
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
165
+							} else {
166
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
167
+							}
137 168
 							$output .= '"fc": "'.$flightcnt.'",';
138 169
 							$output .= '"sqt": "'.$sqltime.'",';
139
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
170
+							if (isset($begindate)) {
171
+								$output .= '"archive_date": "'.$begindate.'",';
172
+							}
140 173
 
141 174
 /*
142 175
 							if ($min) $output .= '"minimal": "true",';
@@ -144,13 +177,21 @@  discard block
 block discarded – undo
144 177
 */
145 178
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
146 179
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
147
-							if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",';
148
-							else $output .= '"callsign": "'.$spotter_item['ident'].'",';
180
+							if ($compress) {
181
+								$output .= '"c": "'.$spotter_item['ident'].'",';
182
+							} else {
183
+								$output .= '"callsign": "'.$spotter_item['ident'].'",';
184
+							}
149 185
 						} else {
150
-							if ($compress) $output .= '"c": "NA",';
151
-							else $output .= '"callsign": "NA",';
186
+							if ($compress) {
187
+								$output .= '"c": "NA",';
188
+							} else {
189
+								$output .= '"callsign": "NA",';
190
+							}
191
+						}
192
+						if (isset($spotter_item['registration'])) {
193
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
152 194
 						}
153
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
154 195
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
155 196
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
156 197
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -163,20 +204,31 @@  discard block
 block discarded – undo
163 204
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
164 205
 						}
165 206
 						if (!isset($spotter_item['aircraft_shadow'])) {
166
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
167
-							else {
207
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
208
+								$spotter_item['aircraft_shadow'] = '';
209
+							} else {
168 210
 								$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
169
-								if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
170
-								elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
171
-								else $spotter_item['aircraft_shadow'] = '';
211
+								if (count($aircraft_info) > 0) {
212
+									$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
213
+								} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
214
+									$spotter_item['aircraft_shadow'] = 'PA18.png';
215
+								} else {
216
+									$spotter_item['aircraft_shadow'] = '';
217
+								}
172 218
 							}
173 219
 						}
174 220
 						if ($spotter_item['aircraft_shadow'] == '') {
175
-							if ($compress) $output .= '"as": "default.png",';
176
-							else $output .= '"aircraft_shadow": "default.png",';
221
+							if ($compress) {
222
+								$output .= '"as": "default.png",';
223
+							} else {
224
+								$output .= '"aircraft_shadow": "default.png",';
225
+							}
177 226
 						} else {
178
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
179
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
227
+							if ($compress) {
228
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
229
+							} else {
230
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
231
+							}
180 232
 						}
181 233
 						if (isset($spotter_item['airline_name'])) {
182 234
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -184,8 +236,11 @@  discard block
 block discarded – undo
184 236
 							$output .= '"airline_name": "NA",';
185 237
 						}
186 238
 						if (isset($spotter_item['departure_airport'])) {
187
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
188
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
239
+							if ($compress) {
240
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
241
+							} else {
242
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
243
+							}
189 244
 						}
190 245
 						if (isset($spotter_item['departure_airport_city'])) {
191 246
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -197,8 +252,11 @@  discard block
 block discarded – undo
197 252
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
198 253
 						}
199 254
 						if (isset($spotter_item['arrival_airport'])) {
200
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
201
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
255
+							if ($compress) {
256
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
257
+							} else {
258
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
259
+							}
202 260
 						}
203 261
 						if (isset($spotter_item['arrival_airport_city'])) {
204 262
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -216,19 +274,30 @@  discard block
 block discarded – undo
216 274
 							$output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",';
217 275
 						}
218 276
 						
219
-						if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
220
-						else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
221
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
222
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
277
+						if ($compress) {
278
+							$output .= '"a": "'.$spotter_item['altitude'].'",';
279
+						} else {
280
+							$output .= '"altitude": "'.$spotter_item['altitude'].'",';
281
+						}
282
+						if ($compress) {
283
+							$output .= '"h": "'.$spotter_item['heading'].'",';
284
+						} else {
285
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
286
+						}
223 287
 						
224
-						if (isset($archivespeed)) $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
225
-						else $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
288
+						if (isset($archivespeed)) {
289
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
290
+						} else {
291
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
292
+						}
226 293
 						//$output .= '"nextlatitude": "'.$nextcoord['latitude'].'",';
227 294
 						//$output .= '"nextlongitude": "'.$nextcoord['longitude'].'",';
228 295
 						$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
229 296
 						//$output .= '"nextlatlon": ['.$nextcoord['longitude'].','.$nextcoord['latitude'].'],';
230 297
 
231
-						if (!$min) $output .= '"image": "'.$image.'",';
298
+						if (!$min) {
299
+							$output .= '"image": "'.$image.'",';
300
+						}
232 301
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
233 302
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
234 303
 						}
@@ -236,8 +305,11 @@  discard block
 block discarded – undo
236 305
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
237 306
 						}
238 307
 						if (isset($spotter_item['squawk'])) {
239
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
240
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
308
+							if ($compress) {
309
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
310
+							} else {
311
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
312
+							}
241 313
 						}
242 314
 						if (isset($spotter_item['squawk_usage'])) {
243 315
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -255,8 +327,11 @@  discard block
 block discarded – undo
255 327
 							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
256 328
 						}
257 329
 						// type when not aircraft ?
258
-						if ($compress) $output .= '"t": "aircraft"';
259
-						else $output .= '"type": "aircraft"';
330
+						if ($compress) {
331
+							$output .= '"t": "aircraft"';
332
+						} else {
333
+							$output .= '"type": "aircraft"';
334
+						}
260 335
 						$output .= '},';
261 336
 						$output .= '"geometry": {';
262 337
 							$output .= '"type": "Point",';
@@ -325,7 +400,9 @@  discard block
 block discarded – undo
325 400
 				//if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) || (isset($_GET['history']) && $_GET['history'] != '' && $_GET['history'] != 'NA' && ($_GET['history'] == $spotter_item['ident'] || $_GET['history'] == $spotter_item['flightaware_id'])))) {
326 401
 				//if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) || (isset($_GET['history']) && $_GET['history'] != '' && $_GET['history'] != 'NA' && ($_GET['history'] == $spotter_item['ident'] || $_GET['history'] == $spotter_item['flightaware_id']))) || (isset($_GET['history']) && $_GET['history'] == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) {
327 402
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
328
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
403
+				if ($history == '' && isset($_COOKIE['history'])) {
404
+					$history = $_COOKIE['history'];
405
+				}
329 406
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) 
330 407
 				|| (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) 
331 408
 				|| (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) {
@@ -350,8 +427,11 @@  discard block
 block discarded – undo
350 427
 						$output_history .= ']}},';
351 428
 						$output .= $output_history;
352 429
 					    }
353
-					    if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
354
-					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
430
+					    if ($compress) {
431
+					    	$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
432
+					    } else {
433
+					    	$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
434
+					    }
355 435
 					}
356 436
 					$output_history .= '[';
357 437
 					$output_history .=  $spotter_history['longitude'].', ';
@@ -401,7 +481,9 @@  discard block
 block discarded – undo
401 481
 			$output .= ']';
402 482
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
403 483
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
404
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
484
+			if (isset($begindate)) {
485
+				$output .= '"archive_date": "'.$begindate.'",';
486
+			}
405 487
 			$output .= '"fc": "'.$j.'"';
406 488
 		} else {
407 489
 			$output .= '"features": ';
Please login to merge, or discard this patch.
header.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30 30
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
31
+		return strpos($key,'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 	}
168 168
 ?>
169 169
 <?php 
170
-    if (isset($_POST['archive'])) {
170
+	if (isset($_POST['archive'])) {
171 171
 ?>
172 172
 <?php 
173
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
173
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
174 174
 ?>
175 175
 
176 176
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script>
177 177
 <?php    
178
-	    }
179
-    } else {
178
+		}
179
+	} else {
180 180
 ?>
181 181
 <?php
182 182
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -188,18 +188,18 @@  discard block
 block discarded – undo
188 188
 */
189 189
 ?>
190 190
 <?php 
191
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
191
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
192 192
 ?>
193 193
 <script src="<?php print $globalURL; ?>/js/leaflet-playback.js"></script>
194 194
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>"></script>
195 195
 <?php
196
-	    }
196
+		}
197 197
 ?>
198 198
 <?php
199 199
 //	}
200 200
 ?>
201 201
 <?php
202
-    }
202
+	}
203 203
 }
204 204
 ?>
205 205
 <?php
@@ -359,23 +359,23 @@  discard block
 block discarded – undo
359 359
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
360 360
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
361 361
             <?php
362
-        	if ($globalACARS) {
363
-        	    if (isset($globalDemo) && $globalDemo) {
364
-    	    ?>
362
+			if ($globalACARS) {
363
+				if (isset($globalDemo) && $globalDemo) {
364
+			?>
365 365
             <li><hr /></li>
366 366
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
367 367
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
368 368
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
369 369
             <?php
370
-        	    } else {
371
-    	    ?>
370
+				} else {
371
+			?>
372 372
             <li><hr /></li>
373 373
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
374 374
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
375 375
             <?php
376
-        	    }
377
-        	}
378
-    	    ?>
376
+				}
377
+			}
378
+			?>
379 379
             <li><hr /></li>
380 380
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
381 381
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
@@ -417,14 +417,14 @@  discard block
 block discarded – undo
417 417
   	    <form>
418 418
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
419 419
   		    <?php
420
-  		        $Language = new Language();
421
-  		        $alllang = $Language->getLanguages();
422
-  		        foreach ($alllang as $key => $lang) {
423
-  		            print '<option value="'.$key.'"';
424
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
425
-  		            print '>'.$lang[0].'</option>';
426
-  		        }
427
-  		    ?>
420
+  				$Language = new Language();
421
+  				$alllang = $Language->getLanguages();
422
+  				foreach ($alllang as $key => $lang) {
423
+  					print '<option value="'.$key.'"';
424
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
425
+  					print '>'.$lang[0].'</option>';
426
+  				}
427
+  			?>
428 428
   		</select>
429 429
   	    </form>
430 430
   	</div>
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 }
461 461
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
462 462
 {
463
-    ?>
463
+	?>
464 464
     <div class="top-header clear" role="main">
465 465
         <div id="map"></div>
466 466
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
         var zoom = 13;
472 472
 //create the map
473 473
 <?php
474
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
474
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
475 475
 ?>
476 476
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
477 477
 <?php
478
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
478
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
479 479
 ?>
480 480
   map = L.map('map', { zoomControl:true });
481 481
 <?php
482
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
482
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
483 483
 ?>
484 484
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
485 485
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -487,22 +487,22 @@  discard block
 block discarded – undo
487 487
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
488 488
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
489 489
 <?php
490
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
490
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
491 491
 ?>
492 492
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
493 493
 <?php
494
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
494
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
495 495
 ?>
496 496
   map = L.map('map', { zoomControl:true });
497 497
 <?php
498
-    }
498
+	}
499 499
 ?>
500 500
   //initialize the layer group for the aircrft markers
501 501
   var layer_data = L.layerGroup();
502 502
 
503 503
   //a few title layers
504 504
 <?php
505
-    if ($globalMapProvider == 'Mapbox') {
505
+	if ($globalMapProvider == 'Mapbox') {
506 506
 ?>
507 507
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
508 508
     maxZoom: 18,
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
     token : '<?php print $globalMapboxToken; ?>'
514 514
   }).addTo(map);
515 515
 <?php
516
-    } elseif ($globalMapProvider == 'OpenStreetMap') {
516
+	} elseif ($globalMapProvider == 'OpenStreetMap') {
517 517
 ?>
518 518
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
519 519
     maxZoom: 18,
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
       '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>'
522 522
   }).addTo(map);
523 523
 <?php
524
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
524
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
525 525
 ?>
526 526
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
527 527
     maxZoom: 18,
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
531 531
   }).addTo(map);
532 532
 <?php
533
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
533
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
534 534
 ?>
535 535
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
536 536
     maxZoom: 18,
@@ -539,27 +539,27 @@  discard block
 block discarded – undo
539 539
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
540 540
   }).addTo(map);
541 541
 <?php
542
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
542
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
543 543
 ?>
544 544
     var googleLayer = new L.Google('ROADMAP');
545 545
     map.addLayer(googleLayer);
546 546
 <?php
547
-    } elseif ($globalMapProvider == 'Google-Satellite') {
547
+	} elseif ($globalMapProvider == 'Google-Satellite') {
548 548
 ?>
549 549
     var googleLayer = new L.Google('SATELLITE');
550 550
     map.addLayer(googleLayer);
551 551
 <?php
552
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
552
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
553 553
 ?>
554 554
     var googleLayer = new L.Google('HYBRID');
555 555
     map.addLayer(googleLayer);
556 556
 <?php
557
-    } elseif ($globalMapProvider == 'Google-Terrain') {
557
+	} elseif ($globalMapProvider == 'Google-Terrain') {
558 558
 ?>
559 559
     var googleLayer = new L.Google('Terrain');
560 560
     map.addLayer(googleLayer);
561 561
 <?php
562
-    }
562
+	}
563 563
 ?>
564 564
         </script>
565 565
     </div>
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,31 +8,31 @@  discard block
 block discarded – undo
8 8
 if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
9 9
 else $MapType = $globalMapProvider;
10 10
 if (isset($_GET['3d'])) {
11
-	setcookie('MapFormat','3d');
11
+	setcookie('MapFormat', '3d');
12 12
 } else if (isset($_GET['2d'])) {
13
-	setcookie('MapFormat','2d');
13
+	setcookie('MapFormat', '2d');
14 14
 }
15 15
 
16 16
 if (isset($_POST['archive'])) {
17
-	setcookie('archive','true');
18
-	setcookie('archive_begin',strtotime($_POST['start_date']));
19
-	setcookie('archive_end',strtotime($_POST['end_date']));
20
-	setcookie('archive_speed',$_POST['archivespeed']);
17
+	setcookie('archive', 'true');
18
+	setcookie('archive_begin', strtotime($_POST['start_date']));
19
+	setcookie('archive_end', strtotime($_POST['end_date']));
20
+	setcookie('archive_speed', $_POST['archivespeed']);
21 21
 }
22 22
 if (isset($_POST['noarchive'])) {
23
-	setcookie('archive','false',-1);
24
-	setcookie('archive_begin','',-1);
25
-	setcookie('archive_end','',-1);
26
-	setcookie('archive_speed','',-1);
23
+	setcookie('archive', 'false', -1);
24
+	setcookie('archive_begin', '', -1);
25
+	setcookie('archive_end', '', -1);
26
+	setcookie('archive_speed', '', -1);
27 27
 }
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30
-	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
30
+	$allfilters = array_filter(array_keys($_COOKIE), function($key) {
31
+	    return strpos($key, 'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
35
-		setcookie($filt,null,-1);
35
+		setcookie($filt, null, -1);
36 36
 	}
37 37
 }
38 38
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script>
217 217
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
218 218
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
219
-<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
219
+<script src="<?php print $globalURL; ?>/js/map.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
220 220
 <?php
221 221
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
222 222
 ?>
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 <script src="<?php print $globalURL; ?>/js/Marker.Rotate.js"></script>
271 271
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
272 272
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
273
-<script src="<?php print $globalURL; ?>/js/map.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
273
+<script src="<?php print $globalURL; ?>/js/map.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
274 274
 <?php
275 275
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
276 276
 ?>
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 ?>
434 434
       <div class="search">
435 435
       <form action="<?php print $globalURL; ?>/search" method="get">
436
-		<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != ""){ print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
436
+		<input type="text" name="q" value="<?php if (isset($GET['q'])) { if ($_GET['q'] != "") { print $_GET['q']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
437 437
 	</form>
438 438
 	</div>
439 439
   	<div class="social">
@@ -451,14 +451,14 @@  discard block
 block discarded – undo
451 451
 	print '</div>';
452 452
 }
453 453
 
454
-if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') {
454
+if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') {
455 455
 ?>
456 456
     <div class="top-header clear" role="main">
457 457
     <div id="archive-map"></div>
458 458
     </div>
459 459
 <?php
460 460
 }
461
-if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
461
+if ((strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) || (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false))
462 462
 {
463 463
     ?>
464 464
     <div class="top-header clear" role="main">
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
         var zoom = 13;
472 472
 //create the map
473 473
 <?php
474
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
474
+    if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) {
475 475
 ?>
476 476
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
477 477
 <?php
478
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
478
+    } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) {
479 479
 ?>
480 480
   map = L.map('map', { zoomControl:true });
481 481
 <?php
482
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
482
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
483 483
 ?>
484 484
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
485 485
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
488 488
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
489 489
 <?php
490
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
490
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
491 491
 ?>
492 492
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
493 493
 <?php
Please login to merge, or discard this patch.