Completed
Push — master ( 492b3e...b38f26 )
by Yannick
29:43
created
require/class.TrackerImport.php 3 patches
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 require_once(dirname(__FILE__).'/class.Source.php');
8 8
 
9 9
 class TrackerImport {
10
-    private $all_tracked = array();
11
-    private $last_delete_hourly = 0;
12
-    private $last_delete = 0;
13
-    private $stats = array();
14
-    private $tmd = 0;
15
-    private $source_location = array();
16
-    public $db = null;
17
-    public $nb = 0;
10
+	private $all_tracked = array();
11
+	private $last_delete_hourly = 0;
12
+	private $last_delete = 0;
13
+	private $stats = array();
14
+	private $tmd = 0;
15
+	private $source_location = array();
16
+	public $db = null;
17
+	public $nb = 0;
18 18
 
19
-    public function __construct($dbc = null) {
19
+	public function __construct($dbc = null) {
20 20
 	global $globalBeta;
21 21
 	$Connection = new Connection($dbc);
22 22
 	$this->db = $Connection->db();
@@ -38,50 +38,50 @@  discard block
 block discarded – undo
38 38
 	    }
39 39
 	}
40 40
 	*/
41
-    }
41
+	}
42 42
 
43
-    public function checkAll() {
43
+	public function checkAll() {
44 44
 	global $globalDebug;
45 45
 	if ($globalDebug) echo "Update last seen tracked data...\n";
46 46
 	foreach ($this->all_tracked as $key => $flight) {
47
-	    if (isset($this->all_tracked[$key]['id'])) {
47
+		if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49
-    		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
-            }
49
+			$Tracker = new Tracker($this->db);
50
+			$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
+			}
52
+	}
52 53
 	}
53
-    }
54 54
 
55
-    public function del() {
55
+	public function del() {
56 56
 	global $globalDebug;
57 57
 	// Delete old infos
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60
-    	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
62
-            	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
60
+			if (isset($flight['lastupdate'])) {
61
+			if ($flight['lastupdate'] < (time()-3000)) {
62
+					if (isset($this->all_tracked[$key]['id'])) {
63
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
65 65
 			$TrackerLive = new TrackerLive();
66 66
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
67 67
 			$TrackerLive->db = null;
68 68
 			*/
69
-            		//$real_arrival = $this->arrival($key);
70
-            		$Tracker = new Tracker($this->db);
71
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
69
+					//$real_arrival = $this->arrival($key);
70
+					$Tracker = new Tracker($this->db);
71
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 72
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
76 76
 //			$Tracker->db = null;
77
-            	    }
78
-            	    unset($this->all_tracked[$key]);
79
-    	        }
80
-	    }
81
-        }
82
-    }
77
+					}
78
+					unset($this->all_tracked[$key]);
79
+				}
80
+		}
81
+		}
82
+	}
83 83
 
84
-    public function add($line) {
84
+	public function add($line) {
85 85
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86 86
 	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
87 87
 	date_default_timezone_set('UTC');
@@ -90,47 +90,47 @@  discard block
 block discarded – undo
90 90
 	
91 91
 	// SBS format is CSV format
92 92
 	if(is_array($line) && isset($line['ident'])) {
93
-	    //print_r($line);
94
-  	    if (isset($line['ident'])) {
93
+		//print_r($line);
94
+  		if (isset($line['ident'])) {
95 95
 
96 96
 		
97 97
 		// Increment message number
98 98
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99
-		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
99
+			$current_date = date('Y-m-d');
100
+			if (isset($line['source_name'])) $source = $line['source_name'];
101
+			else $source = '';
102
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
104
+				$this->stats[$current_date][$source]['msg']['date'] = time();
105
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
107 107
 		}
108 108
 		
109 109
 		
110 110
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
111
+			if (!isset($line['id'])) $id = trim($line['ident']);
112
+			else $id = trim($line['id']);
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115
-		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
-		    if (!isset($line['id'])) {
115
+			$this->all_tracked[$id] = array();
116
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
+			if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121 121
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
122
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
+			if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126 126
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 128
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129
-		    } else {
129
+			} else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133
-		    }
133
+			}
134 134
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
150
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153
-            		$Tracker = new Tracker($this->db);
154
-            		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
153
+					$Tracker = new Tracker($this->db);
154
+					$fromsource = NULL;
155
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158 158
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
159
-		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159
+			}
160
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
-		    if ($distance > 100 && $distance < 10000) {
167
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
+			if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171 171
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173
-		    }
173
+			}
174 174
 		}
175 175
 
176
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
176
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
+				else unset($timediff);
179
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
181
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195
-			    }
195
+				}
196 196
 			}
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200 200
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
-				    $dataFound = true;
203
-				    $this->all_tracked[$id]['time_last_coord'] = time();
201
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
+					$dataFound = true;
203
+					$this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205 205
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210 210
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
-				    $dataFound = true;
213
-				    $this->all_tracked[$id]['time_last_coord'] = time();
211
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
+					$dataFound = true;
213
+					$this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215 215
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218
-		    } else if ($globalDebug && $timediff > 20) {
218
+			} else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
@@ -223,131 +223,131 @@  discard block
 block discarded – undo
223 223
 				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226
-		    }
226
+			}
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
-		    //$dataFound = true;
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
+			//$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
-		    //$dataFound = true;
243
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
+			//$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249 249
 			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250 250
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 251
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
253
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
-		    //$dataFound = true;
261
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
+			//$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
266
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 272
 
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274
-		    $this->all_tracked[$id]['lastupdate'] = time();
275
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
274
+			$this->all_tracked[$id]['lastupdate'] = time();
275
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287 287
 				} else $recent_ident = '';
288 288
 				$TrackerLive->db=null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292
-			    } else {
292
+				} else {
293 293
 				$recent_ident = '';
294 294
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
295
-			    }
296
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
298
-			    {
295
+				}
296
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
+				if($recent_ident == "")
298
+				{
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301
-				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
-				    $timeelapsed = microtime(true);
304
-				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
-				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
+					$highlight = '';
302
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
+					$timeelapsed = microtime(true);
304
+					$Tracker = new Tracker($this->db);
305
+					$result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
+					$Tracker->db = null;
307
+					if ($globalDebug && isset($result)) echo $result."\n";
308
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
309 309
 				    
310 310
 				    
311
-				    // Add source stat in DB
312
-				    $Stats = new Stats($this->db);
313
-				    if (!empty($this->stats)) {
311
+					// Add source stat in DB
312
+					$Stats = new Stats($this->db);
313
+					if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
317
-					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
-				    		if (isset($sourced['msg'])) {
321
-				    		    if (time() - $sourced['msg']['date'] > 10) {
322
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
-			    			        unset($this->stats[$date][$source]['msg']);
325
-			    			    }
326
-			    			}
327
-			    		    }
328
-			    		    if ($date != date('Y-m-d')) {
329
-			    			unset($this->stats[$date]);
330
-			    		    }
331
-				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
315
+						foreach($this->stats as $date => $data) {
316
+						foreach($data as $source => $sourced) {
317
+							//print_r($sourced);
318
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
+							if (isset($sourced['msg'])) {
321
+								if (time() - $sourced['msg']['date'] > 10) {
322
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
+									echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
+									unset($this->stats[$date][$source]['msg']);
325
+								}
326
+							}
327
+							}
328
+							if ($date != date('Y-m-d')) {
329
+							unset($this->stats[$date]);
330
+							}
331
+						}
332
+						if ($globalDebug) echo 'Done'."\n";
333 333
 
334
-				    }
335
-				    $Stats->db = null;
334
+					}
335
+					$Stats->db = null;
336 336
 				    
337
-				    $this->del();
337
+					$this->del();
338 338
 				//$ignoreImport = false;
339 339
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 340
 				//print_r($this->all_tracked[$id]);
341 341
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344
-				    $TrackerLive = new TrackerLive($this->db);
345
-				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
348
-				    $this->last_delete = time();
342
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
344
+					$TrackerLive = new TrackerLive($this->db);
345
+					$TrackerLive->deleteLiveTrackerData();
346
+					$TrackerLive->db=null;
347
+					if ($globalDebug) echo " Done\n";
348
+					$this->last_delete = time();
349 349
 				}
350
-			    } else {
350
+				} else {
351 351
 				$this->all_tracked[$id]['id'] = $recent_ident;
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
359
-			    }
359
+				}
360 360
 			}
361
-		    }
362
-		    //adds the spotter LIVE data
363
-		    if ($globalDebug) {
361
+			}
362
+			//adds the spotter LIVE data
363
+			if ($globalDebug) {
364 364
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
365
-		    }
366
-		    $ignoreImport = false;
365
+			}
366
+			$ignoreImport = false;
367 367
 
368
-		    if (!$ignoreImport) {
368
+			if (!$ignoreImport) {
369 369
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 405
 						for ($i=0;$i<=15;$i++) {
406
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
406
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
409 409
 					} else {
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 					//var_dump($this->stats);
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419
-						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
419
+							end($this->stats[$current_date][$source]['hist']);
420
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
421 421
 						} else $mini = 0;
422 422
 						for ($i=$mini;$i<=$distance;$i+=10) {
423
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
423
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
426 426
 					} else {
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 			
437 437
 			
438 438
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
-			    $TrackerLive = new TrackerLive($this->db);
441
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442
-			    $TrackerLive->db = null;
443
-			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
445
-			    $this->last_delete_hourly = time();
439
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
+				$TrackerLive = new TrackerLive($this->db);
441
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
442
+				$TrackerLive->db = null;
443
+				//TrackerLive->deleteLiveTrackerData();
444
+				if ($globalDebug) echo " Done\n";
445
+				$this->last_delete_hourly = time();
446 446
 			}
447 447
 			
448
-		    }
449
-		    //$ignoreImport = false;
448
+			}
449
+			//$ignoreImport = false;
450 450
 		}
451 451
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452 452
 		if ($send) return $this->all_tracked[$id];
453
-	    }
453
+		}
454
+	}
454 455
 	}
455
-    }
456 456
 }
457 457
 ?>
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	    if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49 49
     		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
50
+        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
51 51
             }
52 52
 	}
53 53
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60 60
     	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
61
+        	if ($flight['lastupdate'] < (time() - 3000)) {
62 62
             	    if (isset($this->all_tracked[$key]['id'])) {
63 63
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             		//$real_arrival = $this->arrival($key);
70 70
             		$Tracker = new Tracker($this->db);
71 71
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72
-				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
72
+				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	$send = false;
90 90
 	
91 91
 	// SBS format is CSV format
92
-	if(is_array($line) && isset($line['ident'])) {
92
+	if (is_array($line) && isset($line['ident'])) {
93 93
 	    //print_r($line);
94 94
   	    if (isset($line['ident'])) {
95 95
 
@@ -113,33 +113,33 @@  discard block
 block discarded – undo
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115 115
 		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
116
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => ''));
118
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
119 119
 		    if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
121
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
122
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
123 123
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
127 127
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
129 129
 		    } else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133 133
 		    }
134
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
137
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
138 138
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
139 139
 			return '';
140 140
 		} elseif (!isset($line['datetime'])) {
141 141
 			date_default_timezone_set('UTC');
142
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
143 143
 		} else {
144 144
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
145 145
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
151 151
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153 153
             		$Tracker = new Tracker($this->db);
154 154
             		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
158
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
159 159
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
168 168
 		    if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173 173
 		    }
174 174
 		}
175 175
 
176 176
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
178 178
 	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
179
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
181
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'], 0.08)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
187 187
 				$timeelapsed = microtime(true);
188 188
 				$Tracker = new Tracker($this->db);
189
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
190 190
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
191 191
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195 195
 			    }
@@ -197,75 +197,75 @@  discard block
 block discarded – undo
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
200
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 201
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 202
 				    $dataFound = true;
203 203
 				    $this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208 208
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
210
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 211
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 212
 				    $dataFound = true;
213 213
 				    $this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
215
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218 218
 		    } else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
222
-				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
223
-				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
222
+				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
223
+				echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226 226
 		    }
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229 229
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
230
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
239
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
240 240
 		    //$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
243
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
244 244
 		    //$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 248
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
249
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => $line['altitude']));
251
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253 253
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
263
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
264 264
 		    //$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
267
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
268
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269 269
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -273,54 +273,54 @@  discard block
 block discarded – undo
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274 274
 		    $this->all_tracked[$id]['lastupdate'] = time();
275 275
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 277
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282 282
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 285
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
286
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
287 287
 				} else $recent_ident = '';
288
-				$TrackerLive->db=null;
288
+				$TrackerLive->db = null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292 292
 			    } else {
293 293
 				$recent_ident = '';
294
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
294
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
295 295
 			    }
296 296
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
297
+			    if ($recent_ident == "")
298 298
 			    {
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301 301
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
302
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303 303
 				    $timeelapsed = microtime(true);
304 304
 				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
306 306
 				    $Tracker->db = null;
307 307
 				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
308
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
309 309
 				    
310 310
 				    
311 311
 				    // Add source stat in DB
312 312
 				    $Stats = new Stats($this->db);
313 313
 				    if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
315
+				        foreach ($this->stats as $date => $data) {
316
+					    foreach ($data as $source => $sourced) {
317 317
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
318
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date);
319
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date);
320 320
 				    		if (isset($sourced['msg'])) {
321 321
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 322
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
323
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date);
324 324
 			    			        unset($this->stats[$date][$source]['msg']);
325 325
 			    			    }
326 326
 			    			}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 344
 				    $TrackerLive = new TrackerLive($this->db);
345 345
 				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
346
+				    $TrackerLive->db = null;
347 347
 				    if ($globalDebug) echo " Done\n";
348 348
 				    $this->last_delete = time();
349 349
 				}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
354 354
 					$Tracker = new Tracker($this->db);
355
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
355
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 		    $ignoreImport = false;
367 367
 
368 368
 		    if (!$ignoreImport) {
369
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
369
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
372 372
 				$TrackerLive = new TrackerLive($this->db);
373
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
373
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
374 374
 				$TrackerLive->db = null;
375 375
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
377 377
 
378 378
 				// Put statistics in $this->stats variable
379 379
 				
@@ -390,19 +390,19 @@  discard block
 block discarded – undo
390 390
 							$latitude = $globalCenterLatitude;
391 391
 							$longitude = $globalCenterLongitude;
392 392
 						}
393
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
393
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
394 394
 					} else {
395 395
 						$latitude = $this->source_location[$source]['latitude'];
396 396
 						$longitude = $this->source_location[$source]['longitude'];
397 397
 					}
398
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
398
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
399 399
 					//$stats_heading = $stats_heading%22.5;
400 400
 					$stats_heading = round($stats_heading/22.5);
401
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
401
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
402 402
 					$current_date = date('Y-m-d');
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405
-						for ($i=0;$i<=15;$i++) {
405
+						for ($i = 0; $i <= 15; $i++) {
406 406
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 419
 						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
420
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
421 421
 						} else $mini = 0;
422
-						for ($i=$mini;$i<=$distance;$i+=10) {
422
+						for ($i = $mini; $i <= $distance; $i += 10) {
423 423
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 				$this->all_tracked[$id]['lastupdate'] = time();
432 432
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433 433
 				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
434
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
435 435
 			//$this->del();
436 436
 			
437 437
 			
Please login to merge, or discard this patch.
Braces   +190 added lines, -65 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function checkAll() {
44 44
 	global $globalDebug;
45
-	if ($globalDebug) echo "Update last seen tracked data...\n";
45
+	if ($globalDebug) {
46
+		echo "Update last seen tracked data...\n";
47
+	}
46 48
 	foreach ($this->all_tracked as $key => $flight) {
47 49
 	    if (isset($this->all_tracked[$key]['id'])) {
48 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -55,12 +57,16 @@  discard block
 block discarded – undo
55 57
     public function del() {
56 58
 	global $globalDebug;
57 59
 	// Delete old infos
58
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
60
+	if ($globalDebug) {
61
+		echo 'Delete old values and update latest data...'."\n";
62
+	}
59 63
 	foreach ($this->all_tracked as $key => $flight) {
60 64
     	    if (isset($flight['lastupdate'])) {
61 65
         	if ($flight['lastupdate'] < (time()-3000)) {
62 66
             	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67
+            		if ($globalDebug) {
68
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		}
64 70
 			/*
65 71
 			$TrackerLive = new TrackerLive();
66 72
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
             		$Tracker = new Tracker($this->db);
71 77
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 78
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
79
+				if ($globalDebug && $result != 'success') {
80
+					echo '!!! ERROR : '.$result."\n";
81
+				}
74 82
 			}
75 83
 			// Put in archive
76 84
 //			$Tracker->db = null;
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
 
84 92
     public function add($line) {
85 93
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
94
+	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') {
95
+		$globalCoordMinChangeTracker = '0.015';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -97,19 +107,29 @@  discard block
 block discarded – undo
97 107
 		// Increment message number
98 108
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99 109
 		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
110
+		    if (isset($line['source_name'])) {
111
+		    	$source = $line['source_name'];
112
+		    } else {
113
+		    	$source = '';
114
+		    }
115
+		    if ($source == '' || $line['format_source'] == 'aprs') {
116
+		    	$source = $line['format_source'];
117
+		    }
103 118
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104 119
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105 120
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
121
+		    } else {
122
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
123
+		    }
107 124
 		}
108 125
 		
109 126
 		
110 127
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
128
+	        if (!isset($line['id'])) {
129
+	        	$id = trim($line['ident']);
130
+	        } else {
131
+	        	$id = trim($line['id']);
132
+	        }
113 133
 		
114 134
 		if (!isset($this->all_tracked[$id])) {
115 135
 		    $this->all_tracked[$id] = array();
@@ -117,31 +137,46 @@  discard block
 block discarded – undo
117 137
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118 138
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119 139
 		    if (!isset($line['id'])) {
120
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
140
+			if (!isset($globalDaemon)) {
141
+				$globalDaemon = TRUE;
142
+			}
121 143
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
144
+		     } else {
145
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
146
+		     }
147
+		    if ($globalAllTracked !== FALSE) {
148
+		    	$dataFound = true;
149
+		    }
124 150
 		}
125 151
 		
126 152
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127 153
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 154
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129 155
 		    } else {
130
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
156
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
157
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
158
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
159
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
160
+				}
132 161
 				return '';
133 162
 		    }
134 163
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
164
+			if ($globalDebug) {
165
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
166
+			}
136 167
 			return '';
137 168
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
138
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
169
+			if ($globalDebug) {
170
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
171
+			}
139 172
 			return '';
140 173
 		} elseif (!isset($line['datetime'])) {
141 174
 			date_default_timezone_set('UTC');
142 175
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
143 176
 		} else {
144
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
177
+			if ($globalDebug) {
178
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
179
+			}
145 180
 			return '';
146 181
 		}
147 182
 		
@@ -153,11 +188,17 @@  discard block
 block discarded – undo
153 188
             		$Tracker = new Tracker($this->db);
154 189
             		$fromsource = NULL;
155 190
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
191
+			if ($globalDebug && $result != 'success') {
192
+				echo '!!! ERROR : '.$result."\n";
193
+			}
157 194
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
195
+			if ($globalDebugTimeElapsed) {
196
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
197
+			}
198
+		    }
199
+		    if (!isset($this->all_tracked[$id]['id'])) {
200
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159 201
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 202
 		}
162 203
 
163 204
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -168,14 +209,21 @@  discard block
 block discarded – undo
168 209
 		    if ($distance > 100 && $distance < 10000) {
169 210
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 211
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
212
+			if ($speed < 1000) {
213
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
214
+			}
215
+  			if ($globalDebug) {
216
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
217
+  			}
173 218
 		    }
174 219
 		}
175 220
 
176 221
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
222
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
223
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
224
+	    	    } else {
225
+	    	    	unset($timediff);
226
+	    	    }
179 227
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 228
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181 229
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
@@ -183,20 +231,30 @@  discard block
 block discarded – undo
183 231
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 232
 				$this->all_tracked[$id]['putinarchive'] = true;
185 233
 				
186
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
234
+				if ($globalDebug) {
235
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
236
+				}
187 237
 				$timeelapsed = microtime(true);
188 238
 				$Tracker = new Tracker($this->db);
189 239
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
190
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
240
+				if (!empty($all_country)) {
241
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
242
+				}
191 243
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
244
+				if ($globalDebugTimeElapsed) {
245
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
246
+				}
193 247
 				$this->tmd = 0;
194
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
248
+				if ($globalDebug) {
249
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
250
+				}
195 251
 			    }
196 252
 			}
197 253
 
198 254
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
255
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
256
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
+				}
200 258
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 259
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 260
 				    $dataFound = true;
@@ -205,8 +263,12 @@  discard block
 block discarded – undo
205 263
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 264
 			}
207 265
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
266
+			    if ($line['longitude'] > 180) {
267
+			    	$line['longitude'] = $line['longitude'] - 360;
268
+			    }
269
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
270
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271
+				}
210 272
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 273
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 274
 				    $dataFound = true;
@@ -226,7 +288,9 @@  discard block
 block discarded – undo
226 288
 		    }
227 289
 		}
228 290
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
291
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
292
+		    	$dataFound = true;
293
+		    }
230 294
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 295
 		}
232 296
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -246,7 +310,9 @@  discard block
 block discarded – undo
246 310
 
247 311
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 312
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
313
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
314
+				$this->all_tracked[$id]['putinarchive'] = true;
315
+			}
250 316
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 317
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 318
 			//$dataFound = true;
@@ -258,15 +324,21 @@  discard block
 block discarded – undo
258 324
 		}
259 325
 		
260 326
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
327
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
328
+		    	$this->all_tracked[$id]['putinarchive'] = true;
329
+		    }
262 330
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263 331
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264 332
 		    //$dataFound = true;
265 333
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266 334
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267 335
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
336
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
337
+		    	$this->all_tracked[$id]['putinarchive'] = true;
338
+		    }
339
+  		    if ($globalDebug) {
340
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
341
+  		    }
270 342
   		}
271 343
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 344
 
@@ -275,20 +347,31 @@  discard block
 block discarded – undo
275 347
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276 348
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 349
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
350
+				if ($globalDebug) {
351
+					echo "Check if aircraft is already in DB...";
352
+				}
279 353
 				$timeelapsed = microtime(true);
280 354
 				$TrackerLive = new TrackerLive($this->db);
281 355
 				if (isset($line['id'])) {
282 356
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
357
+				    if ($globalDebugTimeElapsed) {
358
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+				    }
284 360
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 361
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
-				} else $recent_ident = '';
362
+				    if ($globalDebugTimeElapsed) {
363
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364
+				    }
365
+				} else {
366
+					$recent_ident = '';
367
+				}
288 368
 				$TrackerLive->db=null;
289 369
 
290
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
292 375
 			    } else {
293 376
 				$recent_ident = '';
294 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -296,27 +379,41 @@  discard block
 block discarded – undo
296 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297 380
 			    if($recent_ident == "")
298 381
 			    {
299
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
384
+				}
300 385
 				//adds the spotter data for the archive
301 386
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
389
+				    }
303 390
 				    $timeelapsed = microtime(true);
304 391
 				    $Tracker = new Tracker($this->db);
305 392
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306 393
 				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
309 400
 				    
310 401
 				    
311 402
 				    // Add source stat in DB
312 403
 				    $Stats = new Stats($this->db);
313 404
 				    if (!empty($this->stats)) {
314
-					if ($globalDebug) echo 'Add source stats : ';
405
+					if ($globalDebug) {
406
+						echo 'Add source stats : ';
407
+					}
315 408
 				        foreach($this->stats as $date => $data) {
316 409
 					    foreach($data as $source => $sourced) {
317 410
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
411
+				    	        if (isset($sourced['polar'])) {
412
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
413
+				    	        }
414
+				    	        if (isset($sourced['hist'])) {
415
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
416
+				    	        }
320 417
 				    		if (isset($sourced['msg'])) {
321 418
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 419
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -329,7 +426,9 @@  discard block
 block discarded – undo
329 426
 			    			unset($this->stats[$date]);
330 427
 			    		    }
331 428
 				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
429
+				    	if ($globalDebug) {
430
+				    		echo 'Done'."\n";
431
+				    	}
333 432
 
334 433
 				    }
335 434
 				    $Stats->db = null;
@@ -339,12 +438,16 @@  discard block
 block discarded – undo
339 438
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 439
 				//print_r($this->all_tracked[$id]);
341 440
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
441
+				    if ($globalDebug) {
442
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
443
+				    }
343 444
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 445
 				    $TrackerLive = new TrackerLive($this->db);
345 446
 				    $TrackerLive->deleteLiveTrackerData();
346 447
 				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
448
+				    if ($globalDebug) {
449
+				    	echo " Done\n";
450
+				    }
348 451
 				    $this->last_delete = time();
349 452
 				}
350 453
 			    } else {
@@ -367,19 +470,25 @@  discard block
 block discarded – undo
367 470
 
368 471
 		    if (!$ignoreImport) {
369 472
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
473
+				if ($globalDebug) {
474
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
475
+				}
371 476
 				$timeelapsed = microtime(true);
372 477
 				$TrackerLive = new TrackerLive($this->db);
373 478
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
374 479
 				$TrackerLive->db = null;
375 480
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				if ($globalDebugTimeElapsed) {
482
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+				}
377 484
 
378 485
 				// Put statistics in $this->stats variable
379 486
 				
380 487
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
381 488
 					$source = $this->all_tracked[$id]['source_name'];
382
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
489
+					if ($source == '') {
490
+						$source = $this->all_tracked[$id]['format_source'];
491
+					}
383 492
 					if (!isset($this->source_location[$source])) {
384 493
 						$Location = new Source($this->db);
385 494
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -400,7 +509,9 @@  discard block
 block discarded – undo
400 509
 					$stats_heading = round($stats_heading/22.5);
401 510
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
402 511
 					$current_date = date('Y-m-d');
403
-					if ($stats_heading == 16) $stats_heading = 0;
512
+					if ($stats_heading == 16) {
513
+						$stats_heading = 0;
514
+					}
404 515
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 516
 						for ($i=0;$i<=15;$i++) {
406 517
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -418,7 +529,9 @@  discard block
 block discarded – undo
418 529
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 530
 						    end($this->stats[$current_date][$source]['hist']);
420 531
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
421
-						} else $mini = 0;
532
+						} else {
533
+							$mini = 0;
534
+						}
422 535
 						for ($i=$mini;$i<=$distance;$i+=10) {
423 536
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 537
 						}
@@ -429,19 +542,29 @@  discard block
 block discarded – undo
429 542
 				}
430 543
 
431 544
 				$this->all_tracked[$id]['lastupdate'] = time();
432
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433
-				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
545
+				if ($this->all_tracked[$id]['putinarchive']) {
546
+					$send = true;
547
+				}
548
+				if ($globalDebug) {
549
+					echo $result."\n";
550
+				}
551
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
552
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
553
+			}
435 554
 			//$this->del();
436 555
 			
437 556
 			
438 557
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
558
+			    if ($globalDebug) {
559
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
560
+			    }
440 561
 			    $TrackerLive = new TrackerLive($this->db);
441 562
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442 563
 			    $TrackerLive->db = null;
443 564
 			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
565
+			    if ($globalDebug) {
566
+			    	echo " Done\n";
567
+			    }
445 568
 			    $this->last_delete_hourly = time();
446 569
 			}
447 570
 			
@@ -449,7 +572,9 @@  discard block
 block discarded – undo
449 572
 		    //$ignoreImport = false;
450 573
 		}
451 574
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452
-		if ($send) return $this->all_tracked[$id];
575
+		if ($send) {
576
+			return $this->all_tracked[$id];
577
+		}
453 578
 	    }
454 579
 	}
455 580
     }
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 3 patches
Indentation   +594 added lines, -594 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 	}
11 11
 
12 12
 	/**
13
-	* Get SQL query part for filter used
14
-	* @param Array $filter the filter
15
-	* @return Array the SQL part
16
-	*/
13
+	 * Get SQL query part for filter used
14
+	 * @param Array $filter the filter
15
+	 * @return Array the SQL part
16
+	 */
17 17
 	public function getFilter($filter = array(),$where = false,$and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
@@ -106,44 +106,44 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 
108 108
 
109
-        /**
110
-        * Gets all the spotter information based on a particular callsign
111
-        *
112
-        * @return Array the spotter information
113
-        *
114
-        */
115
-        public function getLastArchiveTrackerDataByIdent($ident)
116
-        {
109
+		/**
110
+		 * Gets all the spotter information based on a particular callsign
111
+		 *
112
+		 * @return Array the spotter information
113
+		 *
114
+		 */
115
+		public function getLastArchiveTrackerDataByIdent($ident)
116
+		{
117 117
 		$Tracker = new Tracker($this->db);
118
-                date_default_timezone_set('UTC');
118
+				date_default_timezone_set('UTC');
119 119
 
120
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
121
-                //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
122
-                $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
120
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
121
+				//$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
122
+				$query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
123 123
 
124
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
124
+				$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
125 125
 
126
-                return $spotter_array;
127
-        }
126
+				return $spotter_array;
127
+		}
128 128
 
129 129
 
130
-        /**
131
-        * Gets last the spotter information based on a particular id
132
-        *
133
-        * @return Array the spotter information
134
-        *
135
-        */
136
-        public function getLastArchiveTrackerDataById($id)
137
-        {
138
-    		$Tracker = new Tracker($this->db);
139
-                date_default_timezone_set('UTC');
140
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
141
-                //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
142
-                //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
143
-                $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
130
+		/**
131
+		 * Gets last the spotter information based on a particular id
132
+		 *
133
+		 * @return Array the spotter information
134
+		 *
135
+		 */
136
+		public function getLastArchiveTrackerDataById($id)
137
+		{
138
+			$Tracker = new Tracker($this->db);
139
+				date_default_timezone_set('UTC');
140
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
141
+				//$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
142
+				//$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
143
+				$query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
144 144
 
145 145
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
146
-                  /*
146
+				  /*
147 147
                 try {
148 148
                         $Connection = new Connection();
149 149
                         $sth = Connection->$db->prepare($query);
@@ -153,189 +153,189 @@  discard block
 block discarded – undo
153 153
                 }
154 154
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
155 155
                 */
156
-                $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
157
-
158
-                return $spotter_array;
159
-        }
160
-
161
-        /**
162
-        * Gets all the spotter information based on a particular id
163
-        *
164
-        * @return Array the spotter information
165
-        *
166
-        */
167
-        public function getAllArchiveTrackerDataById($id,$date = '')
156
+				$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
157
+
158
+				return $spotter_array;
159
+		}
160
+
161
+		/**
162
+		 * Gets all the spotter information based on a particular id
163
+		 *
164
+		 * @return Array the spotter information
165
+		 *
166
+		 */
167
+		public function getAllArchiveTrackerDataById($id,$date = '')
168 168
 	{
169
-                date_default_timezone_set('UTC');
170
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
171
-                if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
-                else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
169
+				date_default_timezone_set('UTC');
170
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
171
+				if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
+				else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
173 173
 
174 174
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
175 175
 
176
-                try {
177
-                        $sth = $this->db->prepare($query);
178
-                        $sth->execute(array(':id' => $id));
179
-                } catch(PDOException $e) {
180
-                        echo $e->getMessage();
181
-                        die;
182
-                }
183
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
184
-
185
-                return $spotter_array;
186
-        }
187
-
188
-        /**
189
-        * Gets coordinate & time spotter information based on a particular id
190
-        *
191
-        * @return Array the spotter information
192
-        *
193
-        */
194
-        public function getCoordArchiveTrackerDataById($id)
195
-        {
196
-                date_default_timezone_set('UTC');
197
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
198
-                $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
176
+				try {
177
+						$sth = $this->db->prepare($query);
178
+						$sth->execute(array(':id' => $id));
179
+				} catch(PDOException $e) {
180
+						echo $e->getMessage();
181
+						die;
182
+				}
183
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
184
+
185
+				return $spotter_array;
186
+		}
187
+
188
+		/**
189
+		 * Gets coordinate & time spotter information based on a particular id
190
+		 *
191
+		 * @return Array the spotter information
192
+		 *
193
+		 */
194
+		public function getCoordArchiveTrackerDataById($id)
195
+		{
196
+				date_default_timezone_set('UTC');
197
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
198
+				$query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
199 199
 
200 200
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
201 201
 
202
-                try {
203
-                        $sth = $this->db->prepare($query);
204
-                        $sth->execute(array(':id' => $id));
205
-                } catch(PDOException $e) {
206
-                        echo $e->getMessage();
207
-                        die;
208
-                }
209
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
202
+				try {
203
+						$sth = $this->db->prepare($query);
204
+						$sth->execute(array(':id' => $id));
205
+				} catch(PDOException $e) {
206
+						echo $e->getMessage();
207
+						die;
208
+				}
209
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
210 210
 
211
-                return $spotter_array;
212
-        }
211
+				return $spotter_array;
212
+		}
213 213
 
214 214
 
215
-        /**
216
-        * Gets altitude information based on a particular callsign
217
-        *
218
-        * @return Array the spotter information
219
-        *
220
-        */
221
-        public function getAltitudeArchiveTrackerDataByIdent($ident)
222
-        {
215
+		/**
216
+		 * Gets altitude information based on a particular callsign
217
+		 *
218
+		 * @return Array the spotter information
219
+		 *
220
+		 */
221
+		public function getAltitudeArchiveTrackerDataByIdent($ident)
222
+		{
223 223
 
224
-                date_default_timezone_set('UTC');
224
+				date_default_timezone_set('UTC');
225 225
 
226
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
227
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
226
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
227
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
228 228
 
229
-                try {
230
-                        $sth = $this->db->prepare($query);
231
-                        $sth->execute(array(':ident' => $ident));
232
-                } catch(PDOException $e) {
233
-                        echo $e->getMessage();
234
-                        die;
235
-                }
236
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
229
+				try {
230
+						$sth = $this->db->prepare($query);
231
+						$sth->execute(array(':ident' => $ident));
232
+				} catch(PDOException $e) {
233
+						echo $e->getMessage();
234
+						die;
235
+				}
236
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
237 237
 
238
-                return $spotter_array;
239
-        }
238
+				return $spotter_array;
239
+		}
240 240
 
241
-        /**
242
-        * Gets altitude information based on a particular id
243
-        *
244
-        * @return Array the spotter information
245
-        *
246
-        */
247
-        public function getAltitudeArchiveTrackerDataById($id)
248
-        {
241
+		/**
242
+		 * Gets altitude information based on a particular id
243
+		 *
244
+		 * @return Array the spotter information
245
+		 *
246
+		 */
247
+		public function getAltitudeArchiveTrackerDataById($id)
248
+		{
249 249
 
250
-                date_default_timezone_set('UTC');
250
+				date_default_timezone_set('UTC');
251 251
 
252
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
253
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
252
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
253
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
254 254
 
255
-                try {
256
-                        $sth = $this->db->prepare($query);
257
-                        $sth->execute(array(':id' => $id));
258
-                } catch(PDOException $e) {
259
-                        echo $e->getMessage();
260
-                        die;
261
-                }
262
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
255
+				try {
256
+						$sth = $this->db->prepare($query);
257
+						$sth->execute(array(':id' => $id));
258
+				} catch(PDOException $e) {
259
+						echo $e->getMessage();
260
+						die;
261
+				}
262
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
263 263
 
264
-                return $spotter_array;
265
-        }
264
+				return $spotter_array;
265
+		}
266 266
 
267
-        /**
268
-        * Gets altitude & speed information based on a particular id
269
-        *
270
-        * @return Array the spotter information
271
-        *
272
-        */
273
-        public function getAltitudeSpeedArchiveTrackerDataById($id)
274
-        {
267
+		/**
268
+		 * Gets altitude & speed information based on a particular id
269
+		 *
270
+		 * @return Array the spotter information
271
+		 *
272
+		 */
273
+		public function getAltitudeSpeedArchiveTrackerDataById($id)
274
+		{
275 275
 
276
-                date_default_timezone_set('UTC');
276
+				date_default_timezone_set('UTC');
277 277
 
278
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
279
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
278
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
279
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
280 280
 
281
-                try {
282
-                        $sth = $this->db->prepare($query);
283
-                        $sth->execute(array(':id' => $id));
284
-                } catch(PDOException $e) {
285
-                        echo $e->getMessage();
286
-                        die;
287
-                }
288
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
281
+				try {
282
+						$sth = $this->db->prepare($query);
283
+						$sth->execute(array(':id' => $id));
284
+				} catch(PDOException $e) {
285
+						echo $e->getMessage();
286
+						die;
287
+				}
288
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
289 289
 
290
-                return $spotter_array;
291
-        }
290
+				return $spotter_array;
291
+		}
292 292
 
293 293
 
294
-        /**
295
-        * Gets altitude information based on a particular callsign
296
-        *
297
-        * @return Array the spotter information
298
-        *
299
-        */
300
-        public function getLastAltitudeArchiveTrackerDataByIdent($ident)
301
-        {
294
+		/**
295
+		 * Gets altitude information based on a particular callsign
296
+		 *
297
+		 * @return Array the spotter information
298
+		 *
299
+		 */
300
+		public function getLastAltitudeArchiveTrackerDataByIdent($ident)
301
+		{
302 302
 
303
-                date_default_timezone_set('UTC');
303
+				date_default_timezone_set('UTC');
304 304
 
305
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
306
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
305
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
306
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
307 307
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
308 308
 
309
-                try {
310
-                        $sth = $this->db->prepare($query);
311
-                        $sth->execute(array(':ident' => $ident));
312
-                } catch(PDOException $e) {
313
-                        echo $e->getMessage();
314
-                        die;
315
-                }
316
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
309
+				try {
310
+						$sth = $this->db->prepare($query);
311
+						$sth->execute(array(':ident' => $ident));
312
+				} catch(PDOException $e) {
313
+						echo $e->getMessage();
314
+						die;
315
+				}
316
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
317 317
 
318
-                return $spotter_array;
319
-        }
318
+				return $spotter_array;
319
+		}
320 320
 
321 321
 
322 322
 
323
-       /**
324
-        * Gets all the archive spotter information
325
-        *
326
-        * @return Array the spotter information
327
-        *
328
-        */
329
-        public function getTrackerArchiveData($ident,$famtrackid,$date)
330
-        {
331
-    		$Tracker = new Tracker($this->db);
332
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
323
+	   /**
324
+	    * Gets all the archive spotter information
325
+	    *
326
+	    * @return Array the spotter information
327
+	    *
328
+	    */
329
+		public function getTrackerArchiveData($ident,$famtrackid,$date)
330
+		{
331
+			$Tracker = new Tracker($this->db);
332
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
334 334
 
335
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
335
+				$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
336 336
 
337
-                return $spotter_array;
338
-        }
337
+				return $spotter_array;
338
+		}
339 339
 
340 340
 	public function deleteTrackerArchiveTrackData()
341 341
 	{
@@ -355,34 +355,34 @@  discard block
 block discarded – undo
355 355
 	}
356 356
 
357 357
 	/**
358
-        * Gets Minimal Live Tracker data
359
-        *
360
-        * @return Array the spotter information
361
-        *
362
-        */
363
-        public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
364
-        {
365
-                global $globalDBdriver, $globalLiveInterval;
366
-                date_default_timezone_set('UTC');
367
-
368
-                $filter_query = '';
369
-                if (isset($filter['source']) && !empty($filter['source'])) {
370
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
-                }
372
-                // Use spotter_output also ?
373
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
375
-                }
376
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
378
-                }
379
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
-                }
358
+	 * Gets Minimal Live Tracker data
359
+	 *
360
+	 * @return Array the spotter information
361
+	 *
362
+	 */
363
+		public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
364
+		{
365
+				global $globalDBdriver, $globalLiveInterval;
366
+				date_default_timezone_set('UTC');
382 367
 
383
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
-                if ($globalDBdriver == 'mysql') {
385
-                        /*
368
+				$filter_query = '';
369
+				if (isset($filter['source']) && !empty($filter['source'])) {
370
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
+				}
372
+				// Use spotter_output also ?
373
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
375
+				}
376
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
378
+				}
379
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
+				}
382
+
383
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
+				if ($globalDBdriver == 'mysql') {
385
+						/*
386 386
                         $query  = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk 
387 387
                     		    FROM tracker_archive 
388 388
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
@@ -401,56 +401,56 @@  discard block
 block discarded – undo
401 401
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
402 402
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
403 403
                         	    '.$filter_query.' ORDER BY famtrackid';
404
-                } else {
405
-                        //$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
406
-                        $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
404
+				} else {
405
+						//$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
406
+						$query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
407 407
                         	    FROM tracker_archive 
408 408
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
409 409
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
410 410
                         	    '.$filter_query.' ORDER BY famtrackid';
411
-                }
412
-                //echo $query;
413
-                try {
414
-                        $sth = $this->db->prepare($query);
415
-                        $sth->execute();
416
-                } catch(PDOException $e) {
417
-                        echo $e->getMessage();
418
-                        die;
419
-                }
420
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
411
+				}
412
+				//echo $query;
413
+				try {
414
+						$sth = $this->db->prepare($query);
415
+						$sth->execute();
416
+				} catch(PDOException $e) {
417
+						echo $e->getMessage();
418
+						die;
419
+				}
420
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
421 421
 
422
-                return $spotter_array;
423
-        }
422
+				return $spotter_array;
423
+		}
424 424
 
425 425
 	/**
426
-        * Gets Minimal Live Tracker data
427
-        *
428
-        * @return Array the spotter information
429
-        *
430
-        */
431
-        public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
432
-        {
433
-                global $globalDBdriver, $globalLiveInterval;
434
-                date_default_timezone_set('UTC');
435
-
436
-                $filter_query = '';
437
-                if (isset($filter['source']) && !empty($filter['source'])) {
438
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
-                }
440
-                // Should use spotter_output also ?
441
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
443
-                }
444
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
446
-                }
447
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
-                }
426
+	 * Gets Minimal Live Tracker data
427
+	 *
428
+	 * @return Array the spotter information
429
+	 *
430
+	 */
431
+		public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
432
+		{
433
+				global $globalDBdriver, $globalLiveInterval;
434
+				date_default_timezone_set('UTC');
435
+
436
+				$filter_query = '';
437
+				if (isset($filter['source']) && !empty($filter['source'])) {
438
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
+				}
440
+				// Should use spotter_output also ?
441
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
443
+				}
444
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
446
+				}
447
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
+				}
450 450
 
451
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
-                if ($globalDBdriver == 'mysql') {
453
-                        /*
451
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
+				if ($globalDBdriver == 'mysql') {
453
+						/*
454 454
                         $query  = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk 
455 455
                     		    FROM tracker_archive 
456 456
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
@@ -461,95 +461,95 @@  discard block
 block discarded – undo
461 461
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
462 462
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
463 463
 
464
-                } else {
465
-                        //$query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao';
466
-                       /*
464
+				} else {
465
+						//$query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao';
466
+					   /*
467 467
                         $query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
468 468
                         	    FROM tracker_archive_output 
469 469
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
470 470
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
471 471
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
472 472
                         */
473
-                        $query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
473
+						$query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
474 474
                         	    FROM tracker_archive_output 
475 475
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
476 476
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
477 477
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
478 478
 //                        	    .' GROUP BY spotter_output.famtrackid, 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';
479 479
                         	    
480
-                }
481
-                //echo $query;
482
-                try {
483
-                        $sth = $this->db->prepare($query);
484
-                        $sth->execute();
485
-                } catch(PDOException $e) {
486
-                        echo $e->getMessage();
487
-                        die;
488
-                }
489
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
480
+				}
481
+				//echo $query;
482
+				try {
483
+						$sth = $this->db->prepare($query);
484
+						$sth->execute();
485
+				} catch(PDOException $e) {
486
+						echo $e->getMessage();
487
+						die;
488
+				}
489
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
490 490
 
491
-                return $spotter_array;
492
-        }
491
+				return $spotter_array;
492
+		}
493 493
 
494 494
 	 /**
495
-        * Gets count Live Tracker data
496
-        *
497
-        * @return Array the spotter information
498
-        *
499
-        */
500
-        public function getLiveTrackerCount($begindate,$enddate,$filter = array())
501
-        {
502
-                global $globalDBdriver, $globalLiveInterval;
503
-                date_default_timezone_set('UTC');
504
-
505
-                $filter_query = '';
506
-                if (isset($filter['source']) && !empty($filter['source'])) {
507
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
-                }
509
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
511
-                }
512
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
514
-                }
515
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
-                }
495
+	  * Gets count Live Tracker data
496
+	  *
497
+	  * @return Array the spotter information
498
+	  *
499
+	  */
500
+		public function getLiveTrackerCount($begindate,$enddate,$filter = array())
501
+		{
502
+				global $globalDBdriver, $globalLiveInterval;
503
+				date_default_timezone_set('UTC');
518 504
 
519
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
-                if ($globalDBdriver == 'mysql') {
505
+				$filter_query = '';
506
+				if (isset($filter['source']) && !empty($filter['source'])) {
507
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
+				}
509
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
511
+				}
512
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
514
+				}
515
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
+				}
518
+
519
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
+				if ($globalDBdriver == 'mysql') {
521 521
 			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb 
522 522
 			FROM tracker_archive l 
523 523
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
524
-                } else {
524
+				} else {
525 525
 			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
526
-                }
527
-                //echo $query;
528
-                try {
529
-                        $sth = $this->db->prepare($query);
530
-                        $sth->execute();
531
-                } catch(PDOException $e) {
532
-                        echo $e->getMessage();
533
-                        die;
534
-                }
526
+				}
527
+				//echo $query;
528
+				try {
529
+						$sth = $this->db->prepare($query);
530
+						$sth->execute();
531
+				} catch(PDOException $e) {
532
+						echo $e->getMessage();
533
+						die;
534
+				}
535 535
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
536 536
 		$sth->closeCursor();
