Completed
Push — master ( 5e2e76...e76a64 )
by Yannick
32:07
created
install/class.update_db.php 1 patch
Doc Comments   +48 added lines patch added patch discarded remove patch
@@ -20,6 +20,9 @@  discard block
 block discarded – undo
20 20
 		return $writable;
21 21
 	}
22 22
 
23
+	/**
24
+	 * @param string $file
25
+	 */
23 26
 	public static function download($url, $file, $referer = '') {
24 27
 		global $globalProxy, $globalForceIPv4;
25 28
 		$fp = fopen($file, 'w');
@@ -44,6 +47,9 @@  discard block
 block discarded – undo
44 47
 		fclose($fp);
45 48
 	}
46 49
 
50
+	/**
51
+	 * @param string $in_file
52
+	 */
47 53
 	public static function gunzip($in_file,$out_file_name = '') {
48 54
 		//echo $in_file.' -> '.$out_file_name."\n";
49 55
 		$buffer_size = 4096; // read 4kb at a time
@@ -65,6 +71,9 @@  discard block
 block discarded – undo
65 71
 		}
66 72
 	}
67 73
 
74
+	/**
75
+	 * @param string $in_file
76
+	 */
68 77
 	public static function unzip($in_file) {
69 78
 		if ($in_file != '' && file_exists($in_file)) {
70 79
 			$path = pathinfo(realpath($in_file), PATHINFO_DIRNAME);
@@ -86,6 +95,9 @@  discard block
 block discarded – undo
86 95
 		}
87 96
 	}
88 97
 	
98
+	/**
99
+	 * @param string $database_file
100
+	 */
89 101
 	public static function retrieve_route_sqlite_to_dest($database_file) {
90 102
 		global $globalDebug, $globalTransaction;
91 103
 		//$query = 'TRUNCATE TABLE routes';
@@ -128,6 +140,10 @@  discard block
 block discarded – undo
128 140
 		}
129 141
                 return '';
130 142
 	}
143
+
144
+	/**
145
+	 * @param string $database_file
146
+	 */
131 147
 	public static function retrieve_route_oneworld($database_file) {
132 148
 		global $globalDebug, $globalTransaction;
133 149
 		//$query = 'TRUNCATE TABLE routes';
@@ -169,6 +185,9 @@  discard block
 block discarded – undo
169 185
                 return '';
170 186
 	}
171 187
 	
188
+	/**
189
+	 * @param string $database_file
190
+	 */
172 191
 	public static function retrieve_route_skyteam($database_file) {
173 192
 		global $globalDebug, $globalTransaction;
174 193
 		//$query = 'TRUNCATE TABLE routes';
@@ -211,6 +230,10 @@  discard block
 block discarded – undo
211 230
 		}
212 231
                 return '';
213 232
 	}
233
+
234
+	/**
235
+	 * @param string $database_file
236
+	 */
214 237
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
215 238
 		global $globalTransaction;
216 239
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -277,6 +300,9 @@  discard block
 block discarded – undo
277 300
 		return '';
278 301
 	}
279 302
 
303
+	/**
304
+	 * @param string $database_file
305
+	 */
280 306
 	public static function retrieve_modes_flarmnet($database_file) {
281 307
 		global $globalTransaction;
282 308
 		$Common = new Common();
@@ -347,6 +373,9 @@  discard block
 block discarded – undo
347 373
 		return '';
348 374
 	}
349 375
 
376
+	/**
377
+	 * @param string $database_file
378
+	 */
350 379
 	public static function retrieve_modes_ogn($database_file) {
351 380
 		global $globalTransaction;
352 381
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -416,6 +445,9 @@  discard block
 block discarded – undo
416 445
 		return '';
417 446
 	}
418 447
 
448
+	/**
449
+	 * @param string $database_file
450
+	 */
419 451
 	public static function retrieve_owner($database_file,$country = 'F') {
420 452
 		global $globalTransaction, $globalMasterSource;
421 453
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -1448,6 +1480,10 @@  discard block
 block discarded – undo
1448 1480
 		return '';
1449 1481
         }
1450 1482
 
1483
+	/**
1484
+	 * @param string $filename
1485
+	 * @param string $tletype
1486
+	 */
1451 1487
 	public static function tle($filename,$tletype) {
1452 1488
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1453 1489
 		global $tmp_dir, $globalTransaction;
@@ -1497,6 +1533,9 @@  discard block
 block discarded – undo
1497 1533
 		return '';
1498 1534
         }
1499 1535
 
1536
+	/**
1537
+	 * @param string $filename
1538
+	 */
1500 1539
 	public static function satellite_ucsdb($filename) {
1501 1540
 		global $tmp_dir, $globalTransaction;
1502 1541
 		
@@ -1545,6 +1584,9 @@  discard block
 block discarded – undo
1545 1584
 		return '';
1546 1585
 	}
1547 1586
 
1587
+	/**
1588
+	 * @param string $filename
1589
+	 */
1548 1590
 	public static function satellite_celestrak($filename) {
1549 1591
 		global $tmp_dir, $globalTransaction, $globalDebug;
1550 1592
 		$satcat_sources = array(
@@ -1871,6 +1913,9 @@  discard block
 block discarded – undo
1871 1913
 
1872 1914
 	}
1873 1915
 */
1916
+	/**
1917
+	 * @param string $filename
1918
+	 */
1874 1919
 	public static function waypoints($filename) {
1875 1920
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1876 1921
 		global $tmp_dir, $globalTransaction;
@@ -1948,6 +1993,9 @@  discard block
 block discarded – undo
1948 1993
 		}
1949 1994
 	}
1950 1995
 
1996
+	/**
1997
+	 * @param string $filename
1998
+	 */
1951 1999
 	public static function ivao_airlines($filename) {
1952 2000
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1953 2001
 		global $tmp_dir, $globalTransaction;
Please login to merge, or discard this patch.
require/class.SpotterImport.php 3 patches
Indentation   +433 added lines, -433 removed lines patch added patch discarded remove patch
@@ -16,20 +16,20 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/class.Source.php');
17 17
 require_once(dirname(__FILE__).'/class.GeoidHeight.php');
18 18
 if (isset($globalServerAPRS) && $globalServerAPRS) {
19
-    require_once(dirname(__FILE__).'/class.APRS.php');
19
+	require_once(dirname(__FILE__).'/class.APRS.php');
20 20
 }
21 21
 
22 22
 class SpotterImport {
23
-    private $all_flights = array();
24
-    private $last_delete_hourly = 0;
25
-    private $last_delete = 0;
26
-    private $stats = array();
27
-    private $tmd = 0;
28
-    private $source_location = array();
29
-    public $db = null;
30
-    public $nb = 0;
23
+	private $all_flights = array();
24
+	private $last_delete_hourly = 0;
25
+	private $last_delete = 0;
26
+	private $stats = array();
27
+	private $tmd = 0;
28
+	private $source_location = array();
29
+	public $db = null;
30
+	public $nb = 0;
31 31
 
32
-    public function __construct($dbc = null) {
32
+	public function __construct($dbc = null) {
33 33
 	global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid;
34 34
 	if (!(isset($globalNoDB) && $globalNoDB)) {
35 35
 		$Connection = new Connection($dbc);
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 		$currentdate = date('Y-m-d');
42 42
 		$sourcestat = $Stats->getStatsSource($currentdate);
43 43
 		if (!empty($sourcestat)) {
44
-		    foreach($sourcestat as $srcst) {
45
-		    	$type = $srcst['stats_type'];
44
+			foreach($sourcestat as $srcst) {
45
+				$type = $srcst['stats_type'];
46 46
 			if ($type == 'polar' || $type == 'hist') {
47
-			    $source = $srcst['source_name'];
48
-			    $data = $srcst['source_data'];
49
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
50
-	    		}
51
-		    }
47
+				$source = $srcst['source_name'];
48
+				$data = $srcst['source_data'];
49
+				$this->stats[$currentdate][$source][$type] = json_decode($data,true);
50
+				}
51
+			}
52 52
 		}
53 53
 	}
54 54
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 			$GeoidClass = FALSE;
64 64
 		}
65 65
 	}
66
-    }
66
+	}
67 67
 
68
-    public function get_Schedule($id,$ident) {
68
+	public function get_Schedule($id,$ident) {
69 69
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
70 70
 	// Get schedule here, so it's done only one time
71 71
 	
@@ -85,43 +85,43 @@  discard block
 block discarded – undo
85 85
 	$operator = $Spotter->getOperator($ident);
86 86
 	$scheduleexist = false;
87 87
 	if ($Schedule->checkSchedule($operator) == 0) {
88
-	    $operator = $Translation->checkTranslation($ident);
89
-	    if ($Schedule->checkSchedule($operator) == 0) {
88
+		$operator = $Translation->checkTranslation($ident);
89
+		if ($Schedule->checkSchedule($operator) == 0) {
90 90
 		$schedule = $Schedule->fetchSchedule($operator);
91 91
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
92
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
93
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
94
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
95
-		    // Should also check if route schedule = route from DB
96
-		    if ($schedule['DepartureAirportIATA'] != '') {
92
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
93
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
94
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
95
+			// Should also check if route schedule = route from DB
96
+			if ($schedule['DepartureAirportIATA'] != '') {
97 97
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
98
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
99
-			    if (trim($airport_icao) != '') {
98
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
99
+				if (trim($airport_icao) != '') {
100 100
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
101 101
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
102
-			    }
102
+				}
103
+			}
103 104
 			}
104
-		    }
105
-		    if ($schedule['ArrivalAirportIATA'] != '') {
105
+			if ($schedule['ArrivalAirportIATA'] != '') {
106 106
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
107
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
108
-			    if (trim($airport_icao) != '') {
107
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
108
+				if (trim($airport_icao) != '') {
109 109
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
110 110
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
111
-			    }
111
+				}
112 112
 			}
113
-		    }
114
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
113
+			}
114
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
115 115
 		}
116
-	    } else $scheduleexist = true;
116
+		} else $scheduleexist = true;
117 117
 	} else $scheduleexist = true;
118 118
 	// close connection, at least one way will work ?
119
-       if ($scheduleexist) {
119
+	   if ($scheduleexist) {
120 120
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
121
-    		$sch = $Schedule->getSchedule($operator);
121
+			$sch = $Schedule->getSchedule($operator);
122 122
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
123 123
 		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
124
-       }
124
+	   }
125 125
 	$Spotter->db = null;
126 126
 	$Schedule->db = null;
127 127
 	$Translation->db = null;
@@ -136,65 +136,65 @@  discard block
 block discarded – undo
136 136
 	}
137 137
 	  */
138 138
 	}
139
-    }
139
+	}
140 140
 
141
-    public function checkAll() {
141
+	public function checkAll() {
142 142
 	global $globalDebug, $globalNoImport;
143 143
 	if ($globalDebug) echo "Update last seen flights data...\n";
144 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
145
-	    foreach ($this->all_flights as $key => $flight) {
145
+		foreach ($this->all_flights as $key => $flight) {
146 146
 		if (isset($this->all_flights[$key]['id'])) {
147
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
148
-    		    $Spotter = new Spotter($this->db);
149
-        	    $real_arrival = $this->arrival($key);
150
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
151
-        	}
152
-	    }
147
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
148
+				$Spotter = new Spotter($this->db);
149
+				$real_arrival = $this->arrival($key);
150
+				if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
151
+			}
152
+		}
153
+	}
153 154
 	}
154
-    }
155 155
 
156
-    public function arrival($key) {
156
+	public function arrival($key) {
157 157
 	global $globalClosestMinDist, $globalDebug;
158 158
 	if ($globalDebug) echo 'Update arrival...'."\n";
159 159
 	$Spotter = new Spotter($this->db);
160
-        $airport_icao = '';
161
-        $airport_time = '';
162
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
160
+		$airport_icao = '';
161
+		$airport_time = '';
162
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
163 163
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
164
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
165
-    	    if (isset($closestAirports[0])) {
166
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
167
-        	    $airport_icao = $closestAirports[0]['icao'];
168
-        	    $airport_time = $this->all_flights[$key]['datetime'];
169
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
170
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
171
-        	    foreach ($closestAirports as $airport) {
172
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
173
-        		    $airport_icao = $airport['icao'];
174
-        		    $airport_time = $this->all_flights[$key]['datetime'];
175
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
176
-        		    break;
177
-        		}
178
-        	    }
179
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
180
-        		$airport_icao = $closestAirports[0]['icao'];
181
-        		$airport_time = $this->all_flights[$key]['datetime'];
182
-        	} else {
183
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
184
-        	}
185
-    	    } else {
186
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
187
-    	    }
164
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
165
+			if (isset($closestAirports[0])) {
166
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
167
+				$airport_icao = $closestAirports[0]['icao'];
168
+				$airport_time = $this->all_flights[$key]['datetime'];
169
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
170
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
171
+				foreach ($closestAirports as $airport) {
172
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
173
+					$airport_icao = $airport['icao'];
174
+					$airport_time = $this->all_flights[$key]['datetime'];
175
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
176
+					break;
177
+				}
178
+				}
179
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
180
+				$airport_icao = $closestAirports[0]['icao'];
181
+				$airport_time = $this->all_flights[$key]['datetime'];
182
+			} else {
183
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
184
+			}
185
+			} else {
186
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
187
+			}
188 188
 
189
-        } else {
190
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
191
-        }
192
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
193
-    }
189
+		} else {
190
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
191
+		}
192
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
193
+	}
194 194
 
195 195
 
196 196
 
197
-    public function del() {
197
+	public function del() {
198 198
 	global $globalDebug, $globalNoImport, $globalNoDB;
199 199
 	// Delete old infos
200 200
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 			}
207 207
 		}
208 208
 	}
209
-    }
209
+	}
210 210
 
211
-    public function delKey($key) {
211
+	public function delKey($key) {
212 212
 	global $globalDebug, $globalNoImport, $globalNoDB;
213 213
 	// Delete old infos
214 214
 	if (isset($this->all_flights[$key]['id'])) {
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 		if ($globalDebug) echo "\n";
231 231
 	}
232 232
 	unset($this->all_flights[$key]);
233
-    }
233
+	}
234 234
 
235
-    public function add($line) {
235
+	public function add($line) {
236 236
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
237 237
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
238 238
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
@@ -258,20 +258,20 @@  discard block
 block discarded – undo
258 258
 	
259 259
 	// SBS format is CSV format
260 260
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
261
-	    //print_r($line);
262
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
263
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
261
+		//print_r($line);
262
+		if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
263
+  		if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
264 264
 
265 265
 		// Increment message number
266 266
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
267
-		    $current_date = date('Y-m-d');
268
-		    if (isset($line['source_name'])) $source = $line['source_name'];
269
-		    else $source = '';
270
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
271
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
272
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
273
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
274
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
267
+			$current_date = date('Y-m-d');
268
+			if (isset($line['source_name'])) $source = $line['source_name'];
269
+			else $source = '';
270
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
271
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
272
+				$this->stats[$current_date][$source]['msg']['date'] = time();
273
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
274
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
275 275
 		}
276 276
 		
277 277
 		/*
@@ -287,54 +287,54 @@  discard block
 block discarded – undo
287 287
 		//$this->db = $dbc;
288 288
 
289 289
 		//$hex = trim($line['hex']);
290
-	        if (!isset($line['id'])) $id = trim($line['hex']);
291
-	        else $id = trim($line['id']);
290
+			if (!isset($line['id'])) $id = trim($line['hex']);
291
+			else $id = trim($line['id']);
292 292
 		
293 293
 		if (!isset($this->all_flights[$id])) {
294
-		    if ($globalDebug) echo 'New flight...'."\n";
295
-		    $this->all_flights[$id] = array();
296
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
297
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0));
298
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
299
-		    if (!isset($line['id'])) {
294
+			if ($globalDebug) echo 'New flight...'."\n";
295
+			$this->all_flights[$id] = array();
296
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
297
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0));
298
+			if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
299
+			if (!isset($line['id'])) {
300 300
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
301 301
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
302 302
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
303 303
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
304
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
305
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
306
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
304
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
305
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
306
+			if ($globalAllFlights !== FALSE) $dataFound = true;
307 307
 		}
308 308
 		if (isset($line['source_type']) && $line['source_type'] != '') {
309
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
309
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
310 310
 		}
311 311
 		
312 312
 		//print_r($this->all_flights);
313 313
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
314
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
315
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
314
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
315
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
316 316
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
317
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
318
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
317
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
318
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
319 319
 			$timeelapsed = microtime(true);
320 320
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
321
-			    $Spotter = new Spotter($this->db);
322
-			    if (isset($this->all_flights[$id]['source_type'])) {
321
+				$Spotter = new Spotter($this->db);
322
+				if (isset($this->all_flights[$id]['source_type'])) {
323 323
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
324
-			    } else {
324
+				} else {
325 325
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
326
-			    }
327
-			    $Spotter->db = null;
328
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
329
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
326
+				}
327
+				$Spotter->db = null;
328
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
329
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
330 330
 			}
331
-		    }
332
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
333
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
331
+			}
332
+			if ($globalAllFlights !== FALSE) $dataFound = true;
333
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
334 334
 		}
335
-	        if (isset($line['id']) && !isset($line['hex'])) {
336
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
337
-	        }
335
+			if (isset($line['id']) && !isset($line['hex'])) {
336
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
337
+			}
338 338
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
339 339
 			$icao = $line['aircraft_icao'];
340 340
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 		}
365 365
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
366 366
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
367
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
367
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
368 368
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
369
-		    } else {
369
+			} else {
370 370
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
371 371
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
372 372
 				/*
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 				print_r($line);
376 376
 				*/
377 377
 				return '';
378
-		    }
378
+			}
379 379
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
380 380
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
381 381
 			return '';
@@ -391,21 +391,21 @@  discard block
 block discarded – undo
391 391
 		}
392 392
 
393 393
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
394
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
394
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
395 395
 		}
396 396
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
397
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
397
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
398 398
 		}
399 399
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
400
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
400
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
401 401
 		}
402 402
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
403
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
403
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
404 404
 		}
405 405
  
406 406
 		if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
407 407
 
408
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
408
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
409 409
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
410 410
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
411 411
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -414,23 +414,23 @@  discard block
 block discarded – undo
414 414
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
415 415
 				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
416 416
 			} else {
417
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
418
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
417
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
418
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
419 419
 				$timeelapsed = microtime(true);
420
-            			$Spotter = new Spotter($this->db);
421
-            			$fromsource = NULL;
422
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
423
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
420
+						$Spotter = new Spotter($this->db);
421
+						$fromsource = NULL;
422
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
423
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
424 424
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
425 425
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
426 426
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
427
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
427
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
428 428
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
429 429
 				$Spotter->db = null;
430 430
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
431
-			    }
431
+				}
432 432
 			}
433
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
433
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
434 434
 		    
435 435
 /*
436 436
 		    if (!isset($line['id'])) {
@@ -440,63 +440,63 @@  discard block
 block discarded – undo
440 440
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
441 441
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
442 442
   */
443
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
443
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
444 444
 
445
-		    //$putinarchive = true;
446
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
445
+			//$putinarchive = true;
446
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
447 447
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
448
-		    }
449
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
448
+			}
449
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
450 450
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
451
-		    }
452
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
453
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
454
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
451
+			}
452
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
453
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
454
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
455 455
 			$timeelapsed = microtime(true);
456 456
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
457 457
 				$Spotter = new Spotter($this->db);
458 458
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
459 459
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
460
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
460
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
461 461
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
462
-                        }
463
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
462
+						}
463
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
464 464
 			$timeelapsed = microtime(true);
465 465
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
466
-			    $Spotter = new Spotter($this->db);
467
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
468
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
466
+				$Spotter = new Spotter($this->db);
467
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
468
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
469 469
 				$Translation = new Translation($this->db);
470 470
 				$ident = $Translation->checkTranslation(trim($line['ident']));
471 471
 				$route = $Spotter->getRouteInfo($ident);
472 472
 				$Translation->db = null;
473
-			    }
474
-			    $Spotter->db = null;
475
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
476
-                    	}
473
+				}
474
+				$Spotter->db = null;
475
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
476
+						}
477 477
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
478
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
479
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
478
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
479
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
480 480
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
481
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
482
-		    	    }
481
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
482
+					}
483 483
 			}
484 484
 			if (!isset($globalFork)) $globalFork = TRUE;
485 485
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
486 486
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
487 487
 			}
488
-		    }
488
+			}
489 489
 		}
490 490
 
491 491
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
492 492
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
493
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
494
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
495
-		    //$dataFound = true;
493
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
494
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
495
+			//$dataFound = true;
496 496
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
497
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
498
-		    if ($distance > 1000 && $distance < 10000) {
499
-		    // use datetime
497
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
498
+			if ($distance > 1000 && $distance < 10000) {
499
+			// use datetime
500 500
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
501 501
 			$speed = $speed*3.6;
502 502
 			if ($speed < 1000) {
@@ -505,49 +505,49 @@  discard block
 block discarded – undo
505 505
 	  		} else {
506 506
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
507 507
 	  		}
508
-		    }
508
+			}
509 509
 		}
510 510
 
511 511
 
512 512
 
513
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
514
-	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
515
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
516
-	    	    	return false;
517
-	    	    }
518
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
519
-	    	    else unset($timediff);
520
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
521
-	    	    else unset($timediff_archive);
522
-	    	    if ($this->tmd > 5
523
-	    	        || (isset($line['format_source']) 
524
-	    	    	    && $line['format_source'] == 'airwhere' 
525
-	    	    	    && ((!isset($this->all_flights[$id]['latitude']) 
526
-	    	    		|| !isset($this->all_flights[$id]['longitude'])) 
527
-	    	    		|| (isset($this->all_flights[$id]['latitude']) 
528
-	    	    		    && isset($this->all_flights[$id]['longitude']) 
529
-	    	    		    && $this->all_flights[$id]['latitude'] != $line['latitude'] 
530
-	    	    		    && $this->all_flights[$id]['longitude'] != $line['longitude']
531
-	    	    		)
532
-	    	    	    )
533
-	    	    	)
534
-	    		|| (isset($globalVA) && $globalVA) 
535
-	    	    	|| (isset($globalIVAO) && $globalIVAO)
536
-	    	    	|| (isset($globalVATSIM) && $globalVATSIM)
537
-	    	    	|| (isset($globalphpVMS) && $globalphpVMS)
538
-	    	    	|| (isset($globalVAM) && $globalVAM)
539
-	    	    	|| !isset($timediff)
540
-	    	    	|| $timediff > $globalLiveInterval
541
-	    	    	|| $globalArchive
542
-	    	    	|| ($timediff > 30 
543
-	    	    	    && isset($this->all_flights[$id]['latitude']) 
544
-	    	    	    && isset($this->all_flights[$id]['longitude']) 
545
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
546
-	    	    	    )
547
-	    	    	) {
513
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
514
+				if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
515
+					if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
516
+					return false;
517
+				}
518
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
519
+				else unset($timediff);
520
+				if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
521
+				else unset($timediff_archive);
522
+				if ($this->tmd > 5
523
+					|| (isset($line['format_source']) 
524
+						&& $line['format_source'] == 'airwhere' 
525
+						&& ((!isset($this->all_flights[$id]['latitude']) 
526
+						|| !isset($this->all_flights[$id]['longitude'])) 
527
+						|| (isset($this->all_flights[$id]['latitude']) 
528
+							&& isset($this->all_flights[$id]['longitude']) 
529
+							&& $this->all_flights[$id]['latitude'] != $line['latitude'] 
530
+							&& $this->all_flights[$id]['longitude'] != $line['longitude']
531
+						)
532
+						)
533
+					)
534
+				|| (isset($globalVA) && $globalVA) 
535
+					|| (isset($globalIVAO) && $globalIVAO)
536
+					|| (isset($globalVATSIM) && $globalVATSIM)
537
+					|| (isset($globalphpVMS) && $globalphpVMS)
538
+					|| (isset($globalVAM) && $globalVAM)
539
+					|| !isset($timediff)
540
+					|| $timediff > $globalLiveInterval
541
+					|| $globalArchive
542
+					|| ($timediff > 30 
543
+						&& isset($this->all_flights[$id]['latitude']) 
544
+						&& isset($this->all_flights[$id]['longitude']) 
545
+						&& $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
546
+						)
547
+					) {
548 548
 
549 549
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
550
-			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
550
+				if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
551 551
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
552 552
 				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
553 553
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 				}
560 560
 				$this->tmd = 0;
561 561
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
562
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
563
-				    $timeelapsed = microtime(true);
564
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
562
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
563
+					$timeelapsed = microtime(true);
564
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
565 565
 					$Spotter = new Spotter($this->db);
566 566
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
567 567
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
@@ -569,11 +569,11 @@  discard block
 block discarded – undo
569 569
 					$Spotter->db = null;
570 570
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
571 571
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
572
-				    }
572
+					}
573 573
 				}
574 574
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
575
-			    } 
576
-			    /*
575
+				} 
576
+				/*
577 577
 			    else {
578 578
 				if (!isset($timediff)) echo 'NO TIMEDIFF';
579 579
 				else {
@@ -587,16 +587,16 @@  discard block
 block discarded – undo
587 587
 			}
588 588
 
589 589
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
590
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
590
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
591 591
 				if (!isset($this->all_flights[$id]['archive_latitude'])) {
592 592
 					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
593 593
 					$this->all_flights[$id]['time_last_coord'] = time();
594 594
 				}
595 595
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
596 596
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
597
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
598
-				    $dataFound = true;
599
-				    $this->all_flights[$id]['time_last_coord'] = time();
597
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
598
+					$dataFound = true;
599
+					$this->all_flights[$id]['time_last_coord'] = time();
600 600
 				}
601 601
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
602 602
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -607,25 +607,25 @@  discard block
 block discarded – undo
607 607
 				    //$putinarchive = true;
608 608
 				}
609 609
 				*/
610
-			    /*
610
+				/*
611 611
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
612 612
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
613 613
 			    }
614 614
 			    */
615 615
 			}
616 616
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
617
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
618
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
617
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
618
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
619 619
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
620 620
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
621 621
 					$this->all_flights[$id]['time_last_coord'] = time();
622 622
 				}
623 623
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
624 624
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
625
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
626
-				    $dataFound = true;
627
-				    $this->all_flights[$id]['coordinates'] += 1;
628
-				    $this->all_flights[$id]['time_last_coord'] = time();
625
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
626
+					$dataFound = true;
627
+					$this->all_flights[$id]['coordinates'] += 1;
628
+					$this->all_flights[$id]['time_last_coord'] = time();
629 629
 				}
630 630
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
631 631
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -643,76 +643,76 @@  discard block
 block discarded – undo
643 643
 			    */
644 644
 			}
645 645
 			if ($globalDaemon === TRUE && isset($updateinitial) && $updateinitial && $this->all_flights[$id]['addedSpotter'] == 1) {
646
-			    if ($globalDebug) echo "\n".'>>> Update initial data !'."\n";
647
-			    unset($updateinitial);
648
-			    $SpotterArchive = new SpotterArchive();
649
-			    $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']);
650
-			    $SpotterArchive->db = null;
651
-			    $Spotter = new Spotter();
652
-			    $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']);
653
-			    $Spotter->db = null;
646
+				if ($globalDebug) echo "\n".'>>> Update initial data !'."\n";
647
+				unset($updateinitial);
648
+				$SpotterArchive = new SpotterArchive();
649
+				$SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']);
650
+				$SpotterArchive->db = null;
651
+				$Spotter = new Spotter();
652
+				$Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']);
653
+				$Spotter->db = null;
654 654
 			}
655
-		    } else if ($globalDebug && $timediff > 30) {
655
+			} else if ($globalDebug && $timediff > 30) {
656 656
 			$this->tmd = $this->tmd + 1;
657 657
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
658 658
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
659 659
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
660 660
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
661
-		    }
661
+			}
662 662
 		}
663 663
 		if (isset($line['last_update']) && $line['last_update'] != '') {
664
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
665
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
664
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
665
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
666 666
 		}
667 667
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
668
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
669
-		    //$dataFound = true;
668
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
669
+			//$dataFound = true;
670 670
 		}
671 671
 		if (isset($line['format_source']) && $line['format_source'] != '') {
672
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
672
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
673 673
 		}
674 674
 		if (isset($line['source_name']) && $line['source_name'] != '') {
675
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
675
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
676 676
 		}
677 677
 		if (isset($line['emergency']) && $line['emergency'] != '') {
678
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
679
-		    //$dataFound = true;
678
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
679
+			//$dataFound = true;
680 680
 		}
681 681
 		if (isset($line['ground']) && $line['ground'] != '') {
682
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
682
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
683 683
 			// Here we force archive of flight because after ground it's a new one (or should be)
684 684
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
685 685
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
686 686
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
687
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
687
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
688 688
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
689
-		    }
690
-		    if ($line['ground'] != 1) $line['ground'] = 0;
691
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
692
-		    //$dataFound = true;
689
+			}
690
+			if ($line['ground'] != 1) $line['ground'] = 0;
691
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
692
+			//$dataFound = true;
693 693
 		}
694 694
 		if (isset($line['squawk']) && $line['squawk'] != '') {
695
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
696
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
697
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
698
-			    $highlight = '';
699
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
700
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
701
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
702
-			    if ($highlight != '') {
695
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
696
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
697
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
698
+				$highlight = '';
699
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
700
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
701
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
702
+				if ($highlight != '') {
703 703
 				$timeelapsed = microtime(true);
704 704
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
705
-				    $Spotter = new Spotter($this->db);
706
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
707
-				    $Spotter->db = null;
708
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
705
+					$Spotter = new Spotter($this->db);
706
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
707
+					$Spotter->db = null;
708
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
709 709
 				}
710 710
 				//$putinarchive = true;
711 711
 				//$highlight = '';
712
-			    }
712
+				}
713 713
 			    
714
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
715
-		    //$dataFound = true;
714
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
715
+			//$dataFound = true;
716 716
 		}
717 717
 
718 718
 		if (isset($line['altitude']) && $line['altitude'] != '') {
@@ -723,13 +723,13 @@  discard block
 block discarded – undo
723 723
 					$line['altitude'] = $line['altitude'] - $geoid;
724 724
 				}
725 725
 			}
726
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
726
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
727 727
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
728 728
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
729 729
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
730 730
 			//$dataFound = true;
731
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
732
-		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
731
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
732
+			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
733 733
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
734 734
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
735 735
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -738,27 +738,27 @@  discard block
 block discarded – undo
738 738
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
739 739
 				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
740 740
 			}
741
-		    }
742
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
741
+			}
742
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
743 743
 		}
744 744
 
745 745
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
746
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
746
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
747 747
 		}
748 748
 		
749 749
 		if (isset($line['heading']) && $line['heading'] != '') {
750
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
751
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
752
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
753
-		    //$dataFound = true;
750
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
751
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
752
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
753
+			//$dataFound = true;
754 754
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
755
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
756
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
757
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
758
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
755
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
756
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
757
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
758
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
759 759
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
760
-  		    // If not enough messages and ACARS set heading to 0
761
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
760
+  			// If not enough messages and ACARS set heading to 0
761
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
762 762
   		}
763 763
 		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
764 764
 		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -771,133 +771,133 @@  discard block
 block discarded – undo
771 771
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
772 772
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
773 773
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
774
-		    $this->all_flights[$id]['lastupdate'] = time();
775
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
776
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
777
-			    //print_r($this->all_flights);
778
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
779
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
780
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
774
+			$this->all_flights[$id]['lastupdate'] = time();
775
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
776
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
777
+				//print_r($this->all_flights);
778
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
779
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
780
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
781 781
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
782
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
783
-				    $timeelapsed = microtime(true);
784
-				    $SpotterLive = new SpotterLive($this->db);
785
-				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
782
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
783
+					$timeelapsed = microtime(true);
784
+					$SpotterLive = new SpotterLive($this->db);
785
+					if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
786 786
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
787 787
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
788
-				    } elseif (isset($line['id'])) {
788
+					} elseif (isset($line['id'])) {
789 789
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
790 790
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
791
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
791
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
792 792
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
793 793
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
794
-				    } else $recent_ident = '';
795
-				    $SpotterLive->db=null;
796
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
797
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
794
+					} else $recent_ident = '';
795
+					$SpotterLive->db=null;
796
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
797
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
798 798
 				} else $recent_ident = '';
799
-			    } else {
799
+				} else {
800 800
 				$recent_ident = '';
801 801
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
802
-			    }
803
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
804
-			    if($recent_ident == "")
805
-			    {
802
+				}
803
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
804
+				if($recent_ident == "")
805
+				{
806 806
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
807 807
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
808 808
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
809 809
 				//adds the spotter data for the archive
810 810
 				$ignoreImport = false;
811 811
 				foreach($globalAirportIgnore as $airportIgnore) {
812
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
812
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
813 813
 					$ignoreImport = true;
814
-				    }
814
+					}
815 815
 				}
816 816
 				if (count($globalAirportAccept) > 0) {
817
-				    $ignoreImport = true;
818
-				    foreach($globalAirportIgnore as $airportIgnore) {
817
+					$ignoreImport = true;
818
+					foreach($globalAirportIgnore as $airportIgnore) {
819 819
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
820
-					    $ignoreImport = false;
820
+						$ignoreImport = false;
821
+					}
821 822
 					}
822
-				    }
823 823
 				}
824 824
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
825
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
825
+					foreach($globalAirlineIgnore as $airlineIgnore) {
826 826
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
827
-					    $ignoreImport = true;
827
+						$ignoreImport = true;
828
+					}
828 829
 					}
829
-				    }
830 830
 				}
831 831
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
832
-				    $ignoreImport = true;
833
-				    foreach($globalAirlineAccept as $airlineAccept) {
832
+					$ignoreImport = true;
833
+					foreach($globalAirlineAccept as $airlineAccept) {
834 834
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
835
-					    $ignoreImport = false;
835
+						$ignoreImport = false;
836
+					}
836 837
 					}
837
-				    }
838 838
 				}
839 839
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
840
-				    $ignoreImport = true;
841
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
840
+					$ignoreImport = true;
841
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
842 842
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
843
-					    $ignoreImport = false;
843
+						$ignoreImport = false;
844
+					}
844 845
 					}
845
-				    }
846 846
 				}
847 847
 				
848 848
 				if (!$ignoreImport) {
849
-				    $highlight = '';
850
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
851
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
852
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
853
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
854
-				    $timeelapsed = microtime(true);
855
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
849
+					$highlight = '';
850
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
851
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
852
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
853
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
854
+					$timeelapsed = microtime(true);
855
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
856 856
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
857
-					    $Spotter = new Spotter($this->db);
858
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
859
-					    $Spotter->db = null;
860
-					    if ($globalDebug) {
857
+						$Spotter = new Spotter($this->db);
858
+						$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
859
+						$Spotter->db = null;
860
+						if ($globalDebug) {
861 861
 						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
862 862
 						else echo 'Success';
863
-					    }
864
-					    if (count($result) > 1) {
865
-					    // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
863
+						}
864
+						if (count($result) > 1) {
865
+						// ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
866 866
 						if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
867 867
 						if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration'];
868
-					    }
868
+						}
869 869
 					}
870
-				    }
871
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
872
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
870
+					}
871
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
872
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
873 873
 
874
-				    // Add source stat in DB
875
-				    $Stats = new Stats($this->db);
876
-				    if (!empty($this->stats)) {
874
+					// Add source stat in DB
875
+					$Stats = new Stats($this->db);
876
+					if (!empty($this->stats)) {
877 877
 					if ($globalDebug) echo 'Add source stats : ';
878
-				        foreach($this->stats as $date => $data) {
879
-					    foreach($data as $source => $sourced) {
880
-					        //print_r($sourced);
881
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
882
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
883
-				    		if (isset($sourced['msg'])) {
884
-				    		    if (time() - $sourced['msg']['date'] > 10) {
885
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
886
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
887
-			    			        unset($this->stats[$date][$source]['msg']);
888
-			    			    }
889
-			    			}
890
-			    		    }
891
-			    		    if ($date != date('Y-m-d')) {
892
-			    			unset($this->stats[$date]);
893
-			    		    }
894
-				    	}
895
-				    	if ($globalDebug) echo 'Done'."\n";
878
+						foreach($this->stats as $date => $data) {
879
+						foreach($data as $source => $sourced) {
880
+							//print_r($sourced);
881
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
882
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
883
+							if (isset($sourced['msg'])) {
884
+								if (time() - $sourced['msg']['date'] > 10) {
885
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
886
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
887
+									unset($this->stats[$date][$source]['msg']);
888
+								}
889
+							}
890
+							}
891
+							if ($date != date('Y-m-d')) {
892
+							unset($this->stats[$date]);
893
+							}
894
+						}
895
+						if ($globalDebug) echo 'Done'."\n";
896 896
 
897
-				    }
898
-				    $Stats->db = null;
899
-				    }
900
-				    $this->del();
897
+					}
898
+					$Stats->db = null;
899
+					}
900
+					$this->del();
901 901
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
902 902
 				//$ignoreImport = false;
903 903
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -915,41 +915,41 @@  discard block
 block discarded – undo
915 915
 			*/
916 916
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
917 917
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
918
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
919
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
920
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
918
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
919
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
920
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
921 921
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
922
-					    $SpotterLive = new SpotterLive($this->db);
923
-					    $SpotterLive->deleteLiveSpotterData();
924
-					    $SpotterLive->db=null;
922
+						$SpotterLive = new SpotterLive($this->db);
923
+						$SpotterLive->deleteLiveSpotterData();
924
+						$SpotterLive->db=null;
925 925
 					}
926
-				    }
927
-				    if ($globalDebug) echo " Done\n";
928
-				    $this->last_delete = time();
926
+					}
927
+					if ($globalDebug) echo " Done\n";
928
+					$this->last_delete = time();
929 929
 				}
930
-			    } else {
930
+				} else {
931 931
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
932
-				    $this->all_flights[$id]['id'] = $recent_ident;
933
-				    $this->all_flights[$id]['addedSpotter'] = 1;
932
+					$this->all_flights[$id]['id'] = $recent_ident;
933
+					$this->all_flights[$id]['addedSpotter'] = 1;
934 934
 				}
935 935
 				if (isset($globalDaemon) && !$globalDaemon) {
936
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
936
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
937 937
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
938
-					    $Spotter = new Spotter($this->db);
939
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
940
-					    $Spotter->db = null;
938
+						$Spotter = new Spotter($this->db);
939
+						$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
940
+						$Spotter->db = null;
941
+					}
941 942
 					}
942
-				    }
943 943
 				}
944 944
 				
945
-			    }
945
+				}
946 946
 			}
947
-		    }
948
-		    //adds the spotter LIVE data
949
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
950
-		    //echo "\nAdd in Live !! \n";
951
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
952
-		    if ($globalDebug) {
947
+			}
948
+			//adds the spotter LIVE data
949
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
950
+			//echo "\nAdd in Live !! \n";
951
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
952
+			if ($globalDebug) {
953 953
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
954 954
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
955 955
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -957,61 +957,61 @@  discard block
 block discarded – undo
957 957
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
958 958
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
959 959
 			}
960
-		    }
961
-		    $ignoreImport = false;
962
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
963
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
960
+			}
961
+			$ignoreImport = false;
962
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
963
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
964 964
 
965
-		    foreach($globalAirportIgnore as $airportIgnore) {
966
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
967
-			    $ignoreImport = true;
965
+			foreach($globalAirportIgnore as $airportIgnore) {
966
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
967
+				$ignoreImport = true;
968
+			}
968 969
 			}
969
-		    }
970
-		    if (count($globalAirportAccept) > 0) {
971
-		        $ignoreImport = true;
972
-		        foreach($globalAirportIgnore as $airportIgnore) {
973
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
970
+			if (count($globalAirportAccept) > 0) {
971
+				$ignoreImport = true;
972
+				foreach($globalAirportIgnore as $airportIgnore) {
973
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
974 974
 				$ignoreImport = false;
975
-			    }
975
+				}
976 976
 			}
977
-		    }
978
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
977
+			}
978
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
979 979
 			foreach($globalAirlineIgnore as $airlineIgnore) {
980
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
980
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
981 981
 				$ignoreImport = true;
982
-			    }
982
+				}
983 983
 			}
984
-		    }
985
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
984
+			}
985
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
986 986
 			$ignoreImport = true;
987 987
 			foreach($globalAirlineAccept as $airlineAccept) {
988
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
988
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
989 989
 				$ignoreImport = false;
990
-			    }
990
+				}
991
+			}
991 992
 			}
992
-		    }
993
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
993
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
994 994
 			$ignoreImport = true;
995 995
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
996
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
997
-			        $ignoreImport = false;
998
-			    }
996
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
997
+					$ignoreImport = false;
998
+				}
999
+			}
999 1000
 			}
1000
-		    }
1001 1001
 
1002
-		    if (!$ignoreImport) {
1002
+			if (!$ignoreImport) {
1003 1003
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
1004 1004
 				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1005 1005
 				$timeelapsed = microtime(true);
1006 1006
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
1007
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1007
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1008 1008
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1009 1009
 					$SpotterLive = new SpotterLive($this->db);
1010 1010
 					//var_dump($this->all_flights[$id]);
1011 1011
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
1012 1012
 					$SpotterLive->db = null;
1013 1013
 					if ($globalDebug) echo $result."\n";
1014
-				    }
1014
+					}
1015 1015
 				}
1016 1016
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
1017 1017
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 				//if ($line['format_source'] != 'aprs') {
1024 1024
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
1025 1025
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1026
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1026
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1027 1027
 					$source = $this->all_flights[$id]['source_name'];
1028 1028
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1029 1029
 					if (!isset($this->source_location[$source])) {
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 					if ($stats_heading == 16) $stats_heading = 0;
1050 1050
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1051 1051
 						for ($i=0;$i<=15;$i++) {
1052
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1052
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
1053 1053
 						}
1054 1054
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
1055 1055
 					} else {
@@ -1062,17 +1062,17 @@  discard block
 block discarded – undo
1062 1062
 					//var_dump($this->stats);
1063 1063
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1064 1064
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1065
-						    end($this->stats[$current_date][$source]['hist']);
1066
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1065
+							end($this->stats[$current_date][$source]['hist']);
1066
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
1067 1067
 						} else $mini = 0;
1068 1068
 						for ($i=$mini;$i<=$distance;$i+=10) {
1069
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1069
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
1070 1070
 						}
1071 1071
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
1072 1072
 					} else {
1073 1073
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
1074 1074
 					}
1075
-				    }
1075
+					}
1076 1076
 				}
1077 1077
 
1078 1078
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 			//$this->del();
1083 1083
 			
1084 1084
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1085
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1085
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1086 1086
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1087 1087
 				$SpotterLive = new SpotterLive($this->db);
1088 1088
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -1090,19 +1090,19 @@  discard block
 block discarded – undo
1090 1090
 				//SpotterLive->deleteLiveSpotterData();
1091 1091
 				if ($globalDebug) echo " Done\n";
1092 1092
 				$this->last_delete_hourly = time();
1093
-			    } else {
1093
+				} else {
1094 1094
 				$this->del();
1095 1095
 				$this->last_delete_hourly = time();
1096
-			    }
1096
+				}
1097 1097
 			}
1098 1098
 			
1099
-		    }
1100
-		    //$ignoreImport = false;
1099
+			}
1100
+			//$ignoreImport = false;
1101 1101
 		}
1102 1102
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1103 1103
 		if ($send) return $this->all_flights[$id];
1104
-	    }
1104
+		}
1105
+	}
1105 1106
 	}
1106
-    }
1107 1107
 }
1108 1108
 ?>
Please login to merge, or discard this patch.
Spacing   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 		$currentdate = date('Y-m-d');
42 42
 		$sourcestat = $Stats->getStatsSource($currentdate);
43 43
 		if (!empty($sourcestat)) {
44
-		    foreach($sourcestat as $srcst) {
44
+		    foreach ($sourcestat as $srcst) {
45 45
 		    	$type = $srcst['stats_type'];
46 46
 			if ($type == 'polar' || $type == 'hist') {
47 47
 			    $source = $srcst['source_name'];
48 48
 			    $data = $srcst['source_data'];
49
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
49
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
50 50
 	    		}
51 51
 		    }
52 52
 		}
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
 	if (isset($globalGeoid) && $globalGeoid) {
59 59
 		try {
60 60
 			$GeoidClass = new GeoidHeight();
61
-		} catch(Exception $e) {
61
+		} catch (Exception $e) {
62 62
 			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
63 63
 			$GeoidClass = FALSE;
64 64
 		}
65 65
 	}
66 66
     }
67 67
 
68
-    public function get_Schedule($id,$ident) {
68
+    public function get_Schedule($id, $ident) {
69 69
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
70 70
 	// Get schedule here, so it's done only one time
71 71
 	
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 		$schedule = $Schedule->fetchSchedule($operator);
91 91
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
92 92
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
93
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
94
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
93
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
94
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
95 95
 		    // Should also check if route schedule = route from DB
96 96
 		    if ($schedule['DepartureAirportIATA'] != '') {
97 97
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			    }
112 112
 			}
113 113
 		    }
114
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
114
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
115 115
 		}
116 116
 	    } else $scheduleexist = true;
117 117
 	} else $scheduleexist = true;
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
        if ($scheduleexist) {
120 120
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
121 121
     		$sch = $Schedule->getSchedule($operator);
122
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
123
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
122
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
123
+		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'], $sch['departure_airport_icao'], $sch['departure_airport_time'], $sch['arrival_airport_icao'], $sch['arrival_airport_time']);
124 124
        }
125 125
 	$Spotter->db = null;
126 126
 	$Schedule->db = null;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
148 148
     		    $Spotter = new Spotter($this->db);
149 149
         	    $real_arrival = $this->arrival($key);
150
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
150
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
151 151
         	}
152 152
 	    }
153 153
 	}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         $airport_time = '';
162 162
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
163 163
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
164
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
164
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
165 165
     	    if (isset($closestAirports[0])) {
166 166
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
167 167
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         		    break;
177 177
         		}
178 178
         	    }
179
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
179
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
180 180
         		$airport_icao = $closestAirports[0]['icao'];
181 181
         		$airport_time = $this->all_flights[$key]['datetime'];
182 182
         	} else {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         } else {
190 190
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
191 191
         }
192
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
192
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
193 193
     }
194 194
 
195 195
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	
202 202
 	foreach ($this->all_flights as $key => $flight) {
203 203
 		if (isset($flight['lastupdate'])) {
204
-			if ($flight['lastupdate'] < (time()-1800)) {
204
+			if ($flight['lastupdate'] < (time() - 1800)) {
205 205
 				$this->delKey($key);
206 206
 			}
207 207
 		}
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
 			$Spotter = new Spotter($this->db);
219 219
 			$SpotterLive = new SpotterLive($this->db);
220 220
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
221
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
221
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
222 222
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
223 223
 				$this->all_flights[$key]['putinarchive'] = true;
224
-				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']);
224
+				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'], $this->all_flights[$key]['route_stop'], $this->all_flights[$key]['hex'], $this->all_flights[$key]['putinarchive'], $this->all_flights[$key]['registration'], $this->all_flights[$key]['pilot_id'], $this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['format_source'], $this->all_flights[$key]['source_name'], $this->all_flights[$key]['over_country']);
225 225
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
226 226
 			}
227 227
 			$Spotter->db = null;
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	$send = false;
258 258
 	
259 259
 	// SBS format is CSV format
260
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
260
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
261 261
 	    //print_r($line);
262 262
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
263
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
263
+  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'], 0, 1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
264 264
 
265 265
 		// Increment message number
266 266
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
@@ -293,25 +293,25 @@  discard block
 block discarded – undo
293 293
 		if (!isset($this->all_flights[$id])) {
294 294
 		    if ($globalDebug) echo 'New flight...'."\n";
295 295
 		    $this->all_flights[$id] = array();
296
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
297
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0));
298
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
296
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
297
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => '', 'coordinates' => 0));
298
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
299 299
 		    if (!isset($line['id'])) {
300 300
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
301 301
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
302 302
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
303
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
303
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
304 304
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
305
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
305
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
306 306
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
307 307
 		}
308 308
 		if (isset($line['source_type']) && $line['source_type'] != '') {
309
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
309
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
310 310
 		}
311 311
 		
312 312
 		//print_r($this->all_flights);
313 313
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
314
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
314
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
315 315
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
316 316
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
317 317
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -320,20 +320,20 @@  discard block
 block discarded – undo
320 320
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
321 321
 			    $Spotter = new Spotter($this->db);
322 322
 			    if (isset($this->all_flights[$id]['source_type'])) {
323
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
323
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
324 324
 			    } else {
325 325
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
326 326
 			    }
327 327
 			    $Spotter->db = null;
328
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
329
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
328
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
329
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
330 330
 			}
331 331
 		    }
332 332
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
333 333
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
334 334
 		}
335 335
 	        if (isset($line['id']) && !isset($line['hex'])) {
336
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
336
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
337 337
 	        }
338 338
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
339 339
 			$icao = $line['aircraft_icao'];
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
 				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
343 343
 				$Spotter->db = null;
344 344
 			}
345
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
345
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
346 346
 		} elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
347 347
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
348 348
 				// Get aircraft ICAO from aircraft name
349 349
 				$Spotter = new Spotter($this->db);
350 350
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
351 351
 				$Spotter->db = null;
352
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
352
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
353 353
 			}
354 354
 		}
355 355
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -357,15 +357,15 @@  discard block
 block discarded – undo
357 357
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
358 358
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
359 359
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
360
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
360
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
361 361
 		}
362 362
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
363
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
363
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
364 364
 		}
365 365
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
366
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
366
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
367 367
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
368
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
368
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
369 369
 		    } else {
370 370
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
371 371
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -376,31 +376,31 @@  discard block
 block discarded – undo
376 376
 				*/
377 377
 				return '';
378 378
 		    }
379
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
379
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
380 380
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
381 381
 			return '';
382
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
382
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
383 383
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
384 384
 			return '';
385 385
 		} elseif (!isset($line['datetime'])) {
386 386
 			date_default_timezone_set('UTC');
387
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
387
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
388 388
 		} else {
389 389
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
390 390
 			return '';
391 391
 		}
392 392
 
393 393
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
394
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
394
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
395 395
 		}
396 396
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
397
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
397
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
398 398
 		}
399 399
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
400
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
400
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
401 401
 		}
402 402
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
403
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
403
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
404 404
 		}
405 405
  
406 406
 		if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
409 409
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
410 410
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
411
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
412
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
413
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
414
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
415
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
411
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
412
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
413
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
414
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
415
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
416 416
 			} else {
417
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
417
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
418 418
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
419 419
 				$timeelapsed = microtime(true);
420 420
             			$Spotter = new Spotter($this->db);
@@ -424,13 +424,13 @@  discard block
 block discarded – undo
424 424
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
425 425
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
426 426
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
427
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
427
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource, $this->all_flights[$id]['source_type']);
428 428
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
429 429
 				$Spotter->db = null;
430
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
430
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
431 431
 			    }
432 432
 			}
433
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
433
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
434 434
 		    
435 435
 /*
436 436
 		    if (!isset($line['id'])) {
@@ -440,25 +440,25 @@  discard block
 block discarded – undo
440 440
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
441 441
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
442 442
   */
443
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
443
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
444 444
 
445 445
 		    //$putinarchive = true;
446 446
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
447
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
447
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
448 448
 		    }
449 449
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
450
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
450
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
451 451
 		    }
452 452
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
453
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
453
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
454 454
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
455 455
 			$timeelapsed = microtime(true);
456 456
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
457 457
 				$Spotter = new Spotter($this->db);
458 458
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
459 459
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
460
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
461
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
460
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
461
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
462 462
                         }
463 463
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
464 464
 			$timeelapsed = microtime(true);
@@ -472,35 +472,35 @@  discard block
 block discarded – undo
472 472
 				$Translation->db = null;
473 473
 			    }
474 474
 			    $Spotter->db = null;
475
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
475
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
476 476
                     	}
477 477
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
478 478
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
479 479
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
480 480
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
481
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
481
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
482 482
 		    	    }
483 483
 			}
484 484
 			if (!isset($globalFork)) $globalFork = TRUE;
485 485
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
486
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
486
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
487 487
 			}
488 488
 		    }
489 489
 		}
490 490
 
491 491
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
492 492
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
493
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
494
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
493
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
494
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
495 495
 		    //$dataFound = true;
496 496
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
497
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
497
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
498 498
 		    if ($distance > 1000 && $distance < 10000) {
499 499
 		    // use datetime
500 500
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
501 501
 			$speed = $speed*3.6;
502 502
 			if ($speed < 1000) {
503
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
503
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
504 504
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
505 505
 	  		} else {
506 506
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -515,9 +515,9 @@  discard block
 block discarded – undo
515 515
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
516 516
 	    	    	return false;
517 517
 	    	    }
518
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
518
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
519 519
 	    	    else unset($timediff);
520
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
520
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
521 521
 	    	    else unset($timediff_archive);
522 522
 	    	    if ($this->tmd > 5
523 523
 	    	        || (isset($line['format_source']) 
@@ -542,14 +542,14 @@  discard block
 block discarded – undo
542 542
 	    	    	|| ($timediff > 30 
543 543
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
544 544
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
545
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
545
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
546 546
 	    	    	    )
547 547
 	    	    	) {
548 548
 
549 549
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
550 550
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
551 551
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
552
-				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
552
+				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
553 553
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
554 554
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
555 555
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
 				    $timeelapsed = microtime(true);
564 564
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
565 565
 					$Spotter = new Spotter($this->db);
566
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
566
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
567 567
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
568 568
 					else $this->all_flights[$id]['over_country'] = '';
569 569
 					$Spotter->db = null;
570
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
570
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
571 571
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
572 572
 				    }
573 573
 				}
@@ -593,13 +593,13 @@  discard block
 block discarded – undo
593 593
 					$this->all_flights[$id]['time_last_coord'] = time();
594 594
 				}
595 595
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
596
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
596
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) {
597 597
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
598 598
 				    $dataFound = true;
599 599
 				    $this->all_flights[$id]['time_last_coord'] = time();
600 600
 				}
601 601
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
602
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
602
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
603 603
 				/*
604 604
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
605 605
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -621,14 +621,14 @@  discard block
 block discarded – undo
621 621
 					$this->all_flights[$id]['time_last_coord'] = time();
622 622
 				}
623 623
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
624
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
624
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) {
625 625
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
626 626
 				    $dataFound = true;
627 627
 				    $this->all_flights[$id]['coordinates'] += 1;
628 628
 				    $this->all_flights[$id]['time_last_coord'] = time();
629 629
 				}
630 630
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
631
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
631
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
632 632
 				/*
633 633
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
634 634
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -649,52 +649,52 @@  discard block
 block discarded – undo
649 649
 			    $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']);
650 650
 			    $SpotterArchive->db = null;
651 651
 			    $Spotter = new Spotter();
652
-			    $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime']);
652
+			    $Spotter->updateInitialSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime']);
653 653
 			    $Spotter->db = null;
654 654
 			}
655 655
 		    } else if ($globalDebug && $timediff > 30) {
656 656
 			$this->tmd = $this->tmd + 1;
657 657
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
658
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
659
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
658
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
659
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
660 660
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
661 661
 		    }
662 662
 		}
663 663
 		if (isset($line['last_update']) && $line['last_update'] != '') {
664 664
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
665
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
665
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
666 666
 		}
667 667
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
668
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
668
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
669 669
 		    //$dataFound = true;
670 670
 		}
671 671
 		if (isset($line['format_source']) && $line['format_source'] != '') {
672
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
672
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
673 673
 		}
674 674
 		if (isset($line['source_name']) && $line['source_name'] != '') {
675
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
675
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
676 676
 		}
677 677
 		if (isset($line['emergency']) && $line['emergency'] != '') {
678
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
678
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
679 679
 		    //$dataFound = true;
680 680
 		}
681 681
 		if (isset($line['ground']) && $line['ground'] != '') {
682 682
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
683 683
 			// Here we force archive of flight because after ground it's a new one (or should be)
684
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
685
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
686
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
687
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
688
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
684
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
685
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
686
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
687
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
688
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
689 689
 		    }
690 690
 		    if ($line['ground'] != 1) $line['ground'] = 0;
691
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
691
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
692 692
 		    //$dataFound = true;
693 693
 		}
694 694
 		if (isset($line['squawk']) && $line['squawk'] != '') {
695 695
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
696 696
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
697
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
697
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
698 698
 			    $highlight = '';
699 699
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
700 700
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -703,66 +703,66 @@  discard block
 block discarded – undo
703 703
 				$timeelapsed = microtime(true);
704 704
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
705 705
 				    $Spotter = new Spotter($this->db);
706
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
706
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
707 707
 				    $Spotter->db = null;
708
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
708
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
709 709
 				}
710 710
 				//$putinarchive = true;
711 711
 				//$highlight = '';
712 712
 			    }
713 713
 			    
714
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
714
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
715 715
 		    //$dataFound = true;
716 716
 		}
717 717
 
718 718
 		if (isset($line['altitude']) && $line['altitude'] != '') {
719 719
 			if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) {
720 720
 				if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') {
721
-					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2);
721
+					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2);
722 722
 					//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n";
723 723
 					$line['altitude'] = $line['altitude'] - $geoid;
724 724
 				}
725 725
 			}
726 726
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
727
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
728
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
729
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
727
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
728
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
729
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
730 730
 			//$dataFound = true;
731 731
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
732 732
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
733 733
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
734 734
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
735
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
736
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
737
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
738
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
739
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
735
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
736
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
737
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
738
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
739
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
740 740
 			}
741 741
 		    }
742
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
742
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
743 743
 		}
744 744
 
745 745
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
746
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
746
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
747 747
 		}
748 748
 		
749 749
 		if (isset($line['heading']) && $line['heading'] != '') {
750
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
751
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
752
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
750
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
751
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
752
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
753 753
 		    //$dataFound = true;
754 754
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
755
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
756
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
757
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
755
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
756
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
757
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
758 758
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
759 759
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
760 760
   		    // If not enough messages and ACARS set heading to 0
761
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
761
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
762 762
   		}
763
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
764
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
765
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
763
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
764
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
765
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
766 766
 
767 767
 //		print_r($this->all_flights[$id]);
768 768
 		//gets the callsign from the last hour
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
774 774
 		    $this->all_flights[$id]['lastupdate'] = time();
775 775
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
776
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
776
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
777 777
 			    //print_r($this->all_flights);
778 778
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
779 779
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -784,61 +784,61 @@  discard block
 block discarded – undo
784 784
 				    $SpotterLive = new SpotterLive($this->db);
785 785
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
786 786
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
787
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
787
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
788 788
 				    } elseif (isset($line['id'])) {
789 789
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
790
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
790
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
791 791
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
792 792
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
793
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
793
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
794 794
 				    } else $recent_ident = '';
795
-				    $SpotterLive->db=null;
795
+				    $SpotterLive->db = null;
796 796
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
797 797
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
798 798
 				} else $recent_ident = '';
799 799
 			    } else {
800 800
 				$recent_ident = '';
801
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
801
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
802 802
 			    }
803 803
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
804
-			    if($recent_ident == "")
804
+			    if ($recent_ident == "")
805 805
 			    {
806 806
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
807 807
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
808 808
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
809 809
 				//adds the spotter data for the archive
810 810
 				$ignoreImport = false;
811
-				foreach($globalAirportIgnore as $airportIgnore) {
811
+				foreach ($globalAirportIgnore as $airportIgnore) {
812 812
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
813 813
 					$ignoreImport = true;
814 814
 				    }
815 815
 				}
816 816
 				if (count($globalAirportAccept) > 0) {
817 817
 				    $ignoreImport = true;
818
-				    foreach($globalAirportIgnore as $airportIgnore) {
818
+				    foreach ($globalAirportIgnore as $airportIgnore) {
819 819
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
820 820
 					    $ignoreImport = false;
821 821
 					}
822 822
 				    }
823 823
 				}
824 824
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
825
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
826
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
825
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
826
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
827 827
 					    $ignoreImport = true;
828 828
 					}
829 829
 				    }
830 830
 				}
831 831
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
832 832
 				    $ignoreImport = true;
833
-				    foreach($globalAirlineAccept as $airlineAccept) {
834
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
833
+				    foreach ($globalAirlineAccept as $airlineAccept) {
834
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
835 835
 					    $ignoreImport = false;
836 836
 					}
837 837
 				    }
838 838
 				}
839 839
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
840 840
 				    $ignoreImport = true;
841
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
841
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
842 842
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
843 843
 					    $ignoreImport = false;
844 844
 					}
@@ -850,12 +850,12 @@  discard block
 block discarded – undo
850 850
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
851 851
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
852 852
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
853
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
853
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
854 854
 				    $timeelapsed = microtime(true);
855 855
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
856 856
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
857 857
 					    $Spotter = new Spotter($this->db);
858
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
858
+					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']);
859 859
 					    $Spotter->db = null;
860 860
 					    if ($globalDebug) {
861 861
 						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
@@ -868,22 +868,22 @@  discard block
 block discarded – undo
868 868
 					    }
869 869
 					}
870 870
 				    }
871
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
871
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
872 872
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
873 873
 
874 874
 				    // Add source stat in DB
875 875
 				    $Stats = new Stats($this->db);
876 876
 				    if (!empty($this->stats)) {
877 877
 					if ($globalDebug) echo 'Add source stats : ';
878
-				        foreach($this->stats as $date => $data) {
879
-					    foreach($data as $source => $sourced) {
878
+				        foreach ($this->stats as $date => $data) {
879
+					    foreach ($data as $source => $sourced) {
880 880
 					        //print_r($sourced);
881
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
882
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
881
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
882
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
883 883
 				    		if (isset($sourced['msg'])) {
884 884
 				    		    if (time() - $sourced['msg']['date'] > 10) {
885 885
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
886
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
886
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
887 887
 			    			        unset($this->stats[$date][$source]['msg']);
888 888
 			    			    }
889 889
 			    			}
@@ -921,14 +921,14 @@  discard block
 block discarded – undo
921 921
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
922 922
 					    $SpotterLive = new SpotterLive($this->db);
923 923
 					    $SpotterLive->deleteLiveSpotterData();
924
-					    $SpotterLive->db=null;
924
+					    $SpotterLive->db = null;
925 925
 					}
926 926
 				    }
927 927
 				    if ($globalDebug) echo " Done\n";
928 928
 				    $this->last_delete = time();
929 929
 				}
930 930
 			    } else {
931
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
931
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
932 932
 				    $this->all_flights[$id]['id'] = $recent_ident;
933 933
 				    $this->all_flights[$id]['addedSpotter'] = 1;
934 934
 				}
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
937 937
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
938 938
 					    $Spotter = new Spotter($this->db);
939
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
939
+					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
940 940
 					    $Spotter->db = null;
941 941
 					}
942 942
 				    }
@@ -962,37 +962,37 @@  discard block
 block discarded – undo
962 962
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
963 963
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
964 964
 
965
-		    foreach($globalAirportIgnore as $airportIgnore) {
965
+		    foreach ($globalAirportIgnore as $airportIgnore) {
966 966
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
967 967
 			    $ignoreImport = true;
968 968
 			}
969 969
 		    }
970 970
 		    if (count($globalAirportAccept) > 0) {
971 971
 		        $ignoreImport = true;
972
-		        foreach($globalAirportIgnore as $airportIgnore) {
972
+		        foreach ($globalAirportIgnore as $airportIgnore) {
973 973
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
974 974
 				$ignoreImport = false;
975 975
 			    }
976 976
 			}
977 977
 		    }
978 978
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
979
-			foreach($globalAirlineIgnore as $airlineIgnore) {
980
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
979
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
980
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
981 981
 				$ignoreImport = true;
982 982
 			    }
983 983
 			}
984 984
 		    }
985 985
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
986 986
 			$ignoreImport = true;
987
-			foreach($globalAirlineAccept as $airlineAccept) {
988
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
987
+			foreach ($globalAirlineAccept as $airlineAccept) {
988
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
989 989
 				$ignoreImport = false;
990 990
 			    }
991 991
 			}
992 992
 		    }
993 993
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
994 994
 			$ignoreImport = true;
995
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
995
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
996 996
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
997 997
 			        $ignoreImport = false;
998 998
 			    }
@@ -1000,24 +1000,24 @@  discard block
 block discarded – undo
1000 1000
 		    }
1001 1001
 
1002 1002
 		    if (!$ignoreImport) {
1003
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
1004
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1003
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
1004
+				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1005 1005
 				$timeelapsed = microtime(true);
1006 1006
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
1007 1007
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1008 1008
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1009 1009
 					$SpotterLive = new SpotterLive($this->db);
1010 1010
 					//var_dump($this->all_flights[$id]);
1011
-					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
1011
+					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
1012 1012
 					$SpotterLive->db = null;
1013 1013
 					if ($globalDebug) echo $result."\n";
1014 1014
 				    }
1015 1015
 				}
1016 1016
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
1017
-					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
1017
+					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
1018 1018
 				}
1019 1019
 				$this->all_flights[$id]['putinarchive'] = false;
1020
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1020
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
1021 1021
 
1022 1022
 				// Put statistics in $this->stats variable
1023 1023
 				//if ($line['format_source'] != 'aprs') {
@@ -1036,19 +1036,19 @@  discard block
 block discarded – undo
1036 1036
 							$latitude = $globalCenterLatitude;
1037 1037
 							$longitude = $globalCenterLongitude;
1038 1038
 						}
1039
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
1039
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
1040 1040
 					} else {
1041 1041
 						$latitude = $this->source_location[$source]['latitude'];
1042 1042
 						$longitude = $this->source_location[$source]['longitude'];
1043 1043
 					}
1044
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1044
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1045 1045
 					//$stats_heading = $stats_heading%22.5;
1046 1046
 					$stats_heading = round($stats_heading/22.5);
1047
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1047
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1048 1048
 					$current_date = date('Y-m-d');
1049 1049
 					if ($stats_heading == 16) $stats_heading = 0;
1050 1050
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1051
-						for ($i=0;$i<=15;$i++) {
1051
+						for ($i = 0; $i <= 15; $i++) {
1052 1052
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1053 1053
 						}
1054 1054
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1063,9 +1063,9 @@  discard block
 block discarded – undo
1063 1063
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1064 1064
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1065 1065
 						    end($this->stats[$current_date][$source]['hist']);
1066
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1066
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1067 1067
 						} else $mini = 0;
1068
-						for ($i=$mini;$i<=$distance;$i+=10) {
1068
+						for ($i = $mini; $i <= $distance; $i += 10) {
1069 1069
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1070 1070
 						}
1071 1071
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 				$this->all_flights[$id]['lastupdate'] = time();
1079 1079
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1080 1080
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1081
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1081
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
1082 1082
 			//$this->del();
1083 1083
 			
1084 1084
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.
Braces   +424 added lines, -151 removed lines patch added patch discarded remove patch
@@ -59,7 +59,9 @@  discard block
 block discarded – undo
59 59
 		try {
60 60
 			$GeoidClass = new GeoidHeight();
61 61
 		} catch(Exception $e) {
62
-			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
62
+			if ($globalDebug) {
63
+				echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
64
+			}
63 65
 			$GeoidClass = FALSE;
64 66
 		}
65 67
 	}
@@ -78,7 +80,9 @@  discard block
 block discarded – undo
78 80
 	$dbc = $this->db;
79 81
 	$this->all_flights[$id]['schedule_check'] = true;
80 82
 	if ($globalSchedulesFetch) {
81
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
83
+	if ($globalDebug) {
84
+		echo 'Getting schedule info...'."\n";
85
+	}
82 86
 	$Spotter = new Spotter($dbc);
83 87
 	$Schedule = new Schedule($dbc);
84 88
 	$Translation = new Translation($dbc);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
 	    if ($Schedule->checkSchedule($operator) == 0) {
90 94
 		$schedule = $Schedule->fetchSchedule($operator);
91 95
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
92
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
96
+		    if ($globalDebug) {
97
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
98
+		    }
93 99
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
94 100
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
95 101
 		    // Should also check if route schedule = route from DB
@@ -98,7 +104,9 @@  discard block
 block discarded – undo
98 104
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
99 105
 			    if (trim($airport_icao) != '') {
100 106
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
101
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
107
+				if ($globalDebug) {
108
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
109
+				}
102 110
 			    }
103 111
 			}
104 112
 		    }
@@ -107,20 +115,30 @@  discard block
 block discarded – undo
107 115
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
108 116
 			    if (trim($airport_icao) != '') {
109 117
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
110
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
118
+				if ($globalDebug) {
119
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
120
+				}
111 121
 			    }
112 122
 			}
113 123
 		    }
114 124
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
115 125
 		}
116
-	    } else $scheduleexist = true;
117
-	} else $scheduleexist = true;
126
+	    } else {
127
+	    	$scheduleexist = true;
128
+	    }
129
+	} else {
130
+		$scheduleexist = true;
131
+	}
118 132
 	// close connection, at least one way will work ?
119 133
        if ($scheduleexist) {
120
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
134
+		if ($globalDebug) {
135
+			echo "-> get arrival/departure airport info for ".$ident."\n";
136
+		}
121 137
     		$sch = $Schedule->getSchedule($operator);
122 138
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
123
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
139
+		if ($this->all_flights[$id]['addedSpotter'] == 1) {
140
+			$Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
141
+		}
124 142
        }
125 143
 	$Spotter->db = null;
126 144
 	$Schedule->db = null;
@@ -140,14 +158,18 @@  discard block
 block discarded – undo
140 158
 
141 159
     public function checkAll() {
142 160
 	global $globalDebug, $globalNoImport;
143
-	if ($globalDebug) echo "Update last seen flights data...\n";
161
+	if ($globalDebug) {
162
+		echo "Update last seen flights data...\n";
163
+	}
144 164
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
145 165
 	    foreach ($this->all_flights as $key => $flight) {
146 166
 		if (isset($this->all_flights[$key]['id'])) {
147 167
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
148 168
     		    $Spotter = new Spotter($this->db);
149 169
         	    $real_arrival = $this->arrival($key);
150
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
170
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) {
171
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
172
+        	    }
151 173
         	}
152 174
 	    }
153 175
 	}
@@ -155,24 +177,32 @@  discard block
 block discarded – undo
155 177
 
156 178
     public function arrival($key) {
157 179
 	global $globalClosestMinDist, $globalDebug;
158
-	if ($globalDebug) echo 'Update arrival...'."\n";
180
+	if ($globalDebug) {
181
+		echo 'Update arrival...'."\n";
182
+	}
159 183
 	$Spotter = new Spotter($this->db);
160 184
         $airport_icao = '';
161 185
         $airport_time = '';
162
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
186
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
187
+        	$globalClosestMinDist = 50;
188
+        }
163 189
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
164 190
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
165 191
     	    if (isset($closestAirports[0])) {
166 192
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
167 193
         	    $airport_icao = $closestAirports[0]['icao'];
168 194
         	    $airport_time = $this->all_flights[$key]['datetime'];
169
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
195
+        	    if ($globalDebug) {
196
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
197
+        	    }
170 198
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
171 199
         	    foreach ($closestAirports as $airport) {
172 200
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
173 201
         		    $airport_icao = $airport['icao'];
174 202
         		    $airport_time = $this->all_flights[$key]['datetime'];
175
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
203
+        		    if ($globalDebug) {
204
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
205
+        		    }
176 206
         		    break;
177 207
         		}
178 208
         	    }
@@ -180,14 +210,20 @@  discard block
 block discarded – undo
180 210
         		$airport_icao = $closestAirports[0]['icao'];
181 211
         		$airport_time = $this->all_flights[$key]['datetime'];
182 212
         	} else {
183
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
213
+        		if ($globalDebug) {
214
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
215
+        		}
184 216
         	}
185 217
     	    } else {
186
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
218
+    		    if ($globalDebug) {
219
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
220
+    		    }
187 221
     	    }
188 222
 
189 223
         } else {
190
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
224
+        	if ($globalDebug) {
225
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
226
+        	}
191 227
         }
192 228
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
193 229
     }
@@ -197,7 +233,9 @@  discard block
 block discarded – undo
197 233
     public function del() {
198 234
 	global $globalDebug, $globalNoImport, $globalNoDB;
199 235
 	// Delete old infos
200
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
236
+	if ($globalDebug) {
237
+		echo 'Delete old values and update latest data...'."\n";
238
+	}
201 239
 	
202 240
 	foreach ($this->all_flights as $key => $flight) {
203 241
 		if (isset($flight['lastupdate'])) {
@@ -212,22 +250,30 @@  discard block
 block discarded – undo
212 250
 	global $globalDebug, $globalNoImport, $globalNoDB;
213 251
 	// Delete old infos
214 252
 	if (isset($this->all_flights[$key]['id'])) {
215
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
253
+		if ($globalDebug) {
254
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
255
+		}
216 256
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
217 257
 			$real_arrival = $this->arrival($key);
218 258
 			$Spotter = new Spotter($this->db);
219 259
 			$SpotterLive = new SpotterLive($this->db);
220 260
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
221 261
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
222
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
262
+				if ($globalDebug && $result != 'success') {
263
+					echo '!!! ERROR : '.$result."\n";
264
+				}
223 265
 				$this->all_flights[$key]['putinarchive'] = true;
224 266
 				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']);
225
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
267
+				if ($globalDebug && $result != 'success') {
268
+					echo '!!! ERROR : '.$result."\n";
269
+				}
226 270
 			}
227 271
 			$Spotter->db = null;
228 272
 			$SpotterLive->db = null;
229 273
 		}
230
-		if ($globalDebug) echo "\n";
274
+		if ($globalDebug) {
275
+			echo "\n";
276
+		}
231 277
 	}
232 278
 	unset($this->all_flights[$key]);
233 279
     }
@@ -235,9 +281,13 @@  discard block
 block discarded – undo
235 281
     public function add($line) {
236 282
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
237 283
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
238
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
239
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
240
-/*
284
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
285
+		$globalCoordMinChange = '0.01';
286
+	}
287
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
288
+		$globalAircraftMaxUpdate = 3000;
289
+	}
290
+	/*
241 291
 	$Spotter = new Spotter();
242 292
 	$dbc = $Spotter->db;
243 293
 	$SpotterLive = new SpotterLive($dbc);
@@ -259,19 +309,28 @@  discard block
 block discarded – undo
259 309
 	// SBS format is CSV format
260 310
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
261 311
 	    //print_r($line);
262
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
312
+	    if (isset($line['hex'])) {
313
+	    	$line['hex'] = strtoupper($line['hex']);
314
+	    }
263 315
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
264 316
 
265 317
 		// Increment message number
266 318
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
267 319
 		    $current_date = date('Y-m-d');
268
-		    if (isset($line['source_name'])) $source = $line['source_name'];
269
-		    else $source = '';
270
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
320
+		    if (isset($line['source_name'])) {
321
+		    	$source = $line['source_name'];
322
+		    } else {
323
+		    	$source = '';
324
+		    }
325
+		    if ($source == '' || $line['format_source'] == 'aprs') {
326
+		    	$source = $line['format_source'];
327
+		    }
271 328
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
272 329
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
273 330
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
274
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
331
+		    } else {
332
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
333
+		    }
275 334
 		}
276 335
 		
277 336
 		/*
@@ -287,23 +346,38 @@  discard block
 block discarded – undo
287 346
 		//$this->db = $dbc;
288 347
 
289 348
 		//$hex = trim($line['hex']);
290
-	        if (!isset($line['id'])) $id = trim($line['hex']);
291
-	        else $id = trim($line['id']);
349
+	        if (!isset($line['id'])) {
350
+	        	$id = trim($line['hex']);
351
+	        } else {
352
+	        	$id = trim($line['id']);
353
+	        }
292 354
 		
293 355
 		if (!isset($this->all_flights[$id])) {
294
-		    if ($globalDebug) echo 'New flight...'."\n";
356
+		    if ($globalDebug) {
357
+		    	echo 'New flight...'."\n";
358
+		    }
295 359
 		    $this->all_flights[$id] = array();
296 360
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
297 361
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '','coordinates' => 0));
298
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
362
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
363
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
364
+		    }
299 365
 		    if (!isset($line['id'])) {
300
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
301
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
366
+			if (!isset($globalDaemon)) {
367
+				$globalDaemon = TRUE;
368
+			}
369
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
302 370
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
303
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
371
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
372
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
373
+			}
304 374
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
305
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
306
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
375
+		     } else {
376
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
377
+		     }
378
+		    if ($globalAllFlights !== FALSE) {
379
+		    	$dataFound = true;
380
+		    }
307 381
 		}
308 382
 		if (isset($line['source_type']) && $line['source_type'] != '') {
309 383
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -325,12 +399,20 @@  discard block
 block discarded – undo
325 399
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
326 400
 			    }
327 401
 			    $Spotter->db = null;
328
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
329
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
402
+			    if ($globalDebugTimeElapsed) {
403
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
404
+			    }
405
+			    if ($aircraft_icao != '') {
406
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
407
+			    }
330 408
 			}
331 409
 		    }
332
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
333
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
410
+		    if ($globalAllFlights !== FALSE) {
411
+		    	$dataFound = true;
412
+		    }
413
+		    if ($globalDebug) {
414
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
415
+		    }
334 416
 		}
335 417
 	        if (isset($line['id']) && !isset($line['hex'])) {
336 418
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -339,7 +421,9 @@  discard block
 block discarded – undo
339 421
 			$icao = $line['aircraft_icao'];
340 422
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
341 423
 				$Spotter = new Spotter($this->db);
342
-				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
424
+				if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
425
+					$icao = $Spotter->aircraft_correct_icaotype[$icao];
426
+				}
343 427
 				$Spotter->db = null;
344 428
 			}
345 429
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
@@ -349,15 +433,24 @@  discard block
 block discarded – undo
349 433
 				$Spotter = new Spotter($this->db);
350 434
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
351 435
 				$Spotter->db = null;
352
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
436
+				if ($aircraft_icao != '') {
437
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
438
+				}
353 439
 			}
354 440
 		}
355 441
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
356
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
357
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
358
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
359
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
360
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
442
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
443
+				$aircraft_icao = 'GLID';
444
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
445
+				$aircraft_icao = 'UHEL';
446
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
447
+				$aircraft_icao = 'TOWPLANE';
448
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
449
+				$aircraft_icao = 'POWAIRC';
450
+			}
451
+			if (isset($aircraft_icao)) {
452
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
453
+			}
361 454
 		}
362 455
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
363 456
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -367,8 +460,11 @@  discard block
 block discarded – undo
367 460
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
368 461
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
369 462
 		    } else {
370
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
371
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
463
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
464
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
465
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
466
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
467
+				}
372 468
 				/*
373 469
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
374 470
 				print_r($this->all_flights[$id]);
@@ -377,16 +473,22 @@  discard block
 block discarded – undo
377 473
 				return '';
378 474
 		    }
379 475
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
380
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
476
+			if ($globalDebug) {
477
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
478
+			}
381 479
 			return '';
382 480
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
383
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
481
+			if ($globalDebug) {
482
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
483
+			}
384 484
 			return '';
385 485
 		} elseif (!isset($line['datetime'])) {
386 486
 			date_default_timezone_set('UTC');
387 487
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
388 488
 		} else {
389
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
489
+			if ($globalDebug) {
490
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
491
+			}
390 492
 			return '';
391 493
 		}
392 494
 
@@ -407,30 +509,48 @@  discard block
 block discarded – undo
407 509
 
408 510
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
409 511
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
410
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
512
+				if ($globalDebug) {
513
+					echo '---!!!! New ident, reset aircraft data...'."\n";
514
+				}
411 515
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
412 516
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
413
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
414
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
415
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
517
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
518
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
519
+				} elseif (isset($line['id'])) {
520
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
521
+				} elseif (isset($this->all_flights[$id]['ident'])) {
522
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
523
+				}
416 524
 			} else {
417 525
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
418 526
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
419 527
 				$timeelapsed = microtime(true);
420 528
             			$Spotter = new Spotter($this->db);
421 529
             			$fromsource = NULL;
422
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
423
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
424
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
425
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
426
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
530
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
531
+            				$fromsource = $globalAirlinesSource;
532
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
533
+            				$fromsource = 'vatsim';
534
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
535
+					$fromsource = 'ivao';
536
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
537
+					$fromsource = 'vatsim';
538
+				} elseif (isset($globalIVAO) && $globalIVAO) {
539
+					$fromsource = 'ivao';
540
+				}
427 541
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
428
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
542
+				if ($globalDebug && $result != 'success') {
543
+					echo '!!! ERROR : '.$result."\n";
544
+				}
429 545
 				$Spotter->db = null;
430
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
546
+				if ($globalDebugTimeElapsed) {
547
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
548
+				}
431 549
 			    }
432 550
 			}
433
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
551
+		    } else {
552
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
553
+		    }
434 554
 		    
435 555
 /*
436 556
 		    if (!isset($line['id'])) {
@@ -440,7 +560,9 @@  discard block
 block discarded – undo
440 560
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
441 561
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
442 562
   */
443
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
563
+		    if (!isset($this->all_flights[$id]['id'])) {
564
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
565
+		    }
444 566
 
445 567
 		    //$putinarchive = true;
446 568
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -458,7 +580,9 @@  discard block
 block discarded – undo
458 580
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
459 581
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
460 582
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
461
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
583
+				if ($globalDebugTimeElapsed) {
584
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
585
+				}
462 586
                         }
463 587
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
464 588
 			$timeelapsed = microtime(true);
@@ -472,7 +596,9 @@  discard block
 block discarded – undo
472 596
 				$Translation->db = null;
473 597
 			    }
474 598
 			    $Spotter->db = null;
475
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
599
+			    if ($globalDebugTimeElapsed) {
600
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
601
+			    }
476 602
                     	}
477 603
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
478 604
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -481,9 +607,13 @@  discard block
 block discarded – undo
481 607
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
482 608
 		    	    }
483 609
 			}
484
-			if (!isset($globalFork)) $globalFork = TRUE;
610
+			if (!isset($globalFork)) {
611
+				$globalFork = TRUE;
612
+			}
485 613
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
486
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
614
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
615
+					$this->get_Schedule($id,trim($line['ident']));
616
+				}
487 617
 			}
488 618
 		    }
489 619
 		}
@@ -501,9 +631,13 @@  discard block
 block discarded – undo
501 631
 			$speed = $speed*3.6;
502 632
 			if ($speed < 1000) {
503 633
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
504
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
634
+	  			if ($globalDebug) {
635
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
636
+	  			}
505 637
 	  		} else {
506
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
638
+	  			if ($globalDebug) {
639
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
640
+	  			}
507 641
 	  		}
508 642
 		    }
509 643
 		}
@@ -512,13 +646,21 @@  discard block
 block discarded – undo
512 646
 
513 647
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
514 648
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
515
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
649
+	    	    	if ($globalDebug) {
650
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
651
+	    	    	}
516 652
 	    	    	return false;
517 653
 	    	    }
518
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
519
-	    	    else unset($timediff);
520
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
521
-	    	    else unset($timediff_archive);
654
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
655
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
656
+	    	    } else {
657
+	    	    	unset($timediff);
658
+	    	    }
659
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
660
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
661
+	    	    } else {
662
+	    	    	unset($timediff_archive);
663
+	    	    }
522 664
 	    	    if ($this->tmd > 5
523 665
 	    	        || (isset($line['format_source']) 
524 666
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -554,21 +696,32 @@  discard block
 block discarded – undo
554 696
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
555 697
 				$this->all_flights[$id]['putinarchive'] = true;
556 698
 				if ($this->tmd > 5 && $this->all_flights[$id]['putinarchive'] == true) {
557
-					if ($globalDebug) echo "\n".' Update Initial data ! '."\n";
699
+					if ($globalDebug) {
700
+						echo "\n".' Update Initial data ! '."\n";
701
+					}
558 702
 					$updateinitial = true;
559 703
 				}
560 704
 				$this->tmd = 0;
561 705
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
562
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
706
+				    if ($globalDebug) {
707
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
708
+				    }
563 709
 				    $timeelapsed = microtime(true);
564 710
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
565 711
 					$Spotter = new Spotter($this->db);
566 712
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
567
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
568
-					else $this->all_flights[$id]['over_country'] = '';
713
+					if (!empty($all_country)) {
714
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
715
+					} else {
716
+						$this->all_flights[$id]['over_country'] = '';
717
+					}
569 718
 					$Spotter->db = null;
570
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
571
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
719
+					if ($globalDebugTimeElapsed) {
720
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
721
+					}
722
+					if ($globalDebug) {
723
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
724
+					}
572 725
 				    }
573 726
 				}
574 727
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -614,7 +767,9 @@  discard block
 block discarded – undo
614 767
 			    */
615 768
 			}
616 769
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
617
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
770
+			    if ($line['longitude'] > 180) {
771
+			    	$line['longitude'] = $line['longitude'] - 360;
772
+			    }
618 773
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
619 774
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
620 775
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -643,7 +798,9 @@  discard block
 block discarded – undo
643 798
 			    */
644 799
 			}
645 800
 			if ($globalDaemon === TRUE && isset($updateinitial) && $updateinitial && $this->all_flights[$id]['addedSpotter'] == 1) {
646
-			    if ($globalDebug) echo "\n".'>>> Update initial data !'."\n";
801
+			    if ($globalDebug) {
802
+			    	echo "\n".'>>> Update initial data !'."\n";
803
+			    }
647 804
 			    unset($updateinitial);
648 805
 			    $SpotterArchive = new SpotterArchive();
649 806
 			    $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']);
@@ -661,7 +818,9 @@  discard block
 block discarded – undo
661 818
 		    }
662 819
 		}
663 820
 		if (isset($line['last_update']) && $line['last_update'] != '') {
664
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
821
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
822
+		    	$dataFound = true;
823
+		    }
665 824
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
666 825
 		}
667 826
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -683,35 +842,53 @@  discard block
 block discarded – undo
683 842
 			// Here we force archive of flight because after ground it's a new one (or should be)
684 843
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
685 844
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
686
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
687
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
688
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
845
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
846
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
847
+			} elseif (isset($line['id'])) {
848
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
849
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
850
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
851
+			}
852
+		    }
853
+		    if ($line['ground'] != 1) {
854
+		    	$line['ground'] = 0;
689 855
 		    }
690
-		    if ($line['ground'] != 1) $line['ground'] = 0;
691 856
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
692 857
 		    //$dataFound = true;
693 858
 		}
694 859
 		if (isset($line['squawk']) && $line['squawk'] != '') {
695 860
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
696
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
861
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
862
+			    	$this->all_flights[$id]['putinarchive'] = true;
863
+			    }
697 864
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
698 865
 			    $highlight = '';
699
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
700
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
701
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
866
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
867
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
868
+			    }
869
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
870
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
871
+			    }
872
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
873
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
874
+			    }
702 875
 			    if ($highlight != '') {
703 876
 				$timeelapsed = microtime(true);
704 877
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
705 878
 				    $Spotter = new Spotter($this->db);
706 879
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
707 880
 				    $Spotter->db = null;
708
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
881
+				    if ($globalDebugTimeElapsed) {
882
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
883
+				    }
709 884
 				}
710 885
 				//$putinarchive = true;
711 886
 				//$highlight = '';
712 887
 			    }
713 888
 			    
714
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
889
+		    } else {
890
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
891
+		    }
715 892
 		    //$dataFound = true;
716 893
 		}
717 894
 
@@ -724,19 +901,27 @@  discard block
 block discarded – undo
724 901
 				}
725 902
 			}
726 903
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
727
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
904
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
905
+				$this->all_flights[$id]['putinarchive'] = true;
906
+			}
728 907
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
729 908
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
730 909
 			//$dataFound = true;
731 910
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
732 911
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
733 912
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
734
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
913
+				if ($globalDebug) {
914
+					echo '--- Reset because of altitude'."\n";
915
+				}
735 916
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
736 917
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
737
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
738
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
739
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
918
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
919
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
920
+				} elseif (isset($line['id'])) {
921
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
922
+				} elseif (isset($this->all_flights[$id]['ident'])) {
923
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
924
+				}
740 925
 			}
741 926
 		    }
742 927
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -747,22 +932,32 @@  discard block
 block discarded – undo
747 932
 		}
748 933
 		
749 934
 		if (isset($line['heading']) && $line['heading'] != '') {
750
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
935
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
936
+		    	$this->all_flights[$id]['putinarchive'] = true;
937
+		    }
751 938
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
752 939
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
753 940
 		    //$dataFound = true;
754 941
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
755 942
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
756 943
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
757
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
758
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
944
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
945
+		    	$this->all_flights[$id]['putinarchive'] = true;
946
+		    }
947
+  		    if ($globalDebug) {
948
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
949
+  		    }
759 950
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
760 951
   		    // If not enough messages and ACARS set heading to 0
761 952
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
762 953
   		}
763
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
764
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
765
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
954
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
955
+			$dataFound = false;
956
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
957
+			$dataFound = false;
958
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) {
959
+			$dataFound = false;
960
+		}
766 961
 
767 962
 //		print_r($this->all_flights[$id]);
768 963
 		//gets the callsign from the last hour
@@ -779,23 +974,38 @@  discard block
 block discarded – undo
779 974
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
780 975
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
781 976
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
782
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
977
+				    if ($globalDebug) {
978
+				    	echo "Check if aircraft is already in DB...";
979
+				    }
783 980
 				    $timeelapsed = microtime(true);
784 981
 				    $SpotterLive = new SpotterLive($this->db);
785 982
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
786 983
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
787
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
984
+					if ($globalDebugTimeElapsed) {
985
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
986
+					}
788 987
 				    } elseif (isset($line['id'])) {
789 988
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
790
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
989
+					if ($globalDebugTimeElapsed) {
990
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
991
+					}
791 992
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
792 993
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
793
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
794
-				    } else $recent_ident = '';
994
+					if ($globalDebugTimeElapsed) {
995
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
996
+					}
997
+				    } else {
998
+				    	$recent_ident = '';
999
+				    }
795 1000
 				    $SpotterLive->db=null;
796
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
797
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
798
-				} else $recent_ident = '';
1001
+				    if ($globalDebug && $recent_ident == '') {
1002
+				    	echo " Not in DB.\n";
1003
+				    } elseif ($globalDebug && $recent_ident != '') {
1004
+				    	echo " Already in DB.\n";
1005
+				    }
1006
+				} else {
1007
+					$recent_ident = '';
1008
+				}
799 1009
 			    } else {
800 1010
 				$recent_ident = '';
801 1011
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -803,7 +1013,9 @@  discard block
 block discarded – undo
803 1013
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
804 1014
 			    if($recent_ident == "")
805 1015
 			    {
806
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
1016
+				if ($globalDebug) {
1017
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
1018
+				}
807 1019
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
808 1020
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
809 1021
 				//adds the spotter data for the archive
@@ -847,10 +1059,18 @@  discard block
 block discarded – undo
847 1059
 				
848 1060
 				if (!$ignoreImport) {
849 1061
 				    $highlight = '';
850
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
851
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
852
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
853
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1062
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1063
+				    	$highlight = 'Squawk 7500 : Hijack';
1064
+				    }
1065
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1066
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1067
+				    }
1068
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1069
+				    	$highlight = 'Squawk 7700 : Emergency';
1070
+				    }
1071
+				    if (!isset($this->all_flights[$id]['id'])) {
1072
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1073
+				    }
854 1074
 				    $timeelapsed = microtime(true);
855 1075
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
856 1076
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -858,28 +1078,43 @@  discard block
 block discarded – undo
858 1078
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
859 1079
 					    $Spotter->db = null;
860 1080
 					    if ($globalDebug) {
861
-						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
862
-						else echo 'Success';
1081
+						if (isset($result['error'])) {
1082
+							echo 'Error: '.$result['error']."\n";
1083
+						} else {
1084
+							echo 'Success';
1085
+						}
863 1086
 					    }
864 1087
 					    if (count($result) > 1) {
865 1088
 					    // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
866
-						if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
867
-						if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration'];
1089
+						if ($this->all_flights[$id]['aircraft_icao'] == '') {
1090
+							$this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
1091
+						}
1092
+						if ($this->all_flights[$id]['registration'] == '') {
1093
+							$this->all_flights[$id]['registration'] = $result[':registration'];
1094
+						}
868 1095
 					    }
869 1096
 					}
870 1097
 				    }
871
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1098
+				    if ($globalDebugTimeElapsed) {
1099
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1100
+				    }
872 1101
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
873 1102
 
874 1103
 				    // Add source stat in DB
875 1104
 				    $Stats = new Stats($this->db);
876 1105
 				    if (!empty($this->stats)) {
877
-					if ($globalDebug) echo 'Add source stats : ';
1106
+					if ($globalDebug) {
1107
+						echo 'Add source stats : ';
1108
+					}
878 1109
 				        foreach($this->stats as $date => $data) {
879 1110
 					    foreach($data as $source => $sourced) {
880 1111
 					        //print_r($sourced);
881
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
882
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1112
+				    	        if (isset($sourced['polar'])) {
1113
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1114
+				    	        }
1115
+				    	        if (isset($sourced['hist'])) {
1116
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1117
+				    	        }
883 1118
 				    		if (isset($sourced['msg'])) {
884 1119
 				    		    if (time() - $sourced['msg']['date'] > 10) {
885 1120
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -892,13 +1127,17 @@  discard block
 block discarded – undo
892 1127
 			    			unset($this->stats[$date]);
893 1128
 			    		    }
894 1129
 				    	}
895
-				    	if ($globalDebug) echo 'Done'."\n";
1130
+				    	if ($globalDebug) {
1131
+				    		echo 'Done'."\n";
1132
+				    	}
896 1133
 
897 1134
 				    }
898 1135
 				    $Stats->db = null;
899 1136
 				    }
900 1137
 				    $this->del();
901
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1138
+				} elseif ($globalDebug) {
1139
+					echo 'Ignore data'."\n";
1140
+				}
902 1141
 				//$ignoreImport = false;
903 1142
 				$this->all_flights[$id]['addedSpotter'] = 1;
904 1143
 				//print_r($this->all_flights[$id]);
@@ -915,7 +1154,9 @@  discard block
 block discarded – undo
915 1154
 			*/
916 1155
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
917 1156
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
918
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1157
+				    if ($globalDebug) {
1158
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1159
+				    }
919 1160
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
920 1161
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
921 1162
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -924,7 +1165,9 @@  discard block
 block discarded – undo
924 1165
 					    $SpotterLive->db=null;
925 1166
 					}
926 1167
 				    }
927
-				    if ($globalDebug) echo " Done\n";
1168
+				    if ($globalDebug) {
1169
+				    	echo " Done\n";
1170
+				    }
928 1171
 				    $this->last_delete = time();
929 1172
 				}
930 1173
 			    } else {
@@ -951,11 +1194,17 @@  discard block
 block discarded – undo
951 1194
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
952 1195
 		    if ($globalDebug) {
953 1196
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
954
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
955
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1197
+				if (isset($this->all_flights[$id]['source_name'])) {
1198
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
1199
+				} else {
1200
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1201
+				}
956 1202
 			} else {
957
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
958
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1203
+				if (isset($this->all_flights[$id]['source_name'])) {
1204
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1205
+				} else {
1206
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1207
+				}
959 1208
 			}
960 1209
 		    }
961 1210
 		    $ignoreImport = false;
@@ -1001,23 +1250,31 @@  discard block
 block discarded – undo
1001 1250
 
1002 1251
 		    if (!$ignoreImport) {
1003 1252
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
1004
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1253
+				if (!isset($this->all_flights[$id]['id'])) {
1254
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1255
+				}
1005 1256
 				$timeelapsed = microtime(true);
1006 1257
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
1007 1258
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1008
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1259
+					if ($globalDebug) {
1260
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1261
+					}
1009 1262
 					$SpotterLive = new SpotterLive($this->db);
1010 1263
 					//var_dump($this->all_flights[$id]);
1011 1264
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
1012 1265
 					$SpotterLive->db = null;
1013
-					if ($globalDebug) echo $result."\n";
1266
+					if ($globalDebug) {
1267
+						echo $result."\n";
1268
+					}
1014 1269
 				    }
1015 1270
 				}
1016 1271
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
1017 1272
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
1018 1273
 				}
1019 1274
 				$this->all_flights[$id]['putinarchive'] = false;
1020
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1275
+				if ($globalDebugTimeElapsed) {
1276
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1277
+				}
1021 1278
 
1022 1279
 				// Put statistics in $this->stats variable
1023 1280
 				//if ($line['format_source'] != 'aprs') {
@@ -1025,7 +1282,9 @@  discard block
 block discarded – undo
1025 1282
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1026 1283
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1027 1284
 					$source = $this->all_flights[$id]['source_name'];
1028
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1285
+					if ($source == '') {
1286
+						$source = $this->all_flights[$id]['format_source'];
1287
+					}
1029 1288
 					if (!isset($this->source_location[$source])) {
1030 1289
 						$Location = new Source($this->db);
1031 1290
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -1046,7 +1305,9 @@  discard block
 block discarded – undo
1046 1305
 					$stats_heading = round($stats_heading/22.5);
1047 1306
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1048 1307
 					$current_date = date('Y-m-d');
1049
-					if ($stats_heading == 16) $stats_heading = 0;
1308
+					if ($stats_heading == 16) {
1309
+						$stats_heading = 0;
1310
+					}
1050 1311
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1051 1312
 						for ($i=0;$i<=15;$i++) {
1052 1313
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1064,7 +1325,9 @@  discard block
 block discarded – undo
1064 1325
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1065 1326
 						    end($this->stats[$current_date][$source]['hist']);
1066 1327
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1067
-						} else $mini = 0;
1328
+						} else {
1329
+							$mini = 0;
1330
+						}
1068 1331
 						for ($i=$mini;$i<=$distance;$i+=10) {
1069 1332
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1070 1333
 						}
@@ -1076,19 +1339,27 @@  discard block
 block discarded – undo
1076 1339
 				}
1077 1340
 
1078 1341
 				$this->all_flights[$id]['lastupdate'] = time();
1079
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1342
+				if ($this->all_flights[$id]['putinarchive']) {
1343
+					$send = true;
1344
+				}
1080 1345
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1081
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1346
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1347
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1348
+			}
1082 1349
 			//$this->del();
1083 1350
 			
1084 1351
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1085 1352
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1086
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1353
+				if ($globalDebug) {
1354
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1355
+				}
1087 1356
 				$SpotterLive = new SpotterLive($this->db);
1088 1357
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1089 1358
 				$SpotterLive->db = null;
1090 1359
 				//SpotterLive->deleteLiveSpotterData();
1091
-				if ($globalDebug) echo " Done\n";
1360
+				if ($globalDebug) {
1361
+					echo " Done\n";
1362
+				}
1092 1363
 				$this->last_delete_hourly = time();
1093 1364
 			    } else {
1094 1365
 				$this->del();
@@ -1100,7 +1371,9 @@  discard block
 block discarded – undo
1100 1371
 		    //$ignoreImport = false;
1101 1372
 		}
1102 1373
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1103
-		if ($send) return $this->all_flights[$id];
1374
+		if ($send) {
1375
+			return $this->all_flights[$id];
1376
+		}
1104 1377
 	    }
1105 1378
 	}
1106 1379
     }
Please login to merge, or discard this patch.
require/class.SpotterLive.php 3 patches
Indentation   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	}
140 140
 
141 141
 	/**
142
-	* Gets all the spotter information based on the latest data entry
143
-	*
144
-	* @return Array the spotter information
145
-	*
146
-	*/
142
+	 * Gets all the spotter information based on the latest data entry
143
+	 *
144
+	 * @return Array the spotter information
145
+	 *
146
+	 */
147 147
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
148 148
 	{
149 149
 		global $globalDBdriver, $globalLiveInterval;
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
 	}
187 187
 
188 188
 	/**
189
-	* Gets Minimal Live Spotter data
190
-	*
191
-	* @return Array the spotter information
192
-	*
193
-	*/
189
+	 * Gets Minimal Live Spotter data
190
+	 *
191
+	 * @return Array the spotter information
192
+	 *
193
+	 */
194 194
 	public function getMinLiveSpotterData($limit = 0,$filter = array())
195 195
 	{
196 196
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 	}
243 243
 
244 244
 	/**
245
-	* Gets Minimal Live Spotter data since xx seconds
246
-	*
247
-	* @return Array the spotter information
248
-	*
249
-	*/
245
+	 * Gets Minimal Live Spotter data since xx seconds
246
+	 *
247
+	 * @return Array the spotter information
248
+	 *
249
+	 */
250 250
 	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = 0, $id = '')
251 251
 	{
252 252
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
@@ -349,11 +349,11 @@  discard block
 block discarded – undo
349 349
 	}
350 350
 
351 351
 	/**
352
-	* Gets Minimal Live Spotter data since xx seconds
353
-	*
354
-	* @return Array the spotter information
355
-	*
356
-	*/
352
+	 * Gets Minimal Live Spotter data since xx seconds
353
+	 *
354
+	 * @return Array the spotter information
355
+	 *
356
+	 */
357 357
 	public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = 0)
358 358
 	{
359 359
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
 	}
420 420
 
421 421
 	/**
422
-	* Gets number of latest data entry
423
-	*
424
-	* @return String number of entry
425
-	*
426
-	*/
422
+	 * Gets number of latest data entry
423
+	 *
424
+	 * @return String number of entry
425
+	 *
426
+	 */
427 427
 	public function getLiveSpotterCount($filter = array())
428 428
 	{
429 429
 		global $globalDBdriver, $globalLiveInterval;
@@ -450,11 +450,11 @@  discard block
 block discarded – undo
450 450
 	}
451 451
 
452 452
 	/**
453
-	* Gets all the spotter information based on the latest data entry and coord
454
-	*
455
-	* @return Array the spotter information
456
-	*
457
-	*/
453
+	 * Gets all the spotter information based on the latest data entry and coord
454
+	 *
455
+	 * @return Array the spotter information
456
+	 *
457
+	 */
458 458
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
459 459
 	{
460 460
 		global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit;
@@ -482,11 +482,11 @@  discard block
 block discarded – undo
482 482
 	}
483 483
 
484 484
 	/**
485
-	* Gets all the spotter information based on the latest data entry and coord
486
-	*
487
-	* @return Array the spotter information
488
-	*
489
-	*/
485
+	 * Gets all the spotter information based on the latest data entry and coord
486
+	 *
487
+	 * @return Array the spotter information
488
+	 *
489
+	 */
490 490
 	public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array())
491 491
 	{
492 492
 		global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit;
@@ -577,11 +577,11 @@  discard block
 block discarded – undo
577 577
 	}
578 578
 
579 579
 	/**
580
-	* Gets all the spotter information based on a user's latitude and longitude
581
-	*
582
-	* @return Array the spotter information
583
-	*
584
-	*/
580
+	 * Gets all the spotter information based on a user's latitude and longitude
581
+	 *
582
+	 * @return Array the spotter information
583
+	 *
584
+	 */
585 585
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
586 586
 	{
587 587
 		$Spotter = new Spotter($this->db);
@@ -591,98 +591,98 @@  discard block
 block discarded – undo
591 591
 				return false;
592 592
 			}
593 593
 		}
594
-        if ($lng != '')
595
-                {
596
-                        if (!is_numeric($lng))
597
-                        {
598
-                                return false;
599
-                        }
600
-                }
601
-
602
-                if ($radius != '')
603
-                {
604
-                        if (!is_numeric($radius))
605
-                        {
606
-                                return false;
607
-                        }
608
-                }
594
+		if ($lng != '')
595
+				{
596
+						if (!is_numeric($lng))
597
+						{
598
+								return false;
599
+						}
600
+				}
601
+
602
+				if ($radius != '')
603
+				{
604
+						if (!is_numeric($radius))
605
+						{
606
+								return false;
607
+						}
608
+				}
609 609
 		$additional_query = '';
610
-        if ($interval != '')
611
-                {
612
-                        if (!is_string($interval))
613
-                        {
614
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
615
-			        return false;
616
-                        } else {
617
-                if ($interval == '1m')
618
-                {
619
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
620
-                } else if ($interval == '15m'){
621
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
622
-                } 
623
-            }
624
-                } else {
625
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
626
-        }
627
-
628
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
610
+		if ($interval != '')
611
+				{
612
+						if (!is_string($interval))
613
+						{
614
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
615
+					return false;
616
+						} else {
617
+				if ($interval == '1m')
618
+				{
619
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
620
+				} else if ($interval == '15m'){
621
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
622
+				} 
623
+			}
624
+				} else {
625
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
626
+		}
627
+
628
+				$query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
629 629
                    WHERE spotter_live.latitude <> '' 
630 630
                                    AND spotter_live.longitude <> '' 
631 631
                    ".$additional_query."
632 632
                    HAVING distance < :radius  
633 633
                                    ORDER BY distance";
634 634
 
635
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
635
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
636 636
 
637
-                return $spotter_array;
638
-        }
637
+				return $spotter_array;
638
+		}
639 639
 
640 640
     
641
-        /**
642
-	* Gets all the spotter information based on a particular callsign
643
-	*
644
-	* @return Array the spotter information
645
-	*
646
-	*/
641
+		/**
642
+		 * Gets all the spotter information based on a particular callsign
643
+		 *
644
+		 * @return Array the spotter information
645
+		 *
646
+		 */
647 647
 	public function getLastLiveSpotterDataByIdent($ident)
648 648
 	{
649 649
 		$Spotter = new Spotter($this->db);
650 650
 		date_default_timezone_set('UTC');
651 651
 
652 652
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
653
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
653
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
654 654
 
655 655
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
656 656
 
657 657
 		return $spotter_array;
658 658
 	}
659 659
 
660
-        /**
661
-	* Gets all the spotter information based on a particular callsign
662
-	*
663
-	* @return Array the spotter information
664
-	*
665
-	*/
660
+		/**
661
+		 * Gets all the spotter information based on a particular callsign
662
+		 *
663
+		 * @return Array the spotter information
664
+		 *
665
+		 */
666 666
 	public function getDateLiveSpotterDataByIdent($ident,$date)
667 667
 	{
668 668
 		$Spotter = new Spotter($this->db);
669 669
 		date_default_timezone_set('UTC');
670 670
 
671 671
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
672
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
672
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
673 673
 
674
-                $date = date('c',$date);
674
+				$date = date('c',$date);
675 675
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
676 676
 
677 677
 		return $spotter_array;
678 678
 	}
679 679
 
680
-        /**
681
-	* Gets last spotter information based on a particular callsign
682
-	*
683
-	* @return Array the spotter information
684
-	*
685
-	*/
680
+		/**
681
+		 * Gets last spotter information based on a particular callsign
682
+		 *
683
+		 * @return Array the spotter information
684
+		 *
685
+		 */
686 686
 	public function getLastLiveSpotterDataById($id)
687 687
 	{
688 688
 		$Spotter = new Spotter($this->db);
@@ -693,12 +693,12 @@  discard block
 block discarded – undo
693 693
 		return $spotter_array;
694 694
 	}
695 695
 
696
-        /**
697
-	* Gets last spotter information based on a particular callsign
698
-	*
699
-	* @return Array the spotter information
700
-	*
701
-	*/
696
+		/**
697
+		 * Gets last spotter information based on a particular callsign
698
+		 *
699
+		 * @return Array the spotter information
700
+		 *
701
+		 */
702 702
 	public function getDateLiveSpotterDataById($id,$date)
703 703
 	{
704 704
 		$Spotter = new Spotter($this->db);
@@ -711,21 +711,21 @@  discard block
 block discarded – undo
711 711
 		return $spotter_array;
712 712
 	}
713 713
 
714
-        /**
715
-	* Gets altitude information based on a particular callsign
716
-	*
717
-	* @return Array the spotter information
718
-	*
719
-	*/
714
+		/**
715
+		 * Gets altitude information based on a particular callsign
716
+		 *
717
+		 * @return Array the spotter information
718
+		 *
719
+		 */
720 720
 	public function getAltitudeLiveSpotterDataByIdent($ident)
721 721
 	{
722 722
 
723 723
 		date_default_timezone_set('UTC');
724 724
 
725 725
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
726
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
726
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
727 727
 
728
-    		try {
728
+			try {
729 729
 			
730 730
 			$sth = $this->db->prepare($query);
731 731
 			$sth->execute(array(':ident' => $ident));
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		return $spotter_array;
739 739
 	}
740 740
 
741
-        /**
742
-	* Gets all the spotter information based on a particular id
743
-	*
744
-	* @return Array the spotter information
745
-	*
746
-	*/
741
+		/**
742
+		 * Gets all the spotter information based on a particular id
743
+		 *
744
+		 * @return Array the spotter information
745
+		 *
746
+		 */
747 747
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
748 748
 	{
749 749
 		global $globalDBdriver, $globalLiveInterval;
@@ -771,18 +771,18 @@  discard block
 block discarded – undo
771 771
 		return $spotter_array;
772 772
 	}
773 773
 
774
-        /**
775
-	* Gets all the spotter information based on a particular ident
776
-	*
777
-	* @return Array the spotter information
778
-	*
779
-	*/
774
+		/**
775
+		 * Gets all the spotter information based on a particular ident
776
+		 *
777
+		 * @return Array the spotter information
778
+		 *
779
+		 */
780 780
 	public function getAllLiveSpotterDataByIdent($ident)
781 781
 	{
782 782
 		date_default_timezone_set('UTC');
783 783
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
784 784
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
785
-    		try {
785
+			try {
786 786
 			
787 787
 			$sth = $this->db->prepare($query);
788 788
 			$sth->execute(array(':ident' => $ident));
@@ -796,23 +796,23 @@  discard block
 block discarded – undo
796 796
 
797 797
 
798 798
 	/**
799
-	* Deletes all info in the table
800
-	*
801
-	* @return String success or false
802
-	*
803
-	*/
799
+	 * Deletes all info in the table
800
+	 *
801
+	 * @return String success or false
802
+	 *
803
+	 */
804 804
 	public function deleteLiveSpotterData()
805 805
 	{
806 806
 		global $globalDBdriver;
807 807
 		if ($globalDBdriver == 'mysql') {
808 808
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
809 809
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
810
-            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
810
+					//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
811 811
 		} else {
812 812
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
813 813
 		}
814 814
         
815
-    		try {
815
+			try {
816 816
 			
817 817
 			$sth = $this->db->prepare($query);
818 818
 			$sth->execute();
@@ -824,18 +824,18 @@  discard block
 block discarded – undo
824 824
 	}
825 825
 
826 826
 	/**
827
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
828
-	*
829
-	* @return String success or false
830
-	*
831
-	*/
827
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
828
+	 *
829
+	 * @return String success or false
830
+	 *
831
+	 */
832 832
 	public function deleteLiveSpotterDataNotUpdated()
833 833
 	{
834 834
 		global $globalDBdriver, $globalDebug;
835 835
 		if ($globalDBdriver == 'mysql') {
836 836
 			//$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0';
837
-    			$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
838
-    			try {
837
+				$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
838
+				try {
839 839
 				
840 840
 				$sth = $this->db->prepare($query);
841 841
 				$sth->execute();
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
 				return "error";
844 844
 			}
845 845
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
846
-                        $i = 0;
847
-                        $j =0;
846
+						$i = 0;
847
+						$j =0;
848 848
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
849 849
 			foreach($all as $row)
850 850
 			{
@@ -852,20 +852,20 @@  discard block
 block discarded – undo
852 852
 				$j++;
853 853
 				if ($j == 30) {
854 854
 					if ($globalDebug) echo ".";
855
-				    	try {
855
+						try {
856 856
 						
857 857
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
858 858
 						$sth->execute();
859 859
 					} catch(PDOException $e) {
860 860
 						return "error";
861 861
 					}
862
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
863
-                                	$j = 0;
862
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
863
+									$j = 0;
864 864
 				}
865 865
 				$query_delete .= "'".$row['flightaware_id']."',";
866 866
 			}
867 867
 			if ($i > 0) {
868
-    				try {
868
+					try {
869 869
 					
870 870
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
871 871
 					$sth->execute();
@@ -876,9 +876,9 @@  discard block
 block discarded – undo
876 876
 			return "success";
877 877
 		} elseif ($globalDBdriver == 'pgsql') {
878 878
 			//$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0";
879
-    			//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
880
-    			$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
881
-    			try {
879
+				//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
880
+				$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
881
+				try {
882 882
 				
883 883
 				$sth = $this->db->prepare($query);
884 884
 				$sth->execute();
@@ -922,17 +922,17 @@  discard block
 block discarded – undo
922 922
 	}
923 923
 
924 924
 	/**
925
-	* Deletes all info in the table for an ident
926
-	*
927
-	* @return String success or false
928
-	*
929
-	*/
925
+	 * Deletes all info in the table for an ident
926
+	 *
927
+	 * @return String success or false
928
+	 *
929
+	 */
930 930
 	public function deleteLiveSpotterDataByIdent($ident)
931 931
 	{
932 932
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
933 933
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
934 934
         
935
-    		try {
935
+			try {
936 936
 			
937 937
 			$sth = $this->db->prepare($query);
938 938
 			$sth->execute(array(':ident' => $ident));
@@ -944,17 +944,17 @@  discard block
 block discarded – undo
944 944
 	}
945 945
 
946 946
 	/**
947
-	* Deletes all info in the table for an id
948
-	*
949
-	* @return String success or false
950
-	*
951
-	*/
947
+	 * Deletes all info in the table for an id
948
+	 *
949
+	 * @return String success or false
950
+	 *
951
+	 */
952 952
 	public function deleteLiveSpotterDataById($id)
953 953
 	{
954 954
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
955 955
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
956 956
         
957
-    		try {
957
+			try {
958 958
 			
959 959
 			$sth = $this->db->prepare($query);
960 960
 			$sth->execute(array(':id' => $id));
@@ -967,11 +967,11 @@  discard block
 block discarded – undo
967 967
 
968 968
 
969 969
 	/**
970
-	* Gets the aircraft ident within the last hour
971
-	*
972
-	* @return String the ident
973
-	*
974
-	*/
970
+	 * Gets the aircraft ident within the last hour
971
+	 *
972
+	 * @return String the ident
973
+	 *
974
+	 */
975 975
 	public function getIdentFromLastHour($ident)
976 976
 	{
977 977
 		global $globalDBdriver, $globalTimezone;
@@ -997,14 +997,14 @@  discard block
 block discarded – undo
997 997
 			$ident_result = $row['ident'];
998 998
 		}
999 999
 		return $ident_result;
1000
-        }
1000
+		}
1001 1001
 
1002 1002
 	/**
1003
-	* Check recent aircraft
1004
-	*
1005
-	* @return String the ident
1006
-	*
1007
-	*/
1003
+	 * Check recent aircraft
1004
+	 *
1005
+	 * @return String the ident
1006
+	 *
1007
+	 */
1008 1008
 	public function checkIdentRecent($ident)
1009 1009
 	{
1010 1010
 		global $globalDBdriver, $globalTimezone;
@@ -1030,14 +1030,14 @@  discard block
 block discarded – undo
1030 1030
 			$ident_result = $row['flightaware_id'];
1031 1031
 		}
1032 1032
 		return $ident_result;
1033
-        }
1033
+		}
1034 1034
 
1035 1035
 	/**
1036
-	* Check recent aircraft by id
1037
-	*
1038
-	* @return String the ident
1039
-	*
1040
-	*/
1036
+	 * Check recent aircraft by id
1037
+	 *
1038
+	 * @return String the ident
1039
+	 *
1040
+	 */
1041 1041
 	public function checkIdRecent($id)
1042 1042
 	{
1043 1043
 		global $globalDBdriver, $globalTimezone;
@@ -1063,14 +1063,14 @@  discard block
 block discarded – undo
1063 1063
 			$ident_result = $row['flightaware_id'];
1064 1064
 		}
1065 1065
 		return $ident_result;
1066
-        }
1066
+		}
1067 1067
 
1068 1068
 	/**
1069
-	* Check recent aircraft by ModeS
1070
-	*
1071
-	* @return String the ModeS
1072
-	*
1073
-	*/
1069
+	 * Check recent aircraft by ModeS
1070
+	 *
1071
+	 * @return String the ModeS
1072
+	 *
1073
+	 */
1074 1074
 	public function checkModeSRecent($modes)
1075 1075
 	{
1076 1076
 		global $globalDBdriver, $globalTimezone;
@@ -1100,11 +1100,11 @@  discard block
 block discarded – undo
1100 1100
 	}
1101 1101
 
1102 1102
 	/**
1103
-	* Gets the aircraft data from the last 20 seconds
1104
-	*
1105
-	* @return Array the spotter data
1106
-	*
1107
-	*/
1103
+	 * Gets the aircraft data from the last 20 seconds
1104
+	 *
1105
+	 * @return Array the spotter data
1106
+	 *
1107
+	 */
1108 1108
 	public function getRealTimeData($q = '')
1109 1109
 	{
1110 1110
 		global $globalDBdriver;
@@ -1146,16 +1146,16 @@  discard block
 block discarded – undo
1146 1146
 	}
1147 1147
 
1148 1148
 	/**
1149
-	* Adds a new spotter data
1150
-	*
1151
-	* @param String $flightaware_id the ID from flightaware
1152
-	* @param String $ident the flight ident
1153
-	* @param String $aircraft_icao the aircraft type
1154
-	* @param String $departure_airport_icao the departure airport
1155
-	* @param String $arrival_airport_icao the arrival airport
1156
-	* @return String success or false
1157
-	*
1158
-	*/
1149
+	 * Adds a new spotter data
1150
+	 *
1151
+	 * @param String $flightaware_id the ID from flightaware
1152
+	 * @param String $ident the flight ident
1153
+	 * @param String $aircraft_icao the aircraft type
1154
+	 * @param String $departure_airport_icao the departure airport
1155
+	 * @param String $arrival_airport_icao the arrival airport
1156
+	 * @return String success or false
1157
+	 *
1158
+	 */
1159 1159
 	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
1160 1160
 	{
1161 1161
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1298,10 +1298,10 @@  discard block
 block discarded – undo
1298 1298
 		$arrival_airport_country = '';
1299 1299
 		
1300 1300
             	
1301
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1302
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1303
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1304
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1301
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1302
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1303
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1304
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1305 1305
 		
1306 1306
 		$query = '';
1307 1307
 		if ($globalArchive) {
@@ -1322,10 +1322,10 @@  discard block
 block discarded – undo
1322 1322
 			return "error : ".$e->getMessage();
1323 1323
 		}
1324 1324
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1325
-		    if ($globalDebug) echo '(Add to Spotter archive : ';
1326
-		    $SpotterArchive = new SpotterArchive($this->db);
1327
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1328
-		    if ($globalDebug) echo $result.')';
1325
+			if ($globalDebug) echo '(Add to Spotter archive : ';
1326
+			$SpotterArchive = new SpotterArchive($this->db);
1327
+			$result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1328
+			if ($globalDebug) echo $result.')';
1329 1329
 		} elseif ($globalDebug && $putinarchive !== true) {
1330 1330
 			echo '(Not adding to archive)';
1331 1331
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -17,62 +17,62 @@  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['airlines']) && !empty($flt['airlines'])) {
38 38
 				if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') {
39 39
 					if (isset($flt['source'])) {
40
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
40
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
41 41
 					} else {
42
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
42
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
43 43
 					}
44 44
 				}
45 45
 			}
46 46
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
47 47
 				if (isset($flt['source'])) {
48
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
48
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
49 49
 				} else {
50
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
50
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
51 51
 				}
52 52
 			}
53 53
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
54 54
 				if (isset($flt['source'])) {
55
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
55
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
56 56
 				} else {
57
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
57
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
58 58
 				}
59 59
 			}
60 60
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
61 61
 				if (isset($flt['source'])) {
62
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
62
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
63 63
 				} else {
64
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
64
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
65 65
 				}
66 66
 			}
67 67
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
68 68
 				if (isset($flt['source'])) {
69
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
69
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
70 70
 				}
71 71
 			}
72 72
 		}
73 73
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
74 74
 			if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') {
75
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
75
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
76 76
 			}
77 77
 		}
78 78
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
83 83
 		}
84 84
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
85
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
85
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
86 86
 		}
87 87
 		if (isset($filter['blocked']) && $filter['blocked'] == true) {
88 88
 			$filter_query_join .= " INNER JOIN (SELECT callsign FROM aircraft_block) cblk ON cblk.callsign = spotter_live.ident";
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			if (count($filter['source']) == 1) {
92 92
 				$filter_query_where .= " AND format_source = '".$filter['source'][0]."'";
93 93
 			} else {
94
-				$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
94
+				$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
95 95
 			}
96 96
 		}
97 97
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
125 125
 				}
126 126
 			}
127
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
127
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
128 128
 		}
129 129
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
130
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
130
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
131 131
 		}
132 132
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
133 133
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
134 134
 		if ($filter_query_where != '') {
135
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
135
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
136 136
 		}
137 137
 		$filter_query = $filter_query_join.$filter_query_where;
138 138
 		return $filter_query;
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 		if ($limit != '')
156 156
 		{
157 157
 			$limit_array = explode(',', $limit);
158
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
159
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
158
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
159
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
160 160
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
161 161
 			{
162 162
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		} else {
181 181
 			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query;
182 182
 		}
183
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
183
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
184 184
 
185 185
 		return $spotter_array;
186 186
 	}
@@ -191,34 +191,34 @@  discard block
 block discarded – undo
191 191
 	* @return Array the spotter information
192 192
 	*
193 193
 	*/
194
-	public function getMinLiveSpotterData($limit = 0,$filter = array())
194
+	public function getMinLiveSpotterData($limit = 0, $filter = array())
195 195
 	{
196 196
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
197 197
 		date_default_timezone_set('UTC');
198
-		$filter_query = $this->getFilter($filter,true,true);
198
+		$filter_query = $this->getFilter($filter, true, true);
199 199
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
200 200
 		if ($globalDBdriver == 'mysql') {
201 201
 			if (isset($globalArchive) && $globalArchive === TRUE) {
202 202
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
203 203
 			//	FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC";
204
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
204
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
205 205
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
206 206
 			} else {
207 207
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
208 208
 			//	FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC";
209
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
209
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
210 210
 				FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
211 211
 			}
212 212
 		} else {
213 213
 			if (isset($globalArchive) && $globalArchive === TRUE) {
214 214
 			//	$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
215 215
 			//	FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND  spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
216
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
216
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
217 217
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND  spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
218 218
 			} else {
219 219
 			//	$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
220 220
 			//	FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
221
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
221
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
222 222
 				FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
223 223
 			}
224 224
 		}
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
 		if ($limit == 0 && isset($globalMap2DAircraftsLimit) && $globalMap2DAircraftsLimit != '') {
227 227
 			$limit = $globalMap2DAircraftsLimit;
228 228
 		}
229
-		if ($limit != 0 && filter_var($limit,FILTER_VALIDATE_INT)) {
229
+		if ($limit != 0 && filter_var($limit, FILTER_VALIDATE_INT)) {
230 230
 			$query .= ' LIMIT '.$limit;
231 231
 		}
232 232
 
233 233
 		try {
234 234
 			$sth = $this->db->prepare($query);
235 235
 			$sth->execute();
236
-		} catch(PDOException $e) {
236
+		} catch (PDOException $e) {
237 237
 			echo $e->getMessage();
238 238
 			die;
239 239
 		}
@@ -247,20 +247,20 @@  discard block
 block discarded – undo
247 247
 	* @return Array the spotter information
248 248
 	*
249 249
 	*/
250
-	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = 0, $id = '')
250
+	public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = 0, $id = '')
251 251
 	{
252 252
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
253 253
 		date_default_timezone_set('UTC');
254 254
 		$usecoord = false;
255 255
 		if (is_array($coord) && !empty($coord)) {
256
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
257
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
258
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
259
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
256
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
257
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
258
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
259
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
260 260
 			$usecoord = true;
261 261
 		}
262
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
263
-		$filter_query = $this->getFilter($filter,true,true);
262
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
263
+		$filter_query = $this->getFilter($filter, true, true);
264 264
 
265 265
 		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
266 266
 		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 				ORDER BY flightaware_id, date";
291 291
 				if ($limit > 0) $query .= " LIMIT ".$limit;
292 292
 			} else {
293
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
293
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
294 294
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
295 295
 				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
296 296
 				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 		try {
341 341
 			$sth = $this->db->prepare($query);
342 342
 			$sth->execute($query_values);
343
-		} catch(PDOException $e) {
343
+		} catch (PDOException $e) {
344 344
 			echo $e->getMessage();
345 345
 			die;
346 346
 		}
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 	* @return Array the spotter information
355 355
 	*
356 356
 	*/
357
-	public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = 0)
357
+	public function getMinLastLiveSpotterDataByID($id = '', $filter = array(), $limit = 0)
358 358
 	{
359 359
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
360 360
 		date_default_timezone_set('UTC');
361
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
362
-		$filter_query = $this->getFilter($filter,true,true);
361
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
362
+		$filter_query = $this->getFilter($filter, true, true);
363 363
 
364 364
 		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
365 365
 		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
@@ -384,13 +384,13 @@  discard block
 block discarded – undo
384 384
 			}
385 385
 		} else {
386 386
 			if (isset($globalArchive) && $globalArchive === TRUE) {
387
-				$query  = "SELECT * FROM (
387
+				$query = "SELECT * FROM (
388 388
 				SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration 
389 389
 				FROM spotter_archive 
390 390
 				INNER JOIN (
391 391
 				    SELECT flightaware_id 
392 392
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
393
-				$query.= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
393
+				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
394 394
 				$query .= "UNION
395 395
 				    SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
396 396
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 		try {
411 411
 			$sth = $this->db->prepare($query);
412 412
 			$sth->execute($query_values);
413
-		} catch(PDOException $e) {
413
+		} catch (PDOException $e) {
414 414
 			echo $e->getMessage();
415 415
 			die;
416 416
 		}
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	public function getLiveSpotterCount($filter = array())
428 428
 	{
429 429
 		global $globalDBdriver, $globalLiveInterval;
430
-		$filter_query = $this->getFilter($filter,true,true);
430
+		$filter_query = $this->getFilter($filter, true, true);
431 431
 
432 432
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
433 433
 		if ($globalDBdriver == 'mysql') {
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 		try {
441 441
 			$sth = $this->db->prepare($query);
442 442
 			$sth->execute();
443
-		} catch(PDOException $e) {
443
+		} catch (PDOException $e) {
444 444
 			echo $e->getMessage();
445 445
 			die;
446 446
 		}
@@ -457,16 +457,16 @@  discard block
 block discarded – undo
457 457
 	*/
458 458
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
459 459
 	{
460
-		global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit;
460
+		global $globalDBdriver, $globalLiveInterval, $globalMap2DAircraftsLimit;
461 461
 		$Spotter = new Spotter($this->db);
462 462
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
463 463
 		$filter_query = $this->getFilter($filter);
464 464
 
465 465
 		if (is_array($coord)) {
466
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
467
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
468
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
469
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
466
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
467
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
468
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
469
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
470 470
 		} else return array();
471 471
 		if ($globalDBdriver == 'mysql') {
472 472
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -487,28 +487,28 @@  discard block
 block discarded – undo
487 487
 	* @return Array the spotter information
488 488
 	*
489 489
 	*/
490
-	public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array())
490
+	public function getMinLiveSpotterDatabyCoord($coord, $limit = 0, $filter = array())
491 491
 	{
492
-		global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit;
492
+		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
493 493
 		$Spotter = new Spotter($this->db);
494 494
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
495
-		$filter_query = $this->getFilter($filter,true,true);
495
+		$filter_query = $this->getFilter($filter, true, true);
496 496
 
497 497
 		if (is_array($coord)) {
498
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
499
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
500
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
501
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
498
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
499
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
500
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
501
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
502 502
 		} else return array();
503 503
 		if ($globalDBdriver == 'mysql') {
504 504
 			if (isset($globalArchive) && $globalArchive === TRUE) {
505
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
505
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
506 506
 				FROM spotter_live 
507 507
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
508 508
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
509 509
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC';
510 510
 			} else {
511
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
511
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
512 512
 				FROM spotter_live 
513 513
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
514 514
 				    FROM spotter_live l 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
529 529
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
530 530
 				*/
531
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
531
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
532 532
 				FROM spotter_live 
533 533
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
534 534
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 				) s on spotter_live.flightaware_id = s.flightaware_id 
548 548
 				AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
549 549
 				*/
550
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
550
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
551 551
 				FROM spotter_live 
552 552
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
553 553
 				    FROM spotter_live l 
@@ -562,13 +562,13 @@  discard block
 block discarded – undo
562 562
 		if ($limit == 0 && isset($globalMap2DAircraftsLimit) && $globalMap2DAircraftsLimit != '') {
563 563
 			$limit = $globalMap2DAircraftsLimit;
564 564
 		}
565
-		if ($limit != 0 && filter_var($limit,FILTER_VALIDATE_INT)) {
565
+		if ($limit != 0 && filter_var($limit, FILTER_VALIDATE_INT)) {
566 566
 			$query .= ' LIMIT '.$limit;
567 567
 		}
568 568
 		try {
569 569
 			$sth = $this->db->prepare($query);
570 570
 			$sth->execute();
571
-		} catch(PDOException $e) {
571
+		} catch (PDOException $e) {
572 572
 			echo $e->getMessage();
573 573
 			die;
574 574
 		}
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
                 if ($interval == '1m')
618 618
                 {
619 619
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
620
-                } else if ($interval == '15m'){
620
+                } else if ($interval == '15m') {
621 621
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
622 622
                 } 
623 623
             }
@@ -625,14 +625,14 @@  discard block
 block discarded – undo
625 625
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
626 626
         }
627 627
 
628
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
628
+                $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
629 629
                    WHERE spotter_live.latitude <> '' 
630 630
                                    AND spotter_live.longitude <> '' 
631 631
                    ".$additional_query."
632 632
                    HAVING distance < :radius  
633 633
                                    ORDER BY distance";
634 634
 
635
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
635
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
636 636
 
637 637
                 return $spotter_array;
638 638
         }
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
 		date_default_timezone_set('UTC');
651 651
 
652 652
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
653
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
653
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
654 654
 
655
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
655
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
656 656
 
657 657
 		return $spotter_array;
658 658
 	}
@@ -663,16 +663,16 @@  discard block
 block discarded – undo
663 663
 	* @return Array the spotter information
664 664
 	*
665 665
 	*/
666
-	public function getDateLiveSpotterDataByIdent($ident,$date)
666
+	public function getDateLiveSpotterDataByIdent($ident, $date)
667 667
 	{
668 668
 		$Spotter = new Spotter($this->db);
669 669
 		date_default_timezone_set('UTC');
670 670
 
671 671
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
672
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
672
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
673 673
 
674
-                $date = date('c',$date);
675
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
674
+                $date = date('c', $date);
675
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
676 676
 
677 677
 		return $spotter_array;
678 678
 	}
@@ -688,8 +688,8 @@  discard block
 block discarded – undo
688 688
 		$Spotter = new Spotter($this->db);
689 689
 		date_default_timezone_set('UTC');
690 690
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
691
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
692
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
691
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
692
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
693 693
 		return $spotter_array;
694 694
 	}
695 695
 
@@ -699,15 +699,15 @@  discard block
 block discarded – undo
699 699
 	* @return Array the spotter information
700 700
 	*
701 701
 	*/
702
-	public function getDateLiveSpotterDataById($id,$date)
702
+	public function getDateLiveSpotterDataById($id, $date)
703 703
 	{
704 704
 		$Spotter = new Spotter($this->db);
705 705
 		date_default_timezone_set('UTC');
706 706
 
707 707
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
708
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
709
-		$date = date('c',$date);
710
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
708
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
709
+		$date = date('c', $date);
710
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
711 711
 		return $spotter_array;
712 712
 	}
713 713
 
@@ -723,13 +723,13 @@  discard block
 block discarded – undo
723 723
 		date_default_timezone_set('UTC');
724 724
 
725 725
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
726
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
726
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
727 727
 
728 728
     		try {
729 729
 			
730 730
 			$sth = $this->db->prepare($query);
731 731
 			$sth->execute(array(':ident' => $ident));
732
-		} catch(PDOException $e) {
732
+		} catch (PDOException $e) {
733 733
 			echo $e->getMessage();
734 734
 			die;
735 735
 		}
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 	* @return Array the spotter information
745 745
 	*
746 746
 	*/
747
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
747
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
748 748
 	{
749 749
 		global $globalDBdriver, $globalLiveInterval;
750 750
 		date_default_timezone_set('UTC');
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 		try {
764 764
 			$sth = $this->db->prepare($query);
765 765
 			$sth->execute(array(':id' => $id));
766
-		} catch(PDOException $e) {
766
+		} catch (PDOException $e) {
767 767
 			echo $e->getMessage();
768 768
 			die;
769 769
 		}
@@ -781,12 +781,12 @@  discard block
 block discarded – undo
781 781
 	{
782 782
 		date_default_timezone_set('UTC');
783 783
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
784
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
784
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
785 785
     		try {
786 786
 			
787 787
 			$sth = $this->db->prepare($query);
788 788
 			$sth->execute(array(':ident' => $ident));
789
-		} catch(PDOException $e) {
789
+		} catch (PDOException $e) {
790 790
 			echo $e->getMessage();
791 791
 			die;
792 792
 		}
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 			
817 817
 			$sth = $this->db->prepare($query);
818 818
 			$sth->execute();
819
-		} catch(PDOException $e) {
819
+		} catch (PDOException $e) {
820 820
 			return "error";
821 821
 		}
822 822
 
@@ -839,14 +839,14 @@  discard block
 block discarded – undo
839 839
 				
840 840
 				$sth = $this->db->prepare($query);
841 841
 				$sth->execute();
842
-			} catch(PDOException $e) {
842
+			} catch (PDOException $e) {
843 843
 				return "error";
844 844
 			}
845 845
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
846 846
                         $i = 0;
847
-                        $j =0;
847
+                        $j = 0;
848 848
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
849
-			foreach($all as $row)
849
+			foreach ($all as $row)
850 850
 			{
851 851
 				$i++;
852 852
 				$j++;
@@ -854,9 +854,9 @@  discard block
 block discarded – undo
854 854
 					if ($globalDebug) echo ".";
855 855
 				    	try {
856 856
 						
857
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
857
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
858 858
 						$sth->execute();
859
-					} catch(PDOException $e) {
859
+					} catch (PDOException $e) {
860 860
 						return "error";
861 861
 					}
862 862
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -867,9 +867,9 @@  discard block
 block discarded – undo
867 867
 			if ($i > 0) {
868 868
     				try {
869 869
 					
870
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
870
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
871 871
 					$sth->execute();
872
-				} catch(PDOException $e) {
872
+				} catch (PDOException $e) {
873 873
 					return "error";
874 874
 				}
875 875
 			}
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 				
883 883
 				$sth = $this->db->prepare($query);
884 884
 				$sth->execute();
885
-			} catch(PDOException $e) {
885
+			} catch (PDOException $e) {
886 886
 				return "error";
887 887
 			}
888 888
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -930,13 +930,13 @@  discard block
 block discarded – undo
930 930
 	public function deleteLiveSpotterDataByIdent($ident)
931 931
 	{
932 932
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
933
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
933
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
934 934
         
935 935
     		try {
936 936
 			
937 937
 			$sth = $this->db->prepare($query);
938 938
 			$sth->execute(array(':ident' => $ident));
939
-		} catch(PDOException $e) {
939
+		} catch (PDOException $e) {
940 940
 			return "error";
941 941
 		}
942 942
 
@@ -952,13 +952,13 @@  discard block
 block discarded – undo
952 952
 	public function deleteLiveSpotterDataById($id)
953 953
 	{
954 954
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
955
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
955
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
956 956
         
957 957
     		try {
958 958
 			
959 959
 			$sth = $this->db->prepare($query);
960 960
 			$sth->execute(array(':id' => $id));
961
-		} catch(PDOException $e) {
961
+		} catch (PDOException $e) {
962 962
 			return "error";
963 963
 		}
964 964
 
@@ -976,13 +976,13 @@  discard block
 block discarded – undo
976 976
 	{
977 977
 		global $globalDBdriver, $globalTimezone;
978 978
 		if ($globalDBdriver == 'mysql') {
979
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
979
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
980 980
 				WHERE spotter_live.ident = :ident 
981 981
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
982 982
 				AND spotter_live.date < UTC_TIMESTAMP()';
983 983
 			$query_data = array(':ident' => $ident);
984 984
 		} else {
985
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
985
+			$query = "SELECT spotter_live.ident FROM spotter_live 
986 986
 				WHERE spotter_live.ident = :ident 
987 987
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
988 988
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -991,8 +991,8 @@  discard block
 block discarded – undo
991 991
 		
992 992
 		$sth = $this->db->prepare($query);
993 993
 		$sth->execute($query_data);
994
-		$ident_result='';
995
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
994
+		$ident_result = '';
995
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
996 996
 		{
997 997
 			$ident_result = $row['ident'];
998 998
 		}
@@ -1009,13 +1009,13 @@  discard block
 block discarded – undo
1009 1009
 	{
1010 1010
 		global $globalDBdriver, $globalTimezone;
1011 1011
 		if ($globalDBdriver == 'mysql') {
1012
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1012
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1013 1013
 				WHERE spotter_live.ident = :ident 
1014 1014
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
1015 1015
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1016 1016
 			$query_data = array(':ident' => $ident);
1017 1017
 		} else {
1018
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1018
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1019 1019
 				WHERE spotter_live.ident = :ident 
1020 1020
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'";
1021 1021
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -1024,8 +1024,8 @@  discard block
 block discarded – undo
1024 1024
 		
1025 1025
 		$sth = $this->db->prepare($query);
1026 1026
 		$sth->execute($query_data);
1027
-		$ident_result='';
1028
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1027
+		$ident_result = '';
1028
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1029 1029
 		{
1030 1030
 			$ident_result = $row['flightaware_id'];
1031 1031
 		}
@@ -1042,13 +1042,13 @@  discard block
 block discarded – undo
1042 1042
 	{
1043 1043
 		global $globalDBdriver, $globalTimezone;
1044 1044
 		if ($globalDBdriver == 'mysql') {
1045
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1045
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1046 1046
 				WHERE spotter_live.flightaware_id = :id 
1047 1047
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
1048 1048
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1049 1049
 			$query_data = array(':id' => $id);
1050 1050
 		} else {
1051
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1051
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1052 1052
 				WHERE spotter_live.flightaware_id = :id 
1053 1053
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
1054 1054
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -1057,8 +1057,8 @@  discard block
 block discarded – undo
1057 1057
 		
1058 1058
 		$sth = $this->db->prepare($query);
1059 1059
 		$sth->execute($query_data);
1060
-		$ident_result='';
1061
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1060
+		$ident_result = '';
1061
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1062 1062
 		{
1063 1063
 			$ident_result = $row['flightaware_id'];
1064 1064
 		}
@@ -1075,13 +1075,13 @@  discard block
 block discarded – undo
1075 1075
 	{
1076 1076
 		global $globalDBdriver, $globalTimezone;
1077 1077
 		if ($globalDBdriver == 'mysql') {
1078
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1078
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1079 1079
 				WHERE spotter_live.ModeS = :modes 
1080 1080
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
1081 1081
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1082 1082
 			$query_data = array(':modes' => $modes);
1083 1083
 		} else {
1084
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1084
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1085 1085
 				WHERE spotter_live.ModeS = :modes 
1086 1086
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'";
1087 1087
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -1090,8 +1090,8 @@  discard block
 block discarded – undo
1090 1090
 		
1091 1091
 		$sth = $this->db->prepare($query);
1092 1092
 		$sth->execute($query_data);
1093
-		$ident_result='';
1094
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1093
+		$ident_result = '';
1094
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1095 1095
 		{
1096 1096
 			//$ident_result = $row['spotter_live_id'];
1097 1097
 			$ident_result = $row['flightaware_id'];
@@ -1116,8 +1116,8 @@  discard block
 block discarded – undo
1116 1116
 				return array();
1117 1117
 			} else {
1118 1118
 				$q_array = explode(" ", $q);
1119
-				foreach ($q_array as $q_item){
1120
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1119
+				foreach ($q_array as $q_item) {
1120
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1121 1121
 					$additional_query .= " AND (";
1122 1122
 					$additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR ";
1123 1123
 					$additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR ";
@@ -1132,11 +1132,11 @@  discard block
 block discarded – undo
1132 1132
 			}
1133 1133
 		}
1134 1134
 		if ($globalDBdriver == 'mysql') {
1135
-			$query  = "SELECT spotter_live.* FROM spotter_live 
1135
+			$query = "SELECT spotter_live.* FROM spotter_live 
1136 1136
 			    WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
1137 1137
 			    AND spotter_live.date < UTC_TIMESTAMP()";
1138 1138
 		} else {
1139
-			$query  = "SELECT spotter_live.* FROM spotter_live 
1139
+			$query = "SELECT spotter_live.* FROM spotter_live 
1140 1140
 			    WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
1141 1141
 			    AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1142 1142
 		}
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 	* @return String success or false
1157 1157
 	*
1158 1158
 	*/
1159
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
1159
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
1160 1160
 	{
1161 1161
 		global $globalURL, $globalArchive, $globalDebug;
1162 1162
 		$Common = new Common();
@@ -1256,27 +1256,27 @@  discard block
 block discarded – undo
1256 1256
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1257 1257
 
1258 1258
         
1259
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1260
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1261
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1262
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1263
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1264
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1265
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1266
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1267
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1268
-		$altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1269
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1270
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1271
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1272
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1273
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1274
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1275
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1276
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1277
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1278
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1279
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1259
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1260
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1261
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1262
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1263
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1264
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1265
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1266
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1267
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1268
+		$altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1269
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1270
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1271
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1272
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1273
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1274
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1275
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1276
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1277
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1278
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1279
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1280 1280
 
1281 1281
 		$airline_name = '';
1282 1282
 		$airline_icao = '';
@@ -1298,10 +1298,10 @@  discard block
 block discarded – undo
1298 1298
 		$arrival_airport_country = '';
1299 1299
 		
1300 1300
             	
1301
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1302
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1303
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1304
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1301
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1302
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1303
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1304
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1305 1305
 		
1306 1306
 		$query = '';
1307 1307
 		if ($globalArchive) {
@@ -1312,19 +1312,19 @@  discard block
 block discarded – undo
1312 1312
 		$query  .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) 
1313 1313
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)';
1314 1314
 
1315
-		$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real);
1315
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real);
1316 1316
 		try {
1317 1317
 			
1318 1318
 			$sth = $this->db->prepare($query);
1319 1319
 			$sth->execute($query_values);
1320 1320
 			$sth->closeCursor();
1321
-		} catch(PDOException $e) {
1321
+		} catch (PDOException $e) {
1322 1322
 			return "error : ".$e->getMessage();
1323 1323
 		}
1324 1324
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1325 1325
 		    if ($globalDebug) echo '(Add to Spotter archive : ';
1326 1326
 		    $SpotterArchive = new SpotterArchive($this->db);
1327
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1327
+		    $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1328 1328
 		    if ($globalDebug) echo $result.')';
1329 1329
 		} elseif ($globalDebug && $putinarchive !== true) {
1330 1330
 			echo '(Not adding to archive)';
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
 
1338 1338
 	public function getOrderBy()
1339 1339
 	{
1340
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1340
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1341 1341
 		return $orderby;
1342 1342
 	}
1343 1343
 
Please login to merge, or discard this patch.
Braces   +167 added lines, -56 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. (SpotterLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (SpotterLive)');
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) {
@@ -129,8 +133,11 @@  discard block
 block discarded – undo
129 133
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
130 134
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
131 135
 		}
132
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
133
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
136
+		if ($filter_query_where == '' && $where) {
137
+			$filter_query_where = ' WHERE';
138
+		} elseif ($filter_query_where != '' && $and) {
139
+			$filter_query_where .= ' AND';
140
+		}
134 141
 		if ($filter_query_where != '') {
135 142
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
136 143
 		}
@@ -171,9 +178,13 @@  discard block
 block discarded – undo
171 178
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
172 179
 			}
173 180
 		}
174
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
181
+		if ($orderby_query == '') {
182
+			$orderby_query = ' ORDER BY date DESC';
183
+		}
175 184
 
176
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
185
+		if (!isset($globalLiveInterval)) {
186
+			$globalLiveInterval = '200';
187
+		}
177 188
 		if ($globalDBdriver == 'mysql') {
178 189
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
179 190
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -196,7 +207,9 @@  discard block
 block discarded – undo
196 207
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
197 208
 		date_default_timezone_set('UTC');
198 209
 		$filter_query = $this->getFilter($filter,true,true);
199
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
210
+		if (!isset($globalLiveInterval)) {
211
+			$globalLiveInterval = '200';
212
+		}
200 213
 		if ($globalDBdriver == 'mysql') {
201 214
 			if (isset($globalArchive) && $globalArchive === TRUE) {
202 215
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
@@ -262,9 +275,15 @@  discard block
 block discarded – undo
262 275
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
263 276
 		$filter_query = $this->getFilter($filter,true,true);
264 277
 
265
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
266
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
267
-		if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit;
278
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
279
+			$globalLiveInterval = '200';
280
+		}
281
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
282
+			$globalMap3DAircraftsLimit = '300';
283
+		}
284
+		if ($limit == 0 || $limit == '') {
285
+			$limit = $globalMap3DAircraftsLimit;
286
+		}
268 287
 		if ($globalDBdriver == 'mysql') {
269 288
 			if (isset($globalArchive) && $globalArchive === TRUE) {
270 289
 				/*
@@ -277,26 +296,42 @@  discard block
 block discarded – undo
277 296
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
278 297
 				//if ($limit > 0) $query .= " LIMIT ".$limit;
279 298
 				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
280
-				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
281
-				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
299
+				if ($usecoord) {
300
+					$query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
301
+				}
302
+				if ($id != '') {
303
+					$query .= "OR spotter_archive.flightaware_id = :id ";
304
+				}
282 305
 				$query .= "UNION
283 306
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
284 307
 				FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
285
-				if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
286
-				if ($id != '') $query .= " OR spotter_live.flightaware_id = :id";
308
+				if ($usecoord) {
309
+					$query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
310
+				}
311
+				if ($id != '') {
312
+					$query .= " OR spotter_live.flightaware_id = :id";
313
+				}
287 314
 				//if ($limit > 0) $query .= " LIMIT ".$limit;
288 315
 				$query .= ") AS spotter 
289 316
 				WHERE latitude <> '0' AND longitude <> '0' 
290 317
 				ORDER BY flightaware_id, date";
291
-				if ($limit > 0) $query .= " LIMIT ".$limit;
318
+				if ($limit > 0) {
319
+					$query .= " LIMIT ".$limit;
320
+				}
292 321
 			} else {
293 322
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
294 323
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
295
-				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
296
-				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
324
+				if ($usecoord) {
325
+					$query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
326
+				}
327
+				if ($id != '') {
328
+					$query .= "OR spotter_live.flightaware_id = :id ";
329
+				}
297 330
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
298 331
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
299
-				if ($limit > 0) $query .= " LIMIT ".$limit;
332
+				if ($limit > 0) {
333
+					$query .= " LIMIT ".$limit;
334
+				}
300 335
 			}
301 336
 		} else {
302 337
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -314,29 +349,47 @@  discard block
 block discarded – undo
314 349
 				    FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
315 350
 				//if ($limit > 0) $query .= " ORDER BY spotter_live.date ASC LIMIT ".$limit;
316 351
 				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
317
-				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
318
-				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
352
+				if ($usecoord) {
353
+					$query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
354
+				}
355
+				if ($id != '') {
356
+					$query .= "OR spotter_archive.flightaware_id = :id ";
357
+				}
319 358
 				$query .= "UNION
320 359
 				    SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
321 360
 				    FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
322
-				if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
323
-				if ($id != '') $query .= " OR spotter_live.flightaware_id = :id";
361
+				if ($usecoord) {
362
+					$query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
363
+				}
364
+				if ($id != '') {
365
+					$query .= " OR spotter_live.flightaware_id = :id";
366
+				}
324 367
 				//if ($limit > 0) $query .= " ORDER BY date ASC LIMIT ".$limit;
325 368
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
326 369
 				$query .= "ORDER BY flightaware_id, date";
327
-				if ($limit > 0) $query .= " LIMIT ".$limit;
370
+				if ($limit > 0) {
371
+					$query .= " LIMIT ".$limit;
372
+				}
328 373
 			} else {
329 374
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
330 375
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date ";
331
-				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
332
-				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
376
+				if ($usecoord) {
377
+					$query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
378
+				}
379
+				if ($id != '') {
380
+					$query .= "OR spotter_live.flightaware_id = :id ";
381
+				}
333 382
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
334 383
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
335
-				if ($limit > 0) $query .= " LIMIT ".$limit;
384
+				if ($limit > 0) {
385
+					$query .= " LIMIT ".$limit;
386
+				}
336 387
 			}
337 388
 		}
338 389
 		$query_values = array();
339
-		if ($id != '') $query_values = array(':id' => $id);
390
+		if ($id != '') {
391
+			$query_values = array(':id' => $id);
392
+		}
340 393
 		try {
341 394
 			$sth = $this->db->prepare($query);
342 395
 			$sth->execute($query_values);
@@ -361,9 +414,15 @@  discard block
 block discarded – undo
361 414
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
362 415
 		$filter_query = $this->getFilter($filter,true,true);
363 416
 
364
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
365
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
366
-		if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit;
417
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
418
+			$globalLiveInterval = '200';
419
+		}
420
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
421
+			$globalMap3DAircraftsLimit = '300';
422
+		}
423
+		if ($limit == 0 || $limit == '') {
424
+			$limit = $globalMap3DAircraftsLimit;
425
+		}
367 426
 		if ($globalDBdriver == 'mysql') {
368 427
 			if (isset($globalArchive) && $globalArchive === TRUE) {
369 428
 				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration 
@@ -374,13 +433,17 @@  discard block
 block discarded – undo
374 433
 				$query .= ") AS spotter 
375 434
 				WHERE latitude <> '0' AND longitude <> '0' 
376 435
 				ORDER BY flightaware_id, date";
377
-				if ($limit > 0) $query .= " LIMIT ".$limit;
436
+				if ($limit > 0) {
437
+					$query .= " LIMIT ".$limit;
438
+				}
378 439
 			} else {
379 440
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
380 441
 				FROM spotter_live'.$filter_query.' spotter_live.flightaware_id = :id ';
381 442
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
382 443
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
383
-				if ($limit > 0) $query .= " LIMIT ".$limit;
444
+				if ($limit > 0) {
445
+					$query .= " LIMIT ".$limit;
446
+				}
384 447
 			}
385 448
 		} else {
386 449
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -396,13 +459,17 @@  discard block
 block discarded – undo
396 459
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
397 460
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
398 461
 				$query .= "ORDER BY flightaware_id, date";
399
-				if ($limit > 0) $query .= " LIMIT ".$limit;
462
+				if ($limit > 0) {
463
+					$query .= " LIMIT ".$limit;
464
+				}
400 465
 			} else {
401 466
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
402 467
 				FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id ";
403 468
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
404 469
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
405
-				if ($limit > 0) $query .= " LIMIT ".$limit;
470
+				if ($limit > 0) {
471
+					$query .= " LIMIT ".$limit;
472
+				}
406 473
 			}
407 474
 		}
408 475
 		$query_values = array();
@@ -429,7 +496,9 @@  discard block
 block discarded – undo
429 496
 		global $globalDBdriver, $globalLiveInterval;
430 497
 		$filter_query = $this->getFilter($filter,true,true);
431 498
 
432
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
499
+		if (!isset($globalLiveInterval)) {
500
+			$globalLiveInterval = '200';
501
+		}
433 502
 		if ($globalDBdriver == 'mysql') {
434 503
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
435 504
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -459,7 +528,9 @@  discard block
 block discarded – undo
459 528
 	{
460 529
 		global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit;
461 530
 		$Spotter = new Spotter($this->db);
462
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
531
+		if (!isset($globalLiveInterval)) {
532
+			$globalLiveInterval = '200';
533
+		}
463 534
 		$filter_query = $this->getFilter($filter);
464 535
 
465 536
 		if (is_array($coord)) {
@@ -467,7 +538,9 @@  discard block
 block discarded – undo
467 538
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
468 539
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
469 540
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
470
-		} else return array();
541
+		} else {
542
+			return array();
543
+		}
471 544
 		if ($globalDBdriver == 'mysql') {
472 545
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
473 546
 		} else {
@@ -491,7 +564,9 @@  discard block
 block discarded – undo
491 564
 	{
492 565
 		global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit;
493 566
 		$Spotter = new Spotter($this->db);
494
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
567
+		if (!isset($globalLiveInterval)) {
568
+			$globalLiveInterval = '200';
569
+		}
495 570
 		$filter_query = $this->getFilter($filter,true,true);
496 571
 
497 572
 		if (is_array($coord)) {
@@ -499,7 +574,9 @@  discard block
 block discarded – undo
499 574
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
500 575
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
501 576
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
502
-		} else return array();
577
+		} else {
578
+			return array();
579
+		}
503 580
 		if ($globalDBdriver == 'mysql') {
504 581
 			if (isset($globalArchive) && $globalArchive === TRUE) {
505 582
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
@@ -752,11 +829,15 @@  discard block
 block discarded – undo
752 829
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
753 830
 		if ($globalDBdriver == 'mysql') {
754 831
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
755
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
832
+			if ($liveinterval) {
833
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
834
+			}
756 835
 			$query .= ' ORDER BY date';
757 836
 		} else {
758 837
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
759
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
838
+			if ($liveinterval) {
839
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
840
+			}
760 841
 			$query .= ' ORDER BY date';
761 842
 		}
762 843
 
@@ -851,7 +932,9 @@  discard block
 block discarded – undo
851 932
 				$i++;
852 933
 				$j++;
853 934
 				if ($j == 30) {
854
-					if ($globalDebug) echo ".";
935
+					if ($globalDebug) {
936
+						echo ".";
937
+					}
855 938
 				    	try {
856 939
 						
857 940
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -1204,7 +1287,9 @@  discard block
 block discarded – undo
1204 1287
 			{
1205 1288
 				return false;
1206 1289
 			}
1207
-		} else return '';
1290
+		} else {
1291
+			return '';
1292
+		}
1208 1293
 
1209 1294
 		if ($longitude != '')
1210 1295
 		{
@@ -1212,7 +1297,9 @@  discard block
 block discarded – undo
1212 1297
 			{
1213 1298
 				return false;
1214 1299
 			}
1215
-		} else return '';
1300
+		} else {
1301
+			return '';
1302
+		}
1216 1303
 
1217 1304
 		if ($waypoints != '')
1218 1305
 		{
@@ -1228,14 +1315,18 @@  discard block
 block discarded – undo
1228 1315
 			{
1229 1316
 				return false;
1230 1317
 			}
1231
-		} else $altitude = 0;
1318
+		} else {
1319
+			$altitude = 0;
1320
+		}
1232 1321
 		if ($altitude_real != '')
1233 1322
 		{
1234 1323
 			if (!is_numeric($altitude_real))
1235 1324
 			{
1236 1325
 				return false;
1237 1326
 			}
1238
-		} else $altitude_real = 0;
1327
+		} else {
1328
+			$altitude_real = 0;
1329
+		}
1239 1330
 
1240 1331
 		if ($heading != '')
1241 1332
 		{
@@ -1243,7 +1334,9 @@  discard block
 block discarded – undo
1243 1334
 			{
1244 1335
 				return false;
1245 1336
 			}
1246
-		} else $heading = 0;
1337
+		} else {
1338
+			$heading = 0;
1339
+		}
1247 1340
 
1248 1341
 		if ($groundspeed != '')
1249 1342
 		{
@@ -1251,9 +1344,13 @@  discard block
 block discarded – undo
1251 1344
 			{
1252 1345
 				return false;
1253 1346
 			}
1254
-		} else $groundspeed = 0;
1347
+		} else {
1348
+			$groundspeed = 0;
1349
+		}
1255 1350
 		date_default_timezone_set('UTC');
1256
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1351
+		if ($date == '') {
1352
+			$date = date("Y-m-d H:i:s", time());
1353
+		}
1257 1354
 
1258 1355
         
1259 1356
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1298,14 +1395,24 @@  discard block
 block discarded – undo
1298 1395
 		$arrival_airport_country = '';
1299 1396
 		
1300 1397
             	
1301
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1302
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1303
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1304
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1398
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1399
+            		$squawk = NULL;
1400
+            	}
1401
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1402
+            		$verticalrate = NULL;
1403
+            	}
1404
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1405
+            		$groundspeed = 0;
1406
+            	}
1407
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1408
+            		$heading = 0;
1409
+            	}
1305 1410
 		
1306 1411
 		$query = '';
1307 1412
 		if ($globalArchive) {
1308
-			if ($globalDebug) echo '-- Delete previous data -- ';
1413
+			if ($globalDebug) {
1414
+				echo '-- Delete previous data -- ';
1415
+			}
1309 1416
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1310 1417
 		}
1311 1418
 
@@ -1322,10 +1429,14 @@  discard block
 block discarded – undo
1322 1429
 			return "error : ".$e->getMessage();
1323 1430
 		}
1324 1431
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1325
-		    if ($globalDebug) echo '(Add to Spotter archive : ';
1432
+		    if ($globalDebug) {
1433
+		    	echo '(Add to Spotter archive : ';
1434
+		    }
1326 1435
 		    $SpotterArchive = new SpotterArchive($this->db);
1327 1436
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1328
-		    if ($globalDebug) echo $result.')';
1437
+		    if ($globalDebug) {
1438
+		    	echo $result.')';
1439
+		    }
1329 1440
 		} elseif ($globalDebug && $putinarchive !== true) {
1330 1441
 			echo '(Not adding to archive)';
1331 1442
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
require/class.Accident.php 2 patches
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
 	* @param String $date get data for a date
43 43
 	* @return Array Return Accidents data in array
44 44
 	*/
45
-	public function getAccidentData($limit = '',$type = '',$date = '') {
45
+	public function getAccidentData($limit = '', $type = '', $date = '') {
46 46
 		global $globalURL, $globalDBdriver;
47 47
 		$Image = new Image($this->db);
48 48
 		$Spotter = new Spotter($this->db);
49 49
 		$Translation = new Translation($this->db);
50
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
50
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
51 51
 		date_default_timezone_set('UTC');
52 52
 		$result = array();
53 53
 		$limit_query = '';
54 54
 		if ($limit != "")
55 55
 		{
56 56
 			$limit_array = explode(",", $limit);
57
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
58
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
57
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
58
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
59 59
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
60 60
 			{
61 61
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -64,29 +64,29 @@  discard block
 block discarded – undo
64 64
 
65 65
 		if ($type != '') {
66 66
 			if ($date != '') {
67
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
67
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
68 68
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
69 69
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
70
-					$query_values = array(':type' => $type,':date' => $date);
71
-				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) {
70
+					$query_values = array(':type' => $type, ':date' => $date);
71
+				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) {
72 72
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
73
-					$query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31');
74
-				} elseif (preg_match("/^[0-9]{4}$/",$date)) {
73
+					$query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31');
74
+				} elseif (preg_match("/^[0-9]{4}$/", $date)) {
75 75
 					if ($globalDBdriver == 'mysql') {
76 76
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
77 77
 					} else {
78 78
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
79 79
 					}
80
-					$query_values = array(':type' => $type,':date' => $date);
80
+					$query_values = array(':type' => $type, ':date' => $date);
81 81
 				} else {
82 82
 					$date = $date.'%';
83 83
 					if ($globalDBdriver == 'mysql') {
84 84
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
85
-						$query_values = array(':type' => $type,':date' => $date);
85
+						$query_values = array(':type' => $type, ':date' => $date);
86 86
 					} else {
87 87
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
88 88
 						//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
89
-						$query_values = array(':type' => $type,':date' => $date);
89
+						$query_values = array(':type' => $type, ':date' => $date);
90 90
 					}
91 91
 				}
92 92
 			} else {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			}
98 98
 		} else {
99 99
 			if ($date != '') {
100
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
100
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
101 101
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
102 102
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
103 103
 				} else {
@@ -116,17 +116,17 @@  discard block
 block discarded – undo
116 116
 		try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
119
-		} catch(PDOException $e) {
119
+		} catch (PDOException $e) {
120 120
 			echo "error : ".$e->getMessage();
121 121
 		}
122 122
 		$i = 0;
123 123
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
124
-			if (preg_match('/^[\w\-]+$/',$row['registration'])) {
124
+			if (preg_match('/^[\w\-]+$/', $row['registration'])) {
125 125
 				$data = array();
126 126
 				if ($row['registration'] != '') {
127 127
 					$image_array = $Image->getSpotterImage($row['registration']);
128
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
129
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
128
+					if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
129
+					else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
130 130
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
131 131
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
132 132
 					if (!empty($aircraft_info)) {
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 						$data['aircraft_name'] = $aircraft_info[0]['type'];
135 135
 						$data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer'];
136 136
 					} else {
137
-						$data = array_merge($data,array('aircraft_type' => 'NA'));
137
+						$data = array_merge($data, array('aircraft_type' => 'NA'));
138 138
 					}
139 139
 					$owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']);
140 140
 					if (!empty($owner_data)) {
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
 						$data['aircraft_base'] = $owner_data['base'];
143 143
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
144 144
 					}
145
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
145
+				} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
146 146
 				if ($row['registration'] == '') $row['registration'] = 'NA';
147 147
 				if ($row['ident'] == '') $row['ident'] = 'NA';
148
-				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
148
+				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3));
149 149
 				if (isset($identicao[0])) {
150
-					if (substr($row['ident'],0,2) == 'AF') {
151
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
152
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
153
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
154
-					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
150
+					if (substr($row['ident'], 0, 2) == 'AF') {
151
+						if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
152
+						else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
153
+					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
154
+					$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
155 155
 				} else $icao = $row['ident'];
156
-				$icao = $Translation->checkTranslation($icao,false);
156
+				$icao = $Translation->checkTranslation($icao, false);
157 157
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
158 158
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
159 159
 					//echo 'Check airline info... for '.$row['airline_name'].' ';
@@ -162,16 +162,16 @@  discard block
 block discarded – undo
162 162
 					if (!empty($airline_info)) {
163 163
 						//echo 'data found !'."\n";
164 164
 						//print_r($airline_info);
165
-						$data = array_merge($data,$airline_info);
165
+						$data = array_merge($data, $airline_info);
166 166
 					} 
167 167
 					//else echo 'No data...'."\n";
168 168
 				}
169
-				$data = array_merge($row,$data);
169
+				$data = array_merge($row, $data);
170 170
 				if ($data['ident'] == null) $data['ident'] = $icao;
171 171
 				if ($data['title'] == null) {
172 172
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
173 173
 				} else $data['message'] = strtolower($data['title']);
174
-				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
174
+				$ids = $Spotter->getAllIDByRegistration($data['registration'], true);
175 175
 				$date = $data['date'];
176 176
 				if (isset($ids[$date])) {
177 177
 					$data['spotted'] = TRUE;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		try {
204 204
 			$sth = $this->db->prepare($query);
205 205
 			$sth->execute();
206
-		} catch(PDOException $e) {
206
+		} catch (PDOException $e) {
207 207
 			echo "Error : ".$e->getMessage();
208 208
 		}
209 209
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		try {
224 224
 			$sth = $this->db->prepare($query);
225 225
 			$sth->execute();
226
-		} catch(PDOException $e) {
226
+		} catch (PDOException $e) {
227 227
 			echo "Error : ".$e->getMessage();
228 228
 		}
229 229
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -238,15 +238,15 @@  discard block
 block discarded – undo
238 238
 		if ($globalDebug) echo 'Import '.$file."\n";
239 239
 		$result = array();
240 240
 		if (file_exists($file)) {
241
-			if (($handle = fopen($file,'r')) !== FALSE) {
242
-				while (($data = fgetcsv($handle,2000,",")) !== FALSE) {
241
+			if (($handle = fopen($file, 'r')) !== FALSE) {
242
+				while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
243 243
 					if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') {
244
-						$result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam');
244
+						$result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam');
245 245
 					}
246 246
 				}
247 247
 				fclose($handle);
248 248
 			}
249
-			if (!empty($result)) $this->add($result,true);
249
+			if (!empty($result)) $this->add($result, true);
250 250
 			elseif ($globalDebug) echo 'Nothing to import';
251 251
 		}
252 252
 	}
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 		$all_md5_new = array();
263 263
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
264 264
 			if ($this->check_accidents_nb() > 0) {
265
-				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
266
-					while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
265
+				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
266
+					while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
267 267
 						if (isset($data[1])) {
268 268
 							$year = $data[0];
269 269
 							$all_md5[$year] = $data[1];
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 				}
274 274
 			}
275 275
 		}
276
-		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5');
276
+		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5');
277 277
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
278
-			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
279
-				while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
278
+			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
279
+				while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
280 280
 					if (isset($data[1])) {
281 281
 						$year = $data[0];
282 282
 						$all_md5_new[$year] = $data[1];
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 				fclose($handle);
286 286
 			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
287 287
 		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
288
-		$result = $Common->arr_diff($all_md5_new,$all_md5);
288
+		$result = $Common->arr_diff($all_md5_new, $all_md5);
289 289
 		if (empty($result) && $globalDebug) echo 'Nothing to update';
290 290
 		foreach ($result as $file => $md5) {
291
-			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
291
+			$Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file);
292 292
 			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
293 293
 			elseif ($globalDebug) echo 'Download '.$file.' failed';
294 294
 		}
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	* Add data to DB
299 299
 	* @param Array $crash An array with accidents/incidents data
300 300
 	*/
301
-	public function add($crash,$new = false) {
301
+	public function add($crash, $new = false) {
302 302
 		global $globalTransaction, $globalDebug, $globalAircraftImageFetch;
303 303
 		require_once('class.Connection.php');
304 304
 		require_once('class.Image.php');
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 			$sthd->execute(array(':source' => $crash[0]['source']));
315 315
 		}
316 316
 		if ($globalTransaction) $Connection->db->beginTransaction();
317
-		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
317
+		$initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null);
318 318
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
319 319
 		$sth_check = $Connection->db->prepare($query_check);
320 320
 		$query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)';
@@ -327,15 +327,15 @@  discard block
 block discarded – undo
327 327
 				$cr = array_map(function($value) {
328 328
 					return $value === "" ? NULL : $value;
329 329
 				}, $cr);
330
-				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
331
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
332
-					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
330
+				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) {
331
+					if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
332
+					$query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']);
333 333
 					$sth_check->execute($query_check_values);
334 334
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
335 335
 					if ($result_check[0]['nb'] == 0) {
336
-						$query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']);
336
+						$query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']);
337 337
 						$sth->execute($query_values);
338
-						if ($cr['date'] > time()-(30*86400)) {
338
+						if ($cr['date'] > time() - (30*86400)) {
339 339
 							if ($globalAircraftImageFetch) {
340 340
 								$imgchk = $Image->getSpotterImage($cr['registration']);
341 341
 								if (empty($imgchk)) {
@@ -346,17 +346,17 @@  discard block
 block discarded – undo
346 346
 								// elseif ($globalDebug) echo 'Image already in DB'."\n";
347 347
 							}
348 348
 							if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
349
-							$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
349
+							$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date']));
350 350
 						}
351 351
 					}
352 352
 				}
353
-				if ($globalTransaction && $j % 1000 == 0) {
353
+				if ($globalTransaction && $j%1000 == 0) {
354 354
 					$Connection->db->commit();
355 355
 					$Connection->db->beginTransaction();
356 356
 				}
357 357
 			}
358 358
 			if ($globalTransaction) $Connection->db->commit();
359
-		} catch(PDOException $e) {
359
+		} catch (PDOException $e) {
360 360
 			if ($globalTransaction) $Connection->db->rollBack();
361 361
 			echo $e->getMessage();
362 362
 		}
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 			$Connection = new Connection();
375 375
 			$sth = $Connection->db->prepare($query);
376 376
 			$sth->execute();
377
-		} catch(PDOException $e) {
377
+		} catch (PDOException $e) {
378 378
 			return "error : ".$e->getMessage();
379 379
 		}
380 380
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 			$Connection = new Connection();
393 393
 			$sth = $Connection->db->prepare($query);
394 394
 			$sth->execute();
395
-		} catch(PDOException $e) {
395
+		} catch (PDOException $e) {
396 396
 			return "error : ".$e->getMessage();
397 397
 		}
398 398
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 			$Connection = new Connection();
408 408
 			$sth = $Connection->db->prepare($query);
409 409
 			$sth->execute();
410
-		} catch(PDOException $e) {
410
+		} catch (PDOException $e) {
411 411
 			return "error : ".$e->getMessage();
412 412
 		}
413 413
 	}
Please login to merge, or discard this patch.
Braces   +87 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
 	public function __construct($dbc = null) {
21 21
 		$Connection = new Connection($dbc);
22 22
 		$this->db = $Connection->db();
23
-		if ($this->db === null) die('Error: No DB connection. (Accident)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Accident)');
25
+		}
24 26
 	}
25 27
 
26 28
 	/*
@@ -125,8 +127,11 @@  discard block
 block discarded – undo
125 127
 				$data = array();
126 128
 				if ($row['registration'] != '') {
127 129
 					$image_array = $Image->getSpotterImage($row['registration']);
128
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
129
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
130
+					if (count($image_array) > 0) {
131
+						$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
132
+					} else {
133
+						$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
134
+					}
130 135
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
131 136
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
132 137
 					if (!empty($aircraft_info)) {
@@ -142,17 +147,30 @@  discard block
 block discarded – undo
142 147
 						$data['aircraft_base'] = $owner_data['base'];
143 148
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
144 149
 					}
145
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
146
-				if ($row['registration'] == '') $row['registration'] = 'NA';
147
-				if ($row['ident'] == '') $row['ident'] = 'NA';
150
+				} else {
151
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
152
+				}
153
+				if ($row['registration'] == '') {
154
+					$row['registration'] = 'NA';
155
+				}
156
+				if ($row['ident'] == '') {
157
+					$row['ident'] = 'NA';
158
+				}
148 159
 				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
149 160
 				if (isset($identicao[0])) {
150 161
 					if (substr($row['ident'],0,2) == 'AF') {
151
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
152
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
153
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
162
+						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
163
+							$icao = $row['ident'];
164
+						} else {
165
+							$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
166
+						}
167
+					} else {
168
+						$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
169
+					}
154 170
 					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
155
-				} else $icao = $row['ident'];
171
+				} else {
172
+					$icao = $row['ident'];
173
+				}
156 174
 				$icao = $Translation->checkTranslation($icao,false);
157 175
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
158 176
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -167,10 +185,14 @@  discard block
 block discarded – undo
167 185
 					//else echo 'No data...'."\n";
168 186
 				}
169 187
 				$data = array_merge($row,$data);
170
-				if ($data['ident'] == null) $data['ident'] = $icao;
188
+				if ($data['ident'] == null) {
189
+					$data['ident'] = $icao;
190
+				}
171 191
 				if ($data['title'] == null) {
172 192
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
173
-				} else $data['message'] = strtolower($data['title']);
193
+				} else {
194
+					$data['message'] = strtolower($data['title']);
195
+				}
174 196
 				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
175 197
 				$date = $data['date'];
176 198
 				if (isset($ids[$date])) {
@@ -189,8 +211,9 @@  discard block
 block discarded – undo
189 211
 		if (isset($result)) {
190 212
 			$result[0]['query_number_rows'] = $i;
191 213
 			return $result;
214
+		} else {
215
+			return array();
192 216
 		}
193
-		else return array();
194 217
 	}
195 218
 
196 219
 	/*
@@ -235,7 +258,9 @@  discard block
 block discarded – undo
235 258
 	*/
236 259
 	public function import($file) {
237 260
 		global $globalTransaction, $globalDebug;
238
-		if ($globalDebug) echo 'Import '.$file."\n";
261
+		if ($globalDebug) {
262
+			echo 'Import '.$file."\n";
263
+		}
239 264
 		$result = array();
240 265
 		if (file_exists($file)) {
241 266
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -246,8 +271,11 @@  discard block
 block discarded – undo
246 271
 				}
247 272
 				fclose($handle);
248 273
 			}
249
-			if (!empty($result)) $this->add($result,true);
250
-			elseif ($globalDebug) echo 'Nothing to import';
274
+			if (!empty($result)) {
275
+				$this->add($result,true);
276
+			} elseif ($globalDebug) {
277
+				echo 'Nothing to import';
278
+			}
251 279
 		}
252 280
 	}
253 281
 
@@ -283,14 +311,23 @@  discard block
 block discarded – undo
283 311
 					}
284 312
 				}
285 313
 				fclose($handle);
286
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
287
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
314
+			} elseif ($globalDebug) {
315
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
316
+			}
317
+		} elseif ($globalDebug) {
318
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
319
+		}
288 320
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
289
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
321
+		if (empty($result) && $globalDebug) {
322
+			echo 'Nothing to update';
323
+		}
290 324
 		foreach ($result as $file => $md5) {
291 325
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
292
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
293
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
326
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
327
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
328
+			} elseif ($globalDebug) {
329
+				echo 'Download '.$file.' failed';
330
+			}
294 331
 		}
295 332
 	}
296 333
 
@@ -307,13 +344,17 @@  discard block
 block discarded – undo
307 344
 		$Image = new Image($this->db);
308 345
 		$Spotter = new Spotter($this->db);
309 346
 
310
-		if (empty($crash)) return false;
347
+		if (empty($crash)) {
348
+			return false;
349
+		}
311 350
 		if ($new === false) {
312 351
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
313 352
 			$sthd = $Connection->db->prepare($query_delete);
314 353
 			$sthd->execute(array(':source' => $crash[0]['source']));
315 354
 		}
316
-		if ($globalTransaction) $Connection->db->beginTransaction();
355
+		if ($globalTransaction) {
356
+			$Connection->db->beginTransaction();
357
+		}
317 358
 		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
318 359
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
319 360
 		$sth_check = $Connection->db->prepare($query_check);
@@ -328,7 +369,9 @@  discard block
 block discarded – undo
328 369
 					return $value === "" ? NULL : $value;
329 370
 				}, $cr);
330 371
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
331
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
372
+					if (strpos($cr['registration'],'-') === FALSE) {
373
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
374
+					}
332 375
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
333 376
 					$sth_check->execute($query_check_values);
334 377
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
@@ -339,13 +382,19 @@  discard block
 block discarded – undo
339 382
 							if ($globalAircraftImageFetch) {
340 383
 								$imgchk = $Image->getSpotterImage($cr['registration']);
341 384
 								if (empty($imgchk)) {
342
-									if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
385
+									if ($globalDebug) {
386
+										echo "\t".'Get image for '.$cr['registration'].'...';
387
+									}
343 388
 									$Image->addSpotterImage($cr['registration']);
344
-									if ($globalDebug) echo "\t".'Done'."\n";
389
+									if ($globalDebug) {
390
+										echo "\t".'Done'."\n";
391
+									}
345 392
 								}
346 393
 								// elseif ($globalDebug) echo 'Image already in DB'."\n";
347 394
 							}
348
-							if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
395
+							if ($cr['title'] == '') {
396
+								$cr['title'] = $cr['registration'].' '.$cr['type'];
397
+							}
349 398
 							$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
350 399
 						}
351 400
 					}
@@ -355,9 +404,13 @@  discard block
 block discarded – undo
355 404
 					$Connection->db->beginTransaction();
356 405
 				}
357 406
 			}
358
-			if ($globalTransaction) $Connection->db->commit();
407
+			if ($globalTransaction) {
408
+				$Connection->db->commit();
409
+			}
359 410
 		} catch(PDOException $e) {
360
-			if ($globalTransaction) $Connection->db->rollBack();
411
+			if ($globalTransaction) {
412
+				$Connection->db->rollBack();
413
+			}
361 414
 			echo $e->getMessage();
362 415
 		}
363 416
 		$sth_check->closeCursor();
@@ -396,8 +449,11 @@  discard block
 block discarded – undo
396 449
 			return "error : ".$e->getMessage();
397 450
 		}
398 451
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
399
-		if ($row['nb'] > 0) return false;
400
-		else return true;
452
+		if ($row['nb'] > 0) {
453
+			return false;
454
+		} else {
455
+			return true;
456
+		}
401 457
 	}
402 458
 
403 459
 	public static function insert_last_accidents_update() {
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     <?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 } ?>
56 56
 </tr></table></div>
57 57
 <?php
58
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
58
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
59 59
 ?>
60 60
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) print '?tsk='.$tsk; ?>"></script>
61 61
 <script src="<?php echo $globalURL; ?>/js/meuusjs.1.0.3.min.js"></script>
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script>
82 82
 <?php
83 83
 	}
84
-    }
84
+	}
85 85
 ?>
86 86
 
87 87
 <div id="sidebar" class="sidebar collapsed">
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
 	<li><a href="" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
93 93
 	<li><a href="" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
94 94
 <?php
95
-    //if ((isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') || (isset($globalBeta) && $globalBeta === TRUE)) {
95
+	//if ((isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') || (isset($globalBeta) && $globalBeta === TRUE)) {
96 96
 	if (isset($globalArchive) && $globalArchive == TRUE && (!isset($globalAircraft) || $globalAircraft === TRUE)) {
97 97
 ?>
98 98
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
99 99
 <?php
100 100
 	}
101
-    //}
101
+	//}
102 102
 ?>
103 103
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
104 104
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 ?>
113 113
 
114 114
 <?php
115
-    if (isset($globalMap3D) && $globalMap3D) {
115
+	if (isset($globalMap3D) && $globalMap3D) {
116 116
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
117 117
 ?>
118 118
 	<li><a href="" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	<li><a href="" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
123 123
 <?php
124 124
 	}
125
-    }
125
+	}
126 126
 ?>
127 127
     </ul>
128 128
 
@@ -306,15 +306,15 @@  discard block
 block discarded – undo
306 306
 		    </div>
307 307
 		</li>
308 308
 		<?php
309
-		    if (isset($globalDemo) && $globalDemo) {
309
+			if (isset($globalDemo) && $globalDemo) {
310 310
 		?>
311 311
 		<li><button type="button" class="btn btn-primary disabled"><?php echo _("Show archive"); ?></button> Disabled in Demo mode</li>
312 312
 		<?php
313
-		    } else {
313
+			} else {
314 314
 		?>
315 315
 		<li><button type="button" onclick="addarchive(begindate,enddate);" class="btn btn-primary"><?php echo _("Show archive"); ?></button></li>
316 316
 		<?php
317
-		    }
317
+			}
318 318
 		?>
319 319
 	    </ul>
320 320
 	    <ul>
@@ -333,82 +333,82 @@  discard block
 block discarded – undo
333 333
 				if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
334 334
 					if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
335 335
 					else $MapType = $_COOKIE['MapType'];
336
-			    ?>
336
+				?>
337 337
 			<select  class="selectpicker" onchange="mapType(this);">
338 338
 			    <?php
339 339
 				} else {
340 340
 					if (!isset($_COOKIE['MapType3D']) || $_COOKIE['MapType3D'] == '') $MapType = $globalMapProvider;
341 341
 					else $MapType = $_COOKIE['MapType3D'];
342
-			    ?>
342
+				?>
343 343
 			<select  class="selectpicker" onchange="mapType3D(this);">
344 344
 			    <?php
345 345
 				}
346
-			    ?>
346
+				?>
347 347
 			    <?php
348 348
 				if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
349
-			    ?>
349
+				?>
350 350
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
351 351
 			    <?php
352 352
 				} else {
353
-				    if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
354
-			    ?>
353
+					if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
354
+				?>
355 355
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
356 356
 			    <?php
357
-				    }
358
-			    ?>
357
+					}
358
+				?>
359 359
 			    <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') print ' selected'; ?>>ArcGIS Streetmap</option>
360 360
 			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') print ' selected'; ?>>ArcGIS Satellite</option>
361 361
 			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Ocean') print ' selected'; ?>>ArcGIS Ocean</option>
362 362
 			    <?php
363
-				    if (isset($globalBingMapKey) && $globalBingMapKey != '') {
364
-			    ?>
363
+					if (isset($globalBingMapKey) && $globalBingMapKey != '') {
364
+				?>
365 365
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
366 366
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
367 367
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
368 368
 			    <?php
369
-				    }
370
-			    ?>
369
+					}
370
+				?>
371 371
 			    <?php
372
-				    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
373
-			    ?>
372
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
373
+				?>
374 374
 			    <?php
375 375
 					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
376
-			    ?>
376
+				?>
377 377
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here-Aerial') print ' selected'; ?>>Here-Aerial</option>
378 378
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here-Hybrid') print ' selected'; ?>>Here-Hybrid</option>
379 379
 			    <option value="Here-Road"<?php if ($MapType == 'Here-Road') print ' selected'; ?>>Here-Road</option>
380 380
 			    <?php
381 381
 					}
382
-			    ?>
382
+				?>
383 383
 			    <?php
384 384
 					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
385
-			    ?>
385
+				?>
386 386
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
387 387
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
388 388
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
389 389
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
390 390
 			    <?php
391 391
 					}
392
-			    ?>
392
+				?>
393 393
 			    <?php
394 394
 					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
395
-			    ?>
395
+				?>
396 396
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
397 397
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
398 398
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
399 399
 			    <?php
400 400
 					}
401
-			    ?>
401
+				?>
402 402
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option>
403 403
 			    <?php
404
-				    }
405
-			    ?>
404
+					}
405
+				?>
406 406
 			    <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') print ' selected'; ?>>National Geographic Street</option>
407 407
 			    <?php
408
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
408
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
409 409
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
410 410
 					else $MapBoxId = $_COOKIE['MapTypeId'];
411
-			    ?>
411
+				?>
412 412
 			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option>
413 413
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
414 414
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
@@ -423,17 +423,17 @@  discard block
 block discarded – undo
423 423
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
424 424
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
425 425
 			    <?php
426
-				    }
427
-			    ?>
426
+					}
427
+				?>
428 428
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
429 429
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
430 430
 			    <?php
431 431
 				}
432
-			    ?>
432
+				?>
433 433
 			</select>
434 434
 		    </li>
435 435
 <?php
436
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) {
436
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) {
437 437
 ?>
438 438
 		    <li><?php echo _("Type of Terrain:"); ?>
439 439
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -444,18 +444,18 @@  discard block
 block discarded – undo
444 444
 			</select>
445 445
 		    </li>
446 446
 <?php
447
-    }
447
+	}
448 448
 ?>
449 449
 
450 450
 <?php
451
-    if (isset($globalMap3D) && $globalMap3D) {
451
+	if (isset($globalMap3D) && $globalMap3D) {
452 452
 ?>
453 453
 		    <li><div class="checkbox"><label><input type="checkbox" name="synchro2d3d" value="1" onclick="clickSyncMap2D3D(this)" <?php if (isset($_COOKIE['Map2D3DSync']) && $_COOKIE['Map2D3DSync'] == 'true') print 'checked'; ?> ><?php echo _("Use same type of map for 2D & 3D"); ?></label></div></li>
454 454
 <?php
455
-    }
455
+	}
456 456
 ?>
457 457
 <?php
458
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
458
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
459 459
 ?>
460 460
 		    <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>
461 461
 
@@ -478,12 +478,12 @@  discard block
 block discarded – undo
478 478
 		    <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>
479 479
 <?php
480 480
 	}
481
-    }
482
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
481
+	}
482
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
483 483
 ?>
484 484
 		    <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>
485 485
 <?php
486
-    }
486
+	}
487 487
 ?>
488 488
 		    <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>
489 489
 		    <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>
@@ -502,88 +502,88 @@  discard block
 block discarded – undo
502 502
 ?>
503 503
 		    <li><div class="checkbox"><label><input type="checkbox" name="truelight" value="1" onclick="clickTrueLight(this)" <?php if ((!isset($_COOKIE['truelight']) && (!isset($globalMapTrueLight) || $globalMapTrueLight)) || (isset($_COOKIE['truelight']) && $_COOKIE['truelight'] == 'true')) print 'checked'; ?> ><?php echo _("Enable globe sun lighting"); ?></label></div></li>
504 504
 <?php
505
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
505
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
506 506
 ?>
507 507
 		    <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>
508 508
 		    <li><div class="checkbox"><label><input type="checkbox" name="shadows" value="1" onclick="clickShadows(this)" <?php if ((!isset($_COOKIE['map3dnoshadows']) && (!isset($globalMap3DShadows) || $globalMap3DShadows)) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'false')) print 'checked'; ?> ><?php echo _("Use shadows"); ?></label></div></li>
509 509
 		    <li><div class="checkbox"><label><input type="checkbox" name="one3dmodel" value="1" onclick="useOne3Dmodel(this)" <?php if ((isset($_COOKIE['one3dmodel']) && $_COOKIE['one3dmodel'] == 'true') || (!isset($_COOKIE['one3dmodel']) && isset($globalMap3DOneModel) && $globalMap3DOneModel)) print 'checked'; ?> ><?php echo _("Use same 3D model for all aircraft (use fewer resources)"); ?></label></div></li>
510 510
 		    <li><div class="checkbox"><label><input type="checkbox" name="updaterealtime" value="1" onclick="clickUpdateRealtime(this)" <?php if ((isset($_COOKIE['updaterealtime']) && $_COOKIE['updaterealtime'] == 'true') || !isset($_COOKIE['updaterealtime'])) print 'checked'; ?> ><?php echo _("Display realtime data in infobox"); ?></label></div></li>
511 511
 <?php
512
-    }
513
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
512
+	}
513
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
514 514
 ?>
515 515
 		    <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>
516 516
 <?php
517
-    }
517
+	}
518 518
 ?>
519 519
 		    <?php
520 520
 			if (function_exists('array_column')) {
521
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
522
-		    ?>
521
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
522
+			?>
523 523
 		    <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>
524 524
 		    <?php
525
-			    }
525
+				}
526 526
 			} elseif (isset($globalSources)) {
527
-			    $dispolar = false;
528
-			    foreach ($globalSources as $testsource) {
529
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
530
-			    }
531
-			    if ($dispolar) {
532
-		    ?>
527
+				$dispolar = false;
528
+				foreach ($globalSources as $testsource) {
529
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
530
+				}
531
+				if ($dispolar) {
532
+			?>
533 533
 		    <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>
534 534
 		    <?php
535
-			    }
536
-		        }
537
-		    ?>
535
+				}
536
+				}
537
+			?>
538 538
 <?php
539
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
539
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
540 540
 ?>
541 541
 		    <?php
542 542
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
543
-		    ?>
543
+			?>
544 544
 		    <li><?php echo _("Max number of flights to display in 2D:"); ?> <input type="number" name="2dlimit" value="<?php if (isset($_COOKIE['map_2d_limit'])) print $_COOKIE['map_2d_limit']; elseif (isset($globalMap2DAircraftsLimit)) print $globalMap2DAircraftsLimit; else print 15000; ?>" onchange="map2dlimit(this.value);" /></li>
545 545
 		    <?php
546 546
 			}
547
-		    ?>
547
+			?>
548 548
 		    <?php
549 549
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
550
-		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
551
-		    ?>
550
+					if (extension_loaded('gd') && function_exists('gd_info')) {
551
+			?>
552 552
 		    <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>
553 553
 		    <?php 
554 554
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
555
-		    ?>
555
+			?>
556 556
 			<li><?php echo _("Aircraft icon color:"); ?> <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(this.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"></li>
557 557
 		    <?php
558 558
 				}
559
-			    }
560
-		        }
561
-		    ?>
559
+				}
560
+				}
561
+			?>
562 562
 		    <?php
563 563
 			if (isset($globalMarine) && $globalMarine === TRUE) {
564
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
565
-		    ?>
564
+				if (extension_loaded('gd') && function_exists('gd_info')) {
565
+			?>
566 566
 		    <li><?php echo _("Marine icon color:"); ?>
567 567
 			<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'; ?>">
568 568
 		    </li>
569 569
 		    <?php
570
-			    }
571
-		        }
572
-		    ?>
570
+				}
571
+				}
572
+			?>
573 573
 		    <?php
574 574
 			if (isset($globalTracker) && $globalTracker === TRUE) {
575
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
576
-		    ?>
575
+				if (extension_loaded('gd') && function_exists('gd_info')) {
576
+			?>
577 577
 		    <li><?php echo _("Tracker icon color:"); ?>
578 578
 			<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'; ?>">
579 579
 		    </li>
580 580
 		    <?php
581
-			    }
582
-		        }
583
-		    ?>
581
+				}
582
+				}
583
+			?>
584 584
 		    <?php
585 585
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
586
-		    ?>
586
+			?>
587 587
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
588 588
 			<div class="range">
589 589
 			    <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'; ?>">
@@ -592,9 +592,9 @@  discard block
 block discarded – undo
592 592
 		    </li>
593 593
 		    <?php
594 594
 			}
595
-		    ?>
595
+			?>
596 596
 <?php
597
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
597
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
598 598
 ?>
599 599
 		    <li><?php echo _("Set scaling factor for rendering resolution:"); ?>
600 600
 			<div class="range">
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 		    </li>
634 634
 <?php
635 635
 	}
636
-    }
636
+	}
637 637
 ?>
638 638
 		    <li><?php echo _("Distance unit:"); ?>
639 639
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -673,19 +673,19 @@  discard block
 block discarded – undo
673 673
 		    <ul>
674 674
 		    <?php
675 675
 			if (!isset($globalAircraft) || $globalAircraft) {
676
-		    ?>
676
+			?>
677 677
 		    <?php
678 678
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
679
-		    ?>
679
+			?>
680 680
 			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') || !isset($_COOKIE['filter_ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
681 681
 			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') || !isset($_COOKIE['filter_ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
682 682
 			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') || !isset($_COOKIE['filter_ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
683 683
 		    <?php
684 684
 			}
685
-		    ?>
685
+			?>
686 686
 		    <?php
687 687
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
688
-		    ?>
688
+			?>
689 689
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
690 690
 			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') || !isset($_COOKIE['filter_ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
691 691
 			<?php } ?>
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 			<li><div class="checkbox"><label><input type="checkbox" name="blocked" value="1" onclick="clickBlocked(this)" <?php if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') print 'checked'; ?> ><?php echo _("Only display FAA ASDI blocked aircrafts"); ?></label></div></li>
696 696
 		    <?php
697 697
 			}
698
-		    ?>
698
+			?>
699 699
 		    <li><?php echo _("Display airlines:"); ?>
700 700
 		    <br/>
701 701
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
716 716
 					}
717 717
 				}
718
-			    ?>
718
+				?>
719 719
 			</select>
720 720
 		    </li>
721 721
 		    <?php
722 722
 			$Spotter = new Spotter();
723 723
 			$allalliancenames = $Spotter->getAllAllianceNames();
724 724
 			if (!empty($allalliancenames)) {
725
-		    ?>
725
+			?>
726 726
 		    <li><?php echo _("Display alliance:"); ?>
727 727
 		    <br/>
728 728
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -736,18 +736,18 @@  discard block
 block discarded – undo
736 736
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
737 737
 					}
738 738
 				}
739
-			    ?>
739
+				?>
740 740
 			</select>
741 741
 		    </li>
742 742
 		    <?php
743 743
 			}
744
-		    ?>
744
+			?>
745 745
 		    <?php
746 746
 			}
747
-		    ?>
747
+			?>
748 748
 		    <?php
749 749
 			if (isset($globalAPRS) && $globalAPRS) {
750
-		    ?>
750
+			?>
751 751
 		    <li><?php echo _("Display APRS sources name:"); ?>
752 752
 			<select class="selectpicker" multiple onchange="sources(this);">
753 753
 			    <?php
@@ -771,18 +771,18 @@  discard block
 block discarded – undo
771 771
 						echo '<option value="'.$src['name'].'">'.$src['name'].'</option>';
772 772
 					}
773 773
 				}
774
-			    ?>
774
+				?>
775 775
 			</select>
776 776
 		    </li>
777 777
 		    <?php
778 778
 			}
779
-		    ?>
779
+			?>
780 780
 		    <?php
781 781
 			if (!isset($globalAircraft) || $globalAircraft) {
782
-		    ?>
782
+			?>
783 783
 		    <?php
784
-			    if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
785
-		    ?>
784
+				if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
785
+			?>
786 786
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
787 787
 			<select class="selectpicker" onchange="airlinestype(this);">
788 788
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -792,14 +792,14 @@  discard block
 block discarded – undo
792 792
 			</select>
793 793
 		    </li>
794 794
 		    <?php
795
-			    }
796
-		    ?>
795
+				}
796
+			?>
797 797
 		    <?php
798 798
 			}
799
-		    ?>
799
+			?>
800 800
 		    <?php
801 801
 			if (isset($globalMarine) && $globalMarine) {
802
-		    ?>
802
+			?>
803 803
 		    <li>
804 804
 			<?php echo _("Display vessels with MMSI:"); ?>
805 805
 			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" />
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 								print '<option value="'.$race['race_id'].'">'.$race['race_name'].'</option>';
823 823
 							}
824 824
 						}
825
-			    ?>
825
+				?>
826 826
 			</select>
827 827
 		    </li>
828 828
 
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 					}
831 831
 				}
832 832
 			}
833
-		    ?>
833
+			?>
834 834
 		    <li>
835 835
 			<?php echo _("Display with ident:"); ?>
836 836
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 	    </form>
844 844
     	</div>
845 845
 <?php
846
-    if (isset($globalSatellite) && $globalSatellite) {
846
+	if (isset($globalSatellite) && $globalSatellite) {
847 847
 ?>
848 848
         <div class="sidebar-pane" id="satellites">
849 849
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -883,14 +883,14 @@  discard block
 block discarded – undo
883 883
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
884 884
 					}
885 885
 				}
886
-			    ?>
886
+				?>
887 887
 			</select>
888 888
 		    </li>
889 889
 		</ul>
890 890
 	    </form>
891 891
 	</div>
892 892
 <?php
893
-    }
893
+	}
894 894
 ?>
895 895
     </div>
896 896
 </div>
Please login to merge, or discard this patch.
Braces   +614 added lines, -153 removed lines patch added patch discarded remove patch
@@ -57,7 +57,10 @@  discard block
 block discarded – undo
57 57
 <?php
58 58
     if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
59 59
 ?>
60
-<script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) print '?tsk='.$tsk; ?>"></script>
60
+<script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) {
61
+	print '?tsk='.$tsk;
62
+}
63
+?>"></script>
61 64
 <script src="<?php echo $globalURL; ?>/js/meuusjs.1.0.3.min.js"></script>
62 65
 <script src="<?php echo $globalURL; ?>/js/map.3d.weather.js"></script>
63 66
 <?php
@@ -137,10 +140,22 @@  discard block
 block discarded – undo
137 140
 			<h1>Weather</h1>
138 141
 			<ul>
139 142
 			
140
-				<li><div class="checkbox"><label><input type="checkbox" name="wind" value="1" onclick="clickWind(this);" <?php if (isset($_COOKIE['weather_wind']) && $_COOKIE['weather_wind'] == 'true') print 'checked'; ?> /><?php echo _("Weather Winds"); ?></label></div></li>
141
-				<li><div class="checkbox"><label><input type="checkbox" name="wave" value="1" onclick="clickWave(this);" <?php if (isset($_COOKIE['weather_wave']) && $_COOKIE['weather_wave'] == 'true') print 'checked'; ?> /><?php echo _("Ocean surface currents"); ?></label></div></li>
142
-				<li><div class="checkbox"><label><input type="checkbox" name="fire" value="1" onclick="clickFire(this);" <?php if (isset($_COOKIE['weather_fire']) && $_COOKIE['weather_fire'] == 'true') print 'checked'; ?> /><?php echo _("NASA Fire Hotspots"); ?></label></div></li>
143
-				<!-- <li><div class="checkbox"><label><input type="checkbox" name="backwave" value="1" onclick="clickBackWave(this);" <?php if (isset($_COOKIE['weather_backwave']) && $_COOKIE['weather_backwave'] == 'true') print 'checked'; ?> /><?php echo _("Weather Waves height background"); ?></label></div></li> -->
143
+				<li><div class="checkbox"><label><input type="checkbox" name="wind" value="1" onclick="clickWind(this);" <?php if (isset($_COOKIE['weather_wind']) && $_COOKIE['weather_wind'] == 'true') {
144
+	print 'checked';
145
+}
146
+?> /><?php echo _("Weather Winds"); ?></label></div></li>
147
+				<li><div class="checkbox"><label><input type="checkbox" name="wave" value="1" onclick="clickWave(this);" <?php if (isset($_COOKIE['weather_wave']) && $_COOKIE['weather_wave'] == 'true') {
148
+	print 'checked';
149
+}
150
+?> /><?php echo _("Ocean surface currents"); ?></label></div></li>
151
+				<li><div class="checkbox"><label><input type="checkbox" name="fire" value="1" onclick="clickFire(this);" <?php if (isset($_COOKIE['weather_fire']) && $_COOKIE['weather_fire'] == 'true') {
152
+	print 'checked';
153
+}
154
+?> /><?php echo _("NASA Fire Hotspots"); ?></label></div></li>
155
+				<!-- <li><div class="checkbox"><label><input type="checkbox" name="backwave" value="1" onclick="clickBackWave(this);" <?php if (isset($_COOKIE['weather_backwave']) && $_COOKIE['weather_backwave'] == 'true') {
156
+	print 'checked';
157
+}
158
+?> /><?php echo _("Weather Waves height background"); ?></label></div></li> -->
144 159
 			
145 160
 <?php
146 161
 		if (isset($globalOpenWeatherMapKey) && $globalOpenWeatherMapKey != '') {
@@ -162,12 +177,18 @@  discard block
 block discarded – undo
162 177
 <?php
163 178
 		if (isset($globalMETAR) && isset($globalMETARcycle) && $globalMETAR && $globalMETARcycle) {
164 179
 ?>
165
-				<li><div class="checkbox"><label><input type="checkbox" name="displayweather" value="1" onclick="clickDisplayWeather(this)" <?php if ((isset($_COOKIE['show_Weather']) && $_COOKIE['show_Weather'] == 'true') || (!isset($_COOKIE['show_Weather']) && (isset($globalMapWeather) && $globalMapWeather === TRUE))) print 'checked'; ?> ><?php echo _("Display 3D weather"); ?></label></div></li>
180
+				<li><div class="checkbox"><label><input type="checkbox" name="displayweather" value="1" onclick="clickDisplayWeather(this)" <?php if ((isset($_COOKIE['show_Weather']) && $_COOKIE['show_Weather'] == 'true') || (!isset($_COOKIE['show_Weather']) && (isset($globalMapWeather) && $globalMapWeather === TRUE))) {
181
+	print 'checked';
182
+}
183
+?> ><?php echo _("Display 3D weather"); ?></label></div></li>
166 184
 			<!--	<li><div class="checkbox"><label><input type="checkbox" name="displayrain" value="1" onclick="clickDisplayRain(this)" ><?php echo _("Display rain on 3D map"); ?></label></div></li>-->
167 185
 <?php
168 186
 		}
169 187
 ?>
170
-				<li><div class="checkbox"><label><input type="checkbox" name="fire" value="1" onclick="clickFire(this);" <?php if (isset($_COOKIE['weather_fire']) && $_COOKIE['weather_fire'] == 'true') print 'checked'; ?> /><?php echo _("NASA Fire Hotspots"); ?></label></div></li>
188
+				<li><div class="checkbox"><label><input type="checkbox" name="fire" value="1" onclick="clickFire(this);" <?php if (isset($_COOKIE['weather_fire']) && $_COOKIE['weather_fire'] == 'true') {
189
+	print 'checked';
190
+}
191
+?> /><?php echo _("NASA Fire Hotspots"); ?></label></div></li>
171 192
 			</ul>
172 193
 <?php
173 194
 	}
@@ -183,13 +204,22 @@  discard block
 block discarded – undo
183 204
 <?php
184 205
 		if (!isset($globalAircraft) || $globalAircraft) {
185 206
 ?>
186
-				<li><div class="checkbox"><label><input type="checkbox" name="waypoints" value="1" onclick="showWaypoints(this);" <?php if (isset($_COOKIE['waypoints']) && $_COOKIE['waypoints'] == 'true') print 'checked'; ?> /><?php echo _("Display waypoints"); ?></label></div></li>
187
-				<li><div class="checkbox"><label><input type="checkbox" name="airspace" value="1" onclick="showAirspace(this);" <?php if (isset($_COOKIE['airspace']) && $_COOKIE['airspace'] == 'true') print 'checked'; ?> /><?php echo _("Display airspace"); ?></label></div></li>
207
+				<li><div class="checkbox"><label><input type="checkbox" name="waypoints" value="1" onclick="showWaypoints(this);" <?php if (isset($_COOKIE['waypoints']) && $_COOKIE['waypoints'] == 'true') {
208
+	print 'checked';
209
+}
210
+?> /><?php echo _("Display waypoints"); ?></label></div></li>
211
+				<li><div class="checkbox"><label><input type="checkbox" name="airspace" value="1" onclick="showAirspace(this);" <?php if (isset($_COOKIE['airspace']) && $_COOKIE['airspace'] == 'true') {
212
+	print 'checked';
213
+}
214
+?> /><?php echo _("Display airspace"); ?></label></div></li>
188 215
 <?php
189 216
 		}
190 217
 		if (isset($globalMarine) && $globalMarine) {
191 218
 ?>
192
-				<li><div class="checkbox"><label><input type="checkbox" name="openseamap" value="1" onclick="clickOpenSeaMap(this);" <?php if (isset($_COOKIE['openseamap']) && $_COOKIE['openseamap'] == 'true') print 'checked'; ?> /><?php echo _("Display OpenSeaMap"); ?></label></div></li>
219
+				<li><div class="checkbox"><label><input type="checkbox" name="openseamap" value="1" onclick="clickOpenSeaMap(this);" <?php if (isset($_COOKIE['openseamap']) && $_COOKIE['openseamap'] == 'true') {
220
+	print 'checked';
221
+}
222
+?> /><?php echo _("Display OpenSeaMap"); ?></label></div></li>
193 223
 <?php
194 224
 		}
195 225
 ?>
@@ -204,13 +234,22 @@  discard block
 block discarded – undo
204 234
 <?php
205 235
 		if (!isset($globalAircraft) || $globalAircraft) {
206 236
 ?>
207
-				<li><div class="checkbox"><label><input type="checkbox" name="waypoints" value="1" onclick="showWaypoints(this);" <?php if (isset($_COOKIE['waypoints']) && $_COOKIE['waypoints'] == 'true') print 'checked'; ?> /><?php echo _("Display waypoints"); ?> Beta</label></div></li>
208
-				<li><div class="checkbox"><label><input type="checkbox" name="airspace" value="1" onclick="showAirspace(this);" <?php if (isset($_COOKIE['airspace']) && $_COOKIE['airspace'] == 'true') print 'checked'; ?> /><?php echo _("Display airspace"); ?> Beta</label></div></li>
237
+				<li><div class="checkbox"><label><input type="checkbox" name="waypoints" value="1" onclick="showWaypoints(this);" <?php if (isset($_COOKIE['waypoints']) && $_COOKIE['waypoints'] == 'true') {
238
+	print 'checked';
239
+}
240
+?> /><?php echo _("Display waypoints"); ?> Beta</label></div></li>
241
+				<li><div class="checkbox"><label><input type="checkbox" name="airspace" value="1" onclick="showAirspace(this);" <?php if (isset($_COOKIE['airspace']) && $_COOKIE['airspace'] == 'true') {
242
+	print 'checked';
243
+}
244
+?> /><?php echo _("Display airspace"); ?> Beta</label></div></li>
209 245
 <?php
210 246
 		}
211 247
 		if (isset($globalMarine) && $globalMarine) {
212 248
 ?>
213
-				<li><div class="checkbox"><label><input type="checkbox" name="openseamap" value="1" onclick="clickOpenSeaMap(this);" <?php if (isset($_COOKIE['openseamap']) && $_COOKIE['openseamap'] == 'true') print 'checked'; ?> /><?php echo _("Display OpenSeaMap"); ?></label></div></li>
249
+				<li><div class="checkbox"><label><input type="checkbox" name="openseamap" value="1" onclick="clickOpenSeaMap(this);" <?php if (isset($_COOKIE['openseamap']) && $_COOKIE['openseamap'] == 'true') {
250
+	print 'checked';
251
+}
252
+?> /><?php echo _("Display OpenSeaMap"); ?></label></div></li>
214 253
 <?php
215 254
 		}
216 255
 ?>
@@ -225,14 +264,32 @@  discard block
 block discarded – undo
225 264
 		<h1>NOTAM</h1>
226 265
 		<form>
227 266
 			<ul>
228
-				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam(this);" <?php if (isset($_COOKIE['notam']) && $_COOKIE['notam'] == 'true') print 'checked'; ?> /><?php echo _("Display NOTAM"); ?></label></div></li>
267
+				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam(this);" <?php if (isset($_COOKIE['notam']) && $_COOKIE['notam'] == 'true') {
268
+	print 'checked';
269
+}
270
+?> /><?php echo _("Display NOTAM"); ?></label></div></li>
229 271
 				<li><?php echo _("NOTAM scope:"); ?>
230 272
 					<select class="selectpicker" onchange="notamscope(this);">
231
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
232
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
233
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
234
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
235
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
273
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
274
+	print ' selected';
275
+}
276
+?>>All</option>
277
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
278
+	print ' selected';
279
+}
280
+?>>Airport/Enroute warning</option>
281
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
282
+	print ' selected';
283
+}
284
+?>>Airport warning</option>
285
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
286
+	print ' selected';
287
+}
288
+?>>Navigation warning</option>
289
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
290
+	print ' selected';
291
+}
292
+?>>Enroute warning</option>
236 293
 					</select
237 294
 				</li>
238 295
 			</ul>
@@ -260,7 +317,10 @@  discard block
 block discarded – undo
260 317
 		    <div class="form-group">
261 318
 			<label><?php echo _("From:"); ?></label>
262 319
 			<div class='input-group date' id='datetimepicker1'>
263
-			    <input type='text' id="start_date" name="start_date" class="form-control" autocomplete="off" value="<?php if (isset($_COOKIE['archive_begin']) && $_COOKIE['archive_begin'] != '') print date("Y-m-d H:i",$_COOKIE['archive_begin']).' UTC'; ?>" required />
320
+			    <input type='text' id="start_date" name="start_date" class="form-control" autocomplete="off" value="<?php if (isset($_COOKIE['archive_begin']) && $_COOKIE['archive_begin'] != '') {
321
+	print date("Y-m-d H:i",$_COOKIE['archive_begin']).' UTC';
322
+}
323
+?>" required />
264 324
 			    <span class="input-group-addon">
265 325
 				<span class="glyphicon glyphicon-calendar"></span>
266 326
 			    </span>
@@ -269,7 +329,10 @@  discard block
 block discarded – undo
269 329
 		    <div class="form-group">
270 330
 			<label><?php echo _("To:"); ?></label>
271 331
 			<div class='input-group date' id='datetimepicker2'>
272
-			    <input type='text' id="end_date" name="end_date" class="form-control" autocomplete="off" value="<?php if (isset($_COOKIE['archive_end']) && $_COOKIE['archive_end'] != '') print date("Y-m-d H:i",$_COOKIE['archive_end']).' UTC'; ?>" />
332
+			    <input type='text' id="end_date" name="end_date" class="form-control" autocomplete="off" value="<?php if (isset($_COOKIE['archive_end']) && $_COOKIE['archive_end'] != '') {
333
+	print date("Y-m-d H:i",$_COOKIE['archive_end']).' UTC';
334
+}
335
+?>" />
273 336
 			    <span class="input-group-addon">
274 337
 				<span class="glyphicon glyphicon-calendar"></span>
275 338
 			    </span>
@@ -301,8 +364,20 @@  discard block
 block discarded – undo
301 364
 		    </script>
302 365
 		<li><?php echo _("Playback speed:"); ?>
303 366
 		    <div class="range">
304
-			<input type="range" min="0" max="50" step="1" id="archivespeed" 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'; ?>">
305
-			<output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
367
+			<input type="range" min="0" max="50" step="1" id="archivespeed" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
368
+	print $_POST['archivespeed'];
369
+} elseif (isset($_COOKIE['archive_speed'])) {
370
+	print $_COOKIE['archive_speed'];
371
+} else {
372
+	print '1';
373
+}
374
+?>">
375
+			<output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
376
+	print $_COOKIE['archive_speed'];
377
+} else {
378
+	print '1';
379
+}
380
+?></output>
306 381
 		    </div>
307 382
 		</li>
308 383
 		<?php
@@ -331,14 +406,20 @@  discard block
 block discarded – undo
331 406
 		    <li><?php echo _("Type of Map:"); ?>
332 407
 			    <?php
333 408
 				if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
334
-					if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
335
-					else $MapType = $_COOKIE['MapType'];
409
+					if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
410
+						$MapType = $globalMapProvider;
411
+					} else {
412
+						$MapType = $_COOKIE['MapType'];
413
+					}
336 414
 			    ?>
337 415
 			<select  class="selectpicker" onchange="mapType(this);">
338 416
 			    <?php
339 417
 				} else {
340
-					if (!isset($_COOKIE['MapType3D']) || $_COOKIE['MapType3D'] == '') $MapType = $globalMapProvider;
341
-					else $MapType = $_COOKIE['MapType3D'];
418
+					if (!isset($_COOKIE['MapType3D']) || $_COOKIE['MapType3D'] == '') {
419
+						$MapType = $globalMapProvider;
420
+					} else {
421
+						$MapType = $_COOKIE['MapType3D'];
422
+					}
342 423
 			    ?>
343 424
 			<select  class="selectpicker" onchange="mapType3D(this);">
344 425
 			    <?php
@@ -347,24 +428,48 @@  discard block
 block discarded – undo
347 428
 			    <?php
348 429
 				if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
349 430
 			    ?>
350
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
431
+			    <option value="offline"<?php if ($MapType == 'offline') {
432
+	print ' selected';
433
+}
434
+?>>Natural Earth (local)</option>
351 435
 			    <?php
352 436
 				} else {
353 437
 				    if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
354 438
 			    ?>
355
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
439
+			    <option value="offline"<?php if ($MapType == 'offline') {
440
+	print ' selected';
441
+}
442
+?>>Natural Earth (local)</option>
356 443
 			    <?php
357 444
 				    }
358 445
 			    ?>
359
-			    <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') print ' selected'; ?>>ArcGIS Streetmap</option>
360
-			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') print ' selected'; ?>>ArcGIS Satellite</option>
361
-			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Ocean') print ' selected'; ?>>ArcGIS Ocean</option>
446
+			    <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') {
447
+	print ' selected';
448
+}
449
+?>>ArcGIS Streetmap</option>
450
+			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') {
451
+	print ' selected';
452
+}
453
+?>>ArcGIS Satellite</option>
454
+			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Ocean') {
455
+	print ' selected';
456
+}
457
+?>>ArcGIS Ocean</option>
362 458
 			    <?php
363 459
 				    if (isset($globalBingMapKey) && $globalBingMapKey != '') {
364 460
 			    ?>
365
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
366
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
367
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
461
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
462
+	print ' selected';
463
+}
464
+?>>Bing-Aerial</option>
465
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
466
+	print ' selected';
467
+}
468
+?>>Bing-Hybrid</option>
469
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
470
+	print ' selected';
471
+}
472
+?>>Bing-Road</option>
368 473
 			    <?php
369 474
 				    }
370 475
 			    ?>
@@ -374,59 +479,143 @@  discard block
 block discarded – undo
374 479
 			    <?php
375 480
 					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
376 481
 			    ?>
377
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here-Aerial') print ' selected'; ?>>Here-Aerial</option>
378
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here-Hybrid') print ' selected'; ?>>Here-Hybrid</option>
379
-			    <option value="Here-Road"<?php if ($MapType == 'Here-Road') print ' selected'; ?>>Here-Road</option>
482
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here-Aerial') {
483
+	print ' selected';
484
+}
485
+?>>Here-Aerial</option>
486
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here-Hybrid') {
487
+	print ' selected';
488
+}
489
+?>>Here-Hybrid</option>
490
+			    <option value="Here-Road"<?php if ($MapType == 'Here-Road') {
491
+	print ' selected';
492
+}
493
+?>>Here-Road</option>
380 494
 			    <?php
381 495
 					}
382 496
 			    ?>
383 497
 			    <?php
384 498
 					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
385 499
 			    ?>
386
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
387
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
388
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
389
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
500
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
501
+	print ' selected';
502
+}
503
+?>>Google Roadmap</option>
504
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
505
+	print ' selected';
506
+}
507
+?>>Google Satellite</option>
508
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
509
+	print ' selected';
510
+}
511
+?>>Google Hybrid</option>
512
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
513
+	print ' selected';
514
+}
515
+?>>Google Terrain</option>
390 516
 			    <?php
391 517
 					}
392 518
 			    ?>
393 519
 			    <?php
394 520
 					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
395 521
 			    ?>
396
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
397
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
398
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
522
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
523
+	print ' selected';
524
+}
525
+?>>MapQuest-OSM</option>
526
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
527
+	print ' selected';
528
+}
529
+?>>MapQuest-Aerial</option>
530
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
531
+	print ' selected';
532
+}
533
+?>>MapQuest-Hybrid</option>
399 534
 			    <?php
400 535
 					}
401 536
 			    ?>
402
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option>
537
+			    <option value="offline"<?php if ($MapType == 'offline') {
538
+	print ' selected';
539
+}
540
+?>>Natural Earth</option>
403 541
 			    <?php
404 542
 				    }
405 543
 			    ?>
406
-			    <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') print ' selected'; ?>>National Geographic Street</option>
544
+			    <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') {
545
+	print ' selected';
546
+}
547
+?>>National Geographic Street</option>
407 548
 			    <?php
408 549
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
409
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
410
-					else $MapBoxId = $_COOKIE['MapTypeId'];
550
+					if (!isset($_COOKIE['MapTypeId'])) {
551
+						$MapBoxId = 'default';
552
+					} else {
553
+						$MapBoxId = $_COOKIE['MapTypeId'];
554
+					}
411 555
 			    ?>
412
-			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option>
413
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
414
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
415
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
416
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
417
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
418
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
419
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
420
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
421
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
422
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
423
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
424
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
556
+			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') {
557
+	print ' selected';
558
+}
559
+?>>Mapbox GL</option>
560
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
561
+	print ' selected';
562
+}
563
+?>>Mapbox default</option>
564
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
565
+	print ' selected';
566
+}
567
+?>>Mapbox streets</option>
568
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
569
+	print ' selected';
570
+}
571
+?>>Mapbox light</option>
572
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
573
+	print ' selected';
574
+}
575
+?>>Mapbox dark</option>
576
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
577
+	print ' selected';
578
+}
579
+?>>Mapbox satellite</option>
580
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
581
+	print ' selected';
582
+}
583
+?>>Mapbox streets-satellite</option>
584
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
585
+	print ' selected';
586
+}
587
+?>>Mapbox streets-basic</option>
588
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
589
+	print ' selected';
590
+}
591
+?>>Mapbox comic</option>
592
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
593
+	print ' selected';
594
+}
595
+?>>Mapbox outdoors</option>
596
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
597
+	print ' selected';
598
+}
599
+?>>Mapbox pencil</option>
600
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
601
+	print ' selected';
602
+}
603
+?>>Mapbox pirates</option>
604
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
605
+	print ' selected';
606
+}
607
+?>>Mapbox emerald</option>
425 608
 			    <?php
426 609
 				    }
427 610
 			    ?>
428
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
429
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
611
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
612
+	print ' selected';
613
+}
614
+?>>OpenStreetMap</option>
615
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
616
+	print ' selected';
617
+}
618
+?>>Yandex</option>
430 619
 			    <?php
431 620
 				}
432 621
 			    ?>
@@ -437,10 +626,22 @@  discard block
 block discarded – undo
437 626
 ?>
438 627
 		    <li><?php echo _("Type of Terrain:"); ?>
439 628
 			<select  class="selectpicker" onchange="terrainType(this);">
440
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
441
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
442
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
443
-			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected';?>>ArticDEM</option>
629
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
630
+	print ' selected';
631
+}
632
+?>>stk terrain</option>
633
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
634
+	print ' selected';
635
+}
636
+?>>ellipsoid</option>
637
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
638
+	print ' selected';
639
+}
640
+?>>vr terrain</option>
641
+			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') {
642
+	print ' selected';
643
+}
644
+?>>ArticDEM</option>
444 645
 			</select>
445 646
 		    </li>
446 647
 <?php
@@ -450,64 +651,124 @@  discard block
 block discarded – undo
450 651
 <?php
451 652
     if (isset($globalMap3D) && $globalMap3D) {
452 653
 ?>
453
-		    <li><div class="checkbox"><label><input type="checkbox" name="synchro2d3d" value="1" onclick="clickSyncMap2D3D(this)" <?php if (isset($_COOKIE['Map2D3DSync']) && $_COOKIE['Map2D3DSync'] == 'true') print 'checked'; ?> ><?php echo _("Use same type of map for 2D & 3D"); ?></label></div></li>
654
+		    <li><div class="checkbox"><label><input type="checkbox" name="synchro2d3d" value="1" onclick="clickSyncMap2D3D(this)" <?php if (isset($_COOKIE['Map2D3DSync']) && $_COOKIE['Map2D3DSync'] == 'true') {
655
+	print 'checked';
656
+}
657
+?> ><?php echo _("Use same type of map for 2D & 3D"); ?></label></div></li>
454 658
 <?php
455 659
     }
456 660
 ?>
457 661
 <?php
458 662
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
459 663
 ?>
460
-		    <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>
664
+		    <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') {
665
+	print 'checked';
666
+}
667
+?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li>
461 668
 
462 669
 <?php
463 670
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
464 671
 ?>
465
-		    <!--<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>-->
466
-		    <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>
467
-		    <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>
468
-		    <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>
469
-		    <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>
672
+		    <!--<li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
673
+	print 'checked';
674
+}
675
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>-->
676
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) {
677
+	print 'checked';
678
+}
679
+?> ><?php echo _("Display flight path"); ?></label></div></li>
680
+		    <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)) {
681
+	print 'checked';
682
+}
683
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
684
+		    <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)) {
685
+	print 'checked';
686
+}
687
+?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
688
+		    <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)) {
689
+	print 'checked';
690
+}
691
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
470 692
 <?php
471 693
 	} elseif (!isset($globalTracker) || $globalTracker === TRUE) {
472 694
 ?>
473
-		    <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>
695
+		    <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)) {
696
+	print 'checked';
697
+}
698
+?> ><?php echo _("Enable map matching"); ?></label></div></li>
474 699
 <?php
475 700
 	}
476 701
 	if (isset($globalSatellite) && $globalSatellite === TRUE) {
477 702
 ?>
478
-		    <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>
703
+		    <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)) {
704
+	print 'checked';
705
+}
706
+?> ><?php echo _("Satellites animate between updates"); ?></label></div></li>
479 707
 <?php
480 708
 	}
481 709
     }
482 710
     if (!isset($globalAircraft) || $globalAircraft === TRUE) {
483 711
 ?>
484
-		    <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>
712
+		    <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'])) {
713
+	print 'checked';
714
+}
715
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
485 716
 <?php
486 717
     }
487 718
 ?>
488
-		    <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>
489
-		    <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>
490
-		    <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>
719
+		    <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))) {
720
+	print 'checked';
721
+}
722
+?> ><?php echo _("Display ground station on map"); ?></label></div></li>
723
+		    <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))) {
724
+	print 'checked';
725
+}
726
+?> ><?php echo _("Display weather station on map"); ?></label></div></li>
727
+		    <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))) {
728
+	print 'checked';
729
+}
730
+?> ><?php echo _("Display lightning on map"); ?></label></div></li>
491 731
 <?php
492 732
 	if (isset($globalFires) && $globalFires) {
493 733
 ?>
494
-		    <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>
734
+		    <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))) {
735
+	print 'checked';
736
+}
737
+?> ><?php echo _("Display fires on map"); ?></label></div></li>
495 738
 <?php
496 739
 	}
497 740
 	if (isset($globalMap3D) && $globalMap3D) {
498 741
 ?>
499
-		    <li><div class="checkbox"><label><input type="checkbox" name="singlemodel" value="1" onclick="clickSingleModel(this)" <?php if ((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') || (!isset($_COOKIE['singlemodel']) && isset($globalMap3DSelected) && $globalMap3DSelected)) print 'checked'; ?> ><?php echo _("Only display selected flight on 3D mode"); ?></label></div></li>
742
+		    <li><div class="checkbox"><label><input type="checkbox" name="singlemodel" value="1" onclick="clickSingleModel(this)" <?php if ((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') || (!isset($_COOKIE['singlemodel']) && isset($globalMap3DSelected) && $globalMap3DSelected)) {
743
+	print 'checked';
744
+}
745
+?> ><?php echo _("Only display selected flight on 3D mode"); ?></label></div></li>
500 746
 <?php
501 747
 	}
502 748
 ?>
503
-		    <li><div class="checkbox"><label><input type="checkbox" name="truelight" value="1" onclick="clickTrueLight(this)" <?php if ((!isset($_COOKIE['truelight']) && (!isset($globalMapTrueLight) || $globalMapTrueLight)) || (isset($_COOKIE['truelight']) && $_COOKIE['truelight'] == 'true')) print 'checked'; ?> ><?php echo _("Enable globe sun lighting"); ?></label></div></li>
749
+		    <li><div class="checkbox"><label><input type="checkbox" name="truelight" value="1" onclick="clickTrueLight(this)" <?php if ((!isset($_COOKIE['truelight']) && (!isset($globalMapTrueLight) || $globalMapTrueLight)) || (isset($_COOKIE['truelight']) && $_COOKIE['truelight'] == 'true')) {
750
+	print 'checked';
751
+}
752
+?> ><?php echo _("Enable globe sun lighting"); ?></label></div></li>
504 753
 <?php
505 754
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
506 755
 ?>
507
-		    <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>
508
-		    <li><div class="checkbox"><label><input type="checkbox" name="shadows" value="1" onclick="clickShadows(this)" <?php if ((!isset($_COOKIE['map3dnoshadows']) && (!isset($globalMap3DShadows) || $globalMap3DShadows)) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'false')) print 'checked'; ?> ><?php echo _("Use shadows"); ?></label></div></li>
509
-		    <li><div class="checkbox"><label><input type="checkbox" name="one3dmodel" value="1" onclick="useOne3Dmodel(this)" <?php if ((isset($_COOKIE['one3dmodel']) && $_COOKIE['one3dmodel'] == 'true') || (!isset($_COOKIE['one3dmodel']) && isset($globalMap3DOneModel) && $globalMap3DOneModel)) print 'checked'; ?> ><?php echo _("Use same 3D model for all aircraft (use fewer resources)"); ?></label></div></li>
510
-		    <li><div class="checkbox"><label><input type="checkbox" name="updaterealtime" value="1" onclick="clickUpdateRealtime(this)" <?php if ((isset($_COOKIE['updaterealtime']) && $_COOKIE['updaterealtime'] == 'true') || !isset($_COOKIE['updaterealtime'])) print 'checked'; ?> ><?php echo _("Display realtime data in infobox"); ?></label></div></li>
756
+		    <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')) {
757
+	print 'checked';
758
+}
759
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
760
+		    <li><div class="checkbox"><label><input type="checkbox" name="shadows" value="1" onclick="clickShadows(this)" <?php if ((!isset($_COOKIE['map3dnoshadows']) && (!isset($globalMap3DShadows) || $globalMap3DShadows)) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'false')) {
761
+	print 'checked';
762
+}
763
+?> ><?php echo _("Use shadows"); ?></label></div></li>
764
+		    <li><div class="checkbox"><label><input type="checkbox" name="one3dmodel" value="1" onclick="useOne3Dmodel(this)" <?php if ((isset($_COOKIE['one3dmodel']) && $_COOKIE['one3dmodel'] == 'true') || (!isset($_COOKIE['one3dmodel']) && isset($globalMap3DOneModel) && $globalMap3DOneModel)) {
765
+	print 'checked';
766
+}
767
+?> ><?php echo _("Use same 3D model for all aircraft (use fewer resources)"); ?></label></div></li>
768
+		    <li><div class="checkbox"><label><input type="checkbox" name="updaterealtime" value="1" onclick="clickUpdateRealtime(this)" <?php if ((isset($_COOKIE['updaterealtime']) && $_COOKIE['updaterealtime'] == 'true') || !isset($_COOKIE['updaterealtime'])) {
769
+	print 'checked';
770
+}
771
+?> ><?php echo _("Display realtime data in infobox"); ?></label></div></li>
511 772
 <?php
512 773
     }
513 774
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -520,17 +781,25 @@  discard block
 block discarded – undo
520 781
 			if (function_exists('array_column')) {
521 782
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
522 783
 		    ?>
523
-		    <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>
784
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
785
+	print 'checked';
786
+}
787
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
524 788
 		    <?php
525 789
 			    }
526 790
 			} elseif (isset($globalSources)) {
527 791
 			    $dispolar = false;
528 792
 			    foreach ($globalSources as $testsource) {
529
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
793
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
794
+			        	$dispolar = true;
795
+			        }
530 796
 			    }
531 797
 			    if ($dispolar) {
532 798
 		    ?>
533
-		    <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>
799
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
800
+	print 'checked';
801
+}
802
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
534 803
 		    <?php
535 804
 			    }
536 805
 		        }
@@ -541,7 +810,14 @@  discard block
 block discarded – undo
541 810
 		    <?php
542 811
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
543 812
 		    ?>
544
-		    <li><?php echo _("Max number of flights to display in 2D:"); ?> <input type="number" name="2dlimit" value="<?php if (isset($_COOKIE['map_2d_limit'])) print $_COOKIE['map_2d_limit']; elseif (isset($globalMap2DAircraftsLimit)) print $globalMap2DAircraftsLimit; else print 15000; ?>" onchange="map2dlimit(this.value);" /></li>
813
+		    <li><?php echo _("Max number of flights to display in 2D:"); ?> <input type="number" name="2dlimit" value="<?php if (isset($_COOKIE['map_2d_limit'])) {
814
+	print $_COOKIE['map_2d_limit'];
815
+} elseif (isset($globalMap2DAircraftsLimit)) {
816
+	print $globalMap2DAircraftsLimit;
817
+} else {
818
+	print 15000;
819
+}
820
+?>" onchange="map2dlimit(this.value);" /></li>
545 821
 		    <?php
546 822
 			}
547 823
 		    ?>
@@ -549,11 +825,21 @@  discard block
 block discarded – undo
549 825
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
550 826
 		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
551 827
 		    ?>
552
-		    <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>
828
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
829
+	print 'checked';
830
+}
831
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
553 832
 		    <?php 
554 833
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
555 834
 		    ?>
556
-			<li><?php echo _("Aircraft icon color:"); ?> <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(this.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"></li>
835
+			<li><?php echo _("Aircraft icon color:"); ?> <input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(this.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
836
+	print $_COOKIE['IconColor'];
837
+} elseif (isset($globalAircraftIconColor)) {
838
+	print $globalAircraftIconColor;
839
+} else {
840
+	print '1a3151';
841
+}
842
+?>"></li>
557 843
 		    <?php
558 844
 				}
559 845
 			    }
@@ -564,7 +850,14 @@  discard block
 block discarded – undo
564 850
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
565 851
 		    ?>
566 852
 		    <li><?php echo _("Marine icon color:"); ?>
567
-			<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'; ?>">
853
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
854
+	print $_COOKIE['MarineIconColor'];
855
+} elseif (isset($globalMarineIconColor)) {
856
+	print $globalMarineIconColor;
857
+} else {
858
+	print '1a3151';
859
+}
860
+?>">
568 861
 		    </li>
569 862
 		    <?php
570 863
 			    }
@@ -575,7 +868,14 @@  discard block
 block discarded – undo
575 868
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
576 869
 		    ?>
577 870
 		    <li><?php echo _("Tracker icon color:"); ?>
578
-			<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'; ?>">
871
+			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) {
872
+	print $_COOKIE['TrackerIconColor'];
873
+} elseif (isset($globalTrackerIconColor)) {
874
+	print $globalTrackerIconColor;
875
+} else {
876
+	print '1a3151';
877
+}
878
+?>">
579 879
 		    </li>
580 880
 		    <?php
581 881
 			    }
@@ -586,8 +886,22 @@  discard block
 block discarded – undo
586 886
 		    ?>
587 887
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
588 888
 			<div class="range">
589
-			    <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'; ?>">
590
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
889
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
890
+	print $_COOKIE['AirportZoom'];
891
+} elseif (isset($globalAirportZoom)) {
892
+	print $globalAirportZoom;
893
+} else {
894
+	print '7';
895
+}
896
+?>">
897
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
898
+	print $_COOKIE['AirportZoom'];
899
+} elseif (isset($globalAirportZoom)) {
900
+	print $globalAirportZoom;
901
+} else {
902
+	print '7';
903
+}
904
+?></output>
591 905
 			</div>
592 906
 		    </li>
593 907
 		    <?php
@@ -598,18 +912,48 @@  discard block
 block discarded – undo
598 912
 ?>
599 913
 		    <li><?php echo _("Set scaling factor for rendering resolution:"); ?>
600 914
 			<div class="range">
601
-			    <input type="range" min="0.5" max="2" step="0.5" name="resolutionscale" onchange="scale.value=value;resolutionScale(resolutionscale.value);" value="<?php if (isset($_COOKIE['resolutionScale'])) print $_COOKIE['resolutionScale']; else print '1'; ?>">
602
-			    <output id="scale"><?php if (isset($_COOKIE['resolutionScale'])) print $_COOKIE['resolutionScale']; else print '1'; ?></output>
915
+			    <input type="range" min="0.5" max="2" step="0.5" name="resolutionscale" onchange="scale.value=value;resolutionScale(resolutionscale.value);" value="<?php if (isset($_COOKIE['resolutionScale'])) {
916
+	print $_COOKIE['resolutionScale'];
917
+} else {
918
+	print '1';
919
+}
920
+?>">
921
+			    <output id="scale"><?php if (isset($_COOKIE['resolutionScale'])) {
922
+	print $_COOKIE['resolutionScale'];
923
+} else {
924
+	print '1';
925
+}
926
+?></output>
603 927
 			</div>
604 928
 		    </li>
605 929
 <?php
606 930
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
607 931
 ?>
608
-		    <!-- <li><?php echo _("Max number of flights to display in 3D:"); ?> <input type="number" name="3dlimit" value="<?php if (isset($_COOKIE['map_3d_limit'])) print $_COOKIE['map_3d_limit']; elseif (isset($globalMap3DAircraftsLimit)) print $globalMap3DAircraftsLimit; else print 300; ?>" onchange="map3dlimit(this.value);" /></li> -->
609
-		    <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>
610
-		    <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"); ?>&nbsp;
932
+		    <!-- <li><?php echo _("Max number of flights to display in 3D:"); ?> <input type="number" name="3dlimit" value="<?php if (isset($_COOKIE['map_3d_limit'])) {
933
+	print $_COOKIE['map_3d_limit'];
934
+} elseif (isset($globalMap3DAircraftsLimit)) {
935
+	print $globalMap3DAircraftsLimit;
936
+} else {
937
+	print 300;
938
+}
939
+?>" onchange="map3dlimit(this.value);" /></li> -->
940
+		    <li><input type="checkbox" name="useliveries" value="1" onclick="useLiveries(this)" <?php if (isset($_COOKIE['UseLiveries']) && $_COOKIE['UseLiveries'] == 'true') {
941
+	print 'checked';
942
+}
943
+?> > <?php echo _("Use airlines liveries"); ?></li>
944
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
945
+	print 'checked';
946
+}
947
+?> > <?php echo _("Force Aircraft color"); ?>&nbsp;
611 948
 		    <!--<li><?php echo _("Aircraft icon color:"); ?>-->
612
-			<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'; ?>">
949
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
950
+	print $_COOKIE['IconColor'];
951
+} elseif (isset($globalAircraftIconColor)) {
952
+	print $globalAircraftIconColor;
953
+} else {
954
+	print 'ff0000';
955
+}
956
+?>">
613 957
 		    </li>
614 958
 <?php
615 959
 	}
@@ -617,9 +961,19 @@  discard block
 block discarded – undo
617 961
 <?php
618 962
 	if (isset($globalMarine) && $globalMarine === TRUE) {
619 963
 ?>
620
-		    <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"); ?>&nbsp;
964
+		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="MarineiconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') {
965
+	print 'checked';
966
+}
967
+?> ><?php echo _("Force Marine color"); ?>&nbsp;
621 968
 		    <!--<li><?php echo _("Marine icon color:"); ?>-->
622
-			<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'; ?>">
969
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
970
+	print $_COOKIE['MarineIconColor'];
971
+} elseif (isset($globalMarineIconColor)) {
972
+	print $globalMarineIconColor;
973
+} else {
974
+	print 'ff0000';
975
+}
976
+?>">
623 977
 		    </li>
624 978
 <?php
625 979
 	}
@@ -627,9 +981,19 @@  discard block
 block discarded – undo
627 981
 <?php
628 982
 	if (isset($globalTracker) && $globalTracker === TRUE) {
629 983
 ?>
630
-		    <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"); ?>&nbsp;
984
+		    <li><input type="checkbox" name="trackercolorforce" value="1" onclick="TrackericonColorForce(this)" <?php if (isset($_COOKIE['TrackerIconColorForce']) && $_COOKIE['TrackerIconColorForce'] == 'true') {
985
+	print 'checked';
986
+}
987
+?> ><?php echo _("Force Tracker color"); ?>&nbsp;
631 988
 		    <!--<li><?php echo _("Tracker icon color:"); ?>-->
632
-			<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'; ?>">
989
+			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) {
990
+	print $_COOKIE['TrackerIconColor'];
991
+} elseif (isset($globalTrackerIconColor)) {
992
+	print $globalTrackerIconColor;
993
+} else {
994
+	print 'ff0000';
995
+}
996
+?>">
633 997
 		    </li>
634 998
 <?php
635 999
 	}
@@ -637,29 +1001,62 @@  discard block
 block discarded – undo
637 1001
 ?>
638 1002
 		    <li><?php echo _("Distance unit:"); ?>
639 1003
 			<select class="selectpicker" onchange="unitdistance(this);">
640
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
641
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
642
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
1004
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1005
+	echo ' selected';
1006
+}
1007
+?>>km</option>
1008
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1009
+	echo ' selected';
1010
+}
1011
+?>>nm</option>
1012
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1013
+	echo ' selected';
1014
+}
1015
+?>>mi</option>
643 1016
 		        </select>
644 1017
 		    </li>
645 1018
 		    <li><?php echo _("Altitude unit:"); ?>
646 1019
 			<select class="selectpicker" onchange="unitaltitude(this);">
647
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
648
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
1020
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
1021
+	echo ' selected';
1022
+}
1023
+?>>m</option>
1024
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
1025
+	echo ' selected';
1026
+}
1027
+?>>feet</option>
649 1028
 		        </select>
650 1029
 		    </li>
651 1030
 		    <li><?php echo _("Speed unit:"); ?>
652 1031
 			<select class="selectpicker" onchange="unitspeed(this);">
653
-			    <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>
654
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
655
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
1032
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
1033
+	echo ' selected';
1034
+}
1035
+?>>km/h</option>
1036
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
1037
+	echo ' selected';
1038
+}
1039
+?>>mph</option>
1040
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
1041
+	echo ' selected';
1042
+}
1043
+?>>knots</option>
656 1044
 		        </select>
657 1045
 		    </li>
658 1046
 		    <li><?php echo _("Coordinate unit:"); ?>
659 1047
 			<select class="selectpicker" onchange="unitcoordinate(this);">
660
-			    <option value="dd"<?php if ((!isset($_COOKIE['unitcoordinate']) && (!isset($globalUnitCoordinate) || (isset($globalUnitCoordinate) && $globalUnitCoordinate == 'dd'))) || (isset($_COOKIE['unitcoordinate']) && $_COOKIE['unitcoordinate'] == 'dd')) echo ' selected'; ?>>DD</option>
661
-			    <option value="dms"<?php if ((!isset($_COOKIE['unitcoordinate']) && isset($globalUnitCoordinate) && $globalUnitCoordinate == 'dms') || (isset($_COOKIE['unitcoordinate']) && $_COOKIE['unitcoordinate'] == 'dms')) echo ' selected'; ?>>DMS</option>
662
-			    <option value="dm"<?php if ((!isset($_COOKIE['unitcoordinate']) && isset($globalUnitCoordinate) && $globalUnitCoordinate == 'dm') || (isset($_COOKIE['unitcoordinate']) && $_COOKIE['unitcoordinate'] == 'dm')) echo ' selected'; ?>>DM</option>
1048
+			    <option value="dd"<?php if ((!isset($_COOKIE['unitcoordinate']) && (!isset($globalUnitCoordinate) || (isset($globalUnitCoordinate) && $globalUnitCoordinate == 'dd'))) || (isset($_COOKIE['unitcoordinate']) && $_COOKIE['unitcoordinate'] == 'dd')) {
1049
+	echo ' selected';
1050
+}
1051
+?>>DD</option>
1052
+			    <option value="dms"<?php if ((!isset($_COOKIE['unitcoordinate']) && isset($globalUnitCoordinate) && $globalUnitCoordinate == 'dms') || (isset($_COOKIE['unitcoordinate']) && $_COOKIE['unitcoordinate'] == 'dms')) {
1053
+	echo ' selected';
1054
+}
1055
+?>>DMS</option>
1056
+			    <option value="dm"<?php if ((!isset($_COOKIE['unitcoordinate']) && isset($globalUnitCoordinate) && $globalUnitCoordinate == 'dm') || (isset($_COOKIE['unitcoordinate']) && $_COOKIE['unitcoordinate'] == 'dm')) {
1057
+	echo ' selected';
1058
+}
1059
+?>>DM</option>
663 1060
 		        </select>
664 1061
 		    </li>
665 1062
 
@@ -677,9 +1074,18 @@  discard block
 block discarded – undo
677 1074
 		    <?php
678 1075
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
679 1076
 		    ?>
680
-			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') || !isset($_COOKIE['filter_ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
681
-			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') || !isset($_COOKIE['filter_ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
682
-			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') || !isset($_COOKIE['filter_ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
1077
+			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') || !isset($_COOKIE['filter_ShowVATSIM'])) {
1078
+	print 'checked';
1079
+}
1080
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
1081
+			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') || !isset($_COOKIE['filter_ShowIVAO'])) {
1082
+	print 'checked';
1083
+}
1084
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
1085
+			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') || !isset($_COOKIE['filter_ShowVMS'])) {
1086
+	print 'checked';
1087
+}
1088
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
683 1089
 		    <?php
684 1090
 			}
685 1091
 		    ?>
@@ -687,12 +1093,21 @@  discard block
 block discarded – undo
687 1093
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
688 1094
 		    ?>
689 1095
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
690
-			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') || !isset($_COOKIE['filter_ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
1096
+			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') || !isset($_COOKIE['filter_ShowSBS1'])) {
1097
+	print 'checked';
1098
+}
1099
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
691 1100
 			<?php } ?>
692 1101
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
693
-			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') || !isset($_COOKIE['filter_ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li>
1102
+			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') || !isset($_COOKIE['filter_ShowAPRS'])) {
1103
+	print 'checked';
1104
+}
1105
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
694 1106
 			<?php } ?>
695
-			<li><div class="checkbox"><label><input type="checkbox" name="blocked" value="1" onclick="clickBlocked(this)" <?php if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') print 'checked'; ?> ><?php echo _("Only display FAA ASDI blocked aircrafts"); ?></label></div></li>
1107
+			<li><div class="checkbox"><label><input type="checkbox" name="blocked" value="1" onclick="clickBlocked(this)" <?php if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') {
1108
+	print 'checked';
1109
+}
1110
+?> ><?php echo _("Only display FAA ASDI blocked aircrafts"); ?></label></div></li>
696 1111
 		    <?php
697 1112
 			}
698 1113
 		    ?>
@@ -708,7 +1123,9 @@  discard block
 block discarded – undo
708 1123
 				}
709 1124
 				foreach($allairlinenames as $airline) {
710 1125
 					$airline_name = $airline['airline_name'];
711
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
1126
+					if (strlen($airline_name) > 30) {
1127
+						$airline_name = substr($airline_name,0,30).'...';
1128
+					}
712 1129
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
713 1130
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
714 1131
 					} else {
@@ -726,7 +1143,10 @@  discard block
 block discarded – undo
726 1143
 		    <li><?php echo _("Display alliance:"); ?>
727 1144
 		    <br/>
728 1145
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
729
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
1146
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
1147
+	echo ' selected';
1148
+}
1149
+?>><?php echo _("All"); ?></option>
730 1150
 			    <?php
731 1151
 				foreach($allalliancenames as $alliance) {
732 1152
 					$alliance_name = $alliance['alliance'];
@@ -785,10 +1205,22 @@  discard block
 block discarded – undo
785 1205
 		    ?>
786 1206
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
787 1207
 			<select class="selectpicker" onchange="airlinestype(this);">
788
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
789
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
790
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
791
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
1208
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
1209
+	echo ' selected';
1210
+}
1211
+?>><?php echo _("All"); ?></option>
1212
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
1213
+	echo ' selected';
1214
+}
1215
+?>><?php echo _("Passenger"); ?></option>
1216
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
1217
+	echo ' selected';
1218
+}
1219
+?>><?php echo _("Cargo"); ?></option>
1220
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
1221
+	echo ' selected';
1222
+}
1223
+?>><?php echo _("Military"); ?></option>
792 1224
 			</select>
793 1225
 		    </li>
794 1226
 		    <?php
@@ -802,7 +1234,10 @@  discard block
 block discarded – undo
802 1234
 		    ?>
803 1235
 		    <li>
804 1236
 			<?php echo _("Display vessels with MMSI:"); ?>
805
-			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" />
1237
+			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) {
1238
+	print $_COOKIE['filter_mmsi'];
1239
+}
1240
+?>" />
806 1241
 		    </li>
807 1242
 			<?php
808 1243
 				if (isset($globalVM) && $globalVM) {
@@ -833,7 +1268,10 @@  discard block
 block discarded – undo
833 1268
 		    ?>
834 1269
 		    <li>
835 1270
 			<?php echo _("Display with ident:"); ?>
836
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
1271
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
1272
+	print $_COOKIE['filter_ident'];
1273
+}
1274
+?>" />
837 1275
 		    </li>
838 1276
 		</ul>
839 1277
 	    </form>
@@ -849,7 +1287,10 @@  discard block
 block discarded – undo
849 1287
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
850 1288
 	    <form>
851 1289
 		<ul>
852
-		    <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>
1290
+		    <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'])) {
1291
+	print 'checked';
1292
+}
1293
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
853 1294
 		    <li><?php echo _("Type:"); ?>
854 1295
 			<select class="selectpicker" multiple onchange="sattypes(this);">
855 1296
 			    <?php
@@ -857,25 +1298,45 @@  discard block
 block discarded – undo
857 1298
 				$types = $Satellite->get_tle_types();
858 1299
 				foreach ($types as $type) {
859 1300
 					$type_name = $type['tle_type'];
860
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
861
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
862
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
863
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
864
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
865
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
866
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
867
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
868
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
869
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
870
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
871
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
872
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
873
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
874
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
875
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
876
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
877
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
878
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
1301
+					if ($type_name == 'musson') {
1302
+						$type_name = 'Russian LEO Navigation';
1303
+					} else if ($type_name == 'nnss') {
1304
+						$type_name = 'Navi Navigation Satellite System';
1305
+					} else if ($type_name == 'sbas') {
1306
+						$type_name = 'Satellite-Based Augmentation System';
1307
+					} else if ($type_name == 'glo-ops') {
1308
+						$type_name = 'Glonass Operational';
1309
+					} else if ($type_name == 'gps-ops') {
1310
+						$type_name = 'GPS Operational';
1311
+					} else if ($type_name == 'argos') {
1312
+						$type_name = 'ARGOS Data Collection System';
1313
+					} else if ($type_name == 'tdrss') {
1314
+						$type_name = 'Tracking and Data Relay Satellite System';
1315
+					} else if ($type_name == 'sarsat') {
1316
+						$type_name = 'Search & Rescue';
1317
+					} else if ($type_name == 'dmc') {
1318
+						$type_name = 'Disaster Monitoring';
1319
+					} else if ($type_name == 'resource') {
1320
+						$type_name = 'Earth Resources';
1321
+					} else if ($type_name == 'stations') {
1322
+						$type_name = 'Space Stations';
1323
+					} else if ($type_name == 'geo') {
1324
+						$type_name = 'Geostationary';
1325
+					} else if ($type_name == 'amateur') {
1326
+						$type_name = 'Amateur Radio';
1327
+					} else if ($type_name == 'x-comm') {
1328
+						$type_name = 'Experimental';
1329
+					} else if ($type_name == 'other-comm') {
1330
+						$type_name = 'Other Comm';
1331
+					} else if ($type_name == 'science') {
1332
+						$type_name = 'Space & Earth Science';
1333
+					} else if ($type_name == 'military') {
1334
+						$type_name = 'Miscellaneous Military';
1335
+					} else if ($type_name == 'radar') {
1336
+						$type_name = 'Radar Calibration';
1337
+					} else if ($type_name == 'tle-new') {
1338
+						$type_name = 'Last 30 days launches';
1339
+					}
879 1340
 					
880 1341
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
881 1342
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.
install/index.php 3 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -229,13 +229,13 @@  discard block
 block discarded – undo
229 229
 			<p>
230 230
 				<label for="siteurl">Site directory</label>
231 231
 				<?php
232
-				    // Try to detect site directory
233
-				    if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
232
+					// Try to detect site directory
233
+					if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
234 234
 					if (isset($_SERVER['REQUEST_URI'])) {
235 235
 						$URL = $_SERVER['REQUEST_URI'];
236 236
 						$globalURL = str_replace('/install','',str_replace('/install/','',str_replace('/install/index.php','',$URL)));
237 237
 					}
238
-				    }
238
+					}
239 239
 				?>
240 240
 				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
241 241
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
@@ -416,17 +416,17 @@  discard block
 block discarded – undo
416 416
 				</thead>
417 417
 				<tbody>
418 418
 		<?php
419
-		    if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
419
+			if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
420 420
 		?>
421 421
 		<!--
422 422
 		<?php
423
-			    require_once(dirname(__FILE__).'/../require/class.Connection.php');
424
-			    $Connection = new Connection();
423
+				require_once(dirname(__FILE__).'/../require/class.Connection.php');
424
+				$Connection = new Connection();
425 425
 		?>
426 426
 		-->
427 427
 		<?php
428 428
 			if ($Connection->db != NULL) {
429
-			    if ($Connection->tableExists('source_location')) {
429
+				if ($Connection->tableExists('source_location')) {
430 430
 				require_once(dirname(__FILE__).'/../require/class.Source.php');
431 431
 				$Source = new Source();
432 432
 				//$alllocations = $Source->getAllLocationInfo();
@@ -446,9 +446,9 @@  discard block
 block discarded – undo
446 446
 		
447 447
 		<?php
448 448
 				}
449
-			    }
449
+				}
450
+			}
450 451
 			}
451
-		    }
452 452
 		?>
453 453
 
454 454
 				<tr>
@@ -577,12 +577,12 @@  discard block
 block discarded – undo
577 577
 ?>
578 578
 							<tr>
579 579
 								<?php
580
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
580
+									if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
581 581
 								?>
582 582
 								<td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td>
583 583
 								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
584 584
 								<?php
585
-								    } else {
585
+									} else {
586 586
 									$hostport = explode(':',$source['host']);
587 587
 									if (isset($hostport[1])) {
588 588
 										$host = $hostport[0];
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 								<td><input type="text" name="host[]" value="<?php print $host; ?>" /></td>
596 596
 								<td><input type="text" name="port[]" class="col-xs-2" value="<?php print $port; ?>" /></td>
597 597
 								<?php
598
-								    }
598
+									}
599 599
 								?>
600 600
 								<td>
601 601
 									<select name="format[]">
@@ -740,9 +740,9 @@  discard block
 block discarded – undo
740 740
 			    </thead>
741 741
 			    <tbody>
742 742
 				<?php
743
-				    if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) {
743
+					if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) {
744 744
 					foreach ($globalNewsFeeds as $type => $feedslng) {
745
-					    foreach ($feedslng as $lng => $feeds) {
745
+						foreach ($feedslng as $lng => $feeds) {
746 746
 						foreach ($feeds as $feed) {
747 747
 				?>
748 748
 				<tr>
@@ -767,9 +767,9 @@  discard block
 block discarded – undo
767 767
 				
768 768
 				<?php
769 769
 						}
770
-					    }
770
+						}
771
+					}
771 772
 					}
772
-				    }
773 773
 				?>
774 774
 				<tr>
775 775
 				    <td><input type="url" name="newsurl[]" /></td>
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
 				<p class="help-block">tsk file can be loaded using http://yourflightairmap/tsk=http://yourtskfile</p>
1185 1185
 			</p>
1186 1186
 			<?php 
1187
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
1187
+				if (extension_loaded('gd') && function_exists('gd_info')) {
1188 1188
 			?>
1189 1189
 			<br />
1190 1190
 			<p>
@@ -1215,14 +1215,14 @@  discard block
 block discarded – undo
1215 1215
 			</p>
1216 1216
 			<?php
1217 1217
 				}
1218
-			    } else {
1218
+				} else {
1219 1219
 			?>
1220 1220
 			<br />
1221 1221
 			<p>
1222 1222
 				<b>PHP GD is not installed, you can't change color of aircraft icon on map</b>
1223 1223
 			</p>
1224 1224
 			<?php
1225
-			    }
1225
+				}
1226 1226
 			?>
1227 1227
 			<br />
1228 1228
 			<p>
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 	</p>
1246 1246
 <?php
1247 1247
 	require('../footer.php');
1248
-        exit;
1248
+		exit;
1249 1249
 }
1250 1250
 // '	
1251 1251
 $settings = array();
@@ -1349,8 +1349,8 @@  discard block
 block discarded – undo
1349 1349
 	
1350 1350
 	$sources = array();
1351 1351
 	foreach ($source_name as $keys => $name) {
1352
-	    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]);
1353
-	    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]);
1352
+		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]);
1353
+		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]);
1354 1354
 	}
1355 1355
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1356 1356
 
@@ -1360,13 +1360,13 @@  discard block
 block discarded – undo
1360 1360
 	
1361 1361
 	$newsfeeds = array();
1362 1362
 	foreach($newsurl as $newskey => $url) {
1363
-	    if ($url != '') {
1363
+		if ($url != '') {
1364 1364
 		$type = $newstype[$newskey];
1365 1365
 		$lng = $newslng[$newskey];
1366 1366
 		if (isset($newsfeeds[$type][$lng])) {
1367
-		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1367
+			$newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1368 1368
 		} else $newsfeeds[$type][$lng] = array($url);
1369
-	    }
1369
+		}
1370 1370
 	}
1371 1371
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1372 1372
 
@@ -1847,14 +1847,14 @@  discard block
 block discarded – undo
1847 1847
 
1848 1848
 	// Set some defaults values...
1849 1849
 	if (!isset($globalAircraftImageSources)) {
1850
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1851
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1850
+		$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1851
+		$settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1852 1852
 	}
1853 1853
 
1854 1854
 	if (!isset($globalSchedulesSources)) {
1855
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1856
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1857
-    	}
1855
+		$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1856
+			$settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1857
+		}
1858 1858
 
1859 1859
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1860 1860
 
@@ -1902,21 +1902,21 @@  discard block
 block discarded – undo
1902 1902
 	$popi = false;
1903 1903
 	$popw = false;
1904 1904
 	foreach ($_SESSION['done'] as $done) {
1905
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1906
-	    if ($done == 'Create database') $pop = true;
1907
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1908
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1909
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1905
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1906
+		if ($done == 'Create database') $pop = true;
1907
+		if ($_SESSION['install'] == 'database_create') $pop = true;
1908
+		if ($_SESSION['install'] == 'database_import') $popi = true;
1909
+		if ($_SESSION['install'] == 'waypoints') $popw = true;
1910 1910
 	}
1911 1911
 	if ($pop) {
1912
-	    sleep(5);
1913
-	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1912
+		sleep(5);
1913
+		print '<li>Create database....<img src="../images/loading.gif" /></li>';
1914 1914
 	} else if ($popi) {
1915
-	    sleep(5);
1916
-	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1915
+		sleep(5);
1916
+		print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1917 1917
 	} else if ($popw) {
1918
-	    sleep(5);
1919
-	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1918
+		sleep(5);
1919
+		print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1920 1920
 	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1921 1921
 	print '</div></ul>';
1922 1922
 	print '<div id="error"></div>';
@@ -1983,7 +1983,7 @@  discard block
 block discarded – undo
1983 1983
 	unset($_COOKIE['install']);
1984 1984
 	print '<div class="info column"><ul>';
1985 1985
 	foreach ($_SESSION['done'] as $done) {
1986
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1986
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1987 1987
 	}
1988 1988
 	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1989 1989
 	print '</ul></div>';
Please login to merge, or discard this patch.
Spacing   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 require_once(dirname(__FILE__).'/class.create_db.php');
24 24
 require_once(dirname(__FILE__).'/class.update_schema.php');
25 25
 require_once(dirname(__FILE__).'/class.settings.php');
26
-$title="Install";
26
+$title = "Install";
27 27
 require(dirname(__FILE__).'/../require/settings.php');
28 28
 require_once(dirname(__FILE__).'/../require/class.Common.php');
29 29
 require(dirname(__FILE__).'/header.php');
30 30
 
31 31
 if (!isset($_SESSION['install']) && !isset($_SESSION['identified'])) {
32
-	$password = filter_input(INPUT_POST,'password',FILTER_SANITIZE_STRING);
32
+	$password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
33 33
 	if ($password == '') {
34 34
 		if ($globalInstalled === TRUE && (!isset($globalInstallPassword) || $globalInstallPassword == '')) {
35 35
 			print '<div class="alert alert-danger">You need to change $globalInstalled in settings.php to FALSE if you want to access setup again.</div>';
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	if (!file_exists(dirname(__FILE__).'/../.htaccess')) {
111 111
 		$error[] = dirname(__FILE__).'/../.htaccess'." doesn't exist. The provided .htaccess must exist if you use Apache.";
112 112
 	}
113
-	if(function_exists('apache_get_modules') ){
114
-		if(!in_array('mod_rewrite',apache_get_modules())) {
113
+	if (function_exists('apache_get_modules')) {
114
+		if (!in_array('mod_rewrite', apache_get_modules())) {
115 115
 			$error[] = "mod_rewrite is not available.";
116 116
 		}
117 117
 	/*
@@ -130,22 +130,22 @@  discard block
 block discarded – undo
130 130
 		$alllng = $Language->listLocaleDir();
131 131
 		if (count($alllng) != count($availablelng)) {
132 132
 			$notavailable = array();
133
-			foreach($alllng as $lng) {
133
+			foreach ($alllng as $lng) {
134 134
 				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
135 135
 			}
136
-			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
136
+			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ', $notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
137 137
 		}
138 138
 	}
139 139
 	print '<div class="alert alert-info">If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some tables can fail.</div>';
140 140
 	if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
141 141
 		if (function_exists('get_headers')) {
142 142
 			//$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
143
-			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'live/geojson?test',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
144
-			if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
143
+			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/', 'install'), 'live/geojson?test', str_replace('index.php', '', $_SERVER["REQUEST_URI"])));
144
+			if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
145 145
 				print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
146 146
 			} else {
147
-				$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
148
-				if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
147
+				$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/', 'install'), 'search', str_replace('index.php', '', $_SERVER["REQUEST_URI"])));
148
+				if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
149 149
 					print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
150 150
 				}
151 151
 			}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 				    if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
234 234
 					if (isset($_SERVER['REQUEST_URI'])) {
235 235
 						$URL = $_SERVER['REQUEST_URI'];
236
-						$globalURL = str_replace('/install','',str_replace('/install/','',str_replace('/install/index.php','',$URL)));
236
+						$globalURL = str_replace('/install', '', str_replace('/install/', '', str_replace('/install/index.php', '', $URL)));
237 237
 					}
238 238
 				    }
239 239
 				?>
@@ -577,13 +577,13 @@  discard block
 block discarded – undo
577 577
 ?>
578 578
 							<tr>
579 579
 								<?php
580
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
580
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
581 581
 								?>
582 582
 								<td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td>
583 583
 								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
584 584
 								<?php
585 585
 								    } else {
586
-									$hostport = explode(':',$source['host']);
586
+									$hostport = explode(':', $source['host']);
587 587
 									if (isset($hostport[1])) {
588 588
 										$host = $hostport[0];
589 589
 										$port = $hostport[1];
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 									<select name="timezones[]">
635 635
 								<?php
636 636
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
637
-									foreach($timezonelist as $timezones){
637
+									foreach ($timezonelist as $timezones) {
638 638
 										if (isset($source['timezone']) && $source['timezone'] == $timezones) {
639 639
 											print '<option selected>'.$timezones.'</option>';
640 640
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 									<select name="timezones[]" id="timezones">
691 691
 								<?php
692 692
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
693
-									foreach($timezonelist as $timezones){
693
+									foreach ($timezonelist as $timezones) {
694 694
 										if ($timezones == 'UTC') {
695 695
 											print '<option selected>'.$timezones.'</option>';
696 696
 										} else print '<option>'.$timezones.'</option>';
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
 			<br />
1171 1171
 			<p>
1172 1172
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1173
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1173
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
1174 1174
 			</p>
1175 1175
 			<br />
1176 1176
 			<p>
@@ -1253,17 +1253,17 @@  discard block
 block discarded – undo
1253 1253
 $error = '';
1254 1254
 
1255 1255
 if (isset($_POST['dbtype'])) {
1256
-	$installpass = filter_input(INPUT_POST,'installpass',FILTER_SANITIZE_STRING);
1257
-	$settings = array_merge($settings,array('globalInstallPassword' => $installpass));
1256
+	$installpass = filter_input(INPUT_POST, 'installpass', FILTER_SANITIZE_STRING);
1257
+	$settings = array_merge($settings, array('globalInstallPassword' => $installpass));
1258 1258
 
1259
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
1260
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
1261
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
1262
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
1263
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
1264
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
1265
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1266
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1259
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
1260
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
1261
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
1262
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
1263
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
1264
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
1265
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
1266
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
1267 1267
 
1268 1268
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1269 1269
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -1283,59 +1283,59 @@  discard block
 block discarded – undo
1283 1283
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1284 1284
 	*/
1285 1285
 	
1286
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1286
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
1287 1287
 
1288
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
1289
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
1290
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
1291
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
1292
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
1288
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
1289
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
1290
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
1291
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
1292
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
1293 1293
 
1294
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
1295
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
1296
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
1297
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
1298
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
1299
-	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
1300
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
1301
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
1302
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
1303
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
1294
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
1295
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
1296
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
1297
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
1298
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
1299
+	$openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING);
1300
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
1301
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
1302
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
1303
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey));
1304 1304
 	
1305
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
1306
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
1307
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
1308
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
1309
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
1310
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
1305
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
1306
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
1307
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
1308
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
1309
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
1310
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
1311 1311
 
1312
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
1313
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
1312
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
1313
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
1314 1314
 
1315
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
1316
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
1317
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
1315
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
1316
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
1317
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
1318 1318
 
1319
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
1319
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
1320 1320
 	if ($acars == 'acars') {
1321
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
1321
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
1322 1322
 	} else {
1323
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
1323
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
1324 1324
 	}
1325
-	$updatecheck = filter_input(INPUT_POST,'updatecheck',FILTER_SANITIZE_STRING);
1325
+	$updatecheck = filter_input(INPUT_POST, 'updatecheck', FILTER_SANITIZE_STRING);
1326 1326
 	if ($updatecheck == 'updatecheck') {
1327
-		$settings = array_merge($settings,array('globalDisableUpdateCheck' => 'TRUE'));
1327
+		$settings = array_merge($settings, array('globalDisableUpdateCheck' => 'TRUE'));
1328 1328
 	} else {
1329
-		$settings = array_merge($settings,array('globalDisableUpdateCheck' => 'FALSE'));
1329
+		$settings = array_merge($settings, array('globalDisableUpdateCheck' => 'FALSE'));
1330 1330
 	}
1331 1331
 
1332
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
1333
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
1334
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
1332
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
1333
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
1334
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
1335 1335
 	
1336
-	$sailawayemail = filter_input(INPUT_POST,'sailawayemail',FILTER_SANITIZE_STRING);
1337
-	$sailawaypass = filter_input(INPUT_POST,'sailawaypassword',FILTER_SANITIZE_STRING);
1338
-	$settings = array_merge($settings,array('globalSailaway' => array('email' => $sailawayemail,'password' => $sailawaypass)));
1336
+	$sailawayemail = filter_input(INPUT_POST, 'sailawayemail', FILTER_SANITIZE_STRING);
1337
+	$sailawaypass = filter_input(INPUT_POST, 'sailawaypassword', FILTER_SANITIZE_STRING);
1338
+	$settings = array_merge($settings, array('globalSailaway' => array('email' => $sailawayemail, 'password' => $sailawaypass)));
1339 1339
 	
1340 1340
 	$source_name = $_POST['source_name'];
1341 1341
 	$source_latitude = $_POST['source_latitude'];
@@ -1349,8 +1349,8 @@  discard block
 block discarded – undo
1349 1349
 	
1350 1350
 	$sources = array();
1351 1351
 	foreach ($source_name as $keys => $name) {
1352
-	    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]);
1353
-	    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]);
1352
+	    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]);
1353
+	    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]);
1354 1354
 	}
1355 1355
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1356 1356
 
@@ -1359,16 +1359,16 @@  discard block
 block discarded – undo
1359 1359
 	$newstype = $_POST['newstype'];
1360 1360
 	
1361 1361
 	$newsfeeds = array();
1362
-	foreach($newsurl as $newskey => $url) {
1362
+	foreach ($newsurl as $newskey => $url) {
1363 1363
 	    if ($url != '') {
1364 1364
 		$type = $newstype[$newskey];
1365 1365
 		$lng = $newslng[$newskey];
1366 1366
 		if (isset($newsfeeds[$type][$lng])) {
1367
-		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1367
+		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng], array($url));
1368 1368
 		} else $newsfeeds[$type][$lng] = array($url);
1369 1369
 	    }
1370 1370
 	}
1371
-	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1371
+	$settings = array_merge($settings, array('globalNewsFeeds' => $newsfeeds));
1372 1372
 
1373 1373
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1374 1374
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1379,28 +1379,28 @@  discard block
 block discarded – undo
1379 1379
 	$sbsurl = $_POST['sbsurl'];
1380 1380
 	*/
1381 1381
 
1382
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1383
-	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1384
-	$globalvm = filter_input(INPUT_POST,'globalvm',FILTER_SANITIZE_STRING);
1385
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1386
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1387
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1388
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1389
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1390
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1382
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
1383
+	$globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING);
1384
+	$globalvm = filter_input(INPUT_POST, 'globalvm', FILTER_SANITIZE_STRING);
1385
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
1386
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
1387
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
1388
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
1389
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
1390
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
1391 1391
 
1392
-	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1393
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1394
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1395
-	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1396
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1397
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1398
-	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1399
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1400
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1401
-	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1402
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1403
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1392
+	$globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING);
1393
+	if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE'));
1394
+	else $settings = array_merge($settings, array('globalAircraft' => 'FALSE'));
1395
+	$globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING);
1396
+	if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE'));
1397
+	else $settings = array_merge($settings, array('globalTracker' => 'FALSE'));
1398
+	$globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING);
1399
+	if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE'));
1400
+	else $settings = array_merge($settings, array('globalMarine' => 'FALSE'));
1401
+	$globalsatellite = filter_input(INPUT_POST, 'globalsatellite', FILTER_SANITIZE_STRING);
1402
+	if ($globalsatellite == 'satellite') $settings = array_merge($settings, array('globalSatellite' => 'TRUE'));
1403
+	else $settings = array_merge($settings, array('globalSatellite' => 'FALSE'));
1404 1404
 
1405 1405
 /*	
1406 1406
 	$globalSBS1Hosts = array();
@@ -1416,7 +1416,7 @@  discard block
 block discarded – undo
1416 1416
 	}
1417 1417
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1418 1418
 */
1419
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1419
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
1420 1420
 	$host = $_POST['host'];
1421 1421
 	$port = $_POST['port'];
1422 1422
 	$name = $_POST['name'];
@@ -1433,115 +1433,115 @@  discard block
 block discarded – undo
1433 1433
 		else $cov = 'FALSE';
1434 1434
 		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1435 1435
 		else $arch = 'FALSE';
1436
-		if (strpos($format[$key],'_callback')) {
1437
-			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1436
+		if (strpos($format[$key], '_callback')) {
1437
+			$gSources[] = array('host' => $h, 'pass' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'TRUE');
1438 1438
 		} elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) {
1439
-			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1439
+			$gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'FALSE');
1440 1440
 		}
1441 1441
 		if ($format[$key] == 'airwhere') $forcepilots = true;
1442 1442
 	}
1443
-	$settings = array_merge($settings,array('globalSources' => $gSources));
1443
+	$settings = array_merge($settings, array('globalSources' => $gSources));
1444 1444
 
1445 1445
 /*
1446 1446
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1447 1447
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1448 1448
 */
1449
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1450
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1451
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1449
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
1450
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
1451
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
1452 1452
 
1453
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1454
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1453
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
1454
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
1455 1455
 
1456
-	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1457
-	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1456
+	$customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING);
1457
+	$settings = array_merge($settings, array('globalCustomCSS' => $customcss));
1458 1458
 
1459
-	$map3dtile = filter_input(INPUT_POST,'map3dtileset',FILTER_SANITIZE_STRING);
1460
-	$settings = array_merge($settings,array('globalMap3DTiles' => $map3dtile));
1459
+	$map3dtile = filter_input(INPUT_POST, 'map3dtileset', FILTER_SANITIZE_STRING);
1460
+	$settings = array_merge($settings, array('globalMap3DTiles' => $map3dtile));
1461 1461
 
1462
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1463
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1464
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1465
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1462
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
1463
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
1464
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
1465
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
1466 1466
 
1467
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1468
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1469
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1467
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
1468
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
1469
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
1470 1470
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1471
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1472
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1471
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
1472
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
1473 1473
 
1474
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1475
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1476
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1477
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1478
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1479
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1480
-	$minfetch = filter_input(INPUT_POST,'minfetch',FILTER_SANITIZE_NUMBER_INT);
1481
-	$settings = array_merge($settings,array('globalMinFetch' => $minfetch));
1482
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1483
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1474
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
1475
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
1476
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
1477
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
1478
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1479
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1480
+	$minfetch = filter_input(INPUT_POST, 'minfetch', FILTER_SANITIZE_NUMBER_INT);
1481
+	$settings = array_merge($settings, array('globalMinFetch' => $minfetch));
1482
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1483
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1484 1484
 
1485
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1486
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1485
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1486
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1487 1487
 
1488
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1489
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1488
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1489
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1490 1490
 	
1491
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1491
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1492 1492
 	if ($archiveyear == "archiveyear") {
1493
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1493
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1494 1494
 	} else {
1495
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1495
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1496 1496
 	}
1497
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1498
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1499
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1500
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1497
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1498
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1499
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1500
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1501 1501
 
1502
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1503
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1504
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1505
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1502
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1503
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1504
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1505
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1506 1506
 
1507
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1508
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1509
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1507
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1508
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1509
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1510 1510
 
1511 1511
 	// Create in settings.php keys not yet configurable if not already here
1512 1512
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1513
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1513
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1514 1514
 
1515
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1515
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1516 1516
 	if ($resetyearstats == 'resetyearstats') {
1517
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1517
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1518 1518
 	} else {
1519
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1519
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1520 1520
 	}
1521 1521
 
1522
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1522
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1523 1523
 	if ($archive == 'archive') {
1524
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1524
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1525 1525
 	} else {
1526
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1526
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1527 1527
 	}
1528
-	$archiveresults = filter_input(INPUT_POST,'archiveresults',FILTER_SANITIZE_STRING);
1528
+	$archiveresults = filter_input(INPUT_POST, 'archiveresults', FILTER_SANITIZE_STRING);
1529 1529
 	if ($archiveresults == 'archiveresults') {
1530
-		$settings = array_merge($settings,array('globalArchiveResults' => 'TRUE'));
1530
+		$settings = array_merge($settings, array('globalArchiveResults' => 'TRUE'));
1531 1531
 	} else {
1532
-		$settings = array_merge($settings,array('globalArchiveResults' => 'FALSE'));
1532
+		$settings = array_merge($settings, array('globalArchiveResults' => 'FALSE'));
1533 1533
 	}
1534
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1534
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1535 1535
 	if ($daemon == 'daemon') {
1536
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1536
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1537 1537
 	} else {
1538
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1538
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1539 1539
 	}
1540
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1540
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1541 1541
 	if ($schedules == 'schedules') {
1542
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1542
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1543 1543
 	} else {
1544
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1544
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1545 1545
 	}
1546 1546
 
1547 1547
 /*
@@ -1552,311 +1552,311 @@  discard block
 block discarded – undo
1552 1552
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1553 1553
 	}
1554 1554
 */
1555
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1556
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1557
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1558
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1559
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1555
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1556
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1557
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1558
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1559
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1560 1560
 	$va = false;
1561 1561
 	if ($globalivao == 'ivao') {
1562
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1562
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1563 1563
 		$va = true;
1564
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1564
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1565 1565
 	if ($globalvatsim == 'vatsim') {
1566
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1566
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1567 1567
 		$va = true;
1568
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1568
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1569 1569
 	if ($globalphpvms == 'phpvms') {
1570
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1570
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1571 1571
 		$va = true;
1572
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1572
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1573 1573
 	if ($globalvam == 'vam') {
1574
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1574
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1575 1575
 		$va = true;
1576
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1576
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1577 1577
 	if ($va) {
1578
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1579
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1578
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1579
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1580 1580
 	if ($globalva == 'va' || $va) {
1581
-		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1582
-		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1581
+		$settings = array_merge($settings, array('globalVA' => 'TRUE'));
1582
+		$settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1583 1583
 	} else {
1584
-		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1585
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1586
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1584
+		$settings = array_merge($settings, array('globalVA' => 'FALSE'));
1585
+		if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1586
+		else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE'));
1587 1587
 	}
1588 1588
 	if ($globalvm == 'vm') {
1589
-		$settings = array_merge($settings,array('globalVM' => 'TRUE'));
1589
+		$settings = array_merge($settings, array('globalVM' => 'TRUE'));
1590 1590
 	} else {
1591
-		$settings = array_merge($settings,array('globalVM' => 'FALSE'));
1591
+		$settings = array_merge($settings, array('globalVM' => 'FALSE'));
1592 1592
 	}
1593 1593
 	
1594
-	$mapoffline = filter_input(INPUT_POST,'mapoffline',FILTER_SANITIZE_STRING);
1594
+	$mapoffline = filter_input(INPUT_POST, 'mapoffline', FILTER_SANITIZE_STRING);
1595 1595
 	if ($mapoffline == 'mapoffline') {
1596
-		$settings = array_merge($settings,array('globalMapOffline' => 'TRUE'));
1596
+		$settings = array_merge($settings, array('globalMapOffline' => 'TRUE'));
1597 1597
 	} else {
1598
-		$settings = array_merge($settings,array('globalMapOffline' => 'FALSE'));
1598
+		$settings = array_merge($settings, array('globalMapOffline' => 'FALSE'));
1599 1599
 	}
1600
-	$globaloffline = filter_input(INPUT_POST,'globaloffline',FILTER_SANITIZE_STRING);
1600
+	$globaloffline = filter_input(INPUT_POST, 'globaloffline', FILTER_SANITIZE_STRING);
1601 1601
 	if ($globaloffline == 'globaloffline') {
1602
-		$settings = array_merge($settings,array('globalOffline' => 'TRUE'));
1602
+		$settings = array_merge($settings, array('globalOffline' => 'TRUE'));
1603 1603
 	} else {
1604
-		$settings = array_merge($settings,array('globalOffline' => 'FALSE'));
1604
+		$settings = array_merge($settings, array('globalOffline' => 'FALSE'));
1605 1605
 	}
1606 1606
 
1607
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1607
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1608 1608
 	if ($notam == 'notam') {
1609
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1609
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1610 1610
 	} else {
1611
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1611
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1612 1612
 	}
1613
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1613
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1614 1614
 	if ($owner == 'owner') {
1615
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1615
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1616 1616
 	} else {
1617
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1617
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1618 1618
 	}
1619
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1619
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1620 1620
 	if ($map3d == 'map3d') {
1621
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1621
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1622 1622
 	} else {
1623
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1623
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1624 1624
 	}
1625
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1625
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1626 1626
 	if ($crash == 'crash') {
1627
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1627
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1628 1628
 	} else {
1629
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1629
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1630 1630
 	}
1631
-	$fires = filter_input(INPUT_POST,'fires',FILTER_SANITIZE_STRING);
1631
+	$fires = filter_input(INPUT_POST, 'fires', FILTER_SANITIZE_STRING);
1632 1632
 	if ($fires == 'fires') {
1633
-		$settings = array_merge($settings,array('globalMapFires' => 'TRUE'));
1633
+		$settings = array_merge($settings, array('globalMapFires' => 'TRUE'));
1634 1634
 	} else {
1635
-		$settings = array_merge($settings,array('globalMapFires' => 'FALSE'));
1635
+		$settings = array_merge($settings, array('globalMapFires' => 'FALSE'));
1636 1636
 	}
1637
-	$firessupport = filter_input(INPUT_POST,'firessupport',FILTER_SANITIZE_STRING);
1637
+	$firessupport = filter_input(INPUT_POST, 'firessupport', FILTER_SANITIZE_STRING);
1638 1638
 	if ($firessupport == 'firessupport') {
1639
-		$settings = array_merge($settings,array('globalFires' => 'TRUE'));
1639
+		$settings = array_merge($settings, array('globalFires' => 'TRUE'));
1640 1640
 	} else {
1641
-		$settings = array_merge($settings,array('globalFires' => 'FALSE'));
1641
+		$settings = array_merge($settings, array('globalFires' => 'FALSE'));
1642 1642
 	}
1643
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1643
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1644 1644
 	if ($mapsatellites == 'mapsatellites') {
1645
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1645
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1646 1646
 	} else {
1647
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1647
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1648 1648
 	}
1649
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1649
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1650 1650
 	if ($map3ddefault == 'map3ddefault') {
1651
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1651
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1652 1652
 	} else {
1653
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1653
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1654 1654
 	}
1655
-	$one3dmodel = filter_input(INPUT_POST,'one3dmodel',FILTER_SANITIZE_STRING);
1655
+	$one3dmodel = filter_input(INPUT_POST, 'one3dmodel', FILTER_SANITIZE_STRING);
1656 1656
 	if ($one3dmodel == 'one3dmodel') {
1657
-		$settings = array_merge($settings,array('globalMap3DOneModel' => 'TRUE'));
1657
+		$settings = array_merge($settings, array('globalMap3DOneModel' => 'TRUE'));
1658 1658
 	} else {
1659
-		$settings = array_merge($settings,array('globalMap3DOneModel' => 'FALSE'));
1659
+		$settings = array_merge($settings, array('globalMap3DOneModel' => 'FALSE'));
1660 1660
 	}
1661
-	$map3dliveries = filter_input(INPUT_POST,'map3dliveries',FILTER_SANITIZE_STRING);
1661
+	$map3dliveries = filter_input(INPUT_POST, 'map3dliveries', FILTER_SANITIZE_STRING);
1662 1662
 	if ($map3dliveries == 'map3dliveries') {
1663
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'TRUE'));
1663
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'TRUE'));
1664 1664
 	} else {
1665
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'FALSE'));
1665
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'FALSE'));
1666 1666
 	}
1667
-	$map3dshadows = filter_input(INPUT_POST,'map3dshadows',FILTER_SANITIZE_STRING);
1667
+	$map3dshadows = filter_input(INPUT_POST, 'map3dshadows', FILTER_SANITIZE_STRING);
1668 1668
 	if ($map3dshadows == 'map3dshadows') {
1669
-		$settings = array_merge($settings,array('globalMap3DShadows' => 'TRUE'));
1669
+		$settings = array_merge($settings, array('globalMap3DShadows' => 'TRUE'));
1670 1670
 	} else {
1671
-		$settings = array_merge($settings,array('globalMap3DShadows' => 'FALSE'));
1671
+		$settings = array_merge($settings, array('globalMap3DShadows' => 'FALSE'));
1672 1672
 	}
1673
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1673
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1674 1674
 	if ($translate == 'translate') {
1675
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1675
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1676 1676
 	} else {
1677
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1677
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1678 1678
 	}
1679
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1679
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1680 1680
 	if ($realairlines == 'realairlines') {
1681
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1681
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1682 1682
 	} else {
1683
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1683
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1684 1684
 	}
1685
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1685
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1686 1686
 	if ($estimation == 'estimation') {
1687
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1687
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1688 1688
 	} else {
1689
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1689
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1690 1690
 	}
1691
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1691
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1692 1692
 	if ($metar == 'metar') {
1693
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1693
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1694 1694
 	} else {
1695
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1695
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1696 1696
 	}
1697
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1697
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1698 1698
 	if ($metarcycle == 'metarcycle') {
1699
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1699
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1700 1700
 	} else {
1701
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1701
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1702 1702
 	}
1703
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1703
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1704 1704
 	if ($fork == 'fork') {
1705
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1705
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1706 1706
 	} else {
1707
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1707
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1708 1708
 	}
1709 1709
 
1710
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1710
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1711 1711
 	if ($colormap == 'colormap') {
1712
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1712
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1713 1713
 	} else {
1714
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1714
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1715 1715
 	}
1716 1716
 	
1717 1717
 	if (isset($_POST['aircrafticoncolor'])) {
1718
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1719
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1718
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1719
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1720 1720
 	}
1721 1721
 	if (isset($_POST['marineiconcolor'])) {
1722
-		$marineiconcolor = filter_input(INPUT_POST,'marineiconcolor',FILTER_SANITIZE_STRING);
1723
-		$settings = array_merge($settings,array('globalMarineIconColor' => substr($marineiconcolor,1)));
1722
+		$marineiconcolor = filter_input(INPUT_POST, 'marineiconcolor', FILTER_SANITIZE_STRING);
1723
+		$settings = array_merge($settings, array('globalMarineIconColor' => substr($marineiconcolor, 1)));
1724 1724
 	}
1725 1725
 	if (isset($_POST['trackericoncolor'])) {
1726
-		$trackericoncolor = filter_input(INPUT_POST,'trackericoncolor',FILTER_SANITIZE_STRING);
1727
-		$settings = array_merge($settings,array('globalTrackerIconColor' => substr($trackericoncolor,1)));
1726
+		$trackericoncolor = filter_input(INPUT_POST, 'trackericoncolor', FILTER_SANITIZE_STRING);
1727
+		$settings = array_merge($settings, array('globalTrackerIconColor' => substr($trackericoncolor, 1)));
1728 1728
 	}
1729 1729
 	if (isset($_POST['satelliteiconcolor'])) {
1730
-		$satelliteiconcolor = filter_input(INPUT_POST,'satelliteiconcolor',FILTER_SANITIZE_STRING);
1731
-		$settings = array_merge($settings,array('globalSatelliteIconColor' => substr($satelliteiconcolor,1)));
1730
+		$satelliteiconcolor = filter_input(INPUT_POST, 'satelliteiconcolor', FILTER_SANITIZE_STRING);
1731
+		$settings = array_merge($settings, array('globalSatelliteIconColor' => substr($satelliteiconcolor, 1)));
1732 1732
 	}
1733 1733
 
1734
-	$corsproxy = filter_input(INPUT_POST,'corsproxy',FILTER_SANITIZE_STRING);
1735
-	$settings = array_merge($settings,array('globalCORSproxy' => $corsproxy));
1734
+	$corsproxy = filter_input(INPUT_POST, 'corsproxy', FILTER_SANITIZE_STRING);
1735
+	$settings = array_merge($settings, array('globalCORSproxy' => $corsproxy));
1736 1736
 
1737
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1738
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1737
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1738
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1739 1739
 
1740
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1741
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1742
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1743
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1744
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1745
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1740
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1741
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1742
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1743
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1744
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1745
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1746 1746
 
1747
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1747
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1748 1748
 	if ($mappopup == 'mappopup') {
1749
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1749
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1750 1750
 	} else {
1751
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1751
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1752 1752
 	}
1753
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1753
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1754 1754
 	if ($airportpopup == 'airportpopup') {
1755
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1755
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1756 1756
 	} else {
1757
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1757
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1758 1758
 	}
1759
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1759
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1760 1760
 	if ($maphistory == 'maphistory') {
1761
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1761
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1762 1762
 	} else {
1763
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1763
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1764 1764
 	}
1765
-	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1765
+	$maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING);
1766 1766
 	if ($maptooltip == 'maptooltip') {
1767
-		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1767
+		$settings = array_merge($settings, array('globalMapTooltip' => 'TRUE'));
1768 1768
 	} else {
1769
-		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1769
+		$settings = array_merge($settings, array('globalMapTooltip' => 'FALSE'));
1770 1770
 	}
1771
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1771
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1772 1772
 	if ($flightroute == 'flightroute') {
1773
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1773
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1774 1774
 	} else {
1775
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1775
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1776 1776
 	}
1777
-	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1777
+	$flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING);
1778 1778
 	if ($flightremainingroute == 'flightremainingroute') {
1779
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1779
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE'));
1780 1780
 	} else {
1781
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1781
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE'));
1782 1782
 	}
1783
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1783
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1784 1784
 	if ($allflights == 'allflights') {
1785
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1785
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1786 1786
 	} else {
1787
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1787
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1788 1788
 	}
1789
-	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1789
+	$bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING);
1790 1790
 	if ($bbox == 'bbox') {
1791
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1791
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE'));
1792 1792
 	} else {
1793
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1793
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE'));
1794 1794
 	}
1795
-	$singlemodel = filter_input(INPUT_POST,'singlemodel',FILTER_SANITIZE_STRING);
1795
+	$singlemodel = filter_input(INPUT_POST, 'singlemodel', FILTER_SANITIZE_STRING);
1796 1796
 	if ($singlemodel == 'singlemodel') {
1797
-		$settings = array_merge($settings,array('globalMap3DSelected' => 'TRUE'));
1797
+		$settings = array_merge($settings, array('globalMap3DSelected' => 'TRUE'));
1798 1798
 	} else {
1799
-		$settings = array_merge($settings,array('globalMap3DSelected' => 'FALSE'));
1799
+		$settings = array_merge($settings, array('globalMap3DSelected' => 'FALSE'));
1800 1800
 	}
1801
-	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1801
+	$groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING);
1802 1802
 	if ($groundaltitude == 'groundaltitude') {
1803
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1803
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE'));
1804 1804
 	} else {
1805
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1805
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE'));
1806 1806
 	}
1807
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1807
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1808 1808
 	if ($waypoints == 'waypoints') {
1809
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1809
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1810 1810
 	} else {
1811
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1811
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1812 1812
 	}
1813
-	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1813
+	$geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING);
1814 1814
 	if ($geoid == 'geoid') {
1815
-		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1815
+		$settings = array_merge($settings, array('globalGeoid' => 'TRUE'));
1816 1816
 	} else {
1817
-		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1817
+		$settings = array_merge($settings, array('globalGeoid' => 'FALSE'));
1818 1818
 	}
1819
-	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1820
-	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1819
+	$geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING);
1820
+	$settings = array_merge($settings, array('globalGeoidSource' => $geoid_source));
1821 1821
 
1822
-	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1822
+	$noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING);
1823 1823
 	if ($noairlines == 'noairlines') {
1824
-		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1824
+		$settings = array_merge($settings, array('globalNoAirlines' => 'TRUE'));
1825 1825
 	} else {
1826
-		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1826
+		$settings = array_merge($settings, array('globalNoAirlines' => 'FALSE'));
1827 1827
 	}
1828 1828
 
1829
-	$tsk = filter_input(INPUT_POST,'tsk',FILTER_SANITIZE_STRING);
1829
+	$tsk = filter_input(INPUT_POST, 'tsk', FILTER_SANITIZE_STRING);
1830 1830
 	if ($tsk == 'tsk') {
1831
-		$settings = array_merge($settings,array('globalTSK' => 'TRUE'));
1831
+		$settings = array_merge($settings, array('globalTSK' => 'TRUE'));
1832 1832
 	} else {
1833
-		$settings = array_merge($settings,array('globalTSK' => 'FALSE'));
1833
+		$settings = array_merge($settings, array('globalTSK' => 'FALSE'));
1834 1834
 	}
1835
-	$mapmatching = filter_input(INPUT_POST,'mapmatching',FILTER_SANITIZE_STRING);
1835
+	$mapmatching = filter_input(INPUT_POST, 'mapmatching', FILTER_SANITIZE_STRING);
1836 1836
 	if ($mapmatching == 'mapmatching') {
1837
-		$settings = array_merge($settings,array('globalMapMatching' => 'TRUE'));
1837
+		$settings = array_merge($settings, array('globalMapMatching' => 'TRUE'));
1838 1838
 	} else {
1839
-		$settings = array_merge($settings,array('globalMapMatching' => 'FALSE'));
1839
+		$settings = array_merge($settings, array('globalMapMatching' => 'FALSE'));
1840 1840
 	}
1841
-	$mapmatchingsource = filter_input(INPUT_POST,'mapmatchingsource',FILTER_SANITIZE_STRING);
1842
-	$settings = array_merge($settings,array('globalMapMatchingSource' => $mapmatchingsource));
1843
-	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1844
-	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1841
+	$mapmatchingsource = filter_input(INPUT_POST, 'mapmatchingsource', FILTER_SANITIZE_STRING);
1842
+	$settings = array_merge($settings, array('globalMapMatchingSource' => $mapmatchingsource));
1843
+	$graphhopper = filter_input(INPUT_POST, 'graphhopper', FILTER_SANITIZE_STRING);
1844
+	$settings = array_merge($settings, array('globalGraphHopperKey' => $graphhopper));
1845 1845
 
1846
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1846
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1847 1847
 
1848 1848
 	// Set some defaults values...
1849 1849
 	if (!isset($globalAircraftImageSources)) {
1850
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1851
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1850
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1851
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1852 1852
 	}
1853 1853
 
1854 1854
 	if (!isset($globalSchedulesSources)) {
1855
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1856
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1855
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1856
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1857 1857
     	}
1858 1858
 
1859
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1859
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1860 1860
 
1861 1861
 	if ($error == '') settings::modify_settings($settings);
1862 1862
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
Braces   +639 added lines, -170 removed lines patch added patch discarded remove patch
@@ -4,12 +4,22 @@  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
-	if (isset($_SESSION['identitied'])) unset($_SESSION['identified']);
12
-}
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
+	if (isset($_SESSION['identitied'])) {
20
+		unset($_SESSION['identified']);
21
+	}
22
+	}
13 23
 /*
14 24
 if (isset($_SESSION['errorlst'])) {
15 25
 	header('Content-Encoding: none;');
@@ -131,7 +141,9 @@  discard block
 block discarded – undo
131 141
 		if (count($alllng) != count($availablelng)) {
132 142
 			$notavailable = array();
133 143
 			foreach($alllng as $lng) {
134
-				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
144
+				if (!isset($availablelng[$lng])) {
145
+					$notavailable[] = $lng;
146
+				}
135 147
 			}
136 148
 			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
137 149
 		}
@@ -170,7 +182,10 @@  discard block
 block discarded – undo
170 182
 			<legend>Install script configuration</legend>
171 183
 			<p>
172 184
 				<label for="installpass">Install password</label>
173
-				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) print $globalInstallPassword; ?>" />
185
+				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) {
186
+	print $globalInstallPassword;
187
+}
188
+?>" />
174 189
 			</p>
175 190
 			<p class="help-block">Password needed to access this install script. If empty, to access this script,  you will need to change the $globalInstalled setting in require/settings.php to FALSE</p>
176 191
 		</fieldset>
@@ -200,31 +215,49 @@  discard block
 block discarded – undo
200 215
 			</div>
201 216
 			<p>
202 217
 				<label for="dbhost">Database hostname</label>
203
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
218
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
219
+	print $globalDBhost;
220
+}
221
+?>" />
204 222
 			</p>
205 223
 			<p>
206 224
 				<label for="dbport">Database port</label>
207
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
225
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
226
+	print $globalDBport;
227
+}
228
+?>" />
208 229
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
209 230
 			</p>
210 231
 			<p>
211 232
 				<label for="dbname">Database name</label>
212
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
233
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
234
+	print $globalDBname;
235
+}
236
+?>" />
213 237
 			</p>
214 238
 			<p>
215 239
 				<label for="dbuser">Database user</label>
216
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
240
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
241
+	print $globalDBuser;
242
+}
243
+?>" />
217 244
 			</p>
218 245
 			<p>
219 246
 				<label for="dbuserpass">Database user password</label>
220
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
247
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
248
+	print $globalDBpass;
249
+}
250
+?>" />
221 251
 			</p>
222 252
 		</fieldset>
223 253
 		<fieldset id="site">
224 254
 			<legend>Site configuration</legend>
225 255
 			<p>
226 256
 				<label for="sitename">Site name</label>
227
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
257
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
258
+	print $globalName;
259
+}
260
+?>" />
228 261
 			</p>
229 262
 			<p>
230 263
 				<label for="siteurl">Site directory</label>
@@ -237,18 +270,27 @@  discard block
 block discarded – undo
237 270
 					}
238 271
 				    }
239 272
 				?>
240
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
273
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
274
+	print $globalURL;
275
+}
276
+?>" />
241 277
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
242 278
 				<p class="help-block">Can be empty</p>
243 279
 			</p>
244 280
 			<p>
245 281
 				<label for="timezone">Timezone</label>
246
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
282
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
283
+	print $globalTimezone;
284
+}
285
+?>" />
247 286
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
248 287
 			</p>
249 288
 			<p>
250 289
 				<label for="language">Language</label>
251
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
290
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
291
+	print $globalLanguage;
292
+}
293
+?>" />
252 294
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
253 295
 			</p>
254 296
 		</fieldset>
@@ -268,11 +310,17 @@  discard block
 block discarded – undo
268 310
 			<div id="mapbox_data">
269 311
 				<p>
270 312
 					<label for="mapboxid">Mapbox id</label>
271
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
313
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
314
+	print $globalMapboxId;
315
+}
316
+?>" />
272 317
 				</p>
273 318
 				<p>
274 319
 					<label for="mapboxtoken">Mapbox token</label>
275
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
320
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
321
+	print $globalMapboxToken;
322
+}
323
+?>" />
276 324
 				</p>
277 325
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
278 326
 			</div>
@@ -280,7 +328,10 @@  discard block
 block discarded – undo
280 328
 			<div id="google_data">
281 329
 				<p>
282 330
 					<label for="googlekey">Google API key</label>
283
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
331
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
332
+	print $globalGoogleAPIKey;
333
+}
334
+?>" />
284 335
 					<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>
285 336
 				</p>
286 337
 			</div>
@@ -288,7 +339,10 @@  discard block
 block discarded – undo
288 339
 			<div id="bing_data">
289 340
 				<p>
290 341
 					<label for="bingkey">Bing Map key</label>
291
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
342
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
343
+	print $globalBingMapKey;
344
+}
345
+?>" />
292 346
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
293 347
 				</p>
294 348
 			</div>
@@ -296,7 +350,10 @@  discard block
 block discarded – undo
296 350
 			<div id="mapquest_data">
297 351
 				<p>
298 352
 					<label for="mapquestkey">MapQuest key</label>
299
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
353
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
354
+	print $globalMapQuestKey;
355
+}
356
+?>" />
300 357
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
301 358
 				</p>
302 359
 			</div>
@@ -304,11 +361,17 @@  discard block
 block discarded – undo
304 361
 			<div id="here_data">
305 362
 				<p>
306 363
 					<label for="hereappid">Here App_Id</label>
307
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
364
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
365
+	print $globalHereappId;
366
+}
367
+?>" />
308 368
 				</p>
309 369
 				<p>
310 370
 					<label for="hereappcode">Here App_Code</label>
311
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
371
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
372
+	print $globalHereappCode;
373
+}
374
+?>" />
312 375
 				</p>
313 376
 				<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>
314 377
 			</div>
@@ -316,7 +379,10 @@  discard block
 block discarded – undo
316 379
 			<div id="openweathermap_data">
317 380
 				<p>
318 381
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
319
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
382
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
383
+	print $globalOpenWeatherMapKey;
384
+}
385
+?>" />
320 386
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
321 387
 				</p>
322 388
 			</div>
@@ -345,42 +411,86 @@  discard block
 block discarded – undo
345 411
 			<legend>Coverage area</legend>
346 412
 			<p>
347 413
 				<label for="latitudemax">The maximum latitude (north)</label>
348
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
414
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
415
+	print $globalLatitudeMax;
416
+}
417
+?>" />
349 418
 			</p>
350 419
 			<p>
351 420
 				<label for="latitudemin">The minimum latitude (south)</label>
352
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
421
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
422
+	print $globalLatitudeMin;
423
+}
424
+?>" />
353 425
 			</p>
354 426
 			<p>
355 427
 				<label for="longitudemax">The maximum longitude (west)</label>
356
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
428
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
429
+	print $globalLongitudeMax;
430
+}
431
+?>" />
357 432
 			</p>
358 433
 			<p>
359 434
 				<label for="longitudemin">The minimum longitude (east)</label>
360
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
435
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
436
+	print $globalLongitudeMin;
437
+}
438
+?>" />
361 439
 			</p>
362 440
 			<p>
363 441
 				<label for="latitudecenter">The latitude center</label>
364
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
442
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
443
+	print $globalCenterLatitude;
444
+}
445
+?>" />
365 446
 			</p>
366 447
 			<p>
367 448
 				<label for="longitudecenter">The longitude center</label>
368
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
449
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
450
+	print $globalCenterLongitude;
451
+}
452
+?>" />
369 453
 			</p>
370 454
 			<p>
371 455
 				<label for="livezoom">Default Zoom on live map</label>
372
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
456
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
457
+	print $globalLiveZoom;
458
+} else {
459
+	print '9';
460
+}
461
+?>" />
373 462
 			</p>
374 463
 			<p>
375 464
 				<label for="squawk_country">Country for squawk usage</label>
376 465
 				<select name="squawk_country" id="squawk_country">
377
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
378
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
379
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
380
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
381
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
382
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
383
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
466
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
467
+	print ' selected ';
468
+}
469
+?>>UK</option>
470
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
471
+	print ' selected ';
472
+}
473
+?>>NZ</option>
474
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
475
+	print ' selected ';
476
+}
477
+?>>US</option>
478
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
479
+	print ' selected ';
480
+}
481
+?>>AU</option>
482
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
483
+	print ' selected ';
484
+}
485
+?>>NL</option>
486
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
487
+	print ' selected ';
488
+}
489
+?>>FR</option>
490
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
491
+	print ' selected ';
492
+}
493
+?>>TR</option>
384 494
 				</select>
385 495
 			</p>
386 496
 		</fieldset>
@@ -389,15 +499,24 @@  discard block
 block discarded – undo
389 499
 			<p><i>Only put in DB flights that are inside a circle</i></p>
390 500
 			<p>
391 501
 				<label for="latitude">Center latitude</label>
392
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
502
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
503
+	echo $globalDistanceIgnore['latitude'];
504
+}
505
+?>" />
393 506
 			</p>
394 507
 			<p>
395 508
 				<label for="longitude">Center longitude</label>
396
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
509
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
510
+	echo $globalDistanceIgnore['longitude'];
511
+}
512
+?>" />
397 513
 			</p>
398 514
 			<p>
399 515
 				<label for="Distance">Distance (in km)</label>
400
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
516
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
517
+	echo $globalDistanceIgnore['distance'];
518
+}
519
+?>" />
401 520
 			</p>
402 521
 		</fieldset>
403 522
 		<fieldset id="sourceloc">
@@ -523,22 +642,34 @@  discard block
 block discarded – undo
523 642
 			<div id="flightaware_data">
524 643
 				<p>
525 644
 					<label for="flightawareusername">FlightAware username</label>
526
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
645
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
646
+	print $globalFlightAwareUsername;
647
+}
648
+?>" />
527 649
 				</p>
528 650
 				<p>
529 651
 					<label for="flightawarepassword">FlightAware password/API key</label>
530
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
652
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
653
+	print $globalFlightAwarePassword;
654
+}
655
+?>" />
531 656
 				</p>
532 657
 			</div>
533 658
 -->
534 659
 			<div id="sailaway_data">
535 660
 				<p>
536 661
 					<label for="sailawayemail">Sailaway email</label>
537
-					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) print $globalSailaway['email']; ?>" />
662
+					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) {
663
+	print $globalSailaway['email'];
664
+}
665
+?>" />
538 666
 				</p>
539 667
 				<p>
540 668
 					<label for="sailawaypassword">Sailaway password</label>
541
-					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) print $globalSailaway['password']; ?>" />
669
+					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) {
670
+	print $globalSailaway['password'];
671
+}
672
+?>" />
542 673
 				</p>
543 674
 			</div>
544 675
 
@@ -580,7 +711,10 @@  discard block
 block discarded – undo
580 711
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
581 712
 								?>
582 713
 								<td><input type="text" name="host[]" value="<?php print $source['host']; ?>" /></td>
583
-								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
714
+								<td><input type="text" name="port[]" class="col-xs-2" value="<?php if (isset($source['port'])) {
715
+	print $source['port'];
716
+}
717
+?>" /></td>
584 718
 								<?php
585 719
 								    } else {
586 720
 									$hostport = explode(':',$source['host']);
@@ -599,37 +733,118 @@  discard block
 block discarded – undo
599 733
 								?>
600 734
 								<td>
601 735
 									<select name="format[]">
602
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
603
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
604
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
605
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
606
-										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
607
-										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option>
608
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
609
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
610
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
611
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
612
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
613
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
614
-										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
615
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
616
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
617
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
618
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
619
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
620
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
621
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
622
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
623
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
624
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
625
-										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') print 'selected'; ?>>Sailaway</option>
736
+										<option value="auto" <?php if (!isset($source['format'])) {
737
+	print 'selected';
738
+}
739
+?>>Auto</option>
740
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
741
+	print 'selected';
742
+}
743
+?>>SBS</option>
744
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
745
+	print 'selected';
746
+}
747
+?>>TSV</option>
748
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
749
+	print 'selected';
750
+}
751
+?>>Raw</option>
752
+										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') {
753
+	print 'selected';
754
+}
755
+?>>Dump1090 aircraft.json</option>
756
+										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') {
757
+	print 'selected';
758
+}
759
+?>>Planefinder client</option>
760
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
761
+	print 'selected';
762
+}
763
+?>>APRS</option>
764
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
765
+	print 'selected';
766
+}
767
+?>>Radarcape deltadb.txt</option>
768
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
769
+	print 'selected';
770
+}
771
+?>>Vatsim</option>
772
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
773
+	print 'selected';
774
+}
775
+?>>Virtual Radar Server AircraftList.json</option>
776
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
777
+	print 'selected';
778
+}
779
+?>>Virtual Radar Server TCP</option>
780
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
781
+	print 'selected';
782
+}
783
+?>>phpVMS</option>
784
+										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
785
+	print 'selected';
786
+}
787
+?>>Virtual Airline Operations System (VAOS)</option>
788
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
789
+	print 'selected';
790
+}
791
+?>>Virtual Airlines Manager</option>
792
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
793
+	print 'selected';
794
+}
795
+?>>IVAO</option>
796
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
797
+	print 'selected';
798
+}
799
+?>>FlightGear Multiplayer</option>
800
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
801
+	print 'selected';
802
+}
803
+?>>FlightGear Singleplayer</option>
804
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
805
+	print 'selected';
806
+}
807
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
808
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
809
+	print 'selected';
810
+}
811
+?>>ACARS SBS-3 over TCP</option>
812
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
813
+	print 'selected';
814
+}
815
+?>>NMEA AIS over TCP</option>
816
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
817
+	print 'selected';
818
+}
819
+?>>AirWhere website</option>
820
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
821
+	print 'selected';
822
+}
823
+?>>HidnSeek Callback</option>
824
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
825
+	print 'selected';
826
+}
827
+?>>Blitzortung</option>
828
+										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') {
829
+	print 'selected';
830
+}
831
+?>>Sailaway</option>
626 832
 									</select>
627 833
 								</td>
628 834
 								<td>
629
-									<input type="text" name="name[]" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
835
+									<input type="text" name="name[]" value="<?php if (isset($source['name'])) {
836
+	print $source['name'];
837
+}
838
+?>" />
630 839
 								</td>
631
-								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
632
-								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
840
+								<td><input type="checkbox" name="sourcestats[]" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
841
+	print 'checked';
842
+}
843
+?> /></td>
844
+								<td><input type="checkbox" name="noarchive[]" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
845
+	print 'checked';
846
+}
847
+?> /></td>
633 848
 								<td>
634 849
 									<select name="timezones[]">
635 850
 								<?php
@@ -639,7 +854,9 @@  discard block
 block discarded – undo
639 854
 											print '<option selected>'.$timezones.'</option>';
640 855
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
641 856
 											print '<option selected>'.$timezones.'</option>';
642
-										} else print '<option>'.$timezones.'</option>';
857
+										} else {
858
+											print '<option>'.$timezones.'</option>';
859
+										}
643 860
 									}
644 861
 								?>
645 862
 									</select>
@@ -693,7 +910,9 @@  discard block
 block discarded – undo
693 910
 									foreach($timezonelist as $timezones){
694 911
 										if ($timezones == 'UTC') {
695 912
 											print '<option selected>'.$timezones.'</option>';
696
-										} else print '<option>'.$timezones.'</option>';
913
+										} else {
914
+											print '<option>'.$timezones.'</option>';
915
+										}
697 916
 									}
698 917
 								?>
699 918
 									</select>
@@ -718,11 +937,17 @@  discard block
 block discarded – undo
718 937
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
719 938
 					<p>
720 939
 						<label for="acarshost">ACARS UDP host</label>
721
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
940
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
941
+	print $globalACARSHost;
942
+}
943
+?>" />
722 944
 					</p>
723 945
 					<p>
724 946
 						<label for="acarsport">ACARS UDP port</label>
725
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
947
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
948
+	print $globalACARSPort;
949
+}
950
+?>" />
726 951
 					</p>
727 952
 					<p class="help-block"><i>daemon-acars.php</i> can only be run as daemon. It's an alternate script for ACARS data, <i>daemon-spotter.php</i> may be better.</p>
728 953
 				</fieldset>
@@ -749,17 +974,38 @@  discard block
 block discarded – undo
749 974
 				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
750 975
 				    <td>
751 976
 					<select name="newslang[]">
752
-					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
753
-					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
977
+					    <option value="en"<?php if ($lng == 'en') {
978
+	print ' selected';
979
+}
980
+?>>English</option>
981
+					    <option value="fr"<?php if ($lng == 'fr') {
982
+	print ' selected';
983
+}
984
+?>>French</option>
754 985
 					</select>
755 986
 				    </td>
756 987
 				    <td>
757 988
 					<select name="newstype[]">
758
-					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
759
-					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
760
-					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
761
-					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
762
-					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
989
+					    <option value="global"<?php if ($type == 'global') {
990
+	print ' selected';
991
+}
992
+?>>Global</option>
993
+					    <option value="aircraft"<?php if ($type == 'aircraft') {
994
+	print ' selected';
995
+}
996
+?>>Aircraft</option>
997
+					    <option value="marine"<?php if ($type == 'marine') {
998
+	print ' selected';
999
+}
1000
+?>>Marine</option>
1001
+					    <option value="tracker"<?php if ($type == 'tracker') {
1002
+	print ' selected';
1003
+}
1004
+?>>Tracker</option>
1005
+					    <option value="satellite"<?php if ($type == 'Satellite') {
1006
+	print ' selected';
1007
+}
1008
+?>>Satellite</option>
763 1009
 					</select>
764 1010
 				    </td>
765 1011
 				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
@@ -843,7 +1089,10 @@  discard block
 block discarded – undo
843 1089
 			</p>
844 1090
 			<p>
845 1091
 				<label for="corsproxy">CORS proxy</label>
846
-				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) print $globalCORSproxy; else print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
1092
+				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) {
1093
+	print $globalCORSproxy;
1094
+} else {
1095
+	print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
847 1096
 				<p class="help-block">CORS proxy used for some WMS servers</p>
848 1097
 			</p>
849 1098
 <!--
@@ -906,13 +1155,18 @@  discard block
 block discarded – undo
906 1155
 			<div id="schedules_options">
907 1156
 				<p>
908 1157
 					<label for="britishairways">British Airways API Key</label>
909
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
1158
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey;
1159
+}
1160
+?>" />
910 1161
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
911 1162
 				</p>
912 1163
 				<!--
913 1164
 				<p>
914 1165
 					<label for="transavia">Transavia Test API Consumer Key</label>
915
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
1166
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
1167
+	print $globalTransaviaKey;
1168
+}
1169
+?>" />
916 1170
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
917 1171
 				</p>
918 1172
 				-->
@@ -921,10 +1175,16 @@  discard block
 block discarded – undo
921 1175
 						<b>Lufthansa API Key</b>
922 1176
 						<p>
923 1177
 							<label for="lufthansakey">Key</label>
924
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
1178
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
1179
+	print $globalLufthansaKey['key'];
1180
+}
1181
+?>" />
925 1182
 						</p><p>
926 1183
 							<label for="lufthansasecret">Secret</label>
927
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
1184
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
1185
+	print $globalLufthansaKey['secret'];
1186
+}
1187
+?>" />
928 1188
 						</p>
929 1189
 					</div>
930 1190
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -934,11 +1194,17 @@  discard block
 block discarded – undo
934 1194
 						<b>FlightAware API Key</b>
935 1195
 						<p>
936 1196
 							<label for="flightawareusername">Username</label>
937
-							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
1197
+							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
1198
+	print $globalFlightAwareUsername;
1199
+}
1200
+?>" />
938 1201
 						</p>
939 1202
 						<p>
940 1203
 							<label for="flightawarepassword">API key</label>
941
-							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
1204
+							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
1205
+	print $globalFlightAwarePassword;
1206
+}
1207
+?>" />
942 1208
 						</p>
943 1209
 					</div>
944 1210
 					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
@@ -955,10 +1221,22 @@  discard block
 block discarded – undo
955 1221
 				<p>
956 1222
 					<label for="mapmatchingsource">Map Matching source</label>
957 1223
 					<select name="mapmatchingsource" id="mapmatchingsource">
958
-						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
959
-						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
960
-						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option>
961
-						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
1224
+						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) {
1225
+	print 'selected="selected" ';
1226
+}
1227
+?>>FlightAirMap Map Matching</option>
1228
+						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') {
1229
+	print 'selected="selected" ';
1230
+}
1231
+?>>GraphHopper</option>
1232
+						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') {
1233
+	print 'selected="selected" ';
1234
+}
1235
+?>>OSMR</option>
1236
+						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') {
1237
+	print 'selected="selected" ';
1238
+}
1239
+?>>Mapbox</option>
962 1240
 					</select>
963 1241
 					<p class="help-block">Mapbox need the API Key defined in map section.</p>
964 1242
 					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
@@ -966,7 +1244,10 @@  discard block
 block discarded – undo
966 1244
 				<br />
967 1245
 				<p>
968 1246
 					<label for="graphhopper">GraphHopper API Key</label>
969
-					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
1247
+					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) {
1248
+	print $globalGraphHopperKey;
1249
+}
1250
+?>" />
970 1251
 					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
971 1252
 				</p>
972 1253
 			</div>
@@ -984,7 +1265,10 @@  discard block
 block discarded – undo
984 1265
 			</p>
985 1266
 			<p>
986 1267
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
987
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1268
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
1269
+	print $globalNOTAMSource;
1270
+}
1271
+?>" />
988 1272
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
989 1273
 			</p>
990 1274
 			<br />
@@ -1000,14 +1284,20 @@  discard block
 block discarded – undo
1000 1284
 			<div id="metarsrc">
1001 1285
 				<p>
1002 1286
 					<label for="metarsource">URL of your METAR source</label>
1003
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1287
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
1288
+	print $globalMETARurl;
1289
+}
1290
+?>" />
1004 1291
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
1005 1292
 				</p>
1006 1293
 			</div>
1007 1294
 			<br />
1008 1295
 			<p>
1009 1296
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
1010
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1297
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
1298
+	print $globalBitlyAccessToken;
1299
+}
1300
+?>" />
1011 1301
 			</p>
1012 1302
 			<br />
1013 1303
 			<p>
@@ -1023,11 +1313,26 @@  discard block
 block discarded – undo
1023 1313
 			<p>
1024 1314
 				<label for="geoid_source">Geoid Source</label>
1025 1315
 				<select name="geoid_source" id="geoid_source">
1026
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
1027
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
1028
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
1029
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
1030
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1316
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
1317
+	print ' selected="selected"';
1318
+}
1319
+?>>EGM96 15' (2.1MB)</option>
1320
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
1321
+	print ' selected="selected"';
1322
+}
1323
+?>>EGM96 5' (19MB)</option>
1324
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
1325
+	print ' selected="selected"';
1326
+}
1327
+?>>EGM2008 5' (19MB)</option>
1328
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
1329
+	print ' selected="selected"';
1330
+}
1331
+?>>EGM2008 2.5' (75MB)</option>
1332
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
1333
+	print ' selected="selected"';
1334
+}
1335
+?>>EGM2008 1' (470MB)</option>
1031 1336
 				</select>
1032 1337
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
1033 1338
 			</p>
@@ -1049,7 +1354,12 @@  discard block
 block discarded – undo
1049 1354
 			</p>
1050 1355
 			<p>
1051 1356
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
1052
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1357
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1358
+	print $globalArchiveMonths;
1359
+} else {
1360
+	echo '1';
1361
+}
1362
+?>" />
1053 1363
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
1054 1364
 			</p>
1055 1365
 			<p>
@@ -1059,12 +1369,22 @@  discard block
 block discarded – undo
1059 1369
 			</p>
1060 1370
 			<p>
1061 1371
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
1062
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1372
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1373
+	print $globalArchiveKeepMonths;
1374
+} else {
1375
+	echo '1';
1376
+}
1377
+?>" />
1063 1378
 				<p class="help-block">0 to disable</p>
1064 1379
 			</p>
1065 1380
 			<p>
1066 1381
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
1067
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1382
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1383
+	print $globalArchiveKeepTrackMonths;
1384
+} else {
1385
+	echo '1';
1386
+}
1387
+?>" />
1068 1388
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
1069 1389
 			</p>
1070 1390
 			<br />
@@ -1074,7 +1394,12 @@  discard block
 block discarded – undo
1074 1394
 				<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>
1075 1395
 				<div id="cronends"> 
1076 1396
 					<label for="cronend">Run script for xx seconds</label>
1077
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1397
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1398
+	print $globalCronEnd;
1399
+} else {
1400
+	print '0';
1401
+}
1402
+?>" />
1078 1403
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
1079 1404
 				</div>
1080 1405
 			</p>
@@ -1133,20 +1458,40 @@  discard block
 block discarded – undo
1133 1458
 			<br />
1134 1459
 			<p>
1135 1460
 				<label for="refresh">Show flights detected since xxx seconds</label>
1136
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1461
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1462
+	echo $globalLiveInterval;
1463
+} else {
1464
+	echo '200';
1465
+}
1466
+?>" />
1137 1467
 			</p>
1138 1468
 			<p>
1139 1469
 				<label for="maprefresh">Live map refresh (in seconds)</label>
1140
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1470
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1471
+	echo $globalMapRefresh;
1472
+} else {
1473
+	echo '30';
1474
+}
1475
+?>" />
1141 1476
 			</p>
1142 1477
 			<p>
1143 1478
 				<label for="mapidle">Map idle timeout (in minutes)</label>
1144
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1479
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1480
+	echo $globalMapIdleTimeout;
1481
+} else {
1482
+	echo '30';
1483
+}
1484
+?>" />
1145 1485
 				<p class="help-block">0 to disable</p>
1146 1486
 			</p>
1147 1487
 			<p>
1148 1488
 				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1149
-				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1489
+				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) {
1490
+	echo $globalMinFetch;
1491
+} else {
1492
+	echo '20';
1493
+}
1494
+?>" />
1150 1495
 			</p>
1151 1496
 			<p>
1152 1497
 				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
@@ -1165,12 +1510,20 @@  discard block
 block discarded – undo
1165 1510
 			<br />
1166 1511
 			<p>
1167 1512
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1168
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1513
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1514
+	echo $globalClosestMinDist;
1515
+} else {
1516
+	echo '50';
1517
+}
1518
+?>" />
1169 1519
 			</p>
1170 1520
 			<br />
1171 1521
 			<p>
1172 1522
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1173
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1523
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1524
+	echo $globalAircraftSize;
1525
+}
1526
+?>" />
1174 1527
 			</p>
1175 1528
 			<br />
1176 1529
 			<p>
@@ -1189,22 +1542,42 @@  discard block
 block discarded – undo
1189 1542
 			<br />
1190 1543
 			<p>
1191 1544
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1192
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1545
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1546
+	echo $globalAircraftIconColor;
1547
+} else {
1548
+	echo '1a3151';
1549
+}
1550
+?>" />
1193 1551
 			</p>
1194 1552
 			<br />
1195 1553
 			<p>
1196 1554
 				<label for="marineiconcolor">Color of marine icon on map</label>
1197
-				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) echo $globalMarineIconColor; else echo '43d1d8'; ?>" />
1555
+				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) {
1556
+	echo $globalMarineIconColor;
1557
+} else {
1558
+	echo '43d1d8';
1559
+}
1560
+?>" />
1198 1561
 			</p>
1199 1562
 			<br />
1200 1563
 			<p>
1201 1564
 				<label for="trackericoncolor">Color of tracker icon on map</label>
1202
-				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) echo $globalTrackerIconColor; else echo '1a3151'; ?>" />
1565
+				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) {
1566
+	echo $globalTrackerIconColor;
1567
+} else {
1568
+	echo '1a3151';
1569
+}
1570
+?>" />
1203 1571
 			</p>
1204 1572
 			<br />
1205 1573
 			<p>
1206 1574
 				<label for="satelliteiconcolor">Color of satellite icon on map</label>
1207
-				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) echo $globalSatelliteIconColor; else echo '1a3151'; ?>" />
1575
+				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) {
1576
+	echo $globalSatelliteIconColor;
1577
+} else {
1578
+	echo '1a3151';
1579
+}
1580
+?>" />
1208 1581
 			</p>
1209 1582
 			<?php
1210 1583
 				if (!is_writable('../cache')) {
@@ -1228,14 +1601,27 @@  discard block
 block discarded – undo
1228 1601
 			<p>
1229 1602
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1230 1603
 				<div class="range">
1231
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1232
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1604
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1605
+	echo $globalAirportZoom;
1606
+} else {
1607
+	echo '7';
1608
+}
1609
+?>" />
1610
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1611
+	echo $globalAirportZoom;
1612
+} else {
1613
+	echo '7';
1614
+}
1615
+?></output>
1233 1616
 				</div>
1234 1617
 			</p>
1235 1618
 			<br />
1236 1619
 			<p>
1237 1620
 				<label for="customcss">Custom CSS web path</label>
1238
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1621
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1622
+	echo $globalCustomCSS;
1623
+}
1624
+?>" />
1239 1625
 			</p>
1240 1626
 		</fieldset>
1241 1627
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -1265,8 +1651,12 @@  discard block
 block discarded – undo
1265 1651
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1266 1652
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1267 1653
 
1268
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1269
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1654
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1655
+		$error .= 'Mysql driver for PDO must be loaded';
1656
+	}
1657
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1658
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1659
+	}
1270 1660
 	
1271 1661
 	$_SESSION['database_root'] = $dbroot;
1272 1662
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1344,15 +1734,23 @@  discard block
 block discarded – undo
1344 1734
 	$source_city = $_POST['source_city'];
1345 1735
 	$source_country = $_POST['source_country'];
1346 1736
 	$source_ref = $_POST['source_ref'];
1347
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1348
-	else $source_id = array();
1737
+	if (isset($source_id)) {
1738
+		$source_id = $_POST['source_id'];
1739
+	} else {
1740
+		$source_id = array();
1741
+	}
1349 1742
 	
1350 1743
 	$sources = array();
1351 1744
 	foreach ($source_name as $keys => $name) {
1352
-	    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]);
1353
-	    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]);
1745
+	    if (isset($source_id[$keys])) {
1746
+	    	$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]);
1747
+	    } else {
1748
+	    	$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]);
1749
+	    }
1750
+	}
1751
+	if (count($sources) > 0) {
1752
+		$_SESSION['sources'] = $sources;
1354 1753
 	}
1355
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1356 1754
 
1357 1755
 	$newsurl = $_POST['newsurl'];
1358 1756
 	$newslng = $_POST['newslang'];
@@ -1365,7 +1763,9 @@  discard block
 block discarded – undo
1365 1763
 		$lng = $newslng[$newskey];
1366 1764
 		if (isset($newsfeeds[$type][$lng])) {
1367 1765
 		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1368
-		} else $newsfeeds[$type][$lng] = array($url);
1766
+		} else {
1767
+			$newsfeeds[$type][$lng] = array($url);
1768
+		}
1369 1769
 	    }
1370 1770
 	}
1371 1771
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
@@ -1390,17 +1790,29 @@  discard block
 block discarded – undo
1390 1790
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1391 1791
 
1392 1792
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1393
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1394
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1793
+	if ($globalaircraft == 'aircraft') {
1794
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1795
+	} else {
1796
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1797
+	}
1395 1798
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1396
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1397
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1799
+	if ($globaltracker == 'tracker') {
1800
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1801
+	} else {
1802
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1803
+	}
1398 1804
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1399
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1400
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1805
+	if ($globalmarine == 'marine') {
1806
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1807
+	} else {
1808
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1809
+	}
1401 1810
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1402
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1403
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1811
+	if ($globalsatellite == 'satellite') {
1812
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1813
+	} else {
1814
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1815
+	}
1404 1816
 
1405 1817
 /*	
1406 1818
 	$globalSBS1Hosts = array();
@@ -1422,23 +1834,37 @@  discard block
 block discarded – undo
1422 1834
 	$name = $_POST['name'];
1423 1835
 	$format = $_POST['format'];
1424 1836
 	$timezones = $_POST['timezones'];
1425
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1426
-	else $sourcestats = array();
1427
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1428
-	else $noarchive = array();
1837
+	if (isset($_POST['sourcestats'])) {
1838
+		$sourcestats = $_POST['sourcestats'];
1839
+	} else {
1840
+		$sourcestats = array();
1841
+	}
1842
+	if (isset($_POST['noarchive'])) {
1843
+		$noarchive = $_POST['noarchive'];
1844
+	} else {
1845
+		$noarchive = array();
1846
+	}
1429 1847
 	$gSources = array();
1430 1848
 	$forcepilots = false;
1431 1849
 	foreach ($host as $key => $h) {
1432
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1433
-		else $cov = 'FALSE';
1434
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1435
-		else $arch = 'FALSE';
1850
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1851
+			$cov = 'TRUE';
1852
+		} else {
1853
+			$cov = 'FALSE';
1854
+		}
1855
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1856
+			$arch = 'TRUE';
1857
+		} else {
1858
+			$arch = 'FALSE';
1859
+		}
1436 1860
 		if (strpos($format[$key],'_callback')) {
1437 1861
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1438 1862
 		} elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) {
1439 1863
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1440 1864
 		}
1441
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1865
+		if ($format[$key] == 'airwhere') {
1866
+			$forcepilots = true;
1867
+		}
1442 1868
 	}
1443 1869
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1444 1870
 
@@ -1469,7 +1895,9 @@  discard block
 block discarded – undo
1469 1895
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1470 1896
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1471 1897
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1472
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1898
+	} else {
1899
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1900
+	}
1473 1901
 
1474 1902
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1475 1903
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1510,7 +1938,9 @@  discard block
 block discarded – undo
1510 1938
 
1511 1939
 	// Create in settings.php keys not yet configurable if not already here
1512 1940
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1513
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1941
+	if (!isset($globalDebug)) {
1942
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1943
+	}
1514 1944
 
1515 1945
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1516 1946
 	if ($resetyearstats == 'resetyearstats') {
@@ -1553,37 +1983,56 @@  discard block
 block discarded – undo
1553 1983
 	}
1554 1984
 */
1555 1985
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1556
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1557
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1558
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1559
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1986
+	if ($globalsbs == 'sbs') {
1987
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1988
+	} else {
1989
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1990
+	}
1991
+	if ($globalaprs == 'aprs') {
1992
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1993
+	} else {
1994
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1995
+	}
1560 1996
 	$va = false;
1561 1997
 	if ($globalivao == 'ivao') {
1562 1998
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1563 1999
 		$va = true;
1564
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2000
+	} else {
2001
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
2002
+	}
1565 2003
 	if ($globalvatsim == 'vatsim') {
1566 2004
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1567 2005
 		$va = true;
1568
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2006
+	} else {
2007
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2008
+	}
1569 2009
 	if ($globalphpvms == 'phpvms') {
1570 2010
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1571 2011
 		$va = true;
1572
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2012
+	} else {
2013
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2014
+	}
1573 2015
 	if ($globalvam == 'vam') {
1574 2016
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1575 2017
 		$va = true;
1576
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2018
+	} else {
2019
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2020
+	}
1577 2021
 	if ($va) {
1578 2022
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1579
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2023
+	} else {
2024
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2025
+	}
1580 2026
 	if ($globalva == 'va' || $va) {
1581 2027
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1582 2028
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1583 2029
 	} else {
1584 2030
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1585
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1586
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2031
+		if ($forcepilots) {
2032
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
2033
+		} else {
2034
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2035
+		}
1587 2036
 	}
1588 2037
 	if ($globalvm == 'vm') {
1589 2038
 		$settings = array_merge($settings,array('globalVM' => 'TRUE'));
@@ -1843,7 +2292,9 @@  discard block
 block discarded – undo
1843 2292
 	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1844 2293
 	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1845 2294
 
1846
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2295
+	if (!isset($globalTransaction)) {
2296
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2297
+	}
1847 2298
 
1848 2299
 	// Set some defaults values...
1849 2300
 	if (!isset($globalAircraftImageSources)) {
@@ -1858,15 +2309,23 @@  discard block
 block discarded – undo
1858 2309
 
1859 2310
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1860 2311
 
1861
-	if ($error == '') settings::modify_settings($settings);
1862
-	if ($error == '') settings::comment_settings($settings_comment);
2312
+	if ($error == '') {
2313
+		settings::modify_settings($settings);
2314
+	}
2315
+	if ($error == '') {
2316
+		settings::comment_settings($settings_comment);
2317
+	}
1863 2318
 	if ($error != '') {
1864 2319
 		print '<div class="info column">'.$error.'</div>';
1865 2320
 		require('../footer.php');
1866 2321
 		exit;
1867 2322
 	} else {
1868
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1869
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
2323
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
2324
+			$_SESSION['waypoints'] = 1;
2325
+		}
2326
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
2327
+			$_SESSION['owner'] = 1;
2328
+		}
1870 2329
 		if (isset($_POST['createdb'])) {
1871 2330
 			$_SESSION['install'] = 'database_create';
1872 2331
 		} else {
@@ -1903,10 +2362,18 @@  discard block
 block discarded – undo
1903 2362
 	$popw = false;
1904 2363
 	foreach ($_SESSION['done'] as $done) {
1905 2364
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1906
-	    if ($done == 'Create database') $pop = true;
1907
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1908
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1909
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
2365
+	    if ($done == 'Create database') {
2366
+	    	$pop = true;
2367
+	    }
2368
+	    if ($_SESSION['install'] == 'database_create') {
2369
+	    	$pop = true;
2370
+	    }
2371
+	    if ($_SESSION['install'] == 'database_import') {
2372
+	    	$popi = true;
2373
+	    }
2374
+	    if ($_SESSION['install'] == 'waypoints') {
2375
+	    	$popw = true;
2376
+	    }
1910 2377
 	}
1911 2378
 	if ($pop) {
1912 2379
 	    sleep(5);
@@ -1917,7 +2384,9 @@  discard block
 block discarded – undo
1917 2384
 	} else if ($popw) {
1918 2385
 	    sleep(5);
1919 2386
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1920
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2387
+	} else {
2388
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2389
+	}
1921 2390
 	print '</div></ul>';
1922 2391
 	print '<div id="error"></div>';
1923 2392
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
scripts/update_db.php 1 patch
Braces   +33 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@  discard block
 block discarded – undo
15 15
 	if(function_exists('exec')) {
16 16
 		exec("ps ux", $output, $result);
17 17
 		$j = 0;
18
-		foreach ($output as $line) if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
18
+		foreach ($output as $line) {
19
+			if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
20
+		}
19 21
 		if ($j > 1) {
20 22
 			echo "Script is already runnning...";
21 23
 			die();
@@ -25,7 +27,9 @@  discard block
 block discarded – undo
25 27
 require(dirname(__FILE__).'/../install/class.update_db.php');
26 28
 $update_db = new update_db();
27 29
 
28
-if ($update_db->check() === false) die();
30
+if ($update_db->check() === false) {
31
+	die();
32
+}
29 33
 
30 34
 if ((!isset($globalMasterServer) || !$globalMasterServer) && (!isset($globalOffline) || $globalOffline === FALSE)) {
31 35
 	if (isset($globalNOTAM) && $globalNOTAM && $update_db->check_last_notam_update()) {
@@ -36,14 +40,18 @@  discard block
 block discarded – undo
36 40
 			$update_db->update_notam();
37 41
 		}
38 42
 		$update_db->insert_last_notam_update();
39
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
43
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
44
+		echo "NOTAM are only updated once a day.\n";
45
+	}
40 46
 	if ((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft)) && ($update_db->check_last_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS))) {
41 47
 		$update_db->update_all();
42 48
 	//	require_once(dirname(__FILE__).'/../require/class.Spotter.php');
43 49
 	//	$Spotter = new Spotter();
44 50
 	//	$Spotter->updateFieldsFromOtherTables();
45 51
 		$update_db->insert_last_update();
46
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
52
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
53
+		echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
54
+	}
47 55
 	if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) {
48 56
 		echo "Check if new airspace version exist...";
49 57
 		echo $update_db->update_airspace_fam();
@@ -52,8 +60,11 @@  discard block
 block discarded – undo
52 60
 	if (isset($globalGeoid) && $globalGeoid && $update_db->check_last_geoid_update()) {
53 61
 		echo "Check if new geoid version exist...";
54 62
 		$error = $update_db->update_geoid_fam();
55
-		if ($error == '') $update_db->insert_last_geoid_update();
56
-		else echo $error;
63
+		if ($error == '') {
64
+			$update_db->insert_last_geoid_update();
65
+		} else {
66
+			echo $error;
67
+		}
57 68
 	}
58 69
 	if (isset($globalMarine) && $globalMarine && (!isset($globalVM) || $globalVM === FALSE) && $update_db->check_last_marine_identity_update()) {
59 70
 		echo "Check if new marine identity version exist...";
@@ -71,13 +82,17 @@  discard block
 block discarded – undo
71 82
 			//echo "Done";
72 83
 		}
73 84
 		$update_db->insert_last_owner_update();
74
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
85
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
86
+		echo "Owner are only updated every 15 days.\n";
87
+	}
75 88
 
76 89
 	if ((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft)) && ($update_db->check_last_airlines_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS))) {
77 90
 		echo "Updating airlines...\n";
78 91
 		echo $update_db->update_airlines_fam();
79 92
 		$update_db->insert_last_airlines_update();
80
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Airlines are only updated every 15 days.\n";
93
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
94
+		echo "Airlines are only updated every 15 days.\n";
95
+	}
81 96
 
82 97
 	if ((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft)) && (isset($globalAccidents) && $globalAccidents && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS))) {
83 98
 		require_once(dirname(__FILE__).'/../require/class.Accident.php');
@@ -86,7 +101,9 @@  discard block
 block discarded – undo
86 101
 		if ($Accident->check_last_accidents_update()) {
87 102
 			$Accident->download_update();
88 103
 			$Accident->insert_last_accidents_update();
89
-		} else echo "Accidents are updated once a day.\n";
104
+		} else {
105
+			echo "Accidents are updated once a day.\n";
106
+		}
90 107
 	}
91 108
   
92 109
 }
@@ -99,7 +116,9 @@  discard block
 block discarded – undo
99 116
 		if ($METAR->check_last_update()) {
100 117
 			$METAR->addMETARCycle();
101 118
 			$METAR->insert_last_update();
102
-		} else echo "METAR are only updated every 30 minutes.\n";
119
+		} else {
120
+			echo "METAR are only updated every 30 minutes.\n";
121
+		}
103 122
 	}
104 123
 
105 124
 	if ((!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft)) && (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS))) {
@@ -107,8 +126,10 @@  discard block
 block discarded – undo
107 126
 		//$update_db->update_oneworld();
108 127
 		$update_db->update_skyteam();
109 128
 		$update_db->insert_last_schedules_update();
110
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
111
-}
129
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
130
+		echo "Schedules are only updated every 15 days.\n";
131
+	}
132
+	}
112 133
 
113 134
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
114 135
 	echo "Updating statistics and archive old data...\n";
Please login to merge, or discard this patch.
live-czml.php 2 patches
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
     $s3 = sin($bank/2);
67 67
     $c1c2 = $c1*$c2;
68 68
     $s1s2 = $s1*$s2;
69
-    $w =$c1c2*$c3 - $s1s2*$s3;
70
-    $x =$c1c2*$s3 + $s1s2*$c3;
71
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
72
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
73
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
69
+    $w = $c1c2*$c3 - $s1s2*$s3;
70
+    $x = $c1c2*$s3 + $s1s2*$c3;
71
+    $y = $s1*$c2*$c3 + $c1*$s2*$s3;
72
+    $z = $c1*$s2*$c3 - $s1*$c2*$s3;
73
+    return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w);
74 74
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
75 75
 
76 76
 }
@@ -92,22 +92,22 @@  discard block
 block discarded – undo
92 92
 $allhistory = false;
93 93
 $filter['source'] = array();
94 94
 $limit = 0;
95
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
96
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
97
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
98
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
99
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
100
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
101
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
102
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
103
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
104
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
105
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
106
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
95
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
96
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
97
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
98
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
99
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
100
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
101
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING);
102
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
103
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
104
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
105
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
106
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'], FILTER_SANITIZE_NUMBER_INT);
107 107
 if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') $filter['blocked'] = true;
108 108
 
109 109
 if (isset($_COOKIE['map_3d_limit'])) {
110
-	$limit = filter_var($_COOKIE['map_3d_limit'],FILTER_SANITIZE_NUMBER_INT);
110
+	$limit = filter_var($_COOKIE['map_3d_limit'], FILTER_SANITIZE_NUMBER_INT);
111 111
 }
112 112
 
113 113
 /*
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
 	$from_archive = true;
157 157
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
158 158
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
159
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
160
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
161
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
162
-	$begindate = date('Y-m-d H:i:s',$begindate);
163
-	$enddate = date('Y-m-d H:i:s',$enddate);
159
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
160
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
161
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
162
+	$begindate = date('Y-m-d H:i:s', $begindate);
163
+	$enddate = date('Y-m-d H:i:s', $enddate);
164 164
 	if ($tracker) {
165
-		$spotter_array = $TrackerArchive->getMinLiveTrackerDataPlayback($begindate,$enddate,$filter);
165
+		$spotter_array = $TrackerArchive->getMinLiveTrackerDataPlayback($begindate, $enddate, $filter);
166 166
 	} elseif ($marine) {
167
-		$spotter_array = $MarineArchive->getMinLiveMarineDataPlayback($begindate,$enddate,$filter);
167
+		$spotter_array = $MarineArchive->getMinLiveMarineDataPlayback($begindate, $enddate, $filter);
168 168
 	} else {
169
-		$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter);
169
+		$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter);
170 170
 	}
171 171
 } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) {
172 172
 	$from_archive = true;
@@ -183,36 +183,36 @@  discard block
 block discarded – undo
183 183
 	}
184 184
 	$enddate = $_COOKIE['archive_end'];
185 185
 	$enddateinitial = $_COOKIE['archive_end'];
186
-	$archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT);
187
-	$begindate = date('Y-m-d H:i:s',$begindate);
188
-	$enddate = date('Y-m-d H:i:s',$enddate);
186
+	$archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT);
187
+	$begindate = date('Y-m-d H:i:s', $begindate);
188
+	$enddate = date('Y-m-d H:i:s', $enddate);
189 189
 	//echo 'Begin : '.$begindate.' - End : '.$enddate."\n";
190 190
 	if ($tracker) {
191
-		$spotter_array = $TrackerArchive->getMinLiveTrackerData($begindate,$enddate,$filter);
191
+		$spotter_array = $TrackerArchive->getMinLiveTrackerData($begindate, $enddate, $filter);
192 192
 	} elseif ($marine) {
193
-		$spotter_array = $MarineArchive->getMinLiveMarineData($begindate,$enddate,$filter);
193
+		$spotter_array = $MarineArchive->getMinLiveMarineData($begindate, $enddate, $filter);
194 194
 	} else {
195
-		$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
195
+		$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
196 196
 	}
197 197
 } elseif ($tracker) {
198 198
 	$coord = array();
199 199
 	if (isset($_GET['coord']) && $_GET['coord'] != '') {
200
-		$coord = explode(',',$_GET['coord']);
201
-		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) 
200
+		$coord = explode(',', $_GET['coord']);
201
+		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) 
202 202
 		    && $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)) {
203 203
 			$coord = array();
204 204
 		}
205 205
 	}
206 206
 	$previous_filter = $filter;
207 207
 	if ((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrackTracker']) && $_COOKIE['MapTrackTracker'] != '')) {
208
-		$filter = array_merge($filter,array('id' => $_COOKIE['MapTrackTracker']));
209
-		$spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,false);
208
+		$filter = array_merge($filter, array('id' => $_COOKIE['MapTrackTracker']));
209
+		$spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord, $filter, false);
210 210
 	/*
211 211
 	} elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && !empty($coord)) {
212 212
 		$spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,true,$_COOKIE['MapTrack']);
213 213
 	*/
214 214
 	} elseif (!isset($_COOKIE['singlemodel']) || $_COOKIE['singlemodel'] == 'false') {
215
-		$spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord,$filter,false);
215
+		$spotter_array = $TrackerLive->getMinLastLiveTrackerData($coord, $filter, false);
216 216
 	} else {
217 217
 		$spotter_array = array();
218 218
 	}
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	$coord = array();
222 222
 	//if (isset($_GET['coord']) && $_GET['coord'] != '') {
223 223
 	if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrackMarine']) && $_COOKIE['MapTrackMarine'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') {
224
-		$coord = explode(',',$_GET['coord']);
225
-		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) 
224
+		$coord = explode(',', $_GET['coord']);
225
+		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) 
226 226
 		    && $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)) {
227 227
 			$coord = array();
228 228
 		}
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 	if (((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') || (!isset($_COOKIE['singlemodel']) && isset($globalMap3DSelected) && $globalMap3DSelected)) && (isset($_COOKIE['MapTrackMarine']) && $_COOKIE['MapTrackMarine'] != '')) {
232 232
 		//$filter = array_merge($filter,array('id' => $_COOKIE['MapTrackMarine']));
233 233
 		//$spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,false);
234
-		$spotter_array = $MarineLive->getMinLastLiveMarineDataByID($_COOKIE['MapTrackMarine'],$filter,false);
234
+		$spotter_array = $MarineLive->getMinLastLiveMarineDataByID($_COOKIE['MapTrackMarine'], $filter, false);
235 235
 	} elseif (isset($_COOKIE['MapTrackMarine']) && $_COOKIE['MapTrackMarine'] != '' && !empty($coord)) {
236
-		$spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,false,$_COOKIE['MapTrack']);
236
+		$spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, false, $_COOKIE['MapTrack']);
237 237
 	} elseif (!isset($_COOKIE['singlemodel']) || $_COOKIE['singlemodel'] == 'false') {
238
-		$spotter_array = $MarineLive->getMinLastLiveMarineData($coord,$filter,false);
238
+		$spotter_array = $MarineLive->getMinLastLiveMarineData($coord, $filter, false);
239 239
 	} else {
240 240
 		$spotter_array = array();
241 241
 	}
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 } else {
244 244
 	$coord = array();
245 245
 	if (!((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') && (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '')) && isset($_GET['coord']) && $_GET['coord'] != '') {
246
-		$coord = explode(',',$_GET['coord']);
247
-		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) 
246
+		$coord = explode(',', $_GET['coord']);
247
+		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) 
248 248
 		    && $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)) {
249 249
 			$coord = array();
250 250
 		}
@@ -252,14 +252,14 @@  discard block
 block discarded – undo
252 252
 	$previous_filter = $filter;
253 253
 	if (((isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') || (!isset($_COOKIE['singlemodel']) && isset($globalMap3DSelected) && $globalMap3DSelected)) && (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '')) {
254 254
 		//$filter = array_merge($filter,array('id' => $_COOKIE['MapTrack']));
255
-		$spotter_array = $SpotterLive->getMinLastLiveSpotterDataByID($_COOKIE['MapTrack'],$filter,$limit);
255
+		$spotter_array = $SpotterLive->getMinLastLiveSpotterDataByID($_COOKIE['MapTrack'], $filter, $limit);
256 256
 		//$spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,false);
257 257
 	} elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '') {
258 258
 		//$spotter_array = $SpotterLive->getMinLastLiveSpotterDataByID($_COOKIE['MapTrack'],$filter,false);
259 259
 		//if (empty($spotter_array)) $spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,false,$_COOKIE['MapTrack']);
260
-		$spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,$limit,$_COOKIE['MapTrack']);
260
+		$spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, $limit, $_COOKIE['MapTrack']);
261 261
 	} elseif (!isset($_COOKIE['singlemodel']) || $_COOKIE['singlemodel'] == 'false') {
262
-		$spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord,$filter,$limit);
262
+		$spotter_array = $SpotterLive->getMinLastLiveSpotterData($coord, $filter, $limit);
263 263
 	} else {
264 264
 		$spotter_array = array();
265 265
 	}
@@ -269,19 +269,19 @@  discard block
 block discarded – undo
269 269
 if (!empty($spotter_array) && isset($coord)) {
270 270
 	if ($tracker) {
271 271
 		if (isset($_GET['archive'])) {
272
-			$flightcnt = $TrackerArchive->getLiveTrackerCount($begindate,$enddate,$filter);
272
+			$flightcnt = $TrackerArchive->getLiveTrackerCount($begindate, $enddate, $filter);
273 273
 		} else {
274 274
 			$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
275 275
 		}
276 276
 	} elseif ($marine) {
277 277
 		if (isset($_GET['archive'])) {
278
-			$flightcnt = $MarineArchive->getLiveMarineCount($begindate,$enddate,$filter);
278
+			$flightcnt = $MarineArchive->getLiveMarineCount($begindate, $enddate, $filter);
279 279
 		} else {
280 280
 			$flightcnt = $MarineLive->getLiveMarineCount($filter);
281 281
 		}
282 282
 	} else {
283 283
 		if (isset($_GET['archive'])) {
284
-			$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
284
+			$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
285 285
 		} else {
286 286
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
287 287
 		}
@@ -289,17 +289,17 @@  discard block
 block discarded – undo
289 289
 	if ($flightcnt == '') $flightcnt = 0;
290 290
 } else $flightcnt = 0;
291 291
 
292
-$sqltime = round(microtime(true)-$begintime,2);
292
+$sqltime = round(microtime(true) - $begintime, 2);
293 293
 $minitime = time();
294 294
 $minitracktime_begin = time();
295 295
 $minitracktime = $minitracktime_begin;
296 296
 $maxitime = 0;
297
-$lastupdate = filter_input(INPUT_GET,'update',FILTER_SANITIZE_NUMBER_INT);
297
+$lastupdate = filter_input(INPUT_GET, 'update', FILTER_SANITIZE_NUMBER_INT);
298 298
 $modelsdb = array();
299 299
 if (file_exists(dirname(__FILE__).'/models/modelsdb')) {
300
-	if (($handle = fopen(dirname(__FILE__).'/models/modelsdb','r')) !== FALSE) {
301
-		while (($row = fgetcsv($handle,1000)) !== FALSE) {
302
-			if (isset($row[1]) ){
300
+	if (($handle = fopen(dirname(__FILE__).'/models/modelsdb', 'r')) !== FALSE) {
301
+		while (($row = fgetcsv($handle, 1000)) !== FALSE) {
302
+			if (isset($row[1])) {
303 303
 				$model = $row[0];
304 304
 				$modelsdb[$model] = $row[1];
305 305
 			}
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
 }
310 310
 $modelsdb2 = array();
311 311
 if (file_exists(dirname(__FILE__).'/models/gltf2/modelsdb')) {
312
-	if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb','r')) !== FALSE) {
313
-		while (($row = fgetcsv($handle,1000)) !== FALSE) {
314
-			if (isset($row[1]) ){
312
+	if (($handle = fopen(dirname(__FILE__).'/models/gltf2/modelsdb', 'r')) !== FALSE) {
313
+		while (($row = fgetcsv($handle, 1000)) !== FALSE) {
314
+			if (isset($row[1])) {
315 315
 				$model = $row[0];
316 316
 				$glb = $row[1];
317 317
 				if (isset($row[2])) {
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 if (!empty($spotter_array) && is_array($spotter_array))
358 358
 {
359 359
 	$nblatlong = 0;
360
-	foreach($spotter_array as $spotter_item)
360
+	foreach ($spotter_array as $spotter_item)
361 361
 	{
362 362
 		$j++;
363 363
 		//if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND';
@@ -411,17 +411,17 @@  discard block
 block discarded – undo
411 411
 			}
412 412
 			if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
413 413
 			if (isset($spotter_item['format_source'])) $output .= '"format": "'.$spotter_item['format_source'].'",';
414
-			if (isset($spotter_item['ident'])) $output.= '"ident": '.json_encode($spotter_item['ident']).',';
414
+			if (isset($spotter_item['ident'])) $output .= '"ident": '.json_encode($spotter_item['ident']).',';
415 415
 			if ($tracker) {
416 416
 				if (isset($spotter_item['type'])) $output .= '"tracker_type": '.json_encode($spotter_item['type']).',';
417
-				$output.= '"type": "tracker"';
417
+				$output .= '"type": "tracker"';
418 418
 			} elseif ($marine) {
419 419
 				if (isset($spotter_item['type'])) $output .= '"marine_type": '.json_encode($spotter_item['type']).',';
420 420
 				if (isset($spotter_item['captain_name'])) $output .= '"captain": '.json_encode($spotter_item['captain_name']).',';
421 421
 				if (isset($spotter_item['race_id'])) $output .= '"raceid": '.$spotter_item['race_id'].',';
422 422
 				if (isset($spotter_item['race_name'])) $output .= '"race": '.json_encode($spotter_item['race_name']).',';
423 423
 				if (isset($spotter_item['race_rank'])) $output .= '"rank": "'.$spotter_item['race_rank'].'",';
424
-				$output.= '"type": "marine"';
424
+				$output .= '"type": "marine"';
425 425
 			} else {
426 426
 				if ($one3dmodel === false && isset($globalMap3DLiveries) && $globalMap3DLiveries) {
427 427
 					$aircraft_icao = $spotter_item['aircraft_icao'];
@@ -435,14 +435,14 @@  discard block
 block discarded – undo
435 435
 						if (isset($airline_icao)) {
436 436
 							$imagefile = $aircraft_icao.'-'.$airline_icao.'.png';
437 437
 							if (file_exists(dirname(__FILE__).'/models/gltf2/liveries/'.$imagefile)) {
438
-								$output.= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",';
438
+								$output .= '"liveries": "'.$globalURL.'/models/gltf2/liveries/'.$imagefile.'",';
439 439
 							}
440 440
 						}
441 441
 					}
442 442
 					//if ($ident != '') $output.= '"ident": "'.$ident.'",';
443 443
 				}
444
-				$output.= '"gltf2": %gltf2%,';
445
-				$output.= '"type": "flight"';
444
+				$output .= '"gltf2": %gltf2%,';
445
+				$output .= '"type": "flight"';
446 446
 			}
447 447
 			$output .= '},';
448 448
 
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 					$output .= '},';
818 818
 				}
819 819
 			}
820
-			if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output);
821
-			else $output = str_replace('%onground%','false',$output);
820
+			if (isset($onground) && $onground) $output = str_replace('%onground%', 'true', $output);
821
+			else $output = str_replace('%onground%', 'false', $output);
822 822
 
823 823
 	//		$output .= '"heightReference": "CLAMP_TO_GROUND",';
824 824
 			//$output .= '"heightReference": "'.$heightrelative.'",';
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
835 835
 			if (isset($_COOKIE['MapTrack']) && $id == $_COOKIE['MapTrack'] && $minitracktime > strtotime($spotter_item['date'])) $minitracktime = strtotime($spotter_item['date']);
836 836
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
837
-			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
837
+			$output .= '"'.date("c", strtotime($spotter_item['date'])).'", ';
838 838
 			$output .= $spotter_item['longitude'].', ';
839 839
 			$output .= $spotter_item['latitude'];
840 840
 			$prevlong = $spotter_item['longitude'];
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
863 863
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
864 864
 		} else {
865
-			$nblatlong = $nblatlong+1;
866
-			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
865
+			$nblatlong = $nblatlong + 1;
866
+			$output .= ',"'.date("c", strtotime($spotter_item['date'])).'", ';
867 867
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
868 868
 			if ($spotter_item['ground_speed'] == 0) {
869 869
 				$output .= $prevlong.', ';
@@ -904,26 +904,26 @@  discard block
 block discarded – undo
904 904
 $output .= ']';
905 905
 if (isset($globalArchive) && $globalArchive === TRUE) {
906 906
 	if (isset($begindateinitial)) {
907
-		$output = str_replace('%minitime%',date("c",$begindateinitial),$output);
908
-	} elseif ((time()-$globalLiveInterval) > $minitime) {
909
-		if (time()-$globalLiveInterval > $maxitime) {
910
-			$output = str_replace('%minitime%',date("c",$maxitime),$output);
907
+		$output = str_replace('%minitime%', date("c", $begindateinitial), $output);
908
+	} elseif ((time() - $globalLiveInterval) > $minitime) {
909
+		if (time() - $globalLiveInterval > $maxitime) {
910
+			$output = str_replace('%minitime%', date("c", $maxitime), $output);
911 911
 		} else {
912
-			$output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
912
+			$output = str_replace('%minitime%', date("c", time() - $globalLiveInterval), $output);
913 913
 		}
914 914
 	}
915
-	else $output = str_replace('%minitime%',date("c",$minitime),$output);
915
+	else $output = str_replace('%minitime%', date("c", $minitime), $output);
916 916
 } elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && $minitracktime != $minitracktime_begin) {
917
-	$output = str_replace('%minitime%',date("c",$minitracktime),$output);
917
+	$output = str_replace('%minitime%', date("c", $minitracktime), $output);
918 918
 } else {
919
-	$output = str_replace('%minitime%',date("c",$minitime),$output);
919
+	$output = str_replace('%minitime%', date("c", $minitime), $output);
920 920
 }
921 921
 if (isset($enddateinitial)) {
922
-	$output = str_replace('%maxitime%',date("c",$enddateinitial),$output);
922
+	$output = str_replace('%maxitime%', date("c", $enddateinitial), $output);
923 923
 } else {
924
-	$output = str_replace('%maxitime%',date("c",$maxitime),$output);
924
+	$output = str_replace('%maxitime%', date("c", $maxitime), $output);
925 925
 }
926
-if ($gltf2) $output = str_replace('%gltf2%','true',$output);
927
-else $output = str_replace('%gltf2%','false',$output);
926
+if ($gltf2) $output = str_replace('%gltf2%', 'true', $output);
927
+else $output = str_replace('%gltf2%', 'false', $output);
928 928
 print $output;
929 929
 ?>
Please login to merge, or discard this patch.
Braces   +150 added lines, -54 removed lines patch added patch discarded remove patch
@@ -26,8 +26,12 @@  discard block
 block discarded – undo
26 26
 }
27 27
 $tracker = false;
28 28
 $marine = false;
29
-if (isset($_GET['tracker'])) $tracker = true;
30
-if (isset($_GET['marine'])) $marine = true;
29
+if (isset($_GET['tracker'])) {
30
+	$tracker = true;
31
+}
32
+if (isset($_GET['marine'])) {
33
+	$marine = true;
34
+}
31 35
 if ($tracker) {
32 36
 	require_once('require/class.Tracker.php');
33 37
 	require_once('require/class.TrackerLive.php');
@@ -84,27 +88,56 @@  discard block
 block discarded – undo
84 88
 }
85 89
 header('Content-Type: text/javascript');
86 90
 
87
-if (!isset($globalJsonCompress)) $compress = true;
88
-else $compress = $globalJsonCompress;
91
+if (!isset($globalJsonCompress)) {
92
+	$compress = true;
93
+} else {
94
+	$compress = $globalJsonCompress;
95
+}
89 96
 
90 97
 $from_archive = false;
91 98
 $min = false;
92 99
 $allhistory = false;
93 100
 $filter['source'] = array();
94 101
 $limit = 0;
95
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
96
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
97
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
98
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
99
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
100
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
101
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
102
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
103
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
104
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
105
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
106
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
107
-if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') $filter['blocked'] = true;
102
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
103
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
104
+}
105
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
106
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
107
+}
108
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
109
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
110
+}
111
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
112
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
113
+}
114
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
115
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
116
+}
117
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
118
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
119
+}
120
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
121
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
122
+}
123
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
124
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
125
+}
126
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
127
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
128
+}
129
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
130
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
131
+}
132
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
133
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
134
+}
135
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') {
136
+	$filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_NUMBER_INT);
137
+}
138
+if (isset($_COOKIE['filter_blocked']) && $_COOKIE['filter_blocked'] == 'true') {
139
+	$filter['blocked'] = true;
140
+}
108 141
 
109 142
 if (isset($_COOKIE['map_3d_limit'])) {
110 143
 	$limit = filter_var($_COOKIE['map_3d_limit'],FILTER_SANITIZE_NUMBER_INT);
@@ -286,8 +319,12 @@  discard block
 block discarded – undo
286 319
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
287 320
 		}
288 321
 	}
289
-	if ($flightcnt == '') $flightcnt = 0;
290
-} else $flightcnt = 0;
322
+	if ($flightcnt == '') {
323
+		$flightcnt = 0;
324
+	}
325
+	} else {
326
+	$flightcnt = 0;
327
+}
291 328
 
292 329
 $sqltime = round(microtime(true)-$begintime,2);
293 330
 $minitime = time();
@@ -333,7 +370,9 @@  discard block
 block discarded – undo
333 370
 $gltf2 = false;
334 371
 $scale = 1.0;
335 372
 $minimumpixelsize = 20;
336
-if (isset($archivespeed)) $speed = $archivespeed;
373
+if (isset($archivespeed)) {
374
+	$speed = $archivespeed;
375
+}
337 376
 $output = '[';
338 377
 if ($tracker) {
339 378
 	$output .= '{"id" : "document", "name" : "tracker","version" : "1.0"';
@@ -369,9 +408,13 @@  discard block
 block discarded – undo
369 408
 			$image = "images/placeholder_thumb.png";
370 409
 		}
371 410
 
372
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
373
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
374
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
411
+                if (isset($spotter_item['flightaware_id'])) {
412
+                	$id = $spotter_item['flightaware_id'];
413
+                } elseif (isset($spotter_item['famtrackid'])) {
414
+                	$id = $spotter_item['famtrackid'];
415
+                } elseif (isset($spotter_item['fammarine_id'])) {
416
+                	$id = $spotter_item['fammarine_id'];
417
+                }
375 418
                 if ($prev_flightaware_id != $id) {
376 419
 			if ($prev_flightaware_id != '') {
377 420
 				/*
@@ -409,18 +452,36 @@  discard block
 block discarded – undo
409 452
 			if (isset($spotter_item['squawk'])) {
410 453
 				$output .= '"squawk": "'.$spotter_item['squawk'].'",';
411 454
 			}
412
-			if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
413
-			if (isset($spotter_item['format_source'])) $output .= '"format": "'.$spotter_item['format_source'].'",';
414
-			if (isset($spotter_item['ident'])) $output.= '"ident": '.json_encode($spotter_item['ident']).',';
455
+			if (isset($spotter_item['registration'])) {
456
+				$output .= '"registration": "'.$spotter_item['registration'].'",';
457
+			}
458
+			if (isset($spotter_item['format_source'])) {
459
+				$output .= '"format": "'.$spotter_item['format_source'].'",';
460
+			}
461
+			if (isset($spotter_item['ident'])) {
462
+				$output.= '"ident": '.json_encode($spotter_item['ident']).',';
463
+			}
415 464
 			if ($tracker) {
416
-				if (isset($spotter_item['type'])) $output .= '"tracker_type": '.json_encode($spotter_item['type']).',';
465
+				if (isset($spotter_item['type'])) {
466
+					$output .= '"tracker_type": '.json_encode($spotter_item['type']).',';
467
+				}
417 468
 				$output.= '"type": "tracker"';
418 469
 			} elseif ($marine) {
419
-				if (isset($spotter_item['type'])) $output .= '"marine_type": '.json_encode($spotter_item['type']).',';
420
-				if (isset($spotter_item['captain_name'])) $output .= '"captain": '.json_encode($spotter_item['captain_name']).',';
421
-				if (isset($spotter_item['race_id'])) $output .= '"raceid": '.$spotter_item['race_id'].',';
422
-				if (isset($spotter_item['race_name'])) $output .= '"race": '.json_encode($spotter_item['race_name']).',';
423
-				if (isset($spotter_item['race_rank'])) $output .= '"rank": "'.$spotter_item['race_rank'].'",';
470
+				if (isset($spotter_item['type'])) {
471
+					$output .= '"marine_type": '.json_encode($spotter_item['type']).',';
472
+				}
473
+				if (isset($spotter_item['captain_name'])) {
474
+					$output .= '"captain": '.json_encode($spotter_item['captain_name']).',';
475
+				}
476
+				if (isset($spotter_item['race_id'])) {
477
+					$output .= '"raceid": '.$spotter_item['race_id'].',';
478
+				}
479
+				if (isset($spotter_item['race_name'])) {
480
+					$output .= '"race": '.json_encode($spotter_item['race_name']).',';
481
+				}
482
+				if (isset($spotter_item['race_rank'])) {
483
+					$output .= '"rank": "'.$spotter_item['race_rank'].'",';
484
+				}
424 485
 				$output.= '"type": "marine"';
425 486
 			} else {
426 487
 				if ($one3dmodel === false && isset($globalMap3DLiveries) && $globalMap3DLiveries) {
@@ -471,7 +532,9 @@  discard block
 block discarded – undo
471 532
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
472 533
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
473 534
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
474
-						} else $aircraft_shadow = '';
535
+						} else {
536
+							$aircraft_shadow = '';
537
+						}
475 538
 	    					$output .= ' "billboard" : {"image" : "'.$globalURL.'/images/aircrafts/new/'.$aircraft_shadow.'","scale" : 0.5';
476 539
 						if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true' && isset($_COOKIE['IconColor'])) {
477 540
 							$rgb = $Common->hex2rgb($_COOKIE['IconColor']);
@@ -479,7 +542,9 @@  discard block
 block discarded – undo
479 542
 						}
480 543
 						$output .= '},';
481 544
 					}
482
-				} else $output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},';
545
+				} else {
546
+					$output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAA7VJREFUeNrEl2uIlWUQx39nXUu0m2uQbZYrbabdLKMs/VBkmHQjioqFIhBS+hKEQpQRgVAf2u5RQkGBRUllRH4I2e5ZUBJlEZVt5i0tTfHStrZ6fn35L70d9n7Obg88vOedmWfmf2bmmZkXlRrtq9V16mZ1iVqqhd5agXvQf1c5zw/V8dXqrqO6dQKwBrgdWApsCb0VqAc2AnOrMVANwIsD4BLgTOBPYB2wHJgEzAG+ANqAu4ZsZYiuX5QwfqI2hvaNulA9J7zLQn8o76vUuuHOwXHqSzH4aIF+TWjnBkSH+nCBf716SP1KPWO4AJ6ltgfIjRW8p9U/1KPz/ry6RT2mIDNF3Zjz19Ya4G1R/J16dgWvQd2pPlXhMdVZPUTgxfCW1wJgXUJpQlvfg8zs8K8r0Caom9QHetG7NGfa1ElDBThRXRtFd/Qh16puKIS3e7+clBjdy7kL1b3q4fzJQQGck5z6Nb97kxujblWf64HXov7Vl/E4YXWccP9AAd6dAx+ox/WTArNzY1t64B0f8K0DyLXuUvRGZfcpCo1VX4tg6wB76WMB0dALf526foAX8cqUot2pGP8B2Kz+krBeNYjS8636dh/8Beo2deoA9TWp76pd6g0q9cDNwKvAD8A84EfglLRBe2g+JWAfcEF68bPABOCoAl/gIPA5MA64FVgGnNhP292W3r0SeB1YVlJXAjcBP8XwyQUj9AKwAzg2+/fQSsBhoJxBAaALaIzenZGnD911wA7gEDAD2FFSpwOzgDHZ5T7+ZSlGd2d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 0.5},';
547
+				}
483 548
 			} elseif ($one3dmodel) {
484 549
 				if (isset($globalMap3DForceModel) && $globalMap3DForceModel != '') {
485 550
 					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$globalMap3DForceModel.'","scale" : '.$scale.',"minimumPixelSize": '.$minimumpixelsize.'';
@@ -519,7 +584,9 @@  discard block
 block discarded – undo
519 584
 							$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
520 585
 							$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
521 586
 							$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
522
-						} else $aircraft_shadow = '';
587
+						} else {
588
+							$aircraft_shadow = '';
589
+						}
523 590
 						if ($aircraft_shadow != '') {
524 591
 							if (isset($modelsdb2[$aircraft_shadow])) {
525 592
 								$output .= '"model": {"gltf" : "'.$globalURL.'/models/gltf2/'.$modelsdb2[$aircraft_shadow]['glb'].'","scale" : '.$scale.',"minimumPixelSize": '.$modelsdb2[$aircraft_shadow]['size'];
@@ -674,7 +741,9 @@  discard block
 block discarded – undo
674 741
 								}
675 742
 								$output .= '},';
676 743
 								//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
677
-								if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
744
+								if ($spotter_item['aircraft_icao'] != '') {
745
+									$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
746
+								}
678 747
 								$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
679 748
 							}
680 749
 						} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
@@ -696,7 +765,9 @@  discard block
 block discarded – undo
696 765
 							}
697 766
 							$output .= '},';
698 767
 							//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
699
-							if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
768
+							if ($spotter_item['aircraft_icao'] != '') {
769
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
770
+							}
700 771
 							$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
701 772
 						}
702 773
 					} else {
@@ -709,7 +780,9 @@  discard block
 block discarded – undo
709 780
 						}
710 781
 						$output .= '},';
711 782
 						//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
712
-						if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
783
+						if ($spotter_item['aircraft_icao'] != '') {
784
+							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
785
+						}
713 786
 						$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
714 787
 					}
715 788
 				} elseif ($tracker && isset($spotter_item['type'])) {
@@ -817,8 +890,11 @@  discard block
 block discarded – undo
817 890
 					$output .= '},';
818 891
 				}
819 892
 			}
820
-			if (isset($onground) && $onground) $output = str_replace('%onground%','true',$output);
821
-			else $output = str_replace('%onground%','false',$output);
893
+			if (isset($onground) && $onground) {
894
+				$output = str_replace('%onground%','true',$output);
895
+			} else {
896
+				$output = str_replace('%onground%','false',$output);
897
+			}
822 898
 
823 899
 	//		$output .= '"heightReference": "CLAMP_TO_GROUND",';
824 900
 			//$output .= '"heightReference": "'.$heightrelative.'",';
@@ -831,9 +907,15 @@  discard block
 block discarded – undo
831 907
 	//		$output .= '"interpolationDegree" : 5,';
832 908
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
833 909
 			$output .= '"cartographicDegrees": [';
834
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
835
-			if (isset($_COOKIE['MapTrack']) && $id == $_COOKIE['MapTrack'] && $minitracktime > strtotime($spotter_item['date'])) $minitracktime = strtotime($spotter_item['date']);
836
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
910
+			if ($minitime > strtotime($spotter_item['date'])) {
911
+				$minitime = strtotime($spotter_item['date']);
912
+			}
913
+			if (isset($_COOKIE['MapTrack']) && $id == $_COOKIE['MapTrack'] && $minitracktime > strtotime($spotter_item['date'])) {
914
+				$minitracktime = strtotime($spotter_item['date']);
915
+			}
916
+			if ($maxitime < strtotime($spotter_item['date'])) {
917
+				$maxitime = strtotime($spotter_item['date']);
918
+			}
837 919
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
838 920
 			$output .= $spotter_item['longitude'].', ';
839 921
 			$output .= $spotter_item['latitude'];
@@ -856,7 +938,9 @@  discard block
 block discarded – undo
856 938
 					$output .= ', '.round($spotter_item['altitude']*30.48);
857 939
 					$prevalt = round($spotter_item['altitude']*30.48);
858 940
 				}
859
-			} else $output .= ', 0';
941
+			} else {
942
+				$output .= ', 0';
943
+			}
860 944
 			//$orientation = '"orientation" : { ';
861 945
 			//$orientation .= '"unitQuaternion": [';
862 946
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
@@ -864,13 +948,18 @@  discard block
 block discarded – undo
864 948
 		} else {
865 949
 			$nblatlong = $nblatlong+1;
866 950
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
867
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
951
+			if ($maxitime < strtotime($spotter_item['date'])) {
952
+				$maxitime = strtotime($spotter_item['date']);
953
+			}
868 954
 			if ($spotter_item['ground_speed'] == 0) {
869 955
 				$output .= $prevlong.', ';
870 956
 				$output .= $prevlat;
871 957
 				//if (!$marine && (!isset($onground) || !$onground)) $output .= ', '.$prevalt;
872
-				if (!$marine) $output .= ', '.$prevalt;
873
-				else $output .= ', 0';
958
+				if (!$marine) {
959
+					$output .= ', '.$prevalt;
960
+				} else {
961
+					$output .= ', 0';
962
+				}
874 963
 			} else {
875 964
 				$output .= $spotter_item['longitude'].', ';
876 965
 				$output .= $spotter_item['latitude'];
@@ -883,14 +972,17 @@  discard block
 block discarded – undo
883 972
 							$output .= ', 0';
884 973
 						}
885 974
 					} else {
886
-						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') $output .= ', '.round($spotter_item['real_altitude']*0.3048);
887
-						elseif ($tracker) {
975
+						if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') {
976
+							$output .= ', '.round($spotter_item['real_altitude']*0.3048);
977
+						} elseif ($tracker) {
888 978
 							$output .= ', '.round($spotter_item['altitude']*0.3048);
889 979
 						} else {
890 980
 							$output .= ', '.round($spotter_item['altitude']*30.48);
891 981
 						}
892 982
 					}
893
-				} else $output .= ', 0';
983
+				} else {
984
+					$output .= ', 0';
985
+				}
894 986
 			}
895 987
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
896 988
 			//$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
@@ -911,9 +1003,10 @@  discard block
 block discarded – undo
911 1003
 		} else {
912 1004
 			$output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
913 1005
 		}
1006
+	} else {
1007
+		$output = str_replace('%minitime%',date("c",$minitime),$output);
914 1008
 	}
915
-	else $output = str_replace('%minitime%',date("c",$minitime),$output);
916
-} elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && $minitracktime != $minitracktime_begin) {
1009
+	} elseif (isset($_COOKIE['MapTrack']) && $_COOKIE['MapTrack'] != '' && $minitracktime != $minitracktime_begin) {
917 1010
 	$output = str_replace('%minitime%',date("c",$minitracktime),$output);
918 1011
 } else {
919 1012
 	$output = str_replace('%minitime%',date("c",$minitime),$output);
@@ -923,7 +1016,10 @@  discard block
 block discarded – undo
923 1016
 } else {
924 1017
 	$output = str_replace('%maxitime%',date("c",$maxitime),$output);
925 1018
 }
926
-if ($gltf2) $output = str_replace('%gltf2%','true',$output);
927
-else $output = str_replace('%gltf2%','false',$output);
1019
+if ($gltf2) {
1020
+	$output = str_replace('%gltf2%','true',$output);
1021
+} else {
1022
+	$output = str_replace('%gltf2%','false',$output);
1023
+}
928 1024
 print $output;
929 1025
 ?>
Please login to merge, or discard this patch.