537
-                return $result['nb'];
537
+				return $result['nb'];
538 538
 
539
-        }
539
+		}
540 540
 
541 541
 
542 542
 
543 543
 	// tracker_archive_output
544 544
 	
545
-    /**
546
-    * Gets all the spotter information
547
-    *
548
-    * @return Array the spotter information
549
-    *
550
-    */
551
-    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
-    {
545
+	/**
546
+	 * Gets all the spotter information
547
+	 *
548
+	 * @return Array the spotter information
549
+	 *
550
+	 */
551
+	public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
+	{
553 553
 	global $globalTimezone, $globalDBdriver;
554 554
 	require_once(dirname(__FILE__).'/class.Translation.php');
555 555
 	$Translation = new Translation($this->db);
@@ -563,159 +563,159 @@  discard block
 block discarded – undo
563 563
 	$filter_query = $this->getFilter($filters);
564 564
 	if ($q != "")
565 565
 	{
566
-	    if (!is_string($q))
567
-	    {
566
+		if (!is_string($q))
567
+		{
568 568
 		return false;
569
-	    } else {
569
+		} else {
570 570
 	        
571 571
 		$q_array = explode(" ", $q);
572 572
 		
573 573
 		foreach ($q_array as $q_item){
574
-		    $additional_query .= " AND (";
575
-		    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
576
-		    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
-		    $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
-		    $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
-		    $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
580
-		    $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
581
-		    $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
582
-		    $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
-		    $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
-		    $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
-		    $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
-		    $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
-		    $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
-		    $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
-		    $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
-		    $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
591
-		    $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
592
-		    $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
593
-		    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
594
-		    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
595
-		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
597
-		    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
598
-		    $additional_query .= ")";
574
+			$additional_query .= " AND (";
575
+			$additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
576
+			$additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
+			$additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
+			$additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
+			$additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
580
+			$additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
581
+			$additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
582
+			$additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
+			$additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
+			$additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
+			$additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
+			$additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
+			$additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
+			$additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
+			$additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
+			$additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
591
+			$additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
592
+			$additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
593
+			$additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
594
+			$additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
595
+			$translate = $Translation->ident2icao($q_item);
596
+			if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
597
+			$additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
598
+			$additional_query .= ")";
599
+		}
599 600
 		}
600
-	    }
601 601
 	}
602 602
 	
603 603
 	if ($registration != "")
604 604
 	{
605
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
-	    if (!is_string($registration))
607
-	    {
605
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
+		if (!is_string($registration))
607
+		{
608 608
 		return false;
609
-	    } else {
609
+		} else {
610 610
 		$additional_query .= " AND (tracker_archive_output.registration = '".$registration."')";
611
-	    }
611
+		}
612 612
 	}
613 613
 	
614 614
 	if ($aircraft_icao != "")
615 615
 	{
616
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
-	    if (!is_string($aircraft_icao))
618
-	    {
616
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
+		if (!is_string($aircraft_icao))
618
+		{
619 619
 		return false;
620
-	    } else {
620
+		} else {
621 621
 		$additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')";
622
-	    }
622
+		}
623 623
 	}
624 624
 	
625 625
 	if ($aircraft_manufacturer != "")
626 626
 	{
627
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
-	    if (!is_string($aircraft_manufacturer))
629
-	    {
627
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
+		if (!is_string($aircraft_manufacturer))
629
+		{
630 630
 		return false;
631
-	    } else {
631
+		} else {
632 632
 		$additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
633
-	    }
633
+		}
634 634
 	}
635 635
 	
636 636
 	if ($highlights == "true")
637 637
 	{
638
-	    if (!is_string($highlights))
639
-	    {
638
+		if (!is_string($highlights))
639
+		{
640 640
 		return false;
641
-	    } else {
641
+		} else {
642 642
 		$additional_query .= " AND (tracker_archive_output.highlight <> '')";
643
-	    }
643
+		}
644 644
 	}
645 645
 	
646 646
 	if ($airline_icao != "")
647 647
 	{
648
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
-	    if (!is_string($airline_icao))
650
-	    {
648
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
+		if (!is_string($airline_icao))
650
+		{
651 651
 		return false;
652
-	    } else {
652
+		} else {
653 653
 		$additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')";
654
-	    }
654
+		}
655 655
 	}
656 656
 	
657 657
 	if ($airline_country != "")
658 658
 	{
659
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
-	    if (!is_string($airline_country))
661
-	    {
659
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
+		if (!is_string($airline_country))
661
+		{
662 662
 		return false;
663
-	    } else {
663
+		} else {
664 664
 		$additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')";
665
-	    }
665
+		}
666 666
 	}
667 667
 	
668 668
 	if ($airline_type != "")
669 669
 	{
670
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
-	    if (!is_string($airline_type))
672
-	    {
670
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
+		if (!is_string($airline_type))
672
+		{
673 673
 		return false;
674
-	    } else {
674
+		} else {
675 675
 		if ($airline_type == "passenger")
676 676
 		{
677
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
677
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
678 678
 		}
679 679
 		if ($airline_type == "cargo")
680 680
 		{
681
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
681
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
682 682
 		}
683 683
 		if ($airline_type == "military")
684 684
 		{
685
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
685
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
686
+		}
686 687
 		}
687
-	    }
688 688
 	}
689 689
 	
690 690
 	if ($airport != "")
691 691
 	{
692
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
-	    if (!is_string($airport))
694
-	    {
692
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
+		if (!is_string($airport))
694
+		{
695 695
 		return false;
696
-	    } else {
696
+		} else {
697 697
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))";
698
-	    }
698
+		}
699 699
 	}
700 700
 	
701 701
 	if ($airport_country != "")
702 702
 	{
703
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
-	    if (!is_string($airport_country))
705
-	    {
703
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
+		if (!is_string($airport_country))
705
+		{
706 706
 		return false;
707
-	    } else {
707
+		} else {
708 708
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))";
709
-	    }
709
+		}
710 710
 	}
711 711
     
712 712
 	if ($callsign != "")
713 713
 	{
714
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
-	    if (!is_string($callsign))
716
-	    {
714
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
+		if (!is_string($callsign))
716
+		{
717 717
 		return false;
718
-	    } else {
718
+		} else {
719 719
 		$translate = $Translation->ident2icao($callsign);
720 720
 		if ($translate != $callsign) {
721 721
 			$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
@@ -723,99 +723,99 @@  discard block
 block discarded – undo
723 723
 		} else {
724 724
 			$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
725 725
 		}
726
-	    }
726
+		}
727 727
 	}
728 728
 
729 729
 	if ($owner != "")
730 730
 	{
731
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
-	    if (!is_string($owner))
733
-	    {
731
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
+		if (!is_string($owner))
733
+		{
734 734
 		return false;
735
-	    } else {
735
+		} else {
736 736
 		$additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')";
737
-	    }
737
+		}
738 738
 	}
739 739
 
740 740
 	if ($pilot_name != "")
741 741
 	{
742
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
-	    if (!is_string($pilot_name))
744
-	    {
742
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
+		if (!is_string($pilot_name))
744
+		{
745 745
 		return false;
746
-	    } else {
746
+		} else {
747 747
 		$additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')";
748
-	    }
748
+		}
749 749
 	}
750 750
 	
751 751
 	if ($pilot_id != "")
752 752
 	{
753
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
-	    if (!is_string($pilot_id))
755
-	    {
753
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
+		if (!is_string($pilot_id))
755
+		{
756 756
 		return false;
757
-	    } else {
757
+		} else {
758 758
 		$additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')";
759
-	    }
759
+		}
760 760
 	}
761 761
 	
762 762
 	if ($departure_airport_route != "")
763 763
 	{
764
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
-	    if (!is_string($departure_airport_route))
766
-	    {
764
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
+		if (!is_string($departure_airport_route))
766
+		{
767 767
 		return false;
768
-	    } else {
768
+		} else {
769 769
 		$additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')";
770
-	    }
770
+		}
771 771
 	}
772 772
 	
773 773
 	if ($arrival_airport_route != "")
774 774
 	{
775
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
-	    if (!is_string($arrival_airport_route))
777
-	    {
775
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
+		if (!is_string($arrival_airport_route))
777
+		{
778 778
 		return false;
779
-	    } else {
779
+		} else {
780 780
 		$additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
781
-	    }
781
+		}
782 782
 	}
783 783
 	
784 784
 	if ($altitude != "")
785 785
 	{
786
-	    $altitude_array = explode(",", $altitude);
786
+		$altitude_array = explode(",", $altitude);
787 787
 	    
788
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
790 790
 	    
791 791
 
792
-	    if ($altitude_array[1] != "")
793
-	    {                
792
+		if ($altitude_array[1] != "")
793
+		{                
794 794
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
795 795
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
796 796
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
797
-	    } else {
797
+		} else {
798 798
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
799 799
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
800
-	    }
800
+		}
801 801
 	}
802 802
 	
803 803
 	if ($date_posted != "")
804 804
 	{
805
-	    $date_array = explode(",", $date_posted);
805
+		$date_array = explode(",", $date_posted);
806 806
 	    
807
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
809 809
 	    
810
-	    if ($globalTimezone != '') {
810
+		if ($globalTimezone != '') {
811 811
 		date_default_timezone_set($globalTimezone);
812 812
 		$datetime = new DateTime();
813 813
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
814
+		} else $offset = '+00:00';
815 815
 
816 816
 
817
-	    if ($date_array[1] != "")
818
-	    {                
817
+		if ($date_array[1] != "")
818
+		{                
819 819
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
820 820
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
821 821
 		if ($globalDBdriver == 'mysql') {
@@ -823,28 +823,28 @@  discard block
 block discarded – undo
823 823
 		} else {
824 824
 			$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
825 825
 		}
826
-	    } else {
826
+		} else {
827 827
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
828
-                if ($globalDBdriver == 'mysql') {
828
+				if ($globalDBdriver == 'mysql') {
829 829
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
830 830
 		} else {
831 831
 			$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
832 832
 		}
833
-	    }
833
+		}
834 834
 	}
835 835
 	
836 836
 	if ($limit != "")
837 837
 	{
838
-	    $limit_array = explode(",", $limit);
838
+		$limit_array = explode(",", $limit);
839 839
 	    
840
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
842 842
 	    
843
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
-	    {
843
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
+		{
845 845
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
846 846
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
847
-	    }
847
+		}
848 848
 	}
849 849
 	
850 850
 
@@ -875,33 +875,33 @@  discard block
 block discarded – undo
875 875
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
876 876
 
877 877
 	return $spotter_array;
878
-    }
878
+	}
879 879
 
880
-    public function deleteTrackerArchiveData()
881
-    {
880
+	public function deleteTrackerArchiveData()
881
+	{
882 882
 		global $globalArchiveKeepMonths, $globalDBdriver;
883
-                date_default_timezone_set('UTC');
884
-                if ($globalDBdriver == 'mysql') {
883
+				date_default_timezone_set('UTC');
884
+				if ($globalDBdriver == 'mysql') {
885 885
 			$query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
886 886
 		} else {
887 887
 			$query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
888 888
 		}
889
-                try {
890
-                        $sth = $this->db->prepare($query);
891
-                        $sth->execute();
892
-                } catch(PDOException $e) {
893
-                        return "error";
894
-                }
889
+				try {
890
+						$sth = $this->db->prepare($query);
891
+						$sth->execute();
892
+				} catch(PDOException $e) {
893
+						return "error";
894
+				}
895 895
 	}
896 896
 
897
-    /**
898
-    * Gets all the spotter information based on the callsign
899
-    *
900
-    * @return Array the spotter information
901
-    *
902
-    */
903
-    public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
904
-    {
897
+	/**
898
+	 * Gets all the spotter information based on the callsign
899
+	 *
900
+	 * @return Array the spotter information
901
+	 *
902
+	 */
903
+	public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
904
+	{
905 905
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
906 906
 	
907 907
 	date_default_timezone_set('UTC');
@@ -913,35 +913,35 @@  discard block
 block discarded – undo
913 913
 	
914 914
 	if ($ident != "")
915 915
 	{
916
-	    if (!is_string($ident))
917
-	    {
916
+		if (!is_string($ident))
917
+		{
918 918
 		return false;
919
-	    } else {
919
+		} else {
920 920
 		$additional_query = " AND (tracker_archive_output.ident = :ident)";
921 921
 		$query_values = array(':ident' => $ident);
922
-	    }
922
+		}
923 923
 	}
924 924
 	
925 925
 	if ($limit != "")
926 926
 	{
927
-	    $limit_array = explode(",", $limit);
927
+		$limit_array = explode(",", $limit);
928 928
 	    
929
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
931 931
 	    
932
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
-	    {
932
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
+		{
934 934
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
935 935
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
936
-	    }
936
+		}
937 937
 	}
938 938
 
939 939
 	if ($sort != "")
940 940
 	{
941
-	    $search_orderby_array = $Tracker->getOrderBy();
942
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
941
+		$search_orderby_array = $Tracker->getOrderBy();
942
+		$orderby_query = $search_orderby_array[$sort]['sql'];
943 943
 	} else {
944
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
944
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
945 945
 	}
946 946
 
947 947
 	$query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -949,17 +949,17 @@  discard block
 block discarded – undo
949 949
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
950 950
 
951 951
 	return $spotter_array;
952
-    }
952
+	}
953 953
 
954 954
 
955
-    /**
956
-    * Gets all the spotter information based on the owner
957
-    *
958
-    * @return Array the spotter information
959
-    *
960
-    */
961
-    public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
-    {
955
+	/**
956
+	 * Gets all the spotter information based on the owner
957
+	 *
958
+	 * @return Array the spotter information
959
+	 *
960
+	 */
961
+	public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
+	{
963 963
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
964 964
 	
965 965
 	date_default_timezone_set('UTC');
@@ -972,35 +972,35 @@  discard block
 block discarded – undo
972 972
 	
973 973
 	if ($owner != "")
974 974
 	{
975
-	    if (!is_string($owner))
976
-	    {
975
+		if (!is_string($owner))
976
+		{
977 977
 		return false;
978
-	    } else {
978
+		} else {
979 979
 		$additional_query = " AND (tracker_archive_output.owner_name = :owner)";
980 980
 		$query_values = array(':owner' => $owner);
981
-	    }
981
+		}
982 982
 	}
983 983
 	
984 984
 	if ($limit != "")
985 985
 	{
986
-	    $limit_array = explode(",", $limit);
986
+		$limit_array = explode(",", $limit);
987 987
 	    
988
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
-	    {
991
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
+		{
993 993
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
994 994
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
995
-	    }
995
+		}
996 996
 	}
997 997
 
998 998
 	if ($sort != "")
999 999
 	{
1000
-	    $search_orderby_array = $Tracker->getOrderBy();
1001
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1000
+		$search_orderby_array = $Tracker->getOrderBy();
1001
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1002 1002
 	} else {
1003
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1003
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1004 1004
 	}
1005 1005
 
1006 1006
 	$query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1008,16 +1008,16 @@  discard block
 block discarded – undo
1008 1008
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1009 1009
 
1010 1010
 	return $spotter_array;
1011
-    }
1012
-
1013
-    /**
1014
-    * Gets all the spotter information based on the pilot
1015
-    *
1016
-    * @return Array the spotter information
1017
-    *
1018
-    */
1019
-    public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
-    {
1011
+	}
1012
+
1013
+	/**
1014
+	 * Gets all the spotter information based on the pilot
1015
+	 *
1016
+	 * @return Array the spotter information
1017
+	 *
1018
+	 */
1019
+	public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
+	{
1021 1021
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
1022 1022
 	
1023 1023
 	date_default_timezone_set('UTC');
@@ -1036,24 +1036,24 @@  discard block
 block discarded – undo
1036 1036
 	
1037 1037
 	if ($limit != "")
1038 1038
 	{
1039
-	    $limit_array = explode(",", $limit);
1039
+		$limit_array = explode(",", $limit);
1040 1040
 	    
1041
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1043 1043
 	    
1044
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
-	    {
1044
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
+		{
1046 1046
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1047 1047
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1048
-	    }
1048
+		}
1049 1049
 	}
1050 1050
 
1051 1051
 	if ($sort != "")
1052 1052
 	{
1053
-	    $search_orderby_array = $Tracker->getOrderBy();
1054
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1053
+		$search_orderby_array = $Tracker->getOrderBy();
1054
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1055 1055
 	} else {
1056
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1056
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1057 1057
 	}
1058 1058
 
1059 1059
 	$query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1061,16 +1061,16 @@  discard block
 block discarded – undo
1061 1061
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1062 1062
 
1063 1063
 	return $spotter_array;
1064
-    }
1065
-
1066
-    /**
1067
-    * Gets all number of flight over countries
1068
-    *
1069
-    * @return Array the airline country list
1070
-    *
1071
-    */
1072
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
-    {
1064
+	}
1065
+
1066
+	/**
1067
+	 * Gets all number of flight over countries
1068
+	 *
1069
+	 * @return Array the airline country list
1070
+	 *
1071
+	 */
1072
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
+	{
1074 1074
 	global $globalDBdriver;
1075 1075
 	/*
1076 1076
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1080,14 +1080,14 @@  discard block
 block discarded – undo
1080 1080
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1081 1081
 		    FROM countries c, tracker_archive s
1082 1082
 		    WHERE c.iso2 = s.over_country ";
1083
-                if ($olderthanmonths > 0) {
1084
-            		if ($globalDBdriver == 'mysql') {
1083
+				if ($olderthanmonths > 0) {
1084
+					if ($globalDBdriver == 'mysql') {
1085 1085
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1086 1086
 			} else {
1087 1087
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1088
 			}
1089 1089
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1090
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1091 1091
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092 1092
 	if ($limit) $query .= " LIMIT 0,10";
1093 1093
       
@@ -1100,23 +1100,23 @@  discard block
 block discarded – undo
1100 1100
         
1101 1101
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1102 1102
 	{
1103
-	    $temp_array['flight_count'] = $row['nb'];
1104
-	    $temp_array['flight_country'] = $row['name'];
1105
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1106
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1107
-	    $flight_array[] = $temp_array;
1103
+		$temp_array['flight_count'] = $row['nb'];
1104
+		$temp_array['flight_country'] = $row['name'];
1105
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1106
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1107
+		$flight_array[] = $temp_array;
1108 1108
 	}
1109 1109
 	return $flight_array;
1110
-    }
1111
-
1112
-    /**
1113
-    * Gets all number of flight over countries
1114
-    *
1115
-    * @return Array the airline country list
1116
-    *
1117
-    */
1118
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
-    {
1110
+	}
1111
+
1112
+	/**
1113
+	 * Gets all number of flight over countries
1114
+	 *
1115
+	 * @return Array the airline country list
1116
+	 *
1117
+	 */
1118
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
+	{
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
1122 1122
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1126,14 +1126,14 @@  discard block
 block discarded – undo
1126 1126
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1127 1127
 		    FROM countries c, tracker_archive s, spotter_output o
1128 1128
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid ";
1129
-                if ($olderthanmonths > 0) {
1130
-            		if ($globalDBdriver == 'mysql') {
1129
+				if ($olderthanmonths > 0) {
1130
+					if ($globalDBdriver == 'mysql') {
1131 1131
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1132 1132
 			} else {
1133 1133
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1134
 			}
1135 1135
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1136
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1137 1137
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138 1138
 	if ($limit) $query .= " LIMIT 0,10";
1139 1139
       
@@ -1146,24 +1146,24 @@  discard block
 block discarded – undo
1146 1146
         
1147 1147
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1150
-	    $temp_array['flight_count'] = $row['nb'];
1151
-	    $temp_array['flight_country'] = $row['name'];
1152
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1153
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1154
-	    $flight_array[] = $temp_array;
1149
+		$temp_array['airline_icao'] = $row['airline_icao'];
1150
+		$temp_array['flight_count'] = $row['nb'];
1151
+		$temp_array['flight_country'] = $row['name'];
1152
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1153
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1154
+		$flight_array[] = $temp_array;
1155 1155
 	}
1156 1156
 	return $flight_array;
1157
-    }
1158
-
1159
-    /**
1160
-    * Gets last spotter information based on a particular callsign
1161
-    *
1162
-    * @return Array the spotter information
1163
-    *
1164
-    */
1165
-    public function getDateArchiveTrackerDataById($id,$date)
1166
-    {
1157
+	}
1158
+
1159
+	/**
1160
+	 * Gets last spotter information based on a particular callsign
1161
+	 *
1162
+	 * @return Array the spotter information
1163
+	 *
1164
+	 */
1165
+	public function getDateArchiveTrackerDataById($id,$date)
1166
+	{
1167 1167
 	$Tracker = new Tracker($this->db);
1168 1168
 	date_default_timezone_set('UTC');
1169 1169
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1171,16 +1171,16 @@  discard block
 block discarded – undo
1171 1171
 	$date = date('c',$date);
1172 1172
 	$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1173 1173
 	return $spotter_array;
1174
-    }
1175
-
1176
-    /**
1177
-    * Gets all the spotter information based on a particular callsign
1178
-    *
1179
-    * @return Array the spotter information
1180
-    *
1181
-    */
1182
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1183
-    {
1174
+	}
1175
+
1176
+	/**
1177
+	 * Gets all the spotter information based on a particular callsign
1178
+	 *
1179
+	 * @return Array the spotter information
1180
+	 *
1181
+	 */
1182
+	public function getDateArchiveTrackerDataByIdent($ident,$date)
1183
+	{
1184 1184
 	$Tracker = new Tracker($this->db);
1185 1185
 	date_default_timezone_set('UTC');
1186 1186
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1188,16 +1188,16 @@  discard block
 block discarded – undo
1188 1188
 	$date = date('c',$date);
1189 1189
 	$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1190 1190
 	return $spotter_array;
1191
-    }
1192
-
1193
-    /**
1194
-    * Gets all the spotter information based on the airport
1195
-    *
1196
-    * @return Array the spotter information
1197
-    *
1198
-    */
1199
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
-    {
1191
+	}
1192
+
1193
+	/**
1194
+	 * Gets all the spotter information based on the airport
1195
+	 *
1196
+	 * @return Array the spotter information
1197
+	 *
1198
+	 */
1199
+	public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
+	{
1201 1201
 	global $global_query;
1202 1202
 	$Tracker = new Tracker($this->db);
1203 1203
 	date_default_timezone_set('UTC');
@@ -1208,35 +1208,35 @@  discard block
 block discarded – undo
1208 1208
 	
1209 1209
 	if ($airport != "")
1210 1210
 	{
1211
-	    if (!is_string($airport))
1212
-	    {
1211
+		if (!is_string($airport))
1212
+		{
1213 1213
 		return false;
1214
-	    } else {
1214
+		} else {
1215 1215
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))";
1216 1216
 		$query_values = array(':airport' => $airport);
1217
-	    }
1217
+		}
1218 1218
 	}
1219 1219
 	
1220 1220
 	if ($limit != "")
1221 1221
 	{
1222
-	    $limit_array = explode(",", $limit);
1222
+		$limit_array = explode(",", $limit);
1223 1223
 	    
1224
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1226 1226
 	    
1227
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
-	    {
1227
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
+		{
1229 1229
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1230 1230
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1231
-	    }
1231
+		}
1232 1232
 	}
1233 1233
 	
1234 1234
 	if ($sort != "")
1235 1235
 	{
1236
-	    $search_orderby_array = $Tracker->getOrderBy();
1237
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1236
+		$search_orderby_array = $Tracker->getOrderBy();
1237
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1238 1238
 	} else {
1239
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1239
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1240 1240
 	}
1241 1241
 
1242 1242
 	$query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1244,6 +1244,6 @@  discard block
 block discarded – undo
1244 1244
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1245 1245
 
1246 1246
 	return $spotter_array;
1247
-    }
1247
+	}
1248 1248
 }
1249 1249
 ?>
1250 1250
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -14,33 +14,33 @@  discard block
 block discarded – undo
14 14
 	* @param Array $filter the filter
15 15
 	* @return Array the SQL part
16 16
 	*/
17
-	public function getFilter($filter = array(),$where = false,$and = false) {
17
+	public function getFilter($filter = array(), $where = false, $and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
20 20
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 				$filters = $globalStatsFilters[$globalFilterName];
23 23
 			} else {
24
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
24
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
25 25
 			}
26 26
 		}
27 27
 		if (isset($filter[0]['source'])) {
28
-			$filters = array_merge($filters,$filter);
28
+			$filters = array_merge($filters, $filter);
29 29
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
31 31
 		$filter_query_join = '';
32 32
 		$filter_query_where = '';
33
-		foreach($filters as $flt) {
33
+		foreach ($filters as $flt) {
34 34
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
35 35
 				if (isset($flt['source'])) {
36
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
36
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
37 37
 				} else {
38
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
38
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
39 39
 				}
40 40
 			}
41 41
 		}
42 42
 		if (isset($filter['source']) && !empty($filter['source'])) {
43
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
43
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
44 44
 		}
45 45
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
46 46
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -68,38 +68,38 @@  discard block
 block discarded – undo
68 68
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'";
69 69
 				}
70 70
 			}
71
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
71
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
72 72
 		}
73 73
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
75 75
 		}
76 76
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77 77
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
78 78
 		if ($filter_query_where != '') {
79
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
79
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
80 80
 		}
81 81
 		$filter_query = $filter_query_join.$filter_query_where;
82 82
 		return $filter_query;
83 83
 	}
84 84
 
85 85
 	// tracker_archive
86
-	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') {
86
+	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
87 87
 		require_once(dirname(__FILE__).'/class.Tracker.php');
88 88
 		if ($over_country == '') {
89 89
 			$Tracker = new Tracker($this->db);
90
-			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
90
+			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude);
91 91
 			if (!empty($data_country)) $country = $data_country['iso2'];
92 92
 			else $country = '';
93 93
 		} else $country = $over_country;
94 94
 		// Route is not added in tracker_archive
95
-		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
95
+		$query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
96 96
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
97
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':comment' => $comment,':type' => $type);
97
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':comment' => $comment, ':type' => $type);
98 98
 		try {
99 99
 			$sth = $this->db->prepare($query);
100 100
 			$sth->execute($query_values);
101 101
 			$sth->closeCursor();
102
-		} catch(PDOException $e) {
102
+		} catch (PDOException $e) {
103 103
 			return "error : ".$e->getMessage();
104 104
 		}
105 105
 		return "success";
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 
120 120
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
121 121
                 //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
122
-                $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
122
+                $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
123 123
 
124
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
124
+                $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident));
125 125
 
126 126
                 return $spotter_array;
127 127
         }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
141 141
                 //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
142 142
                 //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
143
-                $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
143
+                $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
144 144
 
145 145
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
146 146
                   /*
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 }
154 154
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
155 155
                 */
156
-                $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
156
+                $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id));
157 157
 
158 158
                 return $spotter_array;
159 159
         }
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
         * @return Array the spotter information
165 165
         *
166 166
         */
167
-        public function getAllArchiveTrackerDataById($id,$date = '')
167
+        public function getAllArchiveTrackerDataById($id, $date = '')
168 168
 	{
169 169
                 date_default_timezone_set('UTC');
170 170
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
171
-                if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
-                else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
171
+                if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
+                else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c', $date)."' ORDER BY date";
173 173
 
174 174
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
175 175
 
176 176
                 try {
177 177
                         $sth = $this->db->prepare($query);
178 178
                         $sth->execute(array(':id' => $id));
179
-                } catch(PDOException $e) {
179
+                } catch (PDOException $e) {
180 180
                         echo $e->getMessage();
181 181
                         die;
182 182
                 }
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
         {
196 196
                 date_default_timezone_set('UTC');
197 197
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
198
-                $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
198
+                $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
199 199
 
200 200
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
201 201
 
202 202
                 try {
203 203
                         $sth = $this->db->prepare($query);
204 204
                         $sth->execute(array(':id' => $id));
205
-                } catch(PDOException $e) {
205
+                } catch (PDOException $e) {
206 206
                         echo $e->getMessage();
207 207
                         die;
208 208
                 }
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
                 date_default_timezone_set('UTC');
225 225
 
226 226
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
227
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
227
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
228 228
 
229 229
                 try {
230 230
                         $sth = $this->db->prepare($query);
231 231
                         $sth->execute(array(':ident' => $ident));
232
-                } catch(PDOException $e) {
232
+                } catch (PDOException $e) {
233 233
                         echo $e->getMessage();
234 234
                         die;
235 235
                 }
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
                 date_default_timezone_set('UTC');
251 251
 
252 252
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
253
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
253
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
254 254
 
255 255
                 try {
256 256
                         $sth = $this->db->prepare($query);
257 257
                         $sth->execute(array(':id' => $id));
258
-                } catch(PDOException $e) {
258
+                } catch (PDOException $e) {
259 259
                         echo $e->getMessage();
260 260
                         die;
261 261
                 }
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
                 date_default_timezone_set('UTC');
277 277
 
278 278
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
279
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
279
+                $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
280 280
 
281 281
                 try {
282 282
                         $sth = $this->db->prepare($query);
283 283
                         $sth->execute(array(':id' => $id));
284
-                } catch(PDOException $e) {
284
+                } catch (PDOException $e) {
285 285
                         echo $e->getMessage();
286 286
                         die;
287 287
                 }
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
                 date_default_timezone_set('UTC');
304 304
 
305 305
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
306
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
306
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
307 307
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
308 308
 
309 309
                 try {
310 310
                         $sth = $this->db->prepare($query);
311 311
                         $sth->execute(array(':ident' => $ident));
312
-                } catch(PDOException $e) {
312
+                } catch (PDOException $e) {
313 313
                         echo $e->getMessage();
314 314
                         die;
315 315
                 }
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
         * @return Array the spotter information
327 327
         *
328 328
         */
329
-        public function getTrackerArchiveData($ident,$famtrackid,$date)
329
+        public function getTrackerArchiveData($ident, $famtrackid, $date)
330 330
         {
331 331
     		$Tracker = new Tracker($this->db);
332 332
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
333
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
334 334
 
335
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
335
+                $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%'));
336 336
 
337 337
                 return $spotter_array;
338 338
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 		try {
349 349
 			$sth = $this->db->prepare($query);
350 350
 			$sth->execute();
351
-		} catch(PDOException $e) {
351
+		} catch (PDOException $e) {
352 352
 			echo $e->getMessage();
353 353
 			die;
354 354
 		}
@@ -360,24 +360,24 @@  discard block
 block discarded – undo
360 360
         * @return Array the spotter information
361 361
         *
362 362
         */
363
-        public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
363
+        public function getMinLiveTrackerData($begindate, $enddate, $filter = array())
364 364
         {
365 365
                 global $globalDBdriver, $globalLiveInterval;
366 366
                 date_default_timezone_set('UTC');
367 367
 
368 368
                 $filter_query = '';
369 369
                 if (isset($filter['source']) && !empty($filter['source'])) {
370
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
370
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
371 371
                 }
372 372
                 // Use spotter_output also ?
373 373
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
374
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
375 375
                 }
376 376
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377 377
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
378 378
                 }
379 379
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
380
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
381 381
                 }
382 382
 
383 383
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 						GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid 
397 397
 				    AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
398 398
 */
399
-			$query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
399
+			$query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
400 400
 				    FROM tracker_archive 
401 401
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
402 402
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
403 403
                         	    '.$filter_query.' ORDER BY famtrackid';
404 404
                 } else {
405 405
                         //$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
406
-                        $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
406
+                        $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
407 407
                         	    FROM tracker_archive 
408 408
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
409 409
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                 try {
414 414
                         $sth = $this->db->prepare($query);
415 415
                         $sth->execute();
416
-                } catch(PDOException $e) {
416
+                } catch (PDOException $e) {
417 417
                         echo $e->getMessage();
418 418
                         die;
419 419
                 }
@@ -428,24 +428,24 @@  discard block
 block discarded – undo
428 428
         * @return Array the spotter information
429 429
         *
430 430
         */
431
-        public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
431
+        public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array())
432 432
         {
433 433
                 global $globalDBdriver, $globalLiveInterval;
434 434
                 date_default_timezone_set('UTC');
435 435
 
436 436
                 $filter_query = '';
437 437
                 if (isset($filter['source']) && !empty($filter['source'])) {
438
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
438
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
439 439
                 }
440 440
                 // Should use spotter_output also ?
441 441
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
442
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
443 443
                 }
444 444
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445 445
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
446 446
                 }
447 447
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
448
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
449 449
                 }
450 450
 
451 451
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
                     		    FROM tracker_archive 
456 456
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
457 457
 			*/
458
-			$query  = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
458
+			$query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
459 459
 				    FROM tracker_archive_output 
460 460
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao 
461 461
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
471 471
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
472 472
                         */
473
-                        $query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
473
+                        $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
474 474
                         	    FROM tracker_archive_output 
475 475
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
476 476
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
                 try {
483 483
                         $sth = $this->db->prepare($query);
484 484
                         $sth->execute();
485
-                } catch(PDOException $e) {
485
+                } catch (PDOException $e) {
486 486
                         echo $e->getMessage();
487 487
                         die;
488 488
                 }
@@ -497,23 +497,23 @@  discard block
 block discarded – undo
497 497
         * @return Array the spotter information
498 498
         *
499 499
         */
500
-        public function getLiveTrackerCount($begindate,$enddate,$filter = array())
500
+        public function getLiveTrackerCount($begindate, $enddate, $filter = array())
501 501
         {
502 502
                 global $globalDBdriver, $globalLiveInterval;
503 503
                 date_default_timezone_set('UTC');
504 504
 
505 505
                 $filter_query = '';
506 506
                 if (isset($filter['source']) && !empty($filter['source'])) {
507
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
507
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
508 508
                 }
509 509
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
510
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
511 511
                 }
512 512
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513 513
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
514 514
                 }
515 515
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
516
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
517 517
                 }
518 518
 
519 519
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
                 try {
529 529
                         $sth = $this->db->prepare($query);
530 530
                         $sth->execute();
531
-                } catch(PDOException $e) {
531
+                } catch (PDOException $e) {
532 532
                         echo $e->getMessage();
533 533
                         die;
534 534
                 }
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     * @return Array the spotter information
549 549
     *
550 550
     */
551
-    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
551
+    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
552 552
     {
553 553
 	global $globalTimezone, $globalDBdriver;
554 554
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	        
571 571
 		$q_array = explode(" ", $q);
572 572
 		
573
-		foreach ($q_array as $q_item){
573
+		foreach ($q_array as $q_item) {
574 574
 		    $additional_query .= " AND (";
575 575
 		    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
576 576
 		    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	
603 603
 	if ($registration != "")
604 604
 	{
605
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
605
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
606 606
 	    if (!is_string($registration))
607 607
 	    {
608 608
 		return false;
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 	
614 614
 	if ($aircraft_icao != "")
615 615
 	{
616
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
616
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
617 617
 	    if (!is_string($aircraft_icao))
618 618
 	    {
619 619
 		return false;
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 	
625 625
 	if ($aircraft_manufacturer != "")
626 626
 	{
627
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
627
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
628 628
 	    if (!is_string($aircraft_manufacturer))
629 629
 	    {
630 630
 		return false;
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 	
646 646
 	if ($airline_icao != "")
647 647
 	{
648
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
648
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
649 649
 	    if (!is_string($airline_icao))
650 650
 	    {
651 651
 		return false;
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 	
657 657
 	if ($airline_country != "")
658 658
 	{
659
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
659
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
660 660
 	    if (!is_string($airline_country))
661 661
 	    {
662 662
 		return false;
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	
668 668
 	if ($airline_type != "")
669 669
 	{
670
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
670
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
671 671
 	    if (!is_string($airline_type))
672 672
 	    {
673 673
 		return false;
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 	
690 690
 	if ($airport != "")
691 691
 	{
692
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
692
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
693 693
 	    if (!is_string($airport))
694 694
 	    {
695 695
 		return false;
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	
701 701
 	if ($airport_country != "")
702 702
 	{
703
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
703
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
704 704
 	    if (!is_string($airport_country))
705 705
 	    {
706 706
 		return false;
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
     
712 712
 	if ($callsign != "")
713 713
 	{
714
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
714
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
715 715
 	    if (!is_string($callsign))
716 716
 	    {
717 717
 		return false;
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 		$translate = $Translation->ident2icao($callsign);
720 720
 		if ($translate != $callsign) {
721 721
 			$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
722
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
722
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
723 723
 		} else {
724 724
 			$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
725 725
 		}
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 
729 729
 	if ($owner != "")
730 730
 	{
731
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
731
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
732 732
 	    if (!is_string($owner))
733 733
 	    {
734 734
 		return false;
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 
740 740
 	if ($pilot_name != "")
741 741
 	{
742
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
742
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
743 743
 	    if (!is_string($pilot_name))
744 744
 	    {
745 745
 		return false;
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 	
751 751
 	if ($pilot_id != "")
752 752
 	{
753
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
753
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
754 754
 	    if (!is_string($pilot_id))
755 755
 	    {
756 756
 		return false;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	
762 762
 	if ($departure_airport_route != "")
763 763
 	{
764
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
764
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
765 765
 	    if (!is_string($departure_airport_route))
766 766
 	    {
767 767
 		return false;
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 	
773 773
 	if ($arrival_airport_route != "")
774 774
 	{
775
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
775
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
776 776
 	    if (!is_string($arrival_airport_route))
777 777
 	    {
778 778
 		return false;
@@ -785,8 +785,8 @@  discard block
 block discarded – undo
785 785
 	{
786 786
 	    $altitude_array = explode(",", $altitude);
787 787
 	    
788
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
789
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
790 790
 	    
791 791
 
792 792
 	    if ($altitude_array[1] != "")
@@ -804,8 +804,8 @@  discard block
 block discarded – undo
804 804
 	{
805 805
 	    $date_array = explode(",", $date_posted);
806 806
 	    
807
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
808
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
809 809
 	    
810 810
 	    if ($globalTimezone != '') {
811 811
 		date_default_timezone_set($globalTimezone);
@@ -837,8 +837,8 @@  discard block
 block discarded – undo
837 837
 	{
838 838
 	    $limit_array = explode(",", $limit);
839 839
 	    
840
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
841
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
842 842
 	    
843 843
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844 844
 	    {
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	
850 850
 
851 851
 	if ($origLat != "" && $origLon != "" && $dist != "") {
852
-		$dist = number_format($dist*0.621371,2,'.','');
853
-		$query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
852
+		$dist = number_format($dist*0.621371, 2, '.', '');
853
+		$query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
854 854
                           FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
855 855
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
856 856
 	} else {
@@ -867,12 +867,12 @@  discard block
 block discarded – undo
867 867
 			$additional_query .= " AND (tracker_archive_output.waypoints <> '')";
868 868
 		}
869 869
 
870
-		$query  = "SELECT tracker_archive_output.* FROM tracker_archive_output 
870
+		$query = "SELECT tracker_archive_output.* FROM tracker_archive_output 
871 871
 		    WHERE tracker_archive_output.ident <> '' 
872 872
 		    ".$additional_query."
873 873
 		    ".$filter_query.$orderby_query;
874 874
 	}
875
-	$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
875
+	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
876 876
 
877 877
 	return $spotter_array;
878 878
     }
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
                 try {
890 890
                         $sth = $this->db->prepare($query);
891 891
                         $sth->execute();
892
-                } catch(PDOException $e) {
892
+                } catch (PDOException $e) {
893 893
                         return "error";
894 894
                 }
895 895
 	}
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 	{
927 927
 	    $limit_array = explode(",", $limit);
928 928
 	    
929
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
930
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
931 931
 	    
932 932
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933 933
 	    {
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 	$query_values = array();
969 969
 	$limit_query = '';
970 970
 	$additional_query = '';
971
-	$filter_query = $this->getFilter($filter,true,true);
971
+	$filter_query = $this->getFilter($filter, true, true);
972 972
 	
973 973
 	if ($owner != "")
974 974
 	{
@@ -985,8 +985,8 @@  discard block
 block discarded – undo
985 985
 	{
986 986
 	    $limit_array = explode(",", $limit);
987 987
 	    
988
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
989
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991 991
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992 992
 	    {
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 	$query_values = array();
1027 1027
 	$limit_query = '';
1028 1028
 	$additional_query = '';
1029
-	$filter_query = $this->getFilter($filter,true,true);
1029
+	$filter_query = $this->getFilter($filter, true, true);
1030 1030
 	
1031 1031
 	if ($pilot != "")
1032 1032
 	{
@@ -1038,8 +1038,8 @@  discard block
 block discarded – undo
1038 1038
 	{
1039 1039
 	    $limit_array = explode(",", $limit);
1040 1040
 	    
1041
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1042
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1043 1043
 	    
1044 1044
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045 1045
 	    {
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
     * @return Array the airline country list
1070 1070
     *
1071 1071
     */
1072
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1072
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1073 1073
     {
1074 1074
 	global $globalDBdriver;
1075 1075
 	/*
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 	$flight_array = array();
1099 1099
 	$temp_array = array();
1100 1100
         
1101
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1101
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1102 1102
 	{
1103 1103
 	    $temp_array['flight_count'] = $row['nb'];
1104 1104
 	    $temp_array['flight_country'] = $row['name'];
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
     * @return Array the airline country list
1116 1116
     *
1117 1117
     */
1118
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1118
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1119 1119
     {
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 	$flight_array = array();
1145 1145
 	$temp_array = array();
1146 1146
         
1147
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1147
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149 1149
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1150 1150
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1162,14 +1162,14 @@  discard block
 block discarded – undo
1162 1162
     * @return Array the spotter information
1163 1163
     *
1164 1164
     */
1165
-    public function getDateArchiveTrackerDataById($id,$date)
1165
+    public function getDateArchiveTrackerDataById($id, $date)
1166 1166
     {
1167 1167
 	$Tracker = new Tracker($this->db);
1168 1168
 	date_default_timezone_set('UTC');
1169 1169
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1170
-	$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1171
-	$date = date('c',$date);
1172
-	$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1170
+	$query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1171
+	$date = date('c', $date);
1172
+	$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1173 1173
 	return $spotter_array;
1174 1174
     }
1175 1175
 
@@ -1179,14 +1179,14 @@  discard block
 block discarded – undo
1179 1179
     * @return Array the spotter information
1180 1180
     *
1181 1181
     */
1182
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1182
+    public function getDateArchiveTrackerDataByIdent($ident, $date)
1183 1183
     {
1184 1184
 	$Tracker = new Tracker($this->db);
1185 1185
 	date_default_timezone_set('UTC');
1186 1186
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1187
-	$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1188
-	$date = date('c',$date);
1189
-	$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1187
+	$query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1188
+	$date = date('c', $date);
1189
+	$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1190 1190
 	return $spotter_array;
1191 1191
     }
1192 1192
 
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
     * @return Array the spotter information
1197 1197
     *
1198 1198
     */
1199
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1199
+    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1200 1200
     {
1201 1201
 	global $global_query;
1202 1202
 	$Tracker = new Tracker($this->db);
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 	$query_values = array();
1205 1205
 	$limit_query = '';
1206 1206
 	$additional_query = '';
1207
-	$filter_query = $this->getFilter($filters,true,true);
1207
+	$filter_query = $this->getFilter($filters, true, true);
1208 1208
 	
1209 1209
 	if ($airport != "")
1210 1210
 	{
@@ -1221,8 +1221,8 @@  discard block
 block discarded – undo
1221 1221
 	{
1222 1222
 	    $limit_array = explode(",", $limit);
1223 1223
 	    
1224
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1225
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1226 1226
 	    
1227 1227
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228 1228
 	    {
Please login to merge, or discard this patch.
Braces   +42 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection. (TrackerArchive)');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection. (TrackerArchive)');
11
+		}
10 12
 	}
11 13
 
12 14
 	/**
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 		if (isset($filter[0]['source'])) {
28 30
 			$filters = array_merge($filters,$filter);
29 31
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
31 35
 		$filter_query_join = '';
32 36
 		$filter_query_where = '';
33 37
 		foreach($filters as $flt) {
@@ -73,8 +77,11 @@  discard block
 block discarded – undo
73 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74 78
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
75 79
 		}
76
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
80
+		if ($filter_query_where == '' && $where) {
81
+			$filter_query_where = ' WHERE';
82
+		} elseif ($filter_query_where != '' && $and) {
83
+			$filter_query_where .= ' AND';
84
+		}
78 85
 		if ($filter_query_where != '') {
79 86
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
80 87
 		}
@@ -88,9 +95,14 @@  discard block
 block discarded – undo
88 95
 		if ($over_country == '') {
89 96
 			$Tracker = new Tracker($this->db);
90 97
 			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
91
-			if (!empty($data_country)) $country = $data_country['iso2'];
92
-			else $country = '';
93
-		} else $country = $over_country;
98
+			if (!empty($data_country)) {
99
+				$country = $data_country['iso2'];
100
+			} else {
101
+				$country = '';
102
+			}
103
+		} else {
104
+			$country = $over_country;
105
+		}
94 106
 		// Route is not added in tracker_archive
95 107
 		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
96 108
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
@@ -168,8 +180,11 @@  discard block
 block discarded – undo
168 180
 	{
169 181
                 date_default_timezone_set('UTC');
170 182
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
171
-                if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
-                else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
183
+                if ($date == '') {
184
+                	$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
185
+                } else {
186
+                	$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
187
+                }
173 188
 
174 189
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
175 190
 
@@ -593,7 +608,9 @@  discard block
 block discarded – undo
593 608
 		    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
594 609
 		    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
595 610
 		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
611
+		    if ($translate != $q_item) {
612
+		    	$additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
613
+		    }
597 614
 		    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
598 615
 		    $additional_query .= ")";
599 616
 		}
@@ -811,7 +828,9 @@  discard block
 block discarded – undo
811 828
 		date_default_timezone_set($globalTimezone);
812 829
 		$datetime = new DateTime();
813 830
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
831
+	    } else {
832
+	    	$offset = '+00:00';
833
+	    }
815 834
 
816 835
 
817 836
 	    if ($date_array[1] != "")
@@ -1087,9 +1106,13 @@  discard block
 block discarded – undo
1087 1106
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1107
 			}
1089 1108
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1109
+                if ($sincedate != '') {
1110
+                	$query .= "AND date > '".$sincedate."' ";
1111
+                }
1091 1112
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092
-	if ($limit) $query .= " LIMIT 0,10";
1113
+	if ($limit) {
1114
+		$query .= " LIMIT 0,10";
1115
+	}
1093 1116
       
1094 1117
 	
1095 1118
 	$sth = $this->db->prepare($query);
@@ -1133,9 +1156,13 @@  discard block
 block discarded – undo
1133 1156
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1157
 			}
1135 1158
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1159
+                if ($sincedate != '') {
1160
+                	$query .= "AND s.date > '".$sincedate."' ";
1161
+                }
1137 1162
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138
-	if ($limit) $query .= " LIMIT 0,10";
1163
+	if ($limit) {
1164
+		$query .= " LIMIT 0,10";
1165
+	}
1139 1166
       
1140 1167
 	
1141 1168
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
require/class.MapMatching.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 		$gpx .= '<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpsies="http://www.gpsies.com/GPX/1/0" creator="GPSies http://www.gpsies.com - Sendl.-O&amp;apos;sch-heim" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.gpsies.com/GPX/1/0 http://www.gpsies.com/gpsies.xsd">';
45 45
 		$gpx .= '<trk>';
46 46
 		$gpx .= '<trkseg>';
47
-		foreach($spotter_history_array as $spotter_data) {
48
-			$gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">';
49
-			$gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>';
50
-			$gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>';
47
+		foreach ($spotter_history_array as $spotter_data) {
48
+			$gpx .= '<trkpt lat="'.sprintf("%.8f", $spotter_data['latitude']).'" lon="'.sprintf("%.8f", $spotter_data['longitude']).'">';
49
+			$gpx .= '<ele>'.sprintf("%.6f", $spotter_data['altitude']).'</ele>';
50
+			$gpx .= '<time>'.date("Y-m-d\TH:i:s\Z", strtotime($spotter_data['date'])).'</time>';
51 51
 			$gpx .= '</trkpt>';
52 52
 		}
53 53
 		$gpx .= '</trkseg>';
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 		global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId;
85 85
 		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
86 86
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
87
-		if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
87
+		if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
88 88
 		$data = $this->create_gpx($spotter_history_array);
89 89
 		$url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true';
90 90
 		$Common = new Common();
91
-		$matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml','Accept: application/json'));
92
-		$matching = json_decode($matching,true);
91
+		$matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml', 'Accept: application/json'));
92
+		$matching = json_decode($matching, true);
93 93
 		if (isset($matching['diary']['entries'][0]['route']['links'])) {
94 94
 			$spotter_history_array = array();
95 95
 			foreach ($matching['diary']['entries'][0]['route']['links'] as $match) {
96 96
 				if (isset($match['wpts'])) {
97 97
 					foreach ($match['wpts'] as $coord) {
98
-						$spotter_history_array[] = array('longitude' => $coord['x'],'latitude' => $coord['y']);
98
+						$spotter_history_array[] = array('longitude' => $coord['x'], 'latitude' => $coord['y']);
99 99
 					}
100 100
 				}
101 101
 			}
@@ -115,22 +115,22 @@  discard block
 block discarded – undo
115 115
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
116 116
 		$spotter_history_initial_array = array();
117 117
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
118
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
119
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
118
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
119
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
120 120
 		}
121 121
 		$data = $this->create_gpx($spotter_history_array);
122 122
 		$url = 'https://graphhopper.com/api/1/match?vehicle=car&points_encoded=0&instructions=false&key='.$globalGraphHopperKey;
123 123
 		$Common = new Common();
124
-		$matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml'));
125
-		$matching = json_decode($matching,true);
124
+		$matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml'));
125
+		$matching = json_decode($matching, true);
126 126
 		if (isset($matching['paths'][0]['points']['coordinates'])) {
127 127
 			$spotter_history_array = array();
128 128
 			foreach ($matching['paths'][0]['points']['coordinates'] as $match) {
129 129
 				$coord = $match;
130
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
130
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
131 131
 			}
132 132
 		}
133
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
133
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
134 134
 		$spotter_history_array[0]['mapmatching_engine'] = 'graphhopper';
135 135
 		return $spotter_history_array;
136 136
 	}
@@ -146,23 +146,23 @@  discard block
 block discarded – undo
146 146
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
147 147
 		$spotter_history_initial_array = array();
148 148
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
149
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
150
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
149
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
150
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
151 151
 		}
152 152
 		$data = $this->create_gpx($spotter_history_array);
153 153
 		$url = 'https://mapmatching.flightairmap.com/api/1/match?vehicle=car&points_encoded=0&instructions=false';
154 154
 		//$url = 'https://mapmatching.flightairmap.com/api/1/match?vehicle=car&points_encoded=0';
155 155
 		$Common = new Common();
156
-		$matching = $Common->getData($url,'post',$data,array('Content-Type: application/gpx+xml'));
157
-		$matching = json_decode($matching,true);
156
+		$matching = $Common->getData($url, 'post', $data, array('Content-Type: application/gpx+xml'));
157
+		$matching = json_decode($matching, true);
158 158
 		if (isset($matching['paths'][0]['points']['coordinates'])) {
159 159
 			$spotter_history_array = array();
160 160
 			foreach ($matching['paths'][0]['points']['coordinates'] as $match) {
161 161
 				$coord = $match;
162
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
162
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
163 163
 			}
164 164
 		}
165
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
165
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
166 166
 		$spotter_history_array[0]['mapmatching_engine'] = 'fam';
167 167
 		return $spotter_history_array;
168 168
 	}
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
179 179
 		$spotter_history_initial_array = array();
180 180
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
181
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
182
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
181
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
182
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
183 183
 		}
184 184
 		$coord = '';
185 185
 		$ts = '';
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 		$url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore';
196 196
 		$Common = new Common();
197 197
 		$matching = $Common->getData($url);
198
-		$matching  = json_decode($matching,true);
198
+		$matching = json_decode($matching, true);
199 199
 		if (isset($matching['matchings'][0]['geometry']['coordinates'])) {
200 200
 			$spotter_history_array = array();
201 201
 			foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) {
202 202
 				$coord = $match;
203
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
203
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
204 204
 			}
205 205
 		}
206
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
206
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
207 207
 		$spotter_history_array[0]['mapmatching_engine'] = 'osmr';
208 208
 		return $spotter_history_array;
209 209
 	}
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 		if (count($spotter_history_array) < 2) return $spotter_history_array;
220 220
 		$spotter_history_initial_array = array();
221 221
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
222
-			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
223
-			$spotter_history_initial_array = array_slice($spotter_history_array,0,count($spotter_history_array)-$globalMapMatchingMaxPts);
222
+			$spotter_history_array = array_slice($spotter_history_array, -$globalMapMatchingMaxPts);
223
+			$spotter_history_initial_array = array_slice($spotter_history_array, 0, count($spotter_history_array) - $globalMapMatchingMaxPts);
224 224
 		}
225 225
 		$coord = '';
226 226
 		$ts = '';
@@ -237,15 +237,15 @@  discard block
 block discarded – undo
237 237
 		$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'&timestamps='.$ts.'&overview=full&tidy=true&geometries=geojson';
238 238
 		$Common = new Common();
239 239
 		$matching = $Common->getData($url);
240
-		$matching  = json_decode($matching,true);
240
+		$matching = json_decode($matching, true);
241 241
 		if (isset($matching['matchings'][0]['geometry']['coordinates'])) {
242 242
 			$spotter_history_array = array();
243 243
 			foreach ($matching['matchings'][0]['geometry']['coordinates'] as $match) {
244 244
 				$coord = $match;
245
-				$spotter_history_array[] = array('longitude' => $coord[0],'latitude' => $coord[1]);
245
+				$spotter_history_array[] = array('longitude' => $coord[0], 'latitude' => $coord[1]);
246 246
 			}
247 247
 		}
248
-		$spotter_history_array = array_merge($spotter_history_initial_array,$spotter_history_array);
248
+		$spotter_history_array = array_merge($spotter_history_initial_array, $spotter_history_array);
249 249
 		$spotter_history_array[0]['mapmatching_engine'] = 'mapbox';
250 250
 		return $spotter_history_array;
251 251
 	}
Please login to merge, or discard this patch.
Braces   +51 added lines, -17 removed lines patch added patch discarded remove patch
@@ -82,9 +82,15 @@  discard block
 block discarded – undo
82 82
 
83 83
 	public function TrackMatching($spotter_history_array) {
84 84
 		global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId;
85
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
86
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
87
-		if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
85
+		if (!isset($globalMapMatchingMaxPts)) {
86
+			$globalMapMatchingMaxPts = 100;
87
+		}
88
+		if (count($spotter_history_array) < 2) {
89
+			return $spotter_history_array;
90
+		}
91
+		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
92
+			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
93
+		}
88 94
 		$data = $this->create_gpx($spotter_history_array);
89 95
 		$url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true';
90 96
 		$Common = new Common();
@@ -111,8 +117,12 @@  discard block
 block discarded – undo
111 117
 	*/
112 118
 	public function GraphHopper($spotter_history_array) {
113 119
 		global $globalMapMatchingMaxPts, $globalGraphHopperKey;
114
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
115
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
120
+		if (!isset($globalMapMatchingMaxPts)) {
121
+			$globalMapMatchingMaxPts = 100;
122
+		}
123
+		if (count($spotter_history_array) < 2) {
124
+			return $spotter_history_array;
125
+		}
116 126
 		$spotter_history_initial_array = array();
117 127
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
118 128
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -142,8 +152,12 @@  discard block
 block discarded – undo
142 152
 	*/
143 153
 	public function FAMMapMatching($spotter_history_array) {
144 154
 		global $globalMapMatchingMaxPts, $globalGraphHopperKey;
145
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
146
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
155
+		if (!isset($globalMapMatchingMaxPts)) {
156
+			$globalMapMatchingMaxPts = 100;
157
+		}
158
+		if (count($spotter_history_array) < 2) {
159
+			return $spotter_history_array;
160
+		}
147 161
 		$spotter_history_initial_array = array();
148 162
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
149 163
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -174,8 +188,12 @@  discard block
 block discarded – undo
174 188
 	*/
175 189
 	public function osmr($spotter_history_array) {
176 190
 		global $globalMapMatchingMaxPts;
177
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 50;
178
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
191
+		if (!isset($globalMapMatchingMaxPts)) {
192
+			$globalMapMatchingMaxPts = 50;
193
+		}
194
+		if (count($spotter_history_array) < 2) {
195
+			return $spotter_history_array;
196
+		}
179 197
 		$spotter_history_initial_array = array();
180 198
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
181 199
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -185,11 +203,17 @@  discard block
 block discarded – undo
185 203
 		$ts = '';
186 204
 		$rd = '';
187 205
 		foreach ($spotter_history_array as $spotter_data) {
188
-			if ($coord != '') $coord .= ';';
206
+			if ($coord != '') {
207
+				$coord .= ';';
208
+			}
189 209
 			$coord .= $spotter_data['longitude'].','.$spotter_data['latitude'];
190
-			if ($ts != '') $ts .= ';';
210
+			if ($ts != '') {
211
+				$ts .= ';';
212
+			}
191 213
 			$ts .= strtotime($spotter_data['date']);
192
-			if ($rd != '') $rd .= ';';
214
+			if ($rd != '') {
215
+				$rd .= ';';
216
+			}
193 217
 			$rd .= '20';
194 218
 		}
195 219
 		$url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore';
@@ -215,8 +239,12 @@  discard block
 block discarded – undo
215 239
 	*/
216 240
 	public function mapbox($spotter_history_array) {
217 241
 		global $globalMapMatchingMaxPts, $globalMapboxToken;
218
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 60;
219
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
242
+		if (!isset($globalMapMatchingMaxPts)) {
243
+			$globalMapMatchingMaxPts = 60;
244
+		}
245
+		if (count($spotter_history_array) < 2) {
246
+			return $spotter_history_array;
247
+		}
220 248
 		$spotter_history_initial_array = array();
221 249
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
222 250
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -226,11 +254,17 @@  discard block
 block discarded – undo
226 254
 		$ts = '';
227 255
 		$rd = '';
228 256
 		foreach ($spotter_history_array as $spotter_data) {
229
-			if ($coord != '') $coord .= ';';
257
+			if ($coord != '') {
258
+				$coord .= ';';
259
+			}
230 260
 			$coord .= $spotter_data['longitude'].','.$spotter_data['latitude'];
231
-			if ($ts != '') $ts .= ';';
261
+			if ($ts != '') {
262
+				$ts .= ';';
263
+			}
232 264
 			$ts .= strtotime($spotter_data['date']);
233
-			if ($rd != '') $rd .= ';';
265
+			if ($rd != '') {
266
+				$rd .= ';';
267
+			}
234 268
 			$rd .= '20';
235 269
 		}
236 270
 		//$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'&timestamps='.$ts.'&overview=full&tidy=true&geometries=geojson&radiuses='.$rd;
Please login to merge, or discard this patch.
require/class.TrackerLive.php 2 patches
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
39
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
40 40
 				} else {
41
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
41
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
73 73
 				}
74 74
 			}
75
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
75
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
76 76
 		}
77 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
79 79
 		}
80 80
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81 81
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
82 82
 		if ($filter_query_where != '') {
83
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
84 84
 		}
85 85
 		$filter_query = $filter_query_join.$filter_query_where;
86 86
 		return $filter_query;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 		if ($limit != '')
104 104
 		{
105 105
 			$limit_array = explode(',', $limit);
106
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
107
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
107
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
108 108
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
109 109
 			{
110 110
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		} else {
128 128
 			$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query;
129 129
 		}
130
-		$spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true);
130
+		$spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true);
131 131
 
132 132
 		return $spotter_array;
133 133
 	}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		global $globalDBdriver, $globalLiveInterval;
144 144
 		date_default_timezone_set('UTC');
145 145
 
146
-		$filter_query = $this->getFilter($filter,true,true);
146
+		$filter_query = $this->getFilter($filter, true, true);
147 147
 
148 148
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
149 149
 		if ($globalDBdriver == 'mysql') {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		try {
162 162
 			$sth = $this->db->prepare($query);
163 163
 			$sth->execute();
164
-		} catch(PDOException $e) {
164
+		} catch (PDOException $e) {
165 165
 			echo $e->getMessage();
166 166
 			die;
167 167
 		}
@@ -176,25 +176,25 @@  discard block
 block discarded – undo
176 176
 	* @return Array the spotter information
177 177
 	*
178 178
 	*/
179
-	public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false)
179
+	public function getMinLastLiveTrackerData($coord, $filter = array(), $limit = false)
180 180
 	{
181 181
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit;
182 182
 		date_default_timezone_set('UTC');
183 183
 		$usecoord = false;
184 184
 		if (is_array($coord) && !empty($coord)) {
185
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
186
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
187
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
188
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
185
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
186
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
187
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
188
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
189 189
 			$usecoord = true;
190 190
 		}
191
-		$filter_query = $this->getFilter($filter,true,true);
191
+		$filter_query = $this->getFilter($filter, true, true);
192 192
 
193 193
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194 194
 		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
195 195
 		if ($globalDBdriver == 'mysql') {
196 196
 			if (isset($globalArchive) && $globalArchive) {
197
-				$query  = "SELECT * FROM (
197
+				$query = "SELECT * FROM (
198 198
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
199 199
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
200 200
 				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 			}
217 217
 		} else {
218 218
 			if (isset($globalArchive) && $globalArchive) {
219
-				$query  = "SELECT * FROM (
219
+				$query = "SELECT * FROM (
220 220
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
221 221
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
222 222
 				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		try {
241 241
 			$sth = $this->db->prepare($query);
242 242
 			$sth->execute();
243
-		} catch(PDOException $e) {
243
+		} catch (PDOException $e) {
244 244
 			echo $e->getMessage();
245 245
 			die;
246 246
 		}
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	public function getLiveTrackerCount($filter = array())
258 258
 	{
259 259
 		global $globalDBdriver, $globalLiveInterval;
260
-		$filter_query = $this->getFilter($filter,true,true);
260
+		$filter_query = $this->getFilter($filter, true, true);
261 261
 
262 262
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
263 263
 		if ($globalDBdriver == 'mysql') {
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		try {
269 269
 			$sth = $this->db->prepare($query);
270 270
 			$sth->execute();
271
-		} catch(PDOException $e) {
271
+		} catch (PDOException $e) {
272 272
 			echo $e->getMessage();
273 273
 			die;
274 274
 		}
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
 		$filter_query = $this->getFilter($filter);
292 292
 
293 293
 		if (is_array($coord)) {
294
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
295
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
297
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
294
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
295
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
296
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
297
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
298 298
 		} else return array();
299 299
 		if ($globalDBdriver == 'mysql') {
300 300
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
317 317
 		$Tracker = new Tracker($this->db);
318 318
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
319
-		$filter_query = $this->getFilter($filter,true,true);
319
+		$filter_query = $this->getFilter($filter, true, true);
320 320
 
321 321
 		if (is_array($coord)) {
322
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
323
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
322
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
323
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
324
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
325
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
326 326
 		} else return array();
327 327
 		/*
328 328
 		if ($globalDBdriver == 'mysql') {
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 		*/
337 337
 		if ($globalDBdriver == 'mysql') {
338 338
 			if (isset($globalArchive) && $globalArchive === TRUE) {
339
-				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
339
+				$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
340 340
 				    FROM tracker_live 
341 341
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= tracker_live.date 
342 342
 				    AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
343 343
 				    AND tracker_live.latitude <> 0 AND tracker_live.longitude <> 0';
344 344
 			} else {
345
-				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
345
+				$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
346 346
 				    FROM tracker_live 
347 347
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
348 348
 					FROM tracker_live l 
@@ -354,14 +354,14 @@  discard block
 block discarded – undo
354 354
 			}
355 355
 		} else {
356 356
 			if (isset($globalArchive) && $globalArchive === TRUE) {
357
-				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
357
+				$query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
358 358
 				    FROM tracker_live 
359 359
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date 
360 360
 				    AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
361 361
 				    AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
362 362
 				    AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'";
363 363
 			} else {
364
-				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
364
+				$query = "SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
365 365
 				    FROM tracker_live 
366 366
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
367 367
 					FROM tracker_live l 
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
                 if ($interval == '1m')
419 419
                 {
420 420
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
421
-                } else if ($interval == '15m'){
421
+                } else if ($interval == '15m') {
422 422
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
423 423
                 } 
424 424
             }
@@ -426,14 +426,14 @@  discard block
 block discarded – undo
426 426
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
427 427
         }
428 428
 
429
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
429
+                $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
430 430
                    WHERE tracker_live.latitude <> '' 
431 431
                                    AND tracker_live.longitude <> '' 
432 432
                    ".$additional_query."
433 433
                    HAVING distance < :radius  
434 434
                                    ORDER BY distance";
435 435
 
436
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
436
+                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
437 437
 
438 438
                 return $spotter_array;
439 439
         }
@@ -451,9 +451,9 @@  discard block
 block discarded – undo
451 451
 		date_default_timezone_set('UTC');
452 452
 
453 453
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
454
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
454
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
455 455
 
456
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
456
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true);
457 457
 
458 458
 		return $spotter_array;
459 459
 	}
@@ -464,16 +464,16 @@  discard block
 block discarded – undo
464 464
 	* @return Array the spotter information
465 465
 	*
466 466
 	*/
467
-	public function getDateLiveTrackerDataByIdent($ident,$date)
467
+	public function getDateLiveTrackerDataByIdent($ident, $date)
468 468
 	{
469 469
 		$Tracker = new Tracker($this->db);
470 470
 		date_default_timezone_set('UTC');
471 471
 
472 472
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
473
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
473
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
474 474
 
475
-                $date = date('c',$date);
476
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
475
+                $date = date('c', $date);
476
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
477 477
 
478 478
 		return $spotter_array;
479 479
 	}
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
 		date_default_timezone_set('UTC');
491 491
 
492 492
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
493
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
493
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
494 494
 
495
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
495
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true);
496 496
 
497 497
 		return $spotter_array;
498 498
 	}
@@ -503,15 +503,15 @@  discard block
 block discarded – undo
503 503
 	* @return Array the spotter information
504 504
 	*
505 505
 	*/
506
-	public function getDateLiveTrackerDataById($id,$date)
506
+	public function getDateLiveTrackerDataById($id, $date)
507 507
 	{
508 508
 		$Tracker = new Tracker($this->db);
509 509
 		date_default_timezone_set('UTC');
510 510
 
511 511
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
512
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
-                $date = date('c',$date);
514
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
512
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
513
+                $date = date('c', $date);
514
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
515 515
 
516 516
 		return $spotter_array;
517 517
 	}
@@ -528,13 +528,13 @@  discard block
 block discarded – undo
528 528
 		date_default_timezone_set('UTC');
529 529
 
530 530
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
531
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
531
+                $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
532 532
 
533 533
     		try {
534 534
 			
535 535
 			$sth = $this->db->prepare($query);
536 536
 			$sth->execute(array(':ident' => $ident));
537
-		} catch(PDOException $e) {
537
+		} catch (PDOException $e) {
538 538
 			echo $e->getMessage();
539 539
 			die;
540 540
 		}
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 	* @return Array the spotter information
550 550
 	*
551 551
 	*/
552
-	public function getAllLiveTrackerDataById($id,$liveinterval = false)
552
+	public function getAllLiveTrackerDataById($id, $liveinterval = false)
553 553
 	{
554 554
 		global $globalDBdriver, $globalLiveInterval;
555 555
 		date_default_timezone_set('UTC');
@@ -558,19 +558,19 @@  discard block
 block discarded – undo
558 558
 		if ($globalDBdriver == 'mysql') {
559 559
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
560 560
 			if ($liveinterval === true) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
561
-			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'";
561
+			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c', $liveinterval)."'";
562 562
 			$query .= ' ORDER BY date';
563 563
 		} else {
564 564
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
565 565
 			if ($liveinterval === true) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
566
-			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'";
566
+			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c', $liveinterval)."'";
567 567
 			$query .= ' ORDER BY date';
568 568
 		}
569 569
 
570 570
 		try {
571 571
 			$sth = $this->db->prepare($query);
572 572
 			$sth->execute(array(':id' => $id));
573
-		} catch(PDOException $e) {
573
+		} catch (PDOException $e) {
574 574
 			echo $e->getMessage();
575 575
 			die;
576 576
 		}
@@ -588,12 +588,12 @@  discard block
 block discarded – undo
588 588
 	{
589 589
 		date_default_timezone_set('UTC');
590 590
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
591
-		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
591
+		$query = self::$global_query.' WHERE tracker_live.ident = :ident';
592 592
     		try {
593 593
 			
594 594
 			$sth = $this->db->prepare($query);
595 595
 			$sth->execute(array(':ident' => $ident));
596
-		} catch(PDOException $e) {
596
+		} catch (PDOException $e) {
597 597
 			echo $e->getMessage();
598 598
 			die;
599 599
 		}
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 			
624 624
 			$sth = $this->db->prepare($query);
625 625
 			$sth->execute();
626
-		} catch(PDOException $e) {
626
+		} catch (PDOException $e) {
627 627
 			return "error";
628 628
 		}
629 629
 
@@ -646,14 +646,14 @@  discard block
 block discarded – undo
646 646
 				
647 647
 				$sth = $this->db->prepare($query);
648 648
 				$sth->execute();
649
-			} catch(PDOException $e) {
649
+			} catch (PDOException $e) {
650 650
 				return "error";
651 651
 			}
652 652
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
653 653
                         $i = 0;
654
-                        $j =0;
654
+                        $j = 0;
655 655
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
656
-			foreach($all as $row)
656
+			foreach ($all as $row)
657 657
 			{
658 658
 				$i++;
659 659
 				$j++;
@@ -661,9 +661,9 @@  discard block
 block discarded – undo
661 661
 					if ($globalDebug) echo ".";
662 662
 				    	try {
663 663
 						
664
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
664
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
665 665
 						$sth->execute();
666
-					} catch(PDOException $e) {
666
+					} catch (PDOException $e) {
667 667
 						return "error";
668 668
 					}
669 669
                                 	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
 			if ($i > 0) {
675 675
     				try {
676 676
 					
677
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
677
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
678 678
 					$sth->execute();
679
-				} catch(PDOException $e) {
679
+				} catch (PDOException $e) {
680 680
 					return "error";
681 681
 				}
682 682
 			}
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 				
690 690
 				$sth = $this->db->prepare($query);
691 691
 				$sth->execute();
692
-			} catch(PDOException $e) {
692
+			} catch (PDOException $e) {
693 693
 				return "error";
694 694
 			}
695 695
 /*			$query_delete = "DELETE FROM tracker_live WHERE famtrackid IN (";
@@ -737,13 +737,13 @@  discard block
 block discarded – undo
737 737
 	public function deleteLiveTrackerDataByIdent($ident)
738 738
 	{
739 739
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
740
-		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
740
+		$query = 'DELETE FROM tracker_live WHERE ident = :ident';
741 741
         
742 742
     		try {
743 743
 			
744 744
 			$sth = $this->db->prepare($query);
745 745
 			$sth->execute(array(':ident' => $ident));
746
-		} catch(PDOException $e) {
746
+		} catch (PDOException $e) {
747 747
 			return "error";
748 748
 		}
749 749
 
@@ -759,13 +759,13 @@  discard block
 block discarded – undo
759 759
 	public function deleteLiveTrackerDataById($id)
760 760
 	{
761 761
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
762
-		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
762
+		$query = 'DELETE FROM tracker_live WHERE famtrackid = :id';
763 763
         
764 764
     		try {
765 765
 			
766 766
 			$sth = $this->db->prepare($query);
767 767
 			$sth->execute(array(':id' => $id));
768
-		} catch(PDOException $e) {
768
+		} catch (PDOException $e) {
769 769
 			return "error";
770 770
 		}
771 771
 
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
 	{
784 784
 		global $globalDBdriver, $globalTimezone;
785 785
 		if ($globalDBdriver == 'mysql') {
786
-			$query  = 'SELECT tracker_live.ident FROM tracker_live 
786
+			$query = 'SELECT tracker_live.ident FROM tracker_live 
787 787
 				WHERE tracker_live.ident = :ident 
788 788
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
789 789
 				AND tracker_live.date < UTC_TIMESTAMP()';
790 790
 			$query_data = array(':ident' => $ident);
791 791
 		} else {
792
-			$query  = "SELECT tracker_live.ident FROM tracker_live 
792
+			$query = "SELECT tracker_live.ident FROM tracker_live 
793 793
 				WHERE tracker_live.ident = :ident 
794 794
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
795 795
 				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -798,8 +798,8 @@  discard block
 block discarded – undo
798 798
 		
799 799
 		$sth = $this->db->prepare($query);
800 800
 		$sth->execute($query_data);
801
-		$ident_result='';
802
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
801
+		$ident_result = '';
802
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
803 803
 		{
804 804
 			$ident_result = $row['ident'];
805 805
 		}
@@ -816,13 +816,13 @@  discard block
 block discarded – undo
816 816
 	{
817 817
 		global $globalDBdriver, $globalTimezone;
818 818
 		if ($globalDBdriver == 'mysql') {
819
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
819
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
820 820
 				WHERE tracker_live.ident = :ident 
821 821
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
822 822
 //				AND tracker_live.date < UTC_TIMESTAMP()";
823 823
 			$query_data = array(':ident' => $ident);
824 824
 		} else {
825
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
825
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
826 826
 				WHERE tracker_live.ident = :ident 
827 827
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
828 828
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
 		
832 832
 		$sth = $this->db->prepare($query);
833 833
 		$sth->execute($query_data);
834
-		$ident_result='';
835
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
834
+		$ident_result = '';
835
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
836 836
 		{
837 837
 			$ident_result = $row['famtrackid'];
838 838
 		}
@@ -849,13 +849,13 @@  discard block
 block discarded – undo
849 849
 	{
850 850
 		global $globalDBdriver, $globalTimezone;
851 851
 		if ($globalDBdriver == 'mysql') {
852
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
852
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
853 853
 				WHERE tracker_live.famtrackid = :id 
854 854
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
855 855
 //				AND tracker_live.date < UTC_TIMESTAMP()";
856 856
 			$query_data = array(':id' => $id);
857 857
 		} else {
858
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
858
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
859 859
 				WHERE tracker_live.famtrackid = :id 
860 860
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
861 861
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -864,8 +864,8 @@  discard block
 block discarded – undo
864 864
 		
865 865
 		$sth = $this->db->prepare($query);
866 866
 		$sth->execute($query_data);
867
-		$ident_result='';
868
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
867
+		$ident_result = '';
868
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
869 869
 		{
870 870
 			$ident_result = $row['famtrackid'];
871 871
 		}
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	* @return String success or false
884 884
 	*
885 885
 	*/
886
-	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
886
+	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
887 887
 	{
888 888
 		global $globalURL, $globalArchive, $globalDebug;
889 889
 		$Common = new Common();
@@ -942,21 +942,21 @@  discard block
 block discarded – undo
942 942
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
943 943
 
944 944
         
945
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
946
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
947
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
948
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
949
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
950
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
951
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
952
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
953
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
954
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
955
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
956
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
957
-
958
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
959
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
945
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
946
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
947
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
948
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
949
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
950
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
951
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
952
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
953
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
954
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
955
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
956
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
957
+
958
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
959
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
960 960
             	
961 961
 		$query = '';
962 962
 		if ($globalArchive) {
@@ -966,12 +966,12 @@  discard block
 block discarded – undo
966 966
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
967 967
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
968 968
 
969
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type);
969
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type);
970 970
 		try {
971 971
 			$sth = $this->db->prepare($query);
972 972
 			$sth->execute($query_values);
973 973
 			$sth->closeCursor();
974
-		} catch(PDOException $e) {
974
+		} catch (PDOException $e) {
975 975
 			return "error : ".$e->getMessage();
976 976
 		}
977 977
                 /*
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
982 982
 		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
983 983
 		    $TrackerArchive = new TrackerArchive($this->db);
984
-		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
984
+		    $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country);
985 985
 		    if ($globalDebug) echo $result.')';
986 986
 		}
987 987
 
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 
992 992
 	public function getOrderBy()
993 993
 	{
994
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
994
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
995 995
 		return $orderby;
996 996
 	}
997 997
 
Please login to merge, or discard this patch.
Braces   +114 added lines, -39 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (TrackerLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (TrackerLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -77,8 +81,11 @@  discard block
 block discarded – undo
77 81
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78 82
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
79 83
 		}
80
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
84
+		if ($filter_query_where == '' && $where) {
85
+			$filter_query_where = ' WHERE';
86
+		} elseif ($filter_query_where != '' && $and) {
87
+			$filter_query_where .= ' AND';
88
+		}
82 89
 		if ($filter_query_where != '') {
83 90
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84 91
 		}
@@ -120,7 +127,9 @@  discard block
 block discarded – undo
120 127
 			}
121 128
 		}
122 129
 
123
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
130
+		if (!isset($globalLiveInterval)) {
131
+			$globalLiveInterval = '200';
132
+		}
124 133
 		if ($globalDBdriver == 'mysql') {
125 134
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
126 135
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -145,7 +154,9 @@  discard block
 block discarded – undo
145 154
 
146 155
 		$filter_query = $this->getFilter($filter,true,true);
147 156
 
148
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
157
+		if (!isset($globalLiveInterval)) {
158
+			$globalLiveInterval = '200';
159
+		}
149 160
 		if ($globalDBdriver == 'mysql') {
150 161
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
151 162
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -190,50 +201,74 @@  discard block
 block discarded – undo
190 201
 		}
191 202
 		$filter_query = $this->getFilter($filter,true,true);
192 203
 
193
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
-		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
204
+		if (!isset($globalLiveInterval)) {
205
+			$globalLiveInterval = '200';
206
+		}
207
+		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') {
208
+			$globalMap3DTrackersLimit = '300';
209
+		}
195 210
 		if ($globalDBdriver == 'mysql') {
196 211
 			if (isset($globalArchive) && $globalArchive) {
197 212
 				$query  = "SELECT * FROM (
198 213
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
199 214
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
200
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
215
+				if ($usecoord) {
216
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
217
+				}
201 218
 				$query .= "UNION
202 219
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
203 220
 					FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
204
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
221
+				if ($usecoord) {
222
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
223
+				}
205 224
 				$query .= ") AS tracker
206 225
 				    WHERE latitude <> '0' AND longitude <> '0' 
207 226
 				    ORDER BY famtrackid, date";
208
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
227
+				if ($limit) {
228
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
229
+				}
209 230
 			} else {
210 231
 				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
211 232
 				    FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
212
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
233
+				if ($usecoord) {
234
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
235
+				}
213 236
 				$query .= "AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
214 237
 				    ORDER BY tracker_live.famtrackid, tracker_live.date";
215
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
238
+				if ($limit) {
239
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
240
+				}
216 241
 			}
217 242
 		} else {
218 243
 			if (isset($globalArchive) && $globalArchive) {
219 244
 				$query  = "SELECT * FROM (
220 245
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
221 246
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
222
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
247
+				if ($usecoord) {
248
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
249
+				}
223 250
 				$query .= "UNION
224 251
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
225 252
 					FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date";
226
-				if ($usecoord) $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
253
+				if ($usecoord) {
254
+					$query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
255
+				}
227 256
 				$query .= ") AS tracker
228 257
 				    WHERE latitude <> '0' AND longitude <> '0' 
229 258
 				    ORDER BY famtrackid, date";
230
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
259
+				if ($limit) {
260
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
261
+				}
231 262
 			} else {
232 263
 				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
233 264
 				    FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' ";
234
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
265
+				if ($usecoord) {
266
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
267
+				}
235 268
 				$query .= "ORDER BY tracker_live.famtrackid, tracker_live.date";
236
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
269
+				if ($limit) {
270
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
271
+				}
237 272
 			}
238 273
 		}
239 274
 
@@ -259,7 +294,9 @@  discard block
 block discarded – undo
259 294
 		global $globalDBdriver, $globalLiveInterval;
260 295
 		$filter_query = $this->getFilter($filter,true,true);
261 296
 
262
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
297
+		if (!isset($globalLiveInterval)) {
298
+			$globalLiveInterval = '200';
299
+		}
263 300
 		if ($globalDBdriver == 'mysql') {
264 301
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
265 302
 		} else {
@@ -287,7 +324,9 @@  discard block
 block discarded – undo
287 324
 	{
288 325
 		global $globalDBdriver, $globalLiveInterval;
289 326
 		$Tracker = new Tracker($this->db);
290
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
327
+		if (!isset($globalLiveInterval)) {
328
+			$globalLiveInterval = '200';
329
+		}
291 330
 		$filter_query = $this->getFilter($filter);
292 331
 
293 332
 		if (is_array($coord)) {
@@ -295,7 +334,9 @@  discard block
 block discarded – undo
295 334
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296 335
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
297 336
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
298
-		} else return array();
337
+		} else {
338
+			return array();
339
+		}
299 340
 		if ($globalDBdriver == 'mysql') {
300 341
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
301 342
 		} else {
@@ -315,7 +356,9 @@  discard block
 block discarded – undo
315 356
 	{
316 357
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
317 358
 		$Tracker = new Tracker($this->db);
318
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
359
+		if (!isset($globalLiveInterval)) {
360
+			$globalLiveInterval = '200';
361
+		}
319 362
 		$filter_query = $this->getFilter($filter,true,true);
320 363
 
321 364
 		if (is_array($coord)) {
@@ -323,7 +366,9 @@  discard block
 block discarded – undo
323 366
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324 367
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325 368
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326
-		} else return array();
369
+		} else {
370
+			return array();
371
+		}
327 372
 		/*
328 373
 		if ($globalDBdriver == 'mysql') {
329 374
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
@@ -557,13 +602,19 @@  discard block
 block discarded – undo
557 602
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
558 603
 		if ($globalDBdriver == 'mysql') {
559 604
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
560
-			if ($liveinterval === true) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
561
-			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'";
605
+			if ($liveinterval === true) {
606
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
607
+			} elseif ($liveinterval !== false) {
608
+				$query .= " AND date <= '".date('c',$liveinterval)."'";
609
+			}
562 610
 			$query .= ' ORDER BY date';
563 611
 		} else {
564 612
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
565
-			if ($liveinterval === true) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
566
-			elseif ($liveinterval !== false) $query .= " AND date <= '".date('c',$liveinterval)."'";
613
+			if ($liveinterval === true) {
614
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
615
+			} elseif ($liveinterval !== false) {
616
+				$query .= " AND date <= '".date('c',$liveinterval)."'";
617
+			}
567 618
 			$query .= ' ORDER BY date';
568 619
 		}
569 620
 
@@ -658,7 +709,9 @@  discard block
 block discarded – undo
658 709
 				$i++;
659 710
 				$j++;
660 711
 				if ($j == 30) {
661
-					if ($globalDebug) echo ".";
712
+					if ($globalDebug) {
713
+						echo ".";
714
+					}
662 715
 				    	try {
663 716
 						
664 717
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -905,7 +958,9 @@  discard block
 block discarded – undo
905 958
 			{
906 959
 				return false;
907 960
 			}
908
-		} else return '';
961
+		} else {
962
+			return '';
963
+		}
909 964
 
910 965
 		if ($longitude != '')
911 966
 		{
@@ -913,7 +968,9 @@  discard block
 block discarded – undo
913 968
 			{
914 969
 				return false;
915 970
 			}
916
-		} else return '';
971
+		} else {
972
+			return '';
973
+		}
917 974
 
918 975
 		if ($altitude != '')
919 976
 		{
@@ -921,7 +978,9 @@  discard block
 block discarded – undo
921 978
 			{
922 979
 				return false;
923 980
 			}
924
-		} else $altitude = 0;
981
+		} else {
982
+			$altitude = 0;
983
+		}
925 984
 
926 985
 		if ($heading != '')
927 986
 		{
@@ -929,7 +988,9 @@  discard block
 block discarded – undo
929 988
 			{
930 989
 				return false;
931 990
 			}
932
-		} else $heading = 0;
991
+		} else {
992
+			$heading = 0;
993
+		}
933 994
 
934 995
 		if ($groundspeed != '')
935 996
 		{
@@ -937,9 +998,13 @@  discard block
 block discarded – undo
937 998
 			{
938 999
 				return false;
939 1000
 			}
940
-		} else $groundspeed = 0;
1001
+		} else {
1002
+			$groundspeed = 0;
1003
+		}
941 1004
 		date_default_timezone_set('UTC');
942
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1005
+		if ($date == '') {
1006
+			$date = date("Y-m-d H:i:s", time());
1007
+		}
943 1008
 
944 1009
         
945 1010
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -955,12 +1020,18 @@  discard block
 block discarded – undo
955 1020
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
956 1021
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
957 1022
 
958
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
959
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1023
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1024
+            		$groundspeed = 0;
1025
+            	}
1026
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1027
+            		$heading = 0;
1028
+            	}
960 1029
             	
961 1030
 		$query = '';
962 1031
 		if ($globalArchive) {
963
-			if ($globalDebug) echo '-- Delete previous data -- ';
1032
+			if ($globalDebug) {
1033
+				echo '-- Delete previous data -- ';
1034
+			}
964 1035
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
965 1036
 		}
966 1037
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -979,10 +1050,14 @@  discard block
 block discarded – undo
979 1050
                 echo 'noarchive : '.$noarchive."\n";
980 1051
                 */
981 1052
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
982
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
1053
+		    if ($globalDebug) {
1054
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
1055
+		    }
983 1056
 		    $TrackerArchive = new TrackerArchive($this->db);
984 1057
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
985
-		    if ($globalDebug) echo $result.')';
1058
+		    if ($globalDebug) {
1059
+		    	echo $result.')';
1060
+		    }
986 1061
 		}
987 1062
 
988 1063
 		return "success";
Please login to merge, or discard this patch.
live-geojson.php 3 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -13,23 +13,23 @@  discard block
 block discarded – undo
13 13
 $marine = false;
14 14
 $usecoord = false;
15 15
 if (isset($_GET['tracker'])) {
16
-    $tracker = true;
16
+	$tracker = true;
17 17
 }
18 18
 if (isset($_GET['marine'])) {
19
-    $marine = true;
19
+	$marine = true;
20 20
 }
21 21
 if ($tracker) {
22
-    require_once('require/class.Tracker.php');
23
-    require_once('require/class.TrackerLive.php');
24
-    require_once('require/class.TrackerArchive.php');
22
+	require_once('require/class.Tracker.php');
23
+	require_once('require/class.TrackerLive.php');
24
+	require_once('require/class.TrackerArchive.php');
25 25
 } elseif ($marine) {
26
-    require_once('require/class.Marine.php');
27
-    require_once('require/class.MarineLive.php');
28
-    require_once('require/class.MarineArchive.php');
26
+	require_once('require/class.Marine.php');
27
+	require_once('require/class.MarineLive.php');
28
+	require_once('require/class.MarineArchive.php');
29 29
 } else {
30
-    require_once('require/class.Spotter.php');
31
-    require_once('require/class.SpotterLive.php');
32
-    require_once('require/class.SpotterArchive.php');
30
+	require_once('require/class.Spotter.php');
31
+	require_once('require/class.SpotterLive.php');
32
+	require_once('require/class.SpotterArchive.php');
33 33
 }
34 34
 
35 35
 $begintime = microtime(true);
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
 $Common = new Common();
50 50
 
51 51
 if (isset($_GET['download'])) {
52
-    if ($_GET['download'] == "true")
53
-    {
52
+	if ($_GET['download'] == "true")
53
+	{
54 54
 	header('Content-disposition: attachment; filename="flightairmap.json"');
55
-    }
55
+	}
56 56
 }
57 57
 header('Content-Type: text/javascript');
58 58
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	$usecoord = true;
131 131
 	$coord = explode(',',$_GET['coord']);
132 132
 	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
133
-	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
133
+		&& $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
134 134
 		if ($tracker) {
135 135
 			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
136 136
 		} elseif ($marine) {
@@ -634,17 +634,17 @@  discard block
 block discarded – undo
634 634
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
635 635
 				
636 636
 				if (
637
-				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
638
-				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
637
+					(isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
638
+					|| ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
639 639
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
640 640
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
641
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
642
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
643
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
644
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
645
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
646
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
647
-				    ) {
641
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
642
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
643
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
644
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
645
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
646
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
647
+					) {
648 648
 					if ($tracker) {
649 649
 						if ($from_archive || $globalArchive) {
650 650
 							$spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid'],strtotime($spotter_item['date_iso_8601']));
@@ -652,9 +652,9 @@  discard block
 block discarded – undo
652 652
 							$spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']);
653 653
 						}
654 654
 						if (((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') ||
655
-						    (!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && 
656
-						    isset($_GET['zoom']) && $_GET['zoom'] > 12 && 
657
-						    isset($spotter_item['type']) && (
655
+							(!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && 
656
+							isset($_GET['zoom']) && $_GET['zoom'] > 12 && 
657
+							isset($spotter_item['type']) && (
658 658
 							$spotter_item['type'] == 'Firetruck' ||
659 659
 							$spotter_item['type'] == 'Ambulance' ||
660 660
 							$spotter_item['type'] == 'Truck (18 Wheeler)' ||
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 							$spotter_item['type'] == 'Jeep' ||
667 667
 							$spotter_item['type'] == 'Motorcycle' ||
668 668
 							$spotter_item['type'] == 'Car'
669
-						    )
669
+							)
670 670
 						) {
671 671
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
672 672
 							$MapMatching = new MapMatching();
@@ -765,65 +765,65 @@  discard block
 block discarded – undo
765 765
 				}
766 766
 				
767 767
 				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
768
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
769
-				     && (isset($spotter_item['departure_airport']) 
770
-				        && $spotter_item['departure_airport'] != 'NA' 
771
-				        && isset($spotter_item['arrival_airport']) 
772
-				        && $spotter_item['arrival_airport'] != 'NA' 
773
-				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
774
-				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
775
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
776
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
777
-				    if (isset($spotter_item['departure_airport_latitude'])) {
768
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
769
+					 && (isset($spotter_item['departure_airport']) 
770
+						&& $spotter_item['departure_airport'] != 'NA' 
771
+						&& isset($spotter_item['arrival_airport']) 
772
+						&& $spotter_item['arrival_airport'] != 'NA' 
773
+						&& ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
774
+							|| (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
775
+					if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
776
+					else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
777
+					if (isset($spotter_item['departure_airport_latitude'])) {
778 778
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
779
-				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
779
+					} elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
780 780
 					$dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
781 781
 					if (isset($dairport[0]['latitude'])) {
782
-					    $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
782
+						$output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
783 783
 					}
784
-				    }
785
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
784
+					}
785
+					if (isset($spotter_item['arrival_airport_latitude'])) {
786 786
 					$output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].'],';
787
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
787
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
788 788
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
789 789
 					if (isset($aairport[0]['latitude'])) {
790
-					    $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],';
790
+						$output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],';
791 791
 					}
792
-				    }
793
-				    $output_air  = substr($output_air, 0, -1);
794
-				    $output_air .= ']}},';
795
-				    $output .= $output_air;
796
-				    unset($output_air);
792
+					}
793
+					$output_air  = substr($output_air, 0, -1);
794
+					$output_air .= ']}},';
795
+					$output .= $output_air;
796
+					unset($output_air);
797 797
 				}
798 798
 
799 799
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
800 800
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
801 801
 				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
802
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
803
-				     && (isset($spotter_item['arrival_airport']) 
804
-				        && $spotter_item['arrival_airport'] != 'NA' 
805
-				        && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") 
806
-				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
807
-				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
808
-				    $havedata = false;
809
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
810
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
811
-				    $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
802
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
803
+					 && (isset($spotter_item['arrival_airport']) 
804
+						&& $spotter_item['arrival_airport'] != 'NA' 
805
+						&& ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") 
806
+							|| (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
807
+							|| (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
808
+					$havedata = false;
809
+					if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
810
+					else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
811
+					$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
812 812
 
813
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
813
+					if (isset($spotter_item['arrival_airport_latitude'])) {
814 814
 					$output_dest .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']';
815 815
 					$havedata = true;
816
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
816
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
817 817
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
818 818
 					if (isset($aairport[0]['latitude'])) {
819
-					    $output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
820
-					    $havedata = true;
819
+						$output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
820
+						$havedata = true;
821 821
 					}
822
-				    }
823
-				    //$output_dest  = substr($output_dest, 0, -1);
824
-				    $output_dest .= ']}},';
825
-				    if ($havedata) $output .= $output_dest;
826
-				    unset($output_dest);
822
+					}
823
+					//$output_dest  = substr($output_dest, 0, -1);
824
+					$output_dest .= ']}},';
825
+					if ($havedata) $output .= $output_dest;
826
+					unset($output_dest);
827 827
 				}
828 828
 			}
829 829
 			$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -63,17 +63,17 @@  discard block
 block discarded – undo
63 63
 $min = true;
64 64
 $allhistory = false;
65 65
 $filter['source'] = array();
66
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
69
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
71
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
72
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
66
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
68
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
69
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
71
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
72
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING);
73
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
74
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
75
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
76
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
77 77
 
78 78
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
79 79
 	$min = true;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 $spotter_array = array();
83 83
 
84 84
 if (isset($_GET['ident'])) {
85
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
85
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
86 86
 	if ($tracker) {
87 87
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
88 88
 	} elseif ($marine) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 	$allhistory = true;
98 98
 } elseif (isset($_GET['flightaware_id'])) {
99
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
99
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
100 100
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
101 101
 	if (empty($spotter_array)) {
102 102
 		$from_archive = true;
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 	$allhistory = true;
106 106
 } elseif (isset($_GET['famtrack_id'])) {
107
-	$famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING));
107
+	$famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING));
108 108
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
109 109
 	$allhistory = true;
110 110
 } elseif (isset($_GET['fammarine_id'])) {
111
-	$fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING));
111
+	$fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING));
112 112
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
113 113
 	$allhistory = true;
114 114
 /*
@@ -128,15 +128,15 @@  discard block
 block discarded – undo
128 128
 */
129 129
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) {
130 130
 	$usecoord = true;
131
-	$coord = explode(',',$_GET['coord']);
132
-	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
131
+	$coord = explode(',', $_GET['coord']);
132
+	if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
133 133
 	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
134 134
 		if ($tracker) {
135
-			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
135
+			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
136 136
 		} elseif ($marine) {
137
-			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
137
+			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
138 138
 		} else {
139
-			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);
139
+			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);
140 140
 		}
141 141
 	} else {
142 142
 		if ($tracker) {
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
 	$from_archive = true;
152 152
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
153 153
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
154
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
155
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
156
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
157
-	$begindate = date('Y-m-d H:i:s',$begindate);
158
-	$enddate = date('Y-m-d H:i:s',$enddate);
159
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
154
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
155
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
156
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
157
+	$begindate = date('Y-m-d H:i:s', $begindate);
158
+	$enddate = date('Y-m-d H:i:s', $enddate);
159
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
160 160
 } elseif ($min) {
161 161
 	if ($tracker) {
162 162
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
 #	$min = true;
169 169
 } else {
170 170
 	if ($tracker) {
171
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
171
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
172 172
 	} elseif ($marine) {
173
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
173
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
174 174
 	} else {
175
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
175
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
176 176
 	}
177 177
 }
178 178
 
179 179
 if ($usecoord) {
180 180
 	if (isset($_GET['archive'])) {
181
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
181
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
182 182
 	} else {
183 183
 		if ($tracker) {
184 184
 			$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 	if ($flightcnt == '') $flightcnt = 0;
192 192
 } else $flightcnt = 0;
193 193
 
194
-$sqltime = round(microtime(true)-$begintime,2);
194
+$sqltime = round(microtime(true) - $begintime, 2);
195 195
 
196
-$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
196
+$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
197 197
 if ($currenttime != '') $currenttime = round($currenttime/1000);
198 198
 
199 199
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		if (!empty($spotter_array) && is_array($spotter_array))
213 213
 		{
214 214
 			$output .= '"features": [';
215
-			foreach($spotter_array as $spotter_item)
215
+			foreach ($spotter_array as $spotter_item)
216 216
 			{
217 217
 				$j++;
218 218
 				unset($idistance);
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 */
270 270
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
271 271
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
272
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
273
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
272
+							if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",';
273
+							else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",';
274 274
 							//"
275 275
 						} else {
276 276
 							if ($compress) $output .= '"c": "NA",';
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
280 280
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
281 281
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
282
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
282
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
283 283
 						} elseif (isset($spotter_item['aircraft_type'])) {
284 284
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
285 285
 						} elseif (!$min) {
@@ -422,15 +422,15 @@  discard block
 block discarded – undo
422 422
 						if (isset($archivespeed) || $usenextlatlon) {
423 423
 							if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
424 424
 								if (isset($spotter_item['arrival_airport_latitude'])) {
425
-									$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
426
-									$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
425
+									$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
426
+									$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
427 427
 									$farr_lat = $spotter_item['arrival_airport_latitude'];
428 428
 									$farr_lon = $spotter_item['arrival_airport_longitude'];
429 429
 								} else {
430 430
 									$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
431 431
 									if (isset($aairport[0]['latitude'])) {
432
-										$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
433
-										$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
432
+										$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
433
+										$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
434 434
 										$farr_lat = $aairport[0]['latitude'];
435 435
 										$farr_lon = $aairport[0]['longitude'];
436 436
 									}
@@ -443,59 +443,59 @@  discard block
 block discarded – undo
443 443
 						if ($currenttime != '') {
444 444
 							if (strtotime($spotter_item['date']) < $currenttime) {
445 445
 								if (isset($archivespeed)) {
446
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
447
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
446
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
447
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
448 448
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
449 449
 									else {
450
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
451
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
450
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
451
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
452 452
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
453 453
 										else {
454
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
454
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
455 455
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
456 456
 										}
457 457
 									}
458 458
 								} elseif ($usenextlatlon) {
459
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
460
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
459
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
460
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
461 461
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
462 462
 									else {
463
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
464
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
463
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
464
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
465 465
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
466 466
 										else {
467
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
467
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
468 468
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
469 469
 										}
470 470
 									}
471 471
 								}
472 472
 							} else {
473 473
 								if (isset($archivespeed)) {
474
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
474
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
475 475
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
476 476
 								} elseif ($usenextlatlon) {
477
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
477
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
478 478
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
479 479
 								}
480 480
 							}
481 481
 						} else {
482 482
 							if (isset($archivespeed)) {
483
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
484
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
483
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
484
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
485 485
 								if (!isset($idistance) || $fdistance < $idistance) {
486 486
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
487 487
 								} else {
488
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed);
488
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed);
489 489
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
490 490
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
491 491
 								}
492 492
 							} elseif ($usenextlatlon) {
493
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
494
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
493
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
494
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
495 495
 								if (!isset($idistance) || $fdistance < $idistance) {
496 496
 										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
497 497
 								} else {
498
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading);
498
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading);
499 499
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
500 500
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
501 501
 								}
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 
505 505
 						if (!$min) $output .= '"image": "'.$image.'",';
506 506
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
507
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
507
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
508 508
 						}
509 509
 						if (isset($spotter_item['image_source_website'])) {
510 510
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
527 527
 						}
528 528
 						if (isset($spotter_item['acars'])) {
529
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
529
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
530 530
 						}
531 531
 						// type when not aircraft ?
532 532
 						if (isset($spotter_item['type'])) {
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
 								if ($currenttime != '') {
547 547
 									if (strtotime($spotter_item['date']) < $currenttime) {
548 548
 										if (!isset($archivespeed)) $archivespeed = 1;
549
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
550
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
549
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
550
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
551 551
 										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
552 552
 										else {
553
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
554
-											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
553
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
554
+											$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
555 555
 											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
556 556
 											else {
557 557
 												$output .= $spotter_item['longitude'].', ';
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
                 
631 631
 			}
632 632
 */
633
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
633
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
634 634
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
635 635
 				
636 636
 				if (
@@ -638,16 +638,16 @@  discard block
 block discarded – undo
638 638
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
639 639
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
640 640
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
641
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
641
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
642 642
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
643
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
643
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
644 644
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
645
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
645
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
646 646
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
647 647
 				    ) {
648 648
 					if ($tracker) {
649 649
 						if ($from_archive || $globalArchive) {
650
-							$spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid'],strtotime($spotter_item['date_iso_8601']));
650
+							$spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid'], strtotime($spotter_item['date_iso_8601']));
651 651
 						} else {
652 652
 							$spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']);
653 653
 						}
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 						) {
671 671
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
672 672
 							$MapMatching = new MapMatching();
673
-							$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date_iso_8601'])))));
673
+							$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date_iso_8601'])))));
674 674
 							$spotter_history_array = $MapMatching->match($spotter_history_array_mm);
675 675
 						}
676 676
 					} elseif ($marine) {
@@ -701,9 +701,9 @@  discard block
 block discarded – undo
701 701
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
702 702
 							}
703 703
 							$output_history .= '[';
704
-							$output_history .=  $spotter_history['longitude'].', ';
705
-							$output_history .=  $spotter_history['latitude'].', ';
706
-							$output_history .=  $spotter_history['altitude']*30.48;
704
+							$output_history .= $spotter_history['longitude'].', ';
705
+							$output_history .= $spotter_history['latitude'].', ';
706
+							$output_history .= $spotter_history['altitude']*30.48;
707 707
 							$output_history .= '],';
708 708
 							/*
709 709
 							if ($from_archive === false) {
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
 								$d = true;
727 727
 							}
728 728
 							$output_history .= '[';
729
-							$output_history .=  $spotter_history['longitude'].', ';
730
-							$output_history .=  $spotter_history['latitude'];
729
+							$output_history .= $spotter_history['longitude'].', ';
730
+							$output_history .= $spotter_history['latitude'];
731 731
 							$output_history .= '],';
732 732
 							/*
733 733
 							if ($from_archive === false) {
@@ -743,9 +743,9 @@  discard block
 block discarded – undo
743 743
 						//echo $output_history;
744 744
 						if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) {
745 745
 							$output_historyd = '[';
746
-							$output_historyd .=  $spotter_item['longitude'].', ';
747
-							$output_historyd .=  $spotter_item['latitude'];
748
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
746
+							$output_historyd .= $spotter_item['longitude'].', ';
747
+							$output_historyd .= $spotter_item['latitude'];
748
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
749 749
 							$output_historyd .= '],';
750 750
 							//$output_history = $output_historyd.$output_history;
751 751
 							$output_history = $output_history.$output_historyd;
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 							$last = array_pop($spotter_history_array);
754 754
 							$latitude = $last['latitude'];
755 755
 							$longitude = $last['longitude'];
756
-							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output);
756
+							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}', '"coordinates": ['.$longitude.', '.$latitude.']}', $output);
757 757
 						}
758 758
 						
759 759
 						$output_history  = substr($output_history, 0, -1);
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 					}
765 765
 				}
766 766
 				
767
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
767
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
768 768
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
769 769
 				     && (isset($spotter_item['departure_airport']) 
770 770
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 
799 799
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
800 800
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
801
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
801
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
802 802
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
803 803
 				     && (isset($spotter_item['arrival_airport']) 
804 804
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 			$output  = substr($output, 0, -1);
830 830
 			$output .= ']';
831 831
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
832
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
832
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
833 833
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
834 834
 			$output .= '"fc": "'.$j.'"';
835 835
 		} else {
Please login to merge, or discard this patch.
Braces   +318 added lines, -129 removed lines patch added patch discarded remove patch
@@ -56,28 +56,55 @@  discard block
 block discarded – undo
56 56
 }
57 57
 header('Content-Type: text/javascript');
58 58
 
59
-if (!isset($globalJsonCompress)) $compress = true;
60
-else $compress = $globalJsonCompress;
59
+if (!isset($globalJsonCompress)) {
60
+	$compress = true;
61
+} else {
62
+	$compress = $globalJsonCompress;
63
+}
61 64
 
62 65
 $from_archive = false;
63 66
 $min = true;
64 67
 $allhistory = false;
65 68
 $filter['source'] = array();
66
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
69
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
71
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
72
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
69
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
70
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
71
+}
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
73
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
74
+}
75
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
76
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
77
+}
78
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
80
+}
81
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
83
+}
84
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
85
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
86
+}
87
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
88
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
89
+}
90
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
91
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
92
+}
93
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
94
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
97
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
100
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
101
+}
77 102
 
78 103
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
79 104
 	$min = true;
80
-} else $min = false;
105
+} else {
106
+	$min = false;
107
+}
81 108
 
82 109
 $spotter_array = array();
83 110
 
@@ -188,24 +215,38 @@  discard block
 block discarded – undo
188 215
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
189 216
 		}
190 217
 	}
191
-	if ($flightcnt == '') $flightcnt = 0;
192
-} else $flightcnt = 0;
218
+	if ($flightcnt == '') {
219
+		$flightcnt = 0;
220
+	}
221
+	} else {
222
+	$flightcnt = 0;
223
+}
193 224
 
194 225
 $sqltime = round(microtime(true)-$begintime,2);
195 226
 
196 227
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
197
-if ($currenttime != '') $currenttime = round($currenttime/1000);
228
+if ($currenttime != '') {
229
+	$currenttime = round($currenttime/1000);
230
+}
198 231
 
199
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
200
-else $usenextlatlon = true;
201
-if ($usenextlatlon === false) $currenttime = '';
232
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
233
+	$usenextlatlon = false;
234
+} else {
235
+	$usenextlatlon = true;
236
+}
237
+if ($usenextlatlon === false) {
238
+	$currenttime = '';
239
+}
202 240
 $j = 0;
203 241
 $prev_flightaware_id = '';
204 242
 $aircrafts_shadow = array();
205 243
 $output = '{';
206 244
 	$output .= '"type": "FeatureCollection",';
207
-		if ($min) $output .= '"minimal": "true",';
208
-		else $output .= '"minimal": "false",';
245
+		if ($min) {
246
+			$output .= '"minimal": "true",';
247
+		} else {
248
+			$output .= '"minimal": "false",';
249
+		}
209 250
 		//$output .= '"fc": "'.$flightcnt.'",';
210 251
 		$output .= '"sqt": "'.$sqltime.'",';
211 252
 
@@ -250,18 +291,29 @@  discard block
 block discarded – undo
250 291
 						}
251 292
 						$output .= '"properties": {';
252 293
 						if (isset($spotter_item['flightaware_id'])) {
253
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
254
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
294
+							if ($compress) {
295
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
296
+							} else {
297
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
298
+							}
255 299
 						} elseif (isset($spotter_item['famtrackid'])) {
256
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
257
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
300
+							if ($compress) {
301
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
302
+							} else {
303
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
304
+							}
258 305
 						} elseif (isset($spotter_item['fammarine_id'])) {
259
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
260
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
306
+							if ($compress) {
307
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
308
+							} else {
309
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
310
+							}
261 311
 						}
262 312
 							$output .= '"fc": "'.$flightcnt.'",';
263 313
 							$output .= '"sqt": "'.$sqltime.'",';
264
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
314
+							if (isset($begindate)) {
315
+								$output .= '"archive_date": "'.$begindate.'",';
316
+							}
265 317
 
266 318
 /*
267 319
 							if ($min) $output .= '"minimal": "true",';
@@ -269,14 +321,22 @@  discard block
 block discarded – undo
269 321
 */
270 322
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
271 323
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
272
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
273
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
324
+							if ($compress) {
325
+								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
326
+							} else {
327
+								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
328
+							}
274 329
 							//"
275 330
 						} else {
276
-							if ($compress) $output .= '"c": "NA",';
277
-							else $output .= '"callsign": "NA",';
331
+							if ($compress) {
332
+								$output .= '"c": "NA",';
333
+							} else {
334
+								$output .= '"callsign": "NA",';
335
+							}
336
+						}
337
+						if (isset($spotter_item['registration'])) {
338
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
278 339
 						}
279
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
280 340
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
281 341
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
282 342
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -289,16 +349,23 @@  discard block
 block discarded – undo
289 349
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
290 350
 						}
291 351
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
292
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
293
-							else {
352
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
353
+								$spotter_item['aircraft_shadow'] = '';
354
+							} else {
294 355
 								$aircraft_icao = $spotter_item['aircraft_icao'];
295
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
296
-								else {
356
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
357
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
358
+								} else {
297 359
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
298
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
299
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
300
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
301
-									else $spotter_item['aircraft_shadow'] = '';
360
+									if (count($aircraft_info) > 0) {
361
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
362
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
363
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
364
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
365
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
366
+									} else {
367
+										$spotter_item['aircraft_shadow'] = '';
368
+									}
302 369
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
303 370
 								}
304 371
 							}
@@ -306,73 +373,139 @@  discard block
 block discarded – undo
306 373
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
307 374
 							if ($tracker) {
308 375
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
309
-									if ($compress) $output .= '"as": "ambulance.png",';
310
-									else $output .= '"aircraft_shadow": "ambulance.png",';
376
+									if ($compress) {
377
+										$output .= '"as": "ambulance.png",';
378
+									} else {
379
+										$output .= '"aircraft_shadow": "ambulance.png",';
380
+									}
311 381
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
312
-									if ($compress) $output .= '"as": "police.png",';
313
-									else $output .= '"aircraft_shadow": "police.png",';
382
+									if ($compress) {
383
+										$output .= '"as": "police.png",';
384
+									} else {
385
+										$output .= '"aircraft_shadow": "police.png",';
386
+									}
314 387
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
315
-									if ($compress) $output .= '"as": "ship.png",';
316
-									else $output .= '"aircraft_shadow": "ship.png",';
388
+									if ($compress) {
389
+										$output .= '"as": "ship.png",';
390
+									} else {
391
+										$output .= '"aircraft_shadow": "ship.png",';
392
+									}
317 393
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
318
-									if ($compress) $output .= '"as": "ship.png",';
319
-									else $output .= '"aircraft_shadow": "ship.png",';
394
+									if ($compress) {
395
+										$output .= '"as": "ship.png",';
396
+									} else {
397
+										$output .= '"aircraft_shadow": "ship.png",';
398
+									}
320 399
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
321
-									if ($compress) $output .= '"as": "ship.png",';
322
-									else $output .= '"aircraft_shadow": "ship.png",';
400
+									if ($compress) {
401
+										$output .= '"as": "ship.png",';
402
+									} else {
403
+										$output .= '"aircraft_shadow": "ship.png",';
404
+									}
323 405
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
324
-									if ($compress) $output .= '"as": "truck.png",';
325
-									else $output .= '"aircraft_shadow": "truck.png",';
406
+									if ($compress) {
407
+										$output .= '"as": "truck.png",';
408
+									} else {
409
+										$output .= '"aircraft_shadow": "truck.png",';
410
+									}
326 411
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
327
-									if ($compress) $output .= '"as": "truck.png",';
328
-									else $output .= '"aircraft_shadow": "truck.png",';
412
+									if ($compress) {
413
+										$output .= '"as": "truck.png",';
414
+									} else {
415
+										$output .= '"aircraft_shadow": "truck.png",';
416
+									}
329 417
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
330
-									if ($compress) $output .= '"as": "aircraft.png",';
331
-									else $output .= '"aircraft_shadow": "aircraft.png",';
418
+									if ($compress) {
419
+										$output .= '"as": "aircraft.png",';
420
+									} else {
421
+										$output .= '"aircraft_shadow": "aircraft.png",';
422
+									}
332 423
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
333
-									if ($compress) $output .= '"as": "aircraft.png",';
334
-									else $output .= '"aircraft_shadow": "aircraft.png",';
424
+									if ($compress) {
425
+										$output .= '"as": "aircraft.png",';
426
+									} else {
427
+										$output .= '"aircraft_shadow": "aircraft.png",';
428
+									}
335 429
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
336
-									if ($compress) $output .= '"as": "helico.png",';
337
-									else $output .= '"aircraft_shadow": "helico.png",';
430
+									if ($compress) {
431
+										$output .= '"as": "helico.png",';
432
+									} else {
433
+										$output .= '"aircraft_shadow": "helico.png",';
434
+									}
338 435
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
339
-									if ($compress) $output .= '"as": "rail.png",';
340
-									else $output .= '"aircraft_shadow": "rail.png",';
436
+									if ($compress) {
437
+										$output .= '"as": "rail.png",';
438
+									} else {
439
+										$output .= '"aircraft_shadow": "rail.png",';
440
+									}
341 441
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
342
-									if ($compress) $output .= '"as": "firetruck.png",';
343
-									else $output .= '"aircraft_shadow": "firetruck.png",';
442
+									if ($compress) {
443
+										$output .= '"as": "firetruck.png",';
444
+									} else {
445
+										$output .= '"aircraft_shadow": "firetruck.png",';
446
+									}
344 447
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
345
-									if ($compress) $output .= '"as": "bus.png",';
346
-									else $output .= '"aircraft_shadow": "bus.png",';
448
+									if ($compress) {
449
+										$output .= '"as": "bus.png",';
450
+									} else {
451
+										$output .= '"aircraft_shadow": "bus.png",';
452
+									}
347 453
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
348
-									if ($compress) $output .= '"as": "phone.png",';
349
-									else $output .= '"aircraft_shadow": "phone.png",';
454
+									if ($compress) {
455
+										$output .= '"as": "phone.png",';
456
+									} else {
457
+										$output .= '"aircraft_shadow": "phone.png",';
458
+									}
350 459
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
351
-									if ($compress) $output .= '"as": "jogger.png",';
352
-									else $output .= '"aircraft_shadow": "jogger.png",';
460
+									if ($compress) {
461
+										$output .= '"as": "jogger.png",';
462
+									} else {
463
+										$output .= '"aircraft_shadow": "jogger.png",';
464
+									}
353 465
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
354
-									if ($compress) $output .= '"as": "bike.png",';
355
-									else $output .= '"aircraft_shadow": "bike.png",';
466
+									if ($compress) {
467
+										$output .= '"as": "bike.png",';
468
+									} else {
469
+										$output .= '"aircraft_shadow": "bike.png",';
470
+									}
356 471
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
357
-									if ($compress) $output .= '"as": "motorcycle.png",';
358
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
472
+									if ($compress) {
473
+										$output .= '"as": "motorcycle.png",';
474
+									} else {
475
+										$output .= '"aircraft_shadow": "motorcycle.png",';
476
+									}
359 477
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
360
-									if ($compress) $output .= '"as": "balloon.png",';
361
-									else $output .= '"aircraft_shadow": "balloon.png",';
478
+									if ($compress) {
479
+										$output .= '"as": "balloon.png",';
480
+									} else {
481
+										$output .= '"aircraft_shadow": "balloon.png",';
482
+									}
362 483
 								} else {
363
-									if ($compress) $output .= '"as": "car.png",';
364
-									else $output .= '"aircraft_shadow": "car.png",';
484
+									if ($compress) {
485
+										$output .= '"as": "car.png",';
486
+									} else {
487
+										$output .= '"aircraft_shadow": "car.png",';
488
+									}
365 489
 								}
366 490
 							} elseif ($marine) {
367
-								if ($compress) $output .= '"as": "ship.png",';
368
-								else $output .= '"aircraft_shadow": "ship.png",';
491
+								if ($compress) {
492
+									$output .= '"as": "ship.png",';
493
+								} else {
494
+									$output .= '"aircraft_shadow": "ship.png",';
495
+								}
369 496
 							} else {
370
-								if ($compress) $output .= '"as": "default.png",';
371
-								else $output .= '"aircraft_shadow": "default.png",';
497
+								if ($compress) {
498
+									$output .= '"as": "default.png",';
499
+								} else {
500
+									$output .= '"aircraft_shadow": "default.png",';
501
+								}
372 502
 							}
373 503
 						} else {
374
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
375
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
504
+							if ($compress) {
505
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
506
+							} else {
507
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
508
+							}
376 509
 						}
377 510
 						if (isset($spotter_item['airline_name'])) {
378 511
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -380,8 +513,11 @@  discard block
 block discarded – undo
380 513
 							$output .= '"airline_name": "NA",';
381 514
 						}
382 515
 						if (isset($spotter_item['departure_airport'])) {
383
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
384
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
516
+							if ($compress) {
517
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
518
+							} else {
519
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
520
+							}
385 521
 						}
386 522
 						if (isset($spotter_item['departure_airport_city'])) {
387 523
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -393,8 +529,11 @@  discard block
 block discarded – undo
393 529
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
394 530
 						}
395 531
 						if (isset($spotter_item['arrival_airport'])) {
396
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
397
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
532
+							if ($compress) {
533
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
534
+							} else {
535
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
536
+							}
398 537
 						}
399 538
 						if (isset($spotter_item['arrival_airport_city'])) {
400 539
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -413,8 +552,11 @@  discard block
 block discarded – undo
413 552
 						}
414 553
 						
415 554
 						if (isset($spotter_item['altitude'])) {
416
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
417
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
555
+							if ($compress) {
556
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
557
+							} else {
558
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
559
+							}
418 560
 						}
419 561
 						
420 562
 						$heading = $spotter_item['heading'];
@@ -438,19 +580,24 @@  discard block
 block discarded – undo
438 580
 							}
439 581
 						}
440 582
 						
441
-						if ($compress)$output .= '"h": "'.$heading.'",';
442
-						else $output .= '"heading": "'.$heading.'",';
583
+						if ($compress) {
584
+							$output .= '"h": "'.$heading.'",';
585
+						} else {
586
+							$output .= '"heading": "'.$heading.'",';
587
+						}
443 588
 						if ($currenttime != '') {
444 589
 							if (strtotime($spotter_item['date']) < $currenttime) {
445 590
 								if (isset($archivespeed)) {
446 591
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
447 592
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
448
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
449
-									else {
593
+									if (!isset($idistance) || $fdistance < $idistance) {
594
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
595
+									} else {
450 596
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
451 597
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
452
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
453
-										else {
598
+										if (!isset($idistance) || $fdistance < $idistance) {
599
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
600
+										} else {
454 601
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
455 602
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
456 603
 										}
@@ -458,12 +605,14 @@  discard block
 block discarded – undo
458 605
 								} elseif ($usenextlatlon) {
459 606
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
460 607
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
461
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
462
-									else {
608
+									if (!isset($idistance) || $fdistance < $idistance) {
609
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
610
+									} else {
463 611
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
464 612
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
465
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
466
-										else {
613
+										if (!isset($idistance) || $fdistance < $idistance) {
614
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
615
+										} else {
467 616
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
468 617
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
469 618
 										}
@@ -502,7 +651,9 @@  discard block
 block discarded – undo
502 651
 							}
503 652
 						}
504 653
 
505
-						if (!$min) $output .= '"image": "'.$image.'",';
654
+						if (!$min) {
655
+							$output .= '"image": "'.$image.'",';
656
+						}
506 657
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
507 658
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
508 659
 						}
@@ -510,8 +661,11 @@  discard block
 block discarded – undo
510 661
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
511 662
 						}
512 663
 						if (isset($spotter_item['squawk'])) {
513
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
514
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
664
+							if ($compress) {
665
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
666
+							} else {
667
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
668
+							}
515 669
 						}
516 670
 						if (isset($spotter_item['squawk_usage'])) {
517 671
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -530,14 +684,23 @@  discard block
 block discarded – undo
530 684
 						}
531 685
 						// type when not aircraft ?
532 686
 						if (isset($spotter_item['type'])) {
533
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
534
-							else $output .= '"type": "'.$spotter_item['type'].'"';
687
+							if ($compress) {
688
+								$output .= '"t": "'.$spotter_item['type'].'"';
689
+							} else {
690
+								$output .= '"type": "'.$spotter_item['type'].'"';
691
+							}
535 692
 						} elseif ($marine) {
536
-							if ($compress) $output .= '"t": "ship"';
537
-							else $output .= '"type": "ship"';
693
+							if ($compress) {
694
+								$output .= '"t": "ship"';
695
+							} else {
696
+								$output .= '"type": "ship"';
697
+							}
538 698
 						} else {
539
-							if ($compress) $output .= '"t": "aircraft"';
540
-							else $output .= '"type": "aircraft"';
699
+							if ($compress) {
700
+								$output .= '"t": "aircraft"';
701
+							} else {
702
+								$output .= '"type": "aircraft"';
703
+							}
541 704
 						}
542 705
 						$output .= '},';
543 706
 						$output .= '"geometry": {';
@@ -545,15 +708,19 @@  discard block
 block discarded – undo
545 708
 								$output .= '"coordinates": [';
546 709
 								if ($currenttime != '') {
547 710
 									if (strtotime($spotter_item['date']) < $currenttime) {
548
-										if (!isset($archivespeed)) $archivespeed = 1;
711
+										if (!isset($archivespeed)) {
712
+											$archivespeed = 1;
713
+										}
549 714
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
550 715
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
551
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
552
-										else {
716
+										if (!isset($idistance) || $fdistance < $idistance) {
717
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
718
+										} else {
553 719
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
554 720
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
555
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
556
-											else {
721
+											if (!isset($idistance) || $fdistance < $idistance) {
722
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
723
+											} else {
557 724
 												$output .= $spotter_item['longitude'].', ';
558 725
 												$output .= $spotter_item['latitude'];
559 726
 											}
@@ -631,7 +798,9 @@  discard block
 block discarded – undo
631 798
 			}
632 799
 */
633 800
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
634
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
801
+				if ($history == '' && isset($_COOKIE['history'])) {
802
+					$history = $_COOKIE['history'];
803
+				}
635 804
 				
636 805
 				if (
637 806
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -697,8 +866,11 @@  discard block
 block discarded – undo
697 866
 									$output_history .= ']}},';
698 867
 									$output .= $output_history;
699 868
 								}
700
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
701
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
869
+								if ($compress) {
870
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
871
+								} else {
872
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
873
+								}
702 874
 							}
703 875
 							$output_history .= '[';
704 876
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -719,10 +891,15 @@  discard block
 block discarded – undo
719 891
 							if ($d == false) {
720 892
 								if ($compress) {
721 893
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
722
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
723
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
894
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
895
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
896
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
897
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
898
+									}
724 899
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
725
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
900
+								} else {
901
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
902
+								}
726 903
 								$d = true;
727 904
 							}
728 905
 							$output_history .= '[';
@@ -745,7 +922,9 @@  discard block
 block discarded – undo
745 922
 							$output_historyd = '[';
746 923
 							$output_historyd .=  $spotter_item['longitude'].', ';
747 924
 							$output_historyd .=  $spotter_item['latitude'];
748
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
925
+							if (isset($spotter_history['altitude'])) {
926
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
927
+							}
749 928
 							$output_historyd .= '],';
750 929
 							//$output_history = $output_historyd.$output_history;
751 930
 							$output_history = $output_history.$output_historyd;
@@ -772,8 +951,11 @@  discard block
 block discarded – undo
772 951
 				        && $spotter_item['arrival_airport'] != 'NA' 
773 952
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
774 953
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
775
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
776
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
954
+				    if ($compress) {
955
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
956
+				    } else {
957
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
958
+				    }
777 959
 				    if (isset($spotter_item['departure_airport_latitude'])) {
778 960
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
779 961
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -806,8 +988,11 @@  discard block
 block discarded – undo
806 988
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
807 989
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
808 990
 				    $havedata = false;
809
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
810
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
991
+				    if ($compress) {
992
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
993
+				    } else {
994
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
995
+				    }
811 996
 				    $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
812 997
 
813 998
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -822,7 +1007,9 @@  discard block
 block discarded – undo
822 1007
 				    }
823 1008
 				    //$output_dest  = substr($output_dest, 0, -1);
824 1009
 				    $output_dest .= ']}},';
825
-				    if ($havedata) $output .= $output_dest;
1010
+				    if ($havedata) {
1011
+				    	$output .= $output_dest;
1012
+				    }
826 1013
 				    unset($output_dest);
827 1014
 				}
828 1015
 			}
@@ -830,7 +1017,9 @@  discard block
 block discarded – undo
830 1017
 			$output .= ']';
831 1018
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
832 1019
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
833
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1020
+			if (isset($begindate)) {
1021
+				$output .= '"archive_date": "'.$begindate.'",';
1022
+			}
834 1023
 			$output .= '"fc": "'.$j.'"';
835 1024
 		} else {
836 1025
 			$output .= '"features": ';
Please login to merge, or discard this patch.
header.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -14,35 +14,35 @@  discard block
 block discarded – undo
14 14
 if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline';
15 15
 
16 16
 if (isset($_GET['3d'])) {
17
-	setcookie('MapFormat','3d');
17
+	setcookie('MapFormat', '3d');
18 18
 } else if (isset($_GET['2d'])) {
19
-	setcookie('MapFormat','2d');
19
+	setcookie('MapFormat', '2d');
20 20
 }
21 21
 
22 22
 if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) {
23
-	$tsk = filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL);
23
+	$tsk = filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL);
24 24
 }
25 25
 
26 26
 if (isset($_POST['archive'])) {
27
-	setcookie('archive','true');
28
-	setcookie('archive_begin',strtotime($_POST['start_date']));
29
-	setcookie('archive_end',strtotime($_POST['end_date']));
30
-	setcookie('archive_speed',$_POST['archivespeed']);
27
+	setcookie('archive', 'true');
28
+	setcookie('archive_begin', strtotime($_POST['start_date']));
29
+	setcookie('archive_end', strtotime($_POST['end_date']));
30
+	setcookie('archive_speed', $_POST['archivespeed']);
31 31
 }
32 32
 if (isset($_POST['noarchive'])) {
33
-	setcookie('archive','false',-1);
34
-	setcookie('archive_begin','',-1);
35
-	setcookie('archive_end','',-1);
36
-	setcookie('archive_speed','',-1);
33
+	setcookie('archive', 'false', -1);
34
+	setcookie('archive_begin', '', -1);
35
+	setcookie('archive_end', '', -1);
36
+	setcookie('archive_speed', '', -1);
37 37
 }
38 38
 // When button "Remove all filters" is clicked
39 39
 if (isset($_POST['removefilters'])) {
40
-	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
41
-	    return strpos($key,'filter_') === 0;
40
+	$allfilters = array_filter(array_keys($_COOKIE), function($key) {
41
+	    return strpos($key, 'filter_') === 0;
42 42
 	});
43 43
 	foreach ($allfilters as $filt) {
44 44
 		unset($_COOKIE[$filt]);
45
-		setcookie($filt,null,-1);
45
+		setcookie($filt, null, -1);
46 46
 	}
47 47
 }
48 48
 ?>
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
265 265
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
266 266
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
267
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
267
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if (isset($latitude)) print '&latitude='.$latitude; ?><?php if (isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
268 268
 <?php
269 269
 		if (!isset($type) || $type == 'aircraft') {
270 270
 ?>
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
338 338
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
339 339
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
340
-<script src="<?php print $globalURL; ?>/js/map.2d.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>
340
+<script src="<?php print $globalURL; ?>/js/map.2d.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>
341 341
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
342 342
 <?php
343 343
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 ?>
743 743
       <div class="search">
744 744
 	<form action="<?php print $globalURL; ?>/search" method="get">
745
-		<!--<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>-->
746
-		<input type="text" name="callsign" value="<?php if (isset($GET['callsign'])) { if ($_GET['callsign'] != ""){ print $_GET['callsign']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
745
+		<!--<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>-->
746
+		<input type="text" name="callsign" value="<?php if (isset($GET['callsign'])) { if ($_GET['callsign'] != "") { print $_GET['callsign']; } else { print _("Search"); } } else { print _("Search"); } ?>" onfocus="if (this.value=='search'){this.value='';}" /><button type="submit"><i class="fa fa-search"></i></button>
747 747
 	</form>
748 748
 	</div>
749 749
   	<div class="social">
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	print '</div>';
762 762
 }
763 763
 
764
-if (strtolower($current_page) =='ident-detailed' || strtolower($current_page) == 'flightid-overview') {
764
+if (strtolower($current_page) == 'ident-detailed' || strtolower($current_page) == 'flightid-overview') {
765 765
 ?>
766 766
     <div class="top-header clear" role="main">
767 767
 <?php
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
     </div>
775 775
 <?php
776 776
 }
777
-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))
777
+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))
778 778
 {
779 779
     ?>
780 780
     <div class="top-header clear" role="main">
@@ -787,15 +787,15 @@  discard block
 block discarded – undo
787 787
         var zoom = 13;
788 788
 //create the map
789 789
 <?php
790
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
790
+    if (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($airport_array[0]['latitude'])) {
791 791
 ?>
792 792
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
793 793
 <?php
794
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
794
+    } elseif (strpos(strtolower($current_page), 'airport-') !== false && strpos(strtolower($current_page), 'statistics-') === false) {
795 795
 ?>
796 796
   map = L.map('map', { zoomControl:true });
797 797
 <?php
798
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
798
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
799 799
 ?>
800 800
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
801 801
     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);
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
     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);
804 804
     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);
805 805
 <?php
806
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
806
+    } elseif (strpos(strtolower($current_page), 'route-') !== false && strpos(strtolower($current_page), 'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
807 807
 ?>
808 808
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
809 809
 <?php
Please login to merge, or discard this patch.
Braces   +90 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,12 +6,19 @@  discard block
 block discarded – undo
6 6
 //gets the page file and stores it in a variable
7 7
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
8 8
 $current_page = $file_path['filename'];
9
-if ($globalTimezone == '') $globalTimezone = 'UTC';
9
+if ($globalTimezone == '') {
10
+	$globalTimezone = 'UTC';
11
+}
10 12
 date_default_timezone_set($globalTimezone);
11
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
12
-else $MapType = $globalMapProvider;
13
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
14
+	$MapType = $_COOKIE['MapType'];
15
+} else {
16
+	$MapType = $globalMapProvider;
17
+}
13 18
 
14
-if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline';
19
+if (isset($globalMapOffline) && $globalMapOffline) {
20
+	$MapType = 'offline';
21
+}
15 22
 
16 23
 if (isset($_GET['3d'])) {
17 24
 	setcookie('MapFormat','3d');
@@ -219,7 +226,10 @@  discard block
 block discarded – undo
219 226
 <?php
220 227
 //		}
221 228
 ?>
222
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) print '&tsk='.$tsk; ?>"></script>
229
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) {
230
+	print '&tsk='.$tsk;
231
+}
232
+?>"></script>
223 233
 <?php
224 234
 		if (!isset($globalAircraft) || $globalAircraft) {
225 235
 ?>
@@ -264,7 +274,13 @@  discard block
 block discarded – undo
264 274
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
265 275
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
266 276
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
267
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
277
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
278
+	print '&latitude='.$latitude;
279
+}
280
+?><?php if(isset($longitude)) {
281
+	print '&longitude='.$longitude;
282
+}
283
+?>&<?php print time(); ?>"></script>
268 284
 <?php
269 285
 		if (!isset($type) || $type == 'aircraft') {
270 286
 ?>
@@ -337,7 +353,13 @@  discard block
 block discarded – undo
337 353
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
338 354
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
339 355
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
340
-<script src="<?php print $globalURL; ?>/js/map.2d.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>
356
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
357
+	print '&latitude='.$latitude;
358
+}
359
+?><?php if(isset($longitude)) {
360
+	print '&longitude='.$longitude;
361
+}
362
+?>&<?php print time(); ?>"></script>
341 363
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
342 364
 <?php
343 365
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -418,7 +440,12 @@  discard block
 block discarded – undo
418 440
         <span class="icon-bar"></span>
419 441
       </button>
420 442
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle search"><i class="fa fa-search"></i></a>
421
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
443
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
444
+	print '/';
445
+} else {
446
+	print $globalURL;
447
+}
448
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
422 449
     </div>
423 450
     <div class="collapse navbar-collapse">
424 451
 
@@ -473,7 +500,10 @@  discard block
 block discarded – undo
473 500
 	}
474 501
 ?>
475 502
 
476
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
503
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
504
+	echo 'right-';
505
+}
506
+?>caret"></b></a>
477 507
           <ul class="dropdown-menu">
478 508
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li>
479 509
 <?php
@@ -544,8 +574,14 @@  discard block
 block discarded – undo
544 574
         </li>
545 575
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
546 576
       	<li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li>
547
-        <li class="dropdown<?php if ($sub) echo '-submenu'; ?>">
548
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
577
+        <li class="dropdown<?php if ($sub) {
578
+	echo '-submenu';
579
+}
580
+?>">
581
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) {
582
+	echo 'right-';
583
+}
584
+?>caret"></b></a>
549 585
           <ul class="dropdown-menu">
550 586
           	<li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li>
551 587
           	<li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li>
@@ -589,7 +625,10 @@  discard block
 block discarded – undo
589 625
 <?php
590 626
 	}
591 627
 ?>
592
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
628
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
629
+	echo 'right-';
630
+}
631
+?>caret"></b></a>
593 632
 		<ul class="dropdown-menu">
594 633
 		    <li><a href="<?php print $globalURL; ?>/marine/currently"><?php echo _("Current Activity"); ?></a></li>
595 634
 		    <li><a href="<?php print $globalURL; ?>/marine/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -630,7 +669,10 @@  discard block
 block discarded – undo
630 669
 <?php
631 670
 	}
632 671
 ?>
633
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
672
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
673
+	echo 'right-';
674
+}
675
+?>caret"></b></a>
634 676
 		<ul class="dropdown-menu">
635 677
 		    <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li>
636 678
 		    <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -673,7 +715,10 @@  discard block
 block discarded – undo
673 715
 ?>
674 716
 
675 717
 <!--
676
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
718
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
719
+	echo 'right-';
720
+}
721
+?>caret"></b></a>
677 722
 		<ul class="dropdown-menu">
678 723
 		    <li><a href="<?php print $globalURL; ?>/satellite/currently"><?php echo _("Current Activity"); ?></a></li>
679 724
 		    <li><a href="<?php print $globalURL; ?>/satellite/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -730,7 +775,9 @@  discard block
 block discarded – undo
730 775
   		        $alllang = $Language->getLanguages();
731 776
   		        foreach ($alllang as $key => $lang) {
732 777
   		            print '<option value="'.$key.'"';
733
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
778
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
779
+  		            	print ' selected ';
780
+  		            }
734 781
   		            print '>'.$lang[0].'</option>';
735 782
   		        }
736 783
   		    ?>
@@ -878,9 +925,24 @@  discard block
 block discarded – undo
878 925
 	$customid = $globalMapProvider;
879 926
 ?>
880 927
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
881
-        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
882
-        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
883
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
928
+        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
929
+	print $globalMapCustomLayer[$customid]['maxZoom'];
930
+} else {
931
+	print '18';
932
+}
933
+?>,
934
+        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
935
+	print $globalMapCustomLayer[$customid]['minZoom'];
936
+} else {
937
+	print '0';
938
+}
939
+?>,
940
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
941
+	print 'false';
942
+} else {
943
+	print 'true';
944
+}
945
+?>,
884 946
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
885 947
     }).addTo(map);
886 948
 <?php
@@ -895,7 +957,12 @@  discard block
 block discarded – undo
895 957
         maxZoom: 5,
896 958
         tms : true,
897 959
         zindex : 3,
898
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
960
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
961
+	print 'false';
962
+} else {
963
+	print 'true';
964
+}
965
+?>,
899 966
         attribution: 'Natural Earth'
900 967
     }).addTo(map);
901 968
 <?php
@@ -918,4 +985,7 @@  discard block
 block discarded – undo
918 985
 
919 986
 ?>
920 987
 
921
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
988
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
989
+	print 'index ';
990
+}
991
+?>clear">
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +592 added lines, -159 removed lines patch added patch discarded remove patch
@@ -4,11 +4,19 @@  discard block
 block discarded – undo
4 4
 if (isset($_SESSION['error'])) {
5 5
 	header('Content-Encoding: none;');
6 6
 	echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.';
7
-	if (isset($_SESSION['error'])) unset($_SESSION['error']);
8
-	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
9
-	if (isset($_SESSION['next'])) unset($_SESSION['next']);
10
-	if (isset($_SESSION['install'])) unset($_SESSION['install']);
11
-}
7
+	if (isset($_SESSION['error'])) {
8
+		unset($_SESSION['error']);
9
+	}
10
+	if (isset($_SESSION['errorlst'])) {
11
+		unset($_SESSION['errorlst']);
12
+	}
13
+	if (isset($_SESSION['next'])) {
14
+		unset($_SESSION['next']);
15
+	}
16
+	if (isset($_SESSION['install'])) {
17
+		unset($_SESSION['install']);
18
+	}
19
+	}
12 20
 /*
13 21
 if (isset($_SESSION['errorlst'])) {
14 22
 	header('Content-Encoding: none;');
@@ -159,31 +167,49 @@  discard block
 block discarded – undo
159 167
 			</div>
160 168
 			<p>
161 169
 				<label for="dbhost">Database hostname</label>
162
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
170
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
171
+	print $globalDBhost;
172
+}
173
+?>" />
163 174
 			</p>
164 175
 			<p>
165 176
 				<label for="dbport">Database port</label>
166
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
177
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
178
+	print $globalDBport;
179
+}
180
+?>" />
167 181
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
168 182
 			</p>
169 183
 			<p>
170 184
 				<label for="dbname">Database name</label>
171
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
185
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
186
+	print $globalDBname;
187
+}
188
+?>" />
172 189
 			</p>
173 190
 			<p>
174 191
 				<label for="dbuser">Database user</label>
175
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
192
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
193
+	print $globalDBuser;
194
+}
195
+?>" />
176 196
 			</p>
177 197
 			<p>
178 198
 				<label for="dbuserpass">Database user password</label>
179
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
199
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
200
+	print $globalDBpass;
201
+}
202
+?>" />
180 203
 			</p>
181 204
 		</fieldset>
182 205
 		<fieldset id="site">
183 206
 			<legend>Site configuration</legend>
184 207
 			<p>
185 208
 				<label for="sitename">Site name</label>
186
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
209
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
210
+	print $globalName;
211
+}
212
+?>" />
187 213
 			</p>
188 214
 			<p>
189 215
 				<label for="siteurl">Site directory</label>
@@ -196,18 +222,27 @@  discard block
 block discarded – undo
196 222
 					}
197 223
 				    }
198 224
 				?>
199
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
225
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
226
+	print $globalURL;
227
+}
228
+?>" />
200 229
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
201 230
 				<p class="help-block">Can be empty</p>
202 231
 			</p>
203 232
 			<p>
204 233
 				<label for="timezone">Timezone</label>
205
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
234
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
235
+	print $globalTimezone;
236
+}
237
+?>" />
206 238
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
207 239
 			</p>
208 240
 			<p>
209 241
 				<label for="language">Language</label>
210
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
242
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
243
+	print $globalLanguage;
244
+}
245
+?>" />
211 246
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
212 247
 			</p>
213 248
 		</fieldset>
@@ -227,11 +262,17 @@  discard block
 block discarded – undo
227 262
 			<div id="mapbox_data">
228 263
 				<p>
229 264
 					<label for="mapboxid">Mapbox id</label>
230
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
265
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
266
+	print $globalMapboxId;
267
+}
268
+?>" />
231 269
 				</p>
232 270
 				<p>
233 271
 					<label for="mapboxtoken">Mapbox token</label>
234
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
272
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
273
+	print $globalMapboxToken;
274
+}
275
+?>" />
235 276
 				</p>
236 277
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
237 278
 			</div>
@@ -239,7 +280,10 @@  discard block
 block discarded – undo
239 280
 			<div id="google_data">
240 281
 				<p>
241 282
 					<label for="googlekey">Google API key</label>
242
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
283
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
284
+	print $globalGoogleAPIKey;
285
+}
286
+?>" />
243 287
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
244 288
 				</p>
245 289
 			</div>
@@ -247,7 +291,10 @@  discard block
 block discarded – undo
247 291
 			<div id="bing_data">
248 292
 				<p>
249 293
 					<label for="bingkey">Bing Map key</label>
250
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
294
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
295
+	print $globalBingMapKey;
296
+}
297
+?>" />
251 298
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
252 299
 				</p>
253 300
 			</div>
@@ -255,7 +302,10 @@  discard block
 block discarded – undo
255 302
 			<div id="mapquest_data">
256 303
 				<p>
257 304
 					<label for="mapquestkey">MapQuest key</label>
258
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
305
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
306
+	print $globalMapQuestKey;
307
+}
308
+?>" />
259 309
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
260 310
 				</p>
261 311
 			</div>
@@ -263,11 +313,17 @@  discard block
 block discarded – undo
263 313
 			<div id="here_data">
264 314
 				<p>
265 315
 					<label for="hereappid">Here App_Id</label>
266
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
316
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
317
+	print $globalHereappId;
318
+}
319
+?>" />
267 320
 				</p>
268 321
 				<p>
269 322
 					<label for="hereappcode">Here App_Code</label>
270
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
323
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
324
+	print $globalHereappCode;
325
+}
326
+?>" />
271 327
 				</p>
272 328
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
273 329
 			</div>
@@ -275,7 +331,10 @@  discard block
 block discarded – undo
275 331
 			<div id="openweathermap_data">
276 332
 				<p>
277 333
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
278
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
334
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
335
+	print $globalOpenWeatherMapKey;
336
+}
337
+?>" />
279 338
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
280 339
 				</p>
281 340
 			</div>
@@ -304,42 +363,86 @@  discard block
 block discarded – undo
304 363
 			<legend>Coverage area</legend>
305 364
 			<p>
306 365
 				<label for="latitudemax">The maximum latitude (north)</label>
307
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
366
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
367
+	print $globalLatitudeMax;
368
+}
369
+?>" />
308 370
 			</p>
309 371
 			<p>
310 372
 				<label for="latitudemin">The minimum latitude (south)</label>
311
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
373
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
374
+	print $globalLatitudeMin;
375
+}
376
+?>" />
312 377
 			</p>
313 378
 			<p>
314 379
 				<label for="longitudemax">The maximum longitude (west)</label>
315
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
380
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
381
+	print $globalLongitudeMax;
382
+}
383
+?>" />
316 384
 			</p>
317 385
 			<p>
318 386
 				<label for="longitudemin">The minimum longitude (east)</label>
319
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
387
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
388
+	print $globalLongitudeMin;
389
+}
390
+?>" />
320 391
 			</p>
321 392
 			<p>
322 393
 				<label for="latitudecenter">The latitude center</label>
323
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
394
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
395
+	print $globalCenterLatitude;
396
+}
397
+?>" />
324 398
 			</p>
325 399
 			<p>
326 400
 				<label for="longitudecenter">The longitude center</label>
327
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
401
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
402
+	print $globalCenterLongitude;
403
+}
404
+?>" />
328 405
 			</p>
329 406
 			<p>
330 407
 				<label for="livezoom">Default Zoom on live map</label>
331
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
408
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
409
+	print $globalLiveZoom;
410
+} else {
411
+	print '9';
412
+}
413
+?>" />
332 414
 			</p>
333 415
 			<p>
334 416
 				<label for="squawk_country">Country for squawk usage</label>
335 417
 				<select name="squawk_country" id="squawk_country">
336
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
337
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
338
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
339
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
340
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
341
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
342
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
418
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
419
+	print ' selected ';
420
+}
421
+?>>UK</option>
422
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
423
+	print ' selected ';
424
+}
425
+?>>NZ</option>
426
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
427
+	print ' selected ';
428
+}
429
+?>>US</option>
430
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
431
+	print ' selected ';
432
+}
433
+?>>AU</option>
434
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
435
+	print ' selected ';
436
+}
437
+?>>NL</option>
438
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
439
+	print ' selected ';
440
+}
441
+?>>FR</option>
442
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
443
+	print ' selected ';
444
+}
445
+?>>TR</option>
343 446
 				</select>
344 447
 			</p>
345 448
 		</fieldset>
@@ -348,15 +451,24 @@  discard block
 block discarded – undo
348 451
 			<p><i>Only put in DB flights that are inside a circle</i></p>
349 452
 			<p>
350 453
 				<label for="latitude">Center latitude</label>
351
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
454
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
455
+	echo $globalDistanceIgnore['latitude'];
456
+}
457
+?>" />
352 458
 			</p>
353 459
 			<p>
354 460
 				<label for="longitude">Center longitude</label>
355
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
461
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
462
+	echo $globalDistanceIgnore['longitude'];
463
+}
464
+?>" />
356 465
 			</p>
357 466
 			<p>
358 467
 				<label for="Distance">Distance (in km)</label>
359
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
468
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
469
+	echo $globalDistanceIgnore['distance'];
470
+}
471
+?>" />
360 472
 			</p>
361 473
 		</fieldset>
362 474
 		<fieldset id="sourceloc">
@@ -472,11 +584,17 @@  discard block
 block discarded – undo
472 584
 			<div id="flightaware_data">
473 585
 				<p>
474 586
 					<label for="flightawareusername">FlightAware username</label>
475
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
587
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
588
+	print $globalFlightAwareUsername;
589
+}
590
+?>" />
476 591
 				</p>
477 592
 				<p>
478 593
 					<label for="flightawarepassword">FlightAware password/API key</label>
479
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
594
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
595
+	print $globalFlightAwarePassword;
596
+}
597
+?>" />
480 598
 				</p>
481 599
 			</div>
482 600
 -->
@@ -518,7 +636,10 @@  discard block
 block discarded – undo
518 636
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
519 637
 								?>
520 638
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
521
-								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
639
+								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
640
+	print $source['port'];
641
+}
642
+?>" /></td>
522 643
 								<?php
523 644
 								    } else {
524 645
 									$hostport = explode(':',$source['host']);
@@ -537,35 +658,110 @@  discard block
 block discarded – undo
537 658
 								?>
538 659
 								<td>
539 660
 									<select name="format[]" id="format">
540
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
541
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
542
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
543
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
544
-										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
545
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
546
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
547
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
548
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
549
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
550
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
551
-										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
552
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
553
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
554
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
555
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
556
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
557
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
558
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
559
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
560
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
561
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
661
+										<option value="auto" <?php if (!isset($source['format'])) {
662
+	print 'selected';
663
+}
664
+?>>Auto</option>
665
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
666
+	print 'selected';
667
+}
668
+?>>SBS</option>
669
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
670
+	print 'selected';
671
+}
672
+?>>TSV</option>
673
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
674
+	print 'selected';
675
+}
676
+?>>Raw</option>
677
+										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') {
678
+	print 'selected';
679
+}
680
+?>>Dump1090 aircraft.json</option>
681
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
682
+	print 'selected';
683
+}
684
+?>>APRS</option>
685
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
686
+	print 'selected';
687
+}
688
+?>>Radarcape deltadb.txt</option>
689
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
690
+	print 'selected';
691
+}
692
+?>>Vatsim</option>
693
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
694
+	print 'selected';
695
+}
696
+?>>Virtual Radar Server AircraftList.json</option>
697
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
698
+	print 'selected';
699
+}
700
+?>>Virtual Radar Server TCP</option>
701
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
702
+	print 'selected';
703
+}
704
+?>>phpVMS</option>
705
+										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
706
+	print 'selected';
707
+}
708
+?>>Virtual Airline Operations System (VAOS)</option>
709
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
710
+	print 'selected';
711
+}
712
+?>>Virtual Airlines Manager</option>
713
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
714
+	print 'selected';
715
+}
716
+?>>IVAO</option>
717
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
718
+	print 'selected';
719
+}
720
+?>>FlightGear Multiplayer</option>
721
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
722
+	print 'selected';
723
+}
724
+?>>FlightGear Singleplayer</option>
725
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
726
+	print 'selected';
727
+}
728
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
729
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
730
+	print 'selected';
731
+}
732
+?>>ACARS SBS-3 over TCP</option>
733
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
734
+	print 'selected';
735
+}
736
+?>>NMEA AIS over TCP</option>
737
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
738
+	print 'selected';
739
+}
740
+?>>AirWhere website</option>
741
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
742
+	print 'selected';
743
+}
744
+?>>HidnSeek Callback</option>
745
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
746
+	print 'selected';
747
+}
748
+?>>Blitzortung</option>
562 749
 									</select>
563 750
 								</td>
564 751
 								<td>
565
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
752
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
753
+	print $source['name'];
754
+}
755
+?>" />
566 756
 								</td>
567
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
568
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
757
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
758
+	print 'checked';
759
+}
760
+?> /></td>
761
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
762
+	print 'checked';
763
+}
764
+?> /></td>
569 765
 								<td>
570 766
 									<select name="timezones[]" id="timezones">
571 767
 								<?php
@@ -575,7 +771,9 @@  discard block
 block discarded – undo
575 771
 											print '<option selected>'.$timezones.'</option>';
576 772
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
577 773
 											print '<option selected>'.$timezones.'</option>';
578
-										} else print '<option>'.$timezones.'</option>';
774
+										} else {
775
+											print '<option>'.$timezones.'</option>';
776
+										}
579 777
 									}
580 778
 								?>
581 779
 									</select>
@@ -627,7 +825,9 @@  discard block
 block discarded – undo
627 825
 									foreach($timezonelist as $timezones){
628 826
 										if ($timezones == 'UTC') {
629 827
 											print '<option selected>'.$timezones.'</option>';
630
-										} else print '<option>'.$timezones.'</option>';
828
+										} else {
829
+											print '<option>'.$timezones.'</option>';
830
+										}
631 831
 									}
632 832
 								?>
633 833
 									</select>
@@ -652,11 +852,17 @@  discard block
 block discarded – undo
652 852
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
653 853
 					<p>
654 854
 						<label for="acarshost">ACARS UDP host</label>
655
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
855
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
856
+	print $globalACARSHost;
857
+}
858
+?>" />
656 859
 					</p>
657 860
 					<p>
658 861
 						<label for="acarsport">ACARS UDP port</label>
659
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
862
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
863
+	print $globalACARSPort;
864
+}
865
+?>" />
660 866
 					</p>
661 867
 				</fieldset>
662 868
 			</div>
@@ -682,17 +888,38 @@  discard block
 block discarded – undo
682 888
 				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
683 889
 				    <td>
684 890
 					<select name="newslang[]">
685
-					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
686
-					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
891
+					    <option value="en"<?php if ($lng == 'en') {
892
+	print ' selected';
893
+}
894
+?>>English</option>
895
+					    <option value="fr"<?php if ($lng == 'fr') {
896
+	print ' selected';
897
+}
898
+?>>French</option>
687 899
 					</select>
688 900
 				    </td>
689 901
 				    <td>
690 902
 					<select name="newstype[]">
691
-					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
692
-					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
693
-					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
694
-					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
695
-					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
903
+					    <option value="global"<?php if ($type == 'global') {
904
+	print ' selected';
905
+}
906
+?>>Global</option>
907
+					    <option value="aircraft"<?php if ($type == 'aircraft') {
908
+	print ' selected';
909
+}
910
+?>>Aircraft</option>
911
+					    <option value="marine"<?php if ($type == 'marine') {
912
+	print ' selected';
913
+}
914
+?>>Marine</option>
915
+					    <option value="tracker"<?php if ($type == 'tracker') {
916
+	print ' selected';
917
+}
918
+?>>Tracker</option>
919
+					    <option value="satellite"<?php if ($type == 'Satellite') {
920
+	print ' selected';
921
+}
922
+?>>Satellite</option>
696 923
 					</select>
697 924
 				    </td>
698 925
 				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
@@ -825,13 +1052,19 @@  discard block
 block discarded – undo
825 1052
 			<div id="schedules_options">
826 1053
 				<p>
827 1054
 					<label for="britishairways">British Airways API Key</label>
828
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
1055
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
1056
+	print $globalBritishAirwaysKey;
1057
+}
1058
+?>" />
829 1059
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
830 1060
 				</p>
831 1061
 				<!--
832 1062
 				<p>
833 1063
 					<label for="transavia">Transavia Test API Consumer Key</label>
834
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
1064
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
1065
+	print $globalTransaviaKey;
1066
+}
1067
+?>" />
835 1068
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
836 1069
 				</p>
837 1070
 				-->
@@ -840,10 +1073,16 @@  discard block
 block discarded – undo
840 1073
 						<b>Lufthansa API Key</b>
841 1074
 						<p>
842 1075
 							<label for="lufthansakey">Key</label>
843
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
1076
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
1077
+	print $globalLufthansaKey['key'];
1078
+}
1079
+?>" />
844 1080
 						</p><p>
845 1081
 							<label for="lufthansasecret">Secret</label>
846
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
1082
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
1083
+	print $globalLufthansaKey['secret'];
1084
+}
1085
+?>" />
847 1086
 						</p>
848 1087
 					</div>
849 1088
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -853,11 +1092,17 @@  discard block
 block discarded – undo
853 1092
 						<b>FlightAware API Key</b>
854 1093
 						<p>
855 1094
 							<label for="flightawareusername">Username</label>
856
-							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
1095
+							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
1096
+	print $globalFlightAwareUsername;
1097
+}
1098
+?>" />
857 1099
 						</p>
858 1100
 						<p>
859 1101
 							<label for="flightawarepassword">API key</label>
860
-							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
1102
+							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
1103
+	print $globalFlightAwarePassword;
1104
+}
1105
+?>" />
861 1106
 						</p>
862 1107
 					</div>
863 1108
 					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
@@ -874,10 +1119,22 @@  discard block
 block discarded – undo
874 1119
 				<p>
875 1120
 					<label for="mapmatchingsource">Map Matching source</label>
876 1121
 					<select name="mapmatchingsource" id="mapmatchingsource">
877
-						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
878
-						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
879
-						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr')) print 'selected="selected" '; ?>>OSMR</option>
880
-						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
1122
+						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) {
1123
+	print 'selected="selected" ';
1124
+}
1125
+?>>FlightAirMap Map Matching</option>
1126
+						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') {
1127
+	print 'selected="selected" ';
1128
+}
1129
+?>>GraphHopper</option>
1130
+						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') {
1131
+	) print 'selected="selected" ';
1132
+}
1133
+?>>OSMR</option>
1134
+						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') {
1135
+	print 'selected="selected" ';
1136
+}
1137
+?>>Mapbox</option>
881 1138
 					</select>
882 1139
 					<p class="help-block">Mapbox need the API Key defined in map section.</p>
883 1140
 					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
@@ -885,7 +1142,10 @@  discard block
 block discarded – undo
885 1142
 				<br />
886 1143
 				<p>
887 1144
 					<label for="graphhopper">GraphHopper API Key</label>
888
-					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
1145
+					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) {
1146
+	print $globalGraphHopperKey;
1147
+}
1148
+?>" />
889 1149
 					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
890 1150
 				</p>
891 1151
 			</div>
@@ -903,7 +1163,10 @@  discard block
 block discarded – undo
903 1163
 			</p>
904 1164
 			<p>
905 1165
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
906
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1166
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
1167
+	print $globalNOTAMSource;
1168
+}
1169
+?>" />
907 1170
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
908 1171
 			</p>
909 1172
 			<br />
@@ -919,14 +1182,20 @@  discard block
 block discarded – undo
919 1182
 			<div id="metarsrc">
920 1183
 				<p>
921 1184
 					<label for="metarsource">URL of your METAR source</label>
922
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1185
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
1186
+	print $globalMETARurl;
1187
+}
1188
+?>" />
923 1189
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
924 1190
 				</p>
925 1191
 			</div>
926 1192
 			<br />
927 1193
 			<p>
928 1194
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
929
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1195
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
1196
+	print $globalBitlyAccessToken;
1197
+}
1198
+?>" />
930 1199
 			</p>
931 1200
 			<br />
932 1201
 			<p>
@@ -942,11 +1211,26 @@  discard block
 block discarded – undo
942 1211
 			<p>
943 1212
 				<label for="geoid_source">Geoid Source</label>
944 1213
 				<select name="geoid_source" id="geoid_source">
945
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
946
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
947
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
948
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
949
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1214
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
1215
+	print ' selected="selected"';
1216
+}
1217
+?>>EGM96 15' (2.1MB)</option>
1218
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
1219
+	print ' selected="selected"';
1220
+}
1221
+?>>EGM96 5' (19MB)</option>
1222
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
1223
+	print ' selected="selected"';
1224
+}
1225
+?>>EGM2008 5' (19MB)</option>
1226
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
1227
+	print ' selected="selected"';
1228
+}
1229
+?>>EGM2008 2.5' (75MB)</option>
1230
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
1231
+	print ' selected="selected"';
1232
+}
1233
+?>>EGM2008 1' (470MB)</option>
950 1234
 				</select>
951 1235
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
952 1236
 			</p>
@@ -968,7 +1252,12 @@  discard block
 block discarded – undo
968 1252
 			</p>
969 1253
 			<p>
970 1254
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
971
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1255
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1256
+	print $globalArchiveMonths;
1257
+} else {
1258
+	echo '1';
1259
+}
1260
+?>" />
972 1261
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
973 1262
 			</p>
974 1263
 			<p>
@@ -978,12 +1267,22 @@  discard block
 block discarded – undo
978 1267
 			</p>
979 1268
 			<p>
980 1269
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
981
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1270
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1271
+	print $globalArchiveKeepMonths;
1272
+} else {
1273
+	echo '1';
1274
+}
1275
+?>" />
982 1276
 				<p class="help-block">0 to disable</p>
983 1277
 			</p>
984 1278
 			<p>
985 1279
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
986
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1280
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1281
+	print $globalArchiveKeepTrackMonths;
1282
+} else {
1283
+	echo '1';
1284
+}
1285
+?>" />
987 1286
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
988 1287
 			</p>
989 1288
 			<br />
@@ -993,7 +1292,12 @@  discard block
 block discarded – undo
993 1292
 				<p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p>
994 1293
 				<div id="cronends"> 
995 1294
 					<label for="cronend">Run script for xx seconds</label>
996
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1295
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1296
+	print $globalCronEnd;
1297
+} else {
1298
+	print '0';
1299
+}
1300
+?>" />
997 1301
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
998 1302
 				</div>
999 1303
 			</p>
@@ -1046,20 +1350,40 @@  discard block
 block discarded – undo
1046 1350
 			<br />
1047 1351
 			<p>
1048 1352
 				<label for="refresh">Show flights detected since xxx seconds</label>
1049
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1353
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1354
+	echo $globalLiveInterval;
1355
+} else {
1356
+	echo '200';
1357
+}
1358
+?>" />
1050 1359
 			</p>
1051 1360
 			<p>
1052 1361
 				<label for="maprefresh">Live map refresh (in seconds)</label>
1053
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1362
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1363
+	echo $globalMapRefresh;
1364
+} else {
1365
+	echo '30';
1366
+}
1367
+?>" />
1054 1368
 			</p>
1055 1369
 			<p>
1056 1370
 				<label for="mapidle">Map idle timeout (in minutes)</label>
1057
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1371
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1372
+	echo $globalMapIdleTimeout;
1373
+} else {
1374
+	echo '30';
1375
+}
1376
+?>" />
1058 1377
 				<p class="help-block">0 to disable</p>
1059 1378
 			</p>
1060 1379
 			<p>
1061 1380
 				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1062
-				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1381
+				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) {
1382
+	echo $globalMinFetch;
1383
+} else {
1384
+	echo '20';
1385
+}
1386
+?>" />
1063 1387
 			</p>
1064 1388
 			<p>
1065 1389
 				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
@@ -1073,12 +1397,20 @@  discard block
 block discarded – undo
1073 1397
 			<br />
1074 1398
 			<p>
1075 1399
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1076
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1400
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1401
+	echo $globalClosestMinDist;
1402
+} else {
1403
+	echo '50';
1404
+}
1405
+?>" />
1077 1406
 			</p>
1078 1407
 			<br />
1079 1408
 			<p>
1080 1409
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1081
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1410
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1411
+	echo $globalAircraftSize;
1412
+}
1413
+?>" />
1082 1414
 			</p>
1083 1415
 			<br />
1084 1416
 			<p>
@@ -1097,7 +1429,12 @@  discard block
 block discarded – undo
1097 1429
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
1098 1430
 			?>
1099 1431
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1100
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1432
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1433
+	echo $globalAircraftIconColor;
1434
+} else {
1435
+	echo '1a3151';
1436
+}
1437
+?>" />
1101 1438
 			<?php
1102 1439
 				if (!is_writable('../cache')) {
1103 1440
 			?>
@@ -1115,14 +1452,27 @@  discard block
 block discarded – undo
1115 1452
 			<p>
1116 1453
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1117 1454
 				<div class="range">
1118
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1119
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1455
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1456
+	echo $globalAirportZoom;
1457
+} else {
1458
+	echo '7';
1459
+}
1460
+?>" />
1461
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1462
+	echo $globalAirportZoom;
1463
+} else {
1464
+	echo '7';
1465
+}
1466
+?></output>
1120 1467
 				</div>
1121 1468
 			</p>
1122 1469
 			<br />
1123 1470
 			<p>
1124 1471
 				<label for="customcss">Custom CSS web path</label>
1125
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1472
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1473
+	echo $globalCustomCSS;
1474
+}
1475
+?>" />
1126 1476
 			</p>
1127 1477
 		</fieldset>
1128 1478
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -1149,8 +1499,12 @@  discard block
 block discarded – undo
1149 1499
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1150 1500
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1151 1501
 
1152
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1153
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1502
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1503
+		$error .= 'Mysql driver for PDO must be loaded';
1504
+	}
1505
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1506
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1507
+	}
1154 1508
 	
1155 1509
 	$_SESSION['database_root'] = $dbroot;
1156 1510
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1218,15 +1572,23 @@  discard block
 block discarded – undo
1218 1572
 	$source_city = $_POST['source_city'];
1219 1573
 	$source_country = $_POST['source_country'];
1220 1574
 	$source_ref = $_POST['source_ref'];
1221
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1222
-	else $source_id = array();
1575
+	if (isset($source_id)) {
1576
+		$source_id = $_POST['source_id'];
1577
+	} else {
1578
+		$source_id = array();
1579
+	}
1223 1580
 	
1224 1581
 	$sources = array();
1225 1582
 	foreach ($source_name as $keys => $name) {
1226
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1227
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1583
+	    if (isset($source_id[$keys])) {
1584
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1585
+	    } else {
1586
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1587
+	    }
1588
+	}
1589
+	if (count($sources) > 0) {
1590
+		$_SESSION['sources'] = $sources;
1228 1591
 	}
1229
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1230 1592
 
1231 1593
 	$newsurl = $_POST['newsurl'];
1232 1594
 	$newslng = $_POST['newslang'];
@@ -1239,7 +1601,9 @@  discard block
 block discarded – undo
1239 1601
 		$lng = $newslng[$newskey];
1240 1602
 		if (isset($newsfeeds[$type][$lng])) {
1241 1603
 		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1242
-		} else $newsfeeds[$type][$lng] = array($url);
1604
+		} else {
1605
+			$newsfeeds[$type][$lng] = array($url);
1606
+		}
1243 1607
 	    }
1244 1608
 	}
1245 1609
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
@@ -1263,17 +1627,29 @@  discard block
 block discarded – undo
1263 1627
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1264 1628
 
1265 1629
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1266
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1267
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1630
+	if ($globalaircraft == 'aircraft') {
1631
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1632
+	} else {
1633
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1634
+	}
1268 1635
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1269
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1270
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1636
+	if ($globaltracker == 'tracker') {
1637
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1638
+	} else {
1639
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1640
+	}
1271 1641
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1272
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1273
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1642
+	if ($globalmarine == 'marine') {
1643
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1644
+	} else {
1645
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1646
+	}
1274 1647
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1275
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1276
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1648
+	if ($globalsatellite == 'satellite') {
1649
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1650
+	} else {
1651
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1652
+	}
1277 1653
 
1278 1654
 /*	
1279 1655
 	$globalSBS1Hosts = array();
@@ -1295,23 +1671,37 @@  discard block
 block discarded – undo
1295 1671
 	$name = $_POST['name'];
1296 1672
 	$format = $_POST['format'];
1297 1673
 	$timezones = $_POST['timezones'];
1298
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1299
-	else $sourcestats = array();
1300
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1301
-	else $noarchive = array();
1674
+	if (isset($_POST['sourcestats'])) {
1675
+		$sourcestats = $_POST['sourcestats'];
1676
+	} else {
1677
+		$sourcestats = array();
1678
+	}
1679
+	if (isset($_POST['noarchive'])) {
1680
+		$noarchive = $_POST['noarchive'];
1681
+	} else {
1682
+		$noarchive = array();
1683
+	}
1302 1684
 	$gSources = array();
1303 1685
 	$forcepilots = false;
1304 1686
 	foreach ($host as $key => $h) {
1305
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1306
-		else $cov = 'FALSE';
1307
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1308
-		else $arch = 'FALSE';
1687
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1688
+			$cov = 'TRUE';
1689
+		} else {
1690
+			$cov = 'FALSE';
1691
+		}
1692
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1693
+			$arch = 'TRUE';
1694
+		} else {
1695
+			$arch = 'FALSE';
1696
+		}
1309 1697
 		if (strpos($format[$key],'_callback')) {
1310 1698
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1311 1699
 		} elseif ($h != '' || $name[$key] != '') {
1312 1700
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1313 1701
 		}
1314
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1702
+		if ($format[$key] == 'airwhere') {
1703
+			$forcepilots = true;
1704
+		}
1315 1705
 	}
1316 1706
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1317 1707
 
@@ -1342,7 +1732,9 @@  discard block
 block discarded – undo
1342 1732
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1343 1733
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1344 1734
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1345
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1735
+	} else {
1736
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1737
+	}
1346 1738
 
1347 1739
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1348 1740
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1383,7 +1775,9 @@  discard block
 block discarded – undo
1383 1775
 
1384 1776
 	// Create in settings.php keys not yet configurable if not already here
1385 1777
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1386
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1778
+	if (!isset($globalDebug)) {
1779
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1780
+	}
1387 1781
 
1388 1782
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1389 1783
 	if ($resetyearstats == 'resetyearstats') {
@@ -1426,37 +1820,56 @@  discard block
 block discarded – undo
1426 1820
 	}
1427 1821
 */
1428 1822
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1429
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1430
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1431
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1432
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1823
+	if ($globalsbs == 'sbs') {
1824
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1825
+	} else {
1826
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1827
+	}
1828
+	if ($globalaprs == 'aprs') {
1829
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1830
+	} else {
1831
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1832
+	}
1433 1833
 	$va = false;
1434 1834
 	if ($globalivao == 'ivao') {
1435 1835
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1436 1836
 		$va = true;
1437
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1837
+	} else {
1838
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1839
+	}
1438 1840
 	if ($globalvatsim == 'vatsim') {
1439 1841
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1440 1842
 		$va = true;
1441
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1843
+	} else {
1844
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1845
+	}
1442 1846
 	if ($globalphpvms == 'phpvms') {
1443 1847
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1444 1848
 		$va = true;
1445
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1849
+	} else {
1850
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1851
+	}
1446 1852
 	if ($globalvam == 'vam') {
1447 1853
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1448 1854
 		$va = true;
1449
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1855
+	} else {
1856
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1857
+	}
1450 1858
 	if ($va) {
1451 1859
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1452
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1860
+	} else {
1861
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1862
+	}
1453 1863
 	if ($globalva == 'va' || $va) {
1454 1864
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1455 1865
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1456 1866
 	} else {
1457 1867
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1458
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1459
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1868
+		if ($forcepilots) {
1869
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1870
+		} else {
1871
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1872
+		}
1460 1873
 	}
1461 1874
 	
1462 1875
 	
@@ -1679,7 +2092,9 @@  discard block
 block discarded – undo
1679 2092
 	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1680 2093
 	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1681 2094
 
1682
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2095
+	if (!isset($globalTransaction)) {
2096
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2097
+	}
1683 2098
 
1684 2099
 	// Set some defaults values...
1685 2100
 	if (!isset($globalAircraftImageSources)) {
@@ -1694,15 +2109,23 @@  discard block
 block discarded – undo
1694 2109
 
1695 2110
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1696 2111
 
1697
-	if ($error == '') settings::modify_settings($settings);
1698
-	if ($error == '') settings::comment_settings($settings_comment);
2112
+	if ($error == '') {
2113
+		settings::modify_settings($settings);
2114
+	}
2115
+	if ($error == '') {
2116
+		settings::comment_settings($settings_comment);
2117
+	}
1699 2118
 	if ($error != '') {
1700 2119
 		print '<div class="info column">'.$error.'</div>';
1701 2120
 		require('../footer.php');
1702 2121
 		exit;
1703 2122
 	} else {
1704
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1705
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
2123
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
2124
+			$_SESSION['waypoints'] = 1;
2125
+		}
2126
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
2127
+			$_SESSION['owner'] = 1;
2128
+		}
1706 2129
 		if (isset($_POST['createdb'])) {
1707 2130
 			$_SESSION['install'] = 'database_create';
1708 2131
 		} else {
@@ -1739,10 +2162,18 @@  discard block
 block discarded – undo
1739 2162
 	$popw = false;
1740 2163
 	foreach ($_SESSION['done'] as $done) {
1741 2164
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1742
-	    if ($done == 'Create database') $pop = true;
1743
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1744
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1745
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
2165
+	    if ($done == 'Create database') {
2166
+	    	$pop = true;
2167
+	    }
2168
+	    if ($_SESSION['install'] == 'database_create') {
2169
+	    	$pop = true;
2170
+	    }
2171
+	    if ($_SESSION['install'] == 'database_import') {
2172
+	    	$popi = true;
2173
+	    }
2174
+	    if ($_SESSION['install'] == 'waypoints') {
2175
+	    	$popw = true;
2176
+	    }
1746 2177
 	}
1747 2178
 	if ($pop) {
1748 2179
 	    sleep(5);
@@ -1753,7 +2184,9 @@  discard block
 block discarded – undo
1753 2184
 	} else if ($popw) {
1754 2185
 	    sleep(5);
1755 2186
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1756
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2187
+	} else {
2188
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2189
+	}
1757 2190
 	print '</div></ul>';
1758 2191
 	print '<div id="error"></div>';
1759 2192
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
js/map.2d.js.php 1 patch
Braces   +109 added lines, -27 removed lines patch added patch discarded remove patch
@@ -4,10 +4,15 @@  discard block
 block discarded – undo
4 4
 
5 5
 setcookie("MapFormat",'2d');
6 6
 
7
-if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = '';
7
+if (!isset($globalOpenWeatherMapKey)) {
8
+	$globalOpenWeatherMapKey = '';
9
+}
8 10
 // Compressed GeoJson is used if true
9
-if (!isset($globalJsonCompress)) $compress = true;
10
-else $compress = $globalJsonCompress;
11
+if (!isset($globalJsonCompress)) {
12
+	$compress = true;
13
+} else {
14
+	$compress = $globalJsonCompress;
15
+}
11 16
 if (isset($_GET['archive'])) {
12 17
 	$archive = true;
13 18
 	//$archiveupdatetime = 50;
@@ -18,8 +23,11 @@  discard block
 block discarded – undo
18 23
 	//$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10));
19 24
 	//$lastupd = 20;
20 25
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
21
-	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
22
-	else $enddate = time();
26
+	if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
27
+		$enddate = $_GET['enddate'];
28
+	} else {
29
+		$enddate = time();
30
+	}
23 31
 	setcookie("archive_begin",$begindate);
24 32
 	setcookie("archive_end",$enddate);
25 33
 	setcookie("archive_update",$lastupd);
@@ -107,7 +115,17 @@  discard block
 block discarded – undo
107 115
 	}
108 116
 
109 117
 	//create the map
110
-	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom);
118
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
119
+	print $latitude;
120
+} else {
121
+	print $globalCenterLatitude;
122
+}
123
+?>,<?php if (isset($longitude)) {
124
+	print $longitude;
125
+} else {
126
+	print $globalCenterLongitude;
127
+}
128
+?>], zoom);
111 129
 <?php
112 130
 	} else {
113 131
 		if ((isset($globalCenterLatitude) && $globalCenterLatitude != '' && isset($globalCenterLongitude) && $globalCenterLongitude != '') || isset($_COOKIE['lastcentercoord'])) {
@@ -133,9 +151,21 @@  discard block
 block discarded – undo
133 151
 	     || navigator.userAgent.match(/BlackBerry/i)
134 152
 	     || navigator.userAgent.match(/Windows Phone/i))
135 153
 	{
136
-		var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom-1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>;
154
+		var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) {
155
+	print $viewzoom-1;
156
+} elseif (isset($viewzoom)) {
157
+	print $viewzoom;
158
+} else {
159
+	print '8';
160
+}
161
+?>;
137 162
 	} else {
138
-		var zoom = <?php if (isset($viewzoom)) print $viewzoom; else print '9'; ?>;
163
+		var zoom = <?php if (isset($viewzoom)) {
164
+	print $viewzoom;
165
+} else {
166
+	print '9';
167
+}
168
+?>;
139 169
 	}
140 170
 
141 171
 	//create the map
@@ -161,16 +191,27 @@  discard block
 block discarded – undo
161 191
 	bounds = L.latLngBounds(southWest,northEast);
162 192
 	//a few title layers
163 193
 <?php
164
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
165
-	else $MapType = $globalMapProvider;
194
+	if (isset($_COOKIE['MapType'])) {
195
+		$MapType = $_COOKIE['MapType'];
196
+	} else {
197
+		$MapType = $globalMapProvider;
198
+	}
166 199
 
167 200
 	if ($MapType == 'Mapbox') {
168
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
169
-		else $MapBoxId = $_COOKIE['MapTypeId'];
170
-?>
201
+		if ($_COOKIE['MapTypeId'] == 'default') {
202
+			$MapBoxId = $globalMapboxId;
203
+		} else {
204
+			$MapBoxId = $_COOKIE['MapTypeId'];
205
+		}
206
+		?>
171 207
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
172 208
 	    maxZoom: 18,
173
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
209
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
210
+	print 'false';
211
+} else {
212
+	print 'true';
213
+}
214
+?>,
174 215
 	    attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
175 216
 	    id: '<?php print $MapBoxId; ?>',
176 217
 	    token: '<?php print $globalMapboxToken; ?>'
@@ -189,7 +230,12 @@  discard block
 block discarded – undo
189 230
 ?>
190 231
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
191 232
 	    maxZoom: 18,
192
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
233
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
234
+	print 'false';
235
+} else {
236
+	print 'true';
237
+}
238
+?>,
193 239
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
194 240
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
195 241
 	}).addTo(map);
@@ -235,20 +281,26 @@  discard block
 block discarded – undo
235 281
 	map.addLayer(yandexLayer);
236 282
 <?php
237 283
 	} elseif ($MapType == 'Bing-Aerial') {
238
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
239
-?>
284
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
285
+			setcookie('MapType','OpenStreetMap');
286
+		}
287
+		?>
240 288
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
241 289
 	map.addLayer(bingLayer);
242 290
 <?php
243 291
 	} elseif ($MapType == 'Bing-Hybrid') {
244
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
245
-?>
292
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
293
+			setcookie('MapType','OpenStreetMap');
294
+		}
295
+		?>
246 296
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
247 297
 	map.addLayer(bingLayer);
248 298
 <?php
249 299
 	} elseif ($MapType == 'Bing-Road') {
250
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
251
-?>
300
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
301
+			setcookie('MapType','OpenStreetMap');
302
+		}
303
+		?>
252 304
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
253 305
 	map.addLayer(bingLayer);
254 306
 <?php
@@ -277,7 +329,12 @@  discard block
 block discarded – undo
277 329
 	    maxZoom: 5,
278 330
 	    tms : true,
279 331
 	    zindex : 3,
280
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
332
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
333
+	print 'false';
334
+} else {
335
+	print 'true';
336
+}
337
+?>,
281 338
 	    attribution: 'Natural Earth'
282 339
 	}).addTo(map);
283 340
 <?php
@@ -285,9 +342,24 @@  discard block
 block discarded – undo
285 342
 		$customid = $MapType;
286 343
 ?>
287 344
 	L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
288
-	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
289
-	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
290
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
345
+	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
346
+	print $globalMapCustomLayer[$customid]['maxZoom'];
347
+} else {
348
+	print '18';
349
+}
350
+?>,
351
+	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
352
+	print $globalMapCustomLayer[$customid]['minZoom'];
353
+} else {
354
+	print '0';
355
+}
356
+?>,
357
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
358
+	print 'false';
359
+} else {
360
+	print 'true';
361
+}
362
+?>,
291 363
 	    attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
292 364
 	}).addTo(map);
293 365
 
@@ -327,7 +399,12 @@  discard block
 block discarded – undo
327 399
 		}
328 400
 	} elseif ($globalBounding == 'circle') {
329 401
 ?>
330
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
402
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
403
+	print $globalBoundingCircleSize;
404
+} else {
405
+	print '70000';
406
+}
407
+?>,{
331 408
 	    color: '#92C7D1',
332 409
 	    fillColor: '#92C7D1',
333 410
 	    fillOpacity: 0.3,
@@ -419,7 +496,12 @@  discard block
 block discarded – undo
419 496
 		createCookie('lastcentercoord',map.getCenter().lat+','+map.getCenter().lng+','+map.getZoom(),2);
420 497
 	});
421 498
 update_locationsLayer();
422
-setInterval(function(){if (noTimeout) update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
499
+setInterval(function(){if (noTimeout) update_locationsLayer()},<?php if (isset($globalMapRefresh)) {
500
+	print $globalMapRefresh*1000*2;
501
+} else {
502
+	print '60000';
503
+}
504
+?>);
423 505
 
424 506
 <?php
425 507
     // Add support for custom json via $globalMapJson
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     <?php }; if (isset($globalSatellite) && $globalSatellite) { ?><td><div id="ibxsatellite"><h4><?php echo _("Satellites Displayed"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?>
48 48
 </tr></table></div>
49 49
 <?php
50
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
50
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
51 51
 ?>
52 52
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) print '?tsk='.$tsk; ?>"></script>
53 53
 <?php
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script>
72 72
 <?php
73 73
 	}
74
-    }
74
+	}
75 75
 ?>
76 76
 
77 77
 <div id="sidebar" class="sidebar collapsed">
@@ -82,34 +82,34 @@  discard block
 block discarded – undo
82 82
 	<li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
83 83
 	<li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
84 84
 <?php
85
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
85
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
86 86
 	if (isset($globalArchive) && $globalArchive == TRUE) {
87 87
 ?>
88 88
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
89 89
 <?php
90 90
 	}
91
-    }
91
+	}
92 92
 ?>
93 93
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
94 94
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
95 95
 	<li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li>
96 96
 <?php
97
-    if (isset($globalMap3D) && $globalMap3D) {
97
+	if (isset($globalMap3D) && $globalMap3D) {
98 98
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
99 99
 ?>
100 100
 	<li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
101 101
 <?php
102 102
 	} else {
103
-	    if (isset($globalSatellite) && $globalSatellite) {
103
+		if (isset($globalSatellite) && $globalSatellite) {
104 104
 ?>
105 105
 	<li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li>
106 106
 <?php
107
-	    }
107
+		}
108 108
 ?>
109 109
 	<li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
110 110
 <?php
111 111
 	}
112
-    }
112
+	}
113 113
 ?>
114 114
     </ul>
115 115
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 ?>
185 185
         </div>
186 186
 <?php
187
-    if (isset($globalArchive) && $globalArchive == TRUE) {
187
+	if (isset($globalArchive) && $globalArchive == TRUE) {
188 188
 ?>
189 189
         <div class="sidebar-pane" id="archive">
190 190
 	    <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	    </form>
244 244
 	</div>
245 245
 <?php
246
-    }
246
+	}
247 247
 ?>
248 248
         <div class="sidebar-pane" id="settings">
249 249
 	    <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -254,67 +254,67 @@  discard block
 block discarded – undo
254 254
 			    <?php
255 255
 				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
256 256
 				else $MapType = $_COOKIE['MapType'];
257
-			    ?>
257
+				?>
258 258
 			    <?php
259 259
 				if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
260
-			    ?>
260
+				?>
261 261
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
262 262
 			    <?php
263 263
 				} else {
264
-				    if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
265
-			    ?>
264
+					if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
265
+				?>
266 266
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
267 267
 			    <?php
268
-				    }
269
-				    if (isset($globalBingMapKey) && $globalBingMapKey != '') {
270
-			    ?>
268
+					}
269
+					if (isset($globalBingMapKey) && $globalBingMapKey != '') {
270
+				?>
271 271
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
272 272
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
273 273
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
274 274
 			    <?php
275
-				    }
276
-			    ?>
275
+					}
276
+				?>
277 277
 			    <?php
278
-				    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
279
-			    ?>
278
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
279
+				?>
280 280
 			    <?php
281 281
 					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
282
-			    ?>
282
+				?>
283 283
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
284 284
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
285 285
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
286 286
 			    <?php
287 287
 					}
288
-			    ?>
288
+				?>
289 289
 			    <?php
290 290
 					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
291
-			    ?>
291
+				?>
292 292
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
293 293
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
294 294
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
295 295
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
296 296
 			    <?php
297 297
 					}
298
-			    ?>
298
+				?>
299 299
 			    <?php
300 300
 					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
301
-			    ?>
301
+				?>
302 302
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
303 303
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
304 304
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
305 305
 			    <?php
306 306
 					}
307
-			    ?>
307
+				?>
308 308
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
309 309
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option>
310 310
 			    <?php
311
-				    }
312
-			    ?>
311
+					}
312
+				?>
313 313
 			    <?php
314
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
314
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
315 315
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
316 316
 					else $MapBoxId = $_COOKIE['MapTypeId'];
317
-			    ?>
317
+				?>
318 318
 			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option>
319 319
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
320 320
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
@@ -329,16 +329,16 @@  discard block
 block discarded – undo
329 329
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
330 330
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
331 331
 			    <?php
332
-				    }
333
-			    ?>
332
+					}
333
+				?>
334 334
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
335 335
 			    <?php
336 336
 				}
337
-			    ?>
337
+				?>
338 338
 			</select>
339 339
 		    </li>
340 340
 <?php
341
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) {
341
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) {
342 342
 ?>
343 343
 		    <li><?php echo _("Type of Terrain:"); ?>
344 344
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 			</select>
350 350
 		    </li>
351 351
 <?php
352
-    }
352
+	}
353 353
 ?>
354 354
 <?php
355
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
355
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
356 356
 ?>
357 357
 		    <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') print 'checked'; ?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li>
358 358
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 		    <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Satellites animate between updates"); ?></label></div></li>
376 376
 <?php
377 377
 	}
378
-    }
378
+	}
379 379
 ?>
380 380
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
381 381
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li>
@@ -387,81 +387,81 @@  discard block
 block discarded – undo
387 387
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayfires" value="1" onclick="clickDisplayFires(this)" <?php if ((isset($_COOKIE['show_Fires']) && $_COOKIE['show_Fires'] == 'true') || (!isset($_COOKIE['show_Fires']) && (isset($globalMapFires) && $globalMapFires === TRUE))) print 'checked'; ?> ><?php echo _("Display fires on map"); ?></label></div></li>
388 388
 <?php
389 389
 	}
390
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
390
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
391 391
 ?>
392 392
 		    <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>
393 393
 <?php
394
-    }
395
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
394
+	}
395
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
396 396
 ?>
397 397
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li>
398 398
 <?php
399
-    }
399
+	}
400 400
 ?>
401 401
 		    <?php
402 402
 			if (function_exists('array_column')) {
403
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
404
-		    ?>
403
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
404
+			?>
405 405
 		    <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>
406 406
 		    <?php
407
-			    }
407
+				}
408 408
 			} elseif (isset($globalSources)) {
409
-			    $dispolar = false;
410
-			    foreach ($globalSources as $testsource) {
411
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
412
-			    }
413
-			    if ($dispolar) {
414
-		    ?>
409
+				$dispolar = false;
410
+				foreach ($globalSources as $testsource) {
411
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
412
+				}
413
+				if ($dispolar) {
414
+			?>
415 415
 		    <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>
416 416
 		    <?php
417
-			    }
418
-		        }
419
-		    ?>
417
+				}
418
+				}
419
+			?>
420 420
 <?php
421
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
421
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
422 422
 ?>
423 423
 
424 424
 		    <?php
425 425
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
426
-		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
427
-		    ?>
426
+					if (extension_loaded('gd') && function_exists('gd_info')) {
427
+			?>
428 428
 		    <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>
429 429
 		    <?php 
430 430
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
431
-		    ?>
431
+			?>
432 432
 		    <li><?php echo _("Aircraft icon color:"); ?>
433 433
 			<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'; ?>">
434 434
 		    </li>
435 435
 		    <?php
436 436
 				}
437
-			    }
438
-		        }
439
-		    ?>
437
+				}
438
+				}
439
+			?>
440 440
 		    <?php
441 441
 			if (isset($globalMarine) && $globalMarine === TRUE) {
442
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
443
-		    ?>
442
+				if (extension_loaded('gd') && function_exists('gd_info')) {
443
+			?>
444 444
 		    <li><?php echo _("Marine icon color:"); ?>
445 445
 			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
446 446
 		    </li>
447 447
 		    <?php
448
-			    }
449
-		        }
450
-		    ?>
448
+				}
449
+				}
450
+			?>
451 451
 		    <?php
452 452
 			if (isset($globalTracker) && $globalTracker === TRUE) {
453
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
454
-		    ?>
453
+				if (extension_loaded('gd') && function_exists('gd_info')) {
454
+			?>
455 455
 		    <li><?php echo _("Tracker icon color:"); ?>
456 456
 			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>">
457 457
 		    </li>
458 458
 		    <?php
459
-			    }
460
-		        }
461
-		    ?>
459
+				}
460
+				}
461
+			?>
462 462
 		    <?php
463 463
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
464
-		    ?>
464
+			?>
465 465
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
466 466
 			<div class="range">
467 467
 			    <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'; ?>">
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
 		    </li>
471 471
 		    <?php
472 472
 			}
473
-		    ?>
473
+			?>
474 474
 <?php
475
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
475
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
476 476
 ?>
477 477
 <?php
478 478
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 		    </li>
505 505
 <?php
506 506
 	}
507
-    }
507
+	}
508 508
 ?>
509 509
 		    <li><?php echo _("Distance unit:"); ?>
510 510
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -537,19 +537,19 @@  discard block
 block discarded – undo
537 537
 		    <ul>
538 538
 		    <?php
539 539
 			if (!isset($globalAircraft) || $globalAircraft) {
540
-		    ?>
540
+			?>
541 541
 		    <?php
542 542
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
543
-		    ?>
543
+			?>
544 544
 			<?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 } ?>
545 545
 			<?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 } ?>
546 546
 			<?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 } ?>
547 547
 		    <?php
548 548
 			}
549
-		    ?>
549
+			?>
550 550
 		    <?php
551 551
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
552
-		    ?>
552
+			?>
553 553
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
554 554
 			    <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>
555 555
 			<?php } ?>
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 			<?php } ?>
559 559
 		    <?php
560 560
 			}
561
-		    ?>
561
+			?>
562 562
 		    <li><?php echo _("Display airlines:"); ?>
563 563
 		    <br/>
564 564
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -578,14 +578,14 @@  discard block
 block discarded – undo
578 578
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
579 579
 					}
580 580
 				}
581
-			    ?>
581
+				?>
582 582
 			</select>
583 583
 		    </li>
584 584
 		    <?php
585 585
 			$Spotter = new Spotter();
586 586
 			$allalliancenames = $Spotter->getAllAllianceNames();
587 587
 			if (!empty($allalliancenames)) {
588
-		    ?>
588
+			?>
589 589
 		    <li><?php echo _("Display alliance:"); ?>
590 590
 		    <br/>
591 591
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -599,18 +599,18 @@  discard block
 block discarded – undo
599 599
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
600 600
 					}
601 601
 				}
602
-			    ?>
602
+				?>
603 603
 			</select>
604 604
 		    </li>
605 605
 		    <?php
606 606
 			}
607
-		    ?>
607
+			?>
608 608
 		    <?php
609 609
 			}
610
-		    ?>
610
+			?>
611 611
 		    <?php
612 612
 			if (isset($globalAPRS) && $globalAPRS) {
613
-		    ?>
613
+			?>
614 614
 		    <li><?php echo _("Display APRS sources name:"); ?>
615 615
 			<select class="selectpicker" multiple onchange="sources(this);">
616 616
 			    <?php
@@ -634,18 +634,18 @@  discard block
 block discarded – undo
634 634
 						echo '<option value="'.$src['name'].'">'.$src['name'].'</option>';
635 635
 					}
636 636
 				}
637
-			    ?>
637
+				?>
638 638
 			</select>
639 639
 		    </li>
640 640
 		    <?php
641 641
 			}
642
-		    ?>
642
+			?>
643 643
 		    <?php
644 644
 			if (!isset($globalAircraft) || $globalAircraft) {
645
-		    ?>
645
+			?>
646 646
 		    <?php
647
-			    if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
648
-		    ?>
647
+				if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
648
+			?>
649 649
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
650 650
 			<select class="selectpicker" onchange="airlinestype(this);">
651 651
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -655,21 +655,21 @@  discard block
 block discarded – undo
655 655
 			</select>
656 656
 		    </li>
657 657
 		    <?php
658
-			    }
659
-		    ?>
658
+				}
659
+			?>
660 660
 		    <?php
661 661
 			}
662
-		    ?>
662
+			?>
663 663
 		    <?php
664 664
 			if (isset($globalMarine) && $globalMarine) {
665
-		    ?>
665
+			?>
666 666
 		    <li>
667 667
 			<?php echo _("Display vessels with MMSI:"); ?>
668 668
 			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" />
669 669
 		    </li>
670 670
 		    <?php
671 671
 			}
672
-		    ?>
672
+			?>
673 673
 		    <li>
674 674
 			<?php echo _("Display with ident:"); ?>
675 675
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 	    </form>
683 683
     	</div>
684 684
 <?php
685
-    if (isset($globalSatellite) && $globalSatellite) {
685
+	if (isset($globalSatellite) && $globalSatellite) {
686 686
 ?>
687 687
         <div class="sidebar-pane" id="satellites">
688 688
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -722,14 +722,14 @@  discard block
 block discarded – undo
722 722
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
723 723
 					}
724 724
 				}
725
-			    ?>
725
+				?>
726 726
 			</select>
727 727
 		    </li>
728 728
 		</ul>
729 729
 	    </form>
730 730
 	</div>
731 731
 <?php
732
-    }
732
+	}
733 733
 ?>
734 734
     </div>
735 735
 </div>
Please login to merge, or discard this patch.
Braces   +477 added lines, -120 removed lines patch added patch discarded remove patch
@@ -49,7 +49,10 @@  discard block
 block discarded – undo
49 49
 <?php
50 50
     if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
51 51
 ?>
52
-<script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) print '?tsk='.$tsk; ?>"></script>
52
+<script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) {
53
+	print '?tsk='.$tsk;
54
+}
55
+?>"></script>
53 56
 <?php
54 57
 	if (!isset($globalAircraft) || $globalAircraft) {
55 58
 ?>
@@ -163,11 +166,26 @@  discard block
 block discarded – undo
163 166
 				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li>
164 167
 				<li><?php echo _("NOTAM scope:"); ?>
165 168
 					<select class="selectpicker" onchange="notamscope(this);">
166
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
167
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
168
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
169
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
170
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
169
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
170
+	print ' selected';
171
+}
172
+?>>All</option>
173
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
174
+	print ' selected';
175
+}
176
+?>>Airport/Enroute warning</option>
177
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
178
+	print ' selected';
179
+}
180
+?>>Airport warning</option>
181
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
182
+	print ' selected';
183
+}
184
+?>>Navigation warning</option>
185
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
186
+	print ' selected';
187
+}
188
+?>>Enroute warning</option>
171 189
 					</select
172 190
 				</li>
173 191
 			</ul>
@@ -195,7 +213,12 @@  discard block
 block discarded – undo
195 213
 		        <div class="form-group">
196 214
 			    <label>From (UTC):</label>
197 215
 		            <div class='input-group date' id='datetimepicker1'>
198
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
216
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) {
217
+	print $_POST['start_date'];
218
+} elseif (isset($_COOKIE['archive_begin'])) {
219
+	print date("m/d/Y h:i a",$_COOKIE['archive_begin']);
220
+}
221
+?>" required />
199 222
 		                <span class="input-group-addon">
200 223
             			    <span class="glyphicon glyphicon-calendar"></span>
201 224
 		                </span>
@@ -204,7 +227,12 @@  discard block
 block discarded – undo
204 227
 		        <div class="form-group">
205 228
 			    <label>To (UTC):</label>
206 229
 		            <div class='input-group date' id='datetimepicker2'>
207
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" />
230
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) {
231
+	print $_POST['end_date'];
232
+} elseif (isset($_COOKIE['archive_end'])) {
233
+	print date("m/d/Y h:i a",$_COOKIE['archive_end']);
234
+}
235
+?>" />
208 236
             			<span class="input-group-addon">
209 237
 		                    <span class="glyphicon glyphicon-calendar"></span>
210 238
             			</span>
@@ -229,8 +257,20 @@  discard block
 block discarded – undo
229 257
 			</script>
230 258
 		    <li><?php echo _("Playback speed:"); ?>
231 259
 			<div class="range">
232
-			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
233
-			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
260
+			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
261
+	print $_POST['archivespeed'];
262
+} elseif (isset($_COOKIE['archive_speed'])) {
263
+	print $_COOKIE['archive_speed'];
264
+} else {
265
+	print '1';
266
+}
267
+?>">
268
+			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
269
+	print $_COOKIE['archive_speed'];
270
+} else {
271
+	print '1';
272
+}
273
+?></output>
234 274
 			</div>
235 275
 		    </li>
236 276
 		    <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li>
@@ -252,25 +292,43 @@  discard block
 block discarded – undo
252 292
 		    <li><?php echo _("Type of Map:"); ?>
253 293
 			<select  class="selectpicker" onchange="mapType(this);">
254 294
 			    <?php
255
-				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
256
-				else $MapType = $_COOKIE['MapType'];
295
+				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
296
+					$MapType = $globalMapProvider;
297
+				} else {
298
+					$MapType = $_COOKIE['MapType'];
299
+				}
257 300
 			    ?>
258 301
 			    <?php
259 302
 				if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
260 303
 			    ?>
261
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
304
+			    <option value="offline"<?php if ($MapType == 'offline') {
305
+	print ' selected';
306
+}
307
+?>>Natural Earth (local)</option>
262 308
 			    <?php
263 309
 				} else {
264 310
 				    if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
265 311
 			    ?>
266
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
312
+			    <option value="offline"<?php if ($MapType == 'offline') {
313
+	print ' selected';
314
+}
315
+?>>Natural Earth (local)</option>
267 316
 			    <?php
268 317
 				    }
269 318
 				    if (isset($globalBingMapKey) && $globalBingMapKey != '') {
270 319
 			    ?>
271
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
272
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
273
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
320
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
321
+	print ' selected';
322
+}
323
+?>>Bing-Aerial</option>
324
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
325
+	print ' selected';
326
+}
327
+?>>Bing-Hybrid</option>
328
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
329
+	print ' selected';
330
+}
331
+?>>Bing-Road</option>
274 332
 			    <?php
275 333
 				    }
276 334
 			    ?>
@@ -280,58 +338,139 @@  discard block
 block discarded – undo
280 338
 			    <?php
281 339
 					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
282 340
 			    ?>
283
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
284
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
285
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
341
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
342
+	print ' selected';
343
+}
344
+?>>Here-Aerial</option>
345
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
346
+	print ' selected';
347
+}
348
+?>>Here-Hybrid</option>
349
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
350
+	print ' selected';
351
+}
352
+?>>Here-Road</option>
286 353
 			    <?php
287 354
 					}
288 355
 			    ?>
289 356
 			    <?php
290 357
 					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
291 358
 			    ?>
292
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
293
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
294
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
295
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
359
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
360
+	print ' selected';
361
+}
362
+?>>Google Roadmap</option>
363
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
364
+	print ' selected';
365
+}
366
+?>>Google Satellite</option>
367
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
368
+	print ' selected';
369
+}
370
+?>>Google Hybrid</option>
371
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
372
+	print ' selected';
373
+}
374
+?>>Google Terrain</option>
296 375
 			    <?php
297 376
 					}
298 377
 			    ?>
299 378
 			    <?php
300 379
 					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
301 380
 			    ?>
302
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
303
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
304
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
381
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
382
+	print ' selected';
383
+}
384
+?>>MapQuest-OSM</option>
385
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
386
+	print ' selected';
387
+}
388
+?>>MapQuest-Aerial</option>
389
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
390
+	print ' selected';
391
+}
392
+?>>MapQuest-Hybrid</option>
305 393
 			    <?php
306 394
 					}
307 395
 			    ?>
308
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
309
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option>
396
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
397
+	print ' selected';
398
+}
399
+?>>Yandex</option>
400
+			    <option value="offline"<?php if ($MapType == 'offline') {
401
+	print ' selected';
402
+}
403
+?>>Natural Earth</option>
310 404
 			    <?php
311 405
 				    }
312 406
 			    ?>
313 407
 			    <?php
314 408
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
315
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
316
-					else $MapBoxId = $_COOKIE['MapTypeId'];
409
+					if (!isset($_COOKIE['MapTypeId'])) {
410
+						$MapBoxId = 'default';
411
+					} else {
412
+						$MapBoxId = $_COOKIE['MapTypeId'];
413
+					}
317 414
 			    ?>
318
-			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option>
319
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
320
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
321
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
322
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
323
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
324
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
325
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
326
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
327
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
328
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
329
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
330
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
415
+			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') {
416
+	print ' selected';
417
+}
418
+?>>Mapbox GL</option>
419
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
420
+	print ' selected';
421
+}
422
+?>>Mapbox default</option>
423
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
424
+	print ' selected';
425
+}
426
+?>>Mapbox streets</option>
427
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
428
+	print ' selected';
429
+}
430
+?>>Mapbox light</option>
431
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
432
+	print ' selected';
433
+}
434
+?>>Mapbox dark</option>
435
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
436
+	print ' selected';
437
+}
438
+?>>Mapbox satellite</option>
439
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
440
+	print ' selected';
441
+}
442
+?>>Mapbox streets-satellite</option>
443
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
444
+	print ' selected';
445
+}
446
+?>>Mapbox streets-basic</option>
447
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
448
+	print ' selected';
449
+}
450
+?>>Mapbox comic</option>
451
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
452
+	print ' selected';
453
+}
454
+?>>Mapbox outdoors</option>
455
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
456
+	print ' selected';
457
+}
458
+?>>Mapbox pencil</option>
459
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
460
+	print ' selected';
461
+}
462
+?>>Mapbox pirates</option>
463
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
464
+	print ' selected';
465
+}
466
+?>>Mapbox emerald</option>
331 467
 			    <?php
332 468
 				    }
333 469
 			    ?>
334
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
470
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
471
+	print ' selected';
472
+}
473
+?>>OpenStreetMap</option>
335 474
 			    <?php
336 475
 				}
337 476
 			    ?>
@@ -342,10 +481,22 @@  discard block
 block discarded – undo
342 481
 ?>
343 482
 		    <li><?php echo _("Type of Terrain:"); ?>
344 483
 			<select  class="selectpicker" onchange="terrainType(this);">
345
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
346
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
347
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
348
-			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected';?>>ArticDEM</option>
484
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
485
+	print ' selected';
486
+}
487
+?>>stk terrain</option>
488
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
489
+	print ' selected';
490
+}
491
+?>>ellipsoid</option>
492
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
493
+	print ' selected';
494
+}
495
+?>>vr terrain</option>
496
+			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') {
497
+	print ' selected';
498
+}
499
+?>>ArticDEM</option>
349 500
 			</select>
350 501
 		    </li>
351 502
 <?php
@@ -354,42 +505,84 @@  discard block
 block discarded – undo
354 505
 <?php
355 506
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
356 507
 ?>
357
-		    <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') print 'checked'; ?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li>
508
+		    <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') {
509
+	print 'checked';
510
+}
511
+?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li>
358 512
 
359 513
 <?php
360 514
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
361 515
 ?>
362
-		    <!--<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>-->
363
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li>
364
-		    <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']) && isset($globalMapRoute) && $globalMapRoute)) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
365
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || (!isset($_COOKIE['MapRemainingRoute']) && isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) print 'checked'; ?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
366
-		    <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>
516
+		    <!--<li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
517
+	print 'checked';
518
+}
519
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>-->
520
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) {
521
+	print 'checked';
522
+}
523
+?> ><?php echo _("Display flight path"); ?></label></div></li>
524
+		    <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']) && isset($globalMapRoute) && $globalMapRoute)) {
525
+	print 'checked';
526
+}
527
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
528
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || (!isset($_COOKIE['MapRemainingRoute']) && isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) {
529
+	print 'checked';
530
+}
531
+?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
532
+		    <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)) {
533
+	print 'checked';
534
+}
535
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
367 536
 <?php
368 537
 	} elseif (!isset($globalTracker) || $globalTracker === TRUE) {
369 538
 ?>
370
-		    <li><div class="checkbox"><label><input type="checkbox" name="mapmatching" value="1" onclick="clickMapMatching(this)" <?php if ((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') || (!isset($_COOKIE['mapmatching']) && isset($globalMapMatching) && $globalMapMatching)) print 'checked'; ?> ><?php echo _("Enable map matching"); ?></label></div></li>
539
+		    <li><div class="checkbox"><label><input type="checkbox" name="mapmatching" value="1" onclick="clickMapMatching(this)" <?php if ((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') || (!isset($_COOKIE['mapmatching']) && isset($globalMapMatching) && $globalMapMatching)) {
540
+	print 'checked';
541
+}
542
+?> ><?php echo _("Enable map matching"); ?></label></div></li>
371 543
 <?php
372 544
 	}
373 545
 	if (isset($globalSatellite) && $globalSatellite === TRUE) {
374 546
 ?>
375
-		    <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Satellites animate between updates"); ?></label></div></li>
547
+		    <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
548
+	print 'checked';
549
+}
550
+?> ><?php echo _("Satellites animate between updates"); ?></label></div></li>
376 551
 <?php
377 552
 	}
378 553
     }
379 554
 ?>
380
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
381
-		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li>
382
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayweatherstation" value="1" onclick="clickDisplayWeatherStation(this)" <?php if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) print 'checked'; ?> ><?php echo _("Display weather station on map"); ?></label></div></li>
383
-		    <li><div class="checkbox"><label><input type="checkbox" name="displaylightning" value="1" onclick="clickDisplayLightning(this)" <?php if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) print 'checked'; ?> ><?php echo _("Display lightning on map"); ?></label></div></li>
555
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) {
556
+	print 'checked';
557
+}
558
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
559
+		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
560
+	print 'checked';
561
+}
562
+?> ><?php echo _("Display ground station on map"); ?></label></div></li>
563
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayweatherstation" value="1" onclick="clickDisplayWeatherStation(this)" <?php if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
564
+	print 'checked';
565
+}
566
+?> ><?php echo _("Display weather station on map"); ?></label></div></li>
567
+		    <li><div class="checkbox"><label><input type="checkbox" name="displaylightning" value="1" onclick="clickDisplayLightning(this)" <?php if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
568
+	print 'checked';
569
+}
570
+?> ><?php echo _("Display lightning on map"); ?></label></div></li>
384 571
 <?php
385 572
 	if (isset($globalFires)) {
386 573
 ?>
387
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayfires" value="1" onclick="clickDisplayFires(this)" <?php if ((isset($_COOKIE['show_Fires']) && $_COOKIE['show_Fires'] == 'true') || (!isset($_COOKIE['show_Fires']) && (isset($globalMapFires) && $globalMapFires === TRUE))) print 'checked'; ?> ><?php echo _("Display fires on map"); ?></label></div></li>
574
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayfires" value="1" onclick="clickDisplayFires(this)" <?php if ((isset($_COOKIE['show_Fires']) && $_COOKIE['show_Fires'] == 'true') || (!isset($_COOKIE['show_Fires']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
575
+	print 'checked';
576
+}
577
+?> ><?php echo _("Display fires on map"); ?></label></div></li>
388 578
 <?php
389 579
 	}
390 580
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
391 581
 ?>
392
-		    <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>
582
+		    <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')) {
583
+	print 'checked';
584
+}
585
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
393 586
 <?php
394 587
     }
395 588
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -402,17 +595,25 @@  discard block
 block discarded – undo
402 595
 			if (function_exists('array_column')) {
403 596
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
404 597
 		    ?>
405
-		    <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>
598
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
599
+	print 'checked';
600
+}
601
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
406 602
 		    <?php
407 603
 			    }
408 604
 			} elseif (isset($globalSources)) {
409 605
 			    $dispolar = false;
410 606
 			    foreach ($globalSources as $testsource) {
411
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
607
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
608
+			        	$dispolar = true;
609
+			        }
412 610
 			    }
413 611
 			    if ($dispolar) {
414 612
 		    ?>
415
-		    <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>
613
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
614
+	print 'checked';
615
+}
616
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
416 617
 		    <?php
417 618
 			    }
418 619
 		        }
@@ -425,12 +626,22 @@  discard block
 block discarded – undo
425 626
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
426 627
 		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
427 628
 		    ?>
428
-		    <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>
629
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
630
+	print 'checked';
631
+}
632
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
429 633
 		    <?php 
430 634
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
431 635
 		    ?>
432 636
 		    <li><?php echo _("Aircraft icon color:"); ?>
433
-			<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'; ?>">
637
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
638
+	print $_COOKIE['IconColor'];
639
+} elseif (isset($globalAircraftIconColor)) {
640
+	print $globalAircraftIconColor;
641
+} else {
642
+	print '1a3151';
643
+}
644
+?>">
434 645
 		    </li>
435 646
 		    <?php
436 647
 				}
@@ -442,7 +653,14 @@  discard block
 block discarded – undo
442 653
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
443 654
 		    ?>
444 655
 		    <li><?php echo _("Marine icon color:"); ?>
445
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
656
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
657
+	print $_COOKIE['MarineIconColor'];
658
+} elseif (isset($globalMarineIconColor)) {
659
+	print $globalMarineIconColor;
660
+} else {
661
+	print '1a3151';
662
+}
663
+?>">
446 664
 		    </li>
447 665
 		    <?php
448 666
 			    }
@@ -453,7 +671,14 @@  discard block
 block discarded – undo
453 671
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
454 672
 		    ?>
455 673
 		    <li><?php echo _("Tracker icon color:"); ?>
456
-			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>">
674
+			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) {
675
+	print $_COOKIE['TrackerIconColor'];
676
+} elseif (isset($globalTrackerIconColor)) {
677
+	print $globalTrackerIconColor;
678
+} else {
679
+	print '1a3151';
680
+}
681
+?>">
457 682
 		    </li>
458 683
 		    <?php
459 684
 			    }
@@ -464,8 +689,22 @@  discard block
 block discarded – undo
464 689
 		    ?>
465 690
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
466 691
 			<div class="range">
467
-			    <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'; ?>">
468
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
692
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
693
+	print $_COOKIE['AirportZoom'];
694
+} elseif (isset($globalAirportZoom)) {
695
+	print $globalAirportZoom;
696
+} else {
697
+	print '7';
698
+}
699
+?>">
700
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
701
+	print $_COOKIE['AirportZoom'];
702
+} elseif (isset($globalAirportZoom)) {
703
+	print $globalAirportZoom;
704
+} else {
705
+	print '7';
706
+}
707
+?></output>
469 708
 			</div>
470 709
 		    </li>
471 710
 		    <?php
@@ -477,10 +716,23 @@  discard block
 block discarded – undo
477 716
 <?php
478 717
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
479 718
 ?>
480
-		    <li><input type="checkbox" name="useliveries" value="1" onclick="useLiveries(this)" <?php if (isset($_COOKIE['UseLiveries']) && $_COOKIE['UseLiveries'] == 'true') print 'checked'; ?> ><?php echo _("Use airlines liveries"); ?></li>
481
-		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li>
719
+		    <li><input type="checkbox" name="useliveries" value="1" onclick="useLiveries(this)" <?php if (isset($_COOKIE['UseLiveries']) && $_COOKIE['UseLiveries'] == 'true') {
720
+	print 'checked';
721
+}
722
+?> ><?php echo _("Use airlines liveries"); ?></li>
723
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
724
+	print 'checked';
725
+}
726
+?> ><?php echo _("Force Aircraft color"); ?></li>
482 727
 		    <li><?php echo _("Aircraft icon color:"); ?>
483
-			<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 'ff0000'; ?>">
728
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
729
+	print $_COOKIE['IconColor'];
730
+} elseif (isset($globalAircraftIconColor)) {
731
+	print $globalAircraftIconColor;
732
+} else {
733
+	print 'ff0000';
734
+}
735
+?>">
484 736
 		    </li>
485 737
 <?php
486 738
 	}
@@ -488,9 +740,19 @@  discard block
 block discarded – undo
488 740
 <?php
489 741
 	if (isset($globalMarine) && $globalMarine === TRUE) {
490 742
 ?>
491
-		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="MarineiconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Marine color"); ?></li>
743
+		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="MarineiconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') {
744
+	print 'checked';
745
+}
746
+?> ><?php echo _("Force Marine color"); ?></li>
492 747
 		    <li><?php echo _("Marine icon color:"); ?>
493
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print 'ff0000'; ?>">
748
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
749
+	print $_COOKIE['MarineIconColor'];
750
+} elseif (isset($globalMarineIconColor)) {
751
+	print $globalMarineIconColor;
752
+} else {
753
+	print 'ff0000';
754
+}
755
+?>">
494 756
 		    </li>
495 757
 <?php
496 758
 	}
@@ -498,9 +760,19 @@  discard block
 block discarded – undo
498 760
 <?php
499 761
 	if (isset($globalTracker) && $globalTracker === TRUE) {
500 762
 ?>
501
-		    <li><input type="checkbox" name="trackercolorforce" value="1" onclick="TrackericonColorForce(this)" <?php if (isset($_COOKIE['TrackerIconColorForce']) && $_COOKIE['TrackerIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Tracker color"); ?></li>
763
+		    <li><input type="checkbox" name="trackercolorforce" value="1" onclick="TrackericonColorForce(this)" <?php if (isset($_COOKIE['TrackerIconColorForce']) && $_COOKIE['TrackerIconColorForce'] == 'true') {
764
+	print 'checked';
765
+}
766
+?> ><?php echo _("Force Tracker color"); ?></li>
502 767
 		    <li><?php echo _("Tracker icon color:"); ?>
503
-			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print 'ff0000'; ?>">
768
+			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) {
769
+	print $_COOKIE['TrackerIconColor'];
770
+} elseif (isset($globalTrackerIconColor)) {
771
+	print $globalTrackerIconColor;
772
+} else {
773
+	print 'ff0000';
774
+}
775
+?>">
504 776
 		    </li>
505 777
 <?php
506 778
 	}
@@ -508,22 +780,46 @@  discard block
 block discarded – undo
508 780
 ?>
509 781
 		    <li><?php echo _("Distance unit:"); ?>
510 782
 			<select class="selectpicker" onchange="unitdistance(this);">
511
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
512
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
513
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
783
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
784
+	echo ' selected';
785
+}
786
+?>>km</option>
787
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
788
+	echo ' selected';
789
+}
790
+?>>nm</option>
791
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
792
+	echo ' selected';
793
+}
794
+?>>mi</option>
514 795
 		        </select>
515 796
 		    </li>
516 797
 		    <li><?php echo _("Altitude unit:"); ?>
517 798
 			<select class="selectpicker" onchange="unitaltitude(this);">
518
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
519
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
799
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
800
+	echo ' selected';
801
+}
802
+?>>m</option>
803
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
804
+	echo ' selected';
805
+}
806
+?>>feet</option>
520 807
 		        </select>
521 808
 		    </li>
522 809
 		    <li><?php echo _("Speed unit:"); ?>
523 810
 			<select class="selectpicker" onchange="unitspeed(this);">
524
-			    <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>
525
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
526
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
811
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
812
+	echo ' selected';
813
+}
814
+?>>km/h</option>
815
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
816
+	echo ' selected';
817
+}
818
+?>>mph</option>
819
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
820
+	echo ' selected';
821
+}
822
+?>>knots</option>
527 823
 		        </select>
528 824
 		    </li>
529 825
 
@@ -541,9 +837,18 @@  discard block
 block discarded – undo
541 837
 		    <?php
542 838
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
543 839
 		    ?>
544
-			<?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 } ?>
545
-			<?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 } ?>
546
-			<?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 } ?>
840
+			<?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'])) {
841
+	print 'checked';
842
+}
843
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
844
+			<?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'])) {
845
+	print 'checked';
846
+}
847
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
848
+			<?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'])) {
849
+	print 'checked';
850
+}
851
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
547 852
 		    <?php
548 853
 			}
549 854
 		    ?>
@@ -551,10 +856,16 @@  discard block
 block discarded – undo
551 856
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
552 857
 		    ?>
553 858
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
554
-			    <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>
859
+			    <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'])) {
860
+	print 'checked';
861
+}
862
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
555 863
 			<?php } ?>
556 864
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
557
-			    <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>
865
+			    <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'])) {
866
+	print 'checked';
867
+}
868
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
558 869
 			<?php } ?>
559 870
 		    <?php
560 871
 			}
@@ -571,7 +882,9 @@  discard block
 block discarded – undo
571 882
 				}
572 883
 				foreach($allairlinenames as $airline) {
573 884
 					$airline_name = $airline['airline_name'];
574
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
885
+					if (strlen($airline_name) > 30) {
886
+						$airline_name = substr($airline_name,0,30).'...';
887
+					}
575 888
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
576 889
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
577 890
 					} else {
@@ -589,7 +902,10 @@  discard block
 block discarded – undo
589 902
 		    <li><?php echo _("Display alliance:"); ?>
590 903
 		    <br/>
591 904
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
592
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
905
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
906
+	echo ' selected';
907
+}
908
+?>><?php echo _("All"); ?></option>
593 909
 			    <?php
594 910
 				foreach($allalliancenames as $alliance) {
595 911
 					$alliance_name = $alliance['alliance'];
@@ -648,10 +964,22 @@  discard block
 block discarded – undo
648 964
 		    ?>
649 965
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
650 966
 			<select class="selectpicker" onchange="airlinestype(this);">
651
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
652
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
653
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
654
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
967
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
968
+	echo ' selected';
969
+}
970
+?>><?php echo _("All"); ?></option>
971
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
972
+	echo ' selected';
973
+}
974
+?>><?php echo _("Passenger"); ?></option>
975
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
976
+	echo ' selected';
977
+}
978
+?>><?php echo _("Cargo"); ?></option>
979
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
980
+	echo ' selected';
981
+}
982
+?>><?php echo _("Military"); ?></option>
655 983
 			</select>
656 984
 		    </li>
657 985
 		    <?php
@@ -665,14 +993,20 @@  discard block
 block discarded – undo
665 993
 		    ?>
666 994
 		    <li>
667 995
 			<?php echo _("Display vessels with MMSI:"); ?>
668
-			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" />
996
+			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) {
997
+	print $_COOKIE['filter_mmsi'];
998
+}
999
+?>" />
669 1000
 		    </li>
670 1001
 		    <?php
671 1002
 			}
672 1003
 		    ?>
673 1004
 		    <li>
674 1005
 			<?php echo _("Display with ident:"); ?>
675
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
1006
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
1007
+	print $_COOKIE['filter_ident'];
1008
+}
1009
+?>" />
676 1010
 		    </li>
677 1011
 		</ul>
678 1012
 	    </form>
@@ -688,7 +1022,10 @@  discard block
 block discarded – undo
688 1022
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
689 1023
 	    <form>
690 1024
 		<ul>
691
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if ((isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') || !isset($_COOKIE['displayiss'])) print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
1025
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if ((isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') || !isset($_COOKIE['displayiss'])) {
1026
+	print 'checked';
1027
+}
1028
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
692 1029
 		    <li><?php echo _("Type:"); ?>
693 1030
 			<select class="selectpicker" multiple onchange="sattypes(this);">
694 1031
 			    <?php
@@ -696,25 +1033,45 @@  discard block
 block discarded – undo
696 1033
 				$types = $Satellite->get_tle_types();
697 1034
 				foreach ($types as $type) {
698 1035
 					$type_name = $type['tle_type'];
699
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
700
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
701
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
702
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
703
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
704
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
705
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
706
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
707
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
708
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
709
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
710
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
711
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
712
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
713
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
714
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
715
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
716
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
717
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
1036
+					if ($type_name == 'musson') {
1037
+						$type_name = 'Russian LEO Navigation';
1038
+					} else if ($type_name == 'nnss') {
1039
+						$type_name = 'Navi Navigation Satellite System';
1040
+					} else if ($type_name == 'sbas') {
1041
+						$type_name = 'Satellite-Based Augmentation System';
1042
+					} else if ($type_name == 'glo-ops') {
1043
+						$type_name = 'Glonass Operational';
1044
+					} else if ($type_name == 'gps-ops') {
1045
+						$type_name = 'GPS Operational';
1046
+					} else if ($type_name == 'argos') {
1047
+						$type_name = 'ARGOS Data Collection System';
1048
+					} else if ($type_name == 'tdrss') {
1049
+						$type_name = 'Tracking and Data Relay Satellite System';
1050
+					} else if ($type_name == 'sarsat') {
1051
+						$type_name = 'Search & Rescue';
1052
+					} else if ($type_name == 'dmc') {
1053
+						$type_name = 'Disaster Monitoring';
1054
+					} else if ($type_name == 'resource') {
1055
+						$type_name = 'Earth Resources';
1056
+					} else if ($type_name == 'stations') {
1057
+						$type_name = 'Space Stations';
1058
+					} else if ($type_name == 'geo') {
1059
+						$type_name = 'Geostationary';
1060
+					} else if ($type_name == 'amateur') {
1061
+						$type_name = 'Amateur Radio';
1062
+					} else if ($type_name == 'x-comm') {
1063
+						$type_name = 'Experimental';
1064
+					} else if ($type_name == 'other-comm') {
1065
+						$type_name = 'Other Comm';
1066
+					} else if ($type_name == 'science') {
1067
+						$type_name = 'Space & Earth Science';
1068
+					} else if ($type_name == 'military') {
1069
+						$type_name = 'Miscellaneous Military';
1070
+					} else if ($type_name == 'radar') {
1071
+						$type_name = 'Radar Calibration';
1072
+					} else if ($type_name == 'tle-new') {
1073
+						$type_name = 'Last 30 days launches';
1074
+					}
718 1075
 					
719 1076
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
720 1077
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